Skip to content

Commit 7aa1134

Browse files
Bug fixes (#161)
* Refactor namespace resolution logic in MLIRGen to improve clarity and functionality * Refactor function instantiation logic in MLIRGen to enhance clarity and prevent nested generics instantiation * Simplify bound function creation by removing unnecessary opaque type casting * Refactor MLIRGen to remove unnecessary reference type casting and improve type handling; add tests for nested function captures * Enhance MLIR type handling with new toPrimitive methods; add tests for primitive operations * update test * Enhance MLIRGen to support primitive type casting in binary operations; improve class instance handling for union types * refactoring * refactoring binary ops * Refactor MLIRGen to improve function processing and error handling; ensure consistent return types for lambdas * Enhance MLIRGen to improve type casting checks; add validation for class and interface types during casting * Refactor MLIRGen to enhance handling of 'this' context; improve type checks for class and storage types during method resolution * Remove obsolete bug18 test and add new tests for class iterator with super calls * Implement rollback for postponed error messages and enhance generic function instantiation for binary operations * Add tests for logical assignment operators and their behavior with optional parameters * Remove obsolete bug23 test and add new tests for logical assignment operators * Enhance MLIRGen to support additional function types in type handling
1 parent 91acccf commit 7aa1134

14 files changed

Lines changed: 538 additions & 111 deletions

docs/bugs/bug23.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

docs/bugs/generic_in_generic.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
function render(screenWidth, screenHeight) {
22
const getPoint = (x, y) => {
3-
var recenterX = x =>(x - (screenWidth / 2.0)) / 2.0 / screenWidth;
4-
var recenterY = y => - (y - (screenHeight / 2.0)) / 2.0 / screenHeight;
3+
const recenterX = x => (x - (screenWidth / 2.0)) / 2.0 / screenWidth;
4+
const recenterY = y => -(y - (screenHeight / 2.0)) / 2.0 / screenHeight;
55
return recenterX(x) + recenterY(y);
66
}
77

8-
const v = getPoint(0, 0);
8+
const v = getPoint(512, 384);
9+
print(v);
10+
assert(v === 0);
11+
12+
const v2 = getPoint(1024, 768);
13+
print(v2);
14+
assert(v2 === 0);
15+
16+
const v3 = getPoint(300, 200);
17+
print(v3);
18+
assert((v3 - 0.016276) < 0.0001);
19+
920
}
1021

11-
render(8, 6);
22+
render(1024, 768);
1223

1324
print('done');

tag.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
git tag -a v0.0-pre-alpha71 -m "pre alpha v0.0-71"
1+
git tag -a v0.0-pre-alpha72 -m "pre alpha v0.0-72"
22
git push origin --tags

tag_del.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
git push --delete origin v0.0-pre-alpha71
2-
git tag -d v0.0-pre-alpha71
1+
git push --delete origin v0.0-pre-alpha72
2+
git tag -d v0.0-pre-alpha72

tsc/include/TypeScript/MLIRLogic/MLIRCodeLogic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class MLIRCodeLogic
253253

254254
mlir::Type CaptureTypeStorage(llvm::StringMap<ts::VariableDeclarationDOM::TypePtr> &capturedVars)
255255
{
256-
SmallVector<mlir_ts::FieldInfo> fields;
256+
SmallVector<mlir_ts::FieldInfo> fields;
257257
for (auto &varInfo : capturedVars)
258258
{
259259
auto &value = varInfo.getValue();

tsc/include/TypeScript/MLIRLogic/MLIRTypeCore.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ class MLIRTypeCore
1616
{
1717
public:
1818

19+
static bool canHaveToPrimitiveMethod(mlir::Type type)
20+
{
21+
return isa<mlir_ts::ClassType>(type)
22+
|| isa<mlir_ts::InterfaceType>(type)
23+
|| isa<mlir_ts::ObjectType>(type)
24+
|| isa<mlir_ts::TupleType>(type)
25+
|| isa<mlir_ts::ConstTupleType>(type);
26+
}
27+
28+
static bool shouldCastToNumber(mlir::Type type)
29+
{
30+
return isa<mlir::IntegerType>(type)
31+
|| isa<mlir::FloatType>(type);
32+
}
33+
1934
static bool isNullableTypeNoUnion(mlir::Type typeIn)
2035
{
2136
if (isa<mlir_ts::NullType>(typeIn)

0 commit comments

Comments
 (0)