1
0

まだエラーが出ていたので修正

This commit is contained in:
otya128
2015-08-26 22:05:27 +09:00
parent 478c3a397e
commit 6d1acbee10

View File

@@ -41,7 +41,7 @@ class DataTable
} }
void addLabel(wstring label) void addLabel(wstring label)
{ {
this.label[label] = data.length; this.label[label] = cast(int)data.length;
} }
void read(out Value value, VM vm) void read(out Value value, VM vm)
{ {
@@ -554,26 +554,26 @@ class Compiler
forAddr.address = cast(int)code.length; forAddr.address = cast(int)code.length;
s = new Scope(new GotoAddr(-1), new GotoAddr(-1), s); s = new Scope(new GotoAddr(-1), new GotoAddr(-1), s);
compileStatements(node.statements, s); compileStatements(node.statements, s);
s.continueAddr.address = code.length; s.continueAddr.address = cast(int)code.length;
//counterに加算する //counterに加算する
genCodePushVar(node.initExpression.name, s); genCodePushVar(node.initExpression.name, s);
compileExpression(node.stepExpression, s); compileExpression(node.stepExpression, s);
genCodeOP(TokenType.Plus); genCodeOP(TokenType.Plus);
genCodePopVar(node.initExpression.name, s); genCodePopVar(node.initExpression.name, s);
genCodeGoto(forstart); genCodeGoto(cast(int)forstart);
breakAddr.address = code.length; breakAddr.address = cast(int)code.length;
s.breakAddr.address = code.length; s.breakAddr.address = cast(int)code.length;
} }
void compileWhile(While node, Scope s) void compileWhile(While node, Scope s)
{ {
auto whilestart = code.length; auto whilestart = code.length;
s = new Scope(new GotoAddr(-1), new GotoAddr(whilestart), s); s = new Scope(new GotoAddr(-1), new GotoAddr(cast(int)whilestart), s);
compileExpression(node.condExpression, s); compileExpression(node.condExpression, s);
auto breakAddr = genCodeGotoFalse(); auto breakAddr = genCodeGotoFalse();
compileStatements(node.statements, s); compileStatements(node.statements, s);
genCode(s.continueAddr); genCode(s.continueAddr);
s.breakAddr.address = code.length; s.breakAddr.address = cast(int)code.length;
breakAddr.address = code.length; breakAddr.address = cast(int)code.length;
} }
void compileVar(Var node, Scope sc) void compileVar(Var node, Scope sc)
{ {
@@ -597,7 +597,7 @@ class Compiler
break;//4次元まで(パーサーで除去するけど万が一に備えて break;//4次元まで(パーサーで除去するけど万が一に備えて
} }
defineVarIndexVoid(var.name, sc); defineVarIndexVoid(var.name, sc);
genCode(new NewArray(getType(var.name), var.dim.expressions.length)); genCode(new NewArray(getType(var.name), cast(int)var.dim.expressions.length));
genCodePopVar(var.name, sc); genCodePopVar(var.name, sc);
continue; continue;
} }
@@ -626,7 +626,7 @@ class Compiler
void compileDefineFunction(DefineFunction node) void compileDefineFunction(DefineFunction node)
{ {
auto skip = genCodeGoto(); auto skip = genCodeGoto();
Function func = new Function(this.code.length, node.name, node.returnExpr, node.arguments.length); Function func = new Function(cast(int)this.code.length, node.name, node.returnExpr, cast(int)node.arguments.length);
Scope sc = new Scope(func); Scope sc = new Scope(func);
foreach(wstring arg; node.arguments) foreach(wstring arg; node.arguments)
{ {
@@ -637,12 +637,12 @@ class Compiler
func.defineLocalVarIndexVoid(arg, this); func.defineLocalVarIndexVoid(arg, this);
} }
if(!func.returnExpr) if(!func.returnExpr)
func.outArgCount = node.outArguments.length; func.outArgCount = cast(int)node.outArguments.length;
compileStatements(node.functionBody, sc); compileStatements(node.functionBody, sc);
if(func.returnExpr) if(func.returnExpr)
genCodeImm(Value(ValueType.Void)); genCodeImm(Value(ValueType.Void));
genCode(new ReturnFunction(func)); genCode(new ReturnFunction(func));
skip.address = this.code.length; skip.address = cast(int)this.code.length;
this.functions[func.name] = func; this.functions[func.name] = func;
} }
void compileOn(On on, Scope sc) void compileOn(On on, Scope sc)
@@ -665,7 +665,7 @@ class Compiler
{ {
compileExpression(i, sc); compileExpression(i, sc);
} }
genCode(new InputCode(input.variables.length)); genCode(new InputCode(cast(int)input.variables.length));
foreach_reverse(i; input.variables) foreach_reverse(i; input.variables)
{ {
compilePopVar(i, sc); compilePopVar(i, sc);
@@ -673,7 +673,7 @@ class Compiler
} }
void compileRead(Read read, Scope sc) void compileRead(Read read, Scope sc)
{ {
genCode(new ReadCode(read.variables.length)); genCode(new ReadCode(cast(int)read.variables.length));
foreach_reverse(i; read.variables) foreach_reverse(i; read.variables)
{ {
compilePopVar(i, sc); compilePopVar(i, sc);
@@ -703,7 +703,7 @@ class Compiler
break; break;
} }
} }
code ~= new PrintCode(print.args.length); code ~= new PrintCode(cast(int)print.args.length);
} }
break; break;
case NodeType.Assign: case NodeType.Assign:
@@ -718,11 +718,11 @@ class Compiler
auto label = cast(Label)i; auto label = cast(Label)i;
if(s.func) if(s.func)
{ {
s.func.label[label.label] = code.length; s.func.label[label.label] = cast(int)code.length;
} }
else else
{ {
globalLabel[label.label] = code.length; globalLabel[label.label] = cast(int)code.length;
} }
s.data.addLabel(label.label); s.data.addLabel(label.label);
} }
@@ -796,7 +796,7 @@ class Compiler
auto assign = cast(ArrayAssign)i; auto assign = cast(ArrayAssign)i;
compileExpression(assign.assignExpression, s); compileExpression(assign.assignExpression, s);
compileExpression(assign.indexExpression, s); compileExpression(assign.indexExpression, s);
genCode(new PopArray(getGlobalVarIndex(assign.name), assign.indexExpression.expressions.length, !(s.func is null))); genCode(new PopArray(getGlobalVarIndex(assign.name), cast(int)assign.indexExpression.expressions.length, !(s.func is null)));
} }
break; break;
case NodeType.CallFunctionStatement: case NodeType.CallFunctionStatement:
@@ -805,7 +805,7 @@ class Compiler
auto bfun = otya.smilebasic.builtinfunctions.BuiltinFunction.builtinFunctions.get(func.name, null); auto bfun = otya.smilebasic.builtinfunctions.BuiltinFunction.builtinFunctions.get(func.name, null);
if(bfun) if(bfun)
{ {
int k = bfun.argments.length - func.args.length; int k = cast(int)bfun.argments.length - cast(int)func.args.length;
foreach(l;0..k) foreach(l;0..k)
{ {
genCodeImm(Value(ValueType.Void)); genCodeImm(Value(ValueType.Void));
@@ -817,12 +817,12 @@ class Compiler
} }
if(bfun) if(bfun)
{ {
genCode(new CallBuiltinFunction(bfun, func.args.length, func.outVariable.length)); genCode(new CallBuiltinFunction(bfun, cast(int)func.args.length, cast(int)func.outVariable.length));
} }
else else
{ {
writeln(func.name); writeln(func.name);
genCode(new CallFunctionCode(func.name, func.args.length, func.outVariable.length)); genCode(new CallFunctionCode(func.name, cast(int)func.args.length, cast(int)func.outVariable.length));
} }
//TODO:OUT //TODO:OUT
foreach_reverse(wstring var; func.outVariable) foreach_reverse(wstring var; func.outVariable)