mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-21 10:41:42 +00:00
take a step back
This commit is contained in:
@ -1163,8 +1163,7 @@ export enum DecoratorKind {
|
||||
BUILTIN,
|
||||
LAZY,
|
||||
START,
|
||||
UNSAFE,
|
||||
STUB
|
||||
UNSAFE
|
||||
}
|
||||
|
||||
/** Returns the kind of the specified decorator. Defaults to {@link DecoratorKind.CUSTOM}. */
|
||||
@ -1201,7 +1200,6 @@ export function decoratorNameToKind(name: Expression): DecoratorKind {
|
||||
case CharCode.s: {
|
||||
if (nameStr == "sealed") return DecoratorKind.SEALED;
|
||||
if (nameStr == "start") return DecoratorKind.START;
|
||||
if (nameStr == "stub") return DecoratorKind.STUB;
|
||||
break;
|
||||
}
|
||||
case CharCode.u: {
|
||||
|
@ -21,8 +21,7 @@ import {
|
||||
LiteralKind,
|
||||
LiteralExpression,
|
||||
StringLiteralExpression,
|
||||
CallExpression,
|
||||
ElementAccessExpression
|
||||
CallExpression
|
||||
} from "./ast";
|
||||
|
||||
import {
|
||||
@ -100,7 +99,6 @@ export namespace BuiltinSymbols {
|
||||
export const isFunction = "~lib/builtins/isFunction";
|
||||
export const isNullable = "~lib/builtins/isNullable";
|
||||
export const isDefined = "~lib/builtins/isDefined";
|
||||
export const isImplemented = "~lib/builtins/isImplemented";
|
||||
export const isConstant = "~lib/builtins/isConstant";
|
||||
export const isManaged = "~lib/builtins/isManaged";
|
||||
|
||||
@ -472,14 +470,16 @@ export namespace BuiltinSymbols {
|
||||
export const WARNING = "~lib/diagnostics/WARNING";
|
||||
export const INFO = "~lib/diagnostics/INFO";
|
||||
|
||||
// std/runtime.ts
|
||||
export const HEAP_BASE = "~lib/runtime/HEAP_BASE";
|
||||
export const memory_size = "~lib/runtime/memory.size";
|
||||
export const memory_grow = "~lib/runtime/memory.grow";
|
||||
export const memory_copy = "~lib/runtime/memory.copy";
|
||||
export const memory_fill = "~lib/runtime/memory.fill";
|
||||
export const gc_classId = "~lib/runtime/gc.classId";
|
||||
export const gc_iterateRoots = "~lib/runtime/gc.iterateRoots";
|
||||
// std/memory.ts
|
||||
export const HEAP_BASE = "~lib/memory/HEAP_BASE";
|
||||
export const memory_size = "~lib/memory/memory.size";
|
||||
export const memory_grow = "~lib/memory/memory.grow";
|
||||
export const memory_copy = "~lib/memory/memory.copy";
|
||||
export const memory_fill = "~lib/memory/memory.fill";
|
||||
|
||||
// std/gc.ts
|
||||
export const gc_classId = "~lib/gc/gc.classId";
|
||||
export const gc_iterateRoots = "~lib/gc/gc.iterateRoots";
|
||||
|
||||
// std/typedarray.ts
|
||||
export const Int8Array = "~lib/typedarray/Int8Array";
|
||||
@ -621,20 +621,6 @@ export function compileCall(
|
||||
);
|
||||
return module.createI32(element ? 1 : 0);
|
||||
}
|
||||
case BuiltinSymbols.isImplemented: { // isImplemented(expression) -> bool
|
||||
compiler.currentType = Type.bool;
|
||||
if (
|
||||
checkTypeAbsent(typeArguments, reportNode, prototype) |
|
||||
checkArgsRequired(operands, 1, reportNode, compiler)
|
||||
) return module.createUnreachable();
|
||||
let element = compiler.resolver.resolveExpression(
|
||||
operands[0],
|
||||
compiler.currentFlow,
|
||||
Type.void,
|
||||
ReportMode.SWALLOW
|
||||
);
|
||||
return module.createI32(element && !element.hasDecorator(DecoratorFlags.STUB) ? 1 : 0);
|
||||
}
|
||||
case BuiltinSymbols.isConstant: { // isConstant(expression) -> bool
|
||||
compiler.currentType = Type.bool;
|
||||
if (
|
||||
|
@ -930,7 +930,7 @@ export class Program extends DiagnosticEmitter {
|
||||
ensureGlobal(name: string, element: DeclaredElement): DeclaredElement {
|
||||
var elementsByName = this.elementsByName;
|
||||
if (elementsByName.has(name)) {
|
||||
let actual = elementsByName.get(name);
|
||||
let actual = elementsByName.get(name)!;
|
||||
// NOTE: this is effectively only performed when merging native types with
|
||||
// their respective namespaces in std/builtins, but can also trigger when a
|
||||
// user has multiple global elements of the same name in different files,
|
||||
@ -1176,7 +1176,7 @@ export class Program extends DiagnosticEmitter {
|
||||
): void {
|
||||
var name = declaration.name.text;
|
||||
var isStatic = declaration.is(CommonFlags.STATIC);
|
||||
var acceptedFlags = DecoratorFlags.INLINE;
|
||||
var acceptedFlags = DecoratorFlags.INLINE | DecoratorFlags.UNSAFE;
|
||||
if (!declaration.is(CommonFlags.GENERIC)) {
|
||||
acceptedFlags |= DecoratorFlags.OPERATOR_BINARY
|
||||
| DecoratorFlags.OPERATOR_PREFIX
|
||||
@ -1549,7 +1549,7 @@ export class Program extends DiagnosticEmitter {
|
||||
parent: Element
|
||||
): void {
|
||||
var name = declaration.name.text;
|
||||
var validDecorators = DecoratorFlags.UNSAFE | DecoratorFlags.STUB;
|
||||
var validDecorators = DecoratorFlags.UNSAFE;
|
||||
if (declaration.is(CommonFlags.AMBIENT)) {
|
||||
validDecorators |= DecoratorFlags.EXTERNAL;
|
||||
} else {
|
||||
@ -1791,9 +1791,7 @@ export enum DecoratorFlags {
|
||||
/** Is the explicit start function. */
|
||||
START = 1 << 10,
|
||||
/** Is considered unsafe code. */
|
||||
UNSAFE = 1 << 11,
|
||||
/** Is a stub that can be overridden. */
|
||||
STUB = 1 << 12
|
||||
UNSAFE = 1 << 11
|
||||
}
|
||||
|
||||
/** Translates a decorator kind to the respective decorator flag. */
|
||||
@ -1812,7 +1810,6 @@ export function decoratorKindToFlag(kind: DecoratorKind): DecoratorFlags {
|
||||
case DecoratorKind.LAZY: return DecoratorFlags.LAZY;
|
||||
case DecoratorKind.START: return DecoratorFlags.START;
|
||||
case DecoratorKind.UNSAFE: return DecoratorFlags.UNSAFE;
|
||||
case DecoratorKind.STUB: return DecoratorFlags.STUB;
|
||||
default: return DecoratorFlags.NONE;
|
||||
}
|
||||
}
|
||||
@ -1888,8 +1885,8 @@ export abstract class Element {
|
||||
if (!members) this.members = members = new Map();
|
||||
else if (members.has(name)) {
|
||||
let actual = members.get(name)!;
|
||||
if (actual.parent !== this || actual.hasDecorator(DecoratorFlags.STUB)) {
|
||||
// override non-own or stub element
|
||||
if (actual.parent !== this) {
|
||||
// override non-own element
|
||||
} else {
|
||||
let merged = tryMerge(actual, element);
|
||||
if (merged) {
|
||||
|
Reference in New Issue
Block a user