Update binary expression inference, see #35; Update dependencies

This commit is contained in:
dcodeIO
2018-03-01 19:42:07 +01:00
parent 02dce5a518
commit 4633fdab96
26 changed files with 6342 additions and 3057 deletions

View File

@ -41,7 +41,7 @@ export class Array<T> {
@operator("[]")
private __get(index: i32): T {
if (<u32>index >= this.__capacity) {
if (<u32>index >= <u32>this.__capacity) {
throw new Error("Index out of bounds"); // return changetype<T>(0) ?
}
return load<T>(this.__memory + <usize>index * sizeof<T>());
@ -62,7 +62,7 @@ export class Array<T> {
if (fromIndex < 0) {
fromIndex = this.__length + fromIndex;
}
while (<u32>fromIndex < this.__length) {
while (<u32>fromIndex < <u32>this.__length) {
if (load<T>(this.__memory + <usize>fromIndex * sizeof<T>()) == searchElement) {
return fromIndex;
}

View File

@ -185,8 +185,8 @@ export { usize };
@builtin
declare function bool(value: void): bool;
namespace bool {
export const MIN_VALUE: bool = 0;
export const MAX_VALUE: bool = 1;
export const MIN_VALUE: bool = false;
export const MAX_VALUE: bool = true;
}
export { bool };

View File

@ -13,13 +13,13 @@ function allocate(length: i32): String {
export class String {
readonly length: i32;
readonly length: i32; // capped to [0, 0x7fffffff]
@operator("[]")
charAt(pos: i32): String {
assert(this != null);
if (<u32>pos >= this.length) {
if (<u32>pos >= <u32>this.length) {
return EMPTY;
}
@ -37,7 +37,7 @@ export class String {
charCodeAt(pos: i32): i32 {
assert(this != null);
if (<u32>pos >= this.length) {
if (<u32>pos >= <u32>this.length) {
return -1; // (NaN)
}
return load<u16>(
@ -48,7 +48,7 @@ export class String {
codePointAt(pos: i32): i32 {
assert(this != null);
if (<u32>pos >= this.length) {
if (<u32>pos >= <u32>this.length) {
return -1; // (undefined)
}
var first = <i32>load<u16>(