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
{