mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-18 09:21:35 +00:00
Implement reference counting (#592)
This commit is contained in:
42
src/ast.ts
42
src/ast.ts
@ -67,6 +67,7 @@ export enum NodeKind {
|
||||
DO,
|
||||
EMPTY,
|
||||
EXPORT,
|
||||
EXPORTDEFAULT,
|
||||
EXPORTIMPORT,
|
||||
EXPRESSION,
|
||||
FOR,
|
||||
@ -687,6 +688,9 @@ export abstract class Node {
|
||||
range.source.normalizedPath
|
||||
);
|
||||
} else { // absolute
|
||||
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) {
|
||||
normalizedPath = LIBRARY_PREFIX + normalizedPath;
|
||||
}
|
||||
stmt.normalizedPath = normalizedPath;
|
||||
}
|
||||
stmt.internalPath = mangleInternalPath(stmt.normalizedPath);
|
||||
@ -698,6 +702,16 @@ export abstract class Node {
|
||||
return stmt;
|
||||
}
|
||||
|
||||
static createExportDefaultStatement(
|
||||
declaration: DeclarationStatement,
|
||||
range: Range
|
||||
): ExportDefaultStatement {
|
||||
var stmt = new ExportDefaultStatement();
|
||||
stmt.declaration = declaration;
|
||||
stmt.range = range;
|
||||
return stmt;
|
||||
}
|
||||
|
||||
static createExportImportStatement(
|
||||
name: IdentifierExpression,
|
||||
externalName: IdentifierExpression,
|
||||
@ -782,10 +796,18 @@ export abstract class Node {
|
||||
stmt.declarations = null;
|
||||
stmt.namespaceName = identifier;
|
||||
stmt.path = path;
|
||||
stmt.normalizedPath = resolvePath(
|
||||
normalizePath(path.value),
|
||||
range.source.normalizedPath
|
||||
);
|
||||
var normalizedPath = normalizePath(path.value);
|
||||
if (path.value.startsWith(".")) {
|
||||
stmt.normalizedPath = resolvePath(
|
||||
normalizedPath,
|
||||
range.source.normalizedPath
|
||||
);
|
||||
} else {
|
||||
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) {
|
||||
normalizedPath = LIBRARY_PREFIX + normalizedPath;
|
||||
}
|
||||
stmt.normalizedPath = normalizedPath;
|
||||
}
|
||||
stmt.internalPath = mangleInternalPath(stmt.normalizedPath);
|
||||
return stmt;
|
||||
}
|
||||
@ -1162,7 +1184,7 @@ export enum DecoratorKind {
|
||||
EXTERNAL,
|
||||
BUILTIN,
|
||||
LAZY,
|
||||
START
|
||||
UNSAFE
|
||||
}
|
||||
|
||||
/** Returns the kind of the specified decorator. Defaults to {@link DecoratorKind.CUSTOM}. */
|
||||
@ -1198,11 +1220,11 @@ export function decoratorNameToKind(name: Expression): DecoratorKind {
|
||||
}
|
||||
case CharCode.s: {
|
||||
if (nameStr == "sealed") return DecoratorKind.SEALED;
|
||||
if (nameStr == "start") return DecoratorKind.START;
|
||||
break;
|
||||
}
|
||||
case CharCode.u: {
|
||||
if (nameStr == "unmanaged") return DecoratorKind.UNMANAGED;
|
||||
if (nameStr == "unsafe") return DecoratorKind.UNSAFE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1762,6 +1784,14 @@ export class ExportStatement extends Statement {
|
||||
isDeclare: bool;
|
||||
}
|
||||
|
||||
/** Represents an `export default` statement. */
|
||||
export class ExportDefaultStatement extends Statement {
|
||||
kind = NodeKind.EXPORTDEFAULT;
|
||||
|
||||
/** Declaration being exported as default. */
|
||||
declaration: DeclarationStatement;
|
||||
}
|
||||
|
||||
/** Represents an expression that is used as a statement. */
|
||||
export class ExpressionStatement extends Statement {
|
||||
kind = NodeKind.EXPRESSION;
|
||||
|
Reference in New Issue
Block a user