(func $keyword (param $args i32) (result i32)
(LET $str ($to_String ($MEM_VAL1_ptr $args)))
- (if i32 (i32.eq (i32.load8_u $str) (CHR "\x7f"))
+ (if (result i32) (i32.eq (i32.load8_u $str) (CHR "\x7f"))
(then ($INC_REF ($MEM_VAL1_ptr $args)))
(else
(drop ($sprintf_1 (get_global $printf_buf) "\x7f%s" $str))
(func $get (param $args i32) (result i32)
(LET $hm ($MEM_VAL1_ptr $args)
$key ($MEM_VAL1_ptr ($MEM_VAL0_ptr $args)))
- (if i32 (i32.eq $hm (get_global $NIL))
+ (if (result i32) (i32.eq $hm (get_global $NIL))
(then ($INC_REF (get_global $NIL)))
(else ($INC_REF (i32.wrap/i64 ($HASHMAP_GET $hm $key)))))
)
(LET $hm ($MEM_VAL1_ptr $args)
$key ($MEM_VAL1_ptr ($MEM_VAL0_ptr $args)))
($TRUE_FALSE
- (if i32 (i32.eq $hm (get_global $NIL))
+ (if (result i32) (i32.eq $hm (get_global $NIL))
(then 0)
(else (i32.wrap/i64
(i64.shr_u ($HASHMAP_GET $hm $key) (i64.const 32))))))
)
(func $meta (param $args i32) (result i32)
- (if i32 (i32.eq ($TYPE ($MEM_VAL1_ptr $args)) (get_global $METADATA_T))
+ (if (result i32) (i32.eq ($TYPE ($MEM_VAL1_ptr $args)) (get_global $METADATA_T))
(then ($INC_REF ($MEM_VAL1_ptr ($MEM_VAL1_ptr $args))))
(else ($INC_REF (get_global $NIL)))))
)
(func $reset_BANG (param $args i32) (result i32)
- (local $atom i32 $val i32)
(LET $atom ($MEM_VAL1_ptr $args)
$val ($MEM_VAL1_ptr ($MEM_VAL0_ptr $args)))
($_reset_BANG $atom $val)
(module $env
(func $ENV_NEW (param $outer i32) (result i32)
- (local $data i32 $env i32)
-
(LET $data ($HASHMAP) ;; allocate the data hashmap
$env ($ALLOC (get_global $ENVIRONMENT_T) $data $outer 0))
;; environment takes ownership
(func $MalType_size (param $type i32) (result i32)
;;; if (type <= 5 || type == 9 || type == 12)
- (if i32 (OR (i32.le_u $type 5)
+ (if (result i32) (OR (i32.le_u $type 5)
(i32.eq $type 9)
(i32.eq $type 12))
(then 2)
(else
;;; else if (type == 8 || type == 10 || type == 11)
- (if i32 (OR (i32.eq $type 8)
+ (if (result i32) (OR (i32.eq $type 8)
(i32.eq $type 10)
(i32.eq $type 11))
(then 4)
(func $MalVal_size (param $mv i32) (result i32)
(LET $type ($TYPE $mv))
;; if (type == FREE_T)
- (if i32 (i32.eq $type (get_global $FREE_T))
+ (if (result i32) (i32.eq $type (get_global $FREE_T))
(then
;;; return (mv->refcnt_type & 0xffe0)>>5
(i32.shr_u (i32.and (i32.load $mv) 0xffe0) 5)) ;;; / 32
($memmove $buf $line $len)
($lib_free $line)))
(i32.store8 (i32.add $buf $len) (CHR "\x00"))
- (return (if i32 $line 1 0))
+ (return (if (result i32) $line 1 0))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 8: hashmap
(set_local
$res ($sprintf_1 $res "%c"
- (if i32 (i32.eq $type (get_global $LIST_T))
- (CHR "(")
- (else (if i32 (i32.eq $type (get_global $VECTOR_T))
- (CHR "[")
+ (if (result i32) (i32.eq $type (get_global $LIST_T))
+ (then (CHR "("))
+ (else (if (result i32) (i32.eq $type (get_global $VECTOR_T))
+ (then (CHR "["))
(else (CHR "{")))))))
;; PR_SEQ_LOOP
;;; while (VAL0(mv) != 0)
(set_local
$res ($sprintf_1 $res "%c"
- (if i32 (i32.eq $type (get_global $LIST_T))
- (CHR ")")
- (else (if i32 (i32.eq $type (get_global $VECTOR_T))
- (CHR "]")
+ (if (result i32) (i32.eq $type (get_global $LIST_T))
+ (then (CHR ")"))
+ (else (if (result i32) (i32.eq $type (get_global $VECTOR_T))
+ (then (CHR "]"))
(else (CHR "}")))))))
(br $done))
;; 9: function
;; Calculate smallest to most significant digit
(loop $loop
(set_local $digit (i32.rem_u $val $radix))
- (i32.store8 $pbuf (if i32 (i32.lt_u $digit 10)
+ (i32.store8 $pbuf (if (result i32) (i32.lt_u $digit 10)
(i32.add (CHR "0") $digit)
(i32.sub (i32.add (CHR "A") $digit) 10)))
(set_local $pbuf (i32.add $pbuf 1))
(else
(return ($STRING (get_global $SYMBOL_T) $tok))))
))))))))))))))))))))))))))))))))
+ 0 ;; not reachable
)
(func $read_str (param $str i32) (result i32)
(br_if $done (i32.eq ($VAL0 $ast) 0))
(if $skiplast
- (br_if $done (i32.eqz ($VAL0 ($MEM_VAL0_ptr $ast)) 0)))
+ (br_if $done (i32.eqz ($VAL0 ($MEM_VAL0_ptr $ast)))))
(if (i32.eq $type (get_global $HASHMAP_T))
(then
(br_if $done (i32.eq ($VAL0 $ast) 0))
(if $skiplast
- (br_if $done (i32.eqz ($VAL0 ($MEM_VAL0_ptr $ast)) 0)))
+ (br_if $done (i32.eqz ($VAL0 ($MEM_VAL0_ptr $ast)))))
(if (i32.eq $type (get_global $HASHMAP_T))
(then
(br_if $done (i32.eq ($VAL0 $ast) 0))
(if $skiplast
- (br_if $done (i32.eqz ($VAL0 ($MEM_VAL0_ptr $ast)) 0)))
+ (br_if $done (i32.eqz ($VAL0 ($MEM_VAL0_ptr $ast)))))
(if (i32.eq $type (get_global $HASHMAP_T))
(then
(br_if $done (i32.eq ($VAL0 $ast) 0))
(if $skiplast
- (br_if $done (i32.eqz ($VAL0 ($MEM_VAL0_ptr $ast)) 0)))
+ (br_if $done (i32.eqz ($VAL0 ($MEM_VAL0_ptr $ast)))))
(if (i32.eq $type (get_global $HASHMAP_T))
(then
(br_if $done (i32.eq ($VAL0 $ast) 0))
(if $skiplast
- (br_if $done (i32.eqz ($VAL0 ($MEM_VAL0_ptr $ast)) 0)))
+ (br_if $done (i32.eqz ($VAL0 ($MEM_VAL0_ptr $ast)))))
(if (i32.eq $type (get_global $HASHMAP_T))
(then
(br_if $done (i32.eq ($VAL0 $ast) 0))
(if $skiplast
- (br_if $done (i32.eqz ($VAL0 ($MEM_VAL0_ptr $ast)) 0)))
+ (br_if $done (i32.eqz ($VAL0 ($MEM_VAL0_ptr $ast)))))
(if (i32.eq $type (get_global $HASHMAP_T))
(then
(loop $loop
(if (i32.gt_s $i (i32.sub $len $needle_len)) (br $done))
- (if (AND (i32.eq (i32.load8_u $haystack 0)
- (i32.load8_u $needle 0))
+ (if (AND (i32.eq (i32.load8_u $haystack)
+ (i32.load8_u $needle))
(i32.eqz ($strncmp $haystack $needle $needle_len)))
(return $haystack))
(set_local $haystack (i32.add $haystack 1))
(br $loop)
)
)
- (if i32 $neg
+ (if (result i32) $neg
(then (i32.sub 0 $acc))
(else $acc))
)
(br $loop)
)
)
- (if i32 (i32.eq (i32.load8_u $s1) (i32.load8_u $s2))
+ (if (result i32) (i32.eq (i32.load8_u $s1) (i32.load8_u $s2))
(then 0)
(else
- (if i32 (i32.lt_u (i32.load8_u $s1) (i32.load8_u $s2))
+ (if (result i32) (i32.lt_u (i32.load8_u $s1) (i32.load8_u $s2))
(then -1)
(else 1))))
)
(i32.eq (i32.load8_u (i32.add $i $s1))
(i32.load8_u (i32.add $i $s2))))
(return 0))
- (if i32 (i32.lt_u (i32.load8_u (i32.add $i $s1))
+ (if (result i32) (i32.lt_u (i32.load8_u (i32.add $i $s1))
(i32.load8_u (i32.add $i $s2)))
(then -1)
(else 1))
(block $done
(loop $loop
(if (i32.ge_u $s 3) (br $done))
- (set_local $needle (if i32 (i32.eq $s 0) $needle0
- (if i32 (i32.eq $s 1) $needle1
+ (set_local $needle (if (result i32) (i32.eq $s 0) $needle0
+ (if (result i32) (i32.eq $s 1) $needle1
$needle2)))
- (set_local $replace (if i32 (i32.eq $s 0) $replace0
- (if i32 (i32.eq $s 1) $replace1
+ (set_local $replace (if (result i32) (i32.eq $s 0) $replace0
+ (if (result i32) (i32.eq $s 1) $replace1
$replace2)))
(set_local $needle_len ($strlen $needle))
(set_local $replace_len ($strlen $replace))
(block $done2
(loop $loop2
(if (i32.ge_u $s 3) (br $done2))
- (set_local $needle (if i32 (i32.eq $s 0) $needle0
- (if i32 (i32.eq $s 1) $needle1
+ (set_local $needle (if (result i32) (i32.eq $s 0) $needle0
+ (if (result i32) (i32.eq $s 1) $needle1
$needle2)))
- (set_local $replace (if i32 (i32.eq $s 0) $replace0
- (if i32 (i32.eq $s 1) $replace1
+ (set_local $replace (if (result i32) (i32.eq $s 0) $replace0
+ (if (result i32) (i32.eq $s 1) $replace1
$replace2)))
(set_local $s (i32.add $s 1))
(set_local $found_tmp ($strstr $src_str $needle))
)
(func $TRUE_FALSE (param $val i32) (result i32)
- ($INC_REF (if i32 $val (get_global $TRUE) (get_global $FALSE)))
+ ($INC_REF (if (result i32) $val (get_global $TRUE) (get_global $FALSE)))
)
(func $THROW_STR_0 (param $fmt i32)
(else (if (AND (i32.eq $ta (get_global $HASHMAP_T))
(i32.eq $tb (get_global $HASHMAP_T)))
;; EQUAL_Q_HM
- (return 1))
+ (then (return 1))
;; TODO: remove this once strings are interned
(else (if (OR (AND (i32.eq $ta (get_global $STRING_T))
(i32.eq $tb (get_global $STRING_T)))
(AND (i32.eq $ta (get_global $SYMBOL_T))
(i32.eq $tb (get_global $SYMBOL_T))))
- (return (i32.eqz ($strcmp ($to_String $a) ($to_String $b))))
+ (then (return (i32.eqz ($strcmp ($to_String $a) ($to_String $b)))))
(else
(return (AND (i32.eq $ta $tb)
- (i32.eq ($VAL0 $a) ($VAL0 $b)))))))))
+ (i32.eq ($VAL0 $a) ($VAL0 $b))))))))))
+ 0 ;; not reachable
)
(func $DEREF_META (param $mv i32) (result i32)
;; sequence functions
(func $MAP_LOOP_START (param $type i32) (result i32)
- (LET $res (if i32 (i32.eq $type (get_global $LIST_T))
- (get_global $EMPTY_LIST)
- (else (if i32 (i32.eq $type (get_global $VECTOR_T))
- (get_global $EMPTY_VECTOR)
- (else (if i32 (i32.eq $type (get_global $HASHMAP_T))
- (get_global $EMPTY_HASHMAP)
+ (LET $res (if (result i32) (i32.eq $type (get_global $LIST_T))
+ (then (get_global $EMPTY_LIST))
+ (else (if (result i32) (i32.eq $type (get_global $VECTOR_T))
+ (then (get_global $EMPTY_VECTOR))
+ (else (if (result i32) (i32.eq $type (get_global $HASHMAP_T))
+ (then (get_global $EMPTY_HASHMAP))
(else
($THROW_STR_1 "read_seq invalid type %d" $type)
0)))))))