add MemoryAddress primtiive type
parent
506ee9ecad
commit
61344f5b60
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -74,7 +74,8 @@ typedef enum
|
|||
UInt,
|
||||
Float,
|
||||
Double,
|
||||
String
|
||||
String,
|
||||
MemoryAddress
|
||||
} PrimitiveType;
|
||||
|
||||
typedef union
|
||||
|
|
|
@ -204,6 +204,9 @@ static LLVMTypeRef WraithTypeToLLVMType(PrimitiveType type)
|
|||
case Bool:
|
||||
return LLVMInt1Type();
|
||||
|
||||
case MemoryAddress:
|
||||
return LLVMInt64Type();
|
||||
|
||||
case Void:
|
||||
return LLVMVoidType();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue