comparison number_c.rhope @ 136:fc3815b7462f

Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
author Mike Pavone <pavone@retrodev.com>
date Sun, 14 Nov 2010 23:07:55 -0500
parents 18a4403fe576
children fd06fb07762a
comparison
equal deleted inserted replaced
135:18a4403fe576 136:fc3815b7462f
77 ,src <- [func]Read Field["abs", "Num"] 77 ,src <- [func]Read Field["abs", "Num"]
78 { ,dst <- [~]Write Field["out", "Num"] 78 { ,dst <- [~]Write Field["out", "Num"]
79 { ffunc <- [[~]Move[src, dst]]Release["abs"] }} 79 { ffunc <- [[~]Move[src, dst]]Release["abs"] }}
80 80
81 out <- [backend]Store Function[ffunc] 81 out <- [backend]Store Function[ffunc]
82 }
83
84 Supports Type?[backend,type:out]
85 {
86 [[backend]Supported Number Types]Find[=[type,?]]
87 { out <- Yes }
88 { out <- No }
82 } 89 }
83 90
84 _Generate Number Methods[backend, type:out] 91 _Generate Number Methods[backend, type:out]
85 { 92 {
86 //Old crappy parser doesn't like Worker literals in List literals, work around for now 93 //Old crappy parser doesn't like Worker literals in List literals, work around for now
103 ]Append[ [("!=")]Append[CompNotEqual[?]] ] 110 ]Append[ [("!=")]Append[CompNotEqual[?]] ]
104 //(("<", CompLess[?]), (">", CompGreater[?]), ("=", CompEqual[?]), ("<=", CompLessEqual[?]), (">=", CompGreaterEqual[?]), ("!=", CompNotEqual[?])) 111 //(("<", CompLess[?]), (">", CompGreater[?]), ("=", CompEqual[?]), ("<=", CompLessEqual[?]), (">=", CompGreaterEqual[?]), ("!=", CompNotEqual[?]))
105 112
106 Fold[Compile Number Method[?, ?, type], backend, opmap] 113 Fold[Compile Number Method[?, ?, type], backend, opmap]
107 { Fold[Compile Number Comp Method[?, ?, type], ~, compops] 114 { Fold[Compile Number Comp Method[?, ?, type], ~, compops]
108 { Fold[Compile Conversion Method[?, type, ?, ""], ~, Legal Conversions[type]] 115 { Fold[Compile Conversion Method[?, type, ?, ""], ~, Filter[Legal Conversions[type], [backend]Supports Type?[?]]]
109 { 116 {
110 almost <- Fold[Compile Conversion Method[?, type, ?, "Trunc "], ~, Truncations[type]] 117 almost <- Fold[Compile Conversion Method[?, type, ?, "Trunc "], ~, Filter[Truncations[type], [backend]Supports Type?[?]]]
111 If[[type]Starts With["I"]] 118 If[[type]Starts With["I"]]
112 { 119 {
113 out <- Compile Abs UInt Method[almost,type] 120 out <- Compile Abs UInt Method[almost,type]
114 }{ 121 }{
115 out <- Val[almost] 122 out <- Val[almost]
201 }}} 208 }}}
202 } 209 }
203 210
204 Register Number Methods[program:out] 211 Register Number Methods[program:out]
205 { 212 {
206 numtypes <- ("Int8","Int16","Int32","Int64","UInt8","UInt16","UInt32","UInt64") 213 out <- Fold[_Register Number Methods[?], program, [program]Supported Number Types]
207 out <- Fold[_Register Number Methods[?], program, numtypes] 214 }
208 } 215
209