1
0

Fix local restore

This commit is contained in:
otya128
2016-12-23 21:16:59 +09:00
parent 0cda0ee095
commit f0b598e35e
2 changed files with 5 additions and 3 deletions

View File

@@ -1777,9 +1777,11 @@ class ReadCode : Code
class RestoreCodeS : Code class RestoreCodeS : Code
{ {
wstring label; wstring label;
this(wstring label) Scope scope_;
this(wstring label, Scope s)
{ {
this.label = label; this.label = label;
scope_ = s;
this.type = CodeType.RestoreCodeS; this.type = CodeType.RestoreCodeS;
} }
override void execute(VM vm) override void execute(VM vm)

View File

@@ -1170,7 +1170,7 @@ class Compiler
Constant cons = cast(Constant)label; Constant cons = cast(Constant)label;
if(cons.value.isString) if(cons.value.isString)
{ {
genCode(new RestoreCodeS(cons.value.stringValue)); genCode(new RestoreCodeS(cons.value.stringValue, s));
break; break;
//文字列じゃないならば定数でも実行時エラー //文字列じゃないならば定数でも実行時エラー
} }
@@ -1302,7 +1302,7 @@ class Compiler
if(c.type == CodeType.RestoreCodeS) if(c.type == CodeType.RestoreCodeS)
{ {
auto restore = cast(RestoreCodeS)c; auto restore = cast(RestoreCodeS)c;
auto label = s.data.label.get(restore.label, int.min); auto label = restore.scope_.data.label.get(restore.label, int.min);
if (label == int.min) if (label == int.min)
{ {
code[i] = new RestoreUndefinedLabelCode(restore.label); code[i] = new RestoreUndefinedLabelCode(restore.label);