Fixed: hierarchy treated variable assignments as definitions in local counting.

This commit is contained in:
arookas 2015-12-28 02:44:43 -05:00
parent 72387d95eb
commit 63740ea381

View file

@ -18,7 +18,7 @@
class sunVariableDeclaration : sunNode class sunVariableDeclaration : sunNode
{ {
public sunIdentifier Storable { get { return this[0] as sunIdentifier; } } public sunIdentifier Variable { get { return this[0] as sunIdentifier; } }
public sunVariableDeclaration(sunSourceLocation location) public sunVariableDeclaration(sunSourceLocation location)
: base(location) : base(location)
@ -28,12 +28,16 @@
public override void Compile(sunContext context) public override void Compile(sunContext context)
{ {
context.DeclareVariable(Storable); context.DeclareVariable(Variable);
} }
} }
class sunVariableDefinition : sunVariableAssignment class sunVariableDefinition : sunNode
{ {
public sunIdentifier Variable { get { return this[0] as sunIdentifier; } }
public sunAssign Operator { get { return this[1] as sunAssign; } }
public sunExpression Expression { get { return this[2] as sunExpression; } }
public sunVariableDefinition(sunSourceLocation location) public sunVariableDefinition(sunSourceLocation location)
: base(location) : base(location)
{ {
@ -42,13 +46,14 @@
public override void Compile(sunContext context) public override void Compile(sunContext context)
{ {
context.DeclareVariable(Storable); var symbol = context.DeclareVariable(Variable);
base.Compile(context); Operator.Compile(context, symbol, Expression);
} }
} }
class sunVariableAssignment : sunVariableDeclaration class sunVariableAssignment : sunNode
{ {
public sunIdentifier Storable { get { return this[0] as sunIdentifier; } }
public sunAssign Operator { get { return this[1] as sunAssign; } } public sunAssign Operator { get { return this[1] as sunAssign; } }
public sunExpression Expression { get { return this[2] as sunExpression; } } public sunExpression Expression { get { return this[2] as sunExpression; } }
@ -65,7 +70,7 @@
{ {
throw new sunAssignConstantException(Storable); throw new sunAssignConstantException(Storable);
} }
Operator.Compile(context, symbol as sunVariableSymbol, Expression); Operator.Compile(context, symbol, Expression);
} }
} }