Operator overload preparations

This commit is contained in:
dcodeIO
2018-01-06 10:20:38 +01:00
parent 859a0e05bf
commit d8fa04f910
8 changed files with 142 additions and 45 deletions

View File

@ -34,8 +34,8 @@
(global $showcase/AnEnum.TWO i32 (i32.const 2))
(global $showcase/AnEnum.FOUR i32 (i32.const 4))
(global $showcase/AnEnum.FIVE i32 (i32.const 5))
(global $showcase/AnEnum.FOURTYTWO (mut i32) (i32.const 0))
(global $showcase/AnEnum.FOURTYTHREE (mut i32) (i32.const 0))
(global $showcase/AnEnum.FORTYTWO (mut i32) (i32.const 0))
(global $showcase/AnEnum.FORTYTHREE (mut i32) (i32.const 0))
(global $memcpy/dest (mut i32) (i32.const 0))
(global $showcase/aClassInstance (mut i32) (i32.const 8))
(global $showcase/AClass.aStaticField (mut i32) (i32.const 0))
@ -3944,25 +3944,25 @@
)
(unreachable)
)
(set_global $showcase/AnEnum.FOURTYTWO
(set_global $showcase/AnEnum.FORTYTWO
(get_global $showcase/aMutableGlobal)
)
(set_global $showcase/AnEnum.FOURTYTHREE
(set_global $showcase/AnEnum.FORTYTHREE
(i32.add
(get_global $showcase/AnEnum.FOURTYTWO)
(get_global $showcase/AnEnum.FORTYTWO)
(i32.const 1)
)
)
(if
(i32.ne
(get_global $showcase/AnEnum.FOURTYTWO)
(get_global $showcase/AnEnum.FORTYTWO)
(i32.const 42)
)
(unreachable)
)
(if
(i32.ne
(get_global $showcase/AnEnum.FOURTYTHREE)
(get_global $showcase/AnEnum.FORTYTHREE)
(i32.const 43)
)
(unreachable)

View File

@ -34,8 +34,8 @@
(global $showcase/AnEnum.TWO i32 (i32.const 2))
(global $showcase/AnEnum.FOUR i32 (i32.const 4))
(global $showcase/AnEnum.FIVE i32 (i32.const 5))
(global $showcase/AnEnum.FOURTYTWO (mut i32) (i32.const 0))
(global $showcase/AnEnum.FOURTYTHREE (mut i32) (i32.const 0))
(global $showcase/AnEnum.FORTYTWO (mut i32) (i32.const 0))
(global $showcase/AnEnum.FORTYTHREE (mut i32) (i32.const 0))
(global $memcpy/dest (mut i32) (i32.const 0))
(global $showcase/aClassInstance (mut i32) (i32.const 8))
(global $showcase/AClass.aStaticField (mut i32) (i32.const 0))
@ -3961,25 +3961,25 @@
)
(unreachable)
)
(set_global $showcase/AnEnum.FOURTYTWO
(set_global $showcase/AnEnum.FORTYTWO
(get_global $showcase/aMutableGlobal)
)
(set_global $showcase/AnEnum.FOURTYTHREE
(set_global $showcase/AnEnum.FORTYTHREE
(i32.add
(get_global $showcase/AnEnum.FOURTYTWO)
(get_global $showcase/AnEnum.FORTYTWO)
(i32.const 1)
)
)
(if
(i32.ne
(get_global $showcase/AnEnum.FOURTYTWO)
(get_global $showcase/AnEnum.FORTYTWO)
(i32.const 42)
)
(unreachable)
)
(if
(i32.ne
(get_global $showcase/AnEnum.FOURTYTHREE)
(get_global $showcase/AnEnum.FORTYTHREE)
(i32.const 43)
)
(unreachable)

View File

@ -48,15 +48,15 @@ export enum AnEnum {
// or be omitted
FOUR = AnEnum.TWO + 2, // or reference other values (and remain constant through precomputation)
FIVE, // and continue from there
FOURTYTWO = aMutableGlobal, // or reference mutable values but then can't be exported
FOURTYTHREE // and even continue from there without being exported (tsc doesn't allow this)
FORTYTWO = aMutableGlobal, // or reference mutable values but then can't be exported
FORTYTHREE // and even continue from there without being exported (tsc doesn't allow this)
}
assert(AnEnum.ONE == 1);
assert(AnEnum.TWO == 2);
assert(AnEnum.FOUR == 4);
assert(AnEnum.FIVE == 5);
assert(AnEnum.FOURTYTWO == 42);
assert(AnEnum.FOURTYTHREE == 43);
assert(AnEnum.FORTYTWO == 42);
assert(AnEnum.FORTYTHREE == 43);
// In fact, there are a couple of things asc just waves through where tsc refuses to
1, 2, 3; // for example not-so-useful comma expressions
@ -94,13 +94,13 @@ class AClass {
aField: i32;
}
class ADerivedClass extends AClass {
aNotherField: f32;
get aWildAccessorAppears(): f32 { return this.aNotherField; }
set aWildAccessorAppears(val: f32) { this.aNotherField = val; }
anotherField: f32;
get aWildAccessorAppears(): f32 { return this.anotherField; }
set aWildAccessorAppears(val: f32) { this.anotherField = val; }
}
var aClassInstance = changetype<ADerivedClass>(<usize>8);
aClassInstance.aField = 42;
aClassInstance.aNotherField = 9000;
aClassInstance.anotherField = 9000;
assert(load<i32>(8) == 42);
assert(load<f32>(12) == 9000);

View File

@ -67,8 +67,8 @@
(global $showcase/AnEnum.TWO i32 (i32.const 2))
(global $showcase/AnEnum.FOUR i32 (i32.const 4))
(global $showcase/AnEnum.FIVE i32 (i32.const 5))
(global $showcase/AnEnum.FOURTYTWO (mut i32) (i32.const 0))
(global $showcase/AnEnum.FOURTYTHREE (mut i32) (i32.const 0))
(global $showcase/AnEnum.FORTYTWO (mut i32) (i32.const 0))
(global $showcase/AnEnum.FORTYTHREE (mut i32) (i32.const 0))
(global $memcpy/base i32 (i32.const 8))
(global $memcpy/dest (mut i32) (i32.const 0))
(global $showcase/aClassInstance (mut i32) (i32.const 8))
@ -5802,12 +5802,12 @@
)
(unreachable)
)
(set_global $showcase/AnEnum.FOURTYTWO
(set_global $showcase/AnEnum.FORTYTWO
(get_global $showcase/aMutableGlobal)
)
(set_global $showcase/AnEnum.FOURTYTHREE
(set_global $showcase/AnEnum.FORTYTHREE
(i32.add
(get_global $showcase/AnEnum.FOURTYTWO)
(get_global $showcase/AnEnum.FORTYTWO)
(i32.const 1)
)
)
@ -5850,7 +5850,7 @@
(if
(i32.eqz
(i32.eq
(get_global $showcase/AnEnum.FOURTYTWO)
(get_global $showcase/AnEnum.FORTYTWO)
(i32.const 42)
)
)
@ -5859,7 +5859,7 @@
(if
(i32.eqz
(i32.eq
(get_global $showcase/AnEnum.FOURTYTHREE)
(get_global $showcase/AnEnum.FORTYTHREE)
(i32.const 43)
)
)