1
0
This commit is contained in:
otya128
2016-02-23 23:05:24 +09:00
parent 872a51f7cf
commit 8e1860461a
4 changed files with 44 additions and 5 deletions

View File

@@ -72,7 +72,7 @@
<debuglevel>0</debuglevel> <debuglevel>0</debuglevel>
<debugids /> <debugids />
<versionlevel>0</versionlevel> <versionlevel>0</versionlevel>
<versionids>NDirectMode</versionids> <versionids />
<dump_source>0</dump_source> <dump_source>0</dump_source>
<mapverbosity>0</mapverbosity> <mapverbosity>0</mapverbosity>
<createImplib>0</createImplib> <createImplib>0</createImplib>

View File

@@ -1381,6 +1381,24 @@ class BuiltinFunction
flag.setDefaultValue(0); flag.setDefaultValue(0);
throw new IllegalFunctionCall("NOTIMPL:LOAD"); throw new IllegalFunctionCall("NOTIMPL:LOAD");
} }
static void PROJECT(PetitComputer p, wstring name)
{
//DirectMode only
if(p.isRunningDirectMode)
{
if(!p.project.isValidProjectName(name))
{
throw new IllegalFunctionCall("PROJECT");
}
p.currentProject = name;
return;
}
throw new CantUseInProgram("PROJECT");
}
static void PROJECT(PetitComputer p, out wstring name)
{
name = p.currentProject;
}
//alias void function(PetitComputer, Value[], Value[]) BuiltinFunc; //alias void function(PetitComputer, Value[], Value[]) BuiltinFunc;
static BuiltinFunctions[wstring] builtinFunctions; static BuiltinFunctions[wstring] builtinFunctions;
static wstring getBasicName(BFD)(const wstring def) static wstring getBasicName(BFD)(const wstring def)
@@ -1872,9 +1890,18 @@ template AddFuncArg(int L, int N, int M, int O, BFD, P...)
} }
else static if(is(P[0] == wstring)) else static if(is(P[0] == wstring))
{ {
enum add = 1; static if(storage & ParameterStorageClass.out_)
enum outadd = 0; {
const string arg = "arg[" ~ I.to!string ~ "].castString"; enum add = 0;
enum outadd = 1;
const string arg = "ret[" ~ O.to!string ~ "].stringValue";
}
else
{
enum add = 1;
enum outadd = 0;
const string arg = "arg[" ~ I.to!string ~ "].castString";
}
} }
else static if(is(P[0] == DefaultValue!int)) else static if(is(P[0] == DefaultValue!int))
{ {
@@ -1995,6 +2022,10 @@ template OutArgsInit(BFD, int I = 0, int J = 0)
{ {
enum ret2 = "ValueType.Void;"; enum ret2 = "ValueType.Void;";
} }
else static if(is(param[I] == wstring))
{
enum ret2 = "ValueType.String;";
}
else else
{ {
static assert(false, "invalid type " ~ param[I].stringof); static assert(false, "invalid type " ~ param[I].stringof);

View File

@@ -114,4 +114,12 @@ class CantUseFromDirectMode : SmileBasicError
super("Can't use from direct mode"); super("Can't use from direct mode");
} }
} }
class CantUseInProgram : SmileBasicError
{
this(wstring func)
{
this.errnum = 44;
super("Can't use in program");
}
}

View File

@@ -1115,6 +1115,7 @@ class PetitComputer
printConsole("OK\n"); printConsole("OK\n");
} }
Slot[] slot; Slot[] slot;
bool isRunningDirectMode = false;
void run() void run()
{ {
slot = new Slot[5]; slot = new Slot[5];
@@ -1133,7 +1134,6 @@ class PetitComputer
Parser parser; Parser parser;
otya.smilebasic.vm.VM vm; otya.smilebasic.vm.VM vm;
bool directMode = false; bool directMode = false;
bool isRunningDirectMode = false;
int oldpc; int oldpc;
void runSlot(int lot) void runSlot(int lot)
{ {