Trying to add order indendent decls
This commit is contained in:
24
new_ast.cpp
24
new_ast.cpp
@@ -19,6 +19,7 @@ Intern_String intern_int;
|
||||
Intern_String intern_str;
|
||||
Intern_String intern_unsigned;
|
||||
|
||||
struct Ast_Package;
|
||||
struct Sym;
|
||||
struct Parse_Ctx:Lexer{
|
||||
Allocator *perm; // Stores: AST, tokens, interns
|
||||
@@ -27,6 +28,7 @@ struct Parse_Ctx:Lexer{
|
||||
U64 unique_ids;
|
||||
Map type_map;
|
||||
|
||||
Ast_Package *resolving_package;
|
||||
Map resolved;
|
||||
Map syms;
|
||||
S32 scope;
|
||||
@@ -110,10 +112,11 @@ struct Ast{
|
||||
Token *pos;
|
||||
|
||||
Ast_Kind kind;
|
||||
bool is_stmt: 1;
|
||||
bool is_expr: 1;
|
||||
bool is_decl: 1;
|
||||
bool is_named: 1;
|
||||
// @todo?
|
||||
// bool is_stmt: 1;
|
||||
// bool is_expr: 1;
|
||||
// bool is_decl: 1;
|
||||
// bool is_named: 1;
|
||||
};
|
||||
|
||||
struct Ast_Resolved_Type;
|
||||
@@ -128,8 +131,7 @@ struct Ast_Atom: Ast_Expr{
|
||||
};
|
||||
|
||||
struct Ast_Compound_Item: Ast_Expr{
|
||||
// @todo: Ast_Expr to Ast_Atom
|
||||
Ast_Expr *name; // index | name
|
||||
Ast_Atom *name; // index | name
|
||||
Ast_Expr *index;
|
||||
Ast_Expr *item;
|
||||
};
|
||||
@@ -215,19 +217,18 @@ struct Ast_Named:Ast{
|
||||
};
|
||||
|
||||
struct Ast_Var: Ast_Named{
|
||||
Intern_String name;
|
||||
Ast_Typespec *typespec;
|
||||
Ast_Expr *expr;
|
||||
};
|
||||
|
||||
struct Ast_Const: Ast_Named{
|
||||
Intern_String name;
|
||||
Ast_Expr *expr;
|
||||
};
|
||||
|
||||
struct Ast_Package:Ast{
|
||||
Intern_String name;
|
||||
Array<Ast_Named *> decls;
|
||||
Array<Ast_Named *> ordered;
|
||||
};
|
||||
|
||||
function Ast_Typespec *ast_typespec_name(Token *pos, Intern_String name);
|
||||
@@ -279,7 +280,7 @@ ast_expr_compound(Token *pos, Ast_Typespec *typespec, Array<Ast_Compound_Item *>
|
||||
}
|
||||
|
||||
function Ast_Compound_Item *
|
||||
ast_expr_compound_item(Token *pos, Ast_Expr *index, Ast_Expr *name, Ast_Expr *item){
|
||||
ast_expr_compound_item(Token *pos, Ast_Expr *index, Ast_Atom *name, Ast_Expr *item){
|
||||
AST_NEW(Compound_Item, AST_COMPOUND_ITEM, pos);
|
||||
result->name = name;
|
||||
result->index = index;
|
||||
@@ -425,7 +426,8 @@ ast_const(Token *pos, Intern_String name, Ast_Expr *expr){
|
||||
function Ast_Package *
|
||||
ast_package(Token *pos, String name, Array<Ast_Named *> decls){
|
||||
AST_NEW(Package, AST_PACKAGE, pos);
|
||||
result->decls = decls.tight_copy(pctx->perm);
|
||||
result->name = intern_string(&pctx->interns, name);
|
||||
result->decls = decls.tight_copy(pctx->perm);
|
||||
result->ordered = array_make<Ast_Named *>(pctx->perm, decls.len);
|
||||
result->name = intern_string(&pctx->interns, name);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user