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");
|
||||
context.Text.WriteFUNC(builtinInfo.Index, 0);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -96,18 +86,4 @@
|
|||
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
|
||||
DeclareSystemBuiltin("yield", false);
|
||||
DeclareSystemBuiltin("exit", false);
|
||||
DeclareSystemBuiltin("dump", false);
|
||||
DeclareSystemBuiltin("lock", false);
|
||||
DeclareSystemBuiltin("unlock", false);
|
||||
DeclareSystemBuiltin("int", false, "x");
|
||||
DeclareSystemBuiltin("float", false, "x");
|
||||
DeclareSystemBuiltin("typeof", false, "x");
|
||||
DeclareSystemBuiltin("print", true);
|
||||
}
|
||||
public void Close() {
|
||||
if (!mOpen) {
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace arookas {
|
|||
"builtin", "function", "var", "const",
|
||||
"if", "while", "do", "for",
|
||||
"return", "break", "continue",
|
||||
"yield", "exit", "dump", "lock", "unlock", "int", "float", "typeof", "print",
|
||||
"yield", "exit", "lock", "unlock", "int", "float", "typeof",
|
||||
"true", "false",
|
||||
};
|
||||
|
||||
|
@ -83,10 +83,8 @@ namespace arookas {
|
|||
|
||||
case __sunConstants.YIELD_STATEMENT: return new sunYield(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.UNLOCK_STATEMENT: return new sunUnlock(location);
|
||||
case __sunConstants.PRINT_STATEMENT: return new sunPrint(location);
|
||||
}
|
||||
|
||||
// literals
|
||||
|
@ -234,13 +232,11 @@ namespace arookas {
|
|||
|
||||
case __sunConstants.YIELD:
|
||||
case __sunConstants.EXIT:
|
||||
case __sunConstants.DUMP:
|
||||
case __sunConstants.LOCK:
|
||||
case __sunConstants.UNLOCK:
|
||||
case __sunConstants.INT:
|
||||
case __sunConstants.FLOAT:
|
||||
case __sunConstants.TYPEOF:
|
||||
case __sunConstants.PRINT:
|
||||
|
||||
case __sunConstants.TRUE:
|
||||
case __sunConstants.FALSE:
|
||||
|
|
|
@ -41,13 +41,11 @@ CONTINUE = "continue"
|
|||
|
||||
YIELD = "yield"
|
||||
EXIT = "exit"
|
||||
DUMP = "dump"
|
||||
LOCK = "lock"
|
||||
UNLOCK = "unlock"
|
||||
INT = "int"
|
||||
FLOAT = "float"
|
||||
TYPEOF = "typeof"
|
||||
PRINT = "print"
|
||||
|
||||
TRUE = "true"
|
||||
FALSE = "false"
|
||||
|
@ -131,7 +129,6 @@ statement =
|
|||
continue_statement SEMICOLON |
|
||||
yield_statement SEMICOLON |
|
||||
exit_statement SEMICOLON |
|
||||
dump_statement SEMICOLON |
|
||||
lock_statement SEMICOLON |
|
||||
unlock_statement SEMICOLON |
|
||||
statement_block;
|
||||
|
@ -142,17 +139,14 @@ compound_statement_item =
|
|||
variable_declaration |
|
||||
variable_assignment |
|
||||
variable_augment |
|
||||
print_statement |
|
||||
function_call;
|
||||
statement_block = L_BRACE {statement} R_BRACE;
|
||||
|
||||
import_statement = IMPORT STRING;
|
||||
yield_statement = YIELD;
|
||||
exit_statement = EXIT;
|
||||
dump_statement = DUMP;
|
||||
lock_statement = LOCK;
|
||||
unlock_statement = UNLOCK;
|
||||
print_statement = PRINT argument_list;
|
||||
|
||||
name_label = IDENTIFIER COLON;
|
||||
|
||||
|
|
|
@ -10,6 +10,10 @@ const TYPE_INT = 0;
|
|||
const TYPE_FLOAT = 1;
|
||||
const TYPE_STRING = 2;
|
||||
|
||||
// debug
|
||||
builtin dump();
|
||||
builtin print(...);
|
||||
|
||||
import "system.sun";
|
||||
import "talk.sun";
|
||||
import "sound.sun";
|
||||
|
|
Loading…
Reference in a new issue