Merge pull request #110 from Servostar/89-implement-structs-for-parser
fixed: various implementation faults
This commit is contained in:
commit
0edf2f7b17
|
@ -69,6 +69,8 @@ typedef Type* ReferenceType;
|
|||
|
||||
typedef struct BoxType_t BoxType;
|
||||
|
||||
typedef struct Block_t Block;
|
||||
|
||||
typedef struct BoxMember_t {
|
||||
const char* name;
|
||||
Type* type;
|
||||
|
@ -88,11 +90,14 @@ typedef struct BoxType_t {
|
|||
} BoxType;
|
||||
|
||||
typedef struct Variable_t Variable;
|
||||
typedef struct Expression_t Expression;
|
||||
|
||||
typedef struct BoxAccess_t {
|
||||
// list of recursive box accesses
|
||||
// contains a list of BoxMembers (each specifying their own type, name and box type)
|
||||
GArray* member;
|
||||
// box variable to access
|
||||
Variable* variable;
|
||||
AST_NODE_PTR nodePtr;
|
||||
} BoxAccess;
|
||||
|
||||
|
@ -168,7 +173,7 @@ typedef struct ParameterDefinition_t {
|
|||
ParameterDeclaration declaration;
|
||||
// value to initalize the declaration with
|
||||
// NOTE: type of initializer and declaration MUST be equal
|
||||
TypeValue initializer;
|
||||
Expression initializer;
|
||||
AST_NODE_PTR nodePtr;
|
||||
} ParameterDefinition;
|
||||
|
||||
|
@ -189,15 +194,39 @@ typedef struct Parameter_t {
|
|||
ParameterDefinition definiton;
|
||||
} impl;
|
||||
AST_NODE_PTR nodePtr;
|
||||
} Paramer;
|
||||
} Parameter; // fix typo
|
||||
|
||||
typedef enum FunctionKind_t {
|
||||
FunctionDeclarationKind,
|
||||
FunctionDefinitionKind
|
||||
} FunctionKind;
|
||||
|
||||
typedef struct FunctionDefinition_t {
|
||||
// hashtable of parameters
|
||||
// associates a parameters name (const char*) with its parameter declaration (ParameterDeclaration)
|
||||
GArray* parameter;
|
||||
AST_NODE_PTR nodePtr;
|
||||
// body of function
|
||||
Block body;
|
||||
// name of function
|
||||
const char* name;
|
||||
} 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 |
|
||||
// '------------------------------------------------'
|
||||
|
@ -222,7 +251,7 @@ typedef struct VariableDeclaration_t {
|
|||
*/
|
||||
typedef struct VariableDefiniton_t {
|
||||
VariableDeclaration declaration;
|
||||
TypeValue initializer;
|
||||
Expression initializer;
|
||||
AST_NODE_PTR nodePtr;
|
||||
} VariableDefiniton;
|
||||
|
||||
|
@ -238,7 +267,7 @@ typedef struct Variable_t {
|
|||
union VariableImplementation {
|
||||
VariableDeclaration declaration;
|
||||
VariableDefiniton definiton;
|
||||
BoxMember member;
|
||||
BoxAccess member;
|
||||
} impl;
|
||||
AST_NODE_PTR nodePtr;
|
||||
} Variable;
|
||||
|
@ -258,6 +287,7 @@ typedef struct Variable_t {
|
|||
*/
|
||||
typedef struct TypeCast_t {
|
||||
Type targetType;
|
||||
Expression* operand;
|
||||
AST_NODE_PTR nodePtr;
|
||||
} TypeCast;
|
||||
|
||||
|
@ -270,6 +300,7 @@ typedef struct TypeCast_t {
|
|||
*/
|
||||
typedef struct Transmute_t {
|
||||
Type targetType;
|
||||
Expression* operand;
|
||||
AST_NODE_PTR nodePtr;
|
||||
} Transmute;
|
||||
|
||||
|
@ -358,6 +389,7 @@ typedef struct Operation_t {
|
|||
LogicalOperator logical;
|
||||
BitwiseOperator bitwise;
|
||||
} impl;
|
||||
Expression* operands;
|
||||
AST_NODE_PTR nodePtr;
|
||||
} Operation;
|
||||
|
||||
|
@ -374,6 +406,8 @@ typedef enum ExpressionKind_t {
|
|||
|
||||
typedef struct Expression_t {
|
||||
ExpressionKind kind;
|
||||
// type of resulting data
|
||||
Type* result;
|
||||
union ExpressionImplementation_t {
|
||||
Operation operation;
|
||||
TypeCast typecast;
|
||||
|
@ -471,6 +505,7 @@ typedef enum StatementKind_t {
|
|||
} StatementKind;
|
||||
|
||||
typedef struct Statement_t {
|
||||
StatementKind kind;
|
||||
union StatementImplementation {
|
||||
FunctionCall call;
|
||||
FunctionBoxCall boxCall;
|
||||
|
|
Loading…
Reference in New Issue