annotate number.rhope @ 48:a24eb366195c

Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
author Mike Pavone <pavone@retrodev.com>
date Tue, 02 Mar 2010 00:18:49 -0500
parents
children 3e20ed8959c4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
48
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 Compile Number Method[backend, op, type:out]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 {
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5 name <- [[[op]Index[0]]Append["@"]]Append[type]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 backend func <- [op]Index[1]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 type inst <- Type Instance[type]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 func <- [[[[backend]Create Function[name,("a","b"), ("out"), "rhope"]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9 ]Set Input Type[type inst, 0]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 ]Set Input Type[type inst, 1]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 ]Set Output Type[type inst, 0]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
12
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13 ,ina <- [[func]Copy["a"]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14 ]Read Field["a", "Num"]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15 { ,inb <- [~]Read Field["b", "Num"]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 { ,outa <- [~]Write Field["a", "Num"]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 { after op <- [
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18 [backend func]Do[
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 [
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 [
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21 [
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22 [()]Append[~]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23 ]Append[ina]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
24 ]Append[inb]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
25 ]Append[outa] ]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
26 ]Index[0] }}}
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
27
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
28 out <- [backend]Store Function[ [[after op]Move["a","out"]]Release["b"] ]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
29
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
30 }
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
31
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
32 Compile Number Comp Method[backend, op, type:out]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
33 {
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
34 name <- [ [ [op]Index[0] ]Append["@"] ]Append[type]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
35 backend func <- [op]Index[1]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
36 type inst <- Type Instance[type]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
37 func <- [[[[[[ [backend]Create Function[name,("a","b"), ("out"), "rhope"]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
38 ]Set Input Type[type inst, 0]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
39 ]Set Input Type[type inst, 1]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
40 ]Set Output Type[Type Instance["Boolean"], 0]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
41 ]Register Constant["Blueprint_Boolean", Type Instance["Boolean"]]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
42 ]Call["Build", [()]Append[Constant["Blueprint_Boolean"]]]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
43 ]Move[Result[0], "out"]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
44
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
45 ,ina <- [func]Read Field["a", "Num"]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
46 { ,inb <- [~]Read Field["b", "Num"]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
47 { ,outa <- [~]Write Field["out", "Val"]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
48 { after op <- [
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
49 [backend func]Do[
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
50 [
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
51 [
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
52 [
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
53 [()]Append[~]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
54 ]Append[ina]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
55 ]Append[inb]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
56 ]Append[outa] ]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
57 ]Index[0] }}}
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
58
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
59 out <- [backend]Store Function[ [[after op]Release["a"]]Release["b"] ]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
60
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
61 }
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
62
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
63 _Generate Number Methods[backend, type:out]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
64 {
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
65 opmap <- (("+", "Add"), ("-", "Sub"), ("*", "Multiply"), ("/", "Divide"), ("LShift", "DoLShift"), ("RShift", "DoRShift"))
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
66 compops <- (("<", "CompLess"), (">", "CompGreater"), ("=", "CompEqual"), ("<=", "CompLessEqual"), (">=", "CompGreaterEqual"), ("!=", "CompNotEqual"))
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
67
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
68 Fold[["Compile Number Method"]Set Input[2, type], backend, opmap]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
69 { out <- Fold[["Compile Number Comp Method"]Set Input[2, type], ~, compops] }
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
70 }
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
71
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
72 Generate Number Methods[backend:out]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
73 {
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
74 numtypes <- ("Int8","Int16","Int32","UInt8","UInt16","UInt32")
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
75
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
76 out <- Fold["_Generate Number Methods", backend, numtypes]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
77 }
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
78
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
79 Register Number Method[program, method, type, outtype:out]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
80 {
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
81 name <- [[method]Append["@"]]Append[type]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
82 Print[["Regsiter Number Method: "]Append[name]]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
83 out <- [[program]Register Worker[name, "rhope", 2, 1]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
84 ]Bind Worker[name,
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
85 [[[[[NWorker["rhope"]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
86 ]Inputs <<[("left","right")]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
87 ]Input Types <<[ [[()]Append[ Type Instance[type]]]Append[Type Instance[type]] ]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
88 ]Outputs <<[("out")]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
89 ]Output Types <<[ [()]Append[Type Instance[outtype]] ]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
90 ]Builtin? <<[Yes]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
91 ]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
92 }
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
93
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
94 _Register Number Methods[program,type:out]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
95 {
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
96 Print[["_Regsiter Number Methods: "]Append[type]]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
97 methods <- ("+", "-", "*", "/", "LShift", "RShift")
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
98 compmethods <- ("<", ">", "=", "<=", ">=", "!=")
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
99 register <- ["Register Number Method"]Set Input[2, type]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
100 Fold[[register]Set Input[3, type], program, methods]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
101 { out <- Fold[[register]Set Input[3, "Boolean"], ~, compmethods] }
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
102 }
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
103
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
104 Register Number Methods[program:out]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
105 {
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
106 numtypes <- ("Int8","Int16","Int32","UInt8","UInt16","UInt32")
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
107 out <- Fold["_Register Number Methods", program, numtypes]
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
108 }
a24eb366195c Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
109