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 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,11 +90,14 @@ 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
|
||||||
// contains a list of BoxMembers (each specifying their own type, name and box type)
|
// contains a list of BoxMembers (each specifying their own type, name and box type)
|
||||||
GArray* member;
|
GArray* member;
|
||||||
|
// box variable to access
|
||||||
|
Variable* variable;
|
||||||
AST_NODE_PTR nodePtr;
|
AST_NODE_PTR nodePtr;
|
||||||
} BoxAccess;
|
} BoxAccess;
|
||||||
|
|
||||||
|
@ -168,7 +173,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 +194,39 @@ 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;
|
||||||
|
// name of function
|
||||||
|
const char* name;
|
||||||
} 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 +251,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;
|
||||||
|
|
||||||
|
@ -238,7 +267,7 @@ typedef struct Variable_t {
|
||||||
union VariableImplementation {
|
union VariableImplementation {
|
||||||
VariableDeclaration declaration;
|
VariableDeclaration declaration;
|
||||||
VariableDefiniton definiton;
|
VariableDefiniton definiton;
|
||||||
BoxMember member;
|
BoxAccess member;
|
||||||
} impl;
|
} impl;
|
||||||
AST_NODE_PTR nodePtr;
|
AST_NODE_PTR nodePtr;
|
||||||
} Variable;
|
} Variable;
|
||||||
|
@ -258,6 +287,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 +300,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 +389,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;
|
||||||
|
|
||||||
|
@ -374,6 +406,8 @@ typedef enum ExpressionKind_t {
|
||||||
|
|
||||||
typedef struct Expression_t {
|
typedef struct Expression_t {
|
||||||
ExpressionKind kind;
|
ExpressionKind kind;
|
||||||
|
// type of resulting data
|
||||||
|
Type* result;
|
||||||
union ExpressionImplementation_t {
|
union ExpressionImplementation_t {
|
||||||
Operation operation;
|
Operation operation;
|
||||||
TypeCast typecast;
|
TypeCast typecast;
|
||||||
|
@ -471,6 +505,7 @@ typedef enum StatementKind_t {
|
||||||
} StatementKind;
|
} StatementKind;
|
||||||
|
|
||||||
typedef struct Statement_t {
|
typedef struct Statement_t {
|
||||||
|
StatementKind kind;
|
||||||
union StatementImplementation {
|
union StatementImplementation {
|
||||||
FunctionCall call;
|
FunctionCall call;
|
||||||
FunctionBoxCall boxCall;
|
FunctionBoxCall boxCall;
|
||||||
|
|
Loading…
Reference in New Issue