annotate number.rhope @ 75:0083b2f7b3c7

Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
author Mike Pavone <pavone@retrodev.com>
date Tue, 06 Jul 2010 07:52:59 -0400
parents d0ce696786cc
children e73a93fb5de1
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
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
79 _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
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 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
82 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
83
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 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
85 { 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
86 { Fold[[["Compile Conversion Method"]Set Input[1, type]]Set Input[3, ""], ~, Legal Conversions[type]]
52
079200bc3e75 String literals almost working. Print moved out of C runtime.
Mike Pavone <pavone@retrodev.com>
parents: 51
diff changeset
87 { out <- Fold[[["Compile Conversion Method"]Set Input[1, type]]Set Input[3, "Trunc "], ~, Truncations[type]] }}}
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
88 }
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
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 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
91 {
49
3e20ed8959c4 Added initial FFI implementation, Array type and 64-bit integers
Mike Pavone <pavone@retrodev.com>
parents: 48
diff changeset
92 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
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 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
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
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 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
98 {
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 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
100 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
101 ]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
102 [[[[[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
103 ]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
104 ]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
105 ]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
106 ]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
107 ]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
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 }
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
110
51
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
111 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
112 {
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
113 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
114 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
115 ]Bind Worker[name,
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
116 [[[[[NWorker["rhope"]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
117 ]Inputs <<[("in")]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
118 ]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
119 ]Outputs <<[("out")]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
120 ]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
121 ]Builtin? <<[Yes]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
122 ]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
123 }
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
124
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
125 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
126 {
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
127 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
128 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
129 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
130 {
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
131 [type]Slice[4] {}
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
132 { 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
133 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
134 }{
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
135 [type]Slice[3] {}
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
136 { 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
137 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
138 }
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
139 }
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
140
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
141 Truncations[type:truncs]
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
142 {
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
143 ,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
144 { 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
145 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
146 }
7d6a6906b648 Added integer type conversions and started on the implementation of String
Mike Pavone <pavone@retrodev.com>
parents: 49
diff changeset
147
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
148 _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
149 {
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
150 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
151 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
152 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
153 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
154 { 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
155 { Fold[[["Register Conversion Method"]Set Input[1, type]]Set Input[3, ""], ~, Legal Conversions[type]]
52
079200bc3e75 String literals almost working. Print moved out of C runtime.
Mike Pavone <pavone@retrodev.com>
parents: 51
diff changeset
156 { out <- Fold[[["Register Conversion Method"]Set Input[1, type]]Set Input[3, "Trunc "], ~, Truncations[type]] }}}
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
157 }
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
158
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
159 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
160 {
49
3e20ed8959c4 Added initial FFI implementation, Array type and 64-bit integers
Mike Pavone <pavone@retrodev.com>
parents: 48
diff changeset
161 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
162 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
163 }
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
164