1
0

INC/DECを実装(配列除く)

This commit is contained in:
otya128
2015-07-12 14:42:28 +09:00
parent 60654d16e4
commit 2139875751
4 changed files with 95 additions and 4 deletions

View File

@@ -277,8 +277,6 @@ class Compiler
{
if(sc.func)
{
int global = hasGlobalVarIndex(name);
if(global) return global;
int local = sc.func.getLocalVarIndex(name, this);
return local;
}
@@ -477,6 +475,19 @@ class Compiler
}
}
}
void compileInc(Inc node, Scope sc)
{
compileExpression(node.expression, sc);
int index = sc.func ? sc.func.hasLocalVarIndex(node.name) : 0;
if(index)
{
genCode(new IncCodeL(index));
}
else
{
genCode(new IncCodeG(this.getGlobalVarIndex(node.name)));
}
}
void compileStatements(Statements statements, Scope sc)
{
foreach(Statement s ; statements.statements)
@@ -652,6 +663,9 @@ class Compiler
case NodeType.While:
compileWhile(cast(While)i, s);
break;
case NodeType.Inc:
compileInc(cast(Inc)i, s);
break;
default:
stderr.writeln("Compile:NotImpl ", i.type);
}