nitrix
8b17ced533
Build: Set Java to verison 17
2023-03-21 22:43:40 +01:00
nitrix
bacc40d844
GenASM: Make sure the stack is 16 byte aligned before calling malloc or free.
...
The GenASM visitor only uses quad mnemonics so each manipulation to the stack is done in 8 byte chunks. This means our stack is always 8 byte aligned which is fine when only calling KLang code. libc functions like 'malloc' or 'free' require the stack to be 16 byte aligned which isn't automatically guaranteed when being 8 byte aligned. This is why we need to be careful when manipulating the stack (e.g. pushq, popq, subq x, %rsp). By assuming that we are stack aligned at the beginning of execution and by tracking the number of pushq operations we can deduce whether we misaligned the stack and align it again by adding another 8 byte to the stack.
This re-alignment of the stack is done directly before entering a function body or calling malloc. Since there are no stack manipulations involved when generating the code to calling 'free' there is reason to check for alignment there.
2023-03-21 22:21:14 +01:00
nitrix
f38bd3d69e
GenASM: Use leave instead of mov and pop for returning from a function.
2023-03-21 00:22:11 +01:00
nitrix
e835bd0f06
GenASM: Make GenASM quietly rewrite a user's function if it's called main.
...
We generate our own main function that executes the user's specified expression at the end of his file. This auto generated function has to be called "main" in order for it to be executed on startup. If the user chooses to call one of his own functions "main" our auto generated function would collide with the user's function. That's why we quietly rewrite the user's function to "main_by_user". This way we prevent a collision.
Note for the future: We should change our Syntax to allow for no expression as the last definition of a file. This way the user can choose if a particular source file needs to contain a main function or not (just like c does it). This is also one of the requirements for modules to work.
2023-03-20 21:05:24 +01:00
nitrix
ea1c04ae0a
Build: Add a main manifest attribute to the generated jar.
...
This makes it possible to directly execute the packaged jar.
2023-03-20 19:55:37 +01:00
nitrix
198bd74a47
Enums: Make the EnumAccessExpression save a reference to the EnumValue it is referencing.
...
This can be used during assembler generation to easily find the correct EnumValue for a given EnumAccessExpression.
2023-03-20 19:54:48 +01:00
nitrix
0594542167
Enums: Make EnumDefinition use EnumValues instead of Strings as children.
...
This allows us to store the index of the enum value along the name. The index can be used to compare two enum values in assembler.
Later on this might be used to enable users of KLang to set arbitrary values as the index of an enum value.
2023-03-20 19:30:07 +01:00
nitrix
77fe360ffa
Evaluate: Implement evaluation for enums.
2023-03-20 19:10:40 +01:00
nitrix
55a5b8f54a
Make sure that a variable that references an enum has to be initialized.
2023-03-16 00:01:31 +01:00
nitrix
2768b4429c
Check that a struct field name of a struct declaration does not shadow an enum or a struct definition.
2023-03-15 23:48:57 +01:00
nitrix
30dfbbbbba
Check that a variable name of variable declaration does not shadow an enum definition.
2023-03-15 23:33:12 +01:00
nitrix
f77d6a002d
Check that a parameter name of a function definition does not shadow an enum definition.
2023-03-15 23:17:43 +01:00
nitrix
22634c9652
Use LinkedHashMaps and LinkedHashSets to preserve the order of parameters and struct fields.
2023-03-15 23:08:38 +01:00
nitrix
6fd3f5a2e6
Make it possible to use an enum in an expression (i.e. selecting one of the enum values: Foo.A)
2023-03-15 19:14:04 +01:00
nitrix
3b928d621b
Refactor FunctionDefinition and Parameter context analysis and extend the type check to include enums.
2023-03-15 17:47:58 +01:00
nitrix
9a58afb550
Implement StructField type checking in ContextAnalysis.
2023-03-15 17:21:35 +01:00
nitrix
6e4431652c
Remove FunctionInformation and replace it with FunctionDefinition.
2023-03-15 16:19:42 +01:00
nitrix
7af815042b
WIP: Add enum support
2023-03-15 15:56:42 +01:00
nitrix
7c40a50196
add intellij config files
2023-03-15 05:23:09 +01:00
nitrix
221b928d0e
push all args onto stack before moving them into the local var to ensure that the function parameters can be used in the tail recursive function call
2020-03-10 12:07:55 +01:00
nitrix
fd17a25f29
add section explaining structs
2020-03-09 23:18:46 +01:00
nitrix
5a5191612e
visit block first because the condition variable may be initialized inside the block
2020-03-09 23:04:55 +01:00
nitrix
ac870460e6
use ubuntu, install maven
2020-03-09 22:03:01 +01:00
nitrix
da56e1c05e
try maven:latest as base image
2020-03-09 21:55:47 +01:00
nitrix
ba17c7e2b6
fix typo
2020-03-09 21:50:06 +01:00
nitrix
d6c0131d8f
add test parser test, rename test to test compilation
2020-03-09 21:46:52 +01:00
nitrix
d90581f0cd
add new target testJava to execute the junit tests
2020-03-09 21:46:31 +01:00
nitrix
6714d2136d
do not run tests when building the project
2020-03-09 21:43:26 +01:00
nitrix
fe9c9b79b8
add test directory to settings
2020-03-09 21:40:45 +01:00
nitrix
89ec828499
remove unused import
2020-03-09 21:32:40 +01:00
nitrix
9df0da89ff
implement junit tests
2020-03-09 21:32:05 +01:00
nitrix
649e690ac4
add junit
2020-03-09 21:31:54 +01:00
nitrix
6d60dcc4a3
add option to surpress illegal relfective access warning
2020-03-09 21:31:45 +01:00
nitrix
35de3c7de4
implement test for tail call optimization
2020-03-09 17:10:50 +01:00
nitrix
5701d3e918
add TCO to readme, add floats
2020-03-09 16:13:44 +01:00
nitrix
704e6441ca
move float result into rax before further processing
2020-03-09 16:09:15 +01:00
nitrix
cb5ceafbbc
implement tail recursion call optimization when generation function call
2020-03-09 15:58:15 +01:00
nitrix
d96b083c41
add metadata to class fields during visit of function definition nodes
2020-03-09 15:57:37 +01:00
nitrix
acaa37b3b1
implement detection of tail calls
2020-03-09 15:55:23 +01:00
nitrix
d1cf626934
add flag to indicate whether this is a tail call
2020-03-09 15:55:01 +01:00
nitrix
ac6cb22e45
delete print statement
2020-03-09 14:19:43 +01:00
nitrix
14f80b46cc
remove whitespace
2020-03-09 14:12:19 +01:00
nitrix
4a9e5c30e1
implement test_expected functions for all types in use
2020-03-09 14:10:35 +01:00
nitrix
0adb9e22da
implement print function for struct addresses and bools
2020-03-09 14:10:03 +01:00
nitrix
1f8de66751
update the struct test so that field c of the test struct is of type double
2020-03-09 13:49:09 +01:00
nitrix
fc16663dae
make floats work in structs
2020-03-09 13:48:31 +01:00
nitrix
31330db676
replace DOT with PERIOD
2020-03-09 12:53:26 +01:00
nitrix
8bb912b377
implement isNumericType
2020-03-09 12:51:28 +01:00
nitrix
3b5dc43cfb
implement test functions
2020-03-09 12:49:09 +01:00
nitrix
08398e4064
add struct test function prototype
2020-03-09 12:48:31 +01:00
nitrix
b776ac00e3
call struct tests
2020-03-09 12:48:31 +01:00
nitrix
9adc48da82
implement struct tests
2020-03-09 12:48:31 +01:00
nitrix
1403e0a231
fix indices
2020-03-09 12:48:31 +01:00
nitrix
02666a9459
implement visitors
2020-03-09 12:48:31 +01:00
nitrix
32cb06cd51
implement method that returns the index of a field by name
2020-03-09 12:48:31 +01:00
nitrix
e3d8f3cfa7
implement field access visitor
2020-03-09 12:48:31 +01:00
nitrix
90ed033943
implement fielfd assignment node
2020-03-09 12:48:31 +01:00
nitrix
ed4c901c6c
add field assignment to statements
2020-03-09 12:48:31 +01:00
nitrix
86e77d1609
update the struct definition when following the path
2020-03-09 12:48:31 +01:00
nitrix
eb75cc7838
implement GenASM for structs
2020-03-09 12:48:31 +01:00
nitrix
e2986b3d65
add the struct name to the struct field access expression node
2020-03-09 12:48:31 +01:00
nitrix
1693eb6426
implement helper functions to determine the struct size and field offsets
2020-03-09 12:48:31 +01:00
nitrix
622be803cc
add structs to the constructor params of GenASM
2020-03-09 12:48:31 +01:00
nitrix
3f18fa56c2
add struct definitions as a constructor parameter
2020-03-09 12:48:31 +01:00
nitrix
a9ab8f08e6
implement structs
2020-03-09 12:47:44 +01:00
nitrix
bc5efde8c5
add the retrieved structs to the constructor call of the eval visitor
2020-03-09 12:47:44 +01:00
nitrix
edaa686a2a
add method to get the value as a struct
2020-03-09 12:47:44 +01:00
nitrix
b9569c7df6
add missing semicolong since a destructor call is now a statement
2020-03-09 12:47:02 +01:00
nitrix
86fe676492
rename method to match new grammar
2020-03-09 12:47:02 +01:00
nitrix
64634a0d4d
move destructor call from expressions to statements
2020-03-09 12:47:02 +01:00
nitrix
3fb350ad31
make destructor call inherit from statement
2020-03-09 12:47:02 +01:00
nitrix
d89c085ecc
implement context analysis for destructor node
2020-03-09 12:47:02 +01:00
nitrix
9300e37fca
implement node visitors for the destructor node
2020-03-09 12:47:02 +01:00
nitrix
995fac20c5
create node that represents a destructor call
2020-03-09 12:47:02 +01:00
nitrix
31460860d5
add a destructor call to the grammar
2020-03-09 12:47:02 +01:00
nitrix
441466c83f
next time check before commiting everything...
2020-03-09 12:47:02 +01:00
nitrix
80deae6971
implement visitors for null atom
2020-03-09 12:47:02 +01:00
nitrix
2f425944e5
implement null node
2020-03-09 12:47:02 +01:00
nitrix
8ebbd6ae54
implement null type
2020-03-09 12:47:02 +01:00
nitrix
9d83e5425d
add a null literal
2020-03-09 12:46:13 +01:00
nitrix
5c0459c5a2
implement constructor call, eval and genasm are still stubs
2020-03-09 12:45:16 +01:00
nitrix
317c2c52ca
add constructor call expression to the grammar
2020-03-09 12:45:16 +01:00
nitrix
19daaa63af
use GetStructNames instead of collecting the names in GetStructs
2020-03-09 12:45:16 +01:00
nitrix
a79a2332a1
implement visitor to collect all struct names
2020-03-09 12:45:16 +01:00
nitrix
f0b6f052d6
implement pretty print for struct field access expression
2020-03-09 12:45:16 +01:00
nitrix
1ca3f5ca8b
implement context analysis for struct field access expressions
2020-03-09 12:45:16 +01:00
nitrix
6a7eb8fde2
make GetStructs collect the complete struct definitions
2020-03-09 12:45:16 +01:00
nitrix
a969aa895f
make GetStructs collect the complete struct definitions
2020-03-09 12:45:16 +01:00
nitrix
fef397c60d
implement empty visitors
2020-03-09 12:43:25 +01:00
nitrix
e873e211c9
implement node for struct field access expression
2020-03-09 12:43:25 +01:00
nitrix
304891adb8
add struct field access expression
2020-03-09 12:43:25 +01:00
nitrix
233894fbcf
remove NYI errors, check if a struct is defined if the declared type is not primitive
2020-03-09 12:43:25 +01:00
nitrix
6981c288e6
implement context analysis
2020-03-09 12:43:25 +01:00
nitrix
33904a3c33
implement pretty print visitor
2020-03-09 12:41:52 +01:00
nitrix
279ea28a29
add empty stubs for the visit method of the new nodes
2020-03-09 12:41:52 +01:00
nitrix
15c55ed065
add the new nodes to the list of visitable nodes
2020-03-09 12:41:52 +01:00
nitrix
309fe39c01
implement get vars visitor
2020-03-09 12:41:52 +01:00
nitrix
fd7f7c39bb
implement a visitor that collects the names of all structs that were defined
2020-03-09 12:41:52 +01:00
nitrix
b5086b44f0
return a struct type if no primitive type with the given name was found
2020-03-09 12:41:52 +01:00
nitrix
e971b8b91e
create a new type class that represents the type of a struct
2020-03-09 12:40:59 +01:00