if that's what's necessary

This commit is contained in:
dcode
2019-03-14 06:09:49 +01:00
parent a5e14a0eaa
commit 84ddd97761
25 changed files with 1845 additions and 769 deletions

View File

@ -91,6 +91,7 @@ export namespace BuiltinSymbols {
// std/builtins.ts
export const isInteger = "~lib/builtins/isInteger";
export const isFloat = "~lib/builtins/isFloat";
export const isBoolean = "~lib/builtins/isBoolean";
export const isSigned = "~lib/builtins/isSigned";
export const isReference = "~lib/builtins/isReference";
export const isString = "~lib/builtins/isString";
@ -542,6 +543,14 @@ export function compileCall(
? module.createI32(1)
: module.createI32(0);
}
case BuiltinSymbols.isBoolean: { // isBoolean<T!>() / isBoolean<T?>(value: T) -> bool
let type = evaluateConstantType(compiler, typeArguments, operands, reportNode);
compiler.currentType = Type.bool;
if (!type) return module.createUnreachable();
return type == Type.bool
? module.createI32(1)
: module.createI32(0);
}
case BuiltinSymbols.isSigned: { // isSigned<T!>() / isSigned<T?>(value: T) -> bool
let type = evaluateConstantType(compiler, typeArguments, operands, reportNode);
compiler.currentType = Type.bool;