Skip to content

Commit ede26d0

Browse files
committed
Feature: Move Array<T> definitions to runtime library, due mangler usage
1 parent 33fd0c2 commit ede26d0

5 files changed

Lines changed: 63 additions & 62 deletions

File tree

packages/runtime/lib.runtime.d.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,63 @@ declare class Math {
1919
static random(): number;
2020
static abs(value: number): number;
2121
}
22+
23+
interface Array<T = any> {
24+
// push(member: number): number;
25+
}
26+
27+
declare type Int8Array = Array<int8>;
28+
declare type Uint8Array = Array<uint8>;
29+
30+
interface Int8ArrayConstructor {
31+
new(length: number): Int8Array;
32+
}
33+
34+
interface Uint8ArrayConstructor {
35+
new(length: number): Uint8Array;
36+
}
37+
38+
declare const Int8Array: Int8ArrayConstructor;
39+
declare const Uint8Array: Uint8ArrayConstructor;
40+
41+
declare type Int16Array = Array<int16>;
42+
declare type Uint16Array = Array<uint16>;
43+
44+
interface Int16ArrayConstructor {
45+
new(length: number): Int16Array;
46+
}
47+
48+
interface Uint16ArrayConstructor {
49+
new(length: number): Uint16Array;
50+
}
51+
52+
declare const Int16Array: Int16ArrayConstructor;
53+
declare const Uint16Array: Uint16ArrayConstructor;
54+
55+
declare type Int32Array = Array<int32>;
56+
declare type Uint32Array = Array<uint32>;
57+
58+
interface Int32ArrayConstructor {
59+
new(length: number): Int32Array;
60+
}
61+
62+
interface Uint32ArrayConstructor {
63+
new(length: number): Uint32Array;
64+
}
65+
66+
declare const Int32Array: Int32ArrayConstructor;
67+
declare const Uint32Array: Uint32ArrayConstructor;
68+
69+
declare type Float32Array = Array<float32>;
70+
declare type Float64Array = Array<float64>;
71+
72+
interface Float32ArrayConstructor {
73+
new(length: number): Float32Array;
74+
}
75+
76+
interface Float64ArrayConstructor {
77+
new(length: number): Float64Array;
78+
}
79+
80+
declare const Float32Array: Float32ArrayConstructor;
81+
declare const Float64Array: Float64ArrayConstructor;

src/backend/llvm/native-type-resolver.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ export class NativeTypeResolver {
2222
return NativeTypeResolver.getType(genericType.typeArguments[0], ctx);
2323
}
2424

25-
const a = ctx.typeChecker.getApparentType(type);
26-
2725
if (type.isStringLiteral() || (<any>type).intrinsicName === 'string') {
2826
return new NativeType(
2927
llvm.Type.getInt8PtrTy(

src/backend/llvm/node-generate.interface.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import * as ts from 'typescript';
33
import * as llvm from 'llvm-node';
44
import {Context} from './context';
55
import {Value} from "./value";
6+
import {NativeType} from "./native-type";
67

78
export interface NodeGenerateInterface<N extends ts.Node, R extends Value | void> {
8-
generate(node: N, ctx: Context, builder: llvm.IRBuilder): R;
9+
generate(node: N, ctx: Context, builder: llvm.IRBuilder, nativeType?: NativeType): R;
910
}

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ const cliOptions = parseCommandLine();
3434

3535
const options = {
3636
lib: [
37+
path.join(__dirname, '..', 'staticscript.d.ts'),
3738
RUNTIME_DEFINITION_FILE,
38-
path.join(__dirname, '..', 'staticscript.d.ts')
3939
],
4040
types: []
4141
};

staticscript.d.ts

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -29,63 +29,5 @@ interface RegExp {}
2929

3030
interface String {}
3131

32-
interface Array<T = any> {}
33-
34-
declare type Int8Array = Array<int8>;
35-
declare type Uint8Array = Array<uint8>;
36-
37-
interface Int8ArrayConstructor {
38-
new(length: number): Int8Array;
39-
}
40-
41-
interface Uint8ArrayConstructor {
42-
new(length: number): Uint8Array;
43-
}
44-
45-
declare const Int8Array: Int8ArrayConstructor;
46-
declare const Uint8Array: Uint8ArrayConstructor;
47-
48-
declare type Int16Array = Array<int16>;
49-
declare type Uint16Array = Array<uint16>;
50-
51-
interface Int16ArrayConstructor {
52-
new(length: number): Int16Array;
53-
}
54-
55-
interface Uint16ArrayConstructor {
56-
new(length: number): Uint16Array;
57-
}
58-
59-
declare const Int16Array: Int16ArrayConstructor;
60-
declare const Uint16Array: Uint16ArrayConstructor;
61-
62-
declare type Int32Array = Array<int32>;
63-
declare type Uint32Array = Array<uint32>;
64-
65-
interface Int32ArrayConstructor {
66-
new(length: number): Int32Array;
67-
}
68-
69-
interface Uint32ArrayConstructor {
70-
new(length: number): Uint32Array;
71-
}
72-
73-
declare const Int32Array: Int32ArrayConstructor;
74-
declare const Uint32Array: Uint32ArrayConstructor;
75-
76-
declare type Float32Array = Array<float32>;
77-
declare type Float64Array = Array<float64>;
78-
79-
interface Float32ArrayConstructor {
80-
new(length: number): Float32Array;
81-
}
82-
83-
interface Float64ArrayConstructor {
84-
new(length: number): Float64Array;
85-
}
86-
87-
declare const Float32Array: Float32ArrayConstructor;
88-
declare const Float64Array: Float64ArrayConstructor;
89-
9032
declare function puts(str: string): void;
9133

0 commit comments

Comments
 (0)