From 63740ea38169407563f3df28c50ab7e920079b17 Mon Sep 17 00:00:00 2001 From: arookas Date: Mon, 28 Dec 2015 02:44:43 -0500 Subject: [PATCH] Fixed: hierarchy treated variable assignments as definitions in local counting. --- ssc/ast/nodes.variables.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ssc/ast/nodes.variables.cs b/ssc/ast/nodes.variables.cs index 39641ea..1ffd7d5 100644 --- a/ssc/ast/nodes.variables.cs +++ b/ssc/ast/nodes.variables.cs @@ -18,7 +18,7 @@ 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) : base(location) @@ -28,12 +28,16 @@ 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) : base(location) { @@ -42,13 +46,14 @@ public override void Compile(sunContext context) { - context.DeclareVariable(Storable); - base.Compile(context); + var symbol = context.DeclareVariable(Variable); + 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 sunExpression Expression { get { return this[2] as sunExpression; } } @@ -65,7 +70,7 @@ { throw new sunAssignConstantException(Storable); } - Operator.Compile(context, symbol as sunVariableSymbol, Expression); + Operator.Compile(context, symbol, Expression); } }