protoverse

A metaverse protocol
git clone git://jb55.com/protoverse
Log | Files | Refs | README | LICENSE

ifelse2.wat (1020B)


      1 (module
      2 	(func $add (param $lhs i32) (param $rhs i32) (result i32)
      3 	      local.get $lhs
      4 	      local.get $rhs
      5 	      i32.add)
      6 	(func $sub (param $lhs i32) (param $rhs i32) (result i32)
      7 	      local.get $lhs
      8 	      local.get $rhs
      9 	      i32.sub
     10 	      )
     11 	(func $start (result i32)
     12 	      (local i32 i32)
     13 	      i32.const 0
     14 	      local.set 0
     15 	      i32.const 0
     16 	      if
     17 	        (block (result i32)
     18 		  i32.const 0
     19 		  if
     20 		    nop
     21 		  end
     22 	          local.get 0
     23 	          i32.const 1
     24 	          i32.add
     25 	          local.set 0
     26 	          i32.const 4
     27 	          local.get 0
     28 	          i32.gt_u
     29 	          (if (result i32)
     30 		  (then local.get 0)
     31 	          (else
     32 		    local.get 1))
     33 	        )
     34 		local.set 1
     35 	      end
     36 	      i32.const 0
     37 	      )
     38 
     39 	(func $enter (result i32)
     40 	      (local i32)
     41 	      (call $start)
     42 	      local.set 0
     43 	      (call $start)
     44 	      local.get 0
     45 	      i32.ne
     46 	      )
     47 
     48 	(export "start" (func $start))
     49 	(export "_start" (func $enter))
     50 	(export "add" (func $add))
     51 	(export "sub" (func $sub)))