1
0

OPTIONを実装

This commit is contained in:
otya128
2016-09-02 20:57:36 +09:00
parent 2f50fc5ba9
commit 1bfb655e74
4 changed files with 64 additions and 2 deletions

View File

@@ -165,6 +165,8 @@ class Function
class Compiler
{
bool isDirectMode;
bool isDefint;
bool isStrictMode;
ValueType getType(wstring name)
{
wchar s = name[name.length - 1];
@@ -177,8 +179,10 @@ class Compiler
case '%':
return ValueType.Integer;
default:
return ValueType.Double;//非DEFINT時
//return ValueType.Integer;//DEFINT時
if (!isDefint)
return ValueType.Double;//DEFINT時
else
return ValueType.Integer;//DEFINT時
}
}
Statements statements;
@@ -437,6 +441,10 @@ class Compiler
{
//local変数をあたる
//それでもだめならOPTION STRICTならエラー
if (isStrictMode)
{
throw new UndefinedVariable();
}
this.global[name] = VMVariable(global = ++globalIndex, getType(name));
}
return global;
@@ -1088,6 +1096,24 @@ class Compiler
case NodeType.RepeatUntil:
compileRepeat(cast(RepeatUntil)i, s);
break;
case NodeType.Option:
if(isDirectMode)
{
throw new CantUseFromDirectMode();
}
else
{
auto option = cast(Option)i;
if (option.argument == "STRICT")
{
isStrictMode = true;
}
else if (option.argument == "DEFINT")
{
isDefint = true;
}
}
break;
default:
stderr.writeln("Compile:NotImpl ", i.type);
}