annotate number.rhope @ 182:db30bda91aad

Cleanup grammar comment in new parser
author Mike Pavone <pavone@retrodev.com>
date Wed, 27 Jul 2011 21:06:57 -0700
parents e73a93fb5de1
children
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
51
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
63 Compile Conversion Method[backend,intype,outtype,prefix:out]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
64 {
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
65 func <- [[[[[[backend]Create Function[[prefix]Append[[[outtype]Append["@"]]Append[intype]], ("in"), ("out"), "rhope"]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
66 ]Set Input Type[Type Instance[intype], 0]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
67 ]Set Output Type[Type Instance[outtype], 0]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
68 ]Register Constant[["Blueprint_"]Append[outtype], Type Instance[outtype]]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
69 ]Call["Build", [()]Append[ Constant[["Blueprint_"]Append[outtype]] ]]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
70 ]Move[Result[0], "out"]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
71
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
72 ,src <- [func]Read Field["in", "Num"]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
73 { ,dst <- [~]Write Field["out", "Num"]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
74 { ffunc <- [[~]Move[src, dst]]Release["in"] }}
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
75
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
76 out <- [backend]Store Function[ffunc]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
77 }
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
78
92
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
79 Compile Abs UInt Method[backend,type:out]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
80 {
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
81 outtype <- ["U"]Append[type]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
82 func <- [[[[[[[[[backend]Create Function[["Abs UInt@"]Append[type], ("in"), ("out"), "rhope"]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
83 ]Set Input Type[Type Instance[type], 0]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
84 ]Set Output Type[Type Instance[["U"]Append[type]], 0]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
85 ]Register Constant[["Blueprint_"]Append[outtype], Type Instance[outtype]]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
86 ]Allocate Var["abs", Type Instance[type]]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
87 ]Call["Build", [()]Append[ Constant[["Blueprint_"]Append[outtype]] ]]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
88 ]Move[Result[0], "out"]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
89 ]Call["Abs", [()]Append["in"]]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
90 ]Move[Result[0], "abs"]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
91 { Print["After Call to Abs"] }
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
92
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
93 ,src <- [func]Read Field["abs", "Num"]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
94 { ,dst <- [~]Write Field["out", "Num"]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
95 { ffunc <- [[~]Move[src, dst]]Release["abs"] }}
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
96
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
97 out <- [backend]Store Function[ffunc]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
98 }
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
99
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
100 _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
101 {
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 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
103 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
104
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 Fold[["Compile Number Method"]Set Input[2, type], backend, opmap]
51
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
106 { Fold[["Compile Number Comp Method"]Set Input[2, type], ~, compops]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
107 { Fold[[["Compile Conversion Method"]Set Input[1, type]]Set Input[3, ""], ~, Legal Conversions[type]]
92
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
108 {
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
109 almost <- Fold[[["Compile Conversion Method"]Set Input[1, type]]Set Input[3, "Trunc "], ~, Truncations[type]]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
110 If[[type]Starts With["I"]]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
111 {
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
112 out <- Compile Abs UInt Method[almost,type]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
113 }{
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
114 out <- Val[almost]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
115 }
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
116 }}}
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
117 }
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
118
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
119 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
120 {
49
3e20ed8959c4 Added initial FFI implementation, Array type and 64-bit integers
Mike Pavone <pavone@retrodev.com>
parents: 48
diff changeset
121 numtypes <- ("Int8","Int16","Int32","Int64","UInt8","UInt16","UInt32","UInt64")
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
122
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
123 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
124 }
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
125
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
126 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
127 {
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
128 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
129 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
130 ]Bind Worker[name,
92
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
131 [[[[[NWorker["rhope"]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
132 ]Inputs <<[("left","right")]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
133 ]Input Types <<[ [[()]Append[ Type Instance[type]]]Append[Type Instance[type]] ]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
134 ]Outputs <<[("out")]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
135 ]Output Types <<[ [()]Append[Type Instance[outtype]] ]
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
136 ]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
137 ]
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
138 }
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
139
51
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
140 Register Conversion Method[program, intype, outtype,prefix:out]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
141 {
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
142 name <- [prefix]Append[[[outtype]Append["@"]]Append[intype]]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
143 out <- [[program]Register Worker[name, "rhope", 1, 1]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
144 ]Bind Worker[name,
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
145 [[[[[NWorker["rhope"]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
146 ]Inputs <<[("in")]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
147 ]Input Types <<[ [()]Append[Type Instance[intype]] ]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
148 ]Outputs <<[("out")]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
149 ]Output Types <<[ [()]Append[Type Instance[outtype]] ]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
150 ]Builtin? <<[Yes]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
151 ]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
152 }
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
153
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
154 Legal Conversions[type:convs]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
155 {
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
156 bigger <- Filter[(16,32,64), [">"]Set Input[1, size]]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
157 base convs <- Map[bigger, ["Append"]Set Input[0, "Int"]]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
158 If[[type]Starts With["U"]]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
159 {
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
160 [type]Slice[4] {}
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
161 { size <- <String@Whole Number[~] }
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
162 convs <- Concatenate[base convs, Map[bigger, ["Append"]Set Input[0, "UInt"]]]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
163 }{
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
164 [type]Slice[3] {}
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
165 { size <- <String@Whole Number[~] }
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
166 convs <- Val[base convs]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
167 }
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
168 }
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
169
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
170 Truncations[type:truncs]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
171 {
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
172 ,u <- [type]Get DString["Int"]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
173 { size <- <String@Whole Number[~] }
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
174 truncs <- Map[Filter[(8,16,32), ["<"]Set Input[1, size]], ["Append"]Set Input[0, [u]Append["Int"]]]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
175 }
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
176
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
177 _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
178 {
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
179 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
180 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
181 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
182 Fold[[register]Set Input[3, type], program, methods]
51
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
183 { Fold[[register]Set Input[3, "Boolean"], ~, compmethods]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
184 { Fold[[["Register Conversion Method"]Set Input[1, type]]Set Input[3, ""], ~, Legal Conversions[type]]
92
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
185 {
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
186 almost <- Fold[[["Register Conversion Method"]Set Input[1, type]]Set Input[3, "Trunc "], ~, Truncations[type]]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
187 If[[type]Starts With["I"]]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
188 {
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
189 name <- ["Abs UInt@"]Append[type]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
190 out <- [[almost]Register Worker[name, "rhope", 1, 1]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
191 ]Bind Worker[name
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
192 [[[[[NWorker["rhope"]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
193 ]Inputs <<[("in")]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
194 ]Input Types <<[ [()]Append[Type Instance[type]] ]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
195 ]Outputs <<[("out")]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
196 ]Output Types <<[ [()]Append[Type Instance[["U"]Append[type]]] ]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
197 ]Builtin? <<[Yes]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
198 ]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
199 }{
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
200 out <- Val[almost]
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
201 }
e73a93fb5de1 Beginning of port of compiler to itself, some bugfixes and a refcount optimization
Mike Pavone <pavone@retrodev.com>
parents: 69
diff changeset
202 }}}
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
203 }
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
204
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
205 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
206 {
49
3e20ed8959c4 Added initial FFI implementation, Array type and 64-bit integers
Mike Pavone <pavone@retrodev.com>
parents: 48
diff changeset
207 numtypes <- ("Int8","Int16","Int32","Int64","UInt8","UInt16","UInt32","UInt64")
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
208 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
209 }
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
210