Implement PRGNAME$
This commit is contained in:
@@ -2334,7 +2334,7 @@ class Exec : Code
|
|||||||
}
|
}
|
||||||
wstring content;
|
wstring content;
|
||||||
if (vm.petitcomputer.project.loadFile(file.project, "TXT", file.name, content))
|
if (vm.petitcomputer.project.loadFile(file.project, "TXT", file.name, content))
|
||||||
vm.petitcomputer.program.slot[slot].load(content);
|
vm.petitcomputer.program.slot[slot].load(file.name, content);
|
||||||
else
|
else
|
||||||
throw new LoadFailed();//TODO:DIALOG?
|
throw new LoadFailed();//TODO:DIALOG?
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2280,7 +2280,7 @@ class BuiltinFunction
|
|||||||
//not exist
|
//not exist
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
p.program.slot[lot].load(txt);
|
p.program.slot[lot].load(filename, txt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(resname.indexOf("GRP") == 0)
|
if(resname.indexOf("GRP") == 0)
|
||||||
@@ -3211,6 +3211,14 @@ class BuiltinFunction
|
|||||||
import otya.smilebasic.program;
|
import otya.smilebasic.program;
|
||||||
return p.program.size(slot, cast(SizeType)type);
|
return p.program.size(slot, cast(SizeType)type);
|
||||||
}
|
}
|
||||||
|
static wstring PRGNAME(PetitComputer p)
|
||||||
|
{
|
||||||
|
return p.program.name(p.vm.currentSlotNumber);
|
||||||
|
}
|
||||||
|
static wstring PRGNAME(PetitComputer p, int slot)
|
||||||
|
{
|
||||||
|
return p.program.name(slot);
|
||||||
|
}
|
||||||
//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)
|
||||||
|
|||||||
@@ -1093,7 +1093,7 @@ class PetitComputer
|
|||||||
nodirectmode = true;
|
nodirectmode = true;
|
||||||
if (nodirectmode)
|
if (nodirectmode)
|
||||||
{
|
{
|
||||||
program.slot[0].load(readText(inputfile).to!wstring);
|
program.slot[0].load(inputfile.to!wstring, readText(inputfile).to!wstring);
|
||||||
runSlot(0);
|
runSlot(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -169,16 +169,18 @@ enum SizeType
|
|||||||
|
|
||||||
struct Slot
|
struct Slot
|
||||||
{
|
{
|
||||||
DList!wstring program;
|
private DList!wstring program;
|
||||||
DList!wstring.Range range;
|
private DList!wstring.Range range;
|
||||||
|
wstring name;
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
program = make!(DList!wstring)(["\n"w]);
|
program = make!(DList!wstring)(["\n"w]);
|
||||||
range = program[];
|
range = program[];
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(wstring data)
|
void load(wstring filename, wstring data)
|
||||||
{
|
{
|
||||||
|
name = filename;
|
||||||
program.clear();
|
program.clear();
|
||||||
foreach(l; splitter(data, "\n"))
|
foreach(l; splitter(data, "\n"))
|
||||||
{
|
{
|
||||||
@@ -324,11 +326,11 @@ struct Slot
|
|||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case SizeType.Line:
|
case SizeType.Line:
|
||||||
return program[].walkLength;
|
return cast(int)program[].walkLength;
|
||||||
case SizeType.Char:
|
case SizeType.Char:
|
||||||
return program[].map!(x => x.length).sum;
|
return cast(int)program[].map!(x => x.length).sum;
|
||||||
case SizeType.FreeChar:
|
case SizeType.FreeChar:
|
||||||
return (memorySize - program[].map!(x => x.length).sum).max(0);
|
return cast(int)(memorySize - program[].map!(x => x.length).sum).max(0);
|
||||||
default:
|
default:
|
||||||
throw new OutOfRange("PRGSIZE", 2);
|
throw new OutOfRange("PRGSIZE", 2);
|
||||||
}
|
}
|
||||||
@@ -383,4 +385,8 @@ class Program
|
|||||||
{
|
{
|
||||||
return this.slot[slot].size(st);
|
return this.slot[slot].size(st);
|
||||||
}
|
}
|
||||||
|
wstring name(int slot)
|
||||||
|
{
|
||||||
|
return this.slot[slot].name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user