mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-22 11:11:43 +00:00
progress
This commit is contained in:
545
src/builtins.ts
545
src/builtins.ts
File diff suppressed because it is too large
Load Diff
2469
src/compiler.ts
2469
src/compiler.ts
File diff suppressed because it is too large
Load Diff
24
src/flow.ts
24
src/flow.ts
@ -146,32 +146,32 @@ export enum LocalFlags {
|
||||
READFROM = 1 << 2,
|
||||
/** Local is written to. */
|
||||
WRITTENTO = 1 << 3,
|
||||
/** Local must be autoreleased. */
|
||||
AUTORELEASE = 1 << 4,
|
||||
/** Local is retained. */
|
||||
RETAINED = 1 << 4,
|
||||
|
||||
/** Local is conditionally read from. */
|
||||
CONDITIONALLY_READFROM = 1 << 5,
|
||||
/** Local is conditionally written to. */
|
||||
CONDITIONALLY_WRITTENTO = 1 << 6,
|
||||
/** Local must be conditionally autoreleased. */
|
||||
CONDITIONALLY_AUTORELEASE = 1 << 7,
|
||||
/** Local must be conditionally retained. */
|
||||
CONDITIONALLY_RETAINED = 1 << 7,
|
||||
|
||||
/** Any categorical flag. */
|
||||
ANY_CATEGORICAL = WRAPPED
|
||||
| NONNULL
|
||||
| READFROM
|
||||
| WRITTENTO
|
||||
| AUTORELEASE,
|
||||
| RETAINED,
|
||||
|
||||
/** Any conditional flag. */
|
||||
ANY_CONDITIONAL = AUTORELEASE
|
||||
ANY_CONDITIONAL = RETAINED
|
||||
| CONDITIONALLY_READFROM
|
||||
| CONDITIONALLY_WRITTENTO
|
||||
| CONDITIONALLY_AUTORELEASE,
|
||||
| CONDITIONALLY_RETAINED,
|
||||
|
||||
/** Any autorelease flag. */
|
||||
ANY_AUTORELEASE = AUTORELEASE
|
||||
| CONDITIONALLY_AUTORELEASE
|
||||
/** Any retained flag. */
|
||||
ANY_RETAINED = RETAINED
|
||||
| CONDITIONALLY_RETAINED
|
||||
}
|
||||
export namespace LocalFlags {
|
||||
export function join(left: LocalFlags, right: LocalFlags): LocalFlags {
|
||||
@ -324,7 +324,7 @@ export class Flow {
|
||||
var scopedLocals = this.scopedLocals;
|
||||
if (!scopedLocals) this.scopedLocals = scopedLocals = new Map();
|
||||
scopedLocals.set("~auto" + (this.parentFunction.nextAutoreleaseId++), local);
|
||||
this.setLocalFlag(local.index, LocalFlags.AUTORELEASE);
|
||||
this.setLocalFlag(local.index, LocalFlags.RETAINED);
|
||||
return local;
|
||||
}
|
||||
|
||||
@ -585,7 +585,7 @@ export class Flow {
|
||||
var localFlags = other.localFlags;
|
||||
for (let i = 0, k = localFlags.length; i < k; ++i) {
|
||||
let flags = localFlags[i];
|
||||
if (flags & LocalFlags.AUTORELEASE) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_AUTORELEASE);
|
||||
if (flags & LocalFlags.RETAINED) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_RETAINED);
|
||||
if (flags & LocalFlags.READFROM) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_READFROM);
|
||||
if (flags & LocalFlags.WRITTENTO) this.setLocalFlag(i, LocalFlags.CONDITIONALLY_WRITTENTO);
|
||||
}
|
||||
|
12
src/glue/binaryen.d.ts
vendored
12
src/glue/binaryen.d.ts
vendored
@ -22,6 +22,16 @@ declare function _BinaryenTypeVec128(): BinaryenType;
|
||||
declare function _BinaryenTypeUnreachable(): BinaryenType;
|
||||
declare function _BinaryenTypeAuto(): BinaryenType;
|
||||
|
||||
declare type BinaryenFeatureFlags = u32;
|
||||
|
||||
declare function _BinaryenFeatureAtomics(): BinaryenFeatureFlags;
|
||||
declare function _BinaryenFeatureMutableGlobals(): BinaryenFeatureFlags;
|
||||
declare function _BinaryenFeatureNontrappingFPToInt(): BinaryenFeatureFlags;
|
||||
declare function _BinaryenFeatureSIMD128(): BinaryenFeatureFlags;
|
||||
declare function _BinaryenFeatureBulkMemory(): BinaryenFeatureFlags;
|
||||
declare function _BinaryenFeatureSignExt(): BinaryenFeatureFlags;
|
||||
declare function _BinaryenFeatureExceptionHandling(): BinaryenFeatureFlags;
|
||||
|
||||
declare type BinaryenExpressionId = i32;
|
||||
|
||||
declare function _BinaryenInvalidId(): BinaryenExpressionId;
|
||||
@ -612,6 +622,8 @@ declare function _BinaryenModuleRead(input: usize, inputSize: usize): BinaryenMo
|
||||
declare function _BinaryenModuleInterpret(module: BinaryenModuleRef): void;
|
||||
declare function _BinaryenModuleAddDebugInfoFileName(module: BinaryenModuleRef, filename: usize): BinaryenIndex;
|
||||
declare function _BinaryenModuleGetDebugInfoFileName(module: BinaryenModuleRef, index: BinaryenIndex): usize;
|
||||
declare function _BinaryenGetFeatures(module: BinaryenModuleRef): BinaryenFeatureFlags;
|
||||
declare function _BinaryenSetFeatures(module: BinaryenModuleRef, featureFlags: BinaryenFeatureFlags): void;
|
||||
|
||||
declare type BinaryenRelooperRef = usize;
|
||||
declare type BinaryenRelooperBlockRef = usize;
|
||||
|
@ -27,6 +27,16 @@ export enum NativeType {
|
||||
Auto = _BinaryenTypeAuto()
|
||||
}
|
||||
|
||||
export enum FeatureFlags {
|
||||
Atomics = _BinaryenFeatureAtomics(),
|
||||
MutableGloabls = _BinaryenFeatureMutableGlobals(),
|
||||
NontrappingFPToInt = _BinaryenFeatureNontrappingFPToInt(),
|
||||
SIMD128 = _BinaryenFeatureSIMD128(),
|
||||
BulkMemory = _BinaryenFeatureBulkMemory(),
|
||||
SignExt = _BinaryenFeatureSignExt(),
|
||||
ExceptionHandling = _BinaryenFeatureExceptionHandling()
|
||||
}
|
||||
|
||||
export enum ExpressionId {
|
||||
Invalid = _BinaryenInvalidId(),
|
||||
Block = _BinaryenBlockId(),
|
||||
@ -553,6 +563,7 @@ export class Module {
|
||||
offset: Index = 0,
|
||||
align: Index = bytes // naturally aligned by default
|
||||
): ExpressionRef {
|
||||
if (type < NativeType.None || type > NativeType.V128) throw new Error("here: " + type);
|
||||
return _BinaryenStore(this.ref, bytes, offset, align, ptr, value, type);
|
||||
}
|
||||
|
||||
@ -1044,6 +1055,14 @@ export class Module {
|
||||
_BinaryenSetDebugInfo(on);
|
||||
}
|
||||
|
||||
getFeatures(): BinaryenFeatureFlags {
|
||||
return _BinaryenGetFeatures(this.ref);
|
||||
}
|
||||
|
||||
setFeatures(featureFlags: BinaryenFeatureFlags): void {
|
||||
_BinaryenSetFeatures(this.ref, featureFlags);
|
||||
}
|
||||
|
||||
optimize(func: FunctionRef = 0): void {
|
||||
if (func) {
|
||||
_BinaryenFunctionOptimize(func, this.ref);
|
||||
|
@ -309,13 +309,6 @@ function operatorKindFromDecorator(decoratorKind: DecoratorKind, arg: string): O
|
||||
return OperatorKind.INVALID;
|
||||
}
|
||||
|
||||
/** Garbage collector kind present. */
|
||||
export enum CollectorKind {
|
||||
NONE,
|
||||
TRACING,
|
||||
COUNTING
|
||||
}
|
||||
|
||||
/** Represents an AssemblyScript program. */
|
||||
export class Program extends DiagnosticEmitter {
|
||||
|
||||
@ -794,13 +787,18 @@ export class Program extends DiagnosticEmitter {
|
||||
if (globalAliases) {
|
||||
for (let [alias, name] of globalAliases) {
|
||||
if (!name.length) continue; // explicitly disabled
|
||||
let elementsByName = this.elementsByName;
|
||||
let element = elementsByName.get(name);
|
||||
if (element) {
|
||||
if (elementsByName.has(alias)) throw new Error("duplicate global element: " + name);
|
||||
elementsByName.set(alias, element);
|
||||
let firstChar = name.charCodeAt(0);
|
||||
if (firstChar >= CharCode._0 && firstChar <= CharCode._9) {
|
||||
this.registerConstantInteger(alias, Type.i32, i64_new(parseI32(name, 10)));
|
||||
} else {
|
||||
let elementsByName = this.elementsByName;
|
||||
let element = elementsByName.get(name);
|
||||
if (element) {
|
||||
if (elementsByName.has(alias)) throw new Error("duplicate global element: " + name);
|
||||
elementsByName.set(alias, element);
|
||||
}
|
||||
else throw new Error("no such global element: " + name);
|
||||
}
|
||||
else throw new Error("no such global element: " + name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,7 @@ import {
|
||||
Class,
|
||||
FunctionTarget,
|
||||
Program,
|
||||
DecoratorFlags,
|
||||
CollectorKind
|
||||
DecoratorFlags
|
||||
} from "./program";
|
||||
|
||||
import {
|
||||
|
Reference in New Issue
Block a user