mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-19 09:51:33 +00:00
fixes
This commit is contained in:
@ -8091,6 +8091,13 @@ export class Compiler extends DiagnosticEmitter {
|
||||
var options = this.options;
|
||||
var classType = classInstance.type;
|
||||
|
||||
if (!program.allocateMem) {
|
||||
this.error(
|
||||
DiagnosticCode.An_allocator_must_be_present_to_use_0,
|
||||
reportNode.range, "new"
|
||||
);
|
||||
}
|
||||
|
||||
if (classInstance.hasDecorator(DecoratorFlags.UNMANAGED)) {
|
||||
// memory.allocate(sizeof<T>())
|
||||
this.currentType = classType;
|
||||
|
@ -24,7 +24,7 @@ export enum DiagnosticCode {
|
||||
Class_0_is_sealed_and_cannot_be_extended = 211,
|
||||
Decorator_0_is_not_valid_here = 212,
|
||||
Duplicate_decorator = 213,
|
||||
An_allocator_must_be_declared_to_allocate_memory_Try_importing_allocator_arena_or_allocator_tlsf = 214,
|
||||
An_allocator_must_be_present_to_use_0 = 214,
|
||||
Optional_parameter_must_have_an_initializer = 215,
|
||||
Constructor_of_class_0_must_not_require_any_arguments = 216,
|
||||
Function_0_cannot_be_inlined_into_itself = 217,
|
||||
@ -161,7 +161,7 @@ export function diagnosticCodeToString(code: DiagnosticCode): string {
|
||||
case 211: return "Class '{0}' is sealed and cannot be extended.";
|
||||
case 212: return "Decorator '{0}' is not valid here.";
|
||||
case 213: return "Duplicate decorator.";
|
||||
case 214: return "An allocator must be declared to allocate memory. Try importing allocator/arena or allocator/tlsf.";
|
||||
case 214: return "An allocator must be present to use '{0}'.";
|
||||
case 215: return "Optional parameter must have an initializer.";
|
||||
case 216: return "Constructor of class '{0}' must not require any arguments.";
|
||||
case 217: return "Function '{0}' cannot be inlined into itself.";
|
||||
|
@ -16,7 +16,7 @@
|
||||
"Class '{0}' is sealed and cannot be extended.": 211,
|
||||
"Decorator '{0}' is not valid here.": 212,
|
||||
"Duplicate decorator.": 213,
|
||||
"An allocator must be declared to allocate memory. Try importing allocator/arena or allocator/tlsf.": 214,
|
||||
"An allocator must be present to use '{0}'.": 214,
|
||||
"Optional parameter must have an initializer.": 215,
|
||||
"Constructor of class '{0}' must not require any arguments.": 216,
|
||||
"Function '{0}' cannot be inlined into itself.": 217,
|
||||
|
@ -367,6 +367,8 @@ export class Program extends DiagnosticEmitter {
|
||||
/** Runtime make array function. `makeArray(capacity: i32, source: usize = 0, cid: u32): usize` */
|
||||
makeArrayInstance: Function | null = null;
|
||||
|
||||
allocateMem: Function | null = null;
|
||||
freeMem: Function | null = null;
|
||||
linkRef: Function | null = null;
|
||||
unlinkRef: Function | null = null;
|
||||
retainRef: Function | null = null;
|
||||
@ -835,6 +837,15 @@ export class Program extends DiagnosticEmitter {
|
||||
assert(element.kind == ElementKind.FUNCTION_PROTOTYPE);
|
||||
this.makeArrayInstance = this.resolver.resolveFunction(<FunctionPrototype>element, null);
|
||||
}
|
||||
// memory allocator interface
|
||||
if (element = this.lookupGlobal("__memory_allocate")) {
|
||||
assert(element.kind == ElementKind.FUNCTION_PROTOTYPE);
|
||||
this.allocateMem = this.resolver.resolveFunction(<FunctionPrototype>element, null);
|
||||
element = assert(this.lookupGlobal("__memory_free"));
|
||||
assert(element.kind == ElementKind.FUNCTION_PROTOTYPE);
|
||||
this.freeMem = this.resolver.resolveFunction(<FunctionPrototype>element, null);
|
||||
}
|
||||
// garbage collector interface
|
||||
if (this.lookupGlobal("__ref_collect")) {
|
||||
if (element = this.lookupGlobal("__ref_link")) {
|
||||
assert(element.kind == ElementKind.FUNCTION_PROTOTYPE);
|
||||
|
Reference in New Issue
Block a user