Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

Commit

Permalink
fix some files not being included
Browse files Browse the repository at this point in the history
  • Loading branch information
KickdeGans committed Dec 23, 2023
1 parent 751f471 commit 427e25c
Show file tree
Hide file tree
Showing 11 changed files with 372 additions and 4 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Built Binaries
fusion
fusion.debug
beryllium.debug
**/*.o

# Prerequisites
Expand Down
Binary file removed Fusion-Logo.png
Binary file not shown.
2 changes: 1 addition & 1 deletion debug/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
make:
gcc -Wall -Wpedantic -g3 -Werror -O3 -lm ../src/*.c ../src/lib/*.c ../src/core/*.c ../src/runtime/*.c ../src/compiler/*.c -o beryllium
gcc -Wall -Wpedantic -g3 -Werror -O3 -lm ../src/*.c ../src/lib/*.c ../src/core/*.c ../src/runtime/*.c ../src/compiler/*.c -o beryllium.debug
2 changes: 1 addition & 1 deletion debug/debug
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

gdb --args beryllium --debug-mode file.be
gdb --args beryllium.debug --debug-mode file.be
9 changes: 9 additions & 0 deletions libraries/beryllium/fmt.fn
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fun println(__txt__)
{
var stdout = open("/dev/stdout", "w");

if (typeof(__txt__) == string)
{
stdout.write();
}
}
13 changes: 13 additions & 0 deletions libraries/beryllium/http.fn
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fun http_get(host, addr)
{
var header = "GET ";

header = strcat(header, addr);
header = strcat(header, " HTTP/1.1\rHost: ");
header = strcat(header, host);
header = strcat(header, "\r\n\r\n");

println(header);

return http(header);
}
34 changes: 34 additions & 0 deletions libraries/beryllium/io.fn
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
global var stdout = open("/dev/stdout", "w");
global var stderr = open("/dev/stderr", "w");
global val stdin = open("/dev/stdin", "rb");

fun print(str)
{
stdout.write(str);
}
fun active_tty()
{
system("tty > /tmp/tty");
var tty_ = open("/tmp/tty", "rb");
var output = tty_.read();
close(tty_);
return output;
}
fun list_tty()
{
system("ls /dev | grep tty > /tmp/lstty");
var tty_ = open("/tmp/lstty", "rb");
var output = tty_.read();
close(tty_);
return output.split("\n");
}
global val tty = active_tty();
fun create_file(name)
{
var x = open(name, x);
close(x);
}
fun delete_file(name)
{
return system("rm ".concat(name));
}
72 changes: 72 additions & 0 deletions libraries/beryllium/math.fn
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
global val pi = 3.14159265358;

fun octets_to_srgb(red, green, blue)
{
return blue + green + (green * 255) + (red * 65536);
}
fun is_even(x)
{
return (x % 2) == 0;
}
fun is_odd(x)
{
return (x % 2) != 0;
}
fun abs(x)
{
if (x >= 0)
{
return x;
}
else
{
return x - (x * 2);
}
}
fun invert(x)
{
return x - (x * 2);
}
#fun factorial(x)
#{
# var sum = 1;
# foreach (i->x)
# {
# sum = sum * i;
# }
# return sum;
#}
fun power(x, y)
{
var sum = 1;
foreach (i -> y)
{
sum = sum * x;
}
return sum;
}
fun randrange(lower, upper)
{
var r = rand() + upper - lower;
var x = upper - lower;

x = x + 1;
r = r % x;
r = r + lower;

while (r < lower)
{
r = rand() + upper - lower;
x = upper - lower;

x = x + 1;
r = r % x;
r = r + lower;
}

return r;
}
fun sin(x)
{
return x / 90 * 1.564;
}
47 changes: 47 additions & 0 deletions libraries/beryllium/stdlib.fn
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
proc sizeof(x)
int length = 0;

foreach (i -> x)
length = length + 1;
end

return length;
end

proc contains(haystack, needle)
foreach (cc -> haystack)
if (cc == needle)
return true;
end
end

return false;
end

proc get_command_output_no_delete(command)
system(write(command, " > .command_tmp"));

return read(open(".command_tmp", fin));
end

proc get_command_output(command)
string s = get_command_output_no_delete(command);

remove(".command_tmp");

return s;
end

proc starts_with(src, key)
if (sizeof(key) > sizeof(src))
return 0;
end

for (int i = 0; i < sizeof(key); i = i + 1)
if (src[i] != key[i])
return 0;
end
end

return 1;
end
140 changes: 140 additions & 0 deletions libraries/beryllium/string.fn
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
public const var chars = {
"alpha-lower": {
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z"
},
"alpha-upper": {
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z"
},
"numbers": {
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9"
}
};
public const var lower_alpha = chars["alpha-lower"];
public const var upper_alpha = chars["alpha-upper"];
public const var numbers = chars["numbers"];
public const string whitespace = " ";
public const string nothing = "";

proc is_alpha(ch)
foreach (i -> lower_alpha)
if (ch == i)
return 1;
end
end
foreach (i -> upper_alpha)
if (ch == i)
return 1;
end
end
return 0;
end
proc is_digit(ch)
foreach (i -> numbers)
if (ch == i)
return 1;
end
end
return 0;
end

proc is_whitespace(str)
if (str == whitespace)
return 1;
end

int whitespace_count = 0;

foreach (ch -> str)
if (is_whitespace(ch))
whitespace_count = whitespace_count + 1;
end
end

return length(str) == whitespace_count;
end

proc length(str_)
if (typeof(str_) != string)
return 0;
end

int len = 0;

foreach (i -> str_)
len = len + 1;
end

return len + 1;
end

proc concat(str1, str2)
return write(str1, str2);
end

proc join(arr, sep)
string s;

foreach (i -> arr)
s = concat(s, concat(i, sep));
end

return s;
end
Loading

0 comments on commit 427e25c

Please sign in to comment.