ASSERT関数を実装,関数定義の後のコードが実行されない問題を修正
This commit is contained in:
@@ -212,6 +212,7 @@
|
|||||||
<File path="node.d" />
|
<File path="node.d" />
|
||||||
<File path="parser.d" />
|
<File path="parser.d" />
|
||||||
<File path="petitcomputer.d" />
|
<File path="petitcomputer.d" />
|
||||||
|
<File path="TEST.txt" />
|
||||||
<File path="token.d" />
|
<File path="token.d" />
|
||||||
<File path="type.d" />
|
<File path="type.d" />
|
||||||
<File path="VM.d" />
|
<File path="VM.d" />
|
||||||
|
|||||||
28
SMILEBASIC/TEST.txt
Normal file
28
SMILEBASIC/TEST.txt
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
ASSERT__ 1, "TRUE"
|
||||||
|
A$="A"
|
||||||
|
ASSERT__ A$=="A", "A$==A"
|
||||||
|
A$=A$+"B"
|
||||||
|
ASSERT__ A$=="AB", "A$==AA"
|
||||||
|
A=0
|
||||||
|
INC A
|
||||||
|
ASSERT__ A==1, "A==1"
|
||||||
|
INC A, 3
|
||||||
|
ASSERT__ A==4, "A==4"
|
||||||
|
DEC A, 3
|
||||||
|
ASSERT__ A==1, "A==1"
|
||||||
|
DEC A
|
||||||
|
ASSERT__ A==0, "A==0"
|
||||||
|
INCTEST 0
|
||||||
|
DEF INCTEST A
|
||||||
|
INC A
|
||||||
|
ASSERT__ A==1, "A==1"
|
||||||
|
INC A, 3
|
||||||
|
ASSERT__ A==4, "A==4"
|
||||||
|
DEC A, 3
|
||||||
|
ASSERT__ A==1, "A==1"
|
||||||
|
DEC A
|
||||||
|
ASSERT__ A==0, "A==0"
|
||||||
|
END
|
||||||
|
LOCATE 10,
|
||||||
|
COLOR 1,15
|
||||||
|
PRINT "テスト正常終了"
|
||||||
@@ -94,6 +94,14 @@ class BuiltinFunction
|
|||||||
{
|
{
|
||||||
p.cls;
|
p.cls;
|
||||||
}
|
}
|
||||||
|
static void ASSERT__(PetitComputer p, int cond, wstring message)
|
||||||
|
{
|
||||||
|
if(!cond)
|
||||||
|
{
|
||||||
|
p.printConsole("Assertion failed: ", message, "\n");
|
||||||
|
}
|
||||||
|
assert(cond, message.to!string);
|
||||||
|
}
|
||||||
//alias void function(PetitComputer, Value[], Value[]) BuiltinFunc;
|
//alias void function(PetitComputer, Value[], Value[]) BuiltinFunc;
|
||||||
static BuiltinFunction[wstring] builtinFunctions;
|
static BuiltinFunction[wstring] builtinFunctions;
|
||||||
static this()
|
static this()
|
||||||
@@ -202,6 +210,10 @@ template GetFunctionParamType(T, string N)
|
|||||||
{
|
{
|
||||||
const string arg = "ValueType.Integer, false";
|
const string arg = "ValueType.Integer, false";
|
||||||
}
|
}
|
||||||
|
else static if(is(P[0] == wstring))
|
||||||
|
{
|
||||||
|
const string arg = "ValueType.String, false";
|
||||||
|
}
|
||||||
else static if(is(P[0] == DefaultValue!int))
|
else static if(is(P[0] == DefaultValue!int))
|
||||||
{
|
{
|
||||||
const string arg = "ValueType.Integer, true";
|
const string arg = "ValueType.Integer, true";
|
||||||
@@ -250,6 +262,11 @@ template AddFuncArg(int L, int N, int M, P...)
|
|||||||
enum add = 1;
|
enum add = 1;
|
||||||
const string arg = "arg[" ~ I.to!string ~ "].castInteger";
|
const string arg = "arg[" ~ I.to!string ~ "].castInteger";
|
||||||
}
|
}
|
||||||
|
else static if(is(P[0] == wstring))
|
||||||
|
{
|
||||||
|
enum add = 1;
|
||||||
|
const string arg = "arg[" ~ I.to!string ~ "].castString";
|
||||||
|
}
|
||||||
else static if(is(P[0] == DefaultValue!int))
|
else static if(is(P[0] == DefaultValue!int))
|
||||||
{
|
{
|
||||||
enum add = 1;
|
enum add = 1;
|
||||||
|
|||||||
@@ -537,6 +537,7 @@ class Parser
|
|||||||
}
|
}
|
||||||
isFuncReturnExpr = node.returnExpr;//面倒くさい
|
isFuncReturnExpr = node.returnExpr;//面倒くさい
|
||||||
node.functionBody = functionStatements();
|
node.functionBody = functionStatements();
|
||||||
|
lex.popFront();
|
||||||
isFuncReturnExpr = false;
|
isFuncReturnExpr = false;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ class PetitComputer
|
|||||||
}
|
}
|
||||||
}+/
|
}+/
|
||||||
//とりあえず
|
//とりあえず
|
||||||
auto parser = new Parser(/*readText("FIZZBUZZ.TXT").to!wstring*//*"
|
auto parser = new Parser(readText("TEST.TXT").to!wstring/*readText("FIZZBUZZ.TXT").to!wstring*//*"
|
||||||
?ABS(-1)
|
?ABS(-1)
|
||||||
LOCATE 0,10
|
LOCATE 0,10
|
||||||
COLOR 5
|
COLOR 5
|
||||||
@@ -357,10 +357,10 @@ NEXT
|
|||||||
DEF FACT(N)
|
DEF FACT(N)
|
||||||
IF N<=1 THEN RETURN 1
|
IF N<=1 THEN RETURN 1
|
||||||
RETURN N*FACT(N-1)
|
RETURN N*FACT(N-1)
|
||||||
END"*/
|
END"*//*
|
||||||
`CLS : CL=0 : Z=0
|
`CLS : CL=0 : Z=0
|
||||||
WHILE 1
|
WHILE 1
|
||||||
INC Z
|
INC Z,2
|
||||||
?Z,
|
?Z,
|
||||||
WEND
|
WEND
|
||||||
WHILE 1
|
WHILE 1
|
||||||
@@ -370,7 +370,7 @@ WHILE 1
|
|||||||
PRINT "★ 梅雨で雨が多い季節ですね ★"
|
PRINT "★ 梅雨で雨が多い季節ですね ★"
|
||||||
NEXT
|
NEXT
|
||||||
CL=(CL+1) MOD 16 : VSYNC 2
|
CL=(CL+1) MOD 16 : VSYNC 2
|
||||||
WEND`/*
|
WEND`*//*
|
||||||
`CLS : CL=0
|
`CLS : CL=0
|
||||||
WHILE 1
|
WHILE 1
|
||||||
FOR I=0 TO 15
|
FOR I=0 TO 15
|
||||||
@@ -452,7 +452,7 @@ GOTO @LOOP`*/
|
|||||||
auto back = console[y][x].backColor;
|
auto back = console[y][x].backColor;
|
||||||
auto fore = consoleColor[console[y][x].foreColor];
|
auto fore = consoleColor[console[y][x].foreColor];
|
||||||
auto texture = GRPFColor[back].texture;
|
auto texture = GRPFColor[back].texture;
|
||||||
//SDL_RenderCopy(renderer, texture, &fontTable[console[y][x].charater], &rect);
|
SDL_RenderCopy(renderer, texture, &fontTable[console[y][x].charater], &rect);
|
||||||
SDL_SetTextureColorMod(GRPF.texture, fore >> 16 & 0xFF, fore >> 8 & 0xFF, fore & 0xFF);
|
SDL_SetTextureColorMod(GRPF.texture, fore >> 16 & 0xFF, fore >> 8 & 0xFF, fore & 0xFF);
|
||||||
SDL_SetTextureAlphaMod(GRPF.texture, fore >> 24 & 0xFF);
|
SDL_SetTextureAlphaMod(GRPF.texture, fore >> 24 & 0xFF);
|
||||||
SDL_RenderCopy(renderer, GRPF.texture, &fontTable[console[y][x].charater], &rect);
|
SDL_RenderCopy(renderer, GRPF.texture, &fontTable[console[y][x].charater], &rect);
|
||||||
|
|||||||
@@ -90,6 +90,10 @@ struct Value
|
|||||||
{
|
{
|
||||||
return this.type == ValueType.Integer ? this.integerValue : (this.type == ValueType.Double ? this.doubleValue : 0);
|
return this.type == ValueType.Integer ? this.integerValue : (this.type == ValueType.Double ? this.doubleValue : 0);
|
||||||
}
|
}
|
||||||
|
wstring castString()
|
||||||
|
{
|
||||||
|
return this.type == ValueType.String ? this.stringValue : "";
|
||||||
|
}
|
||||||
string toString()
|
string toString()
|
||||||
{
|
{
|
||||||
import std.conv;
|
import std.conv;
|
||||||
|
|||||||
Reference in New Issue
Block a user