diff --git a/generators/wraith.lex b/generators/wraith.lex index 44df0a7..e6ed085 100644 --- a/generators/wraith.lex +++ b/generators/wraith.lex @@ -12,6 +12,7 @@ "double" return DOUBLE; "string" return STRING; "bool" return BOOL; +"MemoryAddress" return MEMORYADDRESS; "struct" return STRUCT; "return" return RETURN; "static" return STATIC; diff --git a/generators/wraith.y b/generators/wraith.y index b3d4d57..a329697 100644 --- a/generators/wraith.y +++ b/generators/wraith.y @@ -25,6 +25,7 @@ extern FILE *yyin; %token DOUBLE %token STRING %token BOOL +%token MEMORYADDRESS %token STRUCT %token RETURN %token STATIC @@ -108,6 +109,10 @@ BaseType : VOID { $$ = MakePrimitiveTypeNode(Bool); } + | MEMORYADDRESS + { + $$ = MakePrimitiveTypeNode(MemoryAddress); + } | Identifier { $$ = MakeCustomTypeNode(yytext); diff --git a/generic.w b/generic.w index 52e9d3c..04f52eb 100644 --- a/generic.w +++ b/generic.w @@ -13,7 +13,7 @@ struct Program { static Main(): int { x: int = 4; y: int = Foo.Func(x); - addr: uint = @malloc(y); + addr: MemoryAddress = @malloc(y); @free(addr); return x; } diff --git a/src/ast.c b/src/ast.c index 7901bbc..12d5677 100644 --- a/src/ast.c +++ b/src/ast.c @@ -499,6 +499,8 @@ static const char *PrimitiveTypeToString(PrimitiveType type) return "UInt"; case Bool: return "Bool"; + case MemoryAddress: + return "MemoryAddress"; case Void: return "Void"; } @@ -728,6 +730,12 @@ void PrintNode(Node *node, uint32_t tabCount) PrintNode(node->structDeclaration.declarationSequence, tabCount + 1); return; + case SystemCall: + printf("\n"); + PrintNode(node->systemCall.identifier, tabCount + 1); + PrintNode(node->systemCall.argumentSequence, tabCount + 1); + return; + case Type: printf("\n"); PrintNode(node->type.typeNode, tabCount + 1); diff --git a/src/ast.h b/src/ast.h index 977262b..65392a8 100644 --- a/src/ast.h +++ b/src/ast.h @@ -74,7 +74,8 @@ typedef enum UInt, Float, Double, - String + String, + MemoryAddress } PrimitiveType; typedef union diff --git a/src/codegen.c b/src/codegen.c index dcd1d53..a1421b2 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -204,6 +204,9 @@ static LLVMTypeRef WraithTypeToLLVMType(PrimitiveType type) case Bool: return LLVMInt1Type(); + case MemoryAddress: + return LLVMInt64Type(); + case Void: return LLVMVoidType(); }