Mercurial > repos > rhope
annotate runtime/integer.c @ 17:d05184970c1c
Merged accidentally created head
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 26 May 2009 23:37:59 -0400 |
parents | 31f8182f3433 |
children | ea991f95ae1f |
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 |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
33 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
|
34 NumParams 2, |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
35 CallSpace 1) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
36 |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
37 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
|
38 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
|
39 |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
40 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
|
41 { |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
42 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
|
43 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
|
44 } else { |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
45 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
|
46 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
|
47 } |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
48 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
|
49 EndFunc |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
50 |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
51 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
|
52 NumParams 2, |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
53 CallSpace 1) |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
54 |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
55 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
|
56 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
|
57 |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
58 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
|
59 { |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
60 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
|
61 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
|
62 } else { |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
63 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
|
64 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
|
65 } |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
66 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
|
67 EndFunc |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
68 |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 object * make_Int32(int32_t val) |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 { |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
71 t_Int32 * obj; |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 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
|
73 obj = (t_Int32 *)ret; |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 obj->num = val; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 return ret; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 } |