Mercurial > repos > rhope
annotate runtime/integer.c @ 37:640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 05 Oct 2009 23:12:43 -0400 |
parents | ea991f95ae1f |
children | a24eb366195c d2f9b0a9403d |
rev | line source |
---|---|
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include "integer.h" |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #include "builtin.h" |
8
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
3 #include "context.h" |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
4 #include "bool.h" |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
6 #define left ((t_Int32 *)cdata->params[0]) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
7 #define right ((t_Int32 *)cdata->params[1]) |
9
52d9948def24
Limit stack use in Int32 in prep for stack unwind changes
Mike Pavone <pavone@retrodev.com>
parents:
8
diff
changeset
|
8 |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
9 MethodNoLocals(_PL_,Int32, |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
10 NumParams 2, |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
11 CallSpace 1) |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
12 |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
13 CopiedParam(0, TYPE_INT32) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
14 Param(1, TYPE_INT32) |
8
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
15 |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 left->num += right->num; |
8
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
17 |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 release_ref((object *)right); |
8
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
19 EndFunc |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
21 MethodNoLocals(_MN_,Int32, |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
22 NumParams 2, |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
23 CallSpace 1) |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
24 |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
25 CopiedParam(0, TYPE_INT32) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
26 Param(1, TYPE_INT32) |
8
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
27 |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 left->num -= right->num; |
8
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
29 |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 release_ref((object *)right); |
8
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
31 EndFunc |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 |
37
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
33 MethodNoLocals(_TM_,Int32, |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
34 NumParams 2, |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
35 CallSpace 1) |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
36 |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
37 CopiedParam(0, TYPE_INT32) |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
38 Param(1, TYPE_INT32) |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
39 |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
40 left->num *= right->num; |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
41 |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
42 release_ref((object *)right); |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
43 EndFunc |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
44 |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
45 MethodNoLocals(_DV_,Int32, |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
46 NumParams 2, |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
47 CallSpace 1) |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
48 |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
49 CopiedParam(0, TYPE_INT32) |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
50 Param(1, TYPE_INT32) |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
51 |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
52 left->num /= right->num; |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
53 |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
54 release_ref((object *)right); |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
55 EndFunc |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
56 |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
57 MethodNoLocals(LShift,Int32, |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
58 NumParams 2, |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
59 CallSpace 1) |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
60 |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
61 CopiedParam(0, TYPE_INT32) |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
62 Param(1, TYPE_INT32) |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
63 |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
64 left->num <<= right->num; |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
65 |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
66 release_ref((object *)right); |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
67 EndFunc |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
68 |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
69 MethodNoLocals(RShift,Int32, |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
70 NumParams 2, |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
71 CallSpace 1) |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
72 |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
73 CopiedParam(0, TYPE_INT32) |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
74 Param(1, TYPE_INT32) |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
75 |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
76 left->num <<= right->num; |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
77 |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
78 release_ref((object *)right); |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
79 EndFunc |
640f541e9116
Added support for type declarations on user defined workers and added a few more methods to Int32 in the runtime for the C backend
Mike Pavone <pavone@retrodev.com>
parents:
18
diff
changeset
|
80 |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
81 MethodNoLocals(_LT_,Int32, |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
82 NumParams 2, |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
83 CallSpace 1) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
84 |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
85 Param(0, TYPE_INT32) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
86 Param(1, TYPE_INT32) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
87 |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
88 if(left->num < right->num) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
89 { |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
90 release_ref(cdata->params[0]); |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
91 Ret(0, Yes) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
92 } else { |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
93 release_ref(cdata->params[0]); |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
94 Ret(0, No) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
95 } |
18
ea991f95ae1f
C backend working well enough to generate Fib test
Mike Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
96 release_ref(cdata->params[1]); |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
97 EndFunc |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
98 |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
99 MethodNoLocals(_GT_,Int32, |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
100 NumParams 2, |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
101 CallSpace 1) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
102 |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
103 Param(0, TYPE_INT32) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
104 Param(1, TYPE_INT32) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
105 |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
106 if(left->num > right->num) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
107 { |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
108 release_ref(cdata->params[0]); |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
109 Ret(0, Yes) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
110 } else { |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
111 release_ref(cdata->params[0]); |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
112 Ret(0, No) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
113 } |
18
ea991f95ae1f
C backend working well enough to generate Fib test
Mike Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
114 release_ref(cdata->params[1]); |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
115 EndFunc |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
116 |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
117 object * make_Int32(int32_t val) |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
118 { |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
119 t_Int32 * obj; |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 object * ret = new_object(TYPE_INT32); |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
121 obj = (t_Int32 *)ret; |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
122 obj->num = val; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 return ret; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 } |