From 91eb79ed40213c8b2842397dcb888f3534f82064 Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Mon, 16 Sep 2019 21:37:41 +0300 Subject: [PATCH] Feature: types.Int - initial support for signed --- src/bitcode.ts | 4 ++-- src/types/int.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bitcode.ts b/src/bitcode.ts index 690287e..7ef6649 100644 --- a/src/bitcode.ts +++ b/src/bitcode.ts @@ -19,8 +19,8 @@ export class Builder { return new types.Void(); } - public static i(width: number): types.Int { - return new types.Int(width); + public static i(width: number, signed: boolean = false): types.Int { + return new types.Int(width, signed); } public static signature(returnType: Type, params: Type[]): types.Signature { diff --git a/src/types/int.ts b/src/types/int.ts index 6c5bd54..9076c24 100644 --- a/src/types/int.ts +++ b/src/types/int.ts @@ -2,7 +2,7 @@ import * as values from '../values'; import { Type } from './base'; export class Int extends Type { - constructor(public readonly width: number) { + constructor(public readonly width: number, public readonly signed: boolean = false) { super('i' + width); } @@ -16,7 +16,7 @@ export class Int extends Type { } const toInt = to as Int; - return toInt.width === this.width; + return toInt.width === this.width && toInt.signed === this.signed; } public val(num: number): values.constants.Int {