Browse Source

pastojs: library: export unitname.name as alias

mattias 3 years ago
parent
commit
4c544d7858
2 changed files with 6 additions and 5 deletions
  1. 3 2
      packages/pastojs/src/fppas2js.pp
  2. 3 3
      packages/pastojs/tests/tcmodules.pas

+ 3 - 2
packages/pastojs/src/fppas2js.pp

@@ -18013,6 +18013,7 @@ var
   EvalValue: TResEvalValue;
   EvalValue: TResEvalValue;
   ExpNameJS: TJSExportNameElement;
   ExpNameJS: TJSExportNameElement;
   Decl: TPasElement;
   Decl: TPasElement;
+  ResolvedEl: TPasResolverResult;
 begin
 begin
   ExportSymbols:=El.LibrarySection.ExportSymbols;
   ExportSymbols:=El.LibrarySection.ExportSymbols;
   if ExportSymbols.Count=0 then exit;
   if ExportSymbols.Count=0 then exit;
@@ -18028,8 +18029,8 @@ begin
     // name
     // name
     if Symb.NameExpr<>nil then
     if Symb.NameExpr<>nil then
       begin
       begin
-      RaiseNotSupported(Symb.NameExpr,AContext,20211020142210);
-      Decl:=nil;
+      aResolver.ComputeElement(Symb.NameExpr,ResolvedEl,[rcConstant]);
+      Decl:=ResolvedEl.IdentEl;
       end
       end
     else
     else
       begin
       begin

+ 3 - 3
packages/pastojs/tests/tcmodules.pas

@@ -33806,15 +33806,15 @@ begin
   'end;',
   'end;',
   'exports',
   'exports',
   '  Run;',
   '  Run;',
-  //'  run name ''Foo'';',
-  //'  test1.run name ''Test1Run'';',
+  '  run name ''Foo'';',
+  '  test1.run name ''Test1Run'';',
   '']);
   '']);
   ConvertLibrary;
   ConvertLibrary;
   CheckSource('TestLibrary_ExportFunc',
   CheckSource('TestLibrary_ExportFunc',
     LinesToStr([ // statements
     LinesToStr([ // statements
     'this.Run = function (w) {',
     'this.Run = function (w) {',
     '};',
     '};',
-    'export { this.Run as Run };',
+    'export { this.Run as Run, this.Run as Foo, this.Run as Test1Run };',
     '']),
     '']),
     LinesToStr([
     LinesToStr([
     '']));
     '']));