More cleanup

This commit is contained in:
dcodeIO
2018-02-16 18:57:51 +01:00
parent 3d7e8b2b7a
commit 48cbbbbd68
18 changed files with 380 additions and 387 deletions

View File

@ -41,7 +41,11 @@ import {
} from "./program";
/** Compiles a get of a built-in global. */
export function compileGetConstant(compiler: Compiler, global: Global, reportNode: Node): ExpressionRef {
export function compileGetConstant(
compiler: Compiler,
global: Global,
reportNode: Node
): ExpressionRef {
switch (global.internalName) {
case "NaN": // context-sensitive
@ -58,14 +62,23 @@ export function compileGetConstant(compiler: Compiler, global: Global, reportNod
case "HEAP_BASE": // never inlined for linking purposes
compiler.currentType = compiler.options.usizeType;
return compiler.module.createGetGlobal("HEAP_BASE", compiler.options.nativeSizeType);
return compiler.module.createGetGlobal(
"HEAP_BASE", compiler.currentType.toNativeType()
);
}
compiler.error(DiagnosticCode.Operation_not_supported, reportNode.range);
return compiler.module.createUnreachable();
}
/** Compiles a call to a built-in function. */
export function compileCall(compiler: Compiler, prototype: FunctionPrototype, typeArguments: Type[] | null, operands: Expression[], contextualType: Type, reportNode: Node): ExpressionRef {
export function compileCall(
compiler: Compiler,
prototype: FunctionPrototype,
typeArguments: Type[] | null,
operands: Expression[],
contextualType: Type,
reportNode: Node
): ExpressionRef {
var module = compiler.module;
var arg0: ExpressionRef,