mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-22 19:21:47 +00:00
Basic initial inheritance
This commit is contained in:
26
tests/compiler/class-extends.optimized.wast
Normal file
26
tests/compiler/class-extends.optimized.wast
Normal file
@ -0,0 +1,26 @@
|
||||
(module
|
||||
(type $iv (func (param i32)))
|
||||
(memory $0 1)
|
||||
(export "test" (func $class-extends/test))
|
||||
(export "memory" (memory $0))
|
||||
(func $class-extends/test (; 0 ;) (type $iv) (param $0 i32)
|
||||
(drop
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load16_s offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.store16 offset=4
|
||||
(get_local $0)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
14
tests/compiler/class-extends.ts
Normal file
14
tests/compiler/class-extends.ts
Normal file
@ -0,0 +1,14 @@
|
||||
class A {
|
||||
a: i32 = 0;
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
b: i16 = 1;
|
||||
}
|
||||
|
||||
export function test(b: B): void {
|
||||
b.a;
|
||||
b.b;
|
||||
b.a = 2;
|
||||
b.b = 3;
|
||||
}
|
79
tests/compiler/class-extends.wast
Normal file
79
tests/compiler/class-extends.wast
Normal file
@ -0,0 +1,79 @@
|
||||
(module
|
||||
(type $iv (func (param i32)))
|
||||
(global $HEAP_BASE i32 (i32.const 4))
|
||||
(memory $0 1)
|
||||
(export "test" (func $class-extends/test))
|
||||
(export "memory" (memory $0))
|
||||
(func $class-extends/test (; 0 ;) (type $iv) (param $0 i32)
|
||||
(drop
|
||||
(i32.load
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(drop
|
||||
(i32.load16_s offset=4
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(i32.store
|
||||
(get_local $0)
|
||||
(i32.const 2)
|
||||
)
|
||||
(i32.store16 offset=4
|
||||
(get_local $0)
|
||||
(i32.const 3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(;
|
||||
[program.elements]
|
||||
GLOBAL: NaN
|
||||
GLOBAL: Infinity
|
||||
FUNCTION_PROTOTYPE: isNaN
|
||||
FUNCTION_PROTOTYPE: isFinite
|
||||
FUNCTION_PROTOTYPE: clz
|
||||
FUNCTION_PROTOTYPE: ctz
|
||||
FUNCTION_PROTOTYPE: popcnt
|
||||
FUNCTION_PROTOTYPE: rotl
|
||||
FUNCTION_PROTOTYPE: rotr
|
||||
FUNCTION_PROTOTYPE: abs
|
||||
FUNCTION_PROTOTYPE: max
|
||||
FUNCTION_PROTOTYPE: min
|
||||
FUNCTION_PROTOTYPE: ceil
|
||||
FUNCTION_PROTOTYPE: floor
|
||||
FUNCTION_PROTOTYPE: copysign
|
||||
FUNCTION_PROTOTYPE: nearest
|
||||
FUNCTION_PROTOTYPE: reinterpret
|
||||
FUNCTION_PROTOTYPE: sqrt
|
||||
FUNCTION_PROTOTYPE: trunc
|
||||
FUNCTION_PROTOTYPE: load
|
||||
FUNCTION_PROTOTYPE: store
|
||||
FUNCTION_PROTOTYPE: sizeof
|
||||
FUNCTION_PROTOTYPE: select
|
||||
FUNCTION_PROTOTYPE: unreachable
|
||||
FUNCTION_PROTOTYPE: current_memory
|
||||
FUNCTION_PROTOTYPE: grow_memory
|
||||
FUNCTION_PROTOTYPE: parseInt
|
||||
FUNCTION_PROTOTYPE: parseFloat
|
||||
FUNCTION_PROTOTYPE: changetype
|
||||
FUNCTION_PROTOTYPE: assert
|
||||
FUNCTION_PROTOTYPE: i8
|
||||
FUNCTION_PROTOTYPE: i16
|
||||
FUNCTION_PROTOTYPE: i32
|
||||
FUNCTION_PROTOTYPE: i64
|
||||
FUNCTION_PROTOTYPE: u8
|
||||
FUNCTION_PROTOTYPE: u16
|
||||
FUNCTION_PROTOTYPE: u32
|
||||
FUNCTION_PROTOTYPE: u64
|
||||
FUNCTION_PROTOTYPE: bool
|
||||
FUNCTION_PROTOTYPE: f32
|
||||
FUNCTION_PROTOTYPE: f64
|
||||
FUNCTION_PROTOTYPE: isize
|
||||
FUNCTION_PROTOTYPE: usize
|
||||
GLOBAL: HEAP_BASE
|
||||
CLASS_PROTOTYPE: class-extends/A
|
||||
CLASS_PROTOTYPE: class-extends/B
|
||||
FUNCTION_PROTOTYPE: class-extends/test
|
||||
[program.exports]
|
||||
FUNCTION_PROTOTYPE: class-extends/test
|
||||
;)
|
Reference in New Issue
Block a user