Commit Graph

95 Commits

Author SHA1 Message Date
Luna 34481c8ea8 main: call gcc to make out executable 2019-09-29 13:16:49 -03:00
Luna 88e505b524 parser: rename main function to __rayoko_main 2019-09-29 12:46:31 -03:00
Luna f00741deca add main() to example 2019-09-29 12:03:17 -03:00
Luna f84eb16490 codegen: emit Store for Assign exprs 2019-09-29 11:41:16 -03:00
Luna 5d8efd657f analysis: add analysis of Assign expressions 2019-09-28 22:48:59 -03:00
Luna 2fea745df4 codegen: use current_scope's meta_map instead of resolveVarType 2019-09-28 22:18:22 -03:00
Luna f2520e7d02 change bits and pieces everywhere about var meta 2019-09-28 22:16:33 -03:00
Luna a95d0e7fd8 comp_ctx: make resolveVarType's return type be nullable
- add a parameter to prevent unwanted side-effects of resolveVarType
 - add basics of resolving scope variables
2019-09-28 21:30:52 -03:00
Luna 182d831408 comp_ctx: use more pointers to variable metadata 2019-09-28 20:52:45 -03:00
Luna ea4dd5fde4 move to llvm 9
- comp_ctx: add VariableMetadata.llvm_alloca
 - comp_ctx: make VariableMetadataMap use ptrs to VariableMetadata
2019-09-28 20:40:07 -03:00
Luna 9869cca2ae remove mutability/publicability
i may implement those in a better way, which isn't V's
2019-09-28 18:09:58 -03:00
Luna c7920246a5 codegen: add emitting of unary exprs 2019-09-28 17:58:17 -03:00
Luna 3d47c0cca8 parser: fix unary operators causing stack overflow 2019-09-28 17:52:30 -03:00
Luna 65a9e58a9a emit a store for the stack fn arguments 2019-09-28 13:40:11 -03:00
Luna 21dcb3e65d codegen: emit load instruction for (now-stack) params
- comp_ctx: make ParameterMap use ptrs to Parameter
2019-09-28 13:30:05 -03:00
Luna 518d2daeb4 Merge branch 'master' of https://gitdab.com/luna/rayoko 2019-09-28 13:18:28 -03:00
Luna a136a377ce change symbol table to use pointers to heap allocated symbols 2019-09-28 13:17:11 -03:00
Luna 93811c986d codegen: use Parameter.llvm_alloca 2019-09-28 12:46:23 -03:00
Luna 61c8493484 add basics of stack-stored arguments
this requires some changes regarding the const-ability of the passed
nodes into codegen.
2019-09-28 11:40:56 -03:00
Luna 58713b20e3 add llvmvalueref to Parameter 2019-09-28 11:32:36 -03:00
Luna 178acc656f codegen: allow for mutable statements
- ast: add llvm_alloca llvmvalueref pointer in VarDeclStmt
2019-09-28 11:30:21 -03:00
Luna 81fd718403 codegen: emit vardecl initializer 2019-09-27 22:49:33 -03:00
Luna d235ce0d13 add codegen for allocating vardecls onto stack (not init yet)
codegen pass needs type information about the variable. thankfully,
analyze pass already did the hard work for it, and scope info has types
of all its declared names. we use that info to generate the alloca

to have information about which current scope we are, we add a "child
index" to scopes so we can repoint current context at them instead of
bumpScope(), which always creates new, empty ones.

initializer exprs are next
2019-09-27 22:36:35 -03:00
Luna 77c88fad34 update readme with usage instructions 2019-09-27 21:23:11 -03:00
Luna dfb7989123 add necessary hello.c code as we dont have linking step 2019-09-27 21:22:03 -03:00
Luna 849bbc0e94 add support for resolving parameters in function body 2019-09-27 20:39:16 -03:00
Luna 3f48be3420 codegen: prepare for variable emitting 2019-09-27 17:18:38 -03:00
Luna 7def9abc5a add "variable metadata"
this is inserted in the analysis pass into a map from expr ptrs to
metadata in the compilation context itself, this enables codegen to
fetch that metadata with the expr pointer

the other approach was embedding it into the variable expr itself (as
seen by VariableExpr), but that causes a compiler crash
2019-09-27 17:08:01 -03:00
Luna 362fc7e3ef analysis: add name type resolution
this only adds resolution for the types. for the actual metadata, such
as e.g parameters, that isn't available, so codegen isn't helped by
this.
2019-09-27 15:12:30 -03:00
Luna 4346636cfa analysis: add check for call expr's arguments 2019-09-27 14:31:59 -03:00
Luna 3f94082477 analyze: make VarDecl statements insert symbols to current scope 2019-09-27 14:07:42 -03:00
Luna 466243fc2b add checking of numeric types around boolean operators 2019-09-27 13:49:53 -03:00
Luna 68b9855309 remove _start from examples/hello.ry 2019-09-27 13:40:05 -03:00
Luna 86c7f7dd6a comp_ctx: remove Environment in favor of UnderlyingTypeMap 2019-09-27 13:39:04 -03:00
Luna a081de93ce comp_ctx: remove isSymUnTypeEnumSubset 2019-09-27 12:08:25 -03:00
Luna 7e41d03eb9 add proper Integer32 and Integer64 literals 2019-09-27 12:07:20 -03:00
Luna 76d888bde8 analysis: create err ctx buffer on init()
- do better error message for resolveGlobalType
2019-09-27 10:47:34 -03:00
Luna c3d3486163 rename types.zig to analysis.zig 2019-09-27 00:00:06 -03:00
Luna 2cb328c3f9 analysis: ensure Get.name exists in enum 2019-09-26 22:27:05 -03:00
Luna 6543884366 analysis: add check of composite types (structs and enums)
- analysis: add bool check for loop condition exprs
2019-09-26 22:22:11 -03:00
Luna dfb954c39c analysis: insert "incomplete" function as soon as possible
by inserting it before we analyze statements, we allow ourselves to
analyze statements *with the data we already have*, for example, we can
now check the return statements' type, and see if it matches with the
functions' declared return type.

this is done via setting CompilationContext.cur_function on insertFn()

 - don't just ignore function analysis if its incomplete, do an error
2019-09-26 22:00:32 -03:00
Luna 093a8003b6 ast_printer: fix children printing
- add scope ids for debug purposes
 - add children to parent on Scope.createChild
 - types: add validation of if's condition expr type
 - types: add scopes to ifs
2019-09-26 21:36:26 -03:00
Luna fc9f5d9ce0 add get expr analysis
- rename GetExpr.struc to GetExpr.target
2019-09-26 18:03:39 -03:00
Luna 64e39a6f1e ast_printer: print scopes inside functions
- comp_ctx: add children attr for debug info
2019-09-26 16:58:57 -03:00
Luna 97c2437d97 add basic business logic for scopes 2019-09-26 16:04:11 -03:00
Luna e91c2dfdaf fix errs 2019-09-26 14:32:23 -03:00
Luna ae27995eb6 add rudimentary type analysis for return, if, loop 2019-09-26 14:23:15 -03:00
Luna 8065d0d905 s/nodePass/stmtPass 2019-09-26 00:12:47 -03:00
Luna bf035abadf add lots of TODOs for variables and type analysis of statements
- comp_ctx: replace Function.symbols to Function.env
2019-09-26 00:11:48 -03:00
Luna 45275d73db change variable declarations to statements
doing them as expressions was a hack since no 'var' keyword,
also, yeet the := operator from the parser.
2019-09-25 22:22:13 -03:00