Skip to content

Commit dcc6554

Browse files
committed
Feature: NativeTypeResolver - initial support for int8, 16, 32, 64, 128
1 parent 53443ad commit dcc6554

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

runtime/lib.runtime.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,11 @@ interface Array<T = any> {}
1818
declare function puts(str: string): void;
1919

2020
declare function number2string(value: number): string;
21+
22+
declare type int8 = {};
23+
declare type int16 = {};
24+
declare type int32 = {};
25+
declare type int64 = {};
26+
declare type int128 = {};
27+
28+
// RSTP - Real Static Type Script

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,36 @@ export class NativeTypeResolver {
2323
);
2424
}
2525

26+
const aliasSymbol = type.aliasSymbol;
27+
if (aliasSymbol) {
28+
switch (aliasSymbol.escapedName) {
29+
case 'int8':
30+
return llvm.Type.getInt8Ty(
31+
ctx.llvmContext
32+
);
33+
case 'int16':
34+
return llvm.Type.getInt16Ty(
35+
ctx.llvmContext
36+
);
37+
case 'int32':
38+
return llvm.Type.getInt32Ty(
39+
ctx.llvmContext
40+
);
41+
case 'int64':
42+
return llvm.Type.getInt64Ty(
43+
ctx.llvmContext
44+
);
45+
case 'int128':
46+
return llvm.Type.getInt128Ty(
47+
ctx.llvmContext
48+
);
49+
default:
50+
throw new Error(
51+
`Unsupported type, "${<string>aliasSymbol.escapedName}"`
52+
);
53+
}
54+
}
55+
2656
throw new Error(
2757
`Unsupported type, it's to dynamic`
2858
);

0 commit comments

Comments
 (0)