fixed: various implementation faults

fixed typo of parameter
added function struct to group their declaration and definitons
added block to function definiton
added operands to cast and operators
This commit is contained in:
Sven Vogel 2024-05-28 00:12:32 +02:00
parent 9a5f392b67
commit 0d1f312ae2
1 changed files with 31 additions and 3 deletions

View File

@ -69,6 +69,8 @@ typedef Type* ReferenceType;
typedef struct BoxType_t BoxType; typedef struct BoxType_t BoxType;
typedef struct Block_t Block;
typedef struct BoxMember_t { typedef struct BoxMember_t {
const char* name; const char* name;
Type* type; Type* type;
@ -88,6 +90,7 @@ typedef struct BoxType_t {
} BoxType; } BoxType;
typedef struct Variable_t Variable; typedef struct Variable_t Variable;
typedef struct Expression_t Expression;
typedef struct BoxAccess_t { typedef struct BoxAccess_t {
// list of recursive box accesses // list of recursive box accesses
@ -168,7 +171,7 @@ typedef struct ParameterDefinition_t {
ParameterDeclaration declaration; ParameterDeclaration declaration;
// value to initalize the declaration with // value to initalize the declaration with
// NOTE: type of initializer and declaration MUST be equal // NOTE: type of initializer and declaration MUST be equal
TypeValue initializer; Expression initializer;
AST_NODE_PTR nodePtr; AST_NODE_PTR nodePtr;
} ParameterDefinition; } ParameterDefinition;
@ -189,15 +192,37 @@ typedef struct Parameter_t {
ParameterDefinition definiton; ParameterDefinition definiton;
} impl; } impl;
AST_NODE_PTR nodePtr; AST_NODE_PTR nodePtr;
} Paramer; } Parameter; // fix typo
typedef enum FunctionKind_t {
FunctionDeclarationKind,
FunctionDefinitionKind
} FunctionKind;
typedef struct FunctionDefinition_t { typedef struct FunctionDefinition_t {
// hashtable of parameters // hashtable of parameters
// associates a parameters name (const char*) with its parameter declaration (ParameterDeclaration) // associates a parameters name (const char*) with its parameter declaration (ParameterDeclaration)
GArray* parameter; GArray* parameter;
AST_NODE_PTR nodePtr; AST_NODE_PTR nodePtr;
// body of function
Block body;
} FunctionDefinition; } FunctionDefinition;
typedef struct FunctionDeclaration_t {
// hashtable of parameters
// associates a parameters name (const char*) with its parameter declaration (ParameterDeclaration)
GArray* parameter;
AST_NODE_PTR nodePtr;
} FunctionDeclaration;
typedef struct Function_t {
FunctionKind kind;
union FunctionImplementation {
FunctionDefinition definition;
FunctionDeclaration declaration;
} impl;
} Function;
// .------------------------------------------------. // .------------------------------------------------.
// | Variables | // | Variables |
// '------------------------------------------------' // '------------------------------------------------'
@ -222,7 +247,7 @@ typedef struct VariableDeclaration_t {
*/ */
typedef struct VariableDefiniton_t { typedef struct VariableDefiniton_t {
VariableDeclaration declaration; VariableDeclaration declaration;
TypeValue initializer; Expression initializer;
AST_NODE_PTR nodePtr; AST_NODE_PTR nodePtr;
} VariableDefiniton; } VariableDefiniton;
@ -258,6 +283,7 @@ typedef struct Variable_t {
*/ */
typedef struct TypeCast_t { typedef struct TypeCast_t {
Type targetType; Type targetType;
Expression* operand;
AST_NODE_PTR nodePtr; AST_NODE_PTR nodePtr;
} TypeCast; } TypeCast;
@ -270,6 +296,7 @@ typedef struct TypeCast_t {
*/ */
typedef struct Transmute_t { typedef struct Transmute_t {
Type targetType; Type targetType;
Expression* operand;
AST_NODE_PTR nodePtr; AST_NODE_PTR nodePtr;
} Transmute; } Transmute;
@ -358,6 +385,7 @@ typedef struct Operation_t {
LogicalOperator logical; LogicalOperator logical;
BitwiseOperator bitwise; BitwiseOperator bitwise;
} impl; } impl;
Expression* operands;
AST_NODE_PTR nodePtr; AST_NODE_PTR nodePtr;
} Operation; } Operation;