-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfo.txt
94 lines (82 loc) · 3.57 KB
/
info.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Toast Compiler project
The goal of bftoast is to have a high level statically typed language that compiles to size optimized brainfuck.
Stack managment:
Every object used in bftoast gets pushed to the right of the stack
There are two types of objects on the stack:
Static objects:
These objects either have a known size at compile time or are finalized
For example ints
Dynamic objects:
These objects can dynamically grow on the stack to the right
For example strings and arrays
Issues happen when multiple dynamic objects need to exist at the same time since obviously you cant have two strings expanding infinitely in the same place
To allow multiple dynamic objects at once, multiple stacks are multiplexed together as one dynamic object on the end of the parent stack
Code running on the child stacks just has its seek commands multiplied
Life-cycle analysis:
This is a somewhat needed optimization feature because once a dynamic object is finalized the space after it
can be used by later objects down the line, without it the stack would get multiplexed for every single dynamic object
allocated in a scope
Tasks:
Tasks are internal structures that allow the program to have non-inlined functions
Recursive functions are also possible by pushing
The objects the task uses to manage functions:
array<int> call stack
container frame stack
Default functions:
print(str) -- outputs text appending a newline
write(str) -- outputs text without a newline
read(int) -- reads a number of characters
readline() -- reads up to a newline
sizeof(...) -- gets size of object
bf(...) -- executes brainfuck code
Default types:
cell -- a single cell unit
short -- 2 cells
int -- 4 cells
I have switched away from a variable sized int<n> type because it would require
a lot more work implementing the following for all the internal types
string -- simple null-terminated string
array<t> -- dynamic array holding up to 256 values of type t
bigarray<t> -- like array but can hold 65536 values
func<params><returns> -- pointer to function in the current task
container -- arbitrary container usually holding unseekable types
Syntax:
number -- number constant
"string" -- string constant
'c' -- char constant
qualifier typename -- type qualifiers
typename -- simple type
typename<...> -- type with template parameters
statement; -- statements end with semicolons to prevent ambiguity
Type qualifiers:
const -- constant value
final -- value does not change
constexpr -- code is emulated at compile-time
Statements:
typename foo; -- decleration
foo = ...; -- definition
typename foo = ...; -- decleration + definition
[typename,...] func([typename foo, ...]) statement; -- function definition
foo(...); -- function call
(...)(...); -- dynamic function call
if (...) statement; -- if statement
while (...) statement; -- while loop
Operators:
x ^ y -- exponent
not x , !x -- logical not
-x -- negative
x ~ y -- xor
x * y -- multiply
x / y -- divide
x + y -- add
x - y -- subtract
x .. y -- concat
x < y -- less than
x > y -- greater than
x <= y -- less or equal
x >= y -- greater or equal
x != y, x ~= y -- not equal
x == y -- equal
x and y, x && y -- logical and
x or y, x || y -- logical or
x ? y : z -- ternary