Commit 2bac6b29 authored by Guy Watson's avatar Guy Watson
Browse files

Add an over-arching supertype: 'number

parent 7e76e749
......@@ -212,8 +212,9 @@
;; ints and floats
;; Use these with (fresh-subtype-of ___)
;; For 32 and 64 bit types, use (fresh-type-variable i32 f32)
(define int (base-type 'int))
(define float (base-type 'float))
(define number (base-type 'number))
(define int (base-type 'int number))
(define float (base-type 'float number))
;; All the base types of WebAssembly, with supertypes of int and float
(define i32 (base-type 'i32 int))
(define i64 (base-type 'i64 int))
......@@ -229,9 +230,9 @@
(λ (n t)
(hash 'Func i32
'globals (λ (child-node) (fresh-type-variable))))]]
[GlobalDeclaration [(fresh-type-variable)
[GlobalDeclaration [(fresh-subtype-of number)
(λ (n t) (hash 'initialvalue t))]]
[Func [(fresh-type-variable)
[Func [(fresh-subtype-of number)
(λ (n t)
(hash 'root t))]]
[LiteralIntThirtyTwo [i32
......@@ -242,33 +243,33 @@
(no-child-types)]]
[LiteralFloatSixtyFour [f64
(no-child-types)]]
[Noop [(fresh-type-variable) (λ (n t) (hash 'expr t))]] ;;todo This is wierd....
[Binop [(fresh-type-variable)
[Noop [(fresh-subtype-of number) (λ (n t) (hash 'expr t))]] ;;todo This is wierd....
[Binop [(fresh-subtype-of number)
(λ (n t)
(hash 'l t
'r t))]]
[Unop [(fresh-type-variable)
[Unop [(fresh-subtype-of number)
(λ (n t)
(hash 'expr t))]]
[IfElse [(fresh-type-variable)
[IfElse [(fresh-subtype-of number)
(λ (n t)
(hash 'cond i32
'then t
'else t))]]
[If [(fresh-type-variable)
[If [(fresh-subtype-of number)
(λ (n t)
(hash 'cond i32
'then t))]]
[Block [(fresh-type-variable) (λ (n t) (hash 'expr t))]]
[Loop [(fresh-type-variable) (λ (n t) (hash 'expr t))]]
[ForLoop [(fresh-type-variable) (λ (n t) (hash 'initial i32
[Block [(fresh-subtype-of number) (λ (n t) (hash 'expr t))]]
[Loop [(fresh-subtype-of number) (λ (n t) (hash 'expr t))]]
[ForLoop [(fresh-subtype-of number) (λ (n t) (hash 'initial i32
'loopvar i32
'loopbody t))]]
[Branch [(fresh-type-variable) (λ (n t) (hash 'val t))]] ;;todo triple check branch interactions here
[BranchIf [(fresh-type-variable)
[Branch [(fresh-subtype-of number) (λ (n t) (hash 'val t))]] ;;todo triple check branch interactions here
[BranchIf [(fresh-subtype-of number)
(λ (n t) (hash 'cond i32
'val t))]]
[MemStore [(fresh-type-variable)
[MemStore [(fresh-subtype-of number)
(λ (n t) (hash 'address i32
'value t
'expr t))]]
......@@ -277,8 +278,8 @@
[LocalSet [i32 (λ (n t) (hash 'val i32
'expr i32))]]
[LocalTee [i32 (λ (n t) (hash 'val i32))]]
[GlobalGet [(fresh-type-variable) (no-child-types)]]
[GlobalSet [(fresh-type-variable) (λ (n t) (hash 'val t
[GlobalGet [(fresh-subtype-of number) (no-child-types)]]
[GlobalSet [(fresh-subtype-of number) (λ (n t) (hash 'val t
'expr t))]]
;;Type conversions
[Truncate [(fresh-subtype-of int)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment