diff --git a/NOTICE b/NOTICE index adaa69cb..7f93b281 100644 --- a/NOTICE +++ b/NOTICE @@ -7,6 +7,7 @@ under the licensing terms detailed in LICENSE: * Max Graey * Igor Sbitnev * Norton Wang +* Alan Pierce Portions of this software are derived from third-party works licensed under the following terms: diff --git a/src/compiler.ts b/src/compiler.ts index d7431a9b..af2a7645 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -4411,7 +4411,7 @@ export class Compiler extends DiagnosticEmitter { return module.createBlock(null, [ module.createSetLocal(tempLocalIndex, valueWithCorrectType), module.createStore( - type.size >> 3, + type.byteSize, thisExpr, module.createGetLocal(tempLocalIndex, nativeType), nativeType, @@ -4421,7 +4421,7 @@ export class Compiler extends DiagnosticEmitter { ], nativeType); } else { return module.createStore( - type.size >> 3, + type.byteSize, thisExpr, valueWithCorrectType, nativeType, diff --git a/tests/compiler/class-with-boolean-field.optimized.wat b/tests/compiler/class-with-boolean-field.optimized.wat new file mode 100644 index 00000000..12bc76fe --- /dev/null +++ b/tests/compiler/class-with-boolean-field.optimized.wat @@ -0,0 +1,16 @@ +(module + (type $i (func (result i32))) + (memory $0 1) + (export "test" (func $class-with-boolean-field/test)) + (export "memory" (memory $0)) + (func $class-with-boolean-field/test (; 0 ;) (type $i) (result i32) + (local $0 i32) + (i32.store8 + (get_local $0) + (i32.const 1) + ) + (i32.load8_u + (get_local $0) + ) + ) +) diff --git a/tests/compiler/class-with-boolean-field.ts b/tests/compiler/class-with-boolean-field.ts new file mode 100644 index 00000000..57b7dbcd --- /dev/null +++ b/tests/compiler/class-with-boolean-field.ts @@ -0,0 +1,9 @@ +class A { + boolValue: bool; +} + +export function test(): bool { + let a: A; + a.boolValue = true; + return a.boolValue; +} diff --git a/tests/compiler/class-with-boolean-field.untouched.wat b/tests/compiler/class-with-boolean-field.untouched.wat new file mode 100644 index 00000000..dcf75163 --- /dev/null +++ b/tests/compiler/class-with-boolean-field.untouched.wat @@ -0,0 +1,20 @@ +(module + (type $i (func (result i32))) + (global $HEAP_BASE i32 (i32.const 4)) + (memory $0 1) + (export "test" (func $class-with-boolean-field/test)) + (export "memory" (memory $0)) + (func $class-with-boolean-field/test (; 0 ;) (type $i) (result i32) + (local $0 i32) + (nop) + (i32.store8 + (get_local $0) + (i32.const 1) + ) + (return + (i32.load8_u + (get_local $0) + ) + ) + ) +)