Add script-scope variables to the symbol table.
This commit is contained in:
parent
102f623cd1
commit
ee5cff3900
1 changed files with 6 additions and 3 deletions
|
@ -10,7 +10,6 @@ namespace arookas
|
||||||
{
|
{
|
||||||
aBinaryWriter writer;
|
aBinaryWriter writer;
|
||||||
uint textOffset, dataOffset, symbolOffset;
|
uint textOffset, dataOffset, symbolOffset;
|
||||||
int varCount;
|
|
||||||
|
|
||||||
public sunWriter Text { get; private set; }
|
public sunWriter Text { get; private set; }
|
||||||
public sunDataTable DataTable { get; private set; }
|
public sunDataTable DataTable { get; private set; }
|
||||||
|
@ -95,7 +94,6 @@ namespace arookas
|
||||||
ImportResolver.EnterFile(file);
|
ImportResolver.EnterFile(file);
|
||||||
var parser = new sunParser();
|
var parser = new sunParser();
|
||||||
var tree = parser.Parse(file);
|
var tree = parser.Parse(file);
|
||||||
varCount += tree.MaxLocalCount;
|
|
||||||
tree.Compile(this);
|
tree.Compile(this);
|
||||||
ImportResolver.ExitFile(file);
|
ImportResolver.ExitFile(file);
|
||||||
}
|
}
|
||||||
|
@ -169,6 +167,11 @@ namespace arookas
|
||||||
throw new sunRedeclaredVariableException(node);
|
throw new sunRedeclaredVariableException(node);
|
||||||
}
|
}
|
||||||
var variableInfo = Scopes.DeclareVariable(node.Value);
|
var variableInfo = Scopes.DeclareVariable(node.Value);
|
||||||
|
if (Scopes.Top.Type == sunScopeType.Script)
|
||||||
|
{
|
||||||
|
// script variables are added to the symbol table
|
||||||
|
SymbolTable.Add(variableInfo);
|
||||||
|
}
|
||||||
return variableInfo;
|
return variableInfo;
|
||||||
}
|
}
|
||||||
public sunVariableSymbol ResolveVariable(sunIdentifier node)
|
public sunVariableSymbol ResolveVariable(sunIdentifier node)
|
||||||
|
@ -240,7 +243,7 @@ namespace arookas
|
||||||
writer.WriteS32(DataTable.Count);
|
writer.WriteS32(DataTable.Count);
|
||||||
writer.Write32(symbolOffset);
|
writer.Write32(symbolOffset);
|
||||||
writer.WriteS32(SymbolTable.Count);
|
writer.WriteS32(SymbolTable.Count);
|
||||||
writer.WriteS32(varCount);
|
writer.WriteS32(SymbolTable.VariableCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue