Skip to content

Commit cdf29ab

Browse files
Improved "exports/imports" (#145)
* added test * fixing "public" property for class static members * more fixes to public property of global ops * progress of adding export dependancy * progress of implementing export * progress of implementing export functionality * added extra code for export * added namespaces to export * fixes to dll symbol names * reactivated test * progress of adding export declaration for classes * progress * fixing typo * fixes to interfaces in declarations of class * fix for namespace in declaration for dll * fixed issues with interfaces in class declarations * updated test * updated test * added cast validation from tuple to cast * added namespaces to exports * added namespace to function exports * added namespace to var name for export * added test for object export in dll * added test for future tests * added test for future use * added more tests * updated enum with name * added enum import * fix for export enum in namespace * fixed issue with not showing error on generating no-entry code * fixes to test * added cast from enum * fixes to export types to dll * added fixes to dependencies when export to dll * progress of fixes * final fix * updated build scripts
1 parent 9fd0d5c commit cdf29ab

27 files changed

+688
-131
lines changed

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-alpha59 -m "pre alpha v0.0-59"
1+
git tag -a v0.0-pre-alpha60 -m "pre alpha v0.0-60"
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-alpha59
2-
git tag -d v0.0-pre-alpha59
1+
git push --delete origin v0.0-pre-alpha60
2+
git tag -d v0.0-pre-alpha60

tsc/include/TypeScript/MLIRLogic/MLIRDeclarationPrinter.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ namespace typescript
1616
public:
1717
MLIRDeclarationPrinter(raw_ostream &os) : os(os) {};
1818

19-
void printTypeDeclaration(StringRef, mlir::Type);
20-
void printEnum(StringRef, mlir::DictionaryAttr);
21-
void printVariableDeclaration(StringRef, mlir::Type, bool);
22-
void print(FunctionPrototypeDOM::TypePtr);
19+
void printTypeDeclaration(StringRef, NamespaceInfo::TypePtr, mlir::Type);
20+
void printEnum(StringRef, NamespaceInfo::TypePtr, mlir::DictionaryAttr);
21+
void printVariableDeclaration(StringRef, NamespaceInfo::TypePtr, mlir::Type, bool);
22+
void print(StringRef, NamespaceInfo::TypePtr, mlir_ts::FunctionType);
2323
void print(ClassInfo::TypePtr);
24-
void print(InterfaceInfo::TypePtr);
24+
void print(InterfaceInfo::TypePtr);
2525

2626
protected:
2727
void newline();
@@ -34,6 +34,8 @@ namespace typescript
3434
void printParams(ArrayRef<mlir::Type>, mlir::Type);
3535
void printFunction(StringRef, ArrayRef<mlir::Type>, mlir::Type);
3636
void printMethod(bool, StringRef, ArrayRef<mlir::Type>, mlir::Type, mlir::Type);
37+
void printNamespaceBegin(NamespaceInfo::TypePtr);
38+
void printNamespaceEnd(NamespaceInfo::TypePtr);
3739
void print(mlir::Type);
3840
};
3941

tsc/include/TypeScript/MLIRLogic/MLIRGenStore.h

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ struct GenericFunctionInfo
2222

2323
mlir::StringRef name;
2424

25+
NamespaceInfo_TypePtr elementNamespace;
26+
2527
llvm::SmallVector<TypeParameterDOM::TypePtr> typeParams;
2628

2729
FunctionLikeDeclarationBase functionDeclaration;
@@ -30,8 +32,6 @@ struct GenericFunctionInfo
3032

3133
mlir_ts::FunctionType funcType;
3234

33-
NamespaceInfo_TypePtr elementNamespace;
34-
3535
llvm::StringMap<std::pair<TypeParameterDOM::TypePtr, mlir::Type>> typeParamsWithArgs;
3636

3737
bool processing;
@@ -201,6 +201,8 @@ struct InterfaceInfo
201201

202202
mlir::StringRef fullName;
203203

204+
NamespaceInfo_TypePtr elementNamespace;
205+
204206
mlir_ts::InterfaceType interfaceType;
205207

206208
mlir_ts::InterfaceType originInterfaceType;
@@ -431,14 +433,14 @@ struct GenericInterfaceInfo
431433

432434
mlir::StringRef fullName;
433435

436+
NamespaceInfo_TypePtr elementNamespace;
437+
434438
llvm::SmallVector<TypeParameterDOM::TypePtr> typeParams;
435439

436440
mlir_ts::InterfaceType interfaceType;
437441

438442
InterfaceDeclaration interfaceDeclaration;
439443

440-
NamespaceInfo_TypePtr elementNamespace;
441-
442444
GenericInterfaceInfo()
443445
{
444446
}
@@ -462,6 +464,22 @@ enum class ProcessingStages : int {
462464
Processed = 7,
463465
};
464466

467+
struct EnumInfo
468+
{
469+
public:
470+
using TypePtr = std::shared_ptr<EnumInfo>;
471+
472+
mlir::StringRef name;
473+
474+
mlir::StringRef fullName;
475+
476+
NamespaceInfo_TypePtr elementNamespace;
477+
478+
mlir_ts::EnumType enumType;
479+
480+
EnumInfo() = default;
481+
};
482+
465483
struct ClassInfo
466484
{
467485
public:
@@ -471,6 +489,8 @@ struct ClassInfo
471489

472490
mlir::StringRef fullName;
473491

492+
NamespaceInfo_TypePtr elementNamespace;
493+
474494
mlir_ts::ClassType classType;
475495

476496
mlir_ts::ClassType originClassType;
@@ -788,14 +808,14 @@ struct GenericClassInfo
788808

789809
mlir::StringRef fullName;
790810

811+
NamespaceInfo_TypePtr elementNamespace;
812+
791813
llvm::SmallVector<TypeParameterDOM::TypePtr> typeParams;
792814

793815
mlir_ts::ClassType classType;
794816

795817
ClassLikeDeclaration classDeclaration;
796818

797-
NamespaceInfo_TypePtr elementNamespace;
798-
799819
GenericClassInfo()
800820
{
801821
}

tsc/include/TypeScript/MLIRLogic/MLIRPrinter.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ class MLIRPrinter
190190
printTupleType(out, t);
191191
})
192192
.template Case<mlir_ts::EnumType>([&](auto t) {
193-
printType(out, t.getElementType());
193+
//printType(out, t.getElementType());
194+
out << t.getName().getValue().str().c_str();
194195
})
195196
.template Case<mlir_ts::FunctionType>([&](auto t) {
196197
printFuncType(out, t);
@@ -334,6 +335,9 @@ class MLIRPrinter
334335
.template Case<mlir_ts::NullType>([&](auto) {
335336
out << "null";
336337
})
338+
.template Case<mlir_ts::NamespaceType>([&](auto t) {
339+
out << t.getName().getValue().str().c_str();
340+
})
337341
.template Case<mlir::NoneType>([&](auto) {
338342
out << "void";
339343
})

tsc/include/TypeScript/MLIRLogic/MLIRTypeHelper.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3052,6 +3052,15 @@ class MLIRTypeHelper
30523052
return iter.some(type, [](mlir::Type type) { return type && isa<mlir_ts::InferType>(type); });
30533053
}
30543054

3055+
void forEachTypes(mlir::Type type, std::function<bool(mlir::Type)> f)
3056+
{
3057+
MLIRTypeIteratorLogic iter(
3058+
getClassInfoByFullName, getGenericClassInfoByFullName,
3059+
getInterfaceInfoByFullName, getGenericInterfaceInfoByFullName
3060+
);
3061+
iter.forEach(type, f);
3062+
}
3063+
30553064
bool getAllInferTypes(mlir::Type type, SmallVector<mlir_ts::InferType> &inferTypes)
30563065
{
30573066
MLIRTypeIteratorLogic iter(

tsc/include/TypeScript/MLIRLogic/MLIRTypeIterator.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,18 @@ class MLIRTypeIterator
9393
return false;
9494
}
9595

96+
for (auto &baseClass : srcClassInfo->baseClasses)
97+
{
98+
if (!iterate(baseClass->classType))
99+
return false;
100+
}
101+
102+
for (auto &impl : srcClassInfo->implements)
103+
{
104+
if (!iterate(impl.interface->interfaceType))
105+
return false;
106+
}
107+
96108
if (!iterate(srcClassInfo->classType.getStorageType()))
97109
return false;
98110
}
@@ -114,6 +126,12 @@ class MLIRTypeIterator
114126
if (!iterate(std::get<1>(pair.getValue())))
115127
return false;
116128
}
129+
130+
for (auto &impl : srcInterfaceInfo->extends)
131+
{
132+
if (!iterate(std::get<1>(impl)->interfaceType))
133+
return false;
134+
}
117135
}
118136

119137
return true;

tsc/include/TypeScript/TypeScriptTypes.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ def TypeScript_Enum : TypeScript_Type<"Enum"> {
177177
enum<i32>
178178
```
179179
}];
180-
let parameters = (ins "Type":$elementType, "DictionaryAttr":$values);
180+
let parameters = (ins "FlatSymbolRefAttr":$name, "Type":$elementType, "DictionaryAttr":$values);
181181

182182
let assemblyFormat = "`<` params `>`";
183183

184184
let builders = [
185-
TypeBuilderWithInferredContext<(ins "Type":$elementType, "DictionaryAttr":$values), [{
186-
return Base::get(elementType.getContext(), elementType, values);
185+
TypeBuilderWithInferredContext<(ins "FlatSymbolRefAttr":$name, "Type":$elementType, "DictionaryAttr":$values), [{
186+
return Base::get(elementType.getContext(), name, elementType, values);
187187
}]>
188-
];
188+
];
189189
}
190190

191191
def TypeScript_LiteralType : TypeScript_Type<"Literal"> {

0 commit comments

Comments
 (0)