diff 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
line wrap: on
line diff
--- a/number_c.rhope	Sun Nov 14 03:09:49 2010 -0500
+++ b/number_c.rhope	Sun Nov 14 23:07:55 2010 -0500
@@ -81,6 +81,13 @@
 	out <- [backend]Store Function[ffunc]
 }
 
+Supports Type?[backend,type:out]
+{
+	[[backend]Supported Number Types]Find[=[type,?]]
+	{ out <- Yes }
+	{ out <- No }
+}
+
 _Generate Number Methods[backend, type:out]
 {
 	//Old crappy parser doesn't like Worker literals in List literals, work around for now
@@ -105,9 +112,9 @@
 	
 	Fold[Compile Number Method[?, ?, type], backend, opmap]
 	{ Fold[Compile Number Comp Method[?, ?, type], ~, compops]
-	{ Fold[Compile Conversion Method[?, type, ?, ""], ~, Legal Conversions[type]]
+	{ Fold[Compile Conversion Method[?, type, ?, ""], ~, Filter[Legal Conversions[type], [backend]Supports Type?[?]]]
 	{ 
-		almost <- Fold[Compile Conversion Method[?, type, ?, "Trunc "], ~, Truncations[type]] 
+		almost <- Fold[Compile Conversion Method[?, type, ?, "Trunc "], ~, Filter[Truncations[type], [backend]Supports Type?[?]]]
 		If[[type]Starts With["I"]]
 		{
 			out <- Compile Abs UInt Method[almost,type]
@@ -203,7 +210,6 @@
 
 Register Number Methods[program:out]
 {
-	numtypes <- ("Int8","Int16","Int32","Int64","UInt8","UInt16","UInt32","UInt64")
-	out <- Fold[_Register Number Methods[?], program, numtypes]
+	out <- Fold[_Register Number Methods[?], program, [program]Supported Number Types]
 }