Rollback global.

This commit is contained in:
Christoffer Lerno
2021-11-17 10:37:23 +01:00
parent b52b42d4da
commit 974cd0acc5
44 changed files with 200 additions and 201 deletions

View File

@@ -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,

View File

@@ -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 */

View File

@@ -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))));
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -1,6 +1,6 @@
module foo;
const int GLOBAL = 0;
const int = 0;
struct Boo
{

View File

@@ -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
{

View File

@@ -442,7 +442,7 @@ typedef enum
TOKEN_FN,
TOKEN_FUNC,
TOKEN_GENERIC,
TOKEN_GLOBAL,
TOKEN_TLOCAL,
TOKEN_IF,
TOKEN_IMPORT,
TOKEN_MACRO,

View File

@@ -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)) != '\'')
{

View File

@@ -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)
{

View File

@@ -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);

View File

@@ -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);

View File

@@ -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:

View File

@@ -6,7 +6,7 @@ struct Foo
int x, y;
}
private global Foo[10] array;
private Foo[10] array;
// #expect: test.ll

View File

@@ -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} };

View File

@@ -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

View File

@@ -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;

View File

@@ -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()
{

View File

@@ -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]");

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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()
{

View File

@@ -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

View File

@@ -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

View File

@@ -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()

View File

@@ -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
{

View File

@@ -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
{

View File

@@ -13,7 +13,7 @@ struct UzGlobs
MinInfo* pInfo;
}
extern global UzGlobs g;
extern UzGlobs g;
fn int extract_or_test_files()
{

View File

@@ -1,6 +1,6 @@
module foo;
global int baz @extname("foobar") = 123;
int baz @extname("foobar") = 123;
// #expect: foo.ll

View File

@@ -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,

View File

@@ -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];

View File

@@ -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 }

View File

@@ -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()
{

View File

@@ -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

View File

@@ -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

View File

@@ -1,6 +1,6 @@
// #target: x64-darwin
global char[] y = "hello";
char[] y = "hello";
fn void test()
{

View File

@@ -1,6 +1,6 @@
module test;
private global Foo a;
private Foo a;
struct Foo
{

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)
{

View File

@@ -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()
{