This repository has been archived by the owner on Aug 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
751f471
commit 427e25c
Showing
11 changed files
with
372 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# Built Binaries | ||
fusion | ||
fusion.debug | ||
beryllium.debug | ||
**/*.o | ||
|
||
# Prerequisites | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.