poorna2152 / nballerina

WebAssembly Backend for the nBallerina compiler
https://ballerina.io/
Apache License 2.0
4 stars 0 forks source link

`RTT` pushed to PostMVP #53

Open poorna2152 opened 2 years ago

poorna2152 commented 2 years ago
(module 
  (type $Any (struct (field $type i32)))  
  (type $BoxedInt (struct_subtype (field $type i32) (field $val i64) $Any))
  (import "console" "log32" (func $println32 (param i32))) 
  (export "main" (func $main)) 
  (func $test (result (ref $BoxedInt))
    (struct.new $BoxedInt
      (i32.const 128)
      (i64.const 1028)))
  (func $main 
    (local $0 eqref)
    (local.set $0
      (call $test))
    (call $println32
      (struct.get $Any $type
        (ref.cast_static $Any
          (ref.as_data
            (local.get $0)))))))

This program works when ./wasm-as is run with the --nominal flag.

New instructions used. struct.new, ref.cast, struct_subtype.

./wasm-as main.wat -o main.wasm --nominal -all
poorna2152 commented 2 years ago

Will look into this once the documentation is updated