mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-11 22:11:27 +00:00
Link globals into global scope instead
This commit is contained in:
@ -222,6 +222,13 @@ export class Program extends DiagnosticEmitter {
|
||||
const prototype: ClassPrototype = new ClassPrototype(this, declaration.identifier.name, internalName, declaration);
|
||||
this.elements.set(internalName, prototype);
|
||||
|
||||
if (hasDecorator("global", declaration.decorators)) {
|
||||
if (this.elements.has(declaration.identifier.name))
|
||||
this.error(DiagnosticCode.Duplicate_identifier_0, declaration.identifier.range, internalName);
|
||||
else
|
||||
this.elements.set(declaration.identifier.name, prototype);
|
||||
}
|
||||
|
||||
if (namespace) {
|
||||
if (namespace.members) {
|
||||
if (namespace.members.has(declaration.identifier.name)) {
|
||||
@ -461,6 +468,13 @@ export class Program extends DiagnosticEmitter {
|
||||
const prototype: FunctionPrototype = new FunctionPrototype(this, declaration.identifier.name, internalName, declaration, null);
|
||||
this.elements.set(internalName, prototype);
|
||||
|
||||
if (hasDecorator("global", declaration.decorators)) {
|
||||
if (this.elements.has(declaration.identifier.name))
|
||||
this.error(DiagnosticCode.Duplicate_identifier_0, declaration.identifier.range, internalName);
|
||||
else
|
||||
this.elements.set(declaration.identifier.name, prototype);
|
||||
}
|
||||
|
||||
if (namespace) {
|
||||
if (namespace.members) {
|
||||
if (namespace.members.has(declaration.identifier.name)) {
|
||||
@ -650,6 +664,13 @@ export class Program extends DiagnosticEmitter {
|
||||
const global: Global = new Global(this, internalName, declaration, null);
|
||||
this.elements.set(internalName, global);
|
||||
|
||||
if (hasDecorator("global", declaration.decorators)) {
|
||||
if (this.elements.has(declaration.identifier.name))
|
||||
this.error(DiagnosticCode.Duplicate_identifier_0, declaration.identifier.range, internalName);
|
||||
else
|
||||
this.elements.set(declaration.identifier.name, global);
|
||||
}
|
||||
|
||||
if (namespace) {
|
||||
if (namespace.members) {
|
||||
if (namespace.members.has(declaration.identifier.name)) {
|
||||
|
@ -49,29 +49,36 @@
|
||||
isize
|
||||
usize
|
||||
HEAP_BASE
|
||||
array/Array
|
||||
Array
|
||||
error/Error
|
||||
Error
|
||||
error/RangeError
|
||||
RangeError
|
||||
heap/ALIGN_LOG2
|
||||
heap/ALIGN_SIZE
|
||||
heap/ALIGN_MASK
|
||||
heap/HEAP_OFFSET
|
||||
heap/Heap
|
||||
Heap
|
||||
Heap.get_used
|
||||
Heap.get_free
|
||||
Heap.get_size
|
||||
Heap.allocate
|
||||
Heap.dispose
|
||||
Heap.copy
|
||||
heap/Heap.get_used
|
||||
heap/Heap.get_free
|
||||
heap/Heap.get_size
|
||||
heap/Heap.allocate
|
||||
heap/Heap.dispose
|
||||
heap/Heap.copy
|
||||
map/Map
|
||||
Map
|
||||
set/Set
|
||||
Set
|
||||
string/String
|
||||
String
|
||||
[program.exports]
|
||||
Array
|
||||
Error
|
||||
RangeError
|
||||
Heap
|
||||
Map
|
||||
Set
|
||||
String
|
||||
array/Array
|
||||
error/Error
|
||||
error/RangeError
|
||||
heap/Heap
|
||||
map/Map
|
||||
set/Set
|
||||
string/String
|
||||
;)
|
||||
|
@ -8,7 +8,7 @@
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $Heap.allocate (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $heap/Heap.allocate (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(if
|
||||
@ -103,12 +103,12 @@
|
||||
(get_global $HEAP_BASE)
|
||||
)
|
||||
(set_global $std/heap/ptr
|
||||
(call $Heap.allocate
|
||||
(call $heap/Heap.allocate
|
||||
(i32.const 10)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(block $__inlined_func$Heap.dispose
|
||||
(block $__inlined_func$heap/Heap.dispose
|
||||
(set_local $0
|
||||
(get_global $std/heap/ptr)
|
||||
)
|
||||
|
@ -8,7 +8,7 @@
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $Heap.allocate (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $heap/Heap.allocate (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(if
|
||||
@ -97,7 +97,7 @@
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(func $Heap.dispose (; 1 ;) (type $iv) (param $0 i32)
|
||||
(func $heap/Heap.dispose (; 1 ;) (type $iv) (param $0 i32)
|
||||
(nop)
|
||||
)
|
||||
(func $start (; 2 ;) (type $v)
|
||||
@ -105,11 +105,11 @@
|
||||
(get_global $HEAP_BASE)
|
||||
)
|
||||
(set_global $std/heap/ptr
|
||||
(call $Heap.allocate
|
||||
(call $heap/Heap.allocate
|
||||
(i32.const 10)
|
||||
)
|
||||
)
|
||||
(call $Heap.dispose
|
||||
(call $heap/Heap.dispose
|
||||
(get_global $std/heap/ptr)
|
||||
)
|
||||
)
|
||||
|
@ -12,7 +12,7 @@
|
||||
(memory $0 1)
|
||||
(export "memory" (memory $0))
|
||||
(start $start)
|
||||
(func $Heap.allocate (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(func $heap/Heap.allocate (; 0 ;) (type $ii) (param $0 i32) (result i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
(local $3 i32)
|
||||
@ -109,18 +109,18 @@
|
||||
(get_local $4)
|
||||
)
|
||||
)
|
||||
(func $Heap.dispose (; 1 ;) (type $iv) (param $0 i32)
|
||||
(func $heap/Heap.dispose (; 1 ;) (type $iv) (param $0 i32)
|
||||
)
|
||||
(func $start (; 2 ;) (type $v)
|
||||
(set_global $heap/HEAP_OFFSET
|
||||
(get_global $HEAP_BASE)
|
||||
)
|
||||
(set_global $std/heap/ptr
|
||||
(call $Heap.allocate
|
||||
(call $heap/Heap.allocate
|
||||
(i32.const 10)
|
||||
)
|
||||
)
|
||||
(call $Heap.dispose
|
||||
(call $heap/Heap.dispose
|
||||
(get_global $std/heap/ptr)
|
||||
)
|
||||
)
|
||||
@ -171,30 +171,37 @@
|
||||
isize
|
||||
usize
|
||||
HEAP_BASE
|
||||
array/Array
|
||||
Array
|
||||
error/Error
|
||||
Error
|
||||
error/RangeError
|
||||
RangeError
|
||||
heap/ALIGN_LOG2
|
||||
heap/ALIGN_SIZE
|
||||
heap/ALIGN_MASK
|
||||
heap/HEAP_OFFSET
|
||||
heap/Heap
|
||||
Heap
|
||||
Heap.get_used
|
||||
Heap.get_free
|
||||
Heap.get_size
|
||||
Heap.allocate
|
||||
Heap.dispose
|
||||
Heap.copy
|
||||
heap/Heap.get_used
|
||||
heap/Heap.get_free
|
||||
heap/Heap.get_size
|
||||
heap/Heap.allocate
|
||||
heap/Heap.dispose
|
||||
heap/Heap.copy
|
||||
map/Map
|
||||
Map
|
||||
set/Set
|
||||
Set
|
||||
string/String
|
||||
String
|
||||
std/heap/ptr
|
||||
[program.exports]
|
||||
Array
|
||||
Error
|
||||
RangeError
|
||||
Heap
|
||||
Map
|
||||
Set
|
||||
String
|
||||
array/Array
|
||||
error/Error
|
||||
error/RangeError
|
||||
heap/Heap
|
||||
map/Map
|
||||
set/Set
|
||||
string/String
|
||||
;)
|
||||
|
Reference in New Issue
Block a user