Skip to content

global const optimization #13

Closed
Closed
@blooddy

Description

@blooddy
const A:i32 = 1;
const B:i32 = A + 1;

export function test():i32 {
    return B;
}

output

// module.ts(2,15): warning TS/AS121: Compiling global with unsupported constant initializer expression as mutable.

(module
 (type $i (func (result i32)))
 (type $v (func))
 (global $B (mut i32) (i32.const 0))
 (memory $0 1)
 (export "test" (func $test))
 (export "memory" (memory $0))
 (start $.start)
 (func $test (; 0 ;) (type $i) (result i32)
  (get_global $B)
 )
 (func $.start (; 1 ;) (type $v)
  (set_global $B
   (i32.const 2)
  )
 )
)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions