diff --git a/SMILEBASIC/SMILEBASIC.visualdproj b/SMILEBASIC/SMILEBASIC.visualdproj
index e59c89c..9f6e23a 100644
--- a/SMILEBASIC/SMILEBASIC.visualdproj
+++ b/SMILEBASIC/SMILEBASIC.visualdproj
@@ -53,7 +53,7 @@
$(CC) -c
1
$(DMDInstallDir)windows\bin\dmd.exe
-
+ $(DMDInstallDir)src
$(ConfigurationName)
$(OutDir)
@@ -89,8 +89,8 @@
-
-
+ DerelictSDL2.lib;DerelictUtil.lib
+ $(DMDInstallDir)windows\lib\
$(OutDir)\$(ProjectName).exe
@@ -210,6 +210,7 @@
+
diff --git a/SMILEBASIC/compiler.d b/SMILEBASIC/compiler.d
index 5a577a5..b23773e 100644
--- a/SMILEBASIC/compiler.d
+++ b/SMILEBASIC/compiler.d
@@ -154,31 +154,31 @@ class Compiler
void genCodePushVar(wstring name, Scope sc)
{
auto global = hasGlobalVarIndex(name);
- if(global)
- {
- code ~= new PushG(global);
- return;
- }
if(sc.func)
{
code ~= new PushL(sc.func.getLocalVarIndex(name, this));
return;
}
+ if(global)
+ {
+ code ~= new PushG(global);
+ return;
+ }
code ~= new PushG(getGlobalVarIndex(name));
}
void genCodePopVar(wstring name, Scope sc)
{
auto global = hasGlobalVarIndex(name);
- if(global)
- {
- code ~= new PopG(global);
- return;
- }
if(sc.func)
{
code ~= new PopL(sc.func.getLocalVarIndex(name, this));
return;
}
+ if(global)
+ {
+ code ~= new PopG(global);
+ return;
+ }
code ~= new PopG(getGlobalVarIndex(name));
}
void genCodeOP(TokenType op)
diff --git a/SMILEBASIC/main.d b/SMILEBASIC/main.d
index 4b90b2b..8e230eb 100644
--- a/SMILEBASIC/main.d
+++ b/SMILEBASIC/main.d
@@ -15,7 +15,10 @@ int main(string[] argv)
auto parser = new Parser(
//"@A\nA=1+2+3+4\nPRINT 1+1,2+3;10-5,A:A=A*2 PRINT A
-"IF 1 THEN PRINT 2
+"
+TEST2 6,7,8 OUT K,L,M
+?K,L,M
+IF 1 THEN PRINT 2
IF 0 THEN PRINT 4 ELSE PRINT 5
IF 0 THEN
PRINT 111
@@ -67,6 +70,8 @@ NEXT
TEST \"HELLO\",\",\",\"WORLD\"
TEST2 6,7,8 OUT K,L,M
?K,L,M
+FACT 10 OUT F
+?F
END
@A
?\"SUBROUTINE TEST\"
@@ -87,12 +92,17 @@ DEF FACT(N)
END
DEF TEST A,B,C
?\"TEST\",A,B,C
+ RETURN
END
+?\"CHECK\"
DEF TEST2 A,B,C OUT D,E,F
- ?\"TEST\",A,B,C
+ ?\"TEST2\",A,B,C
+ F=C
+ F=C
D=A
E=B
- F=C
+ ?F
+ RETURN
END
");
version(none) auto parser = new Parser(readText("FIZZBUZZ.TXT").to!wstring);
diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d
new file mode 100644
index 0000000..dcdbfef
--- /dev/null
+++ b/SMILEBASIC/petitcomputer.d
@@ -0,0 +1,9 @@
+module otya.smilebasic.petitcomputer;
+import derelict.sdl2.sdl;
+class PetitComputer
+{
+ this()
+ {
+ DerelictSDL2.load();
+ }
+}
\ No newline at end of file
diff --git a/SMILEBASIC/type.d b/SMILEBASIC/type.d
index a120aa5..380c9bc 100644
--- a/SMILEBASIC/type.d
+++ b/SMILEBASIC/type.d
@@ -90,6 +90,21 @@ struct Value
{
return this.type == ValueType.Integer ? this.integerValue : (this.type == ValueType.Double ? this.doubleValue : 0);
}
+ string toString()
+ {
+ import std.conv;
+ switch(this.type)
+ {
+ case ValueType.Void:
+ return "void";
+ case ValueType.Integer:
+ return this.integerValue.to!string;
+ case ValueType.String:
+ return this.stringValue.to!string;
+ default:
+ return "default";
+ }
+ }
}
class Array(T)
{