Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added fxquotient/fxmodulo/fxzero?

  • Loading branch information...
commit eda79089f3ffe148eb8d37e3e6aca2e89194439a 1 parent 5a7570a
@Gabriano Gabriano authored
Showing with 63 additions and 1 deletion.
  1. +62 −0 gsc/_t-univ.scm
  2. +1 −1  include/stamp.h
View
62 gsc/_t-univ.scm
@@ -2223,6 +2223,32 @@ EOF
(compiler-internal-error
"univ-or, unknown target"))))
+(define (univ-fxquotient ctx expr1 expr2)
+ (case (target-name (ctx-target ctx))
+
+ ((js)
+ (gen "parseInt(" expr1 " / " expr2 ")"))
+
+ ((python ruby php)
+ (gen ""))
+
+ (else
+ (compiler-internal-error
+ "univ-fxquotient, unknown target"))))
+
+(define (univ-fxmodulo ctx expr1 expr2)
+ (case (target-name (ctx-target ctx))
+
+ ((js)
+ (gen "(" expr1 " % " expr2 ")"))
+
+ ((python ruby php)
+ (gen ""))
+
+ (else
+ (compiler-internal-error
+ "univ-fxmodulo, unknown target"))))
+
(define (univ-< ctx expr1 expr2)
(gen expr1 " < " expr2))
@@ -2679,6 +2705,20 @@ EOF
" * "
(translate-gvm-opnd ctx (list-ref opnds 1)))))
+(univ-define-prim "##fxquotient" #f #f
+
+ (lambda (ctx opnds)
+ (univ-fxquotient ctx
+ (translate-gvm-opnd ctx (list-ref opnds 0))
+ (translate-gvm-opnd ctx (list-ref opnds 1)))))
+
+(univ-define-prim "##fxmodulo" #f #f
+
+ (lambda (ctx opnds)
+ (univ-fxmodulo ctx
+ (translate-gvm-opnd ctx (list-ref opnds 0))
+ (translate-gvm-opnd ctx (list-ref opnds 1)))))
+
(univ-define-prim-bool "##fx<" #f #f
(lambda (ctx opnds)
@@ -2931,6 +2971,28 @@ EOF
+(univ-define-prim-bool "##fxzero?" #t #f
+
+ (lambda (ctx opnds)
+ (case (target-name (ctx-target ctx))
+
+ ((js)
+ (gen "("
+ (translate-gvm-opnd ctx (list-ref opnds 0))
+ " === 0)"))
+
+ ((python ruby)
+ (gen "("
+ (translate-gvm-opnd ctx (list-ref opnds 0))
+ " == 0)"))
+
+ ((php) ;TODO: complete
+ (gen ""))
+
+ (else
+ (compiler-internal-error
+ "##null?, unknown target")))))
+
(univ-define-prim-bool "##null?" #t #f
(lambda (ctx opnds)
View
2  include/stamp.h
@@ -3,4 +3,4 @@
*/
#define ___STAMP_YMD 20120810
-#define ___STAMP_HMS 170027
+#define ___STAMP_HMS 174319
Please sign in to comment.
Something went wrong with that request. Please try again.