-
Notifications
You must be signed in to change notification settings - Fork 1
/
dos_dispatch.inc
97 lines (87 loc) · 3.06 KB
/
dos_dispatch.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* Generated by kalos_idl_compiler - DO NOT MODIFY */
#define K__pstring kalos_string*
#define K__string kalos_string
#define K__pnumber kalos_int
#define K__number kalos_int
#define K__pbool kalos_int
#define K__bool kalos_int
#define K__pobject kalos_object_ref*
#define K__object kalos_object_ref
#define K__pany kalos_value*
#define K__any kalos_value
#define K__t_string KALOS_VALUE_STRING
#define K__t_number KALOS_VALUE_NUMBER
#define K__t_bool KALOS_VALUE_BOOL
#define K__t_object KALOS_VALUE_OBJECT
#define K__t_any KALOS_VALUE_ANY
#define K__final_string(stack, x) if (retval) { push_string(stack, x); } else { kalos_string_release((kalos_state*)state, x);; }
#define K__final_number(stack, x) if (retval) { push_number(stack, x); } else { ;; }
#define K__final_bool(stack, x) if (retval) { push_bool(stack, x); } else { ;; }
#define K__final_object(stack, x) if (retval) { push_object(stack, x); } else { kalos_object_release((kalos_state*)state, &x);; }
#define K__final_any(stack, x) if (retval) { push_any(stack, x); } else { kalos_clear((kalos_state*)state, &x);; }
#define K__arg(n, x) peek(stack, (n)-(x))
#define K__arg_string(x) &((x)->value.string)
#define K__arg_number(x) (x)->value.number
#define K__arg_bool(x) (x)->value.number
#define K__arg_object(x) &((x)->value.object)
#define K__arg_any(x) (x)
#define K__match(id, n, s) (param_count == n && function == id)
bool builtin(kalos_run_state* state, int function, int param_count, kalos_stack* stack, bool retval) {
// id=1 name=print arg_count=1 binding=fn dos_print
if (K__match(/*id=*/1, /*args=*/1, /*name=*/print)) {
const int arg_count = 1;
if (kalos_stack_setup_1(state, arg_count, K__t_string)) {
dos_print((void*)state, K__arg_string(K__arg(arg_count, 1)));
kalos_stack_cleanup(state, arg_count);
return true;
}
}
// id=2 name=println arg_count=1 binding=fn dos_println
if (K__match(/*id=*/2, /*args=*/1, /*name=*/println)) {
const int arg_count = 1;
if (kalos_stack_setup_1(state, arg_count, K__t_string)) {
dos_println((void*)state, K__arg_string(K__arg(arg_count, 1)));
kalos_stack_cleanup(state, arg_count);
return true;
}
}
return false;
}
// id=0001:0001 name=main
void dos_trigger_main(kalos_run_state* state) {
kalos_trigger(state, kalos_make_address(0x1, 0x1));
}
bool dos(kalos_run_state* state, int function, int param_count, kalos_stack* stack, bool retval) {
return false;
}
kalos_dispatch_fn dispatch[] = {
builtin,
dos,
};
#undef K__pstring
#undef K__string
#undef K__pnumber
#undef K__number
#undef K__pbool
#undef K__bool
#undef K__pobject
#undef K__object
#undef K__pany
#undef K__any
#undef K__t_string
#undef K__t_number
#undef K__t_bool
#undef K__t_object
#undef K__t_any
#undef K__final_string
#undef K__final_number
#undef K__final_bool
#undef K__final_object
#undef K__final_any
#undef K__arg
#undef K__arg_string
#undef K__arg_number
#undef K__arg_bool
#undef K__arg_object
#undef K__arg_any
#undef K__match