Moved dump and print to common.sun.
This commit is contained in:
parent
72ea2a031c
commit
ed4822ee29
5 changed files with 5 additions and 37 deletions
|
@ -18,16 +18,6 @@
|
||||||
var builtinInfo = context.ResolveSystemBuiltin("exit");
|
var builtinInfo = context.ResolveSystemBuiltin("exit");
|
||||||
context.Text.WriteFUNC(builtinInfo.Index, 0);
|
context.Text.WriteFUNC(builtinInfo.Index, 0);
|
||||||
context.Text.WritePOP();
|
context.Text.WritePOP();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class sunDump : sunNode {
|
|
||||||
public sunDump(sunSourceLocation location)
|
|
||||||
: base(location) { }
|
|
||||||
|
|
||||||
public override void Compile(sunContext context) {
|
|
||||||
var builtinInfo = context.ResolveSystemBuiltin("dump");
|
|
||||||
context.Text.WriteFUNC(builtinInfo.Index, 0);
|
|
||||||
context.Text.WritePOP();
|
context.Text.WritePOP();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,18 +86,4 @@
|
||||||
Compile(context, context.ResolveSystemBuiltin("typeof"));
|
Compile(context, context.ResolveSystemBuiltin("typeof"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class sunPrint : sunNode {
|
|
||||||
public sunNode ArgumentList { get { return this[0]; } }
|
|
||||||
|
|
||||||
public sunPrint(sunSourceLocation location)
|
|
||||||
: base(location) { }
|
|
||||||
|
|
||||||
public override void Compile(sunContext context) {
|
|
||||||
var builtinInfo = context.ResolveSystemBuiltin("print");
|
|
||||||
ArgumentList.Compile(context);
|
|
||||||
context.Text.WriteFUNC(builtinInfo.Index, ArgumentList.Count);
|
|
||||||
context.Text.WritePOP();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,13 +59,11 @@ namespace arookas {
|
||||||
// add system builtins
|
// add system builtins
|
||||||
DeclareSystemBuiltin("yield", false);
|
DeclareSystemBuiltin("yield", false);
|
||||||
DeclareSystemBuiltin("exit", false);
|
DeclareSystemBuiltin("exit", false);
|
||||||
DeclareSystemBuiltin("dump", false);
|
|
||||||
DeclareSystemBuiltin("lock", false);
|
DeclareSystemBuiltin("lock", false);
|
||||||
DeclareSystemBuiltin("unlock", false);
|
DeclareSystemBuiltin("unlock", false);
|
||||||
DeclareSystemBuiltin("int", false, "x");
|
DeclareSystemBuiltin("int", false, "x");
|
||||||
DeclareSystemBuiltin("float", false, "x");
|
DeclareSystemBuiltin("float", false, "x");
|
||||||
DeclareSystemBuiltin("typeof", false, "x");
|
DeclareSystemBuiltin("typeof", false, "x");
|
||||||
DeclareSystemBuiltin("print", true);
|
|
||||||
}
|
}
|
||||||
public void Close() {
|
public void Close() {
|
||||||
if (!mOpen) {
|
if (!mOpen) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace arookas {
|
||||||
"builtin", "function", "var", "const",
|
"builtin", "function", "var", "const",
|
||||||
"if", "while", "do", "for",
|
"if", "while", "do", "for",
|
||||||
"return", "break", "continue",
|
"return", "break", "continue",
|
||||||
"yield", "exit", "dump", "lock", "unlock", "int", "float", "typeof", "print",
|
"yield", "exit", "lock", "unlock", "int", "float", "typeof",
|
||||||
"true", "false",
|
"true", "false",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,10 +83,8 @@ namespace arookas {
|
||||||
|
|
||||||
case __sunConstants.YIELD_STATEMENT: return new sunYield(location);
|
case __sunConstants.YIELD_STATEMENT: return new sunYield(location);
|
||||||
case __sunConstants.EXIT_STATEMENT: return new sunExit(location);
|
case __sunConstants.EXIT_STATEMENT: return new sunExit(location);
|
||||||
case __sunConstants.DUMP_STATEMENT: return new sunDump(location);
|
|
||||||
case __sunConstants.LOCK_STATEMENT: return new sunLock(location);
|
case __sunConstants.LOCK_STATEMENT: return new sunLock(location);
|
||||||
case __sunConstants.UNLOCK_STATEMENT: return new sunUnlock(location);
|
case __sunConstants.UNLOCK_STATEMENT: return new sunUnlock(location);
|
||||||
case __sunConstants.PRINT_STATEMENT: return new sunPrint(location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// literals
|
// literals
|
||||||
|
@ -234,13 +232,11 @@ namespace arookas {
|
||||||
|
|
||||||
case __sunConstants.YIELD:
|
case __sunConstants.YIELD:
|
||||||
case __sunConstants.EXIT:
|
case __sunConstants.EXIT:
|
||||||
case __sunConstants.DUMP:
|
|
||||||
case __sunConstants.LOCK:
|
case __sunConstants.LOCK:
|
||||||
case __sunConstants.UNLOCK:
|
case __sunConstants.UNLOCK:
|
||||||
case __sunConstants.INT:
|
case __sunConstants.INT:
|
||||||
case __sunConstants.FLOAT:
|
case __sunConstants.FLOAT:
|
||||||
case __sunConstants.TYPEOF:
|
case __sunConstants.TYPEOF:
|
||||||
case __sunConstants.PRINT:
|
|
||||||
|
|
||||||
case __sunConstants.TRUE:
|
case __sunConstants.TRUE:
|
||||||
case __sunConstants.FALSE:
|
case __sunConstants.FALSE:
|
||||||
|
|
|
@ -41,13 +41,11 @@ CONTINUE = "continue"
|
||||||
|
|
||||||
YIELD = "yield"
|
YIELD = "yield"
|
||||||
EXIT = "exit"
|
EXIT = "exit"
|
||||||
DUMP = "dump"
|
|
||||||
LOCK = "lock"
|
LOCK = "lock"
|
||||||
UNLOCK = "unlock"
|
UNLOCK = "unlock"
|
||||||
INT = "int"
|
INT = "int"
|
||||||
FLOAT = "float"
|
FLOAT = "float"
|
||||||
TYPEOF = "typeof"
|
TYPEOF = "typeof"
|
||||||
PRINT = "print"
|
|
||||||
|
|
||||||
TRUE = "true"
|
TRUE = "true"
|
||||||
FALSE = "false"
|
FALSE = "false"
|
||||||
|
@ -131,7 +129,6 @@ statement =
|
||||||
continue_statement SEMICOLON |
|
continue_statement SEMICOLON |
|
||||||
yield_statement SEMICOLON |
|
yield_statement SEMICOLON |
|
||||||
exit_statement SEMICOLON |
|
exit_statement SEMICOLON |
|
||||||
dump_statement SEMICOLON |
|
|
||||||
lock_statement SEMICOLON |
|
lock_statement SEMICOLON |
|
||||||
unlock_statement SEMICOLON |
|
unlock_statement SEMICOLON |
|
||||||
statement_block;
|
statement_block;
|
||||||
|
@ -142,17 +139,14 @@ compound_statement_item =
|
||||||
variable_declaration |
|
variable_declaration |
|
||||||
variable_assignment |
|
variable_assignment |
|
||||||
variable_augment |
|
variable_augment |
|
||||||
print_statement |
|
|
||||||
function_call;
|
function_call;
|
||||||
statement_block = L_BRACE {statement} R_BRACE;
|
statement_block = L_BRACE {statement} R_BRACE;
|
||||||
|
|
||||||
import_statement = IMPORT STRING;
|
import_statement = IMPORT STRING;
|
||||||
yield_statement = YIELD;
|
yield_statement = YIELD;
|
||||||
exit_statement = EXIT;
|
exit_statement = EXIT;
|
||||||
dump_statement = DUMP;
|
|
||||||
lock_statement = LOCK;
|
lock_statement = LOCK;
|
||||||
unlock_statement = UNLOCK;
|
unlock_statement = UNLOCK;
|
||||||
print_statement = PRINT argument_list;
|
|
||||||
|
|
||||||
name_label = IDENTIFIER COLON;
|
name_label = IDENTIFIER COLON;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,10 @@ const TYPE_INT = 0;
|
||||||
const TYPE_FLOAT = 1;
|
const TYPE_FLOAT = 1;
|
||||||
const TYPE_STRING = 2;
|
const TYPE_STRING = 2;
|
||||||
|
|
||||||
|
// debug
|
||||||
|
builtin dump();
|
||||||
|
builtin print(...);
|
||||||
|
|
||||||
import "system.sun";
|
import "system.sun";
|
||||||
import "talk.sun";
|
import "talk.sun";
|
||||||
import "sound.sun";
|
import "sound.sun";
|
||||||
|
|
Loading…
Reference in a new issue