1
0

Add GosubUndefinedLabel

This commit is contained in:
otya128
2016-12-28 17:43:53 +09:00
parent a887d91138
commit d240a0b0d6
2 changed files with 24 additions and 3 deletions

View File

@@ -2387,3 +2387,15 @@ class Use : Code
} }
} }
class GosubUndefinedLabel : Code
{
wstring label;
this(wstring label)
{
this.label = label;
}
override void execute(VM vm)
{
throw new UndefinedLabel(label);
}
}

View File

@@ -1259,13 +1259,22 @@ class Compiler
if(c.type == CodeType.GosubS) if(c.type == CodeType.GosubS)
{ {
auto label = cast(GosubS)c; auto label = cast(GosubS)c;
int addr;
if(label.sc.func) if(label.sc.func)
{ {
code[i] = new GosubAddr(label.sc.func.label[label.label]); addr = label.sc.func.label.get(label.label, int.min);
} }
else else
{ {
code[i] = new GosubAddr(globalLabel[label.label]); addr = globalLabel.get(label.label, int.min);
}
if (addr == int.min)
{
code[i] = new GosubUndefinedLabel(label.label);
}
else
{
code[i] = new GosubAddr(addr);
} }
} }
if(c.type == CodeType.OnS) if(c.type == CodeType.OnS)
@@ -1276,7 +1285,7 @@ class Compiler
{ {
if(label.sc.func) if(label.sc.func)
{ {
addresses[index] =label.sc.func.label.get(l, int.min); addresses[index] = label.sc.func.label.get(l, int.min);
} }
else else
{ {