From 351c66d5a43d18a8c023b68520a5ac51233b0668 Mon Sep 17 00:00:00 2001 From: xuhangqi Date: Wed, 18 Jun 2025 16:38:33 +0800 Subject: [PATCH] Add use static Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICG3TY Signed-off-by: xuhangqi Change-Id: Iedf56a731c862c41920b3da64c97e054b48751f3 --- ets2panda/compiler/core/compilerImpl.cpp | 1 + ets2panda/test/declgen/class-expected.txt | 2 +- ets2panda/test/declgen/enum-expected.txt | 2 +- ets2panda/test/declgen/export-expected.txt | 2 +- ets2panda/test/declgen/function-expected.txt | 1 + ets2panda/test/declgen/import-expected.txt | 2 +- ets2panda/test/declgen/indirect_dependence-expected.txt | 2 +- ets2panda/test/declgen/interface-expected.txt | 2 +- ets2panda/test/declgen/namespace-expected.txt | 2 +- ets2panda/test/declgen/var-expected.txt | 2 +- 10 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ets2panda/compiler/core/compilerImpl.cpp b/ets2panda/compiler/core/compilerImpl.cpp index f62aaf1083..0c66fb32c4 100644 --- a/ets2panda/compiler/core/compilerImpl.cpp +++ b/ets2panda/compiler/core/compilerImpl.cpp @@ -119,6 +119,7 @@ void HandleGenerateDecl(const parser::Program &program, util::DiagnosticEngine & } std::string result = program.Ast()->DumpDecl(); result.erase(0, result.find_first_not_of('\n')); + result = "'use static'\n" + result; outFile << result; outFile.close(); diff --git a/ets2panda/test/declgen/class-expected.txt b/ets2panda/test/declgen/class-expected.txt index 74dcb08e91..443f6a2ee6 100644 --- a/ets2panda/test/declgen/class-expected.txt +++ b/ets2panda/test/declgen/class-expected.txt @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +'use static' export declare interface I0 { I0Method(a: string): String; diff --git a/ets2panda/test/declgen/enum-expected.txt b/ets2panda/test/declgen/enum-expected.txt index 0bff710d1f..048eafcca4 100644 --- a/ets2panda/test/declgen/enum-expected.txt +++ b/ets2panda/test/declgen/enum-expected.txt @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +'use static' export declare final class Direction extends BaseEnum { diff --git a/ets2panda/test/declgen/export-expected.txt b/ets2panda/test/declgen/export-expected.txt index 487a95e02f..4a5c3b6e47 100644 --- a/ets2panda/test/declgen/export-expected.txt +++ b/ets2panda/test/declgen/export-expected.txt @@ -12,5 +12,5 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +'use static' export { union as union1 } from "./var"; \ No newline at end of file diff --git a/ets2panda/test/declgen/function-expected.txt b/ets2panda/test/declgen/function-expected.txt index 6212d507e8..907c95b050 100644 --- a/ets2panda/test/declgen/function-expected.txt +++ b/ets2panda/test/declgen/function-expected.txt @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + 'use static' export declare function add(x: number, y: number): double; export declare function greet(name: string, age?: number): String; diff --git a/ets2panda/test/declgen/import-expected.txt b/ets2panda/test/declgen/import-expected.txt index daaa85018d..9bcb922565 100644 --- a/ets2panda/test/declgen/import-expected.txt +++ b/ets2panda/test/declgen/import-expected.txt @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +'use static' import * as AllType from "./var"; import { union as union1 } from "./var"; \ No newline at end of file diff --git a/ets2panda/test/declgen/indirect_dependence-expected.txt b/ets2panda/test/declgen/indirect_dependence-expected.txt index 0889fa1c7c..9a4918b560 100644 --- a/ets2panda/test/declgen/indirect_dependence-expected.txt +++ b/ets2panda/test/declgen/indirect_dependence-expected.txt @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +'use static' export declare function foo(c: C): int; export declare function foo1(): D; diff --git a/ets2panda/test/declgen/interface-expected.txt b/ets2panda/test/declgen/interface-expected.txt index 0e45342f0c..f43e9fdb28 100644 --- a/ets2panda/test/declgen/interface-expected.txt +++ b/ets2panda/test/declgen/interface-expected.txt @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +'use static' export declare interface User { abstract set id(id: number): void; diff --git a/ets2panda/test/declgen/namespace-expected.txt b/ets2panda/test/declgen/namespace-expected.txt index 8089251f18..d90fc8793c 100644 --- a/ets2panda/test/declgen/namespace-expected.txt +++ b/ets2panda/test/declgen/namespace-expected.txt @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +'use static' export declare namespace MathOperations { let PI: double; diff --git a/ets2panda/test/declgen/var-expected.txt b/ets2panda/test/declgen/var-expected.txt index 2a92bb7cf4..ca601392c0 100644 --- a/ets2panda/test/declgen/var-expected.txt +++ b/ets2panda/test/declgen/var-expected.txt @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +'use static' export declare let n: double; export declare let o: Object; -- Gitee