diff --git a/resources/examples/fasta.c3 b/resources/examples/fasta.c3 index 3f425e06a..4c2d1aa23 100644 --- a/resources/examples/fasta.c3 +++ b/resources/examples/fasta.c3 @@ -6,7 +6,7 @@ const IA = 3877; const IC = 29573; const SEED = 42; -global uint seed = SEED; +uint seed = SEED; fn float fasta_rand(float max) { @@ -14,7 +14,7 @@ fn float fasta_rand(float max) return max * seed / IM; } -private global char[] alu = +private char[] alu = "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" @@ -24,8 +24,8 @@ private global char[] alu = "AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA"; -global char[] iub = "acgtBDHKMNRSVWY"; -global double[] iub_p = { +char[] iub = "acgtBDHKMNRSVWY"; +double[] iub_p = { 0.27, 0.12, 0.12, @@ -42,8 +42,8 @@ global double[] iub_p = { 0.02, 0.02 }; -global char[] homosapiens = "acgt"; -global double[] homosapiens_p = { +char[] homosapiens = "acgt"; +double[] homosapiens_p = { 0.3029549426680, 0.1979883004921, 0.1975473066391, diff --git a/resources/examples/notworking/acornvm/avm_stack.c3 b/resources/examples/notworking/acornvm/avm_stack.c3 index 9f3e3a530..d84f3830e 100644 --- a/resources/examples/notworking/acornvm/avm_stack.c3 +++ b/resources/examples/notworking/acornvm/avm_stack.c3 @@ -388,11 +388,11 @@ fn void Value.setTop(Value* th as AintIdx idx) } /* **************************************** - GLOBAL VARIABLE ACCESS + VARIABLE ACCESS ***************************************/ /** - * Push and return the symbolically-named global variable's value + * Push and return the symbolically-named variable's value * @require vm(*th).global.isTbl() **/ fn Value Value.pushGloVar(Value* th, string var) @@ -405,7 +405,7 @@ fn Value Value.pushGloVar(Value* th, string var) } /** - * Alter the symbolically-named global variable to have the value popped off the local stack + * Alter the symbolically-named variable to have the value popped off the local stack * @require stkSz(th) > 0, vm(th).global.isTbl() **/ fn void Value.popGloVar(Value* th, string var) @@ -417,7 +417,7 @@ fn void Value.popGloVar(Value* th, string var) th(*th).stk_top -= 2; // Pop key & value after value is safely in Global } -/* Push the value of the current process thread's global variable table. */ +/* Push the value of the current process thread's variable table. */ Value pushGlobal(Value th) { stkCanIncTop(th); /* Check if there is room */ diff --git a/resources/examples/notworking/acornvm/gen.c3 b/resources/examples/notworking/acornvm/gen.c3 index ce69b7c7f..fdc4a0f62 100644 --- a/resources/examples/notworking/acornvm/gen.c3 +++ b/resources/examples/notworking/acornvm/gen.c3 @@ -381,7 +381,7 @@ void genAssign(CompInfo *comp, Value lval, Value rval) { if (opcode) genDoProp(comp, lval, opcode, rval, 1); else { - // Handle parallel, local, closure, global variable assignments where rval is loaded first + // Handle parallel, local, closure, variable assignments where rval is loaded first int nlvals = lvalop==vmlit(SymComma)? arr_size(lval)-1 : 1; bool varrvals = false; AuintIdx rvalreg; @@ -445,7 +445,7 @@ void genAssign(CompInfo *comp, Value lval, Value rval) { genAddInstr(comp, BCINS_ABC(OpLoadReg, localreg, rvalreg, 0)); else if ((localreg = findClosureVar(comp, symnm))!=-1) genAddInstr(comp, BCINS_ABC(OpSetClosure, localreg, rvalreg, 0)); - // Load into a global variable + // Load into a variable } else if (vmlit(SymGlobal) == lvalop) genAddInstr(comp, BCINS_ABx(OpSetGlobal, rvalreg, genAddLit(comp, astGet(th, lval, 1)))); } diff --git a/resources/examples/notworking/acornvm/parser.c3 b/resources/examples/notworking/acornvm/parser.c3 index 9fc6bcb0d..04b1e9806 100644 --- a/resources/examples/notworking/acornvm/parser.c3 +++ b/resources/examples/notworking/acornvm/parser.c3 @@ -143,7 +143,7 @@ void parseValue(CompInfo* comp, Value astseg) astAddSeg2(th, astseg, vmlit(SYM_EXT), anInt(genAddUrlLit(comp, comp->lex->token))); lexGetNextToken(comp->lex); } - // Local or global variable / name token + // Local or variable / name token else if (comp->lex->toktype == Name_Token) { Value symnm = pushValue(th, comp->lex->token); lexGetNextToken(comp->lex); @@ -240,7 +240,7 @@ void parseValue(CompInfo* comp, Value astseg) Value symnm = comp->lex->token; const char first = (toStr(symnm))[0]; if (first=='$' || (first>='A' && first<='Z')) - lexLog(comp->lex, "A global name may not be a closure variable"); + lexLog(comp->lex, "A name may not be a closure variable"); arrAdd(th, comp->clovarseg, symnm); lexGetNextToken(comp->lex); @@ -985,7 +985,7 @@ void parseProgram(CompInfo* comp) { Value symnm = comp->lex->token; const char first = (toStr(symnm))[0]; if (first=='$' || (first>='A' && first<='Z')) - lexLog(comp->lex, "A global name may not be a method parameter"); + lexLog(comp->lex, "A name may not be a method parameter"); else { if (findLocalVar(comp, symnm)==-1) { arrAdd(th, comp->locvarseg, symnm); diff --git a/resources/examples/notworking/acornvm/vm.c3 b/resources/examples/notworking/acornvm/vm.c3 index 7ac1daeb3..8a592061a 100644 --- a/resources/examples/notworking/acornvm/vm.c3 +++ b/resources/examples/notworking/acornvm/vm.c3 @@ -13,7 +13,7 @@ void core_init(Value th); // Initialize all core types * different encoding types. * - The symbol table, which is shared across everywhere * - The main thread, which is the recursive root for garbage collection. - * The thread manages the global namespace, including all registered + * The thread manages the namespace, including all registered * core types (including the Acorn compiler and resource types). * * See newVm() for more detailed information on VM initialization. @@ -34,12 +34,12 @@ struct VmInfo ulong pcgrng_state; //!< PCG random-number generator state ulong pcgrng_inc; //!< PCG random-number generator inc value - Value global; //!< VM's "built in" Global hash table + Value global; //!< VM's "built in" hash table Value main_thread; //!< VM's main thread ThreadInfo main_thr; //!< State space for main thread - SymTable sym_table; //!< global symbol table + SymTable sym_table; //!< symbol table AuintIdx hashseed; //!< randomized seed for hashing strings Value literals; //!< array of all built-in symbol and type literals Value stdidx; //!< Table to convert std symbol to index @@ -252,7 +252,7 @@ macro memcpy_Auint(i, val) * and which to discard. * - All value encodings are initialized next, including the single symbol table * used across the VM. - * - The main thread is started up, initializing its global namespace. + * - The main thread is started up, initializing its namespace. * - All core types are progressively loaded, establishing the default types for * each encoding. This includes the resource types and Acorn compiler. */ fn Value new(void) @@ -290,13 +290,13 @@ fn Value new(void) memcpy_Auint(3, &newVM) // public function vm->hashseed = tblCalcStrHash(seedstr, sizeof(seedstr), (AuintIdx) timehash); - // Initialize vm-wide symbol table, global table and literals + // Initialize vm-wide symbol table, table and literals sym_init(th); // Initialize hash table for symbols - newTbl(th, &vm->global, aNull, GLOBAL_NEWSIZE); // Create global hash table + newTbl(th, &vm->global, aNull, GLOBAL_NEWSIZE); // Create hash table mem_markChk(th, vm, vm->global); vm_litinit(th); // Load reserved and standard symbols into literal list - core_init(th); // Load up global table and literal list with core types - setType(th, vm->global, vmlit(TypeIndexm)); // Fix up type info for global table + core_init(th); // Load up table and literal list with core types + setType(th, vm->global, vmlit(TypeIndexm)); // Fix up type info for table // Initialize byte-code standard methods and the Acorn compiler vm_stdinit(th); diff --git a/resources/testfragments/lexertest.c3 b/resources/testfragments/lexertest.c3 index 5df2d1517..825bcf28e 100644 --- a/resources/testfragments/lexertest.c3 +++ b/resources/testfragments/lexertest.c3 @@ -1,6 +1,6 @@ module foo; -const int GLOBAL = 0; +const int = 0; struct Boo { diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index af8aaeab8..edb498238 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -365,7 +365,7 @@ typedef struct VarDecl_ bool unwrap : 1; bool vararg : 1; bool is_static : 1; - bool is_threadglobal : 1; + bool is_threadlocal : 1; TypeInfo *type_info; union { diff --git a/src/compiler/enums.h b/src/compiler/enums.h index 4e926bc98..c7b21ccf3 100644 --- a/src/compiler/enums.h +++ b/src/compiler/enums.h @@ -442,7 +442,7 @@ typedef enum TOKEN_FN, TOKEN_FUNC, TOKEN_GENERIC, - TOKEN_GLOBAL, + TOKEN_TLOCAL, TOKEN_IF, TOKEN_IMPORT, TOKEN_MACRO, diff --git a/src/compiler/lexer.c b/src/compiler/lexer.c index 78e7b0ded..300677eef 100644 --- a/src/compiler/lexer.c +++ b/src/compiler/lexer.c @@ -691,7 +691,7 @@ static inline bool scan_char(Lexer *lexer) int width = 0; char c; - Int128 b = {}; + Int128 b = { 0, 0 }; while ((c = next(lexer)) != '\'') { diff --git a/src/compiler/llvm_codegen.c b/src/compiler/llvm_codegen.c index c829320bf..de7e15be8 100644 --- a/src/compiler/llvm_codegen.c +++ b/src/compiler/llvm_codegen.c @@ -363,8 +363,7 @@ void llvm_emit_global_variable_init(GenContext *c, Decl *decl) // TODO fix name LLVMValueRef old = decl->backend_ref; decl->backend_ref = LLVMAddGlobal(c->module, LLVMTypeOf(init_value), decl->extname ? decl->extname : decl->external_name); - bool thread_local = !decl->var.is_threadglobal && decl->var.kind != VARDECL_CONST; - LLVMSetThreadLocal(decl->backend_ref, thread_local); + LLVMSetThreadLocal(decl->backend_ref, decl->var.is_threadlocal); if (decl->section) { LLVMSetSection(decl->backend_ref, decl->section); @@ -375,7 +374,7 @@ void llvm_emit_global_variable_init(GenContext *c, Decl *decl) if (failable_ref) { llvm_set_alignment(failable_ref, type_alloca_alignment(type_anyerr)); - LLVMSetThreadLocal(failable_ref, thread_local); + LLVMSetThreadLocal(failable_ref, decl->var.is_threadlocal); } if (init_expr && IS_FAILABLE(init_expr) && init_expr->expr_kind == EXPR_FAILABLE) { diff --git a/src/compiler/parse_global.c b/src/compiler/parse_global.c index 797c52810..dfe810527 100644 --- a/src/compiler/parse_global.c +++ b/src/compiler/parse_global.c @@ -805,8 +805,8 @@ Decl *parse_decl(Context *context) return parse_const_declaration(context, VISIBLE_LOCAL); } - bool is_threadglobal = try_consume(context, TOKEN_GLOBAL); - bool is_static = !is_threadglobal && try_consume(context, TOKEN_STATIC); + bool is_threadlocal = try_consume(context, TOKEN_TLOCAL); + bool is_static = !is_threadlocal && try_consume(context, TOKEN_STATIC); ASSIGN_TYPE_ELSE(TypeInfo *type, parse_failable_type(context), poisoned_decl); @@ -816,8 +816,8 @@ Decl *parse_decl(Context *context) SEMA_ERROR(decl, "You cannot use unwrap with a failable variable."); return poisoned_decl; } - decl->var.is_static = is_static || is_threadglobal; - decl->var.is_threadglobal = is_threadglobal; + decl->var.is_static = is_static || is_threadlocal; + decl->var.is_threadlocal = is_threadlocal; return decl; } @@ -1021,13 +1021,13 @@ bool parse_attributes(Context *context, Attr ***attributes_ref) */ static inline Decl *parse_global_declaration(Context *context, Visibility visibility) { - bool thread_global = try_consume(context, TOKEN_GLOBAL); + bool threadlocal = try_consume(context, TOKEN_TLOCAL); ASSIGN_TYPE_ELSE(TypeInfo *type, parse_failable_type(context), poisoned_decl); Decl *decl = decl_new_var(context->tok.id, type, VARDECL_GLOBAL, visibility); - decl->var.is_threadglobal = thread_global; + decl->var.is_threadlocal = threadlocal; if (TOKEN_IS(TOKEN_CONST_IDENT)) { @@ -2366,7 +2366,7 @@ Decl *parse_top_level_statement(Context *context) case TOKEN_IMPORT: SEMA_TOKEN_ERROR(context->tok, "Imports are only allowed directly after the module declaration."); return poisoned_decl; - case TOKEN_GLOBAL: + case TOKEN_TLOCAL: case TYPELIKE_TOKENS: { ASSIGN_DECL_ELSE(decl, parse_global_declaration(context, visibility), poisoned_decl); diff --git a/src/compiler/parse_stmt.c b/src/compiler/parse_stmt.c index 4d6dd7ad4..1f8392315 100644 --- a/src/compiler/parse_stmt.c +++ b/src/compiler/parse_stmt.c @@ -800,7 +800,7 @@ Ast *parse_stmt(Context *context) return parse_decl_or_expr_stmt(context); case TOKEN_VAR: return parse_var_stmt(context); - case TOKEN_GLOBAL: // Global means declaration! + case TOKEN_TLOCAL: // Global means declaration! case TOKEN_STATIC: // Static means declaration! case TOKEN_CONST: // Const means declaration! return parse_declaration_stmt(context); diff --git a/src/compiler/tokens.c b/src/compiler/tokens.c index 2e47bad72..c81cf357d 100644 --- a/src/compiler/tokens.c +++ b/src/compiler/tokens.c @@ -236,8 +236,6 @@ const char *token_type_to_string(TokenType type) return "func"; case TOKEN_GENERIC: return "generic"; - case TOKEN_GLOBAL: - return "global"; case TOKEN_IF: return "if"; case TOKEN_IMPORT: @@ -260,6 +258,8 @@ const char *token_type_to_string(TokenType type) return "struct"; case TOKEN_SWITCH: return "switch"; + case TOKEN_TLOCAL: + return "tlocal"; case TOKEN_TRUE: return "true"; case TOKEN_TRY: diff --git a/test/test_suite/arrays/array_struct.c3t b/test/test_suite/arrays/array_struct.c3t index d585a07f6..304ec68ea 100644 --- a/test/test_suite/arrays/array_struct.c3t +++ b/test/test_suite/arrays/array_struct.c3t @@ -6,7 +6,7 @@ struct Foo int x, y; } -private global Foo[10] array; +private Foo[10] array; // #expect: test.ll diff --git a/test/test_suite/arrays/complex_array_const.c3t b/test/test_suite/arrays/complex_array_const.c3t index a532ff7dd..c5a387497 100644 --- a/test/test_suite/arrays/complex_array_const.c3t +++ b/test/test_suite/arrays/complex_array_const.c3t @@ -8,7 +8,7 @@ struct Connection long length; } -private global Connection[3] link +private Connection[3] link = { {1, "link1", 10}, {2, "link2", 20}, {3, "link3", 30} }; diff --git a/test/test_suite/compile_time/compile_time_ptr_ref.c3t b/test/test_suite/compile_time/compile_time_ptr_ref.c3t index da64ee139..404ed8405 100644 --- a/test/test_suite/compile_time/compile_time_ptr_ref.c3t +++ b/test/test_suite/compile_time/compile_time_ptr_ref.c3t @@ -2,12 +2,12 @@ module test; -global int*[] blurp = { &ptr, &ptr, (&ptr + 1), &ptr - 1, (int*)((iptr)(&ptr) - 4) }; -global int* c = (int*)((iptr)(&ptr) - 4); -global int* c2 = (int*)((iptr)(&ptr) + 4); -global int* c3 = (int*)(4 + (iptr)(&ptr)); -global iptr ff = (iptr)(&ptr); -global int ptr = 0; +int*[] blurp = { &ptr, &ptr, (&ptr + 1), &ptr - 1, (int*)((iptr)(&ptr) - 4) }; +int* c = (int*)((iptr)(&ptr) - 4); +int* c2 = (int*)((iptr)(&ptr) + 4); +int* c3 = (int*)(4 + (iptr)(&ptr)); +iptr ff = (iptr)(&ptr); +int ptr = 0; // #expect: test.ll diff --git a/test/test_suite/compile_time/ct_if.c3t b/test/test_suite/compile_time/ct_if.c3t index 269cfae02..006554164 100644 --- a/test/test_suite/compile_time/ct_if.c3t +++ b/test/test_suite/compile_time/ct_if.c3t @@ -4,7 +4,7 @@ $else: $elif (0): $elif (0): $else: - global int x = 1; + int x = 1; $endif; $endif; @@ -18,7 +18,7 @@ $endif; $if (1): $assert(true); -global int d = 5; +int d = 5; $elif (0): $assert(false); $else: @@ -29,7 +29,7 @@ $if (0): $assert(true); $elif (1): $assert(true); -global int c = 5; +int c = 5; $else: $assert(false); $endif; @@ -38,7 +38,7 @@ $if (0): $assert(true); $elif (1): $assert(true); -global int b = 4; +int b = 4; $elif (0): $assert(false); $else: @@ -51,7 +51,7 @@ $elif (0): $assert(false); $elif (1): $assert(true); -global int a = 3; +int a = 3; $else: $assert(false); $endif; diff --git a/test/test_suite/compile_time/ternary_folding.c3t b/test/test_suite/compile_time/ternary_folding.c3t index 6bf2f0619..58b361351 100644 --- a/test/test_suite/compile_time/ternary_folding.c3t +++ b/test/test_suite/compile_time/ternary_folding.c3t @@ -1,8 +1,8 @@ // #target: x64-darwin -global int foo = 2.2 ? 1 : 2; -global double bar = false ? 1.0 : 2; -global bool baz = 1 ? false : true; +int foo = 2.2 ? 1 : 2; +double bar = false ? 1.0 : 2; +bool baz = 1 ? false : true; fn void test() { diff --git a/test/test_suite/compile_time_introspection/alignof.c3t b/test/test_suite/compile_time_introspection/alignof.c3t index 9eb117325..259cf2831 100644 --- a/test/test_suite/compile_time_introspection/alignof.c3t +++ b/test/test_suite/compile_time_introspection/alignof.c3t @@ -1,7 +1,7 @@ // #target: x64-darwin module foo; -global int[100] zfe; +int[100] zfe; struct Bob { Bob[] x; @@ -37,29 +37,29 @@ union Foob Ar izzy; -global long x = $alignof(zfe); -global short y = $alignof("Bob.y"); -global int z = $alignof("Bob.y"); -global int w = $alignof(Bob.y); -global int v = $alignof(v); -global int x1 = $alignof("Ex.c"); -global int x2 = $alignof(Ex.y); -global int x3 = $alignof(char[8]); -global int x4 = $alignof("Ar.br[1]"); -global int x5 = $alignof(Ar.br[1]); -global int x6 = $alignof(Ar.br[1]); -global int x7 = $alignof(Ar.br[1]); -global int x8 = $alignof(Ar.br[2]); -global int x9 = $alignof("izzy.br[1]"); -global int x10 = $alignof("izzy.br[1]"); -global int x11 = $alignof(izzy.br[1]); -global int z0 = $alignof("Foob.c"); -global int z00 = $alignof("Foob.c[0]"); -global int z01 = $alignof("Foob.c[1]"); -global int z02 = $alignof("Foob.c[2]"); -global int z03 = $alignof("Foob.c[3]"); -global int z04 = $alignof("Foob.c[4]"); -global int z05 = $alignof("Foob.c[5]"); +long x = $alignof(zfe); +short y = $alignof("Bob.y"); +int z = $alignof("Bob.y"); +int w = $alignof(Bob.y); +int v = $alignof(v); +int x1 = $alignof("Ex.c"); +int x2 = $alignof(Ex.y); +int x3 = $alignof(char[8]); +int x4 = $alignof("Ar.br[1]"); +int x5 = $alignof(Ar.br[1]); +int x6 = $alignof(Ar.br[1]); +int x7 = $alignof(Ar.br[1]); +int x8 = $alignof(Ar.br[2]); +int x9 = $alignof("izzy.br[1]"); +int x10 = $alignof("izzy.br[1]"); +int x11 = $alignof(izzy.br[1]); +int z0 = $alignof("Foob.c"); +int z00 = $alignof("Foob.c[0]"); +int z01 = $alignof("Foob.c[1]"); +int z02 = $alignof("Foob.c[2]"); +int z03 = $alignof("Foob.c[3]"); +int z04 = $alignof("Foob.c[4]"); +int z05 = $alignof("Foob.c[5]"); diff --git a/test/test_suite/compile_time_introspection/offsetof.c3t b/test/test_suite/compile_time_introspection/offsetof.c3t index 386ebf574..5ad956f71 100644 --- a/test/test_suite/compile_time_introspection/offsetof.c3t +++ b/test/test_suite/compile_time_introspection/offsetof.c3t @@ -1,7 +1,7 @@ // #target: x64-darwin module foo; -global int[100] zfe; +int[100] zfe; struct Bob { Bob[] x; @@ -36,21 +36,21 @@ union Foob } -global short y = $offsetof("Bob.y"); -global int z = $offsetof("Bob.y"); -global int w = $offsetof(Bob.y); -global int x1 = $offsetof("Ex.c[3]"); -global int x2 = $offsetof("Ex.y[1]"); -global int x4 = $offsetof("Ar.br[1]"); -global int x6 = $offsetof(Ar.br[1].x); -global int x5 = $offsetof(Ar.br[1]); -global int x7 = $offsetof("Ar.br[2].x"); -global int x8 = $offsetof(Ar.br[2]); -global int z0 = $offsetof("Foob.c"); -global int z00 = $offsetof("Foob.c[0]"); -global int z01 = $offsetof("Foob.c[1]"); -global int z02 = $offsetof("Foob.c[5]"); -global int z03 = $offsetof("Foob.a"); +short y = $offsetof("Bob.y"); +int z = $offsetof("Bob.y"); +int w = $offsetof(Bob.y); +int x1 = $offsetof("Ex.c[3]"); +int x2 = $offsetof("Ex.y[1]"); +int x4 = $offsetof("Ar.br[1]"); +int x6 = $offsetof(Ar.br[1].x); +int x5 = $offsetof(Ar.br[1]); +int x7 = $offsetof("Ar.br[2].x"); +int x8 = $offsetof(Ar.br[2]); +int z0 = $offsetof("Foob.c"); +int z00 = $offsetof("Foob.c[0]"); +int z01 = $offsetof("Foob.c[1]"); +int z02 = $offsetof("Foob.c[5]"); +int z03 = $offsetof("Foob.a"); // #expect: foo.ll @foo.y = global i16 16, align 2 diff --git a/test/test_suite/compile_time_introspection/sizeof.c3t b/test/test_suite/compile_time_introspection/sizeof.c3t index d95cf90fc..a0e8fe74d 100644 --- a/test/test_suite/compile_time_introspection/sizeof.c3t +++ b/test/test_suite/compile_time_introspection/sizeof.c3t @@ -2,22 +2,22 @@ module foo; import bar; import bar::abc; -global long x = $sizeof(Baz); -global short y = $sizeof("Baz"); -global int z = $sizeof(bar::Baz); -global int w = $sizeof("bar::Baz"); -global int v = $sizeof("bar::abc::Foo"); -global int x1 = $sizeof(x); -global int y1 = $sizeof("y"); -global int a = $sizeof("Baz.y"); -global int b = $sizeof("Deep.a.b"); -global int c = $sizeof("Deep.a.b.c"); -global int d = $sizeof("Deep[][100]"); -global int e = $sizeof("Deep[][100]**[100][]*"); -global int a2 = $sizeof("Baz.y"); -global int a3 = $sizeof(Baz.y); -global int a4 = $sizeof(Baz.y); -global int a5 = $sizeof(Baz.y); +long x = $sizeof(Baz); +short y = $sizeof("Baz"); +int z = $sizeof(bar::Baz); +int w = $sizeof("bar::Baz"); +int v = $sizeof("bar::abc::Foo"); +int x1 = $sizeof(x); +int y1 = $sizeof("y"); +int a = $sizeof("Baz.y"); +int b = $sizeof("Deep.a.b"); +int c = $sizeof("Deep.a.b.c"); +int d = $sizeof("Deep[][100]"); +int e = $sizeof("Deep[][100]**[100][]*"); +int a2 = $sizeof("Baz.y"); +int a3 = $sizeof(Baz.y); +int a4 = $sizeof(Baz.y); +int a5 = $sizeof(Baz.y); module bar; diff --git a/test/test_suite/constants/byte_literals.c3t b/test/test_suite/constants/byte_literals.c3t index 28c6d00cf..9909bc1f5 100644 --- a/test/test_suite/constants/byte_literals.c3t +++ b/test/test_suite/constants/byte_literals.c3t @@ -1,8 +1,8 @@ -global char[*] foob = x"a0"; -global char[*] fooz = x"00aabbccddeeff"; -global char[*] fooy = x'dead beef'; -global char[*] foow = x"4549234d e d"; -global char[*] foo64 = b64"SGVsbG8gV29ybGQ="; +char[*] foob = x"a0"; +char[*] fooz = x"00aabbccddeeff"; +char[*] fooy = x'dead beef'; +char[*] foow = x"4549234d e d"; +char[*] foo64 = b64"SGVsbG8gV29ybGQ="; // #expect: byte_literals.ll diff --git a/test/test_suite/constants/char_literals.c3t b/test/test_suite/constants/char_literals.c3t index dc1f3d3d7..2a3aa06d0 100644 --- a/test/test_suite/constants/char_literals.c3t +++ b/test/test_suite/constants/char_literals.c3t @@ -1,15 +1,15 @@ // #file: file1.c3 module test; -global char a = ' '; -global char b = '\r'; -global char c = '\t'; -global char d = '\n'; -global char e = '\0'; -global char f = '\''; -global char g = '"'; -global char h = '\\'; -global char i = '\e'; +char a = ' '; +char b = '\r'; +char c = '\t'; +char d = '\n'; +char e = '\0'; +char f = '\''; +char g = '"'; +char h = '\\'; +char i = '\e'; // #expect: test.ll diff --git a/test/test_suite/constants/constants.c3t b/test/test_suite/constants/constants.c3t index 91bc6f184..821669e4a 100644 --- a/test/test_suite/constants/constants.c3t +++ b/test/test_suite/constants/constants.c3t @@ -5,11 +5,11 @@ private const uint DD = FOO; private const FOO = ~(uint)(0); -private global uint x = AA; -private global uint z = CC; -private global char w = (char)(FOO); -private global ushort v = (ushort)(FOO); -private global uint z2 = DD; +private uint x = AA; +private uint z = CC; +private char w = (char)(FOO); +private ushort v = (ushort)(FOO); +private uint z2 = DD; fn void test() { diff --git a/test/test_suite/enumerations/compile_time.c3t b/test/test_suite/enumerations/compile_time.c3t index 64ecd627e..d51584493 100644 --- a/test/test_suite/enumerations/compile_time.c3t +++ b/test/test_suite/enumerations/compile_time.c3t @@ -5,11 +5,11 @@ enum MyEnum : short BYE = -5 } -global int myenum_max = MyEnum.max; -global int myenum_min = MyEnum.min; -global int myenum_elements = MyEnum.elements; -global int myenum_alignof = $alignof(MyEnum); -global int myenum_sizeof = $sizeof(MyEnum); +int myenum_max = MyEnum.max; +int myenum_min = MyEnum.min; +int myenum_elements = MyEnum.elements; +int myenum_alignof = $alignof(MyEnum); +int myenum_sizeof = $sizeof(MyEnum); // #expect: compile_time.ll diff --git a/test/test_suite/expressions/parsed_numbers.c3t b/test/test_suite/expressions/parsed_numbers.c3t index 5ee674d03..727d824eb 100644 --- a/test/test_suite/expressions/parsed_numbers.c3t +++ b/test/test_suite/expressions/parsed_numbers.c3t @@ -1,9 +1,9 @@ module numbers; -global double a = 0x1.1p+1; -global double b = -12.3e-12; -global double c = 0x1.1p-1; -global double d = 12.3e+12; +double a = 0x1.1p+1; +double b = -12.3e-12; +double c = 0x1.1p-1; +double d = 12.3e+12; // #expect: numbers.ll diff --git a/test/test_suite/functions/static_vars.c3t b/test/test_suite/functions/static_vars.c3t index 4cb83d501..a9d2a35f6 100644 --- a/test/test_suite/functions/static_vars.c3t +++ b/test/test_suite/functions/static_vars.c3t @@ -3,15 +3,15 @@ module foo; fn int test() { static int x = 1; - global int y = 2; + tlocal int y = 2; x++; return x; } // #expect: foo.ll -@test.x = hidden thread_local global i32 1, align 4 -@test.y = hidden global i32 2, align 4 +@test.x = hidden global i32 1, align 4 +@test.y = hidden thread_local global i32 2, align 4 define i32 @foo.test() diff --git a/test/test_suite/functions/test_regression.c3t b/test/test_suite/functions/test_regression.c3t index 388e2207d..e8bd39f1c 100644 --- a/test/test_suite/functions/test_regression.c3t +++ b/test/test_suite/functions/test_regression.c3t @@ -15,7 +15,7 @@ fn void helloWorld() } fn int test_static() { - global int x = 1; + static int x = 1; x++; printf("Test static %d\n", x); return x; @@ -201,7 +201,7 @@ fn Type getMult(Type a) { return a * a; } -global Type argh = 234; +Type argh = 234; errtype MyErr { diff --git a/test/test_suite/functions/test_regression_mingw.c3t b/test/test_suite/functions/test_regression_mingw.c3t index 9e2b47ad4..f39b5313b 100644 --- a/test/test_suite/functions/test_regression_mingw.c3t +++ b/test/test_suite/functions/test_regression_mingw.c3t @@ -15,7 +15,7 @@ fn void helloWorld() } fn int test_static() { - global int x = 1; + static int x = 1; x++; printf("Test static %d\n", x); return x; @@ -203,7 +203,7 @@ fn Type getMult(Type a) { return a * a; } -global Type argh = 234; +Type argh = 234; errtype MyErr { diff --git a/test/test_suite/globals/external_global.c3t b/test/test_suite/globals/external_global.c3t index 0c7527f98..eca23cf05 100644 --- a/test/test_suite/globals/external_global.c3t +++ b/test/test_suite/globals/external_global.c3t @@ -13,7 +13,7 @@ struct UzGlobs MinInfo* pInfo; } -extern global UzGlobs g; +extern UzGlobs g; fn int extract_or_test_files() { diff --git a/test/test_suite/globals/global_extname.c3t b/test/test_suite/globals/global_extname.c3t index 71514a523..26f486e22 100644 --- a/test/test_suite/globals/global_extname.c3t +++ b/test/test_suite/globals/global_extname.c3t @@ -1,6 +1,6 @@ module foo; -global int baz @extname("foobar") = 123; +int baz @extname("foobar") = 123; // #expect: foo.ll diff --git a/test/test_suite/initializer_lists/fasta.c3t b/test/test_suite/initializer_lists/fasta.c3t index a486f7176..384c00b8d 100644 --- a/test/test_suite/initializer_lists/fasta.c3t +++ b/test/test_suite/initializer_lists/fasta.c3t @@ -6,7 +6,7 @@ const IA = 3877u; const IC = 29573u; const SEED = 42u; -global uint seed = SEED; +uint seed = SEED; fn float fasta_rand(float max) { @@ -14,7 +14,7 @@ fn float fasta_rand(float max) return max * seed / IM; } -private global char[] alu = +private char[] alu = "GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" "GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA" "CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT" @@ -27,8 +27,8 @@ extern fn int atoi(char *s); extern fn int printf(char *s, ...); extern fn void putchar(int c); -global char[] iub = "acgtBDHKMNRSVWY"; -global double[] iub_p = { +char[] iub = "acgtBDHKMNRSVWY"; +double[] iub_p = { 0.27, 0.12, 0.12, @@ -45,8 +45,8 @@ global double[] iub_p = { 0.02, 0.02 }; -global char[] homosapiens = "acgt"; -global double[] homosapiens_p = { +char[] homosapiens = "acgt"; +double[] homosapiens_p = { 0.3029549426680, 0.1979883004921, 0.1975473066391, diff --git a/test/test_suite/initializer_lists/general_tests.c3t b/test/test_suite/initializer_lists/general_tests.c3t index edb9fc371..6e8758cff 100644 --- a/test/test_suite/initializer_lists/general_tests.c3t +++ b/test/test_suite/initializer_lists/general_tests.c3t @@ -17,7 +17,7 @@ fn int test() int[1] azz = {}; int[*] a = {}; var $foo = { 11, 22, 33 }; - global int foo1 = $foo[1]; + static int foo1 = $foo[1]; int foo2 = $foo[2]; var $foos = { "Hello!" }; char* str = $foos[0]; diff --git a/test/test_suite/initializer_lists/statics.c3t b/test/test_suite/initializer_lists/statics.c3t index 0ddd377c6..2baf910a0 100644 --- a/test/test_suite/initializer_lists/statics.c3t +++ b/test/test_suite/initializer_lists/statics.c3t @@ -16,7 +16,7 @@ struct Bar fn void test() { Bar[] b = { { 1, 2 } }; - global Bar[] c = { { 1, 2 } }; + static Bar[] c = { { 1, 2 } }; io::printf("%d %d\n", b[0].y, c[0].y); b[0].y += 1; c[0].y += 1; @@ -30,7 +30,7 @@ fn int main() return 1; } -// #expect: statics.ll +/* #expect: statics.ll %Bar = type { i32, i32 } %"Bar[]" = type { %Bar*, i64 } diff --git a/test/test_suite/initializer_lists/subarrays.c3t b/test/test_suite/initializer_lists/subarrays.c3t index e51c8fbfe..523cad75e 100644 --- a/test/test_suite/initializer_lists/subarrays.c3t +++ b/test/test_suite/initializer_lists/subarrays.c3t @@ -14,9 +14,9 @@ struct Bar } -global Bar[] arrbar = { { 3, 4 }, { 8, 9 }}; -global int[] xd = { 1, 2 }; -global int* fofeo = &&(int[2]{ 3, 4 }); +Bar[] arrbar = { { 3, 4 }, { 8, 9 }}; +int[] xd = { 1, 2 }; +int* fofeo = &&(int[2]{ 3, 4 }); fn int main() { diff --git a/test/test_suite/literals/literal_general.c3t b/test/test_suite/literals/literal_general.c3t index bd38675cd..b09e6fdb0 100644 --- a/test/test_suite/literals/literal_general.c3t +++ b/test/test_suite/literals/literal_general.c3t @@ -1,14 +1,14 @@ // #target: x64-darwin module foo; -global int aa = 'ä'; -global int x = 'ABCD'; -global uint y = 'Helo'; -global ushort z = '\x31\x32'; -global int d = '\u0031'; -global char b = '\x40'; -global uint abc = '\U133222AB'; -global uint foo = '謝'; +int aa = 'ä'; +int x = 'ABCD'; +uint y = 'Helo'; +ushort z = '\x31\x32'; +int d = '\u0031'; +char b = '\x40'; +uint abc = '\U133222AB'; +uint foo = '謝'; /* #expect: foo.ll diff --git a/test/test_suite/pointers/const_pointer.c3t b/test/test_suite/pointers/const_pointer.c3t index 9a3e95558..78ab41b2b 100644 --- a/test/test_suite/pointers/const_pointer.c3t +++ b/test/test_suite/pointers/const_pointer.c3t @@ -2,13 +2,13 @@ module const_pointer; -private global double foo = 17; -private global double bar = 12.0; -private global float xx = 12.0; +private double foo = 17; +private double bar = 12.0; +private float xx = 12.0; -private global void*[3] data = { &foo, &bar, &xx }; +private void*[3] data = { &foo, &bar, &xx }; -// #expect: const_pointer.ll +/* #expect: const_pointer.ll @const_pointer.foo = protected global double 1.700000e+01, align 8 @const_pointer.bar = protected global double 1.200000e+01, align 8 diff --git a/test/test_suite/strings/literal_to_subarray.c3t b/test/test_suite/strings/literal_to_subarray.c3t index 00a40d72b..910e86abb 100644 --- a/test/test_suite/strings/literal_to_subarray.c3t +++ b/test/test_suite/strings/literal_to_subarray.c3t @@ -1,6 +1,6 @@ // #target: x64-darwin -global char[] y = "hello"; +char[] y = "hello"; fn void test() { diff --git a/test/test_suite/struct/simple_struct.c3t b/test/test_suite/struct/simple_struct.c3t index 105ece5f5..fb5f5308a 100644 --- a/test/test_suite/struct/simple_struct.c3t +++ b/test/test_suite/struct/simple_struct.c3t @@ -1,6 +1,6 @@ module test; -private global Foo a; +private Foo a; struct Foo { diff --git a/test/test_suite/struct/struct_const_construct_simple.c3t b/test/test_suite/struct/struct_const_construct_simple.c3t index af40acd7b..57041cfb2 100644 --- a/test/test_suite/struct/struct_const_construct_simple.c3t +++ b/test/test_suite/struct/struct_const_construct_simple.c3t @@ -6,16 +6,16 @@ struct Foo long bar; } -private global usize x = $sizeof(Foo); +private usize x = $sizeof(Foo); -private global Foo foo1 = { 1, 2 }; -private global Foo foo2 = { .foo = 2 }; -private global Foo foo3 = { .bar = 3 }; -private global Foo foo4 = { .bar = 4, .foo = 4, .bar = 1 }; -private global Foo foo5 = {}; -private global Foo foo6; +private Foo foo1 = { 1, 2 }; +private Foo foo2 = { .foo = 2 }; +private Foo foo3 = { .bar = 3 }; +private Foo foo4 = { .bar = 4, .foo = 4, .bar = 1 }; +private Foo foo5 = {}; +private Foo foo6; private const Foo FOO7 = { 1, 2 }; -private global Foo foo8 = FOO7; +private Foo foo8 = FOO7; // #expect: structo.ll diff --git a/test/test_suite/struct/struct_pack_and_align.c3t b/test/test_suite/struct/struct_pack_and_align.c3t index d0fcb7fce..4983205e4 100644 --- a/test/test_suite/struct/struct_pack_and_align.c3t +++ b/test/test_suite/struct/struct_pack_and_align.c3t @@ -8,7 +8,7 @@ struct Foo1 @packed @align(4) } $assert($sizeof(Foo1) == 12); -global Foo1 foo1 = { 1, 2 }; +Foo1 foo1 = { 1, 2 }; // <{ i8, i64, [3 x i8] }> struct Foo2 @packed @align(4) @@ -18,7 +18,7 @@ struct Foo2 @packed @align(4) } $assert($sizeof(Foo2) == 12); -global Foo2 foo2 = { 1, 2 }; +Foo2 foo2 = { 1, 2 }; // <{ i8, i64, [7 x i8] }> struct Foo3 @packed @align(8) @@ -27,7 +27,7 @@ struct Foo3 @packed @align(8) long bar; } -global Foo3 foo3 = { 1, 2 }; +Foo3 foo3 = { 1, 2 }; $assert($sizeof(Foo3) == 16); // <{ i8, i64 }> @@ -38,7 +38,7 @@ struct Foo4 @packed } $assert($sizeof(Foo4) == 9); -global Foo4 foo4 = { 1, 2 }; +Foo4 foo4 = { 1, 2 }; // { i32, [12 x i8], i8, [15 x i8] } struct Foo5 @@ -48,7 +48,7 @@ struct Foo5 } $assert($sizeof(Foo5) == 32); -global Foo5 foo5 = { 1, 2 }; +Foo5 foo5 = { 1, 2 }; fn int test5(ichar x) { @@ -65,7 +65,7 @@ struct Foo6 @packed } $assert($sizeof(Foo6) == 8); -global Foo6 foo6 = { 1, 2, 3 }; +Foo6 foo6 = { 1, 2, 3 }; // #expect: struct2.ll diff --git a/test/test_suite/union/union_codegen_const.c3t b/test/test_suite/union/union_codegen_const.c3t index fe8ea6235..a6c31cd2a 100644 --- a/test/test_suite/union/union_codegen_const.c3t +++ b/test/test_suite/union/union_codegen_const.c3t @@ -6,10 +6,10 @@ union Foo double b; } -private global Foo f = { .a = 23 }; -private global Foo g = { .b = 2.3 }; -private global Foo h = { .a = 23, .b = 2.3 }; -global Foo i = { .b = 2.3, .a = 23 }; +private Foo f = { .a = 23 }; +private Foo g = { .b = 2.3 }; +private Foo h = { .a = 23, .b = 2.3 }; +Foo i = { .b = 2.3, .a = 23 }; // #expect: test.ll diff --git a/test/test_suite/union/union_in_struct.c3t b/test/test_suite/union/union_in_struct.c3t index a57306d86..f654b57ee 100644 --- a/test/test_suite/union/union_in_struct.c3t +++ b/test/test_suite/union/union_in_struct.c3t @@ -11,8 +11,8 @@ struct Foo int z; } -global Foo foo1 = { .a = 3, .z = 4 }; -global Foo foo2 = { .b = 3, .z = 4 }; +Foo foo1 = { .a = 3, .z = 4 }; +Foo foo2 = { .b = 3, .z = 4 }; struct Blend_Map_Entry { @@ -22,10 +22,10 @@ struct Blend_Map_Entry } } -global Blend_Map_Entry a = { .vals = { .colour = { 1, 2, 3, 4, 5 } } }; -global Blend_Map_Entry b = { .vals = { .point_Slope = { 6, 7 } } }; -global Blend_Map_Entry c = { .vals.colour[2] = 1 }; -global Blend_Map_Entry d = { .vals.colour = { 1, 2, 3, 4, 5 } }; +Blend_Map_Entry a = { .vals = { .colour = { 1, 2, 3, 4, 5 } } }; +Blend_Map_Entry b = { .vals = { .point_Slope = { 6, 7 } } }; +Blend_Map_Entry c = { .vals.colour[2] = 1 }; +Blend_Map_Entry d = { .vals.colour = { 1, 2, 3, 4, 5 } }; fn void test(Blend_Map_Entry* foo) { diff --git a/test/test_suite/vector/vector_init.c3t b/test/test_suite/vector/vector_init.c3t index c3dce2902..c3dc6d460 100644 --- a/test/test_suite/vector/vector_init.c3t +++ b/test/test_suite/vector/vector_init.c3t @@ -1,5 +1,5 @@ // #target: x64-darwin -global int[<4>] baz = { 1, 4, 5, 7 }; +int[<4>] baz = { 1, 4, 5, 7 }; fn void main() {