From a9a8cf8d337470bb9b4466aea9593df7f5fac776 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 6 Oct 2019 20:17:27 +0200 Subject: Implicit cast to larger size, number suffix for number bitsize --- include/ast.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'include/ast.h') diff --git a/include/ast.h b/include/ast.h index c45d4aa..f62d31f 100644 --- a/include/ast.h +++ b/include/ast.h @@ -9,6 +9,7 @@ #include "std/misc.h" #include "std/arena_allocator.h" #include "std/hash_map.h" +#include "number.h" #include "binop_type.h" #include "ssa/ssa.h" @@ -209,6 +210,7 @@ struct StructDecl { u32 fields_num_pointers; /* The total size of all fields which are of a type that have the same size on all platforms (i.e u8, i32, etc), recursive */ u32 fields_fixed_size_bytes; + bool is_signed; /* Only default arithmetic types can be signed, everything else is unsigned */ }; struct StructField { @@ -260,11 +262,7 @@ struct String { }; struct Number { - union { - i64 integer; - f64 floating; - } value; - bool is_integer; + AmalNumber value; BufferView code_ref; }; @@ -307,10 +305,7 @@ typedef struct { jmp_buf env; amal_compiler *compiler; /* Borrowed */ Parser *parser; /* Borrowed. This is the parser that belongs to the thread */ - /* - Borrowed. This is the current scope. Note that this scope can belong to another parser (and thread), - as such, @parser and scope_get_parser(@scope) parser may not be the same. - */ + /* Borrowed. This is the current scope. Note that this scope can belong to another parser (and thread) */ Scope *scope; } AstCompilerContext; @@ -336,7 +331,7 @@ void lhsexpr_init(LhsExpr *self, DeclFlag decl_flag, BufferView var_name); void assignmentexpr_init(AssignmentExpr *self, Ast *lhs_expr, Ast *rhs_expr); void import_init(Import *self, BufferView path); CHECK_RESULT int string_init(String *self, BufferView str); -void number_init(Number *self, i64 value, bool is_integer, BufferView code_ref); +void number_init(Number *self, AmalNumber *value, BufferView code_ref); void variable_init(Variable *self, BufferView name); void binop_init(Binop *self); CHECK_RESULT int if_statement_init(IfStatement *self, Scope *parent, ArenaAllocator *allocator); -- cgit v1.2.3