Use long.js in JS and native i64 in WASM; Compile literals more thoroughly

This commit is contained in:
dcodeIO
2018-02-14 09:18:43 +01:00
parent 874f87f478
commit b1c6ccab2a
82 changed files with 1753 additions and 2199 deletions

View File

@ -13,10 +13,6 @@ import {
typesToString
} from "./types";
import {
I64
} from "./util/i64";
import {
ModifierKind,
Node,
@ -1446,6 +1442,12 @@ export class EnumValue extends Element {
}
}
export const enum ConstantValueKind {
NONE,
INTEGER,
FLOAT
}
export class VariableLikeElement extends Element {
// kind varies
@ -1454,18 +1456,22 @@ export class VariableLikeElement extends Element {
declaration: VariableLikeDeclarationStatement;
/** Variable type. Is {@link Type.void} for type-inferred {@link Global}s before compilation. */
type: Type;
/** Constant value kind. */
constantValueKind: ConstantValueKind = ConstantValueKind.NONE;
/** Constant integer value, if applicable. */
constantIntegerValue: I64 | null = null;
constantIntegerValue: I64;
/** Constant float value, if applicable. */
constantFloatValue: f64 = 0;
constantFloatValue: f64;
withConstantIntegerValue(lo: i32, hi: i32): this {
this.constantIntegerValue = new I64(lo, hi);
this.constantValueKind = ConstantValueKind.INTEGER;
this.constantIntegerValue = i64_new(lo, hi);
this.set(ElementFlags.CONSTANT | ElementFlags.INLINED);
return this;
}
withConstantFloatValue(value: f64): this {
this.constantValueKind = ConstantValueKind.FLOAT;
this.constantFloatValue = value;
this.set(ElementFlags.CONSTANT | ElementFlags.INLINED);
return this;