diff --git a/.gitee/PULL_REQUEST_TEMPLATE.en.md b/.gitee/PULL_REQUEST_TEMPLATE.en.md index 3758df1abdb54e82dfd81d2da9e2c947c11e61aa..e8d76c6d8cb96f0ee66ae881797496b1eca37111 100644 --- a/.gitee/PULL_REQUEST_TEMPLATE.en.md +++ b/.gitee/PULL_REQUEST_TEMPLATE.en.md @@ -12,3 +12,77 @@ _Please add detailed description_ ninja all tests ``` **All required pre-merge tests passed. Results are available in the internal CI.** + +#### Functional Testing (Mandatory unless the change only involves text) [wiki](https://gitee.com/openharmony/arkcompiler_ets_frontend/wikis/%E4%BB%A3%E7%A0%81%E6%8F%90%E4%BA%A4%E8%A6%81%E6%B1%82%E5%8F%8A%E6%B5%8B%E8%AF%95%E9%AA%8C%E8%AF%81%E6%B5%81%E7%A8%8B) +1. es2abc Test Cases (Debug Mode) +- [ ] Passed +- [ ] Not applicable, no need to verify + +2. Verifier Testing +- [ ] Passed +- [ ] Not applicable, no need to verify + +3. 64-bit RK Compilation +- [ ] Passed +- [ ] Not applicable, no need to verify + +4. Compile macOS SDK +- [ ] Passed +- [ ] Not applicable, no need to verify + +#### Obfuscation Testing (Mandatory if ArkGuard-related changes are involved) [wiki](https://gitee.com/openharmony/arkcompiler_ets_frontend/wikis/%E6%B7%B7%E6%B7%86%E6%B5%8B%E8%AF%95%E9%AA%8C%E8%AF%81%E6%B5%81%E7%A8%8B?sort_id=11451209) +1. Unit Tests +- [ ] Passed +- [ ] Not applicable, no need to verify + +2. Compiler Test Suite +- [ ] Passed +- [ ] Not applicable, no need to verify + +3. TSC Extra Test Suite +- [ ] Passed +- [ ] Not applicable, no need to verify + +4. Test262 Test Suite +- [ ] Passed +- [ ] Not applicable, no need to verify + +5. Benchmark Tests +- [ ] Passed +- [ ] Not applicable, no need to verify + +6. Automated Application Test Suite +- [ ] Passed +- [ ] Not applicable, no need to verify + +7. Global Variable Check — Were any global variables created? If so, were they cleared? +- [ ] Global variables created and cleared +- [ ] Global variables created but not cleared +- [ ] No global variables created + +#### Compatibility Testing (for instruction generation or file format changes) +1. Minor Version Compatibility Test +- [ ] Version number added +- [ ] Passed +- [ ] Not applicable, no need to verify + +2. Major Version Compatibility Test +- [ ] Passed +- [ ] Not applicable, no need to verify + +3. es2abc Version Compatibility Test +**Note: If the PR involves changes to version control test cases, you must also check its impact on other branches and confirm whether updates are needed in those branches.** +- [ ] Affected — Changes impact API/bytecode version and need to be synced to other branches +- [ ] Affected — Changes impact API/bytecode version but do not need to be synced to other branches +- [ ] Not affected — Changes do not involve API/bytecode version + +#### Performance Testing (e.g., new syntax checking scenarios) +- [ ] Passed +- [ ] Not applicable, no need to verify + +#### Command/abc format modification self-check, please contact the email below, synchronize to the relevant field +**Important: For modifications involving the abc2program, libpandafile and isa directories in the runtime_core repository, you must provide a compiled hap package for the helloworld project to the corresponding domain and contact the email address below.** +- [ ] Involved, already synchronized +- [ ] Not involved + +**Email:** wutao185@huawei.com \ No newline at end of file diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md index 2ab6c799899617a7abf336004400c3e8d69cccb3..b2eed2595f19a7622862f5c150adb75e7c1ea992 100644 --- a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md +++ b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md @@ -16,47 +16,22 @@ ### 测试结果(测试截图直接贴在对应测试项,主干已知问题需明确引入pr/责任人) -#### 当前GGW中未添加的测试套(请在本地进行验证) -1.Fuzz编译测试 -``` -./build.sh --product-name rk3568 --build-target arkcompiler/runtime_core/tests/fuzztest:fuzztest -``` - -2."runtime_core/libpandabase/tests:host_unittest" -release模式: -``` -./build.sh --product-name rk3568 --build-target runtime_core_host_unittest -``` -debug模式: -``` -./build.sh --product-name rk3568 --build-target runtime_core_host_unittest --gn-args is_debug=true -``` - #### 功能测试(除仅涉及文本外必测项)[wiki](https://gitee.com/openharmony/arkcompiler_ets_frontend/wikis/%E4%BB%A3%E7%A0%81%E6%8F%90%E4%BA%A4%E8%A6%81%E6%B1%82%E5%8F%8A%E6%B5%8B%E8%AF%95%E9%AA%8C%E8%AF%81%E6%B5%81%E7%A8%8B) -1. test262测试 - - [ ] 已通过 - - [ ] 不涉及,无需验证 - -2. ut测试 - - [ ] 已通过 - - [ ] 不涉及,无需验证 - -3. verifier测试 - - [ ] 已通过 - - [ ] 不涉及,无需验证 +1. es2abc测试用例(Debug模式) +- [ ] 已通过 +- [ ] 不涉及,无需验证 -#### 独立编译测试(涉及BUILD.gn改动时必测项)[wiki](https://gitee.com/ark_standalone_build/docs#arkcompiler%E5%BC%80%E5%8F%91%E6%8C%87%E5%AF%BC) -1. test262 release - - [ ] 已通过 - - [ ] 不涉及,无需验证 +2. Verifier测试 +- [ ] 已通过 +- [ ] 不涉及,无需验证 -2. ut release - - [ ] 已通过 - - [ ] 不涉及,无需验证 +3. 64位RK编译 +- [ ] 已通过 +- [ ] 不涉及,无需验证 -3. ut debug - - [ ] 已通过 - - [ ] 不涉及,无需验证 +4. 编译mac平台sdk +- [ ] 已通过 +- [ ] 不涉及,无需验证 #### 混淆测试(涉及arkguard改动时必测项)[wiki](https://gitee.com/openharmony/arkcompiler_ets_frontend/wikis/%E6%B7%B7%E6%B7%86%E6%B5%8B%E8%AF%95%E9%AA%8C%E8%AF%81%E6%B5%81%E7%A8%8B?sort_id=11451209) 1. 单元测试 @@ -98,6 +73,12 @@ debug模式: - [ ] 已通过 - [ ] 不涉及,无需验证 +3. es2abc版本兼容性测试 +**说明:如PR涉及版本控制用例的变更,需同步检查修改对其他分支的影响,并确认是否要同步受影响的分支** + - [ ] 涉及,变更影响 API/字节码 版本, 需同步修改到其他分支 + - [ ] 涉及,变更影响 API/字节码 版本, 无需同步到其他分支 + - [ ] 不涉及,变更不涉及 API/字节码 版本 + #### 性能测试 (新增语法检查等场景) - [ ] 已通过 - [ ] 不涉及,无需验证 @@ -107,4 +88,8 @@ debug模式: - [ ] 涉及,已同步 - [ ] 不涉及 -**Email:** chenqiuyao@huawei.com +**Email:** wutao185@huawei.com + +### 是否已执行L0用例 +- [ ] 已验证 +- [ ] 不涉及。如不涉及,请写明理由 diff --git a/arkguard/src/ArkObfuscator.ts b/arkguard/src/ArkObfuscator.ts index 708aa9ce8911252876380236e3bea0e33f4e6ef9..2e4795e2cafe4109f447561417b9024d4da300e5 100644 --- a/arkguard/src/ArkObfuscator.ts +++ b/arkguard/src/ArkObfuscator.ts @@ -35,7 +35,13 @@ import type { import path from 'path'; -import { AtKeepCollections, LocalVariableCollections, PropCollections } from './utils/CommonCollections'; +import { + AtIntentCollections, + AtKeepCollections, + BytecodeObfuscationCollections, + LocalVariableCollections, + PropCollections +} from './utils/CommonCollections'; import type { IOptions } from './configs/IOptions'; import { FileUtils } from './utils/FileUtils'; import { TransformerManager } from './transformers/TransformerManager'; @@ -74,6 +80,7 @@ import { EventList, TimeAndMemTimeTracker, clearTimeAndMemPrinterData, + disablePrinterTimeAndMemConfig, initPerformanceTimeAndMemPrinter, } from './utils/PrinterTimeAndMemUtils'; @@ -89,9 +96,11 @@ export { } from './utils/PrinterUtils'; export { EventList, + PerfMode, TimeAndMemTimeTracker, - enableTimeAndMemoryPrint, blockTimeAndMemPrinter, + configurePerformancePrinter, + enableTimeAndMemoryPrint, } from './utils/PrinterTimeAndMemUtils'; import { Extension, type ProjectInfo, type FilePathObj } from './common/type'; export { type HvigorErrorInfo } from './common/type'; @@ -111,7 +120,7 @@ export { separateUniversalReservedItem, containWildcards, wildcardTransformer } export type { ReservedNameInfo } from './utils/TransformUtil'; export type { ReseverdSetForArkguard } from './common/ApiReader'; -export { initObfuscationConfig, initPrinterTimeAndMemConfig, printerTimeAndMemConfig, printerTimeAndMemDataConfig } from './initialization/Initializer'; +export { initObfuscationConfig, printerTimeAndMemDataConfig } from './initialization/Initializer'; export { nameCacheMap, unobfuscationNamesObj } from './initialization/CommonObject'; export { collectResevedFileNameInIDEConfig, // For running unit test. @@ -166,12 +175,15 @@ export function clearGlobalCaches(): void { UnobfuscationCollections.clear(); LocalVariableCollections.clear(); AtKeepCollections.clear(); + AtIntentCollections.clear(); renameFileNameModule.clearCaches(); clearUnobfuscationNamesObj(); clearHistoryUnobfuscatedMap(); clearTimeAndMemPrinterData(); + disablePrinterTimeAndMemConfig(); ApiExtractor.mConstructorPropertySet.clear(); ApiExtractor.mEnumMemberSet.clear(); + BytecodeObfuscationCollections.clear(); } export type ObfuscationResultType = { @@ -195,7 +207,7 @@ export class ArkObfuscator { // A text writer of Printer private mTextWriter: EmitTextWriter; - // Compiler Options for typescript,use to parse ast + // Compiler Options for typescript, use to parse ast private readonly mCompilerOptions: CompilerOptions; // User custom obfuscation profiles. @@ -348,6 +360,10 @@ export class ArkObfuscator { this.mCompilerOptions.sourceMap = true; } + if (this.mCustomProfiles.mAllowEtsAnnotations) { + this.mCompilerOptions.etsAnnotationsEnable = true; + } + const enableTopLevel: boolean = this.mCustomProfiles.mNameObfuscation?.mTopLevel; const exportObfuscation: boolean = this.mCustomProfiles.mExportObfuscation; const propertyObfuscation: boolean = this.mCustomProfiles.mNameObfuscation?.mRenameProperties; @@ -360,9 +376,8 @@ export class ArkObfuscator { this.mTransformers = new TransformerManager(this.mCustomProfiles).getTransformers(); initPerformancePrinter(this.mCustomProfiles); - - initPerformanceTimeAndMemPrinter(this.mCustomProfiles); + initPerformanceTimeAndMemPrinter(); if (needReadApiInfo(this.mCustomProfiles)) { // if -enable-property-obfuscation or -enable-export-obfuscation, collect language reserved keywords. let languageSet: Set = new Set(); @@ -454,27 +469,44 @@ export class ArkObfuscator { updatedCache[newKey] = value; continue; } + + const parts = scopeName.split('#'); + // 1: Get the last word 'zz' in '#xx#yy#zz'. + const lastScopeName: string = parts[parts.length - 1]; + const startPosition: SourceMapSegmentObj | null = sourceMapLink.traceSegment( // 1: The line number in originalCache starts from 1 while in source map starts from 0. Number(oldStartLine) - 1, Number(oldStartColumn) - 1, ''); // Minus 1 to get the correct original position. - if (!startPosition) { - // Do not save methods that do not exist in the source code, e.g. 'build' in ArkUI. + if (!startPosition && lastScopeName === value) { + // Do not save methods that do not exist in the source code and not be obfuscated, e.g. 'build' in ArkUI. continue; } const endPosition: SourceMapSegmentObj | null = sourceMapLink.traceSegment( Number(oldEndLine) - 1, Number(oldEndColumn) - 1, ''); // 1: Same as above. - if (!endPosition) { - // Do not save methods that do not exist in the source code, e.g. 'build' in ArkUI. + if (!endPosition && lastScopeName === value) { + // Do not save methods that do not exist in the source code and not be obfuscated, e.g. 'build' in ArkUI. continue; } - const startLine = startPosition.line + 1; // 1: The final line number in updatedCache should starts from 1. - const endLine = endPosition.line + 1; // 1: Same as above. - newKey = `${scopeName}:${startLine}:${endLine}`; - updatedCache[newKey] = value; + + if (!startPosition || !endPosition) { + updatedCache[scopeName] = value; + } else { + const startLine = startPosition.line + 1; // 1: The final line number in updatedCache should starts from 1. + const endLine = endPosition.line + 1; // 1: Same as above. + newKey = `${scopeName}:${startLine}:${endLine}`; + updatedCache[newKey] = value; + } } return updatedCache; } + public convertLineBasedOnSourceMapForTest( + targetCache: string, + sourceMapLink?: SourceMapLink + ): Map { + return this.convertLineBasedOnSourceMap(targetCache, sourceMapLink); + } + /** * Obfuscate ast of a file. * @param content ast or source code of a source file @@ -541,7 +573,7 @@ export class ArkObfuscator { startSingleFileEvent(EventList.CREATE_AST, performancePrinter.timeSumPrinter); let ast: SourceFile; if (typeof content === 'string') { - ast = TypeUtils.createObfSourceFile(sourceFilePath, content); + ast = TypeUtils.createObfSourceFile(sourceFilePath, content, this.mCompilerOptions); } else { ast = content; } diff --git a/arkguard/src/common/ApiExtractor.ts b/arkguard/src/common/ApiExtractor.ts index b6450ea21241063c734459db5816777470391d1c..e286f7d418071481928c6cd0f9e247856189b18d 100644 --- a/arkguard/src/common/ApiExtractor.ts +++ b/arkguard/src/common/ApiExtractor.ts @@ -14,15 +14,20 @@ */ import type { + AnnotationDeclaration, ClassDeclaration, CommentRange, + CompilerOptions, + Decorator, ElementAccessExpression, EnumDeclaration, ExportDeclaration, + Expression, FunctionDeclaration, InterfaceDeclaration, ModifiersArray, ModuleDeclaration, + NamedDeclaration, Node, ParameterDeclaration, PropertyAccessExpression, @@ -37,6 +42,7 @@ import { ClassElement, forEachChild, getLeadingCommentRangesOfNode, + isAnnotationDeclaration, isBinaryExpression, isClassDeclaration, isClassExpression, @@ -76,7 +82,9 @@ import { isParameter, isTypeParameterDeclaration, isIndexedAccessTypeNode, - Extension + Extension, + isCallExpression, + isDecorator } from 'typescript'; import fs from 'fs'; @@ -99,8 +107,13 @@ import { scanProjectConfig } from './ApiReader'; import { enumPropsSet } from '../utils/OhsUtil'; import { FileUtils } from '../utils/FileUtils'; import { supportedParsingExtension } from './type'; -import { addToSet, FileWhiteList, KeepInfo, projectWhiteListManager } from '../utils/ProjectCollections'; -import { AtKeepCollections } from '../utils/CommonCollections'; +import { + addToSet, + DECORATOR_WHITE_LIST, + FileWhiteList, KeepInfo, + projectWhiteListManager +} from '../utils/ProjectCollections'; +import { AtKeepCollections, BytecodeObfuscationCollections, PropCollections } from '../utils/CommonCollections'; import { hasExportModifier } from '../utils/NodeUtils'; export namespace ApiExtractor { @@ -135,7 +148,8 @@ export namespace ApiExtractor { | FunctionDeclaration | ModuleDeclaration | VariableDeclaration - | TypeAliasDeclaration; + | TypeAliasDeclaration + | AnnotationDeclaration; const KEEP_SYMBOL = '//@KeepSymbol'; const KEEP_AS_CONSUMER = '//@KeepAsConsumer'; @@ -143,6 +157,8 @@ export namespace ApiExtractor { let mCurrentExportedPropertySet: Set = new Set(); let mCurrentExportNameSet: Set = new Set(); + let decoratorMap: Map> = new Map>(); + let keepSymbolTemp: KeepInfo = { propertyNames: new Set(), globalNames: new Set(), @@ -688,11 +704,18 @@ export namespace ApiExtractor { projectWhiteListManager?.setCurrentCollector(fileName); - const sourceFile: SourceFile = createSourceFile(fileName, fs.readFileSync(fileName).toString(), ScriptTarget.ES2015, true); + let sourceFile: SourceFile = createSourceFile(fileName, fs.readFileSync(fileName).toString(), ScriptTarget.ES2015, true, undefined, { + etsAnnotationsEnable: true + }, true); mCurrentExportedPropertySet.clear(); collectWhiteListByApiType(sourceFile, apiType, fileName); + // collect field decorated by UI + if (scanProjectConfig.scanDecorator) { + collectAndAddFieldDecorator(sourceFile); + } + // collect names marked with '// @KeepSymbol' or '// @KeepAsConsumer', only support .ts/.ets if (shouldCollectAtKeep(fileName)) { collectAndAddAtKeepNames(sourceFile); @@ -710,6 +733,7 @@ export namespace ApiExtractor { mCurrentExportedPropertySet.forEach(item => mPropertySet.add(item)); mCurrentExportedPropertySet.clear(); exportOriginalNameSet.clear(); + decoratorMap.clear(); }; function shouldCollectAtKeep(fileName: string): boolean { @@ -756,6 +780,59 @@ export namespace ApiExtractor { addToSet(fileWhiteLists.fileKeepInfo.keepAsConsumer.globalNames, keepAsConsumerTemp.globalNames); addToSet(fileWhiteLists.fileKeepInfo.keepAsConsumer.propertyNames, keepAsConsumerTemp.propertyNames); } + if (scanProjectConfig.scanDecorator) { + const convertedMap = new Map( + Array.from(decoratorMap.entries()).map(([key, value]) => [key, Array.from(value)])); + if (!fileWhiteLists.bytecodeObfuscateKeepInfo) { + fileWhiteLists.bytecodeObfuscateKeepInfo = {}; + } + fileWhiteLists.bytecodeObfuscateKeepInfo.decoratorMap = Object.fromEntries(convertedMap); + const allProp = Array.from(convertedMap.values()).flat(); + allProp.forEach(value => BytecodeObfuscationCollections.decoratorProp.add(value)); + } + } + + function collectAndAddFieldDecorator(sourceFile: SourceFile): void { + visitDecorator(sourceFile); + } + + function getDecorators(node: Node): Decorator[] { + const decorators: Decorator[] = []; + forEachChild(node, child => { + if (isDecorator(child)) { + decorators.push(child); + } + }); + return decorators; + } + + function visitDecorator(node: Node): void { + const decorators = getDecorators(node) || []; + const propertyName = (node as NamedDeclaration).name?.getText(); + if (!propertyName) { + forEachChild(node, visitDecorator); + return; + } + + decorators.forEach(decorator => { + const expr = decorator.expression; + const decoratorName = getDecoratorName(expr); + if (!decoratorName || !isWhiteListedDecorator(decoratorName)) { + return; + } + ensureEntry(decoratorMap, decoratorName, () => new Set()); + const decoratorSet = decoratorMap.get(decoratorName)!; + + if (isCallExpression(expr)) { + expr.arguments.forEach(arg => { + const stripped = arg.getText().replace(/^['"]|['"]$/g, '').split('.'); + stripped.forEach(item => decoratorSet.add(item)); + }); + } + decoratorSet.add(propertyName); + + }); + forEachChild(node, visitDecorator); } function collectWhiteListByApiType(sourceFile: SourceFile, apiType: ApiType, fileName: string): void { @@ -1125,6 +1202,9 @@ export namespace ApiExtractor { case SyntaxKind.ModuleDeclaration: collectModuleDeclaration(node as ModuleDeclaration, sourceFile); break; + case SyntaxKind.AnnotationDeclaration: + collectAnnotationDeclaration(node as AnnotationDeclaration, sourceFile); + break; } forEachChild(node, child => collectNamesWithAtKeep(child, sourceFile)); } @@ -1361,6 +1441,13 @@ export namespace ApiExtractor { } } + function collectAnnotationDeclaration(node: AnnotationDeclaration, sourceFile: SourceFile): void { + const atKeepType: AtKeepType = getAtKeepType(node, sourceFile); + const isToplevel: boolean = isSourceFile(node.parent); + const isExported: boolean = hasExportModifier(node); + collectToplevelOrExportedNames(node, isToplevel, isExported, atKeepType); + } + function getAtKeepType(node: Node, sourceFile: SourceFile): AtKeepType { const ranges: CommentRange[] | undefined = getLeadingCommentRangesOfNode(node, sourceFile); let atKeepType: AtKeepType = AtKeepType.None; @@ -1414,4 +1501,24 @@ export namespace ApiExtractor { collector.globalNames.add(name); } } -} + + function ensureEntry(map: Map, key: K, createValue: () => V): void { + if (!map.has(key)) { + map.set(key, createValue()); + } + } + + function isWhiteListedDecorator(name: string): boolean { + return DECORATOR_WHITE_LIST.includes(name); + } + + function getDecoratorName(expr: Expression): string | undefined { + if (isCallExpression(expr)) { + return expr.expression.getText(); + } + if (isIdentifier(expr)) { + return expr.text; + } + return undefined; + } +} \ No newline at end of file diff --git a/arkguard/src/common/ApiReader.ts b/arkguard/src/common/ApiReader.ts index aecec4c60026d8889e52d7c96644b0de3d6ac4a2..0504003668884fbe480ef5a4a2545b3b0edcb7e9 100644 --- a/arkguard/src/common/ApiReader.ts +++ b/arkguard/src/common/ApiReader.ts @@ -28,7 +28,8 @@ export interface ScanProjectConfig { mkeepFilesAndDependencies?: Set, isHarCompiled?: boolean, mStripSystemApiArgs?: boolean, - mEnableAtKeep: boolean + mEnableAtKeep: boolean, + scanDecorator?: boolean; } // Settings for collect white lists. @@ -71,13 +72,18 @@ export function isEnabledPropertyObfuscation(customProfiles: IOptions): boolean customProfiles.mNameObfuscation.mRenameProperties); } -function initScanProjectConfig(customProfiles: IOptions, isHarCompiled?: boolean): void { +export function initScanProjectConfig( + customProfiles: IOptions, + isHarCompiled?: boolean, + scanDecorator: boolean = false +): void { scanProjectConfig.mPropertyObfuscation = customProfiles.mNameObfuscation?.mRenameProperties; scanProjectConfig.mKeepStringProperty = customProfiles.mNameObfuscation?.mKeepStringProperty; scanProjectConfig.mExportObfuscation = customProfiles.mExportObfuscation; scanProjectConfig.mkeepFilesAndDependencies = customProfiles.mKeepFileSourceCode?.mkeepFilesAndDependencies; scanProjectConfig.isHarCompiled = isHarCompiled; scanProjectConfig.mEnableAtKeep = customProfiles.mNameObfuscation?.mEnableAtKeep; + scanProjectConfig.scanDecorator = scanDecorator; } /** @@ -109,7 +115,7 @@ export interface ReseverdSetForArkguard { * @param customProfiles */ export function readProjectPropertiesByCollectedPaths(filesForCompilation: Set, - customProfiles: IOptions, isHarCompiled: boolean): ReseverdSetForArkguard { + customProfiles: IOptions, isHarCompiled: boolean, scanDecorator: boolean = false): ReseverdSetForArkguard { const apiType = ApiExtractor.ApiType; let scanningCommonType = undefined; if (needReadApiInfo(customProfiles)) { @@ -118,7 +124,7 @@ export function readProjectPropertiesByCollectedPaths(filesForCompilation: Set 0) { resultStr += ObConfigResolver.KEEP_GLOBAL_NAME + '\n'; this.reservedGlobalNames.forEach((item) => { @@ -250,10 +272,19 @@ export class ObConfigResolver { this.handleReservedArray(mergedConfigs); endFilesEvent(EventList.RESOLVE_OBFUSCATION_CONFIGS); + /** + * Bytecode obfuscate mode: + * temporary variable or in non-top-level scope is obfuscated to be added to the obfuscate name set, + * All names that appear in the confused name collection will be obfuscated later + * So when a developer-defined name has the same name as systemApi + * Without a whitelist, all the same names would be obfuscated, leading to devastating errors + * so in order to work properly, Bytecode obfuscate enables the obfuscate function and requires whitelist + */ let needKeepSystemApi = enableObfuscation && (mergedConfigs.options.enablePropertyObfuscation || - (mergedConfigs.options.enableExportObfuscation && mergedConfigs.options.enableToplevelObfuscation)); + (mergedConfigs.options.enableExportObfuscation && mergedConfigs.options.enableToplevelObfuscation) || + mergedConfigs.options.bytecodeObf.enable); if (needKeepSystemApi && sourceObConfig.obfuscationCacheDir) { const systemApiCachePath: string = path.join(sourceObConfig.obfuscationCacheDir, 'systemApiCache.json'); @@ -270,8 +301,8 @@ export class ObConfigResolver { } } - // when atKeep is enabled, we can not emit here since we need to collect names marked with atKeep - if (!mergedConfigs.options.enableAtKeep) { + // when obfuscation is enabled, we need to emit consumerConfig files after collecting whitelist. + if (!enableObfuscation) { this.emitConsumerConfigFiles(); } return mergedConfigs; @@ -364,6 +395,11 @@ export class ObConfigResolver { static readonly PRINT_NAMECACHE = '-print-namecache'; static readonly PRINT_KEPT_NAMES = '-print-kept-names'; static readonly APPLY_NAMECACHE = '-apply-namecache'; + // obfuscation options for bytecode obfuscation + static readonly ENABLE_BYTECODE_OBFUSCATION = '-enable-bytecode-obfuscation'; + static readonly ENABLE_BYTECODE_OBFUSCATION_DEBUGGING = '-enable-bytecode-obfuscation-debugging'; + static readonly ENABLE_BYTECODE_OBFUSCATION_ENHANCED = '-enable-bytecode-obfuscation-enhanced'; + static readonly ENABLE_BYTECODE_OBFUSCATION_ARKUI = '-enable-bytecode-obfuscation-arkui'; static readonly EXTRA_OPTIONS = '-extra-options'; static readonly STRIP_LANGUAGE_DEFAULT = 'strip-language-default'; static readonly STRIP_SYSTEM_API_ARGS = 'strip-system-api-args'; @@ -380,6 +416,14 @@ export class ObConfigResolver { private getTokenType(token: string): OptionType { switch (token) { + case ObConfigResolver.ENABLE_BYTECODE_OBFUSCATION: + return OptionType.ENABLE_BYTECODE_OBFUSCATION; + case ObConfigResolver.ENABLE_BYTECODE_OBFUSCATION_DEBUGGING: + return OptionType.ENABLE_BYTECODE_OBFUSCATION_DEBUGGING; + case ObConfigResolver.ENABLE_BYTECODE_OBFUSCATION_ENHANCED: + return OptionType.ENABLE_BYTECODE_OBFUSCATION_ENHANCED; + case ObConfigResolver.ENABLE_BYTECODE_OBFUSCATION_ARKUI: + return OptionType.ENABLE_BYTECODE_OBFUSCATION_ARKUI; case ObConfigResolver.KEEP_DTS: return OptionType.KEEP_DTS; case ObConfigResolver.KEEP_GLOBAL_NAME: @@ -450,6 +494,26 @@ export class ObConfigResolver { tokenType = this.getTokenType(token); // handle switches cases switch (tokenType) { + case OptionType.ENABLE_BYTECODE_OBFUSCATION: { + configs.options.bytecodeObf.enable = true; + extraOptionType = OptionType.NONE; + continue; + } + case OptionType.ENABLE_BYTECODE_OBFUSCATION_DEBUGGING: { + configs.options.bytecodeObf.debugging = true; + extraOptionType = OptionType.NONE; + continue; + } + case OptionType.ENABLE_BYTECODE_OBFUSCATION_ENHANCED: { + configs.options.bytecodeObf.enhanced = true; + extraOptionType = OptionType.NONE; + continue; + } + case OptionType.ENABLE_BYTECODE_OBFUSCATION_ARKUI: { + configs.options.bytecodeObf.obfArkUI = true; + extraOptionType = OptionType.NONE; + continue; + } case OptionType.DISABLE_OBFUSCATION: { configs.options.disableObfuscation = true; extraOptionType = OptionType.NONE; @@ -719,7 +783,7 @@ export class ObConfigResolver { } const arkUIReservedPropertyNames: string[] = this.collectUIApiWhitelist(existPreDefineFilePath, existArkUIWhitelistPath, config); let systemApiContent: SystemApiContent = {}; - if (config.options.enablePropertyObfuscation) { + if (config.options.enablePropertyObfuscation || config.options.bytecodeObf?.enable) { if (!config.options.stripSystemApiArgs) { UnobfuscationCollections.reservedSdkApiForLocal = new Set(ApiExtractor.mPropertySet); systemApiContent.ReservedLocalNames = Array.from(ApiExtractor.mPropertySet); @@ -728,7 +792,8 @@ export class ObConfigResolver { UnobfuscationCollections.reservedSdkApiForProp = savedNameAndPropertySet; systemApiContent.ReservedPropertyNames = Array.from(savedNameAndPropertySet); } - if (config.options.enableToplevelObfuscation && config.options.enableExportObfuscation) { + if ((config.options.enableToplevelObfuscation && config.options.enableExportObfuscation) || + config.options.bytecodeObf?.enable) { const savedExportNamesSet = new Set(ApiExtractor.mSystemExportSet); UnobfuscationCollections.reservedSdkApiForGlobal = savedExportNamesSet; systemApiContent.ReservedGlobalNames = Array.from(savedExportNamesSet); @@ -879,6 +944,7 @@ export class ObConfigResolver { selfConsumerConfig.mergeAllRules(dependencyConfigs); } this.addKeepConsumer(selfConsumerConfig, AtKeepCollections.keepAsConsumer); + this.addIntentCollections(selfConsumerConfig, AtIntentCollections); selfConsumerConfig.sortAndDeduplicate(); this.writeConsumerConfigFile(selfConsumerConfig, sourceObConfig.exportRulePath); } @@ -892,6 +958,15 @@ export class ObConfigResolver { }); } + private addIntentCollections(selfConsumerConfig: MergedConfig, intentCollections: KeepInfo): void { + intentCollections.propertyNames.forEach((propertyName) => { + selfConsumerConfig.reservedPropertyNames.push(propertyName); + }); + intentCollections.globalNames.forEach((globalName) =>{ + selfConsumerConfig.reservedGlobalNames.push(globalName); + }); + } + public genConsumerConfigFilesForTest( sourceObConfig: SourceObConfig, selfConsumerConfig: MergedConfig, @@ -1211,6 +1286,11 @@ export function printWhitelist(obfuscationOptions: ObOptions, nameOptions: IName whitelistObj.conf.push(...atKeepSet); } + let atIndentSet: Set = new Set(); + addToSet(atIndentSet, AtIntentCollections.propertyNames); + addToSet(atIndentSet, AtIntentCollections.globalNames); + whitelistObj.conf.push(...atIndentSet); + let enumSet: Set; if (enableProperty) { enumSet = UnobfuscationCollections.reservedEnum; @@ -1316,7 +1396,8 @@ export function enableObfuscatedFilePathConfig(isPackageModules: boolean, projec } const disableObfuscation = hasObfuscationConfig.options.disableObfuscation; const enableFileNameObfuscation = hasObfuscationConfig.options.enableFileNameObfuscation; - if (disableObfuscation || !enableFileNameObfuscation) { + const enableBytecodeObfuscation = hasObfuscationConfig.options.bytecodeObf?.enable; + if (disableObfuscation || !enableFileNameObfuscation || enableBytecodeObfuscation) { return false; } return true; diff --git a/arkguard/src/initialization/Initializer.ts b/arkguard/src/initialization/Initializer.ts index f8eef2a751a17ad88d2627f24997d825c4f14b61..c0262eb890c69e2a7f803189362af4436709841d 100644 --- a/arkguard/src/initialization/Initializer.ts +++ b/arkguard/src/initialization/Initializer.ts @@ -20,7 +20,7 @@ import { ArkObfuscator, blockPrinter, renameIdentifierModule } from '../ArkObfus import { collectResevedFileNameInIDEConfig, MergedConfig, ObConfigResolver, readNameCache } from './ConfigResolver'; import { type IOptions } from '../configs/IOptions'; import type { HvigorErrorInfo } from '../common/type'; -import { getObfuscationCacheDir } from '../utils/PrinterTimeAndMemUtils'; +import { blockTimeAndMemPrinter, getObfuscationCacheDir } from '../utils/PrinterTimeAndMemUtils'; // Record all unobfuscated properties and reasons. export const historyUnobfuscatedPropMap: Map = new Map(); @@ -44,13 +44,6 @@ export const printerConfig = { mOutputPath: '', }; -export const printerTimeAndMemConfig = { - // A sub-switch of mTimeAndMemPrinter used to control the obfuscation performance printing of files - mFilesPrinter: false, - // A sub-switch of mTimeAndMemPrinter used to control the obfuscation performance printing of singlefile - mSingleFilePrinter: false, -}; - export const printerTimeAndMemDataConfig = { // The switch for printing obfuscation performance data and memory data mTimeAndMemPrinter: false, @@ -58,22 +51,27 @@ export const printerTimeAndMemDataConfig = { mMoreTimePrint: false, }; -// Initialize the configuration of the TimeAndMem performance printer -export function initPrinterTimeAndMemConfig() { - printerTimeAndMemConfig.mFilesPrinter = true; - printerTimeAndMemConfig.mSingleFilePrinter = true; - printerTimeAndMemDataConfig.mTimeAndMemPrinter = true; -} export function initObfuscationConfig(projectConfig: any, arkProjectConfig: any, printObfLogger: Function): void { const obConfig: ObConfigResolver = new ObConfigResolver(projectConfig, printObfLogger, true); - const mergedObConfig: MergedConfig = obConfig.resolveObfuscationConfigs(); + let mergedObConfig: MergedConfig = obConfig.resolveObfuscationConfigs(); + if (arkProjectConfig.allowEtsAnnotations) { + mergedObConfig.options.enableEtsAnnotation = arkProjectConfig.allowEtsAnnotations; + } const isHarCompiled: boolean = projectConfig.compileHar; - getObfuscationCacheDir(projectConfig); if (mergedObConfig.options.disableObfuscation) { blockPrinter(); + blockTimeAndMemPrinter(); return; } + getObfuscationCacheDir(projectConfig); + /** + * Only one of bytecode obfuscation and source code obfuscation will take effect. + * Enabling bytecode obfuscation is to obfuscate declaration files when compile bytecode har. + */ + const isBytecodeObfEnabled = mergedObConfig.options.bytecodeObf.enable; + arkProjectConfig.isBytecodeObfEnabled = isBytecodeObfEnabled; + arkProjectConfig.isArkguardEnabled = !isBytecodeObfEnabled; if (mergedObConfig.options.enableFileNameObfuscation) { const ohPackagePath = path.join(projectConfig.modulePath, 'oh-package.json5'); @@ -139,12 +137,12 @@ function initArkGuardConfig( }, mExportObfuscation: mergedObConfig.options.enableExportObfuscation, mPerformancePrinter: printerConfig, - mPerformanceTimeAndMemPrinter: printerTimeAndMemConfig, mKeepFileSourceCode: { mKeepSourceOfPaths: new Set(), mkeepFilesAndDependencies: new Set(), }, - mStripLanguageDefaultWhitelist: mergedObConfig.options.stripLanguageDefault + mStripLanguageDefaultWhitelist: mergedObConfig.options.stripLanguageDefault, + mAllowEtsAnnotations: mergedObConfig.options.enableEtsAnnotation, }; const arkObfuscator: ArkObfuscator = new ArkObfuscator(); diff --git a/arkguard/src/transformers/rename/RenameFileNameTransformer.ts b/arkguard/src/transformers/rename/RenameFileNameTransformer.ts index bab1c891c39391796433797c265b35099bd697a5..eab7543b3bf46ba08ed1c21bbbea4029c656cc33 100644 --- a/arkguard/src/transformers/rename/RenameFileNameTransformer.ts +++ b/arkguard/src/transformers/rename/RenameFileNameTransformer.ts @@ -101,7 +101,6 @@ namespace secharmony { const tempReservedName: string[] = ['.', '..', '']; configReservedFileNameOrPath.map(fileNameOrPath => { if (!fileNameOrPath || fileNameOrPath.length === 0) { - endFilesEvent(EventList.FILENAME_OBFUSCATION_INITIALIZATION); return; } const directories = FileUtils.splitFilePath(fileNameOrPath); diff --git a/arkguard/src/transformers/rename/RenameIdentifierTransformer.ts b/arkguard/src/transformers/rename/RenameIdentifierTransformer.ts index 53c45994d4253f398d5a66e9d02ee7b4eea498bf..f27fda5560042823bb4614265749b3884e25553c 100644 --- a/arkguard/src/transformers/rename/RenameIdentifierTransformer.ts +++ b/arkguard/src/transformers/rename/RenameIdentifierTransformer.ts @@ -39,7 +39,8 @@ import { isPropertyAssignment, isPrivateIdentifier, isParameter, - isPropertyAccessExpression + isPropertyAccessExpression, + isAnnotationDeclaration } from 'typescript'; import type { @@ -84,7 +85,7 @@ import type {INameGenerator, NameGeneratorOptions} from '../../generator/INameGe import type {IOptions} from '../../configs/IOptions'; import type { INameObfuscationOption, IUnobfuscationOption } from '../../configs/INameObfuscationOption'; import type {TransformPlugin} from '../TransformPlugin'; -import type { MangledSymbolInfo } from '../../common/type'; +import { annotationPrefix, type MangledSymbolInfo } from '../../common/type'; import {TransformerOrder} from '../TransformPlugin'; import {getNameGenerator, NameGeneratorType} from '../../generator/NameFactory'; import {TypeUtils} from '../../utils/TypeUtils'; @@ -99,12 +100,14 @@ import { } from '../../utils/TransformUtil'; import {NodeUtils} from '../../utils/NodeUtils'; import {ApiExtractor} from '../../common/ApiExtractor'; -import {performancePrinter, ArkObfuscator, cleanFileMangledNames} from '../../ArkObfuscator'; +import {performancePrinter, ArkObfuscator, cleanFileMangledNames, FileUtils} from '../../ArkObfuscator'; import { endSingleFileEvent, startSingleFileEvent } from '../../utils/PrinterUtils'; import { EventList, endSingleFileForMoreTimeEvent, startSingleFileForMoreTimeEvent } from '../../utils/PrinterTimeAndMemUtils'; import { isViewPUBasedClass } from '../../utils/OhsUtil'; import { + AtIntentCollections, AtKeepCollections, + BytecodeObfuscationCollections, LocalVariableCollections, PropCollections, UnobfuscationCollections @@ -153,6 +156,7 @@ namespace secharmony { let mangledLabelNames: Map = new Map(); let fileExportNames: Set = undefined; let fileImportNames: Set = undefined; + let currentFileType: string | undefined = undefined; exportElementsWithoutSymbol.clear(); exportSymbolAliasMap.clear(); nodeSymbolMap.clear(); @@ -181,6 +185,7 @@ namespace secharmony { if (!isSourceFile(node) || ArkObfuscator.isKeptCurrentFile) { return node; } + currentFileType = FileUtils.getFileSuffix(node.fileName).ext; isCurFileParamertersKept = shouldKeepCurFileParamerters(node, profile); const checkRecordInfo = ArkObfuscator.recordStage(MemoryDottingDefine.CREATE_CHECKER); @@ -191,7 +196,7 @@ namespace secharmony { const scopeRecordInfo = ArkObfuscator.recordStage(MemoryDottingDefine.SCOPE_ANALYZE); startSingleFileEvent(EventList.SCOPE_ANALYZE, performancePrinter.timeSumPrinter); - manager.analyze(node, checker, exportObfuscation); + manager.analyze(node, checker, exportObfuscation, currentFileType); endSingleFileEvent(EventList.SCOPE_ANALYZE, performancePrinter.timeSumPrinter); ArkObfuscator.stopRecordStage(scopeRecordInfo); @@ -312,11 +317,10 @@ namespace secharmony { recordHistoryUnobfuscatedNames(path); // For incremental build mangled = historyName; } else if (Reflect.has(def, 'obfuscateAsProperty')) { - // obfuscate toplevel, export - mangled = getPropertyMangledName(original, path); + mangled = getPropertyOrAnnotationMangledName(original, path); } else { // obfuscate local variable - mangled = getMangled(scope, generator); + mangled = getMangledLocalName(scope, generator); } // add new names to name cache let identifierCache = nameCache?.get(IDENTIFIER_CACHE); @@ -381,11 +385,7 @@ namespace secharmony { return mangledName; } - function getPropertyMangledName(original: string, nameWithScope: string): string { - if (isInTopLevelWhitelist(original, UnobfuscationCollections.unobfuscatedNamesMap, nameWithScope, enablePropertyObf, shouldPrintKeptNames)) { - return original; - } - + function getMangledName(original: string): string { const historyName: string = PropCollections.historyMangledTable?.get(original); let mangledName: string = historyName ? historyName : PropCollections.globalMangledTable.get(original); while (!mangledName) { @@ -442,6 +442,35 @@ namespace secharmony { return mangledName; } + function getPropertyMangledName(originalName: string, nameWithScope: string): string { + if (isInTopLevelWhitelist(originalName, UnobfuscationCollections.unobfuscatedNamesMap, nameWithScope, enablePropertyObf, shouldPrintKeptNames)) { + return originalName; + } + + let mangledName = getMangledName(originalName); + return mangledName; + } + + // mangle annotation name in intermediate files + function getAnnotationMangledNameWithPrefix(originalName: string, nameWithScope: string): string { + if (isInTopLevelWhitelist(originalName, UnobfuscationCollections.unobfuscatedNamesMap, nameWithScope, enablePropertyObf, shouldPrintKeptNames)) { + return `${annotationPrefix}${originalName}`; + } + let mangledName: string = `${annotationPrefix}${getMangledName(originalName)}`; + return mangledName; + } + + function getPropertyOrAnnotationMangledName(originalName: string, nameWithScope: string): string { + let name: string | undefined = originalName.startsWith(annotationPrefix) ? originalName.substring(annotationPrefix.length) : undefined; + if (name) { + // obfuscate annotation name with prefix, e.g. in intermediate files + return getAnnotationMangledNameWithPrefix(name, nameWithScope); + } else { + // obfuscate toplevel, export + return getPropertyMangledName(originalName, nameWithScope); + } + } + function isExcludeScope(scope: Scope): boolean { if (isClassScope(scope)) { return true; @@ -473,7 +502,7 @@ namespace secharmony { return found; } - function getMangled(scope: Scope, localGenerator: INameGenerator): string { + function getMangledLocalName(scope: Scope, localGenerator: INameGenerator): string { let mangled: string = ''; do { mangled = localGenerator.getName()!; @@ -846,9 +875,9 @@ namespace secharmony { tmpReservedProps.forEach(item => { PropCollections.reservedProperties.add(item); }); - PropCollections.globalMangledNamesInCache = new Set(PropCollections.historyMangledTable?.values()); addToSet(PropCollections.reservedProperties, AtKeepCollections.keepSymbol.propertyNames); addToSet(PropCollections.reservedProperties, AtKeepCollections.keepAsConsumer.propertyNames); + addToSet(PropCollections.reservedProperties, AtIntentCollections.propertyNames); if (profile?.mUniversalReservedProperties) { PropCollections.universalReservedProperties = [...profile.mUniversalReservedProperties]; @@ -863,10 +892,13 @@ namespace secharmony { UnobfuscationCollections.reservedSdkApiForProp.add(element); }); } + PropCollections.globalMangledNamesInCache = new Set(PropCollections.historyMangledTable?.values()); LocalVariableCollections.reservedConfig = new Set(profile?.mReservedNames ?? []); profile?.mReservedToplevelNames?.forEach(item => PropCollections.reservedProperties.add(item)); addToSet(PropCollections.reservedProperties, AtKeepCollections.keepSymbol.globalNames); addToSet(PropCollections.reservedProperties, AtKeepCollections.keepAsConsumer.globalNames); + addToSet(PropCollections.reservedProperties, AtIntentCollections.globalNames); + addToSet(UnobfuscationCollections.reservedSdkApiForProp, BytecodeObfuscationCollections.decoratorProp); profile?.mUniversalReservedToplevelNames?.forEach(item => PropCollections.universalReservedProperties.push(item)); isInitializedReservedList = true; } diff --git a/arkguard/src/transformers/rename/RenamePropertiesTransformer.ts b/arkguard/src/transformers/rename/RenamePropertiesTransformer.ts index d181c6f0ea1bf8733a75fe3e24f1bc26e9d90840..89fa6abb42b1ef9e7a04206c0f65fb65cf7c30e3 100644 --- a/arkguard/src/transformers/rename/RenamePropertiesTransformer.ts +++ b/arkguard/src/transformers/rename/RenamePropertiesTransformer.ts @@ -47,6 +47,7 @@ import type { TypeNode } from 'typescript'; +import { annotationPrefix } from '../../common/type'; import type {IOptions} from '../../configs/IOptions'; import type { INameObfuscationOption } from '../../configs/INameObfuscationOption'; import type {TransformPlugin} from '../TransformPlugin'; @@ -65,6 +66,7 @@ import { globalGenerator, nameCache } from './RenameIdentifierTransformer'; +import { FileUtils } from '../../ArkObfuscator'; import { UpdateMemberMethodName } from '../../utils/NameCacheUtil'; import { PropCollections, UnobfuscationCollections } from '../../utils/CommonCollections'; import { MemoryDottingDefine } from '../../utils/MemoryDottingDefine'; @@ -86,14 +88,14 @@ namespace secharmony { return renamePropertiesFactory; function renamePropertiesFactory(context: TransformationContext): Transformer { - + let currentFileType: string | undefined = undefined; return renamePropertiesTransformer; function renamePropertiesTransformer(node: Node): Node { if (isSourceFile(node) && ArkObfuscator.isKeptCurrentFile) { return node; } - + currentFileType = isSourceFile(node) ? FileUtils.getFileSuffix(node.fileName).ext : undefined; const recordInfo = ArkObfuscator.recordStage(MemoryDottingDefine.PROPERTY_OBFUSCATION); startSingleFileEvent(EventList.PROPERTY_OBFUSCATION, performancePrinter.timeSumPrinter); @@ -115,6 +117,10 @@ namespace secharmony { } function renameProperties(node: Node): Node { + if (NodeUtils.isObjectLiteralInAnnotation(node, currentFileType)) { + return node; + } + if (!NodeUtils.isPropertyNode(node)) { return visitEachChild(node, renameProperties, context); } @@ -204,7 +210,13 @@ namespace secharmony { return node; } - let mangledName: string = getPropertyName(original); + let mangledName: string = original; + let name: string | undefined = original.startsWith(annotationPrefix) ? original.substring(annotationPrefix.length) : undefined; + if (name) { + mangledName = getAnnotationMangledNameWithPrefix(name); + } else { + mangledName = getPropertyMangledName(original); + } if (isStringLiteralLike(node)) { return factory.createStringLiteral(mangledName); @@ -233,7 +245,17 @@ namespace secharmony { return factory.createPrivateIdentifier('#' + mangledName); } - function getPropertyName(original: string): string { + function getPropertyMangledName(original: string): string { + let mangledName: string = getMangledName(original); + return mangledName; + } + + function getAnnotationMangledNameWithPrefix(original: string): string { + let mangledName: string = `${annotationPrefix}${getMangledName(original)}`; + return mangledName; + } + + function getMangledName(original: string): string { const historyName: string = PropCollections.historyMangledTable?.get(original); let mangledName: string = historyName ? historyName : PropCollections.globalMangledTable.get(original); while (!mangledName) { diff --git a/arkguard/src/utils/CommonCollections.ts b/arkguard/src/utils/CommonCollections.ts index 1db093f1eb3792385b1b8f8d3ee23e43cc2d5746..aa31e00fd0afd2bdd208b208f11b5a28c063c788 100644 --- a/arkguard/src/utils/CommonCollections.ts +++ b/arkguard/src/utils/CommonCollections.ts @@ -104,4 +104,22 @@ export namespace AtKeepCollections { keepAsConsumer.globalNames.clear(); keepAsConsumer.propertyNames.clear(); }; +} + +export namespace AtIntentCollections{ + export let propertyNames: Set = new Set(); + export let globalNames: Set = new Set(); + + export function clear(): void{ + propertyNames.clear(); + globalNames.clear(); + } +} + +export namespace BytecodeObfuscationCollections { + export let decoratorProp: Set = new Set(); + + export function clear(): void { + decoratorProp.clear(); + } } \ No newline at end of file diff --git a/arkguard/src/utils/NodeUtils.ts b/arkguard/src/utils/NodeUtils.ts index 08acca40723273c72bc7d30130cfa613ff73733e..c4701cc0af97cc4d0ffaca03deb8bfc42884ce1f 100644 --- a/arkguard/src/utils/NodeUtils.ts +++ b/arkguard/src/utils/NodeUtils.ts @@ -13,6 +13,7 @@ * limitations under the License. */ +import { FileUtils } from './FileUtils'; import type { Expression, Identifier, @@ -24,7 +25,8 @@ import type { TransformerFactory, StringLiteralLike, NumericLiteral, - PrivateIdentifier + PrivateIdentifier, + PropertyAccessExpression, } from 'typescript'; import { canHaveModifiers, @@ -38,6 +40,7 @@ import { isClassExpression, isComputedPropertyName, isConstructorDeclaration, + isDecoratorOrAnnotation, isElementAccessExpression, isEnumMember, isGetAccessor, @@ -59,7 +62,8 @@ import { isVariableDeclaration, visitEachChild, isLiteralTypeNode, - isStringLiteralLike + isStringLiteralLike, + isObjectLiteralExpression } from 'typescript'; import { getViewPUClassProperties, @@ -67,7 +71,7 @@ import { isViewPUBasedClass, visitEnumInitializer } from './OhsUtil'; -import { Extension } from '../common/type'; +import { annotationPrefix, Extension } from '../common/type'; import { MergedConfig } from '../initialization/ConfigResolver'; export class NodeUtils { @@ -253,6 +257,36 @@ export class NodeUtils { return initializer && isCallExpression(initializer); } + public static isObjectLiteralInAnnotation(node: Node, currentFileType: string): boolean { + if (!node || !node.parent || !isObjectLiteralExpression(node) || !isCallExpression(node.parent) || !isDecoratorOrAnnotation(node.parent.parent)) { + return false; + } + if (currentFileType === Extension.DETS) { + return true; + } + const expr = node.parent.expression; + let name: string | undefined = undefined; + switch (expr.kind) { + case SyntaxKind.Identifier: + // @Anno({a: 0}), get 'Anno' + name = (expr as Identifier).text; + break; + case SyntaxKind.PropertyAccessExpression: + // @ns.Anno({a: 0}), get 'Anno' + name = (expr as PropertyAccessExpression).name.text; + break; + default: + name = undefined; + } + if (!name) { + return false; + } + if (currentFileType === Extension.TS && name.startsWith(annotationPrefix)) { + return true; + } + return false; + } + public static isDeclarationFile(node: SourceFile): boolean { return node.isDeclarationFile; } diff --git a/arkguard/src/utils/PrinterTimeAndMemUtils.ts b/arkguard/src/utils/PrinterTimeAndMemUtils.ts index 3d5b31c78f4a591fadbde2fd3d4ed7c4940f96cf..24c03c900b88066839d1174cee987d4f8bb22e07 100644 --- a/arkguard/src/utils/PrinterTimeAndMemUtils.ts +++ b/arkguard/src/utils/PrinterTimeAndMemUtils.ts @@ -17,9 +17,16 @@ import * as fs from 'fs'; import path from 'path'; import type { IOptions } from '../configs/IOptions'; import type { IPrinterOption } from '../configs/INameObfuscationOption'; +import { performance } from 'perf_hooks'; import { performanceTimeAndMemPrinter } from '../ArkObfuscator'; import { printerTimeAndMemDataConfig } from '../initialization/Initializer'; +// DevEco Studio perf mode +export enum PerfMode { + NORMAL = 0, // Normal mode + ADVANCED = 1, // Advanced mode +}; + export enum EventList { OBFUSCATION_INITIALIZATION = 'Obfuscation initialization', SCAN_SYSTEMAPI = 'Scan system api', @@ -111,7 +118,7 @@ const MEMORY_PERFORMANCE_FILE_NAME = 'memoryPerformanceData.json'; // Memory per export const eventListTimeAndMemValues = new Set(Object.values(EventList)); export class TimeAndMemTimeTracker { - static obfuscationCacheDir: string = ''; // Obtain the directory of the obfuscated output file + static obfuscationCacheDir: string | undefined = ''; // Obtain the directory of the obfuscated output file private eventStack: Array<{ eventName: string; data: TimeAndMemInfo }> = []; timeDataArr: TimeInfo[] = []; memoryDataArr: MemInfo[] = []; @@ -194,21 +201,28 @@ export class TimeAndMemTimeTracker { /** * Initialize performance printer */ -export function initPerformanceTimeAndMemPrinter(mCustomProfiles: IOptions): void { - const printerConfig: IPrinterOption | undefined = mCustomProfiles.mPerformanceTimeAndMemPrinter; - - // If no performance printer configuration is provided, disable the printer and return. - if (!printerConfig) { +export function initPerformanceTimeAndMemPrinter(): void { + if (!printerTimeAndMemDataConfig.mTimeAndMemPrinter) { blockTimeAndMemPrinter(); - return; } +} - // Disable performance printer if no specific printer types (files, single file) are enabled. - const isPrinterDisabled = !(printerConfig.mFilesPrinter || printerConfig.mSingleFilePrinter); +/** + * Configures the performance printer based on the specified performance mode + */ +export function configurePerformancePrinter(perf: number): void { + if (perf === PerfMode.ADVANCED) { + initPrinterTimeAndMemConfig(); - if (isPrinterDisabled) { + // If singleFilePrinter and filesPrinter do not exist, create the corresponding instance + if (!performanceTimeAndMemPrinter.singleFilePrinter) { + performanceTimeAndMemPrinter.singleFilePrinter = new TimeAndMemTimeTracker(); + } + if (!performanceTimeAndMemPrinter.filesPrinter) { + performanceTimeAndMemPrinter.filesPrinter = new TimeAndMemTimeTracker(); + } + } else { blockTimeAndMemPrinter(); - return; } } @@ -216,6 +230,7 @@ export function initPerformanceTimeAndMemPrinter(mCustomProfiles: IOptions): voi * Disable performance printer */ export function blockTimeAndMemPrinter(): void { + disablePrinterTimeAndMemConfig(); performanceTimeAndMemPrinter.filesPrinter = undefined; performanceTimeAndMemPrinter.singleFilePrinter = undefined; } @@ -234,6 +249,20 @@ export function clearTimeAndMemPrinterData(): void { } } +/** + * Initialize the configuration of the TimeAndMem performance printer + */ +export function initPrinterTimeAndMemConfig(): void { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = true; +} + +/** + * Disable the configuration of the TimeAndMem performance printer + */ +export function disablePrinterTimeAndMemConfig(): void { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = false; +} + /** * Start recording singleFileForMoreTimePrinter event */ @@ -287,11 +316,13 @@ export function printMemoryPerformanceData(): void { * Write data of timeAndMemoryPerformance */ export async function writeTimeAndMemoryPerformanceData(data: (TimeInfo | MemInfo)[], fileName: string): Promise { - const filePath: string = path.join(TimeAndMemTimeTracker.obfuscationCacheDir, fileName); - try { - await fs.promises.writeFile(filePath, JSON.stringify(data, null, INDENTATION_SPACES)); - } catch (error) { - throw new Error('Failed to write file: ' + error.message.toString()); + if (TimeAndMemTimeTracker.obfuscationCacheDir) { + const filePath: string = path.join(TimeAndMemTimeTracker.obfuscationCacheDir, fileName); + try { + await fs.promises.writeFile(filePath, JSON.stringify(data, null, INDENTATION_SPACES)); + } catch (error) { + throw new Error('Failed to write file: ' + error.message.toString()); + } } } diff --git a/arkguard/src/utils/ProjectCollections.ts b/arkguard/src/utils/ProjectCollections.ts index 62071f3388fce53a2fd6f62182ab0d4b2d325e5e..e218b8b2479665158c740d695dc091893e79276e 100644 --- a/arkguard/src/utils/ProjectCollections.ts +++ b/arkguard/src/utils/ProjectCollections.ts @@ -15,7 +15,12 @@ import { ApiExtractor } from '../common/ApiExtractor'; import { FileUtils } from './FileUtils'; -import { AtKeepCollections, UnobfuscationCollections } from './CommonCollections'; +import { + AtIntentCollections, + AtKeepCollections, + BytecodeObfuscationCollections, + UnobfuscationCollections +} from './CommonCollections'; import * as crypto from 'crypto'; import * as ts from 'typescript'; import fs from 'fs'; @@ -51,6 +56,14 @@ export const FILE_NAMES_MAP: string = 'transformedFileNamesMap.json'; export const FILE_WHITE_LISTS: string = 'fileWhiteLists.json'; export const PROJECT_WHITE_LIST: string = 'projectWhiteList.json'; +// this while list is only used for bytecode obfuscation +export const DECORATOR_WHITE_LIST = [ + 'Monitor', + 'Track', + 'Trace', + 'AnimatableExtend' +]; + export interface KeepInfo { propertyNames: Set; globalNames: Set; @@ -111,6 +124,11 @@ export interface FileContent { * │ │ └── globalNames: Set * │ ├── enumProperties: Set * │ └── stringProperties: Set + * │ └── arkUIKeepInfo: KeepInfo + * │ ├── propertyNames: Set + * │ └── globalNames: Set + * └── bytecodeObfuscateKeepInfo: BytecodeObfuscateKeepInfo + * └── decoratorMap?: Map * └── fileReservedInfo: FileReservedInfo * ├── enumProperties: Set * └── propertyParams: Set @@ -122,6 +140,7 @@ export interface FileKeepInfo { exported: KeepInfo; // Exported names and properties. enumProperties: Set; // Enum properties. stringProperties: Set; // String properties. + arkUIKeepInfo?: KeepInfo; // Collecting classes and members } export interface FileReservedInfo { @@ -129,9 +148,14 @@ export interface FileReservedInfo { propertyParams: Set; // Properties parameters in constructor. } +export interface BytecodeObfuscateKeepInfo { + decoratorMap?: Object; // collect DecoratorMap +} + export interface FileWhiteList { fileKeepInfo: FileKeepInfo; fileReservedInfo: FileReservedInfo; + bytecodeObfuscateKeepInfo?: BytecodeObfuscateKeepInfo } export interface ProjectKeepInfo { @@ -241,6 +265,10 @@ export class ProjectWhiteListManager { }, enumProperties: new Set(), stringProperties: new Set(), + arkUIKeepInfo: { + propertyNames: new Set(), + globalNames: new Set(), + }, }; } @@ -311,14 +339,22 @@ export class ProjectWhiteListManager { }, enumProperties: arrayToSet(parsed[key].fileKeepInfo.enumProperties), stringProperties: arrayToSet(parsed[key].fileKeepInfo.stringProperties), + arkUIKeepInfo: parsed[key].fileKeepInfo.arkUIKeepInfo + ? { + propertyNames: arrayToSet(parsed[key].fileKeepInfo.arkUIKeepInfo.propertyNames), + globalNames: arrayToSet(parsed[key].fileKeepInfo.arkUIKeepInfo.globalNames), + } + : undefined, }; const fileReservedInfo: FileReservedInfo = { enumProperties: arrayToSet(parsed[key].fileReservedInfo.enumProperties), propertyParams: arrayToSet(parsed[key].fileReservedInfo.propertyParams), }; - - map.set(key, { fileKeepInfo, fileReservedInfo }); + const bytecodeObfuscateKeepInfo: BytecodeObfuscateKeepInfo = { + decoratorMap: parsed[key].bytecodeObfuscateKeepInfo?.decoratorMap, + }; + map.set(key, { fileKeepInfo, fileReservedInfo, bytecodeObfuscateKeepInfo }); } } @@ -349,12 +385,23 @@ export class ProjectWhiteListManager { }, enumProperties: setToArray(value.fileKeepInfo.enumProperties), stringProperties: setToArray(value.fileKeepInfo.stringProperties), + arkUIKeepInfo: value.fileKeepInfo.arkUIKeepInfo + ? { + propertyNames: setToArray(value.fileKeepInfo.arkUIKeepInfo.propertyNames), + globalNames: setToArray(value.fileKeepInfo.arkUIKeepInfo.globalNames), + } + : undefined, }, fileReservedInfo: { enumProperties: setToArray(value.fileReservedInfo.enumProperties), propertyParams: setToArray(value.fileReservedInfo.propertyParams), }, }; + if (value.bytecodeObfuscateKeepInfo?.decoratorMap) { + jsonData[key].bytecodeObfuscateKeepInfo = { + decoratorMap: value.bytecodeObfuscateKeepInfo.decoratorMap, + }; + } } const jsonString = JSON.stringify(jsonData, null, 2); @@ -462,6 +509,16 @@ export class ProjectWhiteListManager { projectKeepInfo.propertyNames.add(propertyName); }); + // Collect arkUIKeepInfo + fileWhiteList.fileKeepInfo.arkUIKeepInfo?.globalNames.forEach((globalName) => { + projectKeepInfo.globalNames.add(globalName); + AtIntentCollections.globalNames.add(globalName); + }); + fileWhiteList.fileKeepInfo.arkUIKeepInfo?.propertyNames.forEach((propertyName) => { + projectKeepInfo.propertyNames.add(propertyName); + AtIntentCollections.propertyNames.add(propertyName); + }); + // 2. Collect fileReservedInfo // Collect enumProperties fileWhiteList.fileReservedInfo.enumProperties.forEach((enumPropertyName) => { @@ -472,6 +529,13 @@ export class ProjectWhiteListManager { fileWhiteList.fileReservedInfo.propertyParams.forEach((propertyParam) => { projectReservedInfo.propertyParams.add(propertyParam); }); + + const decoratorMap = fileWhiteList.bytecodeObfuscateKeepInfo?.decoratorMap; + for (const key in decoratorMap) { + if (Object.prototype.hasOwnProperty.call(decoratorMap, key)) { + decoratorMap[key]?.forEach(item => projectKeepInfo.globalNames.add(item)); + } + } }); const projectWhiteList = { @@ -515,8 +579,18 @@ export class ProjectWhiteListManager { addToSet(UnobfuscationCollections.reservedExportName, fileWhiteList.fileKeepInfo.exported.globalNames); addToSet(UnobfuscationCollections.reservedExportNameAndProp, fileWhiteList.fileKeepInfo.exported.propertyNames); addToSet(UnobfuscationCollections.reservedStrProp, fileWhiteList.fileKeepInfo.stringProperties); + if (fileWhiteList.fileKeepInfo.arkUIKeepInfo) { + addToSet(AtIntentCollections.propertyNames, fileWhiteList.fileKeepInfo.arkUIKeepInfo.propertyNames); + addToSet(AtIntentCollections.globalNames, fileWhiteList.fileKeepInfo.arkUIKeepInfo.globalNames); + } addToSet(ApiExtractor.mConstructorPropertySet, fileWhiteList.fileReservedInfo.propertyParams); addToSet(ApiExtractor.mEnumMemberSet, fileWhiteList.fileReservedInfo.enumProperties); + const decoratorMap = fileWhiteList.bytecodeObfuscateKeepInfo?.decoratorMap; + for (const key in decoratorMap) { + if (Object.prototype.hasOwnProperty.call(decoratorMap, key)) { + decoratorMap[key]?.forEach(item => BytecodeObfuscationCollections.decoratorProp.add(item)); + } + } }); } diff --git a/arkguard/src/utils/ScopeAnalyzer.ts b/arkguard/src/utils/ScopeAnalyzer.ts index a2f2466039ad5876ee673773b7a1145aa56bc06f..620758608f87e88d7c2cf074edc82cbc31f42361 100644 --- a/arkguard/src/utils/ScopeAnalyzer.ts +++ b/arkguard/src/utils/ScopeAnalyzer.ts @@ -17,6 +17,7 @@ import { forEachChild, getModifiers, getOriginalNode, + isAnnotationPropertyDeclaration, isCatchClause, isClassDeclaration, isConstructorDeclaration, @@ -40,6 +41,7 @@ import { } from 'typescript'; import type { + AnnotationDeclaration, BreakOrContinueStatement, CaseBlock, CatchClause, @@ -70,7 +72,7 @@ import type { TypeElement } from 'typescript'; -import { NodeUtils } from './NodeUtils'; +import { hasExportModifier, NodeUtils } from './NodeUtils'; import { isParameterPropertyModifier, isViewPUBasedClass } from './OhsUtil'; import { TypeUtils } from './TypeUtils'; import { endSingleFileEvent, startSingleFileEvent } from '../utils/PrinterUtils'; @@ -284,7 +286,7 @@ namespace secharmony { * @param ast ast tree of a source file * @param checker */ - analyze(ast: SourceFile, checker: TypeChecker, isEnabledExportObfuscation: boolean): void; + analyze(ast: SourceFile, checker: TypeChecker, isEnabledExportObfuscation: boolean, currentFileType: string): void; /** * get root scope of a file @@ -307,6 +309,7 @@ namespace secharmony { let checker: TypeChecker = null; let upperLabel: Label | undefined = undefined; let exportObfuscation: boolean = false; + let fileType: string | undefined = undefined; return { getReservedNames, @@ -315,9 +318,10 @@ namespace secharmony { getScopeOfNode, }; - function analyze(ast: SourceFile, typeChecker: TypeChecker, isEnabledExportObfuscation = false): void { + function analyze(ast: SourceFile, typeChecker: TypeChecker, isEnabledExportObfuscation = false, currentFileType: string): void { checker = typeChecker; exportObfuscation = isEnabledExportObfuscation; + fileType = currentFileType; analyzeScope(ast); } @@ -445,7 +449,10 @@ namespace secharmony { break; case SyntaxKind.Identifier: - analyzeSymbol(node as Identifier); + // skip property in annotationDeclaration + if (!isAnnotationPropertyDeclaration(node.parent)) { + analyzeSymbol(node as Identifier); + } break; case SyntaxKind.TypeAliasDeclaration: @@ -469,7 +476,11 @@ namespace secharmony { break; case SyntaxKind.ObjectLiteralExpression: - analyzeObjectLiteralExpression(node as ObjectLiteralExpression); + // skip prop in annotation, e.g. @Anno({a: 0}) + // here, `a` will not be collected + if (!NodeUtils.isObjectLiteralInAnnotation(node as ObjectLiteralExpression, fileType)) { + analyzeObjectLiteralExpression(node as ObjectLiteralExpression); + } break; case SyntaxKind.ExportSpecifier: @@ -488,6 +499,11 @@ namespace secharmony { analyzeImportEqualsDeclaration(node as ImportEqualsDeclaration); break; + // add symbol of annotationDeclaration into global scope + case SyntaxKind.AnnotationDeclaration: + analyzeAnnotationDeclaration(node as AnnotationDeclaration); + break; + default: forEachChild(node, analyzeScope); break; @@ -1060,6 +1076,18 @@ namespace secharmony { forEachChild(node, analyzeScope); } + function analyzeAnnotationDeclaration(node: AnnotationDeclaration): void { + if (hasExportModifier(node)) { + current.exportNames.add(node.name.text); + root.fileExportNames.add(node.name.text); + } + let sym: Symbol | undefined = getAndRecordSymbolOfIdentifier(checker, node.name); + if (sym) { + current.addDefinition(sym, true); + } + forEachChild(node, analyzeScope); + } + function tryAddNoSymbolIdentifiers(node: Identifier): void { if (!isIdentifier(node)) { return; diff --git a/arkguard/src/utils/SourceMapMergingUtil.ts b/arkguard/src/utils/SourceMapMergingUtil.ts index 266f0d33cc4c9677b22066169789d55a757a0053..cb4746226a7603f7ef70dcd3103d53ca7bea49c7 100644 --- a/arkguard/src/utils/SourceMapMergingUtil.ts +++ b/arkguard/src/utils/SourceMapMergingUtil.ts @@ -74,6 +74,11 @@ export interface SourceMapSegmentObj { type MappingsNameType = { mappings: readonly SourceMapSegment[][]; names?: readonly string[] }; type TracedMappingsType = { mappings: SourceMapSegment[][]; names: string[]; sources: string[] }; +/** + * Type of the map parameter of the SourceMapLink class. + */ +export type MappingsNameTypeForTest = MappingsNameType; + /** * Provide api tools related to sourcemap. */ diff --git a/arkguard/src/utils/TypeUtils.ts b/arkguard/src/utils/TypeUtils.ts index cd143376b6519b249c4ed81ab6ccbb18063dedd7..1c80ffea5374c50f2310c24738a9d0e628823649 100644 --- a/arkguard/src/utils/TypeUtils.ts +++ b/arkguard/src/utils/TypeUtils.ts @@ -42,7 +42,7 @@ export class TypeUtils { * @param {string} sourceFilePath * @param {string} content - The content in sourceFilePath */ - public static createObfSourceFile(sourceFilePath: string, content: string): SourceFile { + public static createObfSourceFile(sourceFilePath: string, content: string, compilerOptions?: CompilerOptions): SourceFile { const pathOrExtension: PathAndExtension = FileUtils.getFileSuffix(sourceFilePath); const fileSuffix = pathOrExtension.ext; @@ -50,6 +50,10 @@ export class TypeUtils { sourceFilePath = pathOrExtension.path + Extension.TS; } + if (compilerOptions && compilerOptions.etsAnnotationsEnable === true) { + return createSourceFile(sourceFilePath, content, ScriptTarget.ES2015, true, undefined, compilerOptions, true); + } + return createSourceFile(sourceFilePath, content, ScriptTarget.ES2015, true); } diff --git a/arkguard/test/grammar/advanced_type/intersection_types.ts b/arkguard/test/grammar/advanced_type/intersection_types.ts index 182de6165ace90143339ba74036556a7589ed347..6d4457b850202196b45398ef6b5135b1207be64a 100644 --- a/arkguard/test/grammar/advanced_type/intersection_types.ts +++ b/arkguard/test/grammar/advanced_type/intersection_types.ts @@ -15,35 +15,36 @@ import assert = require('assert'); -function extend(first: T, second: U): T & U { - let result = {}; - for (let id in first) { - (result)[id] = (first)[id]; +function mergeObjects(primary: T, secondary: U): T & U { + const merged = {} as T & U; + + for (const prop in primary) { + merged[prop] = primary[prop] as any; } - for (let id in second) { - if (!result.hasOwnProperty(id)) { - (result)[id] = (second)[id]; + + for (const prop in secondary) { + if (!Object.prototype.hasOwnProperty.call(merged, prop)) { + merged[prop] = secondary[prop] as any; } } - return result; + return merged; } -class Person { - constructor(public name: string) { - } +class Human { + constructor(public username: string) {} } -interface Loggable { - log(): void; +interface LoggingCapability { + writeLog(): void; } -class ConsoleLogger implements Loggable { - log(): void { +class TerminalLogger implements LoggingCapability { + writeLog(): void { console.log('Jim'); } } -const jim = extend(new Person('Jim'), new ConsoleLogger()); -const n = jim.name; +const user = mergeObjects(new Human('Jim'), new TerminalLogger()); +const currentUser = user.username; -assert(n === 'Jim', 'success'); +assert(currentUser === 'Jim', 'success'); diff --git a/arkguard/test/grammar/advanced_type/predefined_types.ts b/arkguard/test/grammar/advanced_type/predefined_types.ts index 22d55829e5b3fcf1eebc0e353a4738e0211096de..d12d9d5acaa3d2b389b057e604da24706aea1b5a 100644 --- a/arkguard/test/grammar/advanced_type/predefined_types.ts +++ b/arkguard/test/grammar/advanced_type/predefined_types.ts @@ -13,8 +13,6 @@ * limitations under the License. */ -import assert = require('assert'); - type T00 = Exclude<'a' | 'b' | 'c' | 'd', 'a' | 'c' | 'f'>; // 'b' | 'd' type T01 = Extract<'a' | 'b' | 'c' | 'd', 'a' | 'c' | 'f'>; // 'a' | 'c' @@ -33,13 +31,13 @@ class C { y = 0; } -type T10 = ReturnType<() => string>; // string -type T11 = ReturnType<(s: string) => void>; // void -type T12 = ReturnType<(() => T)>; // {} -type T13 = ReturnType<(() => T)>; // number[] -type T14 = ReturnType; // { a: number, b: string } -type T15 = ReturnType; // any -type T16 = ReturnType; // any +type ResultString = ReturnType<() => string>; // string +type ResultVoid = ReturnType<(s: string) => void>; // void +type ResultGeneric = ReturnType<(() => T)>; // {} +type ResultConstrained = ReturnType<(() => T)>; // number[] +type ResultInstance = ReturnType; // { a: number, b: string } +type ResultAny = ReturnType; // any +type ResultNever = ReturnType; // any type T20 = InstanceType; // C type T21 = InstanceType; // any diff --git a/arkguard/test/grammar/advanced_type/predefined_types_expected.txt b/arkguard/test/grammar/advanced_type/predefined_types_expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..b22f02196e0cb9e272af321cc65105966a3e1b51 --- /dev/null +++ b/arkguard/test/grammar/advanced_type/predefined_types_expected.txt @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +type l1 = Exclude<'a' | 'b' | 'c' | 'd', 'a' | 'c' | 'f'>; // 'b' | 'd' +type m1 = Extract<'a' | 'b' | 'c' | 'd', 'a' | 'c' | 'f'>; // 'a' | 'c' +type n1 = Exclude void), Function>; // string | number +type o1 = Extract void), Function>; // () => void +type q1 = NonNullable; // string | number +type s1 = NonNullable<(() => string) | string[] | null | undefined>; // (() => string) | string[] +function j1(g2: string): any { + return { a: 1, b: g2 }; +} +class t1 { + x = 0; + y = 0; +} +type u1 = ReturnType<() => string>; // string +type v1 = ReturnType<(s: string) => void>; // void +type w1 = ReturnType<(() => T)>; // {} +type z1 = ReturnType<(() => T)>; // number[] +type a2 = ReturnType; // { a: number, b: string } +type b2 = ReturnType; // any +type c2 = ReturnType; // any +type d2 = InstanceType; // C +type e2 = InstanceType; // any +type f2 = InstanceType; // any diff --git a/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints.ts b/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints.ts index ff334131470e9e6fd14d8cc753535d69e540c4da..4b9cb710891cd458674edd9108e77f798947494e 100644 --- a/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints.ts +++ b/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints.ts @@ -18,33 +18,33 @@ 1. + 2.0 + 3.; var i: number = 1; -var test1 = i.toString(); -var test3 = 3 .toString(); -var test4 = 3 .toString(); -var test5 = 3 .toString(); -var test6 = 3.['toString'](); -var test7 = 3 +var compactTest1 = i.toString(); +var compactTest3 = 3 .toString(); +var compactTest4 = 3 .toString(); +var compactTest5 = 3 .toString(); +var compactTest6 = 3.['toString'](); +var compactTest7 = 3 .toString(); -var test8 = new Number(4).toString(); -var test9 = 3. + 3.; -var test10 = 0 /* comment */.toString(); -var test11 = 3. /* comment */.toString(); -var test12 = 3 +var compactTest8 = new Number(4).toString(); +var compactTest9 = 3. + 3.; +var compactTest10 = 0 /* comment */.toString(); +var compactTest11 = 3. /* comment */.toString(); +var compactTest12 = 3 /* comment */ .toString(); var test122 = 3 /* comment */.toString(); var test1222 = 3 .toString(); -var test13 = 3. +var compactTest13 = 3. /* comment */.toString(); -var test14 = 3 +var compactTest14 = 3 // comment .toString(); -var test15 = 3. +var compactTest15 = 3. // comment .toString(); -var test16 = 3 // comment time +var compactTest16 = 3 // comment time .toString(); -var test17 = 3. // comment time again +var compactTest17 = 3. // comment time again .toString(); \ No newline at end of file diff --git a/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected.txt b/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected.txt index c00d3215e58b153f0e11b2f915f94a5d247a8558..91796cd9c13e67a76ca123b35c6abbaacadb95bf 100644 --- a/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected.txt +++ b/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected.txt @@ -1 +1 @@ -1..toString();1.0.toString();1. + 2.0 + 3.;var i: number = 1;var test1 = i.toString();var test3 = 3..toString();var test4 = 3..toString();var test5 = 3..toString();var test6 = 3.['toString']();var test7 = 3 .toString();var test8 = new Number(4).toString();var test9 = 3. + 3.;var test10 = 0 .toString();var test11 = 3. .toString();var test12 = 3 .toString();var test122 = 3 .toString();var test1222 = 3 .toString();var test13 = 3. .toString();var test14 = 3 .toString();var test15 = 3. .toString();var test16 = 3 .toString();var test17 = 3. .toString(); \ No newline at end of file +1..toString();1.0.toString();1. + 2.0 + 3.;var i: number = 1;var compactTest1 = i.toString();var compactTest3 = 3..toString();var compactTest4 = 3..toString();var compactTest5 = 3..toString();var compactTest6 = 3.['toString']();var compactTest7 = 3 .toString();var compactTest8 = new Number(4).toString();var compactTest9 = 3. + 3.;var compactTest10 = 0 .toString();var compactTest11 = 3. .toString();var compactTest12 = 3 .toString();var test122 = 3 .toString();var test1222 = 3 .toString();var compactTest13 = 3. .toString();var compactTest14 = 3 .toString();var compactTest15 = 3. .toString();var compactTest16 = 3 .toString();var compactTest17 = 3. .toString(); \ No newline at end of file diff --git a/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected_map.txt b/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected_map.txt index 4e7f94de3f118943977ec0128f86fab8d18e5580..69efdc4f7ce3090551b3225128d91851cf225550 100644 --- a/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected_map.txt +++ b/arkguard/test/grammar/compact/numericLiteralsWithTrailingDecimalPoints_expected_map.txt @@ -6,5 +6,5 @@ "test/grammar/compact/numericLiteralsWithTrailingDecimalPoints.ts" ], "names": [], - "mappings": "AAeA,EAAE,CAAC,QAAQ,EAAE,CACb,GAAG,CAAC,QAAQ,EAAE,CACd,EAAE,GAAG,GAAG,GAAG,EAAE,CAEb,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CACjB,IAAI,KAAK,GAAG,CAAC,CAAC,QAAQ,EAAE,CACxB,IAAI,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAE,CACzB,IAAI,KAAK,GAAG,CAAC,EAAK,QAAQ,EAAE,CAC5B,IAAI,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAE,CACzB,IAAI,KAAK,GAAG,EAAE,CAAC,UAAU,CAAC,EAAE,CAC5B,IAAI,KAAK,GAAG,CAAC,EACV,QAAQ,EAAE,CACb,IAAI,KAAK,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CACpC,IAAI,KAAK,GAAG,EAAE,GAAG,EAAE,CACnB,IAAI,MAAM,GAAG,CAAC,CAAc,CAAC,QAAQ,EAAE,CACvC,IAAI,MAAM,GAAG,EAAE,CAAc,CAAC,QAAQ,EAAE,CACxC,IAAI,MAAM,GAAG,CAAC,CACC,EAAE,QAAQ,EAAE,CAC3B,IAAI,OAAO,GAAG,CAAC,CACF,EAAC,QAAQ,EAAE,CACxB,IAAI,QAAQ,GAAG,CAAC,EAEb,QAAQ,EAAE,CACb,IAAI,MAAM,GAAG,EAAE,CACA,EAAC,QAAQ,EAAE,CAC1B,IAAI,MAAM,GAAG,CAAC,CACF,CACT,QAAQ,EAAE,CACb,IAAI,MAAM,GAAG,EAAE,CACH,CACT,QAAQ,EAAE,CACb,IAAI,MAAM,GAAG,CAAC,CAAiB,CAC5B,QAAQ,EAAE,CACb,IAAI,MAAM,GAAG,EAAE,CAAsB,CAClC,QAAQ,EAAE,CAAC" + "mappings": "AAeA,EAAE,CAAC,QAAQ,EAAE,CACb,GAAG,CAAC,QAAQ,EAAE,CACd,EAAE,GAAG,GAAG,GAAG,EAAE,CAEb,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CACjB,IAAI,YAAY,GAAG,CAAC,CAAC,QAAQ,EAAE,CAC/B,IAAI,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAE,CAChC,IAAI,YAAY,GAAG,CAAC,EAAK,QAAQ,EAAE,CACnC,IAAI,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAE,CAChC,IAAI,YAAY,GAAG,EAAE,CAAC,UAAU,CAAC,EAAE,CACnC,IAAI,YAAY,GAAG,CAAC,EACjB,QAAQ,EAAE,CACb,IAAI,YAAY,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAC3C,IAAI,YAAY,GAAG,EAAE,GAAG,EAAE,CAC1B,IAAI,aAAa,GAAG,CAAC,CAAc,CAAC,QAAQ,EAAE,CAC9C,IAAI,aAAa,GAAG,EAAE,CAAc,CAAC,QAAQ,EAAE,CAC/C,IAAI,aAAa,GAAG,CAAC,CACN,EAAE,QAAQ,EAAE,CAC3B,IAAI,OAAO,GAAG,CAAC,CACF,EAAC,QAAQ,EAAE,CACxB,IAAI,QAAQ,GAAG,CAAC,EAEb,QAAQ,EAAE,CACb,IAAI,aAAa,GAAG,EAAE,CACP,EAAC,QAAQ,EAAE,CAC1B,IAAI,aAAa,GAAG,CAAC,CACT,CACT,QAAQ,EAAE,CACb,IAAI,aAAa,GAAG,EAAE,CACV,CACT,QAAQ,EAAE,CACb,IAAI,aAAa,GAAG,CAAC,CAAiB,CACnC,QAAQ,EAAE,CACb,IAAI,aAAa,GAAG,EAAE,CAAsB,CACzC,QAAQ,EAAE,CAAC" } \ No newline at end of file diff --git a/arkguard/test/grammar/interface_validation/interface_class_method.ts b/arkguard/test/grammar/interface_validation/interface_class_method.ts index f9bea5f4f47237c416fce7cf45a0f63ec8774c0a..1636c31168cf4c4b56f53fccf3a1be72d2ed5e25 100644 --- a/arkguard/test/grammar/interface_validation/interface_class_method.ts +++ b/arkguard/test/grammar/interface_validation/interface_class_method.ts @@ -15,27 +15,27 @@ import assert = require('assert'); -interface ClockInterface { - currentTime: Date; +interface TimepieceInterface { + currentDateTime: Date; - setTime(d: Date); + updateTime(newTime: Date); } -class Clock implements ClockInterface { - currentTime: Date; +class WallClock implements TimepieceInterface { + currentDateTime: Date; - setTime(d: Date) { - this.currentTime = d; + updateTime(newTime: Date) { + this.currentDateTime = newTime; } - constructor(h: number, m: number) { + constructor(hour: number, minute: number) { } } -let nowClock = new Clock(3, 20); +let nowClock = new WallClock(3, 20); let now = Date.prototype; -nowClock.setTime(now); +nowClock.updateTime(now); -assert(nowClock.currentTime === now, 'success'); \ No newline at end of file +assert(nowClock.currentDateTime === now, 'success'); \ No newline at end of file diff --git a/arkguard/test/grammar/module_validation/name_space.ts b/arkguard/test/grammar/module_validation/name_space.ts index bc9379802add64166105995aa8e122fb2f3cb846..582fb7951301576551b9a4c761a0bbc94e52ce6a 100644 --- a/arkguard/test/grammar/module_validation/name_space.ts +++ b/arkguard/test/grammar/module_validation/name_space.ts @@ -15,33 +15,33 @@ import assert = require('assert'); -interface StringValidator { - isAcceptable(s: string): boolean; +interface TextValidationRule { + isValid(text: string): boolean; } -let lettersRegexp = /^[A-Za-z]+$/; -let numberRegexp = /^[0-9]+$/; +const alphabeticPattern = /^[A-Za-z]+$/; +const numericPattern = /^[0-9]+$/; -class LettersOnlyValidator implements StringValidator { - isAcceptable(s: string) { - return lettersRegexp.test(s); +class AlphabeticalValidator implements TextValidationRule { + isValid(text: string) { + return alphabeticPattern.test(text); } } -class ZipCodeValidator implements StringValidator { - isAcceptable(s: string) { - return s.length === 5 && numberRegexp.test(s); +class PostalCodeValidator implements TextValidationRule { + isValid(text: string) { + return text.length === 5 && numericPattern.test(text); } } -// Some samples to try -let strings = ["Hello", "98052", "101"]; +// Test cases +const testInputs = ["Hello", "98052", "101"]; -// Validators to use -let validators: { [s: string]: StringValidator; } = {}; -validators["ZIP code"] = new ZipCodeValidator(); -validators["Letters only"] = new LettersOnlyValidator(); +// Validation registry +const validationRules: { [ruleName: string]: TextValidationRule } = {}; +validationRules["Postal Code"] = new PostalCodeValidator(); +validationRules["Alphabetical"] = new AlphabeticalValidator(); -assert(validators["Letters only"].isAcceptable(strings[0]), 'success'); -assert(validators["ZIP code"].isAcceptable(strings[1]), 'success'); +assert(validationRules["Alphabetical"].isValid(testInputs[0]), 'success'); +assert(validationRules["Postal Code"].isValid(testInputs[1]), 'success'); diff --git a/arkguard/test/testData/obfuscation/Configs/bytecodeObf/arkguard_enable.txt b/arkguard/test/testData/obfuscation/Configs/bytecodeObf/arkguard_enable.txt new file mode 100644 index 0000000000000000000000000000000000000000..3886aed9a1183916a362572acc393ad76de4b970 --- /dev/null +++ b/arkguard/test/testData/obfuscation/Configs/bytecodeObf/arkguard_enable.txt @@ -0,0 +1 @@ +#default \ No newline at end of file diff --git a/arkguard/test/testData/obfuscation/Configs/bytecodeObf/bytecodeObf_enable.txt b/arkguard/test/testData/obfuscation/Configs/bytecodeObf/bytecodeObf_enable.txt new file mode 100644 index 0000000000000000000000000000000000000000..810df52a853d84a165e48e3ab2a4af4c8b857a61 --- /dev/null +++ b/arkguard/test/testData/obfuscation/Configs/bytecodeObf/bytecodeObf_enable.txt @@ -0,0 +1,3 @@ +-enable-bytecode-obfuscation +-enable-bytecode-obfuscation-debugging +-enable-bytecode-obfuscation-enhanced \ No newline at end of file diff --git a/arkguard/test/testData/obfuscation/system_api_obfuscation/bytecode_obfuscation/bytecode_obfuscation.txt b/arkguard/test/testData/obfuscation/system_api_obfuscation/bytecode_obfuscation/bytecode_obfuscation.txt new file mode 100644 index 0000000000000000000000000000000000000000..43c1c46fc84eb2992a31048fbe38bc69b66fb977 --- /dev/null +++ b/arkguard/test/testData/obfuscation/system_api_obfuscation/bytecode_obfuscation/bytecode_obfuscation.txt @@ -0,0 +1 @@ +-enable-bytecode-obfuscation \ No newline at end of file diff --git a/arkguard/test/ut/arkobfuscator/ArkObfuscator.spec.ts b/arkguard/test/ut/arkobfuscator/ArkObfuscator.spec.ts index 1d4c9b1bb9829bb9a914131fd563454d29df5262..89cba1945921edec61072ab680f813db25229658 100644 --- a/arkguard/test/ut/arkobfuscator/ArkObfuscator.spec.ts +++ b/arkguard/test/ut/arkobfuscator/ArkObfuscator.spec.ts @@ -260,6 +260,15 @@ class Demo{ } expect(languageSet).to.deep.equal(UnobfuscationCollections.reservedLangForProperty); }); + + it('Tester: test case for enable annotation', function (){ + let configPath = "test/ut/arkobfuscator/iniTestObfConfig.json" + let obfuscator: ArkObfuscator = new ArkObfuscator(); + let config = FileUtils.readFileAsJson(configPath) as IOptions; + obfuscator.init(config); + + expect(config.mAllowEtsAnnotations).to.be.true; + }); }); }); diff --git a/arkguard/test/ut/arkobfuscator/ArkObfuscator2.spec.ts b/arkguard/test/ut/arkobfuscator/ArkObfuscator2.spec.ts index 57e552d25454399ac2feedd0138f4edc55f3d310..a345d5feb3e538a83a7bc568c0db1253cd83f8e3 100644 --- a/arkguard/test/ut/arkobfuscator/ArkObfuscator2.spec.ts +++ b/arkguard/test/ut/arkobfuscator/ArkObfuscator2.spec.ts @@ -67,6 +67,13 @@ import { SOURCE_FILE_PATHS, projectWhiteListManager } from '../../../src/utils/P import { FilePathObj } from '../../../src/common/type'; import { historyAllUnobfuscatedNamesMap } from '../../../src/initialization/Initializer'; import path from 'path'; +import { nameCache } from '../../../src/transformers/rename/RenameIdentifierTransformer'; +import { + decodeSourcemap, + MappingsNameTypeForTest, + Source, + SourceMapLink +} from '../../../src/utils/SourceMapMergingUtil'; describe('Tester Cases for ', function () { let obfuscator: ArkObfuscator; @@ -524,6 +531,67 @@ export declare function findElement(arr: T[], callback: (item: T) => boolean) }); }); + describe('test for ArkObfuscator.convertLineBasedOnSourceMap', () => { + it('there is no location but the value is obfuscated, it should be recorded in nameacahe', () => { + const identifierCache = new Map([ + ['#Person', 'Person'], + ['obfsucationValue:31:5:35:6', 'h'], + ['getName:75:5:77:6', 'getName'] + ]); + nameCache.set('IdentifierCache', identifierCache); + const source: Source = new Source('utils.ets', null); + const previousStageSourceMap: RawSourceMap = { + version: 3, + file: 'utils.ets', + sourceRoot: '', + sources: [ 'entry/src/main/ets/pages/utils/utils.ets'], + names: [], + mappings: '', + sourcesContent: undefined, + } + const decodedSourceMap = decodeSourcemap(previousStageSourceMap as RawSourceMap); + const sourceMapLink: SourceMapLink = new SourceMapLink(decodedSourceMap as MappingsNameTypeForTest, [source]); + + const result = obfuscator.convertLineBasedOnSourceMapForTest('IdentifierCache', sourceMapLink); + const expectedResult= { + '#Person': 'Person', + 'obfsucationValue': 'h' + }; + const compareResult = JSON.stringify(result) === JSON.stringify(expectedResult); + expect(compareResult).to.be.true; + }); + + it('there is start and end location, it should be recorded in nameacahe', () => { + const identifierCache = new Map([ + ['#Person', 'Person'], + ['#foo:1:1:3:2', 'foo'], + ['getName:75:5:77:6', 'getName'] + ]); + nameCache.set('IdentifierCache', identifierCache); + const source: Source = new Source('file.ts', null); + const previousStageSourceMap: RawSourceMap = { + "version": 3, + "file": "file.ts", + "sources": [ + "entry/src/main/ets/pages/file.ts" + ], + "names": [], + "mappings": "AAAA,MAAM,UAAU,GAAG;IACjB,OAAO,CAAC,CAAC;AACX,CAAC", + "sourceRoot": "" + } + const decodedSourceMap = decodeSourcemap(previousStageSourceMap as RawSourceMap); + const sourceMapLink: SourceMapLink = new SourceMapLink(decodedSourceMap as MappingsNameTypeForTest, [source]); + + const result = obfuscator.convertLineBasedOnSourceMapForTest('IdentifierCache', sourceMapLink); + const expectedResult= { + '#Person': 'Person', + '#foo:1:3': 'foo' + }; + const compareResult = JSON.stringify(result) === JSON.stringify(expectedResult); + expect(compareResult).to.be.true; + }); + }); + describe('test for clearGlobalCaches', () => { beforeEach(() => { PropCollections.globalMangledTable.set('test1', 'obfuscated1'); diff --git a/arkguard/test/ut/arkobfuscator/iniTestObfConfig.json b/arkguard/test/ut/arkobfuscator/iniTestObfConfig.json index c4ce5a7e3f7c189ce3119e04563df632d13371a1..c3373c14e770de596f085f95f63f772e808f60fa 100644 --- a/arkguard/test/ut/arkobfuscator/iniTestObfConfig.json +++ b/arkguard/test/ut/arkobfuscator/iniTestObfConfig.json @@ -16,5 +16,6 @@ "mReservedToplevelNames": ["a*", "*shoul?keep*", "func2"] }, "mEnableSourceMap": false, - "mEnableNameCache": false + "mEnableNameCache": false, + "mAllowEtsAnnotations": true } \ No newline at end of file diff --git a/arkguard/test/ut/initialization/ConfigResolver-hsp.spec.ts b/arkguard/test/ut/initialization/ConfigResolver-hsp.spec.ts index 93c20dfafab78c0178e60b64d346ef95e0df8c4f..37031bc400e776c45b2fc6b2329ddb149db64a97 100644 --- a/arkguard/test/ut/initialization/ConfigResolver-hsp.spec.ts +++ b/arkguard/test/ut/initialization/ConfigResolver-hsp.spec.ts @@ -259,6 +259,7 @@ describe('hsp support consumerFiles', () => { localHspConfig.dependencies.hars.push(remoteHarObfFile); const hspResolver = new ObConfigResolver({ obfuscationOptions: localHspConfig, compileHar: false, compileShared: true }, printObfLogger); hspResolver.resolveObfuscationConfigs(); + hspResolver.emitConsumerConfigFiles(); const hspObfuscationContent = fs.readFileSync(localHspConfig.exportRulePath, 'utf-8'); expect(hspObfuscationContent).not.to.include('-disable-obfuscation'); @@ -334,6 +335,7 @@ describe('hsp support consumerFiles', () => { localHarConfig.dependencies.hspLibraries?.push(localHspConfig.selfConfig); const localHarResolver = new ObConfigResolver({ obfuscationOptions: localHarConfig, compileHar: true, compileShared: false }, printObfLogger); localHarResolver.resolveObfuscationConfigs(); + localHarResolver.emitConsumerConfigFiles(); const localHarObfuscationContent = fs.readFileSync(localHarConfig.exportRulePath, 'utf-8'); @@ -412,6 +414,7 @@ describe('hsp support consumerFiles', () => { localHarConfig.dependencies.hsps?.push(remoteHspObfFile); const localHarResolver = new ObConfigResolver({ obfuscationOptions: localHarConfig, compileHar: true, compileShared: false }, printObfLogger); localHarResolver.resolveObfuscationConfigs(); + localHarResolver.emitConsumerConfigFiles(); const localHarObfuscationContent = fs.readFileSync(localHarConfig.exportRulePath, 'utf-8'); @@ -589,6 +592,8 @@ describe('hsp support consumerFiles', () => { localMainHspConfig.dependencies.hsps?.push(remoteHspObfFile); const localMainHspResolver = new ObConfigResolver({ obfuscationOptions: localMainHspConfig, compileHar: false, compileShared: true }, printObfLogger); localMainHspResolver.resolveObfuscationConfigs(); + localMainHspResolver.emitConsumerConfigFiles(); + const localMainHspObfuscationContent = fs.readFileSync(localMainHspConfig.exportRulePath, 'utf-8'); expect(localMainHspObfuscationContent).not.to.include('-enable-filename-obfuscation'); diff --git a/arkguard/test/ut/initialization/ConfigResolver.spec.ts b/arkguard/test/ut/initialization/ConfigResolver.spec.ts index f5b9bc480a08896c7d224991d512017553b34552..26c25a6592f3f3d3c79d1161a5a48c9f3a031e04 100644 --- a/arkguard/test/ut/initialization/ConfigResolver.spec.ts +++ b/arkguard/test/ut/initialization/ConfigResolver.spec.ts @@ -956,6 +956,24 @@ describe('test for ConfigResolve', function() { expect(configs.options.enableLibObfuscationOptions).to.be.true; }); + + it('should handle config correctly when enable bytecode obfuscation options', () => { + const configs: MergedConfig = new MergedConfig(); + configs.options = new ObOptionsForTest(); + + const configPath = './test/testData/obfuscation/enable_lib_obfuscation_options/obfuscation-rule.txt'; + const data = ` + -enable-bytecode-obfuscation + -enable-bytecode-obfuscation-debugging + -enable-bytecode-obfuscation-enhanced + -enable-bytecode-obfuscation-arkui + `; + newObConfigResolver.handleConfigContentForTest(data, configs, configPath); + expect(configs.options.bytecodeObf.enable).to.be.true; + expect(configs.options.bytecodeObf.debugging).to.be.true; + expect(configs.options.bytecodeObf.enhanced).to.be.true; + expect(configs.options.bytecodeObf.obfArkUI).to.be.true; + }); }); describe('1: test Api collectSystemApiWhitelist', function() { @@ -1188,6 +1206,52 @@ describe('test for ConfigResolve', function() { fs.unlinkSync(systemApiPath); }); + + it('1-5: test collectSystemApiWhitelist: -enable-bytecode-obfuscation', function () { + let obfuscationCacheDir = path.join(OBFUSCATE_TESTDATA_DIR, 'bytecode_obfuscation'); + let obfuscationOptions = { + 'selfConfig': { + 'ruleOptions': { + 'enable': true, + 'rules': [ + path.join(OBFUSCATE_TESTDATA_DIR, 'bytecode_obfuscation/bytecode_obfuscation.txt') + ] + }, + 'consumerRules': [], + }, + 'dependencies': { + 'libraries': [], + 'hars': [] + }, + 'obfuscationCacheDir': obfuscationCacheDir, + 'sdkApis': [ + path.join(OBFUSCATE_TESTDATA_DIR, 'system_api.d.ts') + ] + }; + let projectConfig = { + obfuscationOptions, + compileHar: false + }; + const obConfig: ObConfigResolver = new ObConfigResolver(projectConfig, undefined); + obConfig.resolveObfuscationConfigs(); + const reservedSdkApiForProp = UnobfuscationCollections.reservedSdkApiForProp; + const reservedSdkApiForGlobal = UnobfuscationCollections.reservedSdkApiForGlobal; + const reservedSdkApiForLocal = UnobfuscationCollections.reservedSdkApiForLocal; + + expect(reservedSdkApiForProp.size == 12).to.be.true; + expect(reservedSdkApiForGlobal.size == 3).to.be.true; + expect(reservedSdkApiForLocal.size == 8).to.be.true; + UnobfuscationCollections.clear(); + + let systemApiPath = obfuscationCacheDir + '/systemApiCache.json'; + const data = fs.readFileSync(systemApiPath, 'utf8'); + const systemApiContent = JSON.parse(data); + + expect(systemApiContent.ReservedLocalNames.length == 8).to.be.true; + expect(systemApiContent.ReservedPropertyNames.length == 12).to.be.true; + expect(systemApiContent.ReservedGlobalNames.length == 3).to.be.true; + fs.unlinkSync(systemApiPath); + }); }); }); @@ -2015,6 +2079,24 @@ describe('test for ConfigResolve', function() { const result = enableObfuscateFileName(isPackageModules, projectConfig); expect(result).to.be.false; }); + + it('should return false if obfuscation is enabled and bytecodeObf is enable', () => { + const isPackageModules = false; + const projectConfig = { + obfuscationMergedObConfig: { + options: { + disableObfuscation: false, + enableFileNameObfuscation: true, + bytecodeObf: { + enable: true + }, + }, + }, + buildMode: "not Debug" + }; + const result = enableObfuscatedFilePathConfig(isPackageModules, projectConfig); + expect(result).to.be.false; + }); }); describe('getRelativeSourcePath', () => { @@ -2171,6 +2253,7 @@ describe('test for ConfigResolve', function() { AtKeepCollections.clear(); const obConfigResolver = new ObConfigResolver(projectConfig, printObfLogger); obConfigResolver.resolveObfuscationConfigs(); + obConfigResolver.emitConsumerConfigFiles(); const atKeepContent = fs.readFileSync(sourceObConfig.exportRulePath, 'utf-8'); expect(atKeepContent).to.include('-enable-property-obfuscation'); expect(atKeepContent).to.include('-keep-global-name'); diff --git a/arkguard/test/ut/initialization/Initializer.spec.ts b/arkguard/test/ut/initialization/Initializer.spec.ts index 69ae8b1a74a59bea840589dc173b8265e4ee86c8..7657a550feefd6f7514ad08989fb70c4414ab04c 100644 --- a/arkguard/test/ut/initialization/Initializer.spec.ts +++ b/arkguard/test/ut/initialization/Initializer.spec.ts @@ -14,11 +14,23 @@ */ import { - clearHistoryUnobfuscatedMap, - historyAllUnobfuscatedNamesMap, - historyUnobfuscatedPropMap + clearHistoryUnobfuscatedMap, + historyAllUnobfuscatedNamesMap, + historyUnobfuscatedPropMap, + initObfuscationConfig } from '../../../src/initialization/Initializer'; -import { expect } from 'chai'; +import { + expect, + assert +} from 'chai'; +import { + describe, + it +} from 'mocha'; +import { + HvigorErrorInfo, + MergedConfig, +} from '../../../src/ArkObfuscator'; describe('Tester Cases for .', function () { it('Tester Cases for .', function () { @@ -31,3 +43,76 @@ describe('Tester Cases for .', function () { expect(historyUnobfuscatedPropMap.size).to.equal(0); }); }); + +function printObfLogger(errorInfo: string, errorCodeInfo: HvigorErrorInfo | string, level: string): void { + switch (level) { + case 'warn': + console.warn(errorInfo); + break; + case 'error': + console.error(errorInfo); + break; + default: + break; + } +} +const projectConfig = { + 'obfuscationOptions': { + 'selfConfig': { + 'ruleOptions': { + 'enable': true, + 'rules': ['./test/testData/obfuscation/Configs/bytecodeObf/bytecodeObf_enable.txt'] + }, + 'consumerRules': [], + }, + 'dependencies': { + 'libraries': [], + 'hars': [] + }, + obfuscationCacheDir: "" + } +}; +interface ArkProjectConfig { + isBytecodeObfEnabled?: boolean; + isArkguardEnabled?: boolean; + allowEtsAnnotations?: boolean; + obfuscationMergedObConfig?: MergedConfig; +} + +describe('test for set arkguard mode property correctly for arkProjectConfig', function () { + describe('test for set arkguard mode property correctly for arkProjectConfig', () => { + it('should set isBytecodeObfEnabled when enable bytecodeObf', () => { + const arkProjectConfig: ArkProjectConfig = {}; + initObfuscationConfig(projectConfig, arkProjectConfig, printObfLogger); + expect(arkProjectConfig.isBytecodeObfEnabled).to.be.true; + expect(arkProjectConfig.isArkguardEnabled).to.be.false; + }); + + it('should set isArkguardEnabled when enable arkguardObf', () => { + const arkProjectConfig: ArkProjectConfig = {}; + projectConfig.obfuscationOptions.selfConfig.ruleOptions.rules = ['./test/testData/obfuscation/Configs/bytecodeObf/arkguard_enable.txt']; + initObfuscationConfig(projectConfig, arkProjectConfig, printObfLogger); + expect(arkProjectConfig.isArkguardEnabled).to.be.true; + expect(arkProjectConfig.isBytecodeObfEnabled).to.be.false; + }); + + it('should not set isArkguardEnabled and isBytecodeObfEnabled when obf is disabled', () => { + const arkProjectConfig: ArkProjectConfig = {}; + projectConfig.obfuscationOptions.selfConfig.ruleOptions.enable = false; + initObfuscationConfig(projectConfig, arkProjectConfig, printObfLogger); + expect(arkProjectConfig.isBytecodeObfEnabled).to.be.undefined; + expect(arkProjectConfig.isArkguardEnabled).to.be.undefined; + }); + + it('should not set enableEtsAnnotation if allowEtsAnnotations is enabled in arkProjectConfig', () => { + const arkProjectConfig: ArkProjectConfig = { + allowEtsAnnotations: true, + obfuscationMergedObConfig: new MergedConfig(), + }; + projectConfig.obfuscationOptions.selfConfig.ruleOptions.enable = true; + projectConfig.obfuscationOptions.selfConfig.ruleOptions.rules = ['./test/testData/obfuscation/Configs/bytecodeObf/arkguard_enable.txt']; + initObfuscationConfig(projectConfig, arkProjectConfig, printObfLogger); + expect(arkProjectConfig.obfuscationMergedObConfig?.options.enableEtsAnnotation).to.be.true; + }); + }); +}); diff --git a/arkguard/test/ut/transformer/RenameIdentifierTransformer.spec.ts b/arkguard/test/ut/transformer/RenameIdentifierTransformer.spec.ts index 6082c194a381940cfbbcd3d30d0bacf0188d3a3c..41856bcf8d6604e92596ab26aa214f1a893c6fd3 100644 --- a/arkguard/test/ut/transformer/RenameIdentifierTransformer.spec.ts +++ b/arkguard/test/ut/transformer/RenameIdentifierTransformer.spec.ts @@ -617,11 +617,138 @@ describe('Teste Cases for .', function () { const expectContent = `export declare function foo(para: number): void;`; assert.strictEqual(compareStringsIgnoreNewlines(actualContent, expectContent), true); }) + + it('should obfuscate annotationDeclaration when top-level obfuscation is enable', () => { + let options: IOptions = { + 'mNameObfuscation': { + 'mEnable': true, + 'mRenameProperties': false, + 'mReservedProperties': [], + 'mTopLevel': true, + 'mKeepParameterNames': false + }, + 'mAllowEtsAnnotations': true + }; + assert.strictEqual(options !== undefined, true); + const renameIdentifierFactory = secharmony.transformerPlugin.createTransformerFactory(options); + const fileContent = `@interface __$$ETS_ANNOTATION$$__Anno1 {prop1: number = 1}`; + const textWriter = ts.createTextWriter('\n'); + let arkobfuscator = new ArkObfuscatorForTest(); + arkobfuscator.init(options); + const sourceFile: ts.SourceFile = ts.createSourceFile('demo.ts', fileContent, ts.ScriptTarget.ES2015, true, undefined, { + 'etsAnnotationsEnable': true + }, true); + let transformedResult: ts.TransformationResult = ts.transform(sourceFile, [renameIdentifierFactory], {}); + let ast: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile; + arkobfuscator.createObfsPrinter(ast.isDeclarationFile).writeFile(ast, textWriter, undefined); + const actualContent = textWriter.getText(); + const expectContent = `@interface __$$ETS_ANNOTATION$$__a { + prop1: number = 1; + }`; + assert.strictEqual(compareStringsIgnoreNewlines(actualContent, expectContent), true); + PropCollections.clearPropsCollections(); + }) + + it('should not obfuscate when annotationName is in top-level whitelist', function () { + let options: IOptions = { + 'mNameObfuscation': { + 'mEnable': true, + 'mRenameProperties': false, + 'mReservedProperties': [], + 'mTopLevel': true, + 'mKeepParameterNames': false + }, + 'mAllowEtsAnnotations': true + }; + assert.strictEqual(options !== undefined, true); + PropCollections.reservedProperties.add('Anno1'); + const renameIdentifierFactory = secharmony.transformerPlugin.createTransformerFactory(options); + const fileContent = `@interface __$$ETS_ANNOTATION$$__Anno1 {prop1: number = 1}`; + const textWriter = ts.createTextWriter('\n'); + let arkobfuscator = new ArkObfuscatorForTest(); + arkobfuscator.init(options); + const sourceFile: ts.SourceFile = ts.createSourceFile('demo.ts', fileContent, ts.ScriptTarget.ES2015, true, undefined, { + 'etsAnnotationsEnable': true + }, true); + let transformedResult: ts.TransformationResult = ts.transform(sourceFile, [renameIdentifierFactory], {}); + let ast: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile; + arkobfuscator.createObfsPrinter(ast.isDeclarationFile).writeFile(ast, textWriter, undefined); + const actualContent = textWriter.getText(); + const expectContent = `@interface __$$ETS_ANNOTATION$$__Anno1 { + prop1: number = 1; + }`; + assert.strictEqual(compareStringsIgnoreNewlines(actualContent, expectContent), true); + PropCollections.clearPropsCollections(); + }) + + it('should not obfuscate when annotationName is exported and not enable export-obfuscation', function () { + let options: IOptions = { + 'mNameObfuscation': { + 'mEnable': true, + 'mRenameProperties': false, + 'mReservedProperties': [], + 'mTopLevel': true, + 'mKeepParameterNames': false + }, + 'mAllowEtsAnnotations': true, + 'mExportObfuscation': false, + }; + assert.strictEqual(options !== undefined, true); + const renameIdentifierFactory = secharmony.transformerPlugin.createTransformerFactory(options); + const fileContent = `export @interface __$$ETS_ANNOTATION$$__Anno1 {prop1: number = 1}`; + const textWriter = ts.createTextWriter('\n'); + let arkobfuscator = new ArkObfuscatorForTest(); + arkobfuscator.init(options); + const sourceFile: ts.SourceFile = ts.createSourceFile('demo.ts', fileContent, ts.ScriptTarget.ES2015, true, undefined, { + 'etsAnnotationsEnable': true + }, true); + let transformedResult: ts.TransformationResult = ts.transform(sourceFile, [renameIdentifierFactory], {}); + let ast: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile; + arkobfuscator.createObfsPrinter(ast.isDeclarationFile).writeFile(ast, textWriter, undefined); + const actualContent = textWriter.getText(); + const expectContent = `export @interface __$$ETS_ANNOTATION$$__Anno1 { + prop1: number = 1; + }`; + assert.strictEqual(compareStringsIgnoreNewlines(actualContent, expectContent), true); + PropCollections.clearPropsCollections(); + }) + + it('should obfuscate when annotationName is exported and enable export-obfuscation', function () { + let options: IOptions = { + 'mNameObfuscation': { + 'mEnable': true, + 'mRenameProperties': false, + 'mReservedProperties': [], + 'mTopLevel': true, + 'mKeepParameterNames': false + }, + 'mAllowEtsAnnotations': true, + 'mExportObfuscation': true, + }; + assert.strictEqual(options !== undefined, true); + const renameIdentifierFactory = secharmony.transformerPlugin.createTransformerFactory(options); + const fileContent = `export @interface __$$ETS_ANNOTATION$$__Anno1 {prop1: number = 1}`; + const textWriter = ts.createTextWriter('\n'); + let arkobfuscator = new ArkObfuscatorForTest(); + arkobfuscator.init(options); + const sourceFile: ts.SourceFile = ts.createSourceFile('demo.ts', fileContent, ts.ScriptTarget.ES2015, true, undefined, { + 'etsAnnotationsEnable': true + }, true); + let transformedResult: ts.TransformationResult = ts.transform(sourceFile, [renameIdentifierFactory], {}); + let ast: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile; + arkobfuscator.createObfsPrinter(ast.isDeclarationFile).writeFile(ast, textWriter, undefined); + const actualContent = textWriter.getText(); + const expectContent = `export @interface __$$ETS_ANNOTATION$$__a { + prop1: number = 1; + }`; + assert.strictEqual(compareStringsIgnoreNewlines(actualContent, expectContent), true); + PropCollections.clearPropsCollections(); + }) }) }) }) -function compareStringsIgnoreNewlines(str1: string, str2: string): boolean { +export function compareStringsIgnoreNewlines(str1: string, str2: string): boolean { const normalize = (str: string) => str.replace(/[\n\r\s]+/g, ''); return normalize(str1) === normalize(str2); } \ No newline at end of file diff --git a/arkguard/test/ut/transformer/RenamePropertiesTransformer.spec.ts b/arkguard/test/ut/transformer/RenamePropertiesTransformer.spec.ts index 24f8a3f516a3d97fe3d5631ff23442a46d79746c..213e75d6679d6bc377f3c973b6e3520b8a8dbc6f 100644 --- a/arkguard/test/ut/transformer/RenamePropertiesTransformer.spec.ts +++ b/arkguard/test/ut/transformer/RenamePropertiesTransformer.spec.ts @@ -33,6 +33,9 @@ import ts, { } from 'typescript'; import secharmony from '../../../src/transformers/rename/RenamePropertiesTransformer'; import { ArkObfuscator } from '../../../src/ArkObfuscator'; +import { compareStringsIgnoreNewlines } from './RenameIdentifierTransformer.spec'; +import { ArkObfuscatorForTest } from '../../../src/ArkObfuscatorForTest' +import { PropCollections } from '../../../src/utils/CommonCollections'; describe('Tester Cases for .', function () { @@ -202,5 +205,87 @@ describe('Tester Cases for .', function () { expect(((node.indexType as UnionTypeNode).types[0] as LiteralTypeNode).literal).to.be.equal(((parentNodes.indexType as UnionTypeNode).types[0] as LiteralTypeNode).literal); expect(((node.indexType as UnionTypeNode).types[1] as LiteralTypeNode).literal).to.be.equal(((parentNodes.indexType as UnionTypeNode).types[1] as LiteralTypeNode).literal); }); + + it('should not rename property in annotation decl and callsite when using prop', function () { + ArkObfuscator.isKeptCurrentFile = false; + options = { + mNameObfuscation: { + mEnable: true, + mNameGeneratorType: 1, + mRenameProperties: true, + mKeepStringProperty: false, + mReservedProperties: [] + }, + }; + const renameIdentifierFactory = secharmony.transformerPlugin.createTransformerFactory(options as IOptions); + const fileContent = ` + @interface __$$ETS_ANNOTATION$$__Anno1 { + prop1: number = 1; + } + @__$$ETS_ANNOTATION$$__Anno1({prop: 1}) + class myClass1 { + prop1: number = 1; + } + let var1: myClass1 = new myClass1(); + let var2 = var1.prop1; + `; + const textWriter = ts.createTextWriter('\n'); + let arkobfuscator = new ArkObfuscatorForTest(); + arkobfuscator.init(options); + const sourceFile: ts.SourceFile = ts.createSourceFile('demo.ts', fileContent, ts.ScriptTarget.ES2015, true, undefined, { + 'etsAnnotationsEnable': true + }, true); + let transformedResult: ts.TransformationResult = ts.transform(sourceFile, [renameIdentifierFactory], {}); + let ast: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile; + arkobfuscator.createObfsPrinter(ast.isDeclarationFile).writeFile(ast, textWriter, undefined); + const actualContent = textWriter.getText(); + const expectContent = ` + @interface __$$ETS_ANNOTATION$$__Anno1 { + prop1: number = 1; + } + @__$$ETS_ANNOTATION$$__Anno1({ prop: 1 }) + class myClass1 { + g: number = 1; + } + let var1: myClass1 = new myClass1(); + let var2 = var1.g; + `; + assert.strictEqual(compareStringsIgnoreNewlines(actualContent, expectContent), true); + PropCollections.clearPropsCollections(); + }); + + it('should rename annotation called as prop when using prop obfuscation', function () { + ArkObfuscator.isKeptCurrentFile = false; + options = { + mNameObfuscation: { + mEnable: true, + mNameGeneratorType: 1, + mRenameProperties: true, + mKeepStringProperty: false, + mReservedProperties: [] + }, + }; + const renameIdentifierFactory = secharmony.transformerPlugin.createTransformerFactory(options as IOptions); + const fileContent = ` + @ns.__$$ETS_ANNOTATION$$__Anno1({prop: 1}) + class myClass1 {} + `; + const textWriter = ts.createTextWriter('\n'); + let arkobfuscator = new ArkObfuscatorForTest(); + arkobfuscator.init(options); + const sourceFile: ts.SourceFile = ts.createSourceFile('demo.ts', fileContent, ts.ScriptTarget.ES2015, true, undefined, { + 'etsAnnotationsEnable': true + }, true); + let transformedResult: ts.TransformationResult = ts.transform(sourceFile, [renameIdentifierFactory], {}); + let ast: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile; + arkobfuscator.createObfsPrinter(ast.isDeclarationFile).writeFile(ast, textWriter, undefined); + const actualContent = textWriter.getText(); + const expectContent = ` + @ns.__$$ETS_ANNOTATION$$__g({ prop: 1 }) + class myClass1 {} + `; + assert.strictEqual(compareStringsIgnoreNewlines(actualContent, expectContent), true); + PropCollections.clearPropsCollections(); + }); }); }); diff --git a/arkguard/test/ut/utils/ApiExtractor.spec.ts b/arkguard/test/ut/utils/ApiExtractor.spec.ts index 0f29756774df4f0bfe1b9963a446f8849bed3198..628598b86bf5eced441aa88919fdf94b6dd059b2 100644 --- a/arkguard/test/ut/utils/ApiExtractor.spec.ts +++ b/arkguard/test/ut/utils/ApiExtractor.spec.ts @@ -1091,6 +1091,22 @@ describe('test for ApiExtractor', function () { expect(AtKeepCollections.keepAsConsumer.propertyNames.has('globalFunc04')).to.be.true; expect(AtKeepCollections.keepAsConsumer.propertyNames.has('globalMyClass04')).to.be.true; }) + it('should collect atKeep names from annotation declarations if enabled', function () { + let filePath: string = 'test/ut/utils/apiTest_visitAtKeepNames/atKeepAnnotation.ets'; + AtKeepCollections.clear(); + scanProjectConfig.mEnableAtKeep = true; + collectApi(filePath, ApiExtractor.ApiType.PROJECT); + expect(AtKeepCollections.keepSymbol.globalNames.size).to.be.equal(2); + expect(AtKeepCollections.keepSymbol.globalNames.has('MyAnnotation01')).to.be.true; + expect(AtKeepCollections.keepSymbol.globalNames.has('MyAnnotation02')).to.be.true; + expect(AtKeepCollections.keepSymbol.propertyNames.size).to.be.equal(1); + expect(AtKeepCollections.keepSymbol.propertyNames.has('MyAnnotation02')).to.be.true; + expect(AtKeepCollections.keepAsConsumer.globalNames.size).to.be.equal(2); + expect(AtKeepCollections.keepAsConsumer.globalNames.has('MyAnnotation04')).to.be.true; + expect(AtKeepCollections.keepAsConsumer.globalNames.has('MyAnnotation05')).to.be.true; + expect(AtKeepCollections.keepAsConsumer.propertyNames.size).to.be.equal(1); + expect(AtKeepCollections.keepAsConsumer.globalNames.has('MyAnnotation05')).to.be.true; + }) it('should collect atKeep names from .ets', function () { let filePath: string = 'test/ut/utils/apiTest_visitAtKeepNames/atKeepTest01.ets'; AtKeepCollections.clear(); @@ -1200,5 +1216,15 @@ describe('test for ApiExtractor', function () { expect(fileWhiteList.fileKeepInfo.stringProperties.size).to.be.equal(0); expect(fileWhiteList.fileKeepInfo.structProperties.size).to.be.equal(0); }) + it('should collect decoratorMap if need scanDecorator', function () { + let filePath: string = 'test/ut/utils/apiTest_collectFileWhiteList/collectFileWhiteList02.ets'; + scanProjectConfig.scanDecorator = true; + collectApi(filePath, ApiExtractor.ApiType.PROJECT); + const fileWhiteList: FileWhiteList = projectWhiteListManager?.getFileWhiteListMap().get(filePath)!; + if (fileWhiteList?.bytecodeObfuscateKeepInfo?.decoratorMap) { + const decoratorKeys = Object.keys(fileWhiteList.bytecodeObfuscateKeepInfo.decoratorMap); + expect(decoratorKeys.length).to.be.greaterThan(0); + } + }) }) }); \ No newline at end of file diff --git a/arkguard/test/ut/utils/ApiReader.spec.ts b/arkguard/test/ut/utils/ApiReader.spec.ts index 3d0e7ed55e06bd35a9960aff206fefb9c334ab81..32563048f2542087916c4c90acfc52b65dc082fe 100644 --- a/arkguard/test/ut/utils/ApiReader.spec.ts +++ b/arkguard/test/ut/utils/ApiReader.spec.ts @@ -13,7 +13,12 @@ * limitations under the License. */ -import { readProjectPropertiesByCollectedPaths, ReseverdSetForArkguard } from '../../../src/common/ApiReader'; +import { + readProjectPropertiesByCollectedPaths, + ReseverdSetForArkguard, + scanProjectConfig, + initScanProjectConfig +} from '../../../src/common/ApiReader'; import { assert, expect } from 'chai'; import { NameGeneratorType } from '../../../src/generator/NameFactory'; import { @@ -40,7 +45,7 @@ describe('test for ApiReader', function () { mRenameProperties: true, mKeepStringProperty: false, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -88,7 +93,7 @@ describe('test for ApiReader', function () { mRenameProperties: true, mKeepStringProperty: false, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -142,7 +147,7 @@ describe('test for ApiReader', function () { mRenameProperties: false, mKeepStringProperty: false, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -181,7 +186,7 @@ describe('test for ApiReader', function () { mRenameProperties: false, mKeepStringProperty: false, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -270,7 +275,7 @@ describe('test for ApiReader', function () { mRenameProperties: true, mKeepStringProperty: false, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -360,7 +365,7 @@ describe('test for ApiReader', function () { mKeepStringProperty: false, mTopLevel: true, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -396,7 +401,7 @@ describe('test for ApiReader', function () { mKeepStringProperty: false, mTopLevel: true, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -486,7 +491,7 @@ describe('test for ApiReader', function () { mKeepStringProperty: false, mTopLevel: false, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -630,7 +635,7 @@ describe('test for ApiReader', function () { mKeepStringProperty: false, mTopLevel: true, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -776,7 +781,7 @@ describe('test for ApiReader', function () { mKeepStringProperty: false, mTopLevel: true, mNameGeneratorType: NameGeneratorType.ORDERED, - mReservedNames: [], + mReservedNames: [], mReservedToplevelNames: [] } }; @@ -876,5 +881,58 @@ describe('test for ApiReader', function () { expect(fileWhiteList.fileKeepInfo.exported.propertyNames.has('otherElement2')).to.be.false; expect(fileWhiteList.fileKeepInfo.exported.propertyNames.has('o2')).to.be.true; }); + it('decorate collect test', function () { + const filePath = 'test/ut/utils/apiTest_collectFileWhiteList/collectFileWhiteList02.ets' + const fileList: Set = new Set([filePath]); + let config: IOptions = { + mNameObfuscation: { + mEnable: true, + mReservedProperties: [], + mRenameProperties: true, + mKeepStringProperty: false, + mTopLevel: false, + mNameGeneratorType: NameGeneratorType.ORDERED, + mReservedNames: [], + mReservedToplevelNames: [] + } + }; + let cachePath = 'test/ut/utils/obfuscation'; + initProjectWhiteListManager(cachePath, false, false); + let projectAndLibs: ReseverdSetForArkguard = + readProjectPropertiesByCollectedPaths(fileList, + { + mNameObfuscation: config.mNameObfuscation, + mExportObfuscation: true, + mKeepFileSourceCode: { + mKeepSourceOfPaths: new Set(), + mkeepFilesAndDependencies: new Set(), + } + }, true, true); + const fileWhiteList: FileWhiteList = projectWhiteListManager!.getFileWhiteListMap().get(filePath)!; + if (fileWhiteList?.bytecodeObfuscateKeepInfo?.decoratorMap) { + const decoratorKeys = Object.keys(fileWhiteList.bytecodeObfuscateKeepInfo.decoratorMap); + expect(decoratorKeys.length).to.be.greaterThan(0); + } + }); + }); + + describe('test initScanProjectConfig', function () { + it('scanDecorator is false', function () { + let customProfiles = {} + initScanProjectConfig(customProfiles, false, false) + expect(scanProjectConfig.scanDecorator).to.be.false; + }); + + it('scanDecorator is default', function () { + let customProfiles = {} + initScanProjectConfig(customProfiles, false) + expect(scanProjectConfig.scanDecorator).to.be.false; + }); + + it('scanDecorator is true', function () { + let customProfiles = {} + initScanProjectConfig(customProfiles, false, true) + expect(scanProjectConfig.scanDecorator).to.be.true; + }); }); }); \ No newline at end of file diff --git a/arkguard/test/ut/utils/KeepParameterUtils.spec.ts b/arkguard/test/ut/utils/KeepParameterUtils.spec.ts index 9c1e22f976a22e8c704a6449af40ebb7d9428cc5..5942689068cb9b4ad637a34ad6fa867d5a8b27af 100644 --- a/arkguard/test/ut/utils/KeepParameterUtils.spec.ts +++ b/arkguard/test/ut/utils/KeepParameterUtils.spec.ts @@ -212,8 +212,8 @@ describe('Tester Cases for shouldKeepParameter.', function () { it('Tester 2-10: When node is method and method name is not kept, shouldKeepParameter returns false', function () { let content = `declare class A { - constructor(para1: number); - method(para2: number): void; + constructor(para11: number); + method1(para12: number): void; }`; const ast = ts.createSourceFile(path, content, ts.ScriptTarget.ES2015, true); let method: ts.MethodDeclaration = (ast.statements[0] as ts.ClassDeclaration).members[1] as ts.MethodDeclaration; diff --git a/arkguard/test/ut/utils/NodeUtils.spec.ts b/arkguard/test/ut/utils/NodeUtils.spec.ts index ff2672b37ec77148a7e5a75b13f2e583b5ee3d87..5411595ce4413e78065c4131a946725faac968ac 100644 --- a/arkguard/test/ut/utils/NodeUtils.spec.ts +++ b/arkguard/test/ut/utils/NodeUtils.spec.ts @@ -581,4 +581,47 @@ describe('test for NodeUtils', function () { expect(hasExportModifier(sourceFile.statements[0])).to.be.true; }) }) + + describe('test for isObjectLiteralInAnnotation', function () { + it('should return false when node is not ObjectLiteral', function () { + const node = ts.factory.createObjectBindingPattern([]); + expect(NodeUtils.isObjectLiteralInAnnotation(node, '.d.ets')).to.be.false; + }) + it('should return true if annotation is in .d.ets files', function () { + const node = ts.factory.createObjectLiteralExpression( + [ts.factory.createPropertyAssignment( + ts.factory.createIdentifier("a"), + ts.factory.createNumericLiteral("1") + )], + false + ); + const expr = ts.factory.createCallExpression( + ts.factory.createIdentifier("Anno1"), + undefined, + [node] + ); + (node as Mutable).parent = expr; + const decorator = ts.factory.createDecorator(expr); + (expr as Mutable).parent = decorator; + expect(NodeUtils.isObjectLiteralInAnnotation(node, '.d.ets')).to.be.true; + }) + it('should return true if annotation is in .ts files and with annotationPrefix', function () { + const node = ts.factory.createObjectLiteralExpression( + [ts.factory.createPropertyAssignment( + ts.factory.createIdentifier("a"), + ts.factory.createNumericLiteral("1") + )], + false + ); + const expr = ts.factory.createCallExpression( + ts.factory.createIdentifier("__$$ETS_ANNOTATION$$__Anno1"), + undefined, + [node] + ); + (node as Mutable).parent = expr; + const decorator = ts.factory.createDecorator(expr); + (expr as Mutable).parent = decorator; + expect(NodeUtils.isObjectLiteralInAnnotation(node, '.ts')).to.be.true; + }) +}) }) \ No newline at end of file diff --git a/arkguard/test/ut/utils/PrinterTimeAndmemUtils.spec.ts b/arkguard/test/ut/utils/PrinterTimeAndmemUtils.spec.ts index 4e7c2ce735dd3957d42034a478d5803a8f69030a..a3675c328738d2c8ad03a09490b8fba788936e0c 100644 --- a/arkguard/test/ut/utils/PrinterTimeAndmemUtils.spec.ts +++ b/arkguard/test/ut/utils/PrinterTimeAndmemUtils.spec.ts @@ -16,20 +16,23 @@ import * as fs from 'fs'; import * as path from 'path'; import { + PerfMode, TimeAndMemTimeTracker, clearTimeAndMemPrinterData, + configurePerformancePrinter, + disablePrinterTimeAndMemConfig, enableTimeAndMemoryPrint, endSingleFileForMoreTimeEvent, getObfuscationCacheDir, getMemoryPerformanceData, getTimePerformanceData, initPerformanceTimeAndMemPrinter, + initPrinterTimeAndMemConfig, startSingleFileForMoreTimeEvent, writeTimeAndMemoryPerformanceData, } from '../../../src/utils/PrinterTimeAndMemUtils'; import { expect } from 'chai'; import { performanceTimeAndMemPrinter } from '../../../src/ArkObfuscator'; -import type { IOptions } from '../../../src/configs/IOptions'; import { printerTimeAndMemDataConfig } from '../../../src/initialization/Initializer'; describe('test Cases for .', function () { @@ -67,35 +70,50 @@ describe('test Cases for .', function () { }); describe('Tester Cases for ', () => { - it('Printer config is not set', () => { - const mCustomProfiles: IOptions = {}; - initPerformanceTimeAndMemPrinter(mCustomProfiles); - expect(performanceTimeAndMemPrinter.filesPrinter).to.be.undefined; + it('should block performance printer when mTimeAndMemPrinter is false', () => { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = false; + performanceTimeAndMemPrinter.singleFilePrinter = new TimeAndMemTimeTracker(); + performanceTimeAndMemPrinter.filesPrinter = new TimeAndMemTimeTracker(); + + initPerformanceTimeAndMemPrinter(); + expect(performanceTimeAndMemPrinter.singleFilePrinter).to.be.undefined; - }); - - it('Printer config is set all false', () => { - const mCustomProfiles: IOptions = { - mPerformanceTimeAndMemPrinter: { - mFilesPrinter: false, - mSingleFilePrinter: false, - }, - }; - initPerformanceTimeAndMemPrinter(mCustomProfiles); expect(performanceTimeAndMemPrinter.filesPrinter).to.be.undefined; - expect(performanceTimeAndMemPrinter.singleFilePrinter).to.be.undefined; }); - - it('Printer config is set not all false', () => { - const mCustomProfiles: IOptions = { - mPerformanceTimeAndMemPrinter: { - mFilesPrinter: false, - mSingleFilePrinter: true, - }, - }; - initPerformanceTimeAndMemPrinter(mCustomProfiles); + + it('should not block performance printer when mTimeAndMemPrinter is true', () => { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = true; + performanceTimeAndMemPrinter.singleFilePrinter = new TimeAndMemTimeTracker(); + performanceTimeAndMemPrinter.filesPrinter = new TimeAndMemTimeTracker(); + + initPerformanceTimeAndMemPrinter(); + + expect(performanceTimeAndMemPrinter.singleFilePrinter).to.not.be.undefined; expect(performanceTimeAndMemPrinter.filesPrinter).to.not.be.undefined; + }); + }); + + describe('Tester Cases for ', () => { + it('should configure performance printer for advanced mode', () => { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = false; + performanceTimeAndMemPrinter.singleFilePrinter = undefined; + performanceTimeAndMemPrinter.filesPrinter = undefined; + + configurePerformancePrinter(PerfMode.ADVANCED); + expect(performanceTimeAndMemPrinter.singleFilePrinter).to.not.be.undefined; + expect(performanceTimeAndMemPrinter.filesPrinter).to.not.be.undefined; + expect(printerTimeAndMemDataConfig.mTimeAndMemPrinter).to.be.true; + }); + + it('should block performance printer for normal mode', () => { + performanceTimeAndMemPrinter.singleFilePrinter = new TimeAndMemTimeTracker(); + performanceTimeAndMemPrinter.filesPrinter = new TimeAndMemTimeTracker(); + + configurePerformancePrinter(PerfMode.NORMAL); + + expect(performanceTimeAndMemPrinter.singleFilePrinter).to.be.undefined; + expect(performanceTimeAndMemPrinter.filesPrinter).to.be.undefined; }); }); @@ -149,6 +167,22 @@ describe('test Cases for .', function () { }); }); + describe('Tester Cases for ', () => { + it('start a initPrinterTimeAndMemConfig', () => { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = false; + initPrinterTimeAndMemConfig(); + expect(printerTimeAndMemDataConfig.mTimeAndMemPrinter).to.be.true; + }); + }); + + describe('Tester Cases for ', () => { + it('start a disablePrinterTimeAndMemConfig', () => { + printerTimeAndMemDataConfig.mTimeAndMemPrinter = true; + disablePrinterTimeAndMemConfig(); + expect(printerTimeAndMemDataConfig.mTimeAndMemPrinter).to.be.false; + }); + }); + describe('Tester Cases for ', () => { it('start a singleFile event for more timeEvent when mMoreTimePrint is true', () => { if (!performanceTimeAndMemPrinter.singleFilePrinter) { @@ -273,6 +307,7 @@ describe('test Cases for .', function () { }); await enableTimeAndMemoryPrint(); + await new Promise(resolve => setTimeout(resolve, 100)); expect(fs.existsSync(timePerformanceFilePath)).to.be.true; expect(fs.existsSync(memoryPerformanceFilePath)).to.be.true; @@ -281,6 +316,11 @@ describe('test Cases for .', function () { describe('Tester Cases for ', () => { it('Write file error', () => { + const projectConfig = { + obfuscationOptions: { + obfuscationCacheDir: 'test/', + }, + }; const data = [ { 'name': 'BreakpointConstants.ts', @@ -289,6 +329,7 @@ describe('test Cases for .', function () { }, ]; const fileName = ''; + getObfuscationCacheDir(projectConfig); expect(writeTimeAndMemoryPerformanceData(data, fileName)).to.be.throw; }); }); diff --git a/arkguard/test/ut/utils/ProjectCollections.spec.ts b/arkguard/test/ut/utils/ProjectCollections.spec.ts index f1f6dcd6b3e3c686c2bb4d6eb3fe959e7e70727d..1695ac1e82cb370310c4b07b3b65c05e355a7d16 100644 --- a/arkguard/test/ut/utils/ProjectCollections.spec.ts +++ b/arkguard/test/ut/utils/ProjectCollections.spec.ts @@ -26,7 +26,7 @@ import { FileWhiteList, FileContent } from '../../../src/utils/ProjectCollections'; -import { AtKeepCollections, UnobfuscationCollections } from '../../../src/utils/CommonCollections'; +import { AtIntentCollections, AtKeepCollections, UnobfuscationCollections } from '../../../src/utils/CommonCollections'; import { ApiExtractor } from '../../../src/common/ApiExtractor' import { FileUtils } from '../../../src/utils/FileUtils'; import * as fs from 'fs'; @@ -113,6 +113,8 @@ describe('test for CommonCollections', function () { expect(fileWhiteLists.fileKeepInfo.exported?.globalNames.size).to.be.equal(0); expect(fileWhiteLists.fileKeepInfo.enumProperties.size).to.be.equal(0); expect(fileWhiteLists.fileKeepInfo.stringProperties.size).to.be.equal(0); + expect(fileWhiteLists.fileKeepInfo.arkUIKeepInfo?.propertyNames.size).to.be.equal(0); + expect(fileWhiteLists.fileKeepInfo.arkUIKeepInfo?.globalNames.size).to.be.equal(0); expect(fileWhiteLists.fileReservedInfo.enumProperties.size).to.be.equal(0); expect(fileWhiteLists.fileReservedInfo.propertyParams.size).to.be.equal(0); }); @@ -159,6 +161,8 @@ describe('test for CommonCollections', function () { fileWhilteListTemp.fileKeepInfo.exported.globalNames.add('test7'); fileWhilteListTemp.fileKeepInfo.exported.propertyNames.add('test8'); fileWhilteListTemp.fileKeepInfo.stringProperties.add('test9'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.globalNames.add('test111'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.propertyNames.add('test112'); fileWhilteListTemp.fileReservedInfo.enumProperties.add('test10'); fileWhilteListTemp.fileReservedInfo.propertyParams.add('test11'); const fileWhilteList: FileWhiteList | undefined = projectWhiteListManagerForTest.getFileWhiteListMap().get('testPath3'); @@ -171,6 +175,8 @@ describe('test for CommonCollections', function () { expect(fileWhilteList?.fileKeepInfo.exported.globalNames.has('test7')).to.be.true; expect(fileWhilteList?.fileKeepInfo.exported.propertyNames.has('test8')).to.be.true; expect(fileWhilteList?.fileKeepInfo.stringProperties.has('test9')).to.be.true; + expect(fileWhilteList?.fileKeepInfo.arkUIKeepInfo.globalNames.has('test111')).to.be.true; + expect(fileWhilteList?.fileKeepInfo.arkUIKeepInfo.propertyNames.has('test112')).to.be.true; expect(fileWhilteList?.fileReservedInfo.enumProperties.has('test10')).to.be.true; expect(fileWhilteList?.fileReservedInfo.propertyParams.has('test11')).to.be.true; expect(fileWhilteListTemp.fileKeepInfo.keepSymbol?.globalNames.size).to.be.equal(1); @@ -184,6 +190,8 @@ describe('test for CommonCollections', function () { expect(fileWhilteListTemp.fileKeepInfo.stringProperties.size).to.be.equal(1); expect(fileWhilteListTemp.fileReservedInfo.enumProperties.size).to.be.equal(1); expect(fileWhilteListTemp.fileReservedInfo.propertyParams.size).to.be.equal(1); + expect(fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.globalNames.size).to.be.equal(1); + expect(fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.propertyNames.size).to.be.equal(1); }); it('should not collect atKeep if not enabled', () => { let projectWhiteListManager = new ProjectWhiteListManager(cachePath, false, false); @@ -198,6 +206,8 @@ describe('test for CommonCollections', function () { fileWhilteListTemp.fileKeepInfo.exported.globalNames.add('test7'); fileWhilteListTemp.fileKeepInfo.exported.propertyNames.add('test8'); fileWhilteListTemp.fileKeepInfo.stringProperties.add('test9'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.globalNames.add('test111'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.propertyNames.add('test112'); fileWhilteListTemp.fileReservedInfo.enumProperties.add('test10'); fileWhilteListTemp.fileReservedInfo.propertyParams.add('test11'); const fileWhilteList: FileWhiteList | undefined = projectWhiteListManager.getFileWhiteListMap().get('testPath4'); @@ -210,6 +220,8 @@ describe('test for CommonCollections', function () { expect(fileWhilteList?.fileKeepInfo.exported.globalNames.has('test7')).to.be.true; expect(fileWhilteList?.fileKeepInfo.exported.propertyNames.has('test8')).to.be.true; expect(fileWhilteList?.fileKeepInfo.stringProperties.has('test9')).to.be.true; + expect(fileWhilteList?.fileKeepInfo.arkUIKeepInfo.globalNames.has('test111')).to.be.true; + expect(fileWhilteList?.fileKeepInfo.arkUIKeepInfo.propertyNames.has('test112')).to.be.true; expect(fileWhilteList?.fileReservedInfo.enumProperties.has('test10')).to.be.true; expect(fileWhilteList?.fileReservedInfo.propertyParams.has('test11')).to.be.true; }); @@ -236,6 +248,8 @@ describe('test for CommonCollections', function () { fileWhilteListTemp.fileKeepInfo.exported.globalNames.add('test7'); fileWhilteListTemp.fileKeepInfo.exported.propertyNames.add('test8'); fileWhilteListTemp.fileKeepInfo.stringProperties.add('test9'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo?.globalNames.add('test111'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo?.propertyNames.add('test112'); fileWhilteListTemp.fileReservedInfo.enumProperties.add('test10'); fileWhilteListTemp.fileReservedInfo.propertyParams.add('test11'); projectWhiteListManager.setCurrentCollector('testPath2'); @@ -262,6 +276,10 @@ describe('test for CommonCollections', function () { expect(UnobfuscationCollections.reservedStrProp.size==0).to.be.true; expect(ApiExtractor.mConstructorPropertySet.size==0).to.be.true; expect(ApiExtractor.mEnumMemberSet.size==0).to.be.true; + expect(AtIntentCollections.globalNames.size==1).to.be.true; + expect(AtIntentCollections.propertyNames.size==1).to.be.true; + expect(AtIntentCollections.globalNames.has('test111')).to.be.true; + expect(AtIntentCollections.propertyNames.has('test112')).to.be.true; }); it('should update fileWhiteLists and projectWhiteList if is incremental(project white list changed)', () => { let projectWhiteListManager = new ProjectWhiteListManager(cachePath, true, true); @@ -281,6 +299,8 @@ describe('test for CommonCollections', function () { fileWhilteListTemp.fileKeepInfo.exported.globalNames.add('test7'); fileWhilteListTemp.fileKeepInfo.exported.propertyNames.add('test8'); fileWhilteListTemp.fileKeepInfo.stringProperties.add('test9'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.globalNames.add('test122'); + fileWhilteListTemp.fileKeepInfo.arkUIKeepInfo.propertyNames.add('test123'); fileWhilteListTemp.fileReservedInfo.enumProperties.add('test10'); fileWhilteListTemp.fileReservedInfo.propertyParams.add('test11'); fileWhilteListTemp.fileReservedInfo.propertyParams.add('test31'); @@ -313,6 +333,8 @@ describe('test for CommonCollections', function () { expect(ApiExtractor.mConstructorPropertySet.has('test31')).to.be.true; expect(UnobfuscationCollections.reservedExportName.has('test33')).to.be.true; expect(UnobfuscationCollections.reservedExportNameAndProp.has('test12')).to.be.false; + expect(AtIntentCollections.globalNames.has('test122')).to.be.true; + expect(AtIntentCollections.propertyNames.has('test123')).to.be.true; }); it('should update fileWhiteLists and projectWhiteList if is incremental(project white list not changed)', () => { let projectWhiteListManager = new ProjectWhiteListManager(cachePath, true, true); @@ -332,6 +354,24 @@ describe('test for CommonCollections', function () { expect(projectWhiteListManager.getShouldReObfuscate()).to.be.false; }); }); + + describe('test for createProjectWhiteList when bytecodeObfuscate enable', function () { + it('should add property decorated to projectWhiteList when bytecodeObfuscate enable)', () => { + let projectWhiteListManager = new ProjectWhiteListManager(cachePath, false, false); + projectWhiteListManager.setCurrentCollector("testPath5") + const fileWhiteLists = projectWhiteListManager.createFileWhiteList(); + fileWhiteLists.bytecodeObfuscateKeepInfo = { + "decoratorMap": { + "Track": ["prop1"] + } + }; + projectWhiteListManager.getFileWhiteListMap().set("testPath5", fileWhiteLists); + projectWhiteListManager.createOrUpdateWhiteListCaches(); + const cacheContent = fs.readFileSync(projectWhiteListManager.getProjectWhiteListCachePath(), 'utf-8'); + const parsedCache = JSON.parse(cacheContent); + expect(parsedCache.projectKeepInfo.globalNames).to.include("prop1"); + }); + }) }) describe('test for FilePathManager', function () { diff --git a/arkguard/test/ut/utils/ScopeAnalyzer.spec.ts b/arkguard/test/ut/utils/ScopeAnalyzer.spec.ts index ed10c4ec266e3d5a92ce9832a2ca64cf61e61ee0..a9be991b62ad28f0994185cffb25638e89498b37 100644 --- a/arkguard/test/ut/utils/ScopeAnalyzer.spec.ts +++ b/arkguard/test/ut/utils/ScopeAnalyzer.spec.ts @@ -317,7 +317,7 @@ describe('ScopeAnalyzer ut', function () { sourceFile = createSourceFile(newFilePath, fileContent, ScriptTarget.ES2015, true); checker = TypeUtils.createChecker(sourceFile); scopeManager = createScopeManager(); - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, newFilePath); } describe('analyze', function () { @@ -456,7 +456,7 @@ describe('ScopeAnalyzer ut', function () { let sourceFile = createSourceFile(filePath, fileContent, ScriptTarget.ES2015, true); let checker = TypeUtils.createChecker(sourceFile); let scopeManager = createScopeManager(); - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, filePath); const functionDeclaration = sourceFile.statements[0] as FunctionDeclaration; const parameter = functionDeclaration.parameters[0] as ParameterDeclaration; @@ -472,7 +472,7 @@ describe('ScopeAnalyzer ut', function () { let sourceFile = createSourceFile(filePath, fileContent, ScriptTarget.ES2015, true); let checker = TypeUtils.createChecker(sourceFile); let scopeManager = createScopeManager(); - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, filePath); it('getReservedNames', function () { const reservedNames = scopeManager.getReservedNames(); assert.strictEqual(reservedNames.size === 0, true); @@ -542,7 +542,7 @@ describe('ScopeAnalyzer ut', function () { let sourceFile = createSourceFile(filePath, fileContent, ScriptTarget.ES2015, true); let checker = TypeUtils.createChecker(sourceFile); let scopeManager = createScopeManager(); - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, filePath); it('getReservedNames', function () { const reservedNames = scopeManager.getReservedNames(); @@ -581,13 +581,13 @@ describe('ScopeAnalyzer ut', function () { let scopeManager = createScopeManager(); it('exportObfuscation is false', function () { - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, filePath); const rootScope = scopeManager.getRootScope(); assert.deepEqual(rootScope.defs.size, 0); }); it('exportObfuscation is true', function () { - scopeManager.analyze(sourceFile, checker, true); + scopeManager.analyze(sourceFile, checker, true, filePath); const rootScope = scopeManager.getRootScope(); assert.strictEqual(rootScope.defs.size, 1); }); @@ -623,7 +623,7 @@ describe('ScopeAnalyzer ut', function () { let sourceFile = createSourceFile(filePath, fileContent, ScriptTarget.ES2015, true); let checker = TypeUtils.createChecker(sourceFile); let scopeManager = createScopeManager(); - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, filePath); it('getReservedNames', function () { const reservedNames = scopeManager.getReservedNames(); @@ -666,7 +666,7 @@ describe('ScopeAnalyzer ut', function () { let sourceFile = createSourceFile(filePath, fileContent, ScriptTarget.ES2015, true); let checker = TypeUtils.createChecker(sourceFile); let scopeManager = createScopeManager(); - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, filePath); it('getReservedNames', function () { const reservedNames = scopeManager.getReservedNames(); @@ -701,7 +701,7 @@ describe('ScopeAnalyzer ut', function () { let sourceFile = createSourceFile(filePath, fileContent, ScriptTarget.ES2015, true); let checker = TypeUtils.createChecker(sourceFile); let scopeManager = createScopeManager(); - scopeManager.analyze(sourceFile, checker, false); + scopeManager.analyze(sourceFile, checker, false, filePath); it('getReservedNames', function () { const reservedNames = scopeManager.getReservedNames(); diff --git a/arkguard/test/ut/utils/apiTest_collectFileWhiteList/collectFileWhiteList02.ets b/arkguard/test/ut/utils/apiTest_collectFileWhiteList/collectFileWhiteList02.ets new file mode 100644 index 0000000000000000000000000000000000000000..a6464b217cfcc049996e4aad63162e0e64cfa488 --- /dev/null +++ b/arkguard/test/ut/utils/apiTest_collectFileWhiteList/collectFileWhiteList02.ets @@ -0,0 +1,8 @@ +@ObservedV2 +class son{ + @Trace aaaa:number=100; +} + +class father{ + bbb:number=100; +} \ No newline at end of file diff --git a/arkguard/test/ut/utils/apiTest_visitAtKeepNames/atKeepAnnotation.ets b/arkguard/test/ut/utils/apiTest_visitAtKeepNames/atKeepAnnotation.ets new file mode 100644 index 0000000000000000000000000000000000000000..c78baa7d212e30fdf4556887babdd3baa3b3fbaa --- /dev/null +++ b/arkguard/test/ut/utils/apiTest_visitAtKeepNames/atKeepAnnotation.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// @KeepSymbol +@interface MyAnnotation01 { + authorName: string; +} + +// @KeepSymbol +export @interface MyAnnotation02 { + authorName: string; +} + +@interface MyAnnotation03 { + // @KeepSymbol + authorName: string; +} + +// @KeepAsConsumer +@interface MyAnnotation04 { + authorName: string; +} + +// @KeepAsConsumer +export @interface MyAnnotation05 { + authorName: string; +} + +@interface MyAnnotation06 { + // @KeepAsConsumer + authorName: string; +} \ No newline at end of file diff --git a/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected01.json b/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected01.json index 9112b78b8c162e2b22640688812abe5562b5a399..6bde5ff86f41a23d37e29854d37ad3d97906b01f 100644 --- a/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected01.json +++ b/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected01.json @@ -35,7 +35,15 @@ ], "stringProperties": [ "test9" - ] + ], + "arkUIKeepInfo": { + "propertyNames": [ + "test112" + ], + "globalNames": [ + "test111" + ] + } }, "fileReservedInfo": { "enumProperties": [ @@ -64,7 +72,11 @@ "globalNames": [] }, "enumProperties": [], - "stringProperties": [] + "stringProperties": [], + "arkUIKeepInfo": { + "propertyNames": [], + "globalNames": [] + } }, "fileReservedInfo": { "enumProperties": [], @@ -89,7 +101,11 @@ ] }, "enumProperties": [], - "stringProperties": [] + "stringProperties": [], + "arkUIKeepInfo": { + "propertyNames": [], + "globalNames": [] + } }, "fileReservedInfo": { "enumProperties": [], diff --git a/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected02.json b/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected02.json index f0d382095b9c07298d38c9d700aba35cb3ef92e6..419d982f190777835007520932081ad18917268c 100644 --- a/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected02.json +++ b/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected02.json @@ -35,7 +35,15 @@ ], "stringProperties": [ "test9" - ] + ], + "arkUIKeepInfo": { + "propertyNames": [ + "test112" + ], + "globalNames": [ + "test111" + ] + } }, "fileReservedInfo": { "enumProperties": [ @@ -64,7 +72,11 @@ ] }, "enumProperties": [], - "stringProperties": [] + "stringProperties": [], + "arkUIKeepInfo": { + "propertyNames": [], + "globalNames": [] + } }, "fileReservedInfo": { "enumProperties": [], @@ -108,7 +120,15 @@ ], "stringProperties": [ "test9" - ] + ], + "arkUIKeepInfo": { + "propertyNames": [ + "test123" + ], + "globalNames": [ + "test122" + ] + } }, "fileReservedInfo": { "enumProperties": [ diff --git a/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected03.json b/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected03.json index 809b11a7834e2585c2f32c6e871671a0abf6e7fd..af417be3794957d5ec09c6ccfcd765e3db28256d 100644 --- a/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected03.json +++ b/arkguard/test/ut/utils/obfuscation/fileWhiteLists_expected03.json @@ -35,7 +35,15 @@ ], "stringProperties": [ "test9" - ] + ], + "arkUIKeepInfo": { + "propertyNames": [ + "test112" + ], + "globalNames": [ + "test111" + ] + } }, "fileReservedInfo": { "enumProperties": [ @@ -64,7 +72,11 @@ ] }, "enumProperties": [], - "stringProperties": [] + "stringProperties": [], + "arkUIKeepInfo": { + "propertyNames": [], + "globalNames": [] + } }, "fileReservedInfo": { "enumProperties": [], @@ -108,7 +120,15 @@ ], "stringProperties": [ "test9" - ] + ], + "arkUIKeepInfo": { + "propertyNames": [ + "test123" + ], + "globalNames": [ + "test122" + ] + } }, "fileReservedInfo": { "enumProperties": [ @@ -143,7 +163,11 @@ "enumProperties": [ "test02" ], - "stringProperties": [] + "stringProperties": [], + "arkUIKeepInfo": { + "propertyNames": [], + "globalNames": [] + } }, "fileReservedInfo": { "enumProperties": [], diff --git a/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected01.json b/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected01.json index d7ce25e326a86bc8b3f0962365f9ddd08a4f3e47..a2a5d19ca71fef5d36055828a0216b533cbd7a8c 100644 --- a/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected01.json +++ b/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected01.json @@ -9,12 +9,14 @@ "test02", "test6", "test9", + "test112", "test12" ], "globalNames": [ "test1", "test3", "test7", + "test111", "test13" ] }, diff --git a/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected02.json b/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected02.json index 212230f3d0898b7467e954306840c9ab23a84caf..c3773352499cb6ebb61bea4d7330df463255b235 100644 --- a/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected02.json +++ b/arkguard/test/ut/utils/obfuscation/projectWhiteList_expected02.json @@ -8,14 +8,18 @@ "test8", "test02", "test6", - "test9" + "test9", + "test112", + "test123" ], "globalNames": [ "test1", "test3", "test7", + "test111", "test33", - "test32" + "test32", + "test122" ] }, "projectReservedInfo": { diff --git a/arkguard/tools/timesum.py b/arkguard/tools/timesum.py index 20781a7d79c0715ba9e931a608bd09d41c772a98..d7515007b4aed0330f5b43c39eff482d77dc2608 100644 --- a/arkguard/tools/timesum.py +++ b/arkguard/tools/timesum.py @@ -19,6 +19,8 @@ limitations under the License. from collections import defaultdict import json import logging +import os +import stat # Configure logging to display timestamps and messages logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(message)s") @@ -33,7 +35,8 @@ def gen_parent(data): """ # Sort the data by timestamp (ts) data = sorted(data, key=lambda x: x["ts"]) - for i in range(len(data)): + data_length = len(data) + for i in range(data_length): current = data[i] # Current event current_end = current["ts"] + current["dur"] # End time of the current event for j in range(i - 1, -1, -1): # Candidate parent event @@ -136,8 +139,12 @@ def re_gen_ts_and_dur(data_with_parent): flattened.extend(nodes) # Save the flattened data to a JSON file - with open("data.json", "w") as f: - json.dump(flattened, f, indent=2) + if os.path.exists('data.json'): + os.remove('data.json') + flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL + modes = stat.S_IWUSR | stat.S_IRUSR + with os.fdopen(os.open('data.json', flags, modes), 'w') as file: + json.dump(flattened, file, indent=2) return groups @@ -158,8 +165,8 @@ def group_by_parent(data): if __name__ == "__main__": # Load input data from a JSON file with open("timePerformanceData.json", "r") as f: - data = json.load(f) + datas = json.load(f) # Generate parent information for each event - data_with_parent = gen_parent(data) + data_with_parents = gen_parent(datas) # Regenerate timestamps and durations based on parent relationships - re_gen_ts_and_dur(data_with_parent) + re_gen_ts_and_dur(data_with_parents) diff --git a/bundle.json b/bundle.json index 142291a602d1816d52b25cde51f9854cbe80013b..3ea4b67716580490c83ee24a95b068b98b2402fd 100644 --- a/bundle.json +++ b/bundle.json @@ -1,5 +1,5 @@ { - "name": "@arkcompiller/ets_frontend", + "name": "@ohos/ets_frontend", "description": "支持应用TS/JS语言代码的编译,行为符合ArkUI框架需要的Strict模式的ES2015标准", "version": "3.1", "license": "Apache License 2.0", @@ -22,12 +22,11 @@ "runtime_core", "zlib", "bounds_checking_function", - "protobuf" + "protobuf", + "icu", + "abseil-cpp" ], - "third_party": [ - "json", - "icu" - ] + "third_party": [] }, "build": { "sub_component": [ @@ -48,8 +47,9 @@ } ], "test": [ - "//arkcompiler/ets_frontend/es2panda:es2abc_tests" + "//arkcompiler/ets_frontend/es2panda:es2abc_tests", + "//arkcompiler/ets_frontend/ets2panda/bindings/test:bindings_test" ] } } -} +} \ No newline at end of file diff --git a/codecheck_ignore.json b/codecheck_ignore.json index 775d3e87749d84a686e43295bed4f0abf0ba279e..a30bb19d2b134825596abb32890795d7089fd638 100755 --- a/codecheck_ignore.json +++ b/codecheck_ignore.json @@ -8,9 +8,18 @@ "test_ecma_bcopt": "*", "legacy_bin": "*", "merge_abc": "*", + "ets2panda/bindings/src": "*", + "ets2panda/driver/build_system/src": "*", "ets2panda/public/headers_parser": "*", "ets2panda/linter/arkanalyzer": "*", "ets2panda/linter/homecheck": "*", + "ets2panda/linter/build_linter.py": "*", + "ets2panda/linter/src/cli/CommandLineParser.ts": "*", + "ets2panda/linter/src/lib/TypeScriptLinter.ts": "*", + "ets2panda/linter/src/lib/autofixes/Autofixer.ts": "*", + "ets2panda/linter/src/lib/autofixes/QuasiEditor.ts": "*", + "ets2panda/linter/src/lib/statistics/scan/ProblemStatisticsCommonFunction.ts": "*", + "ets2panda/linter/src/lib/utils/functions/ConfiguredRulesProcess.ts": "*", "*": ["G.CMT.03", "G.FMT.11", "G.NAM.03", "huge_headerfile", "huge_non_headerfile", "bc-30001"] } diff --git a/es2panda/BUILD.gn b/es2panda/BUILD.gn index d7f663a2bb92b56aac0ea96c668bfc51ea120271..56f0a55564f9829840842e4c3ca74afb81840ac9 100644 --- a/es2panda/BUILD.gn +++ b/es2panda/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -293,14 +293,18 @@ config("es2abc_config_src") { config("es2abc_config_common") { configs = [ "$ark_root:ark_config", - "$sdk_libc_secshared_config", "$ark_root/libpandafile:arkfile_public_config", "$ark_root/libpandabase:arkbase_public_config", "$ark_root/assembler:arkassembler_public_config", "$ark_root/abc2program:abc2program_public_config", - "$ark_third_party_root/json:nlohmann_json_config", ":es2abc_config_src", ] + if (defined(is_arkui_x) && is_arkui_x) { + configs += [ + "$sdk_libc_secshared_config", + "$ark_third_party_root/json:nlohmann_json_config", + ] + } if (enable_bytecode_optimizer) { defines = [ "ENABLE_BYTECODE_OPT" ] @@ -343,7 +347,11 @@ action_foreach("gen_keywords_headers") { # generate headers for es2panda compiler isa_gen = "${ark_root}/isa/gen.rb" -isa_gen_data = "$root_gen_dir/isa/isa.yaml" +if (defined(ohos_indep_compiler_enable) && ohos_indep_compiler_enable) { + isa_gen_data = "$root_build_dir/gen/isa/isa.yaml" +} else { + isa_gen_data = "$root_gen_dir/isa/isa.yaml" +} isa_gen_require = "${ark_root}/isa/isapi.rb" action_foreach("gen_isa_headers") { deps = [ "//arkcompiler/runtime_core/isa:isa_combine" ] @@ -361,11 +369,13 @@ action_foreach("gen_isa_headers") { outputs = [ "${generated_header_dir}/{{source_name_part}}" ] script = "scripts/gen_isa.sh" - inputs = [ - "${isa_gen}", - "${isa_gen_data}", - "${isa_gen_require}", - ] + if (defined(ohos_indep_compiler_enable) && !ohos_indep_compiler_enable) { + inputs = [ + "${isa_gen}", + "${isa_gen_data}", + "${isa_gen_require}", + ] + } args = [ "-g", rebase_path("${isa_gen}"), @@ -394,21 +404,25 @@ ohos_static_library("es2panda_lib") { "../merge_abc:panda_assembly_proto_public_config", ] - include_dirs = [ - "${target_out_dir}", - "//third_party/icu/icu4c/source/common", - "//third_party/icu/icu4c/source/i18n", - "//third_party/icu/icu4c/source", - ] + include_dirs = [ "${target_out_dir}" ] deps = [ ":gen_isa_headers", ":gen_keywords_headers", - "$ark_third_party_root/icu/icu4c:static_icuuc", "../merge_abc:panda_assembly_proto_static", ] + external_deps = [ sdk_libc_secshared_dep ] + if (ark_standalone_build || (defined(is_arkui_x) && is_arkui_x)) { + deps += [ "$ark_third_party_root/icu/icu4c:static_icuuc" ] + include_dirs += [ + "//third_party/icu/icu4c/source/common", + "//third_party/icu/icu4c/source/i18n", + "//third_party/icu/icu4c/source", + ] + } else { + external_deps += [ "icu:static_icuuc" ] + } - external_deps = [] if (!is_arkui_x) { external_deps += [ "json:nlohmann_json_static", @@ -451,7 +465,14 @@ ohos_static_library("es2panda_lib") { "-Wno-c++20-designator", "-Wno-implicit-fallthrough", ] - + if (defined(ohos_indep_compiler_enable) && ohos_indep_compiler_enable) { + external_deps += [ "runtime_core:libarkassembler_static" ] + if (enable_hilog) { + external_deps += [ "hilog:libhilog" ] + } + cflags += [ "-I" + rebase_path( + "$root_build_dir/gen/arkcompiler/runtime_core/compiler/generated") ] + } part_name = "ets_frontend" subsystem_name = "arkcompiler" } @@ -481,7 +502,30 @@ ohos_executable("es2panda") { "//arkcompiler/ets_frontend/merge_abc:panda_assembly_proto_static", ] - external_deps = [ "zlib:libz" ] + external_deps = [ + "json:nlohmann_json_static", + "zlib:libz", + sdk_libc_secshared_dep, + ] + + if (defined(ohos_indep_compiler_enable) && ohos_indep_compiler_enable) { + external_deps += [ + "abseil-cpp:absl_base_static", + "icu:shared_icuuc", + "runtime_core:libarkassembler_static", + ] + if (enable_hilog) { + external_deps += [ "hilog:libhilog" ] + } + cflags = [ + "-Wno-constant-conversion", + "-I" + rebase_path( + "$root_build_dir/gen/arkcompiler/runtime_core/bytecode_optimizer"), + "-I" + rebase_path( + "$root_build_dir/gen/arkcompiler/runtime_core/compiler/generated"), + ] + } + if (ark_standalone_build) { external_deps += [ "protobuf:protobuf_lite_static", diff --git a/es2panda/aot/emitFiles.cpp b/es2panda/aot/emitFiles.cpp index 10396d754610c0c05f3856e6da4a85b6d8babdde..121f0824f43a815d4c2ac6cb215cea27a2ff8fb3 100644 --- a/es2panda/aot/emitFiles.cpp +++ b/es2panda/aot/emitFiles.cpp @@ -49,13 +49,10 @@ void EmitFileQueue::Schedule() { ASSERT(jobsCount_ == 0); std::unique_lock lock(m_); - auto targetApi = options_->CompilerOptions().targetApiVersion; - auto targetSubApi = options_->CompilerOptions().targetApiSubVersion; if (mergeAbc_) { // generate merged abc - auto emitMergedAbcJob = new EmitMergedAbcJob(options_->CompilerOutput(), - options_->CompilerOptions().transformLib, progsInfo_, targetApi, targetSubApi); + auto emitMergedAbcJob = new EmitMergedAbcJob(options_, progsInfo_); // One job should be placed before the jobs on which it depends to prevent blocking jobs_.push_back(emitMergedAbcJob); jobsCount_++; @@ -65,6 +62,8 @@ void EmitFileQueue::Schedule() ScheduleEmitCacheJobs(emitMergedAbcJob); } } else { + auto targetApi = options_->CompilerOptions().targetApiVersion; + auto targetSubApi = options_->CompilerOptions().targetApiSubVersion; for (const auto &info: progsInfo_) { try { // generate multi abcs @@ -109,9 +108,11 @@ void EmitMergedAbcJob::Run() progs.push_back(&(info.second->program)); } + panda::pandasm::EmitterConfig emitConfig {targetApiVersion_, targetApiSubVersion_, + options_->CompilerOptions().isDebug, options_->CompilerOptions().fileThreadCount}; bool success = panda::pandasm::AsmEmitter::EmitPrograms( panda::os::file::File::GetExtendedFilePath(outputFileName_), progs, true, - targetApiVersion_, targetApiSubVersion_); + emitConfig); panda::Timer::timerEnd(panda::EVENT_EMIT_MERGED_PROGRAM, ""); diff --git a/es2panda/aot/emitFiles.h b/es2panda/aot/emitFiles.h index 9a223386c6741919cfc26cc7bef3efd565348038..f3d3ad2e78b307194375f647fc1956115bc80ff3 100644 --- a/es2panda/aot/emitFiles.h +++ b/es2panda/aot/emitFiles.h @@ -45,17 +45,19 @@ private: class EmitMergedAbcJob : public util::WorkerJob { public: - explicit EmitMergedAbcJob(const std::string &outputFileName, const std::string &transformLib, - const std::map &progsInfo, - uint8_t targetApi, std::string targetSubApi) - : outputFileName_(outputFileName), transformLib_(transformLib), - progsInfo_(progsInfo), targetApiVersion_(targetApi), targetApiSubVersion_(targetSubApi) {}; + explicit EmitMergedAbcJob(const std::unique_ptr &options, + const std::map &progsInfo) + : options_(options), outputFileName_(options->CompilerOutput()), + transformLib_(options->CompilerOptions().transformLib), + progsInfo_(progsInfo), targetApiVersion_(options->CompilerOptions().targetApiVersion), + targetApiSubVersion_(options->CompilerOptions().targetApiSubVersion) {}; NO_COPY_SEMANTIC(EmitMergedAbcJob); NO_MOVE_SEMANTIC(EmitMergedAbcJob); ~EmitMergedAbcJob() override = default; void Run() override; private: + const std::unique_ptr &options_; std::string outputFileName_; std::string transformLib_; const std::map &progsInfo_; diff --git a/es2panda/aot/options.cpp b/es2panda/aot/options.cpp index 0ae82fe65fdb6c60b9628bb340c07f2ff3dbccb1..3a4f766e5a064d40b9e26d26c797b459ce850f18 100644 --- a/es2panda/aot/options.cpp +++ b/es2panda/aot/options.cpp @@ -420,8 +420,8 @@ bool Options::Parse(int argc, const char **argv) "bc-min-version are enabled, only bc-version will take effects"); panda::PandArg bcMinVersion("bc-min-version", false, "Print ark bytecode minimum supported version"); // todo(huyunhui): change default api verion to 0 after refactoring - // Current api version is 18 - panda::PandArg targetApiVersion("target-api-version", 18, + // Current api version is 20 + panda::PandArg targetApiVersion("target-api-version", 20, "Specify the targeting api version for es2abc to generated the corresponding version of bytecode"); panda::PandArg targetBcVersion("target-bc-version", false, "Print the corresponding ark bytecode version"\ "for target api version. If both target-bc-version and bc-version are enabled, only target-bc-version"\ diff --git a/es2panda/binder/binder.cpp b/es2panda/binder/binder.cpp index 32b9e3809cb95483aee1f42278fc31916aca99e4..c26216945a93b8924f2a8439e2e3c1eb86f95a2c 100644 --- a/es2panda/binder/binder.cpp +++ b/es2panda/binder/binder.cpp @@ -757,6 +757,7 @@ void Binder::ResolveReference(const ir::AstNode *parent, ir::AstNode *childNode) } case ir::AstNodeType::SUPER_EXPRESSION: { VariableScope *varScope = scope_->EnclosingVariableScope(); + CHECK_NOT_NULL(varScope); varScope->AddFlag(VariableScopeFlags::USE_SUPER); ResolveReferences(childNode); @@ -844,6 +845,7 @@ void Binder::ResolveReference(const ir::AstNode *parent, ir::AstNode *childNode) if (Program()->Extension() == ScriptExtension::TS && (Program()->TargetApiVersion() < 11 || (!prop->IsStatic() && !prop->IsPrivate()))) { const ir::ScriptFunction *ctor = util::Helpers::GetContainingConstructor(prop); + CHECK_NOT_NULL(ctor); auto scopeCtx = LexicalScope::Enter(this, ctor->Scope()); ResolveReferences(childNode); break; diff --git a/es2panda/compiler/core/dynamicContext.cpp b/es2panda/compiler/core/dynamicContext.cpp index a6e2c3d60f869ed0da5b74792dce646fca4f63f2..5949319bc46e5e18f31266a8e77ba48570edd3f8 100644 --- a/es2panda/compiler/core/dynamicContext.cpp +++ b/es2panda/compiler/core/dynamicContext.cpp @@ -95,6 +95,17 @@ bool LexEnvContext::HasTryCatch() const return envScope_->HasEnv(); } +void LexEnvContext::HandleForUpdateDirectReturnContext() +{ + if (!envScope_->HasEnv()) { + return; + } + const auto *node = envScope_->Scope()->Node(); + if (node->IsForUpdateStatement()) { + pg_->PopLexEnv(node); + } +} + void LexEnvContext::AbortContext([[maybe_unused]] ControlFlowChange cfc, const util::StringView &targetLabel) { @@ -105,7 +116,8 @@ void LexEnvContext::AbortContext([[maybe_unused]] ControlFlowChange cfc, const auto *node = envScope_->Scope()->Node(); // Process the continue label in the ForUpdate Statement. if (node->IsForUpdateStatement()) { - if (targetLabel == LabelTarget::CONTINUE_LABEL || targetLabel == LabelTarget::BREAK_LABEL) { + if (targetLabel == LabelTarget::CONTINUE_LABEL || targetLabel == LabelTarget::BREAK_LABEL || + targetLabel == LabelTarget::RETURN_LABEL) { return; } diff --git a/es2panda/compiler/core/dynamicContext.h b/es2panda/compiler/core/dynamicContext.h index 3fa63347fd75b3c8d6fb343a2c89c3d4f7841f83..3ab8647bc270927d616d51862e0c195f537e84c6 100644 --- a/es2panda/compiler/core/dynamicContext.h +++ b/es2panda/compiler/core/dynamicContext.h @@ -125,6 +125,12 @@ public: { return tryEndFlag; } + /** + * Handle for update direct return context + * If the lexical environment context is in for update statement, pop the lexical environment + */ + void HandleForUpdateDirectReturnContext(); + private: VariableEnvScope *envScope_; CatchTable *catchTable_ {}; diff --git a/es2panda/compiler/core/emitter/emitter.cpp b/es2panda/compiler/core/emitter/emitter.cpp index 051e0d84d0fd7a81ac2b1da693f3fa65364a362c..3855d73498c1fc3809c821a5a5a9f66fbc519d3e 100644 --- a/es2panda/compiler/core/emitter/emitter.cpp +++ b/es2panda/compiler/core/emitter/emitter.cpp @@ -71,11 +71,15 @@ void FunctionEmitter::Generate(util::PatchFix *patchFixHelper) GenFunctionCatchTables(); GenLiteralBuffers(); GenConcurrentFunctionModuleRequests(); - GenAnnotations(); + if (pg_->Binder()->Program()->IsEnableAnnotations()) { + GenAnnotations(); + } if (patchFixHelper != nullptr) { patchFixHelper->ProcessFunction(pg_, func_, literalBuffers_); } - GenExpectedPropertyCountAnnotation(); + if (util::Helpers::IsEnableExpectedPropertyCountApiVersion(pg_->Binder()->Program()->TargetApiVersion())) { + GenExpectedPropertyCountAnnotation(); + } GenSlotNumberAnnotation(); if (pg_->Context()->IsMergeAbc()) { GenConcurrentModuleRequestsAnnotation(); @@ -207,11 +211,6 @@ void FunctionEmitter::GenInstructionDebugInfo(const IRNode *ins, panda::pandasm: if (pg_->IsDebug()) { size_t insLen = GetIRNodeWholeLength(ins); - if (insLen != 0) { - pandaIns->ins_debug.bound_left = offset_; - pandaIns->ins_debug.bound_right = offset_ + insLen; - } - offset_ += insLen; pandaIns->ins_debug.column_number = columnNum; } @@ -453,10 +452,9 @@ void FunctionEmitter::GenFunctionInstructions() func_->ins.reserve(pg_->Insns().size()); for (const auto *ins : pg_->Insns()) { - auto &pandaIns = func_->ins.emplace_back(); - - ins->Transform(&pandaIns); - GenInstructionDebugInfo(ins, &pandaIns); + auto *pandaIns = ins->Transform(); + func_->ins.emplace_back(pandaIns); + GenInstructionDebugInfo(ins, pandaIns); } } @@ -668,7 +666,9 @@ Emitter::Emitter(CompilerContext *context): source_lang_(context->SourceLang()) } AddSharedModuleRecord(context); AddScopeNamesRecord(context); - AddExpectedPropertyCountRecord(); + if (util::Helpers::IsEnableExpectedPropertyCountApiVersion(context->Binder()->Program()->TargetApiVersion())) { + AddExpectedPropertyCountRecord(); + } AddSlotNumberRecord(); if (context->IsMergeAbc()) { AddConcurrentModuleRequestsRecord(); @@ -1257,7 +1257,7 @@ void Emitter::DumpAsm(const panda::pandasm::Program *prog) ss << ") {" << std::endl; for (const auto &ins : func.ins) { - ss << (ins.set_label ? "" : "\t") << ins.ToString("", true, func.GetTotalRegs()) << std::endl; + ss << (ins->IsLabel() ? "" : "\t") << ins->ToString("", true, func.GetTotalRegs()) << std::endl; } ss << "}" << std::endl << std::endl; diff --git a/es2panda/compiler/core/emitter/emitter.h b/es2panda/compiler/core/emitter/emitter.h index f43cf2f36de5a70bce851154e7177481a1595fc3..7353567fc52414202740c3d32ba840b41e788a3a 100644 --- a/es2panda/compiler/core/emitter/emitter.h +++ b/es2panda/compiler/core/emitter/emitter.h @@ -34,7 +34,7 @@ namespace panda::pandasm { struct Program; struct Function; -struct Ins; +class Ins; struct Record; } // namespace panda::pandasm diff --git a/es2panda/compiler/core/pandagen.cpp b/es2panda/compiler/core/pandagen.cpp index 4806d01e945863fb973a04d9aea304d436751f2c..f2bb23e6996107fdacf3df580a268f0918f68058 100644 --- a/es2panda/compiler/core/pandagen.cpp +++ b/es2panda/compiler/core/pandagen.cpp @@ -105,7 +105,8 @@ void PandaGen::SetInSendable() size_t PandaGen::GetExpectedPropertyCount() const { - if (rootNode_->IsProgram()) { + if (rootNode_->IsProgram() || + !util::Helpers::IsEnableExpectedPropertyCountApiVersion(context_->Binder()->Program()->TargetApiVersion())) { return 0; } @@ -1267,6 +1268,15 @@ void PandaGen::ValidateClassDirectReturn(const ir::AstNode *node) BranchIfStrictNotUndefined(node, notUndefined); GetThis(func); ThrowIfSuperNotCorrectCall(func, 0); + + auto *iter = dynamicContext_; + while (iter) { + if (iter->Type() == DynamicContextType::LEX_ENV) { + auto *envContext = static_cast(iter); + envContext->HandleForUpdateDirectReturnContext(); + } + iter = iter->Prev(); + } Branch(node, condEnd); SetLabel(node, notUndefined); diff --git a/es2panda/compiler/debugger/debuginfoDumper.cpp b/es2panda/compiler/debugger/debuginfoDumper.cpp index 37d2beb5aaea490381b03d9ee91239ada5c06fb0..5bbbd2b5d716bc5260b8bdfe1cb4b9e6f9cacfff 100644 --- a/es2panda/compiler/debugger/debuginfoDumper.cpp +++ b/es2panda/compiler/debugger/debuginfoDumper.cpp @@ -55,7 +55,7 @@ void DebugInfoDumper::WrapArray(const char *name, const std::vector &array, b for (elem = array.begin(); elem != array.end(); ++elem) { Indent(); // NOLINTNEXTLINE - if constexpr (std::is_same_v) { + if constexpr (std::is_same_v) { WriteIns(*elem); // NOLINTNEXTLINE } else if constexpr (std::is_same_v) { @@ -86,25 +86,19 @@ void DebugInfoDumper::WrapArray(const char *name, const std::vector &array, b ss_ << "]" << PutComma(comma); } -void DebugInfoDumper::WriteIns(const pandasm::Ins &ins) +void DebugInfoDumper::WriteIns(const pandasm::InsPtr &ins) { ss_ << "{"; - { - pandasm::Ins insCopy; - insCopy.opcode = ins.opcode; - insCopy.set_label = ins.set_label; - insCopy.label = ins.label; - WriteProperty("opcode", insCopy.ToString()); - } + WriteProperty("opcode", ins->OpcodeToString()); indent_++; - WrapArray("regs", ins.regs); - WrapArray("ids", ins.ids); - WrapArray("imms", ins.imms); + WrapArray("regs", ins->Regs()); + WrapArray("ids", ins->Ids()); + WrapArray("imms", ins->Imms()); ss_ << std::endl; Indent(); ss_ << "\"label\": " - << "\"" << ins.label << "\","; - WritePosInfo(ins.ins_debug); + << "\"" << (ins->IsLabel() ? ins->Label() : "") << "\","; + WritePosInfo(ins->ins_debug); indent_--; Indent(); ss_ << "}"; @@ -129,8 +123,6 @@ void DebugInfoDumper::WritePosInfo(const pandasm::debuginfo::Ins &posInfo) ss_ << std::endl; Indent(); ss_ << "\"debug_pos_info\": {"; - WriteProperty("boundLeft", posInfo.bound_left); - WriteProperty("boundRight", posInfo.bound_right); WriteProperty("sourceLineNum", static_cast(posInfo.line_number), false); Indent(); ss_ << "}" << std::endl; diff --git a/es2panda/compiler/debugger/debuginfoDumper.h b/es2panda/compiler/debugger/debuginfoDumper.h index a9d0aecf5ad882c84432dd1283e0b584016b0e50..02a6dfbbbfdbaf9a87cf3448dc21797b60a1544c 100644 --- a/es2panda/compiler/debugger/debuginfoDumper.h +++ b/es2panda/compiler/debugger/debuginfoDumper.h @@ -36,7 +36,7 @@ public: private: template void WrapArray(const char *name, const std::vector &array, bool comma = true); - void WriteIns(const pandasm::Ins &ins); + void WriteIns(const pandasm::InsPtr &ins); void WriteMetaData(const std::vector &metaData); void WriteProperty(const char *key, const Value &value, bool comma = true); void WritePosInfo(const pandasm::debuginfo::Ins &posInfo); diff --git a/es2panda/compiler/templates/isa.h.erb b/es2panda/compiler/templates/isa.h.erb index 9d5137be16beb2f485a1461f27f1544316ad5ad3..eeaef9e919d300d1e05b3d62dac41860be398271 100644 --- a/es2panda/compiler/templates/isa.h.erb +++ b/es2panda/compiler/templates/isa.h.erb @@ -57,11 +57,9 @@ public: return 0; } - void Transform(pandasm::Ins *ins) const override + pandasm::Ins *Transform() const override { - ins->opcode = pandasm::Opcode::INVALID; - ins->set_label = true; - ins->label = id_; + return new pandasm::LabelIns(id_); } ICSlot SetIcSlot(IcSizeType currentSlot) override @@ -236,30 +234,21 @@ public: return <%= reg_cnt %>; } - void Transform(pandasm::Ins* ins) const override + pandasm::Ins *Transform() const override { - ins->opcode = pandasm::Opcode::<%= node_kind %>; -% if op_map['reg'].length != 0 - ins->regs.reserve(<%= op_map['reg'].length %>); -% end -% if op_map['imm'].length != 0 - ins->imms.reserve(<%= op_map['imm'].length %>); -% end -% if op_map['str'].length + op_map['lbl'].length != 0 - ins->ids.reserve(<%= op_map['str'].length + op_map['lbl'].length %>); -% end -% for reg in op_map['reg'] - ins->regs.emplace_back(<%= reg %>); -% end -% for imm in op_map['imm'] - ins->imms.emplace_back(<%= imm %>); -% end -% for str in op_map['str'] - ins->ids.emplace_back(<%= str %>.Mutf8()); -% end -% for lbl in op_map['lbl'] - ins->ids.emplace_back(<%= lbl %>->Id()); +% pa_ins_args_list = Array.new +% ctor_arg_list.each do |arg| +% type = arg.split(" ")[0] +% name = arg.split(" ")[1] +% if type == "util::StringView" +% pa_ins_args_list.push("#{name}_.Mutf8()") +% elsif type == "Label*" +% pa_ins_args_list.push("#{name}_->Id()") +% else +% pa_ins_args_list.push("#{name}_") +% end % end + return new pandasm::<%= class_name %>(<%= pa_ins_args_list.join(", ") %>); } ICSlot SetIcSlot(IcSizeType slot) override diff --git a/es2panda/es2abc_config.gni b/es2panda/es2abc_config.gni index 7f9c8c833a0653ee3e86f41759b99f239f16c40b..9427086588d14b3b6294d1dce362f7f525ffd18e 100644 --- a/es2panda/es2abc_config.gni +++ b/es2panda/es2abc_config.gni @@ -64,7 +64,17 @@ template("es2abc_gen_abc") { script = "${es2abc_root}/scripts/generate_js_bytecode.py" deps = extra_dependencies - deps += es2abc_build_deps + if (ark_standalone_build || is_arkui_x) { + deps += es2abc_build_deps + } else { + if (host_toolchain == toolchain_mac) { + external_deps = ["ets_frontend:es2panda($toolchain_mac)"] + } else if (host_toolchain == toolchain_win) { + external_deps = ["ets_frontend:es2panda(${host_toolchain})"] + } else { + external_deps = ["ets_frontend:es2panda($toolchain_linux)"] + } + } args = [ "--src-js", @@ -125,7 +135,15 @@ template("es2abc_gen_newest_abc") { script = "${es2abc_root}/scripts/generate_js_bytecode.py" deps = extra_dependencies - deps += es2abc_build_deps + if (host_toolchain == toolchain_mac) { + external_deps = ["ets_frontend:es2panda($toolchain_mac)"] + } else if (host_toolchain == toolchain_win) { + external_deps = ["ets_frontend:es2panda(${host_toolchain})"] + } else if (ark_standalone_build) { + deps += es2abc_build_deps + } else { + external_deps = ["ets_frontend:es2panda($toolchain_linux)"] + } args = [ "--src-js", diff --git a/es2panda/es2panda.cpp b/es2panda/es2panda.cpp index 3bb600c0385622e95f9e2a1bf4113dedacca6175..ddd62b5d9ed6c5e269071188dafac115873cdcd9 100644 --- a/es2panda/es2panda.cpp +++ b/es2panda/es2panda.cpp @@ -223,9 +223,9 @@ void Compiler::DumpAsm(const panda::pandasm::Program *prog) int Compiler::CompileFiles(CompilerOptions &options, std::map &progsInfo, panda::ArenaAllocator *allocator) { - util::SymbolTable *symbolTable = nullptr; + std::unique_ptr symbolTable; if (!options.patchFixOptions.symbolTable.empty() || !options.patchFixOptions.dumpSymbolTable.empty()) { - symbolTable = new util::SymbolTable(options.patchFixOptions.symbolTable, + symbolTable = std::make_unique(options.patchFixOptions.symbolTable, options.patchFixOptions.dumpSymbolTable); if (!symbolTable->Initialize(options.targetApiVersion, options.targetApiSubVersion)) { std::cerr << "Failed to initialize for Hotfix." << std::endl; @@ -236,7 +236,7 @@ int Compiler::CompileFiles(CompilerOptions &options, bool failed = false; std::unordered_set optimizationPendingProgs; auto queue = new compiler::CompileFileQueue(options.fileThreadCount, &options, progsInfo, - optimizationPendingProgs, symbolTable, allocator); + optimizationPendingProgs, symbolTable.get(), allocator); try { queue->Schedule(); @@ -256,8 +256,6 @@ int Compiler::CompileFiles(CompilerOptions &options, if (!options.patchFixOptions.dumpSymbolTable.empty()) { symbolTable->WriteSymbolTable(); } - delete symbolTable; - symbolTable = nullptr; } if (options.requireGlobalOptimization) { diff --git a/es2panda/ir/base/annotation.h b/es2panda/ir/base/annotation.h index ce9c16f1721cc92318dbf4acff85b96bbbf93199..6df31ff5a5b4033782bcc32247f1b670f5ffadaf 100644 --- a/es2panda/ir/base/annotation.h +++ b/es2panda/ir/base/annotation.h @@ -20,8 +20,7 @@ #include #include #include - -#include +#include namespace panda::es2panda::compiler { class PandaGen; @@ -48,9 +47,7 @@ public: name_.insert(0, "."); expr = expr->AsMemberExpression()->Object(); } - name_.insert(0, expr->AsIdentifier()->Name().Utf8()); - name_.erase(0, std::strlen(annotationPrefix)); nameView_ = util::StringView(name_); } diff --git a/es2panda/ir/expressions/callExpression.cpp b/es2panda/ir/expressions/callExpression.cpp index 96085be9abf3b5aae3ab14ebbf795f948895d79f..cc1963c9c7e2328303b78c411401b456ba3ec07f 100644 --- a/es2panda/ir/expressions/callExpression.cpp +++ b/es2panda/ir/expressions/callExpression.cpp @@ -180,7 +180,11 @@ void CallExpression::Compile(compiler::PandaGen *pg) const realCallee->Compile(pg); } - pg->StoreAccumulator(this, callee); + if (realCallee->IsMemberExpression()) { + pg->StoreAccumulator(realCallee->AsMemberExpression()->Property(), callee); + } else { + pg->StoreAccumulator(this, callee); + } pg->GetOptionalChain()->CheckNullish(optional_, callee); if (containsSpread) { @@ -202,6 +206,16 @@ void CallExpression::Compile(compiler::PandaGen *pg) const } if (hasThis) { + /* + * To obtain more accurate line number information in the MemberExpression scenario, + * bind CallThis to the property node instead of the entire callee. + * especially for cases involving async stack tracing. + */ + if (realCallee->IsMemberExpression()) { + pg->CallThis(realCallee->AsMemberExpression()->Property(), callee, + static_cast(arguments_.size() + 1)); + return; + } pg->CallThis(this, callee, static_cast(arguments_.size() + 1)); return; } diff --git a/es2panda/ir/expressions/memberExpression.cpp b/es2panda/ir/expressions/memberExpression.cpp index c86f519c0a84935cbc97ad19c577e4c2b68acaaf..c36674e1608c5dd5e23ecb151f308d7cf5a034ce 100644 --- a/es2panda/ir/expressions/memberExpression.cpp +++ b/es2panda/ir/expressions/memberExpression.cpp @@ -93,9 +93,9 @@ void MemberExpression::Compile(compiler::PandaGen *pg, compiler::VReg objReg) co compiler::Operand prop = CompileKey(pg); if (object_->IsSuperExpression()) { - pg->LoadSuperProperty(this, objReg, prop); + pg->LoadSuperProperty(property_, objReg, prop); } else { - pg->LoadObjProperty(this, objReg, prop); + pg->LoadObjProperty(property_, objReg, prop); } } diff --git a/es2panda/ir/irnode.h b/es2panda/ir/irnode.h index 576c50cbf3a23e6f5b412c277434b10335623747..bde613106d340335170fef5d04fe8249cf14d994 100644 --- a/es2panda/ir/irnode.h +++ b/es2panda/ir/irnode.h @@ -33,7 +33,7 @@ class AstNode; } // namespace panda::es2panda::ir namespace panda::pandasm { -struct Ins; +class Ins; } // namespace panda::pandasm namespace panda::es2panda::compiler { @@ -120,7 +120,7 @@ public: virtual Formats GetFormats() const = 0; virtual size_t Registers([[maybe_unused]] std::array *regs) = 0; virtual size_t Registers([[maybe_unused]] std::array *regs) const = 0; - virtual void Transform(panda::pandasm::Ins *ins) const = 0; + virtual panda::pandasm::Ins *Transform() const = 0; virtual ICSlot SetIcSlot(IcSizeType currentSlot) = 0; virtual bool InlineCacheEnabled() = 0; virtual ICSlot GetIcSlot() = 0; diff --git a/es2panda/lexer/lexer.cpp b/es2panda/lexer/lexer.cpp index ff656fe34d5579f7be08ea2c3d605658b3e0ab2d..b5e4726b1e07a426a5f7450afb2411a0985045f3 100644 --- a/es2panda/lexer/lexer.cpp +++ b/es2panda/lexer/lexer.cpp @@ -271,6 +271,7 @@ void Lexer::ScanNumberLeadingZero() case LEX_CHAR_8: case LEX_CHAR_9: { ThrowError("Invalid octal digit"); + break; } default: { break; @@ -371,14 +372,27 @@ void Lexer::ConvertNumber(size_t exponentSignPos) GetToken().src_ = sv; } - try { - GetToken().number_ = static_cast(std::stold(utf8, nullptr)); - } catch (const std::invalid_argument &) { + errno = 0; + char *endptr = nullptr; + double value = std::strtod(utf8.c_str(), &endptr); + + if (endptr == utf8.c_str()) { ThrowError("Invalid number"); - } catch (const std::out_of_range &) { - // TODO(frobert): look for a more elegant solution to this - GetToken().number_ = std::numeric_limits::infinity(); + return; } + + /* + * Extreme value handling: + * If the number exceeds Number.MAX_VALUE (~1.7976931348623157e+308), treat it as Infinity / -Infinity + * If the number is smaller than Number.MIN_VALUE (5e-324), it may be rounded to 0.0 or Number.MIN_VALUE, + * depending on platform behavior. + */ + if (errno == ERANGE && std::abs(value) > std::numeric_limits::max()) { + value = (value > 0.0 ? std::numeric_limits::infinity() + : -std::numeric_limits::infinity()); + } + + GetToken().number_ = value; } void Lexer::ScanNumber(bool allowNumericSeparator, bool allowBigInt) { diff --git a/es2panda/lexer/token/token.h b/es2panda/lexer/token/token.h index 168af8dad068d953050888866a4c3c76d523bc69..383f9a1c229baee590ff412b5b16d64d4eed9d95 100644 --- a/es2panda/lexer/token/token.h +++ b/es2panda/lexer/token/token.h @@ -85,6 +85,11 @@ public: return src_; } + void SetIdent(const util::StringView &ident) + { + src_ = ident; + } + const util::StringView &BigInt() const { ASSERT(type_ == TokenType::LITERAL_NUMBER && (flags_ & TokenFlags::NUMBER_BIGINT)); diff --git a/es2panda/lexer/token/tokenType.h b/es2panda/lexer/token/tokenType.h index 6fe7fb0f0ef21bdbfce9999104ec0aa67ec70489..45a23d0ed2344b6d356d119d746c9e442c3ce040 100644 --- a/es2panda/lexer/token/tokenType.h +++ b/es2panda/lexer/token/tokenType.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -142,6 +142,7 @@ enum class TokenType { KEYW_RETURN, KEYW_STRING, KEYW_SUPER, + KEYW_STRUCT, KEYW_SWITCH, KEYW_SYMBOL, KEYW_THIS, diff --git a/es2panda/parser/parserImpl.cpp b/es2panda/parser/parserImpl.cpp index cf578562b764135d0c0878bee238ba18d9df6b22..0dab3b7005fa022e95dab4bb43f5501d3e77ae12 100644 --- a/es2panda/parser/parserImpl.cpp +++ b/es2panda/parser/parserImpl.cpp @@ -117,7 +117,9 @@ Program ParserImpl::Parse(const SourceFile &sourceFile, const CompilerOptions &o program_.SetDebug(options.isDebug); program_.SetTargetApiVersion(options.targetApiVersion); program_.SetTargetApiSubVersion(options.targetApiSubVersion); - program_.SetEnableAnnotations(options.enableAnnotations); + if (util::Helpers::IsSupportAnnotationVersion(program_.TargetApiVersion())) { + program_.SetEnableAnnotations(options.enableAnnotations); + } program_.SetEnableEtsImplements(options.enableEtsImplements); program_.SetShared(sourceFile.isSharedModule); program_.SetModuleRecordFieldName(options.moduleRecordFieldName); @@ -1489,7 +1491,7 @@ ir::Expression *ParserImpl::ParseTsTypeLiteralOrInterfaceMember() char32_t nextToken = lexer_->Lookahead(); if (lexer_->GetToken().KeywordType() == lexer::TokenType::KEYW_READONLY && nextToken != LEX_CHAR_LEFT_PAREN && nextToken != LEX_CHAR_COLON && nextToken != LEX_CHAR_COMMA && nextToken != LEX_CHAR_LESS_THAN && - nextToken != LEX_CHAR_SEMICOLON) { + nextToken != LEX_CHAR_SEMICOLON && nextToken != LEX_CHAR_QUESTION) { readonly = true; lexer_->NextToken(lexer::LexerNextTokenFlags::KEYWORD_TO_IDENT); } @@ -2787,6 +2789,47 @@ ir::Expression *ParserImpl::ParseClassKeyAnnotation() return nullptr; } +bool ParserImpl::CheckAnnotationPrefix(const util::StringView &Ident) +{ + auto prefixLen = std::strlen(ir::Annotation::annotationPrefix); + return Ident.Length() >= prefixLen && + Ident.Substr(0, prefixLen) == ir::Annotation::annotationPrefix; +} + +void ParserImpl::ThrowAnnotationNotEnable() +{ + std::string errMessage = + "Current configuration does not support using annotations. " + "Annotations can be used in the version of API 20 or higher versions.\n" + "Solutions: > Check the compatibleSdkVersion in build-profile.json5." + "> If compatibleSdkVersion is set to API 20 or higher version." + "> If you're running es2abc in commandline without IDE, please check whether target-api-version and " + "enable-annotations options are correctly configured."; + ThrowSyntaxError(errMessage); +} + +ir::Statement *ParserImpl::ParseAnnotationUsage(ir::Expression *expr, lexer::SourcePosition start) +{ + auto *exprTemp = expr; + if (exprTemp->IsCallExpression()) { + exprTemp = expr->AsCallExpression()->Callee(); + } + if (exprTemp->IsMemberExpression() || exprTemp->IsIdentifier()) { + auto *ident = exprTemp->IsIdentifier() ? exprTemp->AsIdentifier() + : exprTemp->AsMemberExpression()->Property()->AsIdentifier(); + if (CheckAnnotationPrefix(ident->Name())) { + if (!program_.IsEnableAnnotations()) { + ThrowAnnotationNotEnable(); + } + ident->SetName(ident->Name().Substr(std::strlen(ir::Annotation::annotationPrefix), ident->Name().Length())); + ir::Statement *resultAnnotation = static_cast(AllocNode(expr)); + resultAnnotation->SetRange({start, expr->End()}); + return resultAnnotation; + } + } + return nullptr; +} + ir::Statement *ParserImpl::ParseDecoratorAndAnnotation() { ASSERT(lexer_->GetToken().Type() == lexer::TokenType::PUNCTUATOR_AT); @@ -2795,23 +2838,22 @@ ir::Statement *ParserImpl::ParseDecoratorAndAnnotation() lexer::SourcePosition start = lexer_->GetToken().Start(); lexer_->NextToken(); // eat '@' - if (lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT && - lexer_->GetToken().Ident().Utf8().rfind(ir::Annotation::annotationPrefix, 0) != std::string_view::npos) { - // Annotation usage case - if (!program_.IsEnableAnnotations()) { - ThrowSyntaxError("Annotations are not enabled"); - } - ir::Expression *expr = ParseLeftHandSideExpression(); - ir::Statement *resultAnnotation = static_cast(AllocNode(expr)); - resultAnnotation->SetRange({start, expr->End()}); + ir::Expression *expr = ParseLeftHandSideExpression(); + auto *resultAnnotation = ParseAnnotationUsage(expr, start); + if (resultAnnotation != nullptr) { return resultAnnotation; } - ir::Expression *expr = ParseLeftHandSideExpression(); if (expr->IsIdentifier() && expr->AsIdentifier()->Name().Utf8() == ir::Annotation::interfaceString) { // Annotation declaration case if (!program_.IsEnableAnnotations()) { - ThrowSyntaxError("Annotations are not enabled"); + ThrowAnnotationNotEnable(); + } + + if (!CheckAnnotationPrefix(lexer_->GetToken().Ident())) { + std::stringstream ss; + ss << "Annotation declaration need to be prefixed with '" << ir::Annotation::annotationPrefix << "'"; + ThrowSyntaxError(ss.str()); } lexer_->Rewind(lexPos); return nullptr; @@ -3135,13 +3177,16 @@ bool ParserImpl::IsMethodDefinitionsAreSame(const ir::MethodDefinition *property return IsPropertyKeysAreSame(property->Key(), overload->Key()); } -ir::Identifier *ParserImpl::SetIdentNodeInClassDefinition(bool isDeclare, binder::ConstDecl **decl) +ir::Identifier *ParserImpl::SetIdentNodeInClassDefinition(bool isDeclare, binder::ConstDecl **decl, bool isAnnotation) { if (!isDeclare) { CheckStrictReservedWord(); } - const util::StringView &identStr = lexer_->GetToken().Ident(); + const util::StringView &identStr = + isAnnotation ? lexer_->GetToken().Ident().Substr(std::strlen(ir::Annotation::annotationPrefix), + lexer_->GetToken().Ident().Length()) + : lexer_->GetToken().Ident(); *decl = Binder()->AddDecl(lexer_->GetToken().Start(), isDeclare, identStr); @@ -3154,7 +3199,7 @@ ir::Identifier *ParserImpl::SetIdentNodeInClassDefinition(bool isDeclare, binder } ir::ClassDefinition *ParserImpl::ParseClassDefinition(bool isDeclaration, bool idRequired, bool isDeclare, - bool isAbstract) + bool isAbstract, bool isAnnotation) { isDeclare = isDeclare | (context_.Status() & ParserStatus::IN_AMBIENT_CONTEXT); lexer::SourcePosition startLoc = lexer_->GetToken().Start(); @@ -3168,7 +3213,7 @@ ir::ClassDefinition *ParserImpl::ParseClassDefinition(bool isDeclaration, bool i if ((lexer_->GetToken().Type() == lexer::TokenType::LITERAL_IDENT || lexer_->GetToken().Type() == lexer::TokenType::KEYW_AWAIT) && (Extension() != ScriptExtension::TS || lexer_->GetToken().KeywordType() != lexer::TokenType::KEYW_IMPLEMENTS)) { - identNode = SetIdentNodeInClassDefinition(isDeclare, &decl); + identNode = SetIdentNodeInClassDefinition(isDeclare, &decl, isAnnotation); } else if (isDeclaration && idRequired) { ThrowSyntaxError("Unexpected token, expected an identifier."); } @@ -3735,7 +3780,9 @@ ArenaVector ParserImpl::ParseFunctionParams(bool isDeclare, } } + context_.Status() |= ParserStatus::FUNCTION_PARAM; ir::Expression *parameter = ParseFunctionParameter(isDeclare); + context_.Status() &= ~ParserStatus::FUNCTION_PARAM; ValidateFunctionParam(params, parameter, &seenOptional); params.push_back(parameter); @@ -4086,7 +4133,6 @@ ir::ScriptFunction *ParserImpl::ParseFunction(ParserStatus newStatus, funcParamScope->BindNode(funcNode); funcNode->SetRange({startLoc, endLoc}); funcNode->CalculateFunctionExpectedPropertyCount(); - return funcNode; } diff --git a/es2panda/parser/parserImpl.h b/es2panda/parser/parserImpl.h index a69af8e055f135e4ee3c80c84f4fa630b3ba24fd..3254760260be2bb6559dcbfb1eab16d30ff0af67 100644 --- a/es2panda/parser/parserImpl.h +++ b/es2panda/parser/parserImpl.h @@ -322,7 +322,11 @@ private: void CheckClassGeneratorMethod(ClassElmentDescriptor *desc); void CheckClassPrivateIdentifier(ClassElmentDescriptor *desc); void CheckFieldKey(ir::Expression *propName); + bool CheckAnnotationPrefix(const util::StringView &Ident); + void ThrowAnnotationNotEnable(); + ir::Expression *ParseClassKeyAnnotation(); + ir::Statement *ParseAnnotationUsage(ir::Expression *expr, lexer::SourcePosition start); ir::Statement *ParseDecoratorAndAnnotation(); std::pair, ArenaVector> ParseDecoratorsAndAnnotations(); ir::Statement *ParseClassElement(const ArenaVector &properties, @@ -335,9 +339,9 @@ private: ir::MethodDefinition *CheckClassMethodOverload(ir::Statement *property, ir::MethodDefinition **ctor, bool isDeclare, lexer::SourcePosition errorInfo, ir::MethodDefinition *lastOverload, bool implExists, bool isAbstract = false); - ir::Identifier *SetIdentNodeInClassDefinition(bool isDeclare, binder::ConstDecl **decl); + ir::Identifier *SetIdentNodeInClassDefinition(bool isDeclare, binder::ConstDecl **decl, bool isAnnotation = false); ir::ClassDefinition *ParseClassDefinition(bool isDeclaration, bool idRequired = true, bool isDeclare = false, - bool isAbstract = false); + bool isAbstract = false, bool isAnnotation = false); ir::Expression *ParseSuperClass(bool isDeclare, bool *hasSuperClass, bool *isExtendsFromNull); ArenaVector ParseTSClassImplements(bool isDeclare); void ValidateClassConstructor(const ir::MethodDefinition *ctor, @@ -602,7 +606,7 @@ private: ir::VariableDeclaration *ParseContextualLet(VariableParsingFlags flags, StatementParsingFlags stmFlags = StatementParsingFlags::ALLOW_LEXICAL, bool isDeclare = false); - void VerifySupportLazyImportVersion(bool isNamedImport); + void VerifySupportLazyImportVersion(); util::StringView GetNamespaceExportInternalName() { diff --git a/es2panda/parser/program/program.cpp b/es2panda/parser/program/program.cpp index 5151f3845c35b604012dd754b291710a9f0ec940..992292ea0023783bce88558618fc237f0615d396 100644 --- a/es2panda/parser/program/program.cpp +++ b/es2panda/parser/program/program.cpp @@ -48,6 +48,7 @@ Program::Program(Program &&other) targetApiVersion_(other.targetApiVersion_), useDefineSemantic_(other.useDefineSemantic_), isShared_(other.isShared_), + enableAnnotations_(other.enableAnnotations_), enableEtsImplements_(other.enableEtsImplements_), targetApiSubVersion_(other.targetApiSubVersion_), moduleRecordFieldName_(other.moduleRecordFieldName_), @@ -79,6 +80,7 @@ Program &Program::operator=(Program &&other) targetApiVersion_ = other.targetApiVersion_; useDefineSemantic_ = other.useDefineSemantic_; isShared_ = other.isShared_; + enableAnnotations_ = other.enableAnnotations_; enableEtsImplements_ = other.enableEtsImplements_; targetApiSubVersion_ = other.targetApiSubVersion_; moduleRecordFieldName_ = other.moduleRecordFieldName_; diff --git a/es2panda/parser/program/program.h b/es2panda/parser/program/program.h index 493fff1a021dd357725a7380477f3c0bebe004c8..f19e6ed06982fb58a80bb259ab59e2fa98fc8e4a 100644 --- a/es2panda/parser/program/program.h +++ b/es2panda/parser/program/program.h @@ -230,7 +230,7 @@ public: enableAnnotations_ = enableAnnotations; } - bool IsEnableAnnotations() + bool IsEnableAnnotations() const { return enableAnnotations_; } diff --git a/es2panda/parser/statementParser.cpp b/es2panda/parser/statementParser.cpp index 3a0b46e5ca19ada2c9740c7bfc5ab461dee5c0b0..b158dbae4e889c22e9181b959a159b02d6afdbd6 100644 --- a/es2panda/parser/statementParser.cpp +++ b/es2panda/parser/statementParser.cpp @@ -690,7 +690,7 @@ ir::ClassDeclaration *ParserImpl::ParseClassDeclaration(bool idRequired, ArenaVe bool isAbstract, bool isExported, bool isAnnotation) { lexer::SourcePosition startLoc = lexer_->GetToken().Start(); - ir::ClassDefinition *classDefinition = ParseClassDefinition(true, idRequired, isDeclare, isAbstract); + ir::ClassDefinition *classDefinition = ParseClassDefinition(true, idRequired, isDeclare, isAbstract, isAnnotation); if (isExported && !idRequired) { classDefinition->SetAsExportDefault(); } @@ -2610,6 +2610,10 @@ ir::ExportNamedDeclaration *ParserImpl::ParseExportNamedSpecifiers(const lexer:: } lexer::Token localToken = lexer_->GetToken(); + if (program_.IsEnableAnnotations() && CheckAnnotationPrefix(lexer_->GetToken().Ident())) { + localToken.SetIdent(lexer_->GetToken().Ident().Substr(std::strlen(ir::Annotation::annotationPrefix), + lexer_->GetToken().Ident().Length())); + } auto *local = AllocNode(lexer_->GetToken().Ident()); local->SetRange(lexer_->GetToken().Loc()); @@ -2990,6 +2994,10 @@ void ParserImpl::ParseNamedImportSpecifiers(ArenaVector *specifie } lexer::Token importedToken = lexer_->GetToken(); + if (program_.IsEnableAnnotations() && CheckAnnotationPrefix(lexer_->GetToken().Ident())) { + importedToken.SetIdent(lexer_->GetToken().Ident().Substr(std::strlen(ir::Annotation::annotationPrefix), + lexer_->GetToken().Ident().Length())); + } auto *imported = AllocNode(importedToken.Ident()); ir::Identifier *local = nullptr; imported->SetRange(lexer_->GetToken().Loc()); @@ -3186,30 +3194,18 @@ ir::AstNode *ParserImpl::ParseImportSpecifiers(ArenaVector *speci return nullptr; } -void ParserImpl::VerifySupportLazyImportVersion(bool isNamedImport) +void ParserImpl::VerifySupportLazyImportVersion() { - if (isNamedImport) { - if (!util::Helpers::IsSupportLazyImportVersion(program_.TargetApiVersion(), - program_.GetTargetApiSubVersion())) { - std::string errMessage = "Current configuration does not support using lazy import. Lazy import can be " - "used in the beta3 version of API 12 or higher versions.\n" - "Solutions: > Check the compatibleSdkVersion and compatibleSdkVersionStage in build-profile.json5." - "> If compatibleSdkVersion is set to API 12, then compatibleSdkVersionStage needs to be configured " - "as beta3." - "> If you're running es2abc in commandline without IDE, please check whether target-api-version and " - "target-api-sub-version options are correctly configured."; - ThrowSyntaxError(errMessage); - } - } else { - if (!util::Helpers::IsSupportLazyImportDefaultVersion(program_.TargetApiVersion())) { - std::string errMessage = "Current configuration does not support using lazy import default." - "Lazy import can be used in the version of API 18 or higher versions.\n" - "Solutions: > Check the compatibleSdkVersion in build-profile.json5." - "> If compatibleSdkVersion is set to API 18." - "> If you're running es2abc in commandline without IDE, please check whether target-api-version " - "options are correctly configured."; - ThrowSyntaxError(errMessage); - } + if (!util::Helpers::IsSupportLazyImportVersion(program_.TargetApiVersion(), + program_.GetTargetApiSubVersion())) { + std::string errMessage = "Current configuration does not support using lazy import. Lazy import can be " + "used in the beta3 version of API 12 or higher versions.\n" + "Solutions: > Check the compatibleSdkVersion and compatibleSdkVersionStage in build-profile.json5." + "> If compatibleSdkVersion is set to API 12, then compatibleSdkVersionStage needs to be configured " + "as beta3." + "> If you're running es2abc in commandline without IDE, please check whether target-api-version and " + "target-api-sub-version options are correctly configured."; + ThrowSyntaxError(errMessage); } } @@ -3246,7 +3242,7 @@ ir::Statement *ParserImpl::ParseImportDeclaration(StatementParsingFlags flags) lexer_->GetToken().KeywordType() != lexer::TokenType::KEYW_TYPE) && lexer_->GetToken().KeywordType() != lexer::TokenType::KEYW_FROM; if (isNamedImport || isDefaultImport) { - VerifySupportLazyImportVersion(isNamedImport); + VerifySupportLazyImportVersion(); isLazy = true; } else { lexer_->Rewind(savedPos); diff --git a/es2panda/parser/transformer/transformer.cpp b/es2panda/parser/transformer/transformer.cpp index f41498a83f45dcef9db6024a515f4a11a12ba249..ff06eafee3354db6d79f5cb4889f430b837439eb 100644 --- a/es2panda/parser/transformer/transformer.cpp +++ b/es2panda/parser/transformer/transformer.cpp @@ -697,15 +697,22 @@ std::vector Transformer::VisitInstanceProperty(ir::Cl ir::MemberExpression *left = nullptr; auto *member = GetClassMemberName(it->Key(), it->IsComputed(), it, false); + auto thisExpression = AllocNode(); + // Set the range of the 'this' expression to the property key's range + // for accurate debug to the original field. (e.g., the "prop" in '"prop" = 1'). + thisExpression->SetRange(member->Range()); if (member->IsIdentifier() && !it->IsComputed()) { - left = AllocNode(AllocNode(), member, + left = AllocNode(thisExpression, member, ir::MemberExpression::MemberExpressionKind::PROPERTY_ACCESS, false, false); } else { - left = AllocNode(AllocNode(), member, + left = AllocNode(thisExpression, member, ir::MemberExpression::MemberExpressionKind::ELEMENT_ACCESS, true, false); } + // Set the range of the property access expression (e.g., this["prop"] or this.prop) + // to the property key's range for accurate debug. + left->SetRange(member->Range()); auto assignment = AllocNode(left, it->Value(), lexer::TokenType::PUNCTUATOR_SUBSTITUTION); @@ -1558,20 +1565,33 @@ ir::Expression *Transformer::GetClassMemberName(ir::Expression *key, bool isComp { if (isComputed) { auto name = GetComputedPropertyBinding(node); - return AllocNode(name); + auto *ident = AllocNode(name); + ident->SetRange(key->Range()); + return ident; } if (key->IsIdentifier()) { if (inDecorator) { - return AllocNode(key->AsIdentifier()->Name()); + auto *strLiteral = AllocNode(key->AsIdentifier()->Name()); + strLiteral->SetRange(key->AsIdentifier()->Range()); + return strLiteral; } else { - return AllocNode(key->AsIdentifier()->Name()); + auto *ident = AllocNode(key->AsIdentifier()->Name()); + ident->SetRange(key->AsIdentifier()->Range()); + return ident; } } else if (key->IsStringLiteral()) { - return AllocNode(key->AsStringLiteral()->Str()); + auto *strLiteral = AllocNode(key->AsStringLiteral()->Str()); + strLiteral->SetRange(key->AsStringLiteral()->Range()); + return strLiteral; } else if (key->IsNumberLiteral()) { - return AllocNode(key->AsNumberLiteral()->Number(), key->AsNumberLiteral()->Str()); + auto *numLiteral = AllocNode(key->AsNumberLiteral()->Number(), + key->AsNumberLiteral()->Str()); + numLiteral->SetRange(key->AsNumberLiteral()->Range()); + return numLiteral; } else if (key->IsBigIntLiteral()) { - return AllocNode(key->AsBigIntLiteral()->Str()); + auto *bigIntLiteral = AllocNode(key->AsBigIntLiteral()->Str()); + bigIntLiteral->SetRange(key->AsBigIntLiteral()->Range()); + return bigIntLiteral; } UNREACHABLE(); return nullptr; diff --git a/es2panda/test/base64/availableTargetApiVersion/10/expected.txt b/es2panda/test/base64/availableTargetApiVersion/10/expected.txt index 7196886c4e5cf0f3cb19ad4d939f09f64e2e7c60..ea65d584ae2cfdff4b04e21864de8947fb8f8a77 100644 --- a/es2panda/test/base64/availableTargetApiVersion/10/expected.txt +++ b/es2panda/test/base64/availableTargetApiVersion/10/expected.txt @@ -11,4 +11,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -UEFOREEAAAAAAAAACQAAAJwBAAAAAAAAAAAAAAMAAAA8AAAAAQAAAJgBAAAAAAAASAAAAAEAAABIAAAArgAAAN8AAAASAQAAiAAAAJwBAAACAAAAcAAAAAMAAAB4AAAAAAAAAIQAAAABAAAAhAAAAN8AAAASAQAAiAAAAKIAAACpAAAARAEAADFoZWxsbyB3b3JsZCwgdmVyc2lvbiAxMCEAC3ByaW50AAdzdHIASUxfRVNFeHBlY3RlZFByb3BlcnR5Q291bnRBbm5vdGF0aW9uOwAAAAAAgUAAAAIAADNMX0VTU2xvdE51bWJlckFubm90YXRpb247AAAAAACBQAAAAgAAF2Z1bmNfbWFpbl8wABNMX0dMT0JBTDsAAAAAAAEAAQIAAAEAAAAFAQAAiAIBYQEAAAIABYwBAAAGVAEAAAAA7u4AABVTbG90TnVtYmVyAAAAAQBIAQAABQAAADcHAyEARHBEgUSSPgAASAAAAgA/AQEAYQU/AgIAYQZgBSoDBgBlC2uJAQ4A/////w8AAgARAAAAhgEAAA== +UEFOREEAAAAAAAAACQAAAGQBAAAAAAAAAAAAAAIAAAA8AAAAAQAAAGABAAAAAAAARAAAAAEAAABEAAAAqgAAAN0AAACEAAAAZAEAAAIAAABsAAAAAwAAAHQAAAAAAAAAgAAAAAEAAACAAAAAqgAAAN0AAACEAAAAngAAAKUAAAAOAQAAMWhlbGxvIHdvcmxkLCB2ZXJzaW9uIDEwIQALcHJpbnQAB3N0cgAzTF9FU1Nsb3ROdW1iZXJBbm5vdGF0aW9uOwAAAAAAgUAAAAIAABdmdW5jX21haW5fMAATTF9HTE9CQUw7AAAAAAABAAECAAABAAAA0AAAAIgCASsBAAACAAVWAQAABh4BAAAA7u4AABVTbG90TnVtYmVyAAAAAQASAQAABQAAADcHAyEARHBEgUSSPgAASAAAAgA/AQEAYQU/AgIAYQZgBSoDBgBlC2uJAQ4A/////w8AAgARAFABAAA= diff --git a/es2panda/test/base64/availableTargetApiVersion/11/expected.txt b/es2panda/test/base64/availableTargetApiVersion/11/expected.txt index d27a626eee9142bd3f06b9183a03466dd2558b81..e4039082c8b3e142fe762b3e74c6659b351f6819 100644 --- a/es2panda/test/base64/availableTargetApiVersion/11/expected.txt +++ b/es2panda/test/base64/availableTargetApiVersion/11/expected.txt @@ -11,4 +11,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -UEFOREEAAAAAAAAACwACAJwBAAAAAAAAAAAAAAMAAAA8AAAAAQAAAJgBAAAAAAAASAAAAAEAAABIAAAArgAAAN8AAAASAQAAiAAAAJwBAAACAAAAcAAAAAMAAAB4AAAAAAAAAIQAAAABAAAAhAAAAN8AAAASAQAAiAAAAKIAAACpAAAARAEAADFoZWxsbyB3b3JsZCwgdmVyc2lvbiAxMSEAC3ByaW50AAdzdHIASUxfRVNFeHBlY3RlZFByb3BlcnR5Q291bnRBbm5vdGF0aW9uOwAAAAAAgUAAAAIAADNMX0VTU2xvdE51bWJlckFubm90YXRpb247AAAAAACBQAAAAgAAF2Z1bmNfbWFpbl8wABNMX0dMT0JBTDsAAAAAAAEAAQIAAAEAAAAFAQAAiAIBYQEAAAIABYwBAAAGVAEAAAAA7u4AABVTbG90TnVtYmVyAAAAAQBIAQAABQAAADcHAyEARHBEgUSSPgAASAAAAgA/AQEAYQU/AgIAYQZgBSoDBgBlC2uJAQ4A/////w8AAgARAAAAhgEAAA== +UEFOREEAAAAAAAAACwACAGQBAAAAAAAAAAAAAAIAAAA8AAAAAQAAAGABAAAAAAAARAAAAAEAAABEAAAAqgAAAN0AAACEAAAAZAEAAAIAAABsAAAAAwAAAHQAAAAAAAAAgAAAAAEAAACAAAAAqgAAAN0AAACEAAAAngAAAKUAAAAOAQAAMWhlbGxvIHdvcmxkLCB2ZXJzaW9uIDExIQALcHJpbnQAB3N0cgAzTF9FU1Nsb3ROdW1iZXJBbm5vdGF0aW9uOwAAAAAAgUAAAAIAABdmdW5jX21haW5fMAATTF9HTE9CQUw7AAAAAAABAAECAAABAAAA0AAAAIgCASsBAAACAAVWAQAABh4BAAAA7u4AABVTbG90TnVtYmVyAAAAAQASAQAABQAAADcHAyEARHBEgUSSPgAASAAAAgA/AQEAYQU/AgIAYQZgBSoDBgBlC2uJAQ4A/////w8AAgARAFABAAA= diff --git a/es2panda/test/base64/availableTargetApiVersion/12/expected.txt b/es2panda/test/base64/availableTargetApiVersion/12/expected.txt index 3308f1d348bd13cb2e9859b58ff09dcd82aa17f8..5851b369e143eaff057f4c075e8764ac61acc54e 100644 --- a/es2panda/test/base64/availableTargetApiVersion/12/expected.txt +++ b/es2panda/test/base64/availableTargetApiVersion/12/expected.txt @@ -11,4 +11,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -UEFOREEAAAAAAAAADAAGANgBAAAAAAAAAAAAAAQAAAA8AAAAAQAAANQBAAABAAAATAAAAAEAAABQAAAAugAAAOsAAAAdAQAAUAEAAIEBAACUAAAA2AEAAAQAAAB4AAAAAwAAAIgAAAD/////////////////////BgAAAOsAAAAdAQAAUAEAAJQAAACuAAAAtQAAADFoZWxsbyB3b3JsZCwgdmVyc2lvbiAxMiEAC3ByaW50AAdzdHIASUxfRVNFeHBlY3RlZFByb3BlcnR5Q291bnRBbm5vdGF0aW9uOwAAAAAAgUAAAAIAACtMX0VTU2NvcGVOYW1lc1JlY29yZDsAAAAAAAEBAAIAAAEAAAAbAQAAAAKBAQAAAAEAM0xfRVNTbG90TnVtYmVyQW5ub3RhdGlvbjsAAAAAAIFAAAACAAAXZnVuY19tYWluXzAAE0xfR0xPQkFMOwAAAAAAAQABAgAAAwD//0MBAACIAgGeAQAAAgAFyQEAAAaRAQAAAAAAAAAVU2xvdE51bWJlcgACAAEAhQEAAAUAAAA3BwMhAERwRIFEkj4AAEgAAAIAPwEBAGEFPwICAGEGYAUqAwYAZQtriQEOAP////8PAAIAEQAAwwEAAA== +UEFOREEAAAAAAAAADAAGAKQBAAAAAAAAAAAAAAMAAAA8AAAAAQAAAKABAAABAAAASAAAAAEAAABMAAAAtgAAAOgAAAAbAQAATAEAAJAAAACkAQAABAAAAHQAAAADAAAAhAAAAP////////////////////8GAAAAtgAAAOgAAAAbAQAAkAAAAKoAAACxAAAAMWhlbGxvIHdvcmxkLCB2ZXJzaW9uIDEyIQALcHJpbnQAB3N0cgArTF9FU1Njb3BlTmFtZXNSZWNvcmQ7AAAAAAABAQACAAABAAAA5gAAAAACTAEAAAABADNMX0VTU2xvdE51bWJlckFubm90YXRpb247AAAAAACBQAAAAgAAF2Z1bmNfbWFpbl8wABNMX0dMT0JBTDsAAAAAAAEAAQIAAAMA//8OAQAAiAIBaQEAAAIABZQBAAAGXAEAAAAAAAAAFVNsb3ROdW1iZXIAAgABAFABAAAFAAAANwcDIQBEcESBRJI+AABIAAACAD8BAQBhBT8CAgBhBmAFKgMGAGULa4kBDgD/////DwACABEAAACOAQAA diff --git a/es2panda/test/base64/availableTargetApiVersion/9/expected.txt b/es2panda/test/base64/availableTargetApiVersion/9/expected.txt index 4493d88c5e760a6b4103669c127dee32f8184fa7..3a5ba6e9a24ed7dcf3b447e691140b28d93df3de 100644 --- a/es2panda/test/base64/availableTargetApiVersion/9/expected.txt +++ b/es2panda/test/base64/availableTargetApiVersion/9/expected.txt @@ -11,4 +11,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -UEFOREEAAAAAAAAACQAAAJgBAAAAAAAAAAAAAAMAAAA8AAAAAQAAAJQBAAAAAAAASAAAAAEAAABIAAAArQAAAN4AAAARAQAAiAAAAJgBAAACAAAAcAAAAAMAAAB4AAAAAAAAAIQAAAABAAAAhAAAAN4AAAARAQAAiAAAAKEAAACoAAAAQgEAAC9oZWxsbyB3b3JsZCwgdmVyc2lvbiA5IQALcHJpbnQAB3N0cgBJTF9FU0V4cGVjdGVkUHJvcGVydHlDb3VudEFubm90YXRpb247AAAAAACBQAAAAgAAM0xfRVNTbG90TnVtYmVyQW5ub3RhdGlvbjsAAAAAAIFAAAACAAAXZnVuY19tYWluXzAAE0xfR0xPQkFMOwAAAAAAAQABAgAAAQAAAAQBAACIAgFfAQAAAgAFigEAAAZSAQAAAO7uAAAVU2xvdE51bWJlcgAAAAEARgEAAAUAAAA3BwMhAERwRIFEkj4AAEgAAAIAPwEBAGEFPwICAGEGYAUqAwYAZQtriQEOAP////8PAAIAEQCEAQAA +UEFOREEAAAAAAAAACQAAAGQBAAAAAAAAAAAAAAIAAAA8AAAAAQAAAGABAAAAAAAARAAAAAEAAABEAAAAqQAAANwAAACEAAAAZAEAAAIAAABsAAAAAwAAAHQAAAAAAAAAgAAAAAEAAACAAAAAqQAAANwAAACEAAAAnQAAAKQAAAAOAQAAL2hlbGxvIHdvcmxkLCB2ZXJzaW9uIDkhAAtwcmludAAHc3RyADNMX0VTU2xvdE51bWJlckFubm90YXRpb247AAAAAACBQAAAAgAAF2Z1bmNfbWFpbl8wABNMX0dMT0JBTDsAAAAAAAEAAQIAAAEAAADPAAAAiAIBKwEAAAIABVYBAAAGHgEAAAAA7u4AABVTbG90TnVtYmVyAAAAAQASAQAABQAAADcHAyEARHBEgUSSPgAASAAAAgA/AQEAYQU/AgIAYQZgBSoDBgBlC2uJAQ4A/////w8AAgARAFABAAA= diff --git a/es2panda/test/bytecode/js/lexicalEnv/constructor-try-catch-expected.txt b/es2panda/test/bytecode/js/lexicalEnv/constructor-try-catch-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..dfa8103e1bf36c2287c6f2bf4cdc93098f3ce40b --- /dev/null +++ b/es2panda/test/bytecode/js/lexicalEnv/constructor-try-catch-expected.txt @@ -0,0 +1,162 @@ +slotNum = 0x0 +.language ECMAScript +.function any .#~@0=#C34(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0xb +.language ECMAScript +.function any .#~@1=#C35(any a0, any a1, any a2, any a3, any a4, any a5) { + nop +label_17: +label_0: + newlexenv 0x1 +label_11: +label_13: + ldai 0x19 + sta v1 + ldai 0x7 + sta v2 +label_7: + lda v1 + less 0x0, v2 + jeqz label_8 +label_9: +label_2: + definefunc 0x1, .#~@1=@1*#f43, 0x0 + stlexvar 0x0, 0x0 + definefunc 0x2, .#~@1=@1*#f46, 0x2 + ldundefined + sta v3 + ldundefined + stricteq 0x3, v3 + jeqz label_5 +label_4: + lda a2 + throw.ifsupernotcorrectcall 0x0 + poplexenv + mov v3, a2 +label_5: + lda v3 + return +label_10: +end_label_10: +label_19: +label_15: + lda.str 123 + sta v3 + tryldglobalbyname 0x4, print + callarg1 0x5, v3 + ldlexvar 0x0, 0x0 + sta v3 + poplexenv + newlexenv 0x1 + lda v3 + stlexvar 0x0, 0x0 + lda v2 + tonumeric 0x7 + inc 0x8 + sta v2 +label_12: +end_label_12: + jmp label_7 +label_20: + sta v0 +label_16: + poplexenv + lda v0 + throw +label_8: + poplexenv + ldundefined + sta v0 + mov v4, v0 + supercallthisrange 0x9, 0x0, v4 + sta v0 + lda a2 + throw.ifsupernotcorrectcall 0x1 + lda v0 + throw.ifsupernotcorrectcall 0x0 + lda v0 + return +label_18: +} + +.catchall label_9, end_label_10, label_19 + +.catchall label_11, end_label_12, label_20 + +slotNum = 0x0 +.language ECMAScript +.function any .#~@1=@1*#f43(any a0, any a1, any a2) { +label_1: +label_0: + ldlexvar 0x0, 0x0 + return +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any .#~@1=@1*#f46(any a0, any a1, any a2, any a3, any a4) { +label_1: +label_0: + ldlexvar 0x1, 0x0 + sta v0 + throw.undefinedifholewithname C35 + lda v0 + return +label_2: +} + +slotNum = 0xc +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { + nop +label_7: +label_0: + ldhole + sta v0 + defineclasswithbuffer 0x0, .#~@0=#C34, _1, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 + sttoglobalrecord 0x3, C34 + newlexenv 0x1 +label_2: +label_4: + tryldglobalbyname 0x4, C34 + sta v1 + defineclasswithbuffer 0x5, .#~@1=#C35, _2, 0x3, v1 + sta v1 + stlexvar 0x0, 0x0 + lda v1 + ldobjbyname 0x6, prototype +label_3: +end_label_3: + jmp label_1 +label_9: + sta v0 +label_6: + poplexenv + lda v0 + throw +label_1: + poplexenv + lda v1 + sttoglobalrecord 0x8, C35 + tryldglobalbyname 0x9, C35 + sta v0 + mov v2, v0 + newobjrange 0xa, 0x1, v2 + returnundefined +label_8: +} + +.catchall label_2, end_label_3, label_9 + + diff --git a/es2panda/test/bytecode/js/lexicalEnv/constructor-try-catch.js b/es2panda/test/bytecode/js/lexicalEnv/constructor-try-catch.js new file mode 100644 index 0000000000000000000000000000000000000000..f3a1fc3929458c2e90e6d1d99b0f5a3c324c7fad --- /dev/null +++ b/es2panda/test/bytecode/js/lexicalEnv/constructor-try-catch.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class C34 {} +class C35 extends C34 { + constructor(a37, a38 , a39) { + for (let v40 = 7; v40 < 25; v40++) { + try { + let v42; + return v42; + function f43() { + return f43; + } + function f46(a47, a48) { + return C35; + } + } catch (e52) { + let x = '123'; + print(x); + } + } + super(); + } +} + +new C35(); diff --git a/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations-exec.ts b/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations-exec.ts index 84370500e341ae7716a10fa55791095a854dac31..44f43d0ae8b93fafac7a4164091c496ec269a30c 100644 --- a/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations-exec.ts +++ b/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations-exec.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number = 42 } diff --git a/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations.ts b/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations.ts index 56903a4827894404715e606172d83d02d49a0a99..49a9b8d2d8d86bfd4969346a04a525e330a924b0 100644 --- a/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations.ts +++ b/es2panda/test/compiler/annotations-projects/ts_identical_annotations_project/test-ts-identical-annotations.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { b: boolean = true } diff --git a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-export-annotations.ts b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-export-annotations.ts index 8c10cc06288a7c1197e1b1c601491358d987f698..2a5d2772fd2923a497c5a03ada83b604bc8245f9 100644 --- a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-export-annotations.ts +++ b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-export-annotations.ts @@ -13,9 +13,9 @@ * limitations under the License. */ -export @interface Anno1 {} +export @interface __$$ETS_ANNOTATION$$__Anno1 {} -export @interface Anno2 { +export @interface __$$ETS_ANNOTATION$$__Anno2 { a: number = 0; } @@ -24,4 +24,3 @@ export class A {} @__$$ETS_ANNOTATION$$__Anno1() export default class B {} - diff --git a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-import-annotations-exec.ts b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-import-annotations-exec.ts index 446556e337073a83d0a2df990549c128eafc0384..13ab7bdb6b46ded18550f221cbc6019943ba27ab 100644 --- a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-import-annotations-exec.ts +++ b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_1/test-ts-import-annotations-exec.ts @@ -15,20 +15,20 @@ import * as Namespace1 from "./test-ts-export-annotations" -@__$$ETS_ANNOTATION$$__Namespace1.Anno() +@Namespace1.__$$ETS_ANNOTATION$$__Anno() class A {} -@__$$ETS_ANNOTATION$$__Namespace1.Anno +@Namespace1.__$$ETS_ANNOTATION$$__Anno class B {} -@__$$ETS_ANNOTATION$$__Namespace1.Anno1({a: 1, b: "string"}) +@Namespace1.__$$ETS_ANNOTATION$$__Anno1({a: 1, b: "string"}) class C {} -@__$$ETS_ANNOTATION$$__Namespace1.Namespace2.Namespace3.Anno2() +@Namespace1.Namespace2.Namespace3.__$$ETS_ANNOTATION$$__Anno2() class D {} -@__$$ETS_ANNOTATION$$__Namespace1.Namespace2.Namespace3.Anno2 +@Namespace1.Namespace2.Namespace3.__$$ETS_ANNOTATION$$__Anno2 class E {} -@__$$ETS_ANNOTATION$$__Namespace1.Namespace2.Namespace3.Anno3({a: 1, b: "string"}) -class F {} \ No newline at end of file +@Namespace1.Namespace2.Namespace3.__$$ETS_ANNOTATION$$__Anno3({a: 1, b: "string"}) +class F {} diff --git a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-export-annotations.ts b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-export-annotations.ts index 8c10cc06288a7c1197e1b1c601491358d987f698..6bea13acdc05d843f551afdf62e7a7d27cc561fd 100644 --- a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-export-annotations.ts +++ b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-export-annotations.ts @@ -13,9 +13,9 @@ * limitations under the License. */ -export @interface Anno1 {} +export @interface __$$ETS_ANNOTATION$$__Anno1 {} -export @interface Anno2 { +export @interface __$$ETS_ANNOTATION$$__Anno2 { a: number = 0; } diff --git a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-import-annotations-exec.ts b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-import-annotations-exec.ts index 734f114a32138d2d1ce2da8d3df63b0e5b7a59a0..de240324b1c1ae40e9672a936fed27be20d814d7 100644 --- a/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-import-annotations-exec.ts +++ b/es2panda/test/compiler/annotations-projects/ts_import_annotations_project_2/test-ts-import-annotations-exec.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import { Anno1, Anno2 } from "./test-ts-export-annotations" +import { __$$ETS_ANNOTATION$$__Anno1, __$$ETS_ANNOTATION$$__Anno2 } from "./test-ts-export-annotations" @__$$ETS_ANNOTATION$$__Anno1 class A {} diff --git a/es2panda/test/compiler/annotations/declaration-3d-array-boolean.ts b/es2panda/test/compiler/annotations/declaration-3d-array-boolean.ts index 8bb5148dc721dad55760f4cf315cd6dd0f348a4c..b13f16c168dc4afec2966bf489d0c34eafae41d4 100644 --- a/es2panda/test/compiler/annotations/declaration-3d-array-boolean.ts +++ b/es2panda/test/compiler/annotations/declaration-3d-array-boolean.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: boolean[][][]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: boolean[][][] = [[new Array()]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: boolean[][][] = [[[true, false], [true, false]]]; } diff --git a/es2panda/test/compiler/annotations/declaration-3d-array-enum-number.ts b/es2panda/test/compiler/annotations/declaration-3d-array-enum-number.ts index 8f50c85fbff71f5f2e49017f2143631e206ccdbb..bf399ee5c9305cbeb60cfaec6c81828e837514d2 100644 --- a/es2panda/test/compiler/annotations/declaration-3d-array-enum-number.ts +++ b/es2panda/test/compiler/annotations/declaration-3d-array-enum-number.ts @@ -18,16 +18,16 @@ const enum E { B = -314 } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying number type a: E[][][] = [[new Array(0)]]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying number type a: E[][][] = [[new Array(1)]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[][][] = [[[42, -314, 42]]]; } diff --git a/es2panda/test/compiler/annotations/declaration-3d-array-enum-string.ts b/es2panda/test/compiler/annotations/declaration-3d-array-enum-string.ts index 8eeef595d0e2bbd1b6afbe902a3920b97f0c564b..a24f1a805f6938f5b29fa3a66b6379ecdb596eb2 100644 --- a/es2panda/test/compiler/annotations/declaration-3d-array-enum-string.ts +++ b/es2panda/test/compiler/annotations/declaration-3d-array-enum-string.ts @@ -18,16 +18,16 @@ const enum E { B = "world!" } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying string type a: E[][][] = [[new Array(2)]]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying string type a: E[][][] = [[new Array(3)]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[][][] = [[["Hello", "world!", "Hello"]]]; } diff --git a/es2panda/test/compiler/annotations/declaration-3d-array-number.ts b/es2panda/test/compiler/annotations/declaration-3d-array-number.ts index e83e604801225ef9f226b3b862ad60e602dd2418..22d514157862b006230a5d89c581d1d5856c6104 100644 --- a/es2panda/test/compiler/annotations/declaration-3d-array-number.ts +++ b/es2panda/test/compiler/annotations/declaration-3d-array-number.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number[][][]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: number[][][] = [[new Array()]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: number[][][] = [[[1, -2, 3], [4, -5, 6]]]; } diff --git a/es2panda/test/compiler/annotations/declaration-3d-array-string.ts b/es2panda/test/compiler/annotations/declaration-3d-array-string.ts index 9d2d477d78b5c09c70f7b74b42b74cc38f80640e..09a27904d4751c31a2b11852d7ccb84d003d5461 100644 --- a/es2panda/test/compiler/annotations/declaration-3d-array-string.ts +++ b/es2panda/test/compiler/annotations/declaration-3d-array-string.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: string[][][]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: string[][][] = [[new Array()]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: string[][][] = [[["hello", "world"], ["hello", "world"]]]; } diff --git a/es2panda/test/compiler/annotations/declaration-array-boolean.ts b/es2panda/test/compiler/annotations/declaration-array-boolean.ts index b5e92f592d43e9018fc8ef55a4931d9e1f89c936..c575410d77ecb84c7c4056b56f99dd36be3cc499 100644 --- a/es2panda/test/compiler/annotations/declaration-array-boolean.ts +++ b/es2panda/test/compiler/annotations/declaration-array-boolean.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: boolean[]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: boolean[] = new Array(); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: boolean[] = [true, false, true]; } diff --git a/es2panda/test/compiler/annotations/declaration-array-enum-number.ts b/es2panda/test/compiler/annotations/declaration-array-enum-number.ts index d947e16c08f264c72522e47bdb51582c5d6dc8fb..139e108acbe8ba544fd8a31f859d48cb33bd23e9 100644 --- a/es2panda/test/compiler/annotations/declaration-array-enum-number.ts +++ b/es2panda/test/compiler/annotations/declaration-array-enum-number.ts @@ -18,16 +18,16 @@ const enum E { B = -314 } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying number type a: E[] = new Array(0); } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying number type a: E[] = new Array(1); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[] = [42, -314, 42]; } diff --git a/es2panda/test/compiler/annotations/declaration-array-enum-string.ts b/es2panda/test/compiler/annotations/declaration-array-enum-string.ts index a55745424cd2cbffdff0f6844cd0e61f46a21db3..39e7411e1a54dfec881d36f64e0a08203b809baa 100644 --- a/es2panda/test/compiler/annotations/declaration-array-enum-string.ts +++ b/es2panda/test/compiler/annotations/declaration-array-enum-string.ts @@ -18,16 +18,16 @@ const enum E { B = "world!" } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying string type a: E[] = new Array(2); } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying string type a: E[] = new Array(3); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[] = ["Hello", "world!", "Hello"]; } diff --git a/es2panda/test/compiler/annotations/declaration-array-number.ts b/es2panda/test/compiler/annotations/declaration-array-number.ts index d573f6ebb3a1b6e184ad1aa23bb189d8f24308cd..13e7ce6232018cb48c06efb09457f279fa2be5b8 100644 --- a/es2panda/test/compiler/annotations/declaration-array-number.ts +++ b/es2panda/test/compiler/annotations/declaration-array-number.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number[]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: number[] = new Array(); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: number[] = [1, -2, 3]; } diff --git a/es2panda/test/compiler/annotations/declaration-array-string.ts b/es2panda/test/compiler/annotations/declaration-array-string.ts index 69cfe97efcf42aa24d331347f690be6f4c018abc..2de6642e2463d14334115eb53fe796878f86bf69 100644 --- a/es2panda/test/compiler/annotations/declaration-array-string.ts +++ b/es2panda/test/compiler/annotations/declaration-array-string.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: string[]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: string[] = new Array(); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: string[] = ["Hello", "world", "!"]; } diff --git a/es2panda/test/compiler/annotations/declaration-boolean.ts b/es2panda/test/compiler/annotations/declaration-boolean.ts index e9bf814b7e14fef3b349fe5c28dd3aefae01d47b..086025dbd9a81925f1c84429f7f88a27a32e022e 100644 --- a/es2panda/test/compiler/annotations/declaration-boolean.ts +++ b/es2panda/test/compiler/annotations/declaration-boolean.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: boolean; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: boolean = true; } \ No newline at end of file diff --git a/es2panda/test/compiler/annotations/declaration-combination.ts b/es2panda/test/compiler/annotations/declaration-combination.ts index 15fa1399e46e8c87bfa2a48eed28518b9efaa7a6..7eaa0d8662020b0f5903dfdf53d4857d8bcee05e 100644 --- a/es2panda/test/compiler/annotations/declaration-combination.ts +++ b/es2panda/test/compiler/annotations/declaration-combination.ts @@ -24,7 +24,7 @@ const enum E1 { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number b: number[] = [13, -10] c: string diff --git a/es2panda/test/compiler/annotations/declaration-empty.ts b/es2panda/test/compiler/annotations/declaration-empty.ts index 4d205f1d28c5947498aa920c5ee887ea825a4a16..80ae4e05b8580a0eeb03456386a7854204744303 100644 --- a/es2panda/test/compiler/annotations/declaration-empty.ts +++ b/es2panda/test/compiler/annotations/declaration-empty.ts @@ -13,4 +13,4 @@ * limitations under the License. */ -@interface Anno {} +@interface __$$ETS_ANNOTATION$$__Anno {} diff --git a/es2panda/test/compiler/annotations/declaration-enum-number.ts b/es2panda/test/compiler/annotations/declaration-enum-number.ts index 095d97c985d0ca75c019935f770412d0b8878c07..74f82890046248d5b22dae7f8015a8a4ba17b26f 100644 --- a/es2panda/test/compiler/annotations/declaration-enum-number.ts +++ b/es2panda/test/compiler/annotations/declaration-enum-number.ts @@ -18,11 +18,11 @@ const enum E { B = 314 } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // No initializer with underlying type number a: E = new Number(0) as number; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: E = 42; } \ No newline at end of file diff --git a/es2panda/test/compiler/annotations/declaration-enum-string.ts b/es2panda/test/compiler/annotations/declaration-enum-string.ts index 668b13ba51d72057b1111438bd928c13bedd489f..e8f77e41a217e4caa3a3db46de289c62347a6b45 100644 --- a/es2panda/test/compiler/annotations/declaration-enum-string.ts +++ b/es2panda/test/compiler/annotations/declaration-enum-string.ts @@ -18,11 +18,11 @@ const enum E { B = "world!" } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // No initializer with underlying type string a: E; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: E = "Hello"; } \ No newline at end of file diff --git a/es2panda/test/compiler/annotations/declaration-number.ts b/es2panda/test/compiler/annotations/declaration-number.ts index 47f96358bc2142b3490c406048a8761e8d70f250..241b6909776cdb45499d6cf50d99c0dc8a10fe0f 100644 --- a/es2panda/test/compiler/annotations/declaration-number.ts +++ b/es2panda/test/compiler/annotations/declaration-number.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: number = 42; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: number = -314; } \ No newline at end of file diff --git a/es2panda/test/compiler/annotations/declaration-string.ts b/es2panda/test/compiler/annotations/declaration-string.ts index 2f67dfdc93f9626c754bb871e1a3ea6eda569e78..52e99594617389227a8f3c2e932abc592571d4c2 100644 --- a/es2panda/test/compiler/annotations/declaration-string.ts +++ b/es2panda/test/compiler/annotations/declaration-string.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: string; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: string = "Hello world!"; } \ No newline at end of file diff --git a/es2panda/test/compiler/annotations/declaration-usage-3d-array-boolean.ts b/es2panda/test/compiler/annotations/declaration-usage-3d-array-boolean.ts index b228a7be88bbcdc9acf8ad31da5fa7d30d5aea2e..e707f942b5deddf83713a8c326d93162c8f4d590 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-3d-array-boolean.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-3d-array-boolean.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: boolean[][][]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-number.ts b/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-number.ts index 4439bb44647435b12b1217d6530bbedaa4f19297..3c503d4bdc442841224d4ec86bc0bb40042d38e9 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-number.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-number.ts @@ -18,7 +18,7 @@ const enum E { B = -2 } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[][][] = [[new Array(0)]]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-string.ts b/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-string.ts index 3ea8b4242bbbf19418701fbf8dce909f75358500..175a0dcb7a93270affd66c1335480c174a2be5f4 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-string.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-3d-array-enum-string.ts @@ -18,7 +18,7 @@ const enum E { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[][][] = [[new Array(2)]]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-3d-array-number.ts b/es2panda/test/compiler/annotations/declaration-usage-3d-array-number.ts index 880fe4b3a0ce614fb09658f56b12dc5034efa6ec..9dbe6711ed5b5491114969dd792ba535bf57c904 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-3d-array-number.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-3d-array-number.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number[][][]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-3d-array-string.ts b/es2panda/test/compiler/annotations/declaration-usage-3d-array-string.ts index 8bdbb7118e9996f7c99637dd147a82d0e24eb1b6..37e8437d72aa2c3145dca40ffa6691294fcb79e2 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-3d-array-string.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-3d-array-string.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: string[][][]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-array-boolean.ts b/es2panda/test/compiler/annotations/declaration-usage-array-boolean.ts index 06ae0c99571fdd0308b644460b368e65d069b7d4..cd8fece8279a7d132e7a6398b85631455d073d2c 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-array-boolean.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-array-boolean.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: boolean[]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-array-enum-number.ts b/es2panda/test/compiler/annotations/declaration-usage-array-enum-number.ts index 03162a2deff807a424dc76390e630d22eaa84c1a..07c2b6bb2f0f5c629986f44764655669ae399c8c 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-array-enum-number.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-array-enum-number.ts @@ -18,7 +18,7 @@ const enum E { B = -2, } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[] = new Array(0); } diff --git a/es2panda/test/compiler/annotations/declaration-usage-array-enum-string.ts b/es2panda/test/compiler/annotations/declaration-usage-array-enum-string.ts index aa3bd9c9fbd145aba6be513f37384ffc078ad36b..52742a3241cc03aafcb0daf8228f2a14bdee1464 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-array-enum-string.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-array-enum-string.ts @@ -18,7 +18,7 @@ const enum E { B = "world", } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[] = new Array(2); } diff --git a/es2panda/test/compiler/annotations/declaration-usage-array-number.ts b/es2panda/test/compiler/annotations/declaration-usage-array-number.ts index e2003df66c22c54a3302252748e0842a3752300c..2fe6ab909a70db9c28511dce3156556dfe604b73 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-array-number.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-array-number.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number[]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-array-string.ts b/es2panda/test/compiler/annotations/declaration-usage-array-string.ts index c14f9d9d8fd68fa1d0756c8f21d84b10da738391..c00fe674fcc5ac3a3cebb385e3c3a25224990fbe 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-array-string.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-array-string.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: string[]; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-boolean.ts b/es2panda/test/compiler/annotations/declaration-usage-boolean.ts index b47a2078487b87c4f8b679c8b12633597c77307a..3e7da49918ef6cf00cac1e7740bc1fb3464bc09a 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-boolean.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-boolean.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: boolean; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-combination.ts b/es2panda/test/compiler/annotations/declaration-usage-combination.ts index ca3633d57a3e83867c09edc7b3ab99426ce15cd1..30fa5b53c632a3c12675d4c6295c2f2cd9b85e6e 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-combination.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-combination.ts @@ -24,7 +24,7 @@ const enum E1 { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number b: number[] = [13, -10] c: string diff --git a/es2panda/test/compiler/annotations/declaration-usage-empty.ts b/es2panda/test/compiler/annotations/declaration-usage-empty.ts index badbc9745a1434a8e45996e86aee590e4705958f..b781add198329819f7d9e2290005b6ac08b2e6f2 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-empty.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-empty.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno {} +@interface __$$ETS_ANNOTATION$$__Anno {} @__$$ETS_ANNOTATION$$__Anno class A { diff --git a/es2panda/test/compiler/annotations/declaration-usage-enum-number.ts b/es2panda/test/compiler/annotations/declaration-usage-enum-number.ts index 3bc341432f881e4b6a2d9ad9b0b72fa01ad923ed..ecba445cf885279b39c803c6e6d267855e3ee957 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-enum-number.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-enum-number.ts @@ -18,7 +18,7 @@ const enum E { B = -2 } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E = new Number(0) as number; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-enum-string.ts b/es2panda/test/compiler/annotations/declaration-usage-enum-string.ts index d9c8f8e0477c4cf4d408da1c680efe924ab3e872..320500abe99431974fd5f281561301106df16035 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-enum-string.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-enum-string.ts @@ -18,7 +18,7 @@ const enum E { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-number.ts b/es2panda/test/compiler/annotations/declaration-usage-number.ts index 34e2ac30ec1078242f3e0922547280ed6384173e..637713e19282cae6bd44de9a9827a0ddc003ede0 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-number.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-number.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number; } diff --git a/es2panda/test/compiler/annotations/declaration-usage-string.ts b/es2panda/test/compiler/annotations/declaration-usage-string.ts index 0c627768fd650a5e4bac6cac31df0b4baaf5d8b6..5ad01ef4ed9394074ca233092f0bf41cc67628ab 100644 --- a/es2panda/test/compiler/annotations/declaration-usage-string.ts +++ b/es2panda/test/compiler/annotations/declaration-usage-string.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: string; } diff --git a/es2panda/test/compiler/annotations/export.ts b/es2panda/test/compiler/annotations/export.ts index d11841f8a91f6fa63d0b960f671f4883982a4581..3dd42d6c7458e22e5114fef020eed609dc3a3e8f 100644 --- a/es2panda/test/compiler/annotations/export.ts +++ b/es2panda/test/compiler/annotations/export.ts @@ -15,9 +15,9 @@ // import tests are located in compiler/ts/annotations-projects -export @interface Anno1 {} +export @interface __$$ETS_ANNOTATION$$__Anno1 {} -export @interface Anno2 { +export @interface __$$ETS_ANNOTATION$$__Anno2 { a: number = 0; } diff --git a/es2panda/test/compiler/annotations/multiple-annotations.ts b/es2panda/test/compiler/annotations/multiple-annotations.ts index cf0af17c46b720c83ce8e40a6a328b68010b19f7..246af473b26a6a8d76defe52e36865f928a33bc7 100644 --- a/es2panda/test/compiler/annotations/multiple-annotations.ts +++ b/es2panda/test/compiler/annotations/multiple-annotations.ts @@ -13,15 +13,15 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number = 1; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { b: string = "string" } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { c: boolean[] = [true, false]; } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/abcinputs/bytecodehar.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/abcinputs/bytecodehar.txt new file mode 100644 index 0000000000000000000000000000000000000000..2bed2a047fa2004fcca50e9d9c5051a4027a913f --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/abcinputs/bytecodehar.txt @@ -0,0 +1,2 @@ +bytecodehar-dynamic-import.ts +bytecodehar-static-import.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/bytecodehar-dynamic-import.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/bytecodehar-dynamic-import.ts new file mode 100644 index 0000000000000000000000000000000000000000..8a98a541e1cfd9b3fc982dbc7d0174ed46c50ea2 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/bytecodehar-dynamic-import.ts @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export let test: string = "test"; + +function testReplacementWoAt() { + import("@normalized:N&module&bundle&lib/importfile1&1.0.0"); + import("@normalized:N&module&bundle&lib/importfile1&"); + import("@normalized:N&&bundle&lib/importfile1&1.0.0"); + import("@normalized:N&&bundle&lib/importfile1&"); + + // No-effect since no version info in compileContextInfo.json + import("@normalized:N&&&lib2/importfile3&"); +} + +function testReplacementWithAt() { + import("@normalized:N&module&&@ohos/lib/importfile2&1.0.0"); + import("@normalized:N&module&&@ohos/lib/importfile2&"); + import("@normalized:N&&&@ohos/lib/importfile2&1.0.0"); + import("@normalized:N&&&@ohos/lib/importfile2&"); + + // No-effect since no version info in compileContextInfo.json + import("@normalized:N&&&@ohos/lib2/importfile4&"); +} + +function testNonOhmurl() { + import("aaa"); +} + +function testNonConst() { + // Take effect only under release due to bcopt + let a = "@normalized:N&&bundle&lib/importfile1&" + import(a); + + a = "@normalized:N&&bundle&lib/importfile1&"; + let b = "@normalized:N&&bundle&lib/importfile1&"; + import(a); + + a = "@normalized:N&&bundle&lib/importfile1&"; + "@normalized:N&&bundle&lib/importfile1&"; + import(a); +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/bytecodehar-static-import.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/bytecodehar-static-import.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b6252c67f1dd6029d825afb21f17aacfaababd9 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/bytecodehar-static-import.ts @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// testReplacementWoAt +import * as a from "@normalized:N&module&bundle&lib/importfile1&1.0.0"; +import * as b from "@normalized:N&module&bundle&lib/importfile1&"; +import * as c from "@normalized:N&&bundle&lib/importfile1&1.0.0"; +import * as d from "@normalized:N&&bundle&lib/importfile1&"; + +// No-effect since no version info in compileContextInfo.json +import * as e from "@normalized:N&&&lib2/importfile3&"; + +//testReplacementWithAt +import * as f from "@normalized:N&module&&@ohos/lib/importfile2&1.0.0"; +import * as g from "@normalized:N&module&&@ohos/lib/importfile2&"; +import * as h from "@normalized:N&&&@ohos/lib/importfile2&1.0.0"; +import * as i from "@normalized:N&&&@ohos/lib/importfile2&"; + +// No-effect since no version info in compileContextInfo.json +import * as j from "@normalized:N&&&@ohos/lib2/importfile4&"; + +function foo() { + print([a, b, c, d, e, f, g, h, i, j]); +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/compileContextInfo.json b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/compileContextInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..3c35014906e6b28a3452825af397a0bb1487b1a0 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/compileContextInfo.json @@ -0,0 +1,12 @@ +{ + "compileEntries": [ + "&myapp/hap-file-exec&" + ], + "hspPkgNames": [], + "updateVersionInfo": { + "bytecodehar": { + "lib": "2.0.0", + "@ohos/lib": "2.0.0" + } + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/hap-file-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/hap-file-exec-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..6f146bddc005d33fdf60e0a7556f8bad7c9b02ca --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/hap-file-exec-expected.pa.txt @@ -0,0 +1,1670 @@ +All Dependency Files: +program_file: bytecodehar-abcinput.abc +record_name: &bytecodehar/bytecodehar-dynamic-import& +program_file: bytecodehar-abcinput.abc +record_name: &bytecodehar/bytecodehar-static-import& +program_file: hap-file-exec.ts +record_name: &myapp/hap-file-exec& +program_file: importfile1.ts +record_name: bundle&lib/importfile1&2.0.0 +program_file: importfile2.ts +record_name: &@ohos/lib/importfile2&2.0.0 +program_file: importfile3.ts +record_name: &lib2/importfile3& +program_file: importfile4.ts +record_name: &@ohos/lib2/importfile4& + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst(any a0, any a1, any a2) { + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl(any a0, any a1, any a2) { + lda.str aaa + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib2/importfile4& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&&lib2/importfile3& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst, 0x0 + definefunc 0x1, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl, 0x0 + definefunc 0x2, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt, 0x0 + definefunc 0x3, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt, 0x0 + lda.str test + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x4, &bytecodehar/bytecodehar-dynamic-import&.#~A=#A, &bytecodehar/bytecodehar-dynamic-import&_2514, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2466 +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2470 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2514 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt"; "&bytecodehar/bytecodehar-dynamic-import&.#~A=#A"; "@normalized:N&&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&&&@ohos/lib2/importfile4&"; "@normalized:N&&&lib2/importfile3&"; "@normalized:N&&bundle&lib/importfile1&2.0.0"; "@normalized:N&module&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&module&bundle&lib/importfile1&2.0.0"; "aaa"; "prototype"; "test"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x18 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#*#foo(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + createemptyarray 0x1 + sta v1 + ldlexvar 0x0, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + stownbyindex 0x2, v1, 0x0 + ldlexvar 0x0, 0x1 + sta v2 + throw.undefinedifholewithname b + lda v2 + stownbyindex 0x4, v1, 0x1 + ldlexvar 0x0, 0x2 + sta v2 + throw.undefinedifholewithname c + lda v2 + stownbyindex 0x6, v1, 0x2 + ldlexvar 0x0, 0x3 + sta v2 + throw.undefinedifholewithname d + lda v2 + stownbyindex 0x8, v1, 0x3 + ldlexvar 0x0, 0x4 + sta v2 + throw.undefinedifholewithname e + lda v2 + stownbyindex 0xa, v1, 0x4 + ldlexvar 0x0, 0x5 + sta v2 + throw.undefinedifholewithname f + lda v2 + stownbyindex 0xc, v1, 0x5 + ldlexvar 0x0, 0x6 + sta v2 + throw.undefinedifholewithname g + lda v2 + stownbyindex 0xe, v1, 0x6 + ldlexvar 0x0, 0x7 + sta v2 + throw.undefinedifholewithname h + lda v2 + stownbyindex 0x10, v1, 0x7 + ldlexvar 0x0, 0x8 + sta v2 + throw.undefinedifholewithname i + lda v2 + stownbyindex 0x12, v1, 0x8 + ldlexvar 0x0, 0x9 + sta v2 + throw.undefinedifholewithname j + lda v2 + stownbyindex 0x14, v1, 0x9 + lda v0 + callarg1 0x16, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.func_main_0(any a0, any a1, any a2) { + newlexenv 0xa + definefunc 0x0, &bytecodehar/bytecodehar-static-import&.#*#foo, 0x0 + getmodulenamespace 0x0 + stlexvar 0x0, 0x0 + getmodulenamespace 0x1 + stlexvar 0x0, 0x1 + getmodulenamespace 0x2 + stlexvar 0x0, 0x2 + getmodulenamespace 0x3 + stlexvar 0x0, 0x3 + getmodulenamespace 0x4 + stlexvar 0x0, 0x4 + getmodulenamespace 0x5 + stlexvar 0x0, 0x5 + getmodulenamespace 0x6 + stlexvar 0x0, 0x6 + getmodulenamespace 0x7 + stlexvar 0x0, 0x7 + getmodulenamespace 0x8 + stlexvar 0x0, 0x8 + getmodulenamespace 0x9 + stlexvar 0x0, 0x9 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar/bytecodehar-static-import&.#~A=#A, &bytecodehar/bytecodehar-static-import&_2663, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2523 +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2527 +{ + index: 0 + tag: 2 + val: 10 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 2 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 3 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 4 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 5 + tag: 5 + val: @normalized:N&&&lib2/importfile3& +}, +{ + index: 6 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 7 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 8 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 9 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 10 + tag: 5 + val: @normalized:N&&&@ohos/lib2/importfile4& +}, +{ + index: 11 + tag: 2 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 10 +}, +{ + index: 13 + tag: 5 + val: a +}, +{ + index: 14 + tag: 9 + val: 0 +}, +{ + index: 15 + tag: 5 + val: b +}, +{ + index: 16 + tag: 9 + val: 1 +}, +{ + index: 17 + tag: 5 + val: c +}, +{ + index: 18 + tag: 9 + val: 2 +}, +{ + index: 19 + tag: 5 + val: d +}, +{ + index: 20 + tag: 9 + val: 3 +}, +{ + index: 21 + tag: 5 + val: e +}, +{ + index: 22 + tag: 9 + val: 4 +}, +{ + index: 23 + tag: 5 + val: f +}, +{ + index: 24 + tag: 9 + val: 5 +}, +{ + index: 25 + tag: 5 + val: g +}, +{ + index: 26 + tag: 9 + val: 6 +}, +{ + index: 27 + tag: 5 + val: h +}, +{ + index: 28 + tag: 9 + val: 7 +}, +{ + index: 29 + tag: 5 + val: i +}, +{ + index: 30 + tag: 9 + val: 8 +}, +{ + index: 31 + tag: 5 + val: j +}, +{ + index: 32 + tag: 9 + val: 9 +}, +{ + index: 33 + tag: 2 + val: 1 +}, +{ + index: 34 + tag: 5 + val: Anno2 +}, +{ + index: 35 + tag: 5 + val: Anno2 +}, +{ + index: 36 + tag: 2 + val: 0 +}, +{ + index: 37 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2663 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-static-import&.#*#foo"; "&bytecodehar/bytecodehar-static-import&.#~A=#A"; "a"; "b"; "c"; "d"; "e"; "f"; "g"; "h"; "i"; "j"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0xd +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + getmodulenamespace 0x0 + sta v0 + getmodulenamespace 0x1 + sta v1 + tryldglobalbyname 0x0, print + sta v2 + lda v0 + ldobjbyname 0x1, test + sta v0 + lda v2 + callarg1 0x3, v0 + tryldglobalbyname 0x5, print + sta v0 + lda v1 + ldobjbyname 0x6, test + sta v1 + lda v0 + callarg1 0x8, v1 + ldhole + sta v0 + defineclasswithbuffer 0xa, &myapp/hap-file-exec&.#~A=#A, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0xb, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 2 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-dynamic-import& +}, +{ + index: 2 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-static-import& +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 2 +}, +{ + index: 5 + tag: 5 + val: bytecodeharDynamicImport +}, +{ + index: 6 + tag: 9 + val: 0 +}, +{ + index: 7 + tag: 5 + val: bytecodeharStaticImport +}, +{ + index: 8 + tag: 9 + val: 1 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#~A=#A"; "print"; "prototype"; "test"; +slotNum = 0x0 +.language ECMAScript +.function any bundle&lib/importfile1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot bundle&lib/importfile1&2.0.0_0 +------------------------------------ +slot bundle&lib/importfile1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test1 +}, +{ + index: 5 + tag: 5 + val: test1 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib/importfile2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_0 +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test2 +}, +{ + index: 5 + tag: 5 + val: test2 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &lib2/importfile3&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &lib2/importfile3&_0 +------------------------------------ +slot &lib2/importfile3&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test3 +}, +{ + index: 5 + tag: 5 + val: test3 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib2/importfile4&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib2/importfile4&_0 +------------------------------------ +slot &@ohos/lib2/importfile4&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test4 +}, +{ + index: 5 + tag: 5 + val: test4 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst(any a0, any a1, any a2) { + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl(any a0, any a1, any a2) { + lda.str aaa + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib2/importfile4& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&&lib2/importfile3& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst, 0x0 + definefunc 0x1, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl, 0x0 + definefunc 0x2, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt, 0x0 + definefunc 0x3, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt, 0x0 + lda.str test + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x4, &bytecodehar/bytecodehar-dynamic-import&.#~A=#A, &bytecodehar/bytecodehar-dynamic-import&_2514, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2466 +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2470 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2514 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt"; "&bytecodehar/bytecodehar-dynamic-import&.#~A=#A"; "@normalized:N&&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&&&@ohos/lib2/importfile4&"; "@normalized:N&&&lib2/importfile3&"; "@normalized:N&&bundle&lib/importfile1&2.0.0"; "@normalized:N&module&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&module&bundle&lib/importfile1&2.0.0"; "aaa"; "prototype"; "test"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x18 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#*#foo(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + createemptyarray 0x1 + sta v1 + ldlexvar 0x0, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + stownbyindex 0x2, v1, 0x0 + ldlexvar 0x0, 0x1 + sta v2 + throw.undefinedifholewithname b + lda v2 + stownbyindex 0x4, v1, 0x1 + ldlexvar 0x0, 0x2 + sta v2 + throw.undefinedifholewithname c + lda v2 + stownbyindex 0x6, v1, 0x2 + ldlexvar 0x0, 0x3 + sta v2 + throw.undefinedifholewithname d + lda v2 + stownbyindex 0x8, v1, 0x3 + ldlexvar 0x0, 0x4 + sta v2 + throw.undefinedifholewithname e + lda v2 + stownbyindex 0xa, v1, 0x4 + ldlexvar 0x0, 0x5 + sta v2 + throw.undefinedifholewithname f + lda v2 + stownbyindex 0xc, v1, 0x5 + ldlexvar 0x0, 0x6 + sta v2 + throw.undefinedifholewithname g + lda v2 + stownbyindex 0xe, v1, 0x6 + ldlexvar 0x0, 0x7 + sta v2 + throw.undefinedifholewithname h + lda v2 + stownbyindex 0x10, v1, 0x7 + ldlexvar 0x0, 0x8 + sta v2 + throw.undefinedifholewithname i + lda v2 + stownbyindex 0x12, v1, 0x8 + ldlexvar 0x0, 0x9 + sta v2 + throw.undefinedifholewithname j + lda v2 + stownbyindex 0x14, v1, 0x9 + lda v0 + callarg1 0x16, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.func_main_0(any a0, any a1, any a2) { + newlexenv 0xa + definefunc 0x0, &bytecodehar/bytecodehar-static-import&.#*#foo, 0x0 + getmodulenamespace 0x0 + stlexvar 0x0, 0x0 + getmodulenamespace 0x1 + stlexvar 0x0, 0x1 + getmodulenamespace 0x2 + stlexvar 0x0, 0x2 + getmodulenamespace 0x3 + stlexvar 0x0, 0x3 + getmodulenamespace 0x4 + stlexvar 0x0, 0x4 + getmodulenamespace 0x5 + stlexvar 0x0, 0x5 + getmodulenamespace 0x6 + stlexvar 0x0, 0x6 + getmodulenamespace 0x7 + stlexvar 0x0, 0x7 + getmodulenamespace 0x8 + stlexvar 0x0, 0x8 + getmodulenamespace 0x9 + stlexvar 0x0, 0x9 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar/bytecodehar-static-import&.#~A=#A, &bytecodehar/bytecodehar-static-import&_2663, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2523 +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2527 +{ + index: 0 + tag: 2 + val: 10 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 2 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 3 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 4 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 5 + tag: 5 + val: @normalized:N&&&lib2/importfile3& +}, +{ + index: 6 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 7 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 8 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 9 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 10 + tag: 5 + val: @normalized:N&&&@ohos/lib2/importfile4& +}, +{ + index: 11 + tag: 2 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 10 +}, +{ + index: 13 + tag: 5 + val: a +}, +{ + index: 14 + tag: 9 + val: 0 +}, +{ + index: 15 + tag: 5 + val: b +}, +{ + index: 16 + tag: 9 + val: 1 +}, +{ + index: 17 + tag: 5 + val: c +}, +{ + index: 18 + tag: 9 + val: 2 +}, +{ + index: 19 + tag: 5 + val: d +}, +{ + index: 20 + tag: 9 + val: 3 +}, +{ + index: 21 + tag: 5 + val: e +}, +{ + index: 22 + tag: 9 + val: 4 +}, +{ + index: 23 + tag: 5 + val: f +}, +{ + index: 24 + tag: 9 + val: 5 +}, +{ + index: 25 + tag: 5 + val: g +}, +{ + index: 26 + tag: 9 + val: 6 +}, +{ + index: 27 + tag: 5 + val: h +}, +{ + index: 28 + tag: 9 + val: 7 +}, +{ + index: 29 + tag: 5 + val: i +}, +{ + index: 30 + tag: 9 + val: 8 +}, +{ + index: 31 + tag: 5 + val: j +}, +{ + index: 32 + tag: 9 + val: 9 +}, +{ + index: 33 + tag: 2 + val: 1 +}, +{ + index: 34 + tag: 5 + val: Anno2 +}, +{ + index: 35 + tag: 5 + val: Anno2 +}, +{ + index: 36 + tag: 2 + val: 0 +}, +{ + index: 37 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2663 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-static-import&.#*#foo"; "&bytecodehar/bytecodehar-static-import&.#~A=#A"; "a"; "b"; "c"; "d"; "e"; "f"; "g"; "h"; "i"; "j"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0xd +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + getmodulenamespace 0x0 + sta v0 + getmodulenamespace 0x1 + sta v1 + tryldglobalbyname 0x0, print + sta v2 + lda v0 + ldobjbyname 0x1, test + sta v0 + lda v2 + callarg1 0x3, v0 + tryldglobalbyname 0x5, print + sta v0 + lda v1 + ldobjbyname 0x6, test + sta v1 + lda v0 + callarg1 0x8, v1 + ldhole + sta v0 + defineclasswithbuffer 0xa, &myapp/hap-file-exec&.#~A=#A, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0xb, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 2 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-dynamic-import& +}, +{ + index: 2 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-static-import& +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 2 +}, +{ + index: 5 + tag: 5 + val: bytecodeharDynamicImport +}, +{ + index: 6 + tag: 9 + val: 0 +}, +{ + index: 7 + tag: 5 + val: bytecodeharStaticImport +}, +{ + index: 8 + tag: 9 + val: 1 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#~A=#A"; "print"; "prototype"; "test"; +slotNum = 0x0 +.language ECMAScript +.function any bundle&lib/importfile1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot bundle&lib/importfile1&2.0.0_0 +------------------------------------ +slot bundle&lib/importfile1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test1 +}, +{ + index: 5 + tag: 5 + val: test1 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib/importfile2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_0 +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test2 +}, +{ + index: 5 + tag: 5 + val: test2 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &lib2/importfile3&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &lib2/importfile3&_0 +------------------------------------ +slot &lib2/importfile3&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test3 +}, +{ + index: 5 + tag: 5 + val: test3 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib2/importfile4&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib2/importfile4&_0 +------------------------------------ +slot &@ohos/lib2/importfile4&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test4 +}, +{ + index: 5 + tag: 5 + val: test4 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/hap-file-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/hap-file-exec.ts new file mode 100644 index 0000000000000000000000000000000000000000..6c9b1c36d21c906a373e1b53da815a5fade14555 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/hap-file-exec.ts @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as bytecodeharDynamicImport from "@normalized:N&&&bytecodehar/bytecodehar-dynamic-import&"; +import * as bytecodeharStaticImport from "@normalized:N&&&bytecodehar/bytecodehar-static-import&"; + +print(bytecodeharDynamicImport.test) +print(bytecodeharStaticImport.test) + +@bytecodeharDynamicImport.__$$ETS_ANNOTATION$$__Anno1() +@bytecodeharStaticImport.__$$ETS_ANNOTATION$$__Anno2() +class A { } diff --git a/ets2panda/test/isolated_declgen/infer_function_return_type_with_variable-expected.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile1.ts similarity index 91% rename from ets2panda/test/isolated_declgen/infer_function_return_type_with_variable-expected.txt rename to es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile1.ts index 6eced866112266e6fc719f40a73bfa8ce070d9a3..5635f70b7138307a334a7526af3c8d596a37dc73 100644 --- a/ets2panda/test/isolated_declgen/infer_function_return_type_with_variable-expected.txt +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile1.ts @@ -13,4 +13,4 @@ * limitations under the License. */ - export declare function foo(a: int): String|B|Int|A; \ No newline at end of file +export const test1: boolean = true; \ No newline at end of file diff --git a/ets2panda/test/isolated_declgen/infer_function_return_type_with_literal-expected.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile2.ts similarity index 91% rename from ets2panda/test/isolated_declgen/infer_function_return_type_with_literal-expected.txt rename to es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile2.ts index 05805385471adb6e052b1feb486d7bdf830517ad..5267ff5e2937f60b551f7dc08245daca4a93ff68 100644 --- a/ets2panda/test/isolated_declgen/infer_function_return_type_with_literal-expected.txt +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile2.ts @@ -12,5 +12,5 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - export declare function foo(a: int): Int|Boolean|String; \ No newline at end of file + +export const test2: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile3.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile3.ts new file mode 100644 index 0000000000000000000000000000000000000000..d9a8057d7ba62b25ef432a284327fb347718ea56 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile3.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const test3: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile4.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile4.ts new file mode 100644 index 0000000000000000000000000000000000000000..3fedda824b526993822e0c90fc38728ec99e45f9 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/importfile4.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const test4: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..185dca611160d3ada3534a652765594eb6ec9472 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-accuate-version-update/recordnames.txt @@ -0,0 +1,7 @@ +bytecodehar-dynamic-import:&bytecodehar/bytecodehar-dynamic-import& +bytecodehar-static-import:&bytecodehar/bytecodehar-static-import& +importfile1:bundle&lib/importfile1&2.0.0 +importfile2:&@ohos/lib/importfile2&2.0.0 +importfile3:&lib2/importfile3& +importfile4:&@ohos/lib2/importfile4& +hap-file-exec:&myapp/hap-file-exec& diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/abcinputs/bytecodehar1.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/abcinputs/bytecodehar1.txt new file mode 100644 index 0000000000000000000000000000000000000000..44fef6254c424437d17bdd628f89ec1827c753d0 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/abcinputs/bytecodehar1.txt @@ -0,0 +1,2 @@ +bytecodehar1-file1.ts +bytecodehar1-file2.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/abcinputs/bytecodehar2.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/abcinputs/bytecodehar2.txt new file mode 100644 index 0000000000000000000000000000000000000000..01249cd0afb7ae24d54f9a1b926115fc33893104 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/abcinputs/bytecodehar2.txt @@ -0,0 +1,2 @@ +bytecodehar2-file1.ts +bytecodehar2-file2.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar1-file1.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar1-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..27094c100af48c267e81b02ae128158162289e0b --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar1-file1.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {test as test1} from '@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0' + +export function test() { + print('bytecodehar1.file1.test'); + import('@normalized:N&&&sourcehar/sourcehar-file1&2.0.0') +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar1-file2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar1-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..5962b22672130d07d4de572d0a55364e61b84dec --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar1-file2.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {test as test1} from "@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&1.0.0" + +export function test() { + print('bytecodehar1.file2.test'); + import("@normalized:N&&&sourcehar/sourcehar-file2&2.0.0") +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar2-file1.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar2-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc82d9af7342aa36651045fde1b22f60a5147c20 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar2-file1.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function test() { + print('bytecodehar2.file1.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar2-file2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar2-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..aacfd725551080ed37cc0ff7f3bd39b9b7179cd1 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/bytecodehar2-file2.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function test() { + print('bytecodehar2.file2.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/compileContextInfo.json b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/compileContextInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..a8744ff6d302a7650651886c9655de5ad7c3e609 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/compileContextInfo.json @@ -0,0 +1,44 @@ +{ + "compileEntries": [ + "&myapp/hap-file-exec&" + ], + "hspPkgNames": [], + "pkgContextInfo": { + "myapp": { + "packageName": "myapp", + "bundleName": "", + "moduleName": "", + "version": "", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "bytecodehar1": { + "packageName": "bytecodehar1", + "bundleName": "", + "moduleName": "", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "@ohos/bytecodehar2": { + "packageName": "@ohos/bytecodehar2", + "bundleName": "", + "moduleName": "", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "sourcehar": { + "packageName": "sourcehar", + "bundleName": "", + "moduleName": "", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + } + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..d327a5a78ae710fd6825297c7ad8bc8a44aeacec --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec-expected.pa.txt @@ -0,0 +1,1354 @@ +All Dependency Files: +program_file: bytecodehar1-abcinput.abc +record_name: &bytecodehar1/bytecodehar1-file1&2.0.0 +program_file: bytecodehar2-abcinput.abc +record_name: &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +program_file: hap-file-exec.ts +record_name: &myapp/hap-file-exec& +program_file: sourcehar-file1.ts +record_name: &sourcehar/sourcehar-file1&2.0.0 +program_file: sourcehar-file2.ts +record_name: &sourcehar/sourcehar-file2&2.0.0 + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file1&2.0.0_1844, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1782 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1786 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1844 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "bytecodehar1.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file2&2.0.0_1915, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1853 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1857 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno2 +}, +{ + index: 9 + tag: 5 + val: Anno2 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1915 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file2&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file2&2.0.0"; "bytecodehar1.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1607 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1611 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1712, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1664 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1668 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno2 +}, +{ + index: 5 + tag: 5 + val: Anno2 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1712 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A"; "bytecodehar2.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname A + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~B=#B(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~B=#B, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: A +}, +{ + index: 4 + tag: 5 + val: A +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: Anno1 +}, +{ + index: 7 + tag: 5 + val: Anno1 +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "A"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +{ + index: 8 + tag: 5 + val: test +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file2&2.0.0.#*#test"; "print"; "sourcehar.file2.test"; +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file1&2.0.0_1844, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1782 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1786 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1844 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "bytecodehar1.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1607 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1611 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname A + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~B=#B(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~B=#B, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: A +}, +{ + index: 4 + tag: 5 + val: A +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: Anno1 +}, +{ + index: 7 + tag: 5 + val: Anno1 +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "A"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +{ + index: 8 + tag: 5 + val: test +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file2&2.0.0.#*#test"; "print"; "sourcehar.file2.test"; diff --git a/ets2panda/test/isolated_declgen/infer_function_return_type_with_variable.ets b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec.ts similarity index 73% rename from ets2panda/test/isolated_declgen/infer_function_return_type_with_variable.ets rename to es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec.ts index 4a19a2de337f3d47e3f48e3886f6269b06a6b799..8fe9e1625e9e5f9626041a272bd5853e1937ba51 100644 --- a/ets2panda/test/isolated_declgen/infer_function_return_type_with_variable.ets +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/hap-file-exec.ts @@ -12,21 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -class A {} -class B {} -export function foo(a: int) -{ - if (a < 0) { - return 1; - } - if (a == 0) { - return new A; - } - if (a > 0) { - return new B; - } - - return "hello"; -} \ No newline at end of file +import { test, __$$ETS_ANNOTATION$$__Anno1, A } from "@normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0" + +function main() { + test(); + let a = new A(); +} + +@__$$ETS_ANNOTATION$$__Anno1({ b: true }) +class B { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..70074eddf79afcc444b4ccee16630de0b4fa6d9d --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/recordnames.txt @@ -0,0 +1,7 @@ +bytecodehar1-file1:&bytecodehar1/bytecodehar1-file1&2.0.0 +bytecodehar1-file2:&bytecodehar1/bytecodehar1-file2&2.0.0 +bytecodehar2-file1:&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +bytecodehar2-file2:&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +sourcehar-file1:&sourcehar/sourcehar-file1&2.0.0 +sourcehar-file2:&sourcehar/sourcehar-file2&2.0.0 +hap-file-exec:&myapp/hap-file-exec& diff --git a/ets2panda/test/isolated_declgen/isolated_function_with_optional_parameter-expected.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/sourcehar-file1.ts similarity index 81% rename from ets2panda/test/isolated_declgen/isolated_function_with_optional_parameter-expected.txt rename to es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/sourcehar-file1.ts index 5276a1c1bdc1e8292851d58d4bf38cf6bba15789..f688431373716beb39877a74cd5d87297d0a64e3 100644 --- a/ets2panda/test/isolated_declgen/isolated_function_with_optional_parameter-expected.txt +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/sourcehar-file1.ts @@ -13,6 +13,8 @@ * limitations under the License. */ -export declare function greet(name: string, age?: number): String; +import {test as test1} from '@normalized:N&&&sourcehar/sourcehar-file2&2.0.0' -export declare function multiply(x: number, gensym%%_1?: number): double; \ No newline at end of file +export function test() { + print('sourcehar.file1.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/sourcehar-file2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/sourcehar-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..7702af07787a7190c88033b40fe1024e0f5e8e24 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-dependency-resolve/sourcehar-file2.ts @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function test() { + print('sourcehar.file2.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/abcinputs/bytecodehar.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/abcinputs/bytecodehar.txt new file mode 100644 index 0000000000000000000000000000000000000000..2bed2a047fa2004fcca50e9d9c5051a4027a913f --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/abcinputs/bytecodehar.txt @@ -0,0 +1,2 @@ +bytecodehar-dynamic-import.ts +bytecodehar-static-import.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/bytecodehar-dynamic-import.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/bytecodehar-dynamic-import.ts new file mode 100644 index 0000000000000000000000000000000000000000..30d55ea9aefa0f15c5b3654293d3f95021d5ae69 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/bytecodehar-dynamic-import.ts @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export let test: string = "test"; + +function testReplacementWoAt() { + import("@normalized:N&module&bundle&lib/importfile1&1.0.0"); + import("@normalized:N&module&bundle&lib/importfile1&"); + import("@normalized:N&module&bundle&lib/importfile1&1.0.0"); + import("@normalized:N&module&bundle&lib/importfile1&"); + + // No-effect since no version info in compileContextInfo.json + import("@normalized:N&&&lib2/importfile3&"); +} + +function testReplacementWithAt() { + import("@normalized:N&lib&&@ohos/lib/importfile2&1.0.0"); + import("@normalized:N&lib&&@ohos/lib/importfile2&"); + import("@normalized:N&lib&&@ohos/lib/importfile2&1.0.0"); + import("@normalized:N&lib&&@ohos/lib/importfile2&"); + + // No-effect since no version info in compileContextInfo.json + import("@normalized:N&&&@ohos/lib2/importfile4&"); +} + +function testNonOhmurl() { + import("aaa"); +} + +function testNonConst() { + // Take effect only under release due to bcopt + let a = "@normalized:N&module&bundle&lib/importfile1&" + import(a); + + a = "@normalized:N&module&bundle&lib/importfile1&"; + let b = "@normalized:N&module&bundle&lib/importfile1&"; + import(a); + + a = "@normalized:N&module&bundle&lib/importfile1&"; + "@normalized:N&module&bundle&lib/importfile1&"; + import(a); +} + +@interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A1 { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/bytecodehar-static-import.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/bytecodehar-static-import.ts new file mode 100644 index 0000000000000000000000000000000000000000..e8d2d8608ccdee5f66f5df5c96c221b6b0353a8c --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/bytecodehar-static-import.ts @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// testReplacementWoAt +import * as a from "@normalized:N&module&bundle&lib/importfile1&1.0.0"; +import * as b from "@normalized:N&module&bundle&lib/importfile1&"; +import * as c from "@normalized:N&&bundle&lib/importfile1&1.0.0"; +import * as d from "@normalized:N&&bundle&lib/importfile1&"; + +// No-effect since no version info in compileContextInfo.json +import * as e from "@normalized:N&&&lib2/importfile3&"; + +//testReplacementWithAt +import * as f from "@normalized:N&module&&@ohos/lib/importfile2&1.0.0"; +import * as g from "@normalized:N&module&&@ohos/lib/importfile2&"; +import * as h from "@normalized:N&&&@ohos/lib/importfile2&1.0.0"; +import * as i from "@normalized:N&&&@ohos/lib/importfile2&"; + +// No-effect since no version info in compileContextInfo.json +import * as j from "@normalized:N&&&@ohos/lib2/importfile4&"; + +function foo() { + print([a, b, c, d, e, f, g, h, i, j]); +} + +@interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class B { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/compileContextInfo.json b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/compileContextInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..f7127bcf76b35ba74fb1a0d26f7adc3dd276681f --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/compileContextInfo.json @@ -0,0 +1,17 @@ +{ + "compileEntries": [ + "com.inter_app.hsp&myapp/inter-app-hsp-file-exec&" + ], + "hspPkgNames": [ + "lib", + "@ohos/lib" + ], + "updateVersionInfo": { + "bytecodehar": { + "lib": "2.0.0", + "@ohos/lib": "2.0.0" + } + }, + "needModifyRecord": true, + "bundleName": "com.inter_app.hsp" +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile1.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile1.ts new file mode 100644 index 0000000000000000000000000000000000000000..5635f70b7138307a334a7526af3c8d596a37dc73 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile1.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const test1: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile2.ts new file mode 100644 index 0000000000000000000000000000000000000000..5267ff5e2937f60b551f7dc08245daca4a93ff68 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile2.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const test2: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile3.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile3.ts new file mode 100644 index 0000000000000000000000000000000000000000..d9a8057d7ba62b25ef432a284327fb347718ea56 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile3.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const test3: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile4.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile4.ts new file mode 100644 index 0000000000000000000000000000000000000000..3fedda824b526993822e0c90fc38728ec99e45f9 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/importfile4.ts @@ -0,0 +1,16 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const test4: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/inter-app-hsp-file-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/inter-app-hsp-file-exec-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..cf4b80b652cb86899bbfe097ffbcf3b538ac6061 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/inter-app-hsp-file-exec-expected.pa.txt @@ -0,0 +1,1508 @@ +All Dependency Files: +program_file: bytecodehar-abcinput.abc +record_name: com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import& +program_file: bytecodehar-abcinput.abc +record_name: com.inter_app.hsp&bytecodehar/bytecodehar-static-import& +program_file: importfile3.ts +record_name: com.inter_app.hsp&lib2/importfile3& +program_file: importfile4.ts +record_name: com.inter_app.hsp&@ohos/lib2/importfile4& +program_file: inter-app-hsp-file-exec.ts +record_name: com.inter_app.hsp&myapp/inter-app-hsp-file-exec& + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl(any a0, any a1, any a2) { + lda.str aaa + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt(any a0, any a1, any a2) { + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&com.inter_app.hsp&@ohos/lib2/importfile4& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&com.inter_app.hsp&lib2/importfile3& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#~A1=#A1(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst, 0x0 + definefunc 0x1, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl, 0x0 + definefunc 0x2, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt, 0x0 + definefunc 0x3, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt, 0x0 + lda.str test + stmodulevar 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x4, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#~A1=#A1, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2561, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2521 +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2525 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2561 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"@normalized:N&&com.inter_app.hsp&@ohos/lib2/importfile4&"; "@normalized:N&&com.inter_app.hsp&lib2/importfile3&"; "@normalized:N&lib&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&module&bundle&lib/importfile1&2.0.0"; "aaa"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#~A1=#A1"; "prototype"; "test"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x18 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#*#foo(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + createemptyarray 0x1 + sta v1 + ldlexvar 0x0, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + stownbyindex 0x2, v1, 0x0 + ldlexvar 0x0, 0x1 + sta v2 + throw.undefinedifholewithname b + lda v2 + stownbyindex 0x4, v1, 0x1 + ldlexvar 0x0, 0x2 + sta v2 + throw.undefinedifholewithname c + lda v2 + stownbyindex 0x6, v1, 0x2 + ldlexvar 0x0, 0x3 + sta v2 + throw.undefinedifholewithname d + lda v2 + stownbyindex 0x8, v1, 0x3 + ldlexvar 0x0, 0x4 + sta v2 + throw.undefinedifholewithname e + lda v2 + stownbyindex 0xa, v1, 0x4 + ldlexvar 0x0, 0x5 + sta v2 + throw.undefinedifholewithname f + lda v2 + stownbyindex 0xc, v1, 0x5 + ldlexvar 0x0, 0x6 + sta v2 + throw.undefinedifholewithname g + lda v2 + stownbyindex 0xe, v1, 0x6 + ldlexvar 0x0, 0x7 + sta v2 + throw.undefinedifholewithname h + lda v2 + stownbyindex 0x10, v1, 0x7 + ldlexvar 0x0, 0x8 + sta v2 + throw.undefinedifholewithname i + lda v2 + stownbyindex 0x12, v1, 0x8 + ldlexvar 0x0, 0x9 + sta v2 + throw.undefinedifholewithname j + lda v2 + stownbyindex 0x14, v1, 0x9 + lda v0 + callarg1 0x16, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.func_main_0(any a0, any a1, any a2) { + newlexenv 0xa + definefunc 0x0, com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#*#foo, 0x0 + getmodulenamespace 0x0 + stlexvar 0x0, 0x0 + getmodulenamespace 0x1 + stlexvar 0x0, 0x1 + getmodulenamespace 0x2 + stlexvar 0x0, 0x2 + getmodulenamespace 0x3 + stlexvar 0x0, 0x3 + getmodulenamespace 0x4 + stlexvar 0x0, 0x4 + getmodulenamespace 0x5 + stlexvar 0x0, 0x5 + getmodulenamespace 0x6 + stlexvar 0x0, 0x6 + getmodulenamespace 0x7 + stlexvar 0x0, 0x7 + getmodulenamespace 0x8 + stlexvar 0x0, 0x8 + getmodulenamespace 0x9 + stlexvar 0x0, 0x9 + ldhole + sta v0 + defineclasswithbuffer 0x1, com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#~B=#B, com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2702, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2570 +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2574 +{ + index: 0 + tag: 2 + val: 10 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 2 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 3 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 4 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 5 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&lib2/importfile3& +}, +{ + index: 6 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 7 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 8 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 9 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 10 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&@ohos/lib2/importfile4& +}, +{ + index: 11 + tag: 2 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 10 +}, +{ + index: 13 + tag: 5 + val: a +}, +{ + index: 14 + tag: 9 + val: 0 +}, +{ + index: 15 + tag: 5 + val: b +}, +{ + index: 16 + tag: 9 + val: 1 +}, +{ + index: 17 + tag: 5 + val: c +}, +{ + index: 18 + tag: 9 + val: 2 +}, +{ + index: 19 + tag: 5 + val: d +}, +{ + index: 20 + tag: 9 + val: 3 +}, +{ + index: 21 + tag: 5 + val: e +}, +{ + index: 22 + tag: 9 + val: 4 +}, +{ + index: 23 + tag: 5 + val: f +}, +{ + index: 24 + tag: 9 + val: 5 +}, +{ + index: 25 + tag: 5 + val: g +}, +{ + index: 26 + tag: 9 + val: 6 +}, +{ + index: 27 + tag: 5 + val: h +}, +{ + index: 28 + tag: 9 + val: 7 +}, +{ + index: 29 + tag: 5 + val: i +}, +{ + index: 30 + tag: 9 + val: 8 +}, +{ + index: 31 + tag: 5 + val: j +}, +{ + index: 32 + tag: 9 + val: 9 +}, +{ + index: 33 + tag: 2 + val: 0 +}, +{ + index: 34 + tag: 2 + val: 0 +}, +{ + index: 35 + tag: 2 + val: 0 +}, +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2702 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"a"; "b"; "c"; "com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#*#foo"; "com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#~B=#B"; "d"; "e"; "f"; "g"; "h"; "i"; "j"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any bundle&lib/importfile1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot bundle&lib/importfile1&2.0.0_0 +------------------------------------ +slot bundle&lib/importfile1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test1 +}, +{ + index: 5 + tag: 5 + val: test1 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&@ohos/lib/importfile2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&@ohos/lib/importfile2&2.0.0_0 +------------------------------------ +slot com.inter_app.hsp&@ohos/lib/importfile2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test2 +}, +{ + index: 5 + tag: 5 + val: test2 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&lib2/importfile3&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&lib2/importfile3&_0 +------------------------------------ +slot com.inter_app.hsp&lib2/importfile3&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test3 +}, +{ + index: 5 + tag: 5 + val: test3 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&@ohos/lib2/importfile4&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&@ohos/lib2/importfile4&_0 +------------------------------------ +slot com.inter_app.hsp&@ohos/lib2/importfile4&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test4 +}, +{ + index: 5 + tag: 5 + val: test4 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0xd +.language ECMAScript +.function any com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + getmodulenamespace 0x0 + sta v0 + getmodulenamespace 0x1 + sta v1 + tryldglobalbyname 0x0, print + sta v2 + lda v0 + ldobjbyname 0x1, test + sta v0 + lda v2 + callarg1 0x3, v0 + tryldglobalbyname 0x5, print + sta v0 + lda v1 + ldobjbyname 0x6, test + sta v1 + lda v0 + callarg1 0x8, v1 + ldhole + sta v0 + defineclasswithbuffer 0xa, com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.#~A=#A, com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_2, 0x0, v0 + ldobjbyname 0xb, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_0 +------------------------------------ +slot com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_1 +{ + index: 0 + tag: 2 + val: 2 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import& +}, +{ + index: 2 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&bytecodehar/bytecodehar-static-import& +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 2 +}, +{ + index: 5 + tag: 5 + val: bytecodeharDynamicImport +}, +{ + index: 6 + tag: 9 + val: 0 +}, +{ + index: 7 + tag: 5 + val: bytecodeharStaticImport +}, +{ + index: 8 + tag: 9 + val: 1 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +------------------------------------ +slot com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.#~A=#A"; "print"; "prototype"; "test"; +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl(any a0, any a1, any a2) { + lda.str aaa + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt(any a0, any a1, any a2) { + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&lib&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&com.inter_app.hsp&@ohos/lib2/importfile4& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&com.inter_app.hsp&lib2/importfile3& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#~A1=#A1(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst, 0x0 + definefunc 0x1, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl, 0x0 + definefunc 0x2, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt, 0x0 + definefunc 0x3, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt, 0x0 + lda.str test + stmodulevar 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x4, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#~A1=#A1, com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2561, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2521 +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2525 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&_2561 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"@normalized:N&&com.inter_app.hsp&@ohos/lib2/importfile4&"; "@normalized:N&&com.inter_app.hsp&lib2/importfile3&"; "@normalized:N&lib&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&module&bundle&lib/importfile1&2.0.0"; "aaa"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt"; "com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&.#~A1=#A1"; "prototype"; "test"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x18 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#*#foo(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + createemptyarray 0x1 + sta v1 + ldlexvar 0x0, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + stownbyindex 0x2, v1, 0x0 + ldlexvar 0x0, 0x1 + sta v2 + throw.undefinedifholewithname b + lda v2 + stownbyindex 0x4, v1, 0x1 + ldlexvar 0x0, 0x2 + sta v2 + throw.undefinedifholewithname c + lda v2 + stownbyindex 0x6, v1, 0x2 + ldlexvar 0x0, 0x3 + sta v2 + throw.undefinedifholewithname d + lda v2 + stownbyindex 0x8, v1, 0x3 + ldlexvar 0x0, 0x4 + sta v2 + throw.undefinedifholewithname e + lda v2 + stownbyindex 0xa, v1, 0x4 + ldlexvar 0x0, 0x5 + sta v2 + throw.undefinedifholewithname f + lda v2 + stownbyindex 0xc, v1, 0x5 + ldlexvar 0x0, 0x6 + sta v2 + throw.undefinedifholewithname g + lda v2 + stownbyindex 0xe, v1, 0x6 + ldlexvar 0x0, 0x7 + sta v2 + throw.undefinedifholewithname h + lda v2 + stownbyindex 0x10, v1, 0x7 + ldlexvar 0x0, 0x8 + sta v2 + throw.undefinedifholewithname i + lda v2 + stownbyindex 0x12, v1, 0x8 + ldlexvar 0x0, 0x9 + sta v2 + throw.undefinedifholewithname j + lda v2 + stownbyindex 0x14, v1, 0x9 + lda v0 + callarg1 0x16, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.func_main_0(any a0, any a1, any a2) { + newlexenv 0xa + definefunc 0x0, com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#*#foo, 0x0 + getmodulenamespace 0x0 + stlexvar 0x0, 0x0 + getmodulenamespace 0x1 + stlexvar 0x0, 0x1 + getmodulenamespace 0x2 + stlexvar 0x0, 0x2 + getmodulenamespace 0x3 + stlexvar 0x0, 0x3 + getmodulenamespace 0x4 + stlexvar 0x0, 0x4 + getmodulenamespace 0x5 + stlexvar 0x0, 0x5 + getmodulenamespace 0x6 + stlexvar 0x0, 0x6 + getmodulenamespace 0x7 + stlexvar 0x0, 0x7 + getmodulenamespace 0x8 + stlexvar 0x0, 0x8 + getmodulenamespace 0x9 + stlexvar 0x0, 0x9 + ldhole + sta v0 + defineclasswithbuffer 0x1, com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#~B=#B, com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2702, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2570 +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2574 +{ + index: 0 + tag: 2 + val: 10 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 2 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 3 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 4 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 5 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&lib2/importfile3& +}, +{ + index: 6 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 7 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 8 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 9 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 10 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&@ohos/lib2/importfile4& +}, +{ + index: 11 + tag: 2 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 10 +}, +{ + index: 13 + tag: 5 + val: a +}, +{ + index: 14 + tag: 9 + val: 0 +}, +{ + index: 15 + tag: 5 + val: b +}, +{ + index: 16 + tag: 9 + val: 1 +}, +{ + index: 17 + tag: 5 + val: c +}, +{ + index: 18 + tag: 9 + val: 2 +}, +{ + index: 19 + tag: 5 + val: d +}, +{ + index: 20 + tag: 9 + val: 3 +}, +{ + index: 21 + tag: 5 + val: e +}, +{ + index: 22 + tag: 9 + val: 4 +}, +{ + index: 23 + tag: 5 + val: f +}, +{ + index: 24 + tag: 9 + val: 5 +}, +{ + index: 25 + tag: 5 + val: g +}, +{ + index: 26 + tag: 9 + val: 6 +}, +{ + index: 27 + tag: 5 + val: h +}, +{ + index: 28 + tag: 9 + val: 7 +}, +{ + index: 29 + tag: 5 + val: i +}, +{ + index: 30 + tag: 9 + val: 8 +}, +{ + index: 31 + tag: 5 + val: j +}, +{ + index: 32 + tag: 9 + val: 9 +}, +{ + index: 33 + tag: 2 + val: 0 +}, +{ + index: 34 + tag: 2 + val: 0 +}, +{ + index: 35 + tag: 2 + val: 0 +}, +------------------------------------ +slot com.inter_app.hsp&bytecodehar/bytecodehar-static-import&_2702 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"a"; "b"; "c"; "com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#*#foo"; "com.inter_app.hsp&bytecodehar/bytecodehar-static-import&.#~B=#B"; "d"; "e"; "f"; "g"; "h"; "i"; "j"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&lib2/importfile3&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&lib2/importfile3&_0 +------------------------------------ +slot com.inter_app.hsp&lib2/importfile3&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test3 +}, +{ + index: 5 + tag: 5 + val: test3 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&@ohos/lib2/importfile4&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&@ohos/lib2/importfile4&_0 +------------------------------------ +slot com.inter_app.hsp&@ohos/lib2/importfile4&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test4 +}, +{ + index: 5 + tag: 5 + val: test4 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0xd +.language ECMAScript +.function any com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + getmodulenamespace 0x0 + sta v0 + getmodulenamespace 0x1 + sta v1 + tryldglobalbyname 0x0, print + sta v2 + lda v0 + ldobjbyname 0x1, test + sta v0 + lda v2 + callarg1 0x3, v0 + tryldglobalbyname 0x5, print + sta v0 + lda v1 + ldobjbyname 0x6, test + sta v1 + lda v0 + callarg1 0x8, v1 + ldhole + sta v0 + defineclasswithbuffer 0xa, com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.#~A=#A, com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_2, 0x0, v0 + ldobjbyname 0xb, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_0 +------------------------------------ +slot com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_1 +{ + index: 0 + tag: 2 + val: 2 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import& +}, +{ + index: 2 + tag: 5 + val: @normalized:N&&com.inter_app.hsp&bytecodehar/bytecodehar-static-import& +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 2 +}, +{ + index: 5 + tag: 5 + val: bytecodeharDynamicImport +}, +{ + index: 6 + tag: 9 + val: 0 +}, +{ + index: 7 + tag: 5 + val: bytecodeharStaticImport +}, +{ + index: 8 + tag: 9 + val: 1 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +------------------------------------ +slot com.inter_app.hsp&myapp/inter-app-hsp-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"com.inter_app.hsp&myapp/inter-app-hsp-file-exec&.#~A=#A"; "print"; "prototype"; "test"; diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/inter-app-hsp-file-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/inter-app-hsp-file-exec.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a849d9f969707261762ff0c326fa52f179632c5 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/inter-app-hsp-file-exec.ts @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as bytecodeharDynamicImport from "@normalized:N&&com.inter_app.hsp&bytecodehar/bytecodehar-dynamic-import&"; +import * as bytecodeharStaticImport from "@normalized:N&&com.inter_app.hsp&bytecodehar/bytecodehar-static-import&"; + +print(bytecodeharDynamicImport.test) +print(bytecodeharStaticImport.test) + +@bytecodeharDynamicImport.__$$ETS_ANNOTATION$$__Anno1() +@bytecodeharStaticImport.__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..7fff897e3c90a12ec32d3925d2a09d3e1ae7b9b1 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-inter-app-hsp/recordnames.txt @@ -0,0 +1,7 @@ +bytecodehar-dynamic-import:&bytecodehar/bytecodehar-dynamic-import& +bytecodehar-static-import:&bytecodehar/bytecodehar-static-import& +importfile1:bundle&lib/importfile1&2.0.0 +importfile2:com.inter_app.hsp&@ohos/lib/importfile2&2.0.0 +importfile3:com.inter_app.hsp&lib2/importfile3& +importfile4:com.inter_app.hsp&@ohos/lib2/importfile4& +inter-app-hsp-file-exec:com.inter_app.hsp&myapp/inter-app-hsp-file-exec& diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/abcinputs/bytecodehar1.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/abcinputs/bytecodehar1.txt new file mode 100644 index 0000000000000000000000000000000000000000..44fef6254c424437d17bdd628f89ec1827c753d0 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/abcinputs/bytecodehar1.txt @@ -0,0 +1,2 @@ +bytecodehar1-file1.ts +bytecodehar1-file2.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/abcinputs/bytecodehar2.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/abcinputs/bytecodehar2.txt new file mode 100644 index 0000000000000000000000000000000000000000..01249cd0afb7ae24d54f9a1b926115fc33893104 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/abcinputs/bytecodehar2.txt @@ -0,0 +1,2 @@ +bytecodehar2-file1.ts +bytecodehar2-file2.ts diff --git a/ets2panda/test/isolated_declgen/infer_function_return_type_with_import_symbol-expected.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar1-file1.ts similarity index 60% rename from ets2panda/test/isolated_declgen/infer_function_return_type_with_import_symbol-expected.txt rename to es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar1-file1.ts index 1804ab1e7b0d015bede8f8e8a61ec68c5830e100..a057a3927b5fe78c9e4448ead9970b7319988517 100644 --- a/ets2panda/test/isolated_declgen/infer_function_return_type_with_import_symbol-expected.txt +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar1-file1.ts @@ -13,14 +13,22 @@ * limitations under the License. */ -import A from "./infer_function_return_type_with_literal.ets"; +import {test as test1} from '@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0' -import B from "./infer_function_return_type_with_literal.ets"; +export function test() { + print('bytecodehar1.file1.test'); + import('@normalized:N&&&sourcehar/sourcehar-file1&2.0.0') +} -import C from "./infer_function_return_type_with_literal.ets"; +function A(a) { + this.a = a + this.b = 1 + this.c = 2 +} -export declare let b: A; +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} -export default declare let d: int; - -export declare function foo(a: int, c: C): A | Array | Array | Array | B | Number | String; \ No newline at end of file +@__$$ETS_ANNOTATION$$__Anno1() +class B { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar1-file2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar1-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..3946722605096fbc5999375259e24199cef3fe32 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar1-file2.ts @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {test as test1} from "@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&1.0.0" + +export function test() { + print('bytecodehar1.file2.test'); + import("@normalized:N&&&sourcehar/sourcehar-file2&2.0.0") +} + +class Example { + a: number; + + constructor() { + this.a = 0; + } + + setValue(value: number) { + this.a = value; + } +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar2-file1.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar2-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..c040f93e6cb741f937769bb2c89c3458fbad1481 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar2-file1.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function test() { + print('bytecodehar2.file1.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar2-file2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar2-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..a2da8dcd93249f8f559d3d0a0f70346f048d9035 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/bytecodehar2-file2.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function test() { + print('bytecodehar2.file2.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class B { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/compileContextInfo.json b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/compileContextInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..a8744ff6d302a7650651886c9655de5ad7c3e609 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/compileContextInfo.json @@ -0,0 +1,44 @@ +{ + "compileEntries": [ + "&myapp/hap-file-exec&" + ], + "hspPkgNames": [], + "pkgContextInfo": { + "myapp": { + "packageName": "myapp", + "bundleName": "", + "moduleName": "", + "version": "", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "bytecodehar1": { + "packageName": "bytecodehar1", + "bundleName": "", + "moduleName": "", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "@ohos/bytecodehar2": { + "packageName": "@ohos/bytecodehar2", + "bundleName": "", + "moduleName": "", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "sourcehar": { + "packageName": "sourcehar", + "bundleName": "", + "moduleName": "", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + } + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/hap-file-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/hap-file-exec-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..d6cd6d3e45ecf6f3b46b4267640feae85631a671 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/hap-file-exec-expected.pa.txt @@ -0,0 +1,1340 @@ +All Dependency Files: +program_file: bytecodehar1-abcinput.abc +record_name: &bytecodehar1/bytecodehar1-file1&2.0.0 +program_file: bytecodehar2-abcinput.abc +record_name: &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +program_file: hap-file-exec.ts +record_name: &myapp/hap-file-exec& +program_file: sourcehar-file1.ts +record_name: &sourcehar/sourcehar-file1&2.0.0 + +slotNum = 0x6 +expectedProperty = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#A(any a0, any a1, any a2, any a3) { + lda a3 + stobjbyname 0x0, a, a2 + ldai 0x1 + stobjbyname 0x2, b, a2 + ldai 0x2 + stobjbyname 0x4, c, a2 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x5 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#A, 0x1 + definefunc 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x2, &bytecodehar1/bytecodehar1-file1&2.0.0.#~B=#B, &bytecodehar1/bytecodehar1-file1&2.0.0_2142, 0x0, v0 + ldobjbyname 0x3, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_2080 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_2084 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_2142 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#A"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~B=#B"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "a"; "b"; "bytecodehar1.file1.test"; "c"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#~@0=#Example(any a0, any a1, any a2) { + ldai 0x0 + stobjbyname 0x0, a, a2 + lda a2 + return +} + +slotNum = 0x2 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#~@0>#setValue(any a0, any a1, any a2, any a3) { + lda a3 + stobjbyname 0x0, a, a2 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file2&2.0.0.#~@0=#Example, &bytecodehar1/bytecodehar1-file2&2.0.0_2218, 0x0, v0 + ldobjbyname 0x2, prototype + ldhole + sta v0 + defineclasswithbuffer 0x4, &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file2&2.0.0_2240, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_2151 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: Example +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_2160 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno2 +}, +{ + index: 9 + tag: 5 + val: Anno2 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_2218 +{ + index: 0 + tag: 0 + val: 5 +}, +{ + index: 1 + tag: 5 + val: setValue +}, +{ + index: 2 + tag: 0 + val: 6 +}, +{ + index: 3 + tag: 6 + val: &bytecodehar1/bytecodehar1-file2&2.0.0.#~@0>#setValue +}, +{ + index: 4 + tag: 0 + val: 9 +}, +{ + index: 5 + tag: 9 + val: 1 +}, +{ + index: 6 + tag: 0 + val: 2 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_2240 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file2&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file2&2.0.0.#~@0=#Example"; "&bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file2&2.0.0"; "a"; "bytecodehar1.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1649, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1601 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1605 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1649 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~B=#B, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1706, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1658 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1662 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno2 +}, +{ + index: 5 + tag: 5 + val: Anno2 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1706 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~B=#B"; "bytecodehar2.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x1 + sta v0 + throw.undefinedifholewithname B + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~C=#C(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~C=#C, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: Anno1 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: B +}, +{ + index: 7 + tag: 5 + val: B +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~C=#C"; "B"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file2&2.0.0.#*#test"; "print"; "sourcehar.file2.test"; +slotNum = 0x6 +expectedProperty = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#A(any a0, any a1, any a2, any a3) { + lda a3 + stobjbyname 0x0, a, a2 + ldai 0x1 + stobjbyname 0x2, b, a2 + ldai 0x2 + stobjbyname 0x4, c, a2 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~B=#B(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x5 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#A, 0x1 + definefunc 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x2, &bytecodehar1/bytecodehar1-file1&2.0.0.#~B=#B, &bytecodehar1/bytecodehar1-file1&2.0.0_2142, 0x0, v0 + ldobjbyname 0x3, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_2080 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_2084 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_2142 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#A"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~B=#B"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "a"; "b"; "bytecodehar1.file1.test"; "c"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1649, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1601 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1605 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1649 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x1 + sta v0 + throw.undefinedifholewithname B + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~C=#C(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~C=#C, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: Anno1 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: B +}, +{ + index: 7 + tag: 5 + val: B +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~C=#C"; "B"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/hap-file-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/hap-file-exec.ts new file mode 100644 index 0000000000000000000000000000000000000000..dfb9dcabd30e577833eb1baf7e2f82ada2a1881c --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/hap-file-exec.ts @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { test, __$$ETS_ANNOTATION$$__Anno1, B } from "@normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0" + +function main() { + test(); + let a = new B(); +} + +@__$$ETS_ANNOTATION$$__Anno1({ b: true }) +class C { } diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..70074eddf79afcc444b4ccee16630de0b4fa6d9d --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/recordnames.txt @@ -0,0 +1,7 @@ +bytecodehar1-file1:&bytecodehar1/bytecodehar1-file1&2.0.0 +bytecodehar1-file2:&bytecodehar1/bytecodehar1-file2&2.0.0 +bytecodehar2-file1:&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +bytecodehar2-file2:&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +sourcehar-file1:&sourcehar/sourcehar-file1&2.0.0 +sourcehar-file2:&sourcehar/sourcehar-file2&2.0.0 +hap-file-exec:&myapp/hap-file-exec& diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/sourcehar-file1.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/sourcehar-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9215bd1f398efaf7980d8451eb64fbea1bc10dc --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/sourcehar-file1.ts @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function test() { + print('sourcehar.file1.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/sourcehar-file2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/sourcehar-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..7702af07787a7190c88033b40fe1024e0f5e8e24 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-test-project/sourcehar-file2.ts @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function test() { + print('sourcehar.file2.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/abcinputs/bytecodehar.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/abcinputs/bytecodehar.txt new file mode 100644 index 0000000000000000000000000000000000000000..2bed2a047fa2004fcca50e9d9c5051a4027a913f --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/abcinputs/bytecodehar.txt @@ -0,0 +1,2 @@ +bytecodehar-dynamic-import.ts +bytecodehar-static-import.ts diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/bytecodehar-dynamic-import.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/bytecodehar-dynamic-import.ts new file mode 100644 index 0000000000000000000000000000000000000000..773f5fa662c2cd98b0b6e9da42f43ec157d05c10 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/bytecodehar-dynamic-import.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export let test: string = "test"; + +function testReplacementWoAt() { + import("@normalized:N&module&bundle&lib/importfile1&1.0.0"); + import("@normalized:N&module&bundle&lib/importfile1&"); + import("@normalized:N&&bundle&lib/importfile1&1.0.0"); + import("@normalized:N&&bundle&lib/importfile1&"); + + // No-effect since no version info in compileContextInfo.json + import("@normalized:N&&&lib2/importfile3&"); +} + +function testReplacementWithAt() { + import("@normalized:N&module&&@ohos/lib/importfile2&1.0.0"); + import("@normalized:N&module&&@ohos/lib/importfile2&"); + import("@normalized:N&&&@ohos/lib/importfile2&1.0.0"); + import("@normalized:N&&&@ohos/lib/importfile2&"); + + // No-effect since no version info in compileContextInfo.json + import("@normalized:N&&&@ohos/lib2/importfile4&"); +} + +function testNonOhmurl() { + import("aaa"); +} + +function testNonConst() { + // Take effect only under release due to bcopt + let a = "@normalized:N&&bundle&lib/importfile1&" + import(a); + + a = "@normalized:N&&bundle&lib/importfile1&"; + let b = "@normalized:N&&bundle&lib/importfile1&"; + import(a); + + a = "@normalized:N&&bundle&lib/importfile1&"; + "@normalized:N&&bundle&lib/importfile1&"; + import(a); +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/bytecodehar-static-import.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/bytecodehar-static-import.ts new file mode 100644 index 0000000000000000000000000000000000000000..730ef9995187872998242685c0c477f23116e62d --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/bytecodehar-static-import.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// testReplacementWoAt +import * as a from "@normalized:N&module&bundle&lib/importfile1&1.0.0"; +import * as b from "@normalized:N&module&bundle&lib/importfile1&"; +import * as c from "@normalized:N&&bundle&lib/importfile1&1.0.0"; +import * as d from "@normalized:N&&bundle&lib/importfile1&"; + +// No-effect since no version info in compileContextInfo.json +import * as e from "@normalized:N&&&lib2/importfile3&"; + +//testReplacementWithAt +import * as f from "@normalized:N&module&&@ohos/lib/importfile2&1.0.0"; +import * as g from "@normalized:N&module&&@ohos/lib/importfile2&"; +import * as h from "@normalized:N&&&@ohos/lib/importfile2&1.0.0"; +import * as i from "@normalized:N&&&@ohos/lib/importfile2&"; + +// No-effect since no version info in compileContextInfo.json +import * as j from "@normalized:N&&&@ohos/lib2/importfile4&"; + +function foo() { + print([a, b, c, d, e, f, g, h, i, j]); +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/compileContextInfo.json b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/compileContextInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..be6b280850e709ed18b7d46fd80490ebbf1e9376 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/compileContextInfo.json @@ -0,0 +1,53 @@ +{ + "compileEntries": [ + "&myapp/hap-file-exec&" + ], + "hspPkgNames": [], + "pkgContextInfo": { + "myapp": { + "packageName": "myapp", + "bundleName": "", + "moduleName": "", + "version": "", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "lib": { + "packageName": "lib", + "bundleName": "bundle", + "moduleName": "module", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "@ohos/lib": { + "packageName": "@ohos/lib", + "bundleName": "", + "moduleName": "module", + "version": "2.0.0", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "lib2": { + "packageName": "lib2", + "bundleName": "", + "moduleName": "", + "version": "", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + }, + "@ohos/lib2": { + "packageName": "@ohos/lib2", + "bundleName": "", + "moduleName": "", + "version": "", + "entryPath": "", + "isSo": false, + "dependencyAlias": "" + } + } +} diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/hap-file-exec-expected.pa.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/hap-file-exec-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..951b2a1d14353002088d287324d24d43ac3593b7 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/hap-file-exec-expected.pa.txt @@ -0,0 +1,1670 @@ +All Dependency Files: +program_file: bytecodehar-abcinput.abc +record_name: &bytecodehar/bytecodehar-dynamic-import& +program_file: bytecodehar-abcinput.abc +record_name: &bytecodehar/bytecodehar-static-import& +program_file: hap-file-exec.ts +record_name: &myapp/hap-file-exec& +program_file: importfile1.ts +record_name: bundle&lib/importfile1&2.0.0 +program_file: importfile2.ts +record_name: &@ohos/lib/importfile2&2.0.0 +program_file: importfile3.ts +record_name: &lib2/importfile3& +program_file: importfile4.ts +record_name: &@ohos/lib2/importfile4& + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst(any a0, any a1, any a2) { + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl(any a0, any a1, any a2) { + lda.str aaa + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib2/importfile4& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&&lib2/importfile3& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst, 0x0 + definefunc 0x1, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl, 0x0 + definefunc 0x2, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt, 0x0 + definefunc 0x3, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt, 0x0 + lda.str test + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x4, &bytecodehar/bytecodehar-dynamic-import&.#~A=#A, &bytecodehar/bytecodehar-dynamic-import&_2498, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2450 +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2454 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2498 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt"; "&bytecodehar/bytecodehar-dynamic-import&.#~A=#A"; "@normalized:N&&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&&&@ohos/lib2/importfile4&"; "@normalized:N&&&lib2/importfile3&"; "@normalized:N&&bundle&lib/importfile1&2.0.0"; "@normalized:N&module&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&module&bundle&lib/importfile1&2.0.0"; "aaa"; "prototype"; "test"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x18 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#*#foo(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + createemptyarray 0x1 + sta v1 + ldlexvar 0x0, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + stownbyindex 0x2, v1, 0x0 + ldlexvar 0x0, 0x1 + sta v2 + throw.undefinedifholewithname b + lda v2 + stownbyindex 0x4, v1, 0x1 + ldlexvar 0x0, 0x2 + sta v2 + throw.undefinedifholewithname c + lda v2 + stownbyindex 0x6, v1, 0x2 + ldlexvar 0x0, 0x3 + sta v2 + throw.undefinedifholewithname d + lda v2 + stownbyindex 0x8, v1, 0x3 + ldlexvar 0x0, 0x4 + sta v2 + throw.undefinedifholewithname e + lda v2 + stownbyindex 0xa, v1, 0x4 + ldlexvar 0x0, 0x5 + sta v2 + throw.undefinedifholewithname f + lda v2 + stownbyindex 0xc, v1, 0x5 + ldlexvar 0x0, 0x6 + sta v2 + throw.undefinedifholewithname g + lda v2 + stownbyindex 0xe, v1, 0x6 + ldlexvar 0x0, 0x7 + sta v2 + throw.undefinedifholewithname h + lda v2 + stownbyindex 0x10, v1, 0x7 + ldlexvar 0x0, 0x8 + sta v2 + throw.undefinedifholewithname i + lda v2 + stownbyindex 0x12, v1, 0x8 + ldlexvar 0x0, 0x9 + sta v2 + throw.undefinedifholewithname j + lda v2 + stownbyindex 0x14, v1, 0x9 + lda v0 + callarg1 0x16, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.func_main_0(any a0, any a1, any a2) { + newlexenv 0xa + definefunc 0x0, &bytecodehar/bytecodehar-static-import&.#*#foo, 0x0 + getmodulenamespace 0x0 + stlexvar 0x0, 0x0 + getmodulenamespace 0x1 + stlexvar 0x0, 0x1 + getmodulenamespace 0x2 + stlexvar 0x0, 0x2 + getmodulenamespace 0x3 + stlexvar 0x0, 0x3 + getmodulenamespace 0x4 + stlexvar 0x0, 0x4 + getmodulenamespace 0x5 + stlexvar 0x0, 0x5 + getmodulenamespace 0x6 + stlexvar 0x0, 0x6 + getmodulenamespace 0x7 + stlexvar 0x0, 0x7 + getmodulenamespace 0x8 + stlexvar 0x0, 0x8 + getmodulenamespace 0x9 + stlexvar 0x0, 0x9 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar/bytecodehar-static-import&.#~A=#A, &bytecodehar/bytecodehar-static-import&_2647, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2507 +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2511 +{ + index: 0 + tag: 2 + val: 10 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 2 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 3 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 4 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 5 + tag: 5 + val: @normalized:N&&&lib2/importfile3& +}, +{ + index: 6 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 7 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 8 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 9 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 10 + tag: 5 + val: @normalized:N&&&@ohos/lib2/importfile4& +}, +{ + index: 11 + tag: 2 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 10 +}, +{ + index: 13 + tag: 5 + val: a +}, +{ + index: 14 + tag: 9 + val: 0 +}, +{ + index: 15 + tag: 5 + val: b +}, +{ + index: 16 + tag: 9 + val: 1 +}, +{ + index: 17 + tag: 5 + val: c +}, +{ + index: 18 + tag: 9 + val: 2 +}, +{ + index: 19 + tag: 5 + val: d +}, +{ + index: 20 + tag: 9 + val: 3 +}, +{ + index: 21 + tag: 5 + val: e +}, +{ + index: 22 + tag: 9 + val: 4 +}, +{ + index: 23 + tag: 5 + val: f +}, +{ + index: 24 + tag: 9 + val: 5 +}, +{ + index: 25 + tag: 5 + val: g +}, +{ + index: 26 + tag: 9 + val: 6 +}, +{ + index: 27 + tag: 5 + val: h +}, +{ + index: 28 + tag: 9 + val: 7 +}, +{ + index: 29 + tag: 5 + val: i +}, +{ + index: 30 + tag: 9 + val: 8 +}, +{ + index: 31 + tag: 5 + val: j +}, +{ + index: 32 + tag: 9 + val: 9 +}, +{ + index: 33 + tag: 2 + val: 1 +}, +{ + index: 34 + tag: 5 + val: Anno2 +}, +{ + index: 35 + tag: 5 + val: Anno2 +}, +{ + index: 36 + tag: 2 + val: 0 +}, +{ + index: 37 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2647 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-static-import&.#*#foo"; "&bytecodehar/bytecodehar-static-import&.#~A=#A"; "a"; "b"; "c"; "d"; "e"; "f"; "g"; "h"; "i"; "j"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0xd +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + getmodulenamespace 0x0 + sta v0 + getmodulenamespace 0x1 + sta v1 + tryldglobalbyname 0x0, print + sta v2 + lda v0 + ldobjbyname 0x1, test + sta v0 + lda v2 + callarg1 0x3, v0 + tryldglobalbyname 0x5, print + sta v0 + lda v1 + ldobjbyname 0x6, test + sta v1 + lda v0 + callarg1 0x8, v1 + ldhole + sta v0 + defineclasswithbuffer 0xa, &myapp/hap-file-exec&.#~A=#A, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0xb, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 2 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-dynamic-import& +}, +{ + index: 2 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-static-import& +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 2 +}, +{ + index: 5 + tag: 5 + val: bytecodeharDynamicImport +}, +{ + index: 6 + tag: 9 + val: 0 +}, +{ + index: 7 + tag: 5 + val: bytecodeharStaticImport +}, +{ + index: 8 + tag: 9 + val: 1 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#~A=#A"; "print"; "prototype"; "test"; +slotNum = 0x0 +.language ECMAScript +.function any bundle&lib/importfile1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot bundle&lib/importfile1&2.0.0_0 +------------------------------------ +slot bundle&lib/importfile1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test1 +}, +{ + index: 5 + tag: 5 + val: test1 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib/importfile2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_0 +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test2 +}, +{ + index: 5 + tag: 5 + val: test2 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &lib2/importfile3&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &lib2/importfile3&_0 +------------------------------------ +slot &lib2/importfile3&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test3 +}, +{ + index: 5 + tag: 5 + val: test3 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib2/importfile4&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib2/importfile4&_0 +------------------------------------ +slot &@ohos/lib2/importfile4&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test4 +}, +{ + index: 5 + tag: 5 + val: test4 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst(any a0, any a1, any a2) { + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl(any a0, any a1, any a2) { + lda.str aaa + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&module&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib/importfile2&2.0.0 + dynamicimport + lda.str @normalized:N&&&@ohos/lib2/importfile4& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt(any a0, any a1, any a2) { + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&module&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&bundle&lib/importfile1&2.0.0 + dynamicimport + lda.str @normalized:N&&&lib2/importfile3& + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x7 +.language ECMAScript +.function any &bytecodehar/bytecodehar-dynamic-import&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst, 0x0 + definefunc 0x1, &bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl, 0x0 + definefunc 0x2, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt, 0x0 + definefunc 0x3, &bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt, 0x0 + lda.str test + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x4, &bytecodehar/bytecodehar-dynamic-import&.#~A=#A, &bytecodehar/bytecodehar-dynamic-import&_2498, 0x0, v0 + ldobjbyname 0x5, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2450 +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2454 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-dynamic-import&_2498 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-dynamic-import&.#*#testNonConst"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testNonOhmurl"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWithAt"; "&bytecodehar/bytecodehar-dynamic-import&.#*#testReplacementWoAt"; "&bytecodehar/bytecodehar-dynamic-import&.#~A=#A"; "@normalized:N&&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&&&@ohos/lib2/importfile4&"; "@normalized:N&&&lib2/importfile3&"; "@normalized:N&&bundle&lib/importfile1&2.0.0"; "@normalized:N&module&&@ohos/lib/importfile2&2.0.0"; "@normalized:N&module&bundle&lib/importfile1&2.0.0"; "aaa"; "prototype"; "test"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x18 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#*#foo(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + createemptyarray 0x1 + sta v1 + ldlexvar 0x0, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + stownbyindex 0x2, v1, 0x0 + ldlexvar 0x0, 0x1 + sta v2 + throw.undefinedifholewithname b + lda v2 + stownbyindex 0x4, v1, 0x1 + ldlexvar 0x0, 0x2 + sta v2 + throw.undefinedifholewithname c + lda v2 + stownbyindex 0x6, v1, 0x2 + ldlexvar 0x0, 0x3 + sta v2 + throw.undefinedifholewithname d + lda v2 + stownbyindex 0x8, v1, 0x3 + ldlexvar 0x0, 0x4 + sta v2 + throw.undefinedifholewithname e + lda v2 + stownbyindex 0xa, v1, 0x4 + ldlexvar 0x0, 0x5 + sta v2 + throw.undefinedifholewithname f + lda v2 + stownbyindex 0xc, v1, 0x5 + ldlexvar 0x0, 0x6 + sta v2 + throw.undefinedifholewithname g + lda v2 + stownbyindex 0xe, v1, 0x6 + ldlexvar 0x0, 0x7 + sta v2 + throw.undefinedifholewithname h + lda v2 + stownbyindex 0x10, v1, 0x7 + ldlexvar 0x0, 0x8 + sta v2 + throw.undefinedifholewithname i + lda v2 + stownbyindex 0x12, v1, 0x8 + ldlexvar 0x0, 0x9 + sta v2 + throw.undefinedifholewithname j + lda v2 + stownbyindex 0x14, v1, 0x9 + lda v0 + callarg1 0x16, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar/bytecodehar-static-import&.func_main_0(any a0, any a1, any a2) { + newlexenv 0xa + definefunc 0x0, &bytecodehar/bytecodehar-static-import&.#*#foo, 0x0 + getmodulenamespace 0x0 + stlexvar 0x0, 0x0 + getmodulenamespace 0x1 + stlexvar 0x0, 0x1 + getmodulenamespace 0x2 + stlexvar 0x0, 0x2 + getmodulenamespace 0x3 + stlexvar 0x0, 0x3 + getmodulenamespace 0x4 + stlexvar 0x0, 0x4 + getmodulenamespace 0x5 + stlexvar 0x0, 0x5 + getmodulenamespace 0x6 + stlexvar 0x0, 0x6 + getmodulenamespace 0x7 + stlexvar 0x0, 0x7 + getmodulenamespace 0x8 + stlexvar 0x0, 0x8 + getmodulenamespace 0x9 + stlexvar 0x0, 0x9 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar/bytecodehar-static-import&.#~A=#A, &bytecodehar/bytecodehar-static-import&_2647, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2507 +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2511 +{ + index: 0 + tag: 2 + val: 10 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 2 + tag: 5 + val: @normalized:N&module&bundle&lib/importfile1&2.0.0 +}, +{ + index: 3 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 4 + tag: 5 + val: @normalized:N&&bundle&lib/importfile1&2.0.0 +}, +{ + index: 5 + tag: 5 + val: @normalized:N&&&lib2/importfile3& +}, +{ + index: 6 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 7 + tag: 5 + val: @normalized:N&module&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 8 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 9 + tag: 5 + val: @normalized:N&&&@ohos/lib/importfile2&2.0.0 +}, +{ + index: 10 + tag: 5 + val: @normalized:N&&&@ohos/lib2/importfile4& +}, +{ + index: 11 + tag: 2 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 10 +}, +{ + index: 13 + tag: 5 + val: a +}, +{ + index: 14 + tag: 9 + val: 0 +}, +{ + index: 15 + tag: 5 + val: b +}, +{ + index: 16 + tag: 9 + val: 1 +}, +{ + index: 17 + tag: 5 + val: c +}, +{ + index: 18 + tag: 9 + val: 2 +}, +{ + index: 19 + tag: 5 + val: d +}, +{ + index: 20 + tag: 9 + val: 3 +}, +{ + index: 21 + tag: 5 + val: e +}, +{ + index: 22 + tag: 9 + val: 4 +}, +{ + index: 23 + tag: 5 + val: f +}, +{ + index: 24 + tag: 9 + val: 5 +}, +{ + index: 25 + tag: 5 + val: g +}, +{ + index: 26 + tag: 9 + val: 6 +}, +{ + index: 27 + tag: 5 + val: h +}, +{ + index: 28 + tag: 9 + val: 7 +}, +{ + index: 29 + tag: 5 + val: i +}, +{ + index: 30 + tag: 9 + val: 8 +}, +{ + index: 31 + tag: 5 + val: j +}, +{ + index: 32 + tag: 9 + val: 9 +}, +{ + index: 33 + tag: 2 + val: 1 +}, +{ + index: 34 + tag: 5 + val: Anno2 +}, +{ + index: 35 + tag: 5 + val: Anno2 +}, +{ + index: 36 + tag: 2 + val: 0 +}, +{ + index: 37 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar/bytecodehar-static-import&_2647 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar/bytecodehar-static-import&.#*#foo"; "&bytecodehar/bytecodehar-static-import&.#~A=#A"; "a"; "b"; "c"; "d"; "e"; "f"; "g"; "h"; "i"; "j"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0xd +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + getmodulenamespace 0x0 + sta v0 + getmodulenamespace 0x1 + sta v1 + tryldglobalbyname 0x0, print + sta v2 + lda v0 + ldobjbyname 0x1, test + sta v0 + lda v2 + callarg1 0x3, v0 + tryldglobalbyname 0x5, print + sta v0 + lda v1 + ldobjbyname 0x6, test + sta v1 + lda v0 + callarg1 0x8, v1 + ldhole + sta v0 + defineclasswithbuffer 0xa, &myapp/hap-file-exec&.#~A=#A, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0xb, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 2 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-dynamic-import& +}, +{ + index: 2 + tag: 5 + val: @normalized:N&&&bytecodehar/bytecodehar-static-import& +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 2 +}, +{ + index: 5 + tag: 5 + val: bytecodeharDynamicImport +}, +{ + index: 6 + tag: 9 + val: 0 +}, +{ + index: 7 + tag: 5 + val: bytecodeharStaticImport +}, +{ + index: 8 + tag: 9 + val: 1 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#~A=#A"; "print"; "prototype"; "test"; +slotNum = 0x0 +.language ECMAScript +.function any bundle&lib/importfile1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot bundle&lib/importfile1&2.0.0_0 +------------------------------------ +slot bundle&lib/importfile1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test1 +}, +{ + index: 5 + tag: 5 + val: test1 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib/importfile2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_0 +------------------------------------ +slot &@ohos/lib/importfile2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test2 +}, +{ + index: 5 + tag: 5 + val: test2 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &lib2/importfile3&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &lib2/importfile3&_0 +------------------------------------ +slot &lib2/importfile3&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test3 +}, +{ + index: 5 + tag: 5 + val: test3 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/lib2/importfile4&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldtrue + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/lib2/importfile4&_0 +------------------------------------ +slot &@ohos/lib2/importfile4&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test4 +}, +{ + index: 5 + tag: 5 + val: test4 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== + diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/hap-file-exec.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/hap-file-exec.ts new file mode 100644 index 0000000000000000000000000000000000000000..572bc4616e688a06c0e967006701f1326f1d8d60 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/hap-file-exec.ts @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as bytecodeharDynamicImport from "@normalized:N&&&bytecodehar/bytecodehar-dynamic-import&"; +import * as bytecodeharStaticImport from "@normalized:N&&&bytecodehar/bytecodehar-static-import&"; + +print(bytecodeharDynamicImport.test) +print(bytecodeharStaticImport.test) + +@bytecodeharDynamicImport.__$$ETS_ANNOTATION$$__Anno1() +@bytecodeharStaticImport.__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile1.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile1.ts new file mode 100644 index 0000000000000000000000000000000000000000..afc68146cdbba67e99626c8d8e621fce279997f7 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile1.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const test1: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile2.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile2.ts new file mode 100644 index 0000000000000000000000000000000000000000..f31867bafae7f57cced3748a8aac231abda27d72 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile2.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const test2: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile3.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile3.ts new file mode 100644 index 0000000000000000000000000000000000000000..314b5403fc82ee28d43ea37dc891ad31ee5efc7c --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile3.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const test3: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile4.ts b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile4.ts new file mode 100644 index 0000000000000000000000000000000000000000..fad2380a354687a68f814a2f402d0fffe7936c6d --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/importfile4.ts @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const test4: boolean = true; \ No newline at end of file diff --git a/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/recordnames.txt b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..185dca611160d3ada3534a652765594eb6ec9472 --- /dev/null +++ b/es2panda/test/compiler/bytecodehar/projects/bytecodehar-annotations-version-update/recordnames.txt @@ -0,0 +1,7 @@ +bytecodehar-dynamic-import:&bytecodehar/bytecodehar-dynamic-import& +bytecodehar-static-import:&bytecodehar/bytecodehar-static-import& +importfile1:bundle&lib/importfile1&2.0.0 +importfile2:&@ohos/lib/importfile2&2.0.0 +importfile3:&lib2/importfile3& +importfile4:&@ohos/lib2/importfile4& +hap-file-exec:&myapp/hap-file-exec& diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/abcinputs/bytecodehar1.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/abcinputs/bytecodehar1.txt new file mode 100644 index 0000000000000000000000000000000000000000..44fef6254c424437d17bdd628f89ec1827c753d0 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/abcinputs/bytecodehar1.txt @@ -0,0 +1,2 @@ +bytecodehar1-file1.ts +bytecodehar1-file2.ts diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/abcinputs/bytecodehar2.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/abcinputs/bytecodehar2.txt new file mode 100644 index 0000000000000000000000000000000000000000..01249cd0afb7ae24d54f9a1b926115fc33893104 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/abcinputs/bytecodehar2.txt @@ -0,0 +1,2 @@ +bytecodehar2-file1.ts +bytecodehar2-file2.ts diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar1-file1.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar1-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..7478e0048213402e23cc0b7943b4732b63481299 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar1-file1.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {test as test1} from '@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0' + +export function test() { + print('bytecodehar1.file1.test'); + import('@normalized:N&&&sourcehar/sourcehar-file1&2.0.0') +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar1-file2.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar1-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..5962b22672130d07d4de572d0a55364e61b84dec --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar1-file2.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {test as test1} from "@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&1.0.0" + +export function test() { + print('bytecodehar1.file2.test'); + import("@normalized:N&&&sourcehar/sourcehar-file2&2.0.0") +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar2-file1.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar2-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc82d9af7342aa36651045fde1b22f60a5147c20 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar2-file1.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function test() { + print('bytecodehar2.file1.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar2-file2.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar2-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..3716361621e705ebf971362f3a919d49d9c63bd1 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/bytecodehar2-file2.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function test() { + print('bytecodehar2.file2.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/compileContextInfo.json b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/compileContextInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..43eafd903dcdabf37bff8b31ae5b227be5be0bb2 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/compileContextInfo.json @@ -0,0 +1,13 @@ +{ + "compileEntries": [ + "&myapp/hap-file-exec&" + ], + "hspPkgNames": [], + "updateVersionInfo": { + "bytecodehar1": { + "@ohos/bytecodehar2": "2.0.0" + }, + "@ohos/bytecodehar2": { + } + } +} diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/hap-file-exec-expected.pa.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/hap-file-exec-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..819272cd4acd1c633cef7a3df0de506fd9e7cbfa --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/hap-file-exec-expected.pa.txt @@ -0,0 +1,1354 @@ +All Dependency Files: +program_file: bytecodehar1-abcinput.abc +record_name: &bytecodehar1/bytecodehar1-file1&2.0.0 +program_file: bytecodehar2-abcinput.abc +record_name: &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +program_file: hap-file-exec.ts +record_name: &myapp/hap-file-exec& +program_file: sourcehar-file1.ts +record_name: &sourcehar/sourcehar-file1&2.0.0 +program_file: sourcehar-file2.ts +record_name: &sourcehar/sourcehar-file2&2.0.0 + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file1&2.0.0_1826, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1764 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1768 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1826 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "bytecodehar1.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file2&2.0.0_1897, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1835 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1839 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno2 +}, +{ + index: 9 + tag: 5 + val: Anno2 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1897 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file2&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file2&2.0.0"; "bytecodehar1.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1637, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1589 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1593 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1637 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1694, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1646 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1650 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno2 +}, +{ + index: 5 + tag: 5 + val: Anno2 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1694 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A"; "bytecodehar2.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname A + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~B=#B(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~B=#B, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: A +}, +{ + index: 4 + tag: 5 + val: A +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: Anno1 +}, +{ + index: 7 + tag: 5 + val: Anno1 +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "A"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +{ + index: 8 + tag: 5 + val: test +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file2&2.0.0.#*#test"; "print"; "sourcehar.file2.test"; +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file1&2.0.0_1826, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1764 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1768 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1826 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "bytecodehar1.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1637, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1589 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1593 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1637 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname A + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~B=#B(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~B=#B, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: A +}, +{ + index: 4 + tag: 5 + val: A +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: Anno1 +}, +{ + index: 7 + tag: 5 + val: Anno1 +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "A"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +{ + index: 8 + tag: 5 + val: test +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file2&2.0.0.#*#test"; "print"; "sourcehar.file2.test"; diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/hap-file-exec.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/hap-file-exec.ts new file mode 100644 index 0000000000000000000000000000000000000000..8fe9e1625e9e5f9626041a272bd5853e1937ba51 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/hap-file-exec.ts @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { test, __$$ETS_ANNOTATION$$__Anno1, A } from "@normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0" + +function main() { + test(); + let a = new A(); +} + +@__$$ETS_ANNOTATION$$__Anno1({ b: true }) +class B { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/recordnames.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..70074eddf79afcc444b4ccee16630de0b4fa6d9d --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/recordnames.txt @@ -0,0 +1,7 @@ +bytecodehar1-file1:&bytecodehar1/bytecodehar1-file1&2.0.0 +bytecodehar1-file2:&bytecodehar1/bytecodehar1-file2&2.0.0 +bytecodehar2-file1:&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +bytecodehar2-file2:&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +sourcehar-file1:&sourcehar/sourcehar-file1&2.0.0 +sourcehar-file2:&sourcehar/sourcehar-file2&2.0.0 +hap-file-exec:&myapp/hap-file-exec& diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/sourcehar-file1.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/sourcehar-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..f688431373716beb39877a74cd5d87297d0a64e3 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/sourcehar-file1.ts @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {test as test1} from '@normalized:N&&&sourcehar/sourcehar-file2&2.0.0' + +export function test() { + print('sourcehar.file1.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/sourcehar-file2.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/sourcehar-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..7702af07787a7190c88033b40fe1024e0f5e8e24 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-cache-file/sourcehar-file2.ts @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function test() { + print('sourcehar.file2.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/abcinputs/bytecodehar1.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/abcinputs/bytecodehar1.txt new file mode 100644 index 0000000000000000000000000000000000000000..44fef6254c424437d17bdd628f89ec1827c753d0 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/abcinputs/bytecodehar1.txt @@ -0,0 +1,2 @@ +bytecodehar1-file1.ts +bytecodehar1-file2.ts diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/abcinputs/bytecodehar2.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/abcinputs/bytecodehar2.txt new file mode 100644 index 0000000000000000000000000000000000000000..01249cd0afb7ae24d54f9a1b926115fc33893104 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/abcinputs/bytecodehar2.txt @@ -0,0 +1,2 @@ +bytecodehar2-file1.ts +bytecodehar2-file2.ts diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar1-file1.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar1-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..7478e0048213402e23cc0b7943b4732b63481299 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar1-file1.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {test as test1} from '@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0' + +export function test() { + print('bytecodehar1.file1.test'); + import('@normalized:N&&&sourcehar/sourcehar-file1&2.0.0') +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar1-file2.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar1-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..5962b22672130d07d4de572d0a55364e61b84dec --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar1-file2.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {test as test1} from "@normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&1.0.0" + +export function test() { + print('bytecodehar1.file2.test'); + import("@normalized:N&&&sourcehar/sourcehar-file2&2.0.0") +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar2-file1.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar2-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc82d9af7342aa36651045fde1b22f60a5147c20 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar2-file1.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function test() { + print('bytecodehar2.file1.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno1 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno1() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar2-file2.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar2-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..3716361621e705ebf971362f3a919d49d9c63bd1 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/bytecodehar2-file2.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function test() { + print('bytecodehar2.file2.test'); +} + +export @interface __$$ETS_ANNOTATION$$__Anno2 { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno2() +class A { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/compileContextInfo.json b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/compileContextInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..43eafd903dcdabf37bff8b31ae5b227be5be0bb2 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/compileContextInfo.json @@ -0,0 +1,13 @@ +{ + "compileEntries": [ + "&myapp/hap-file-exec&" + ], + "hspPkgNames": [], + "updateVersionInfo": { + "bytecodehar1": { + "@ohos/bytecodehar2": "2.0.0" + }, + "@ohos/bytecodehar2": { + } + } +} diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/hap-file-exec-expected.pa.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/hap-file-exec-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..839d23a63be919aec0c375491c09e70baf8755e3 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/hap-file-exec-expected.pa.txt @@ -0,0 +1,1718 @@ +All Dependency Files: +program_file: bytecodehar1-abcinput.abc +record_name: &bytecodehar1/bytecodehar1-file1&2.0.0 +program_file: bytecodehar1-abcinput.abc +record_name: &bytecodehar1/bytecodehar1-file2&2.0.0 +program_file: bytecodehar2-abcinput.abc +record_name: &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +program_file: bytecodehar2-abcinput.abc +record_name: &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +program_file: hap-file-exec.ts +record_name: &myapp/hap-file-exec& +program_file: hap-add-file.ts +record_name: &myapp/hap-add-file& +program_file: sourcehar-file1.ts +record_name: &sourcehar/sourcehar-file1&2.0.0 +program_file: sourcehar-file2.ts +record_name: &sourcehar/sourcehar-file2&2.0.0 + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file1&2.0.0_1844, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1782 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1786 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1844 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "bytecodehar1.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file2&2.0.0_1915, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1853 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1857 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno2 +}, +{ + index: 9 + tag: 5 + val: Anno2 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1915 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file2&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file2&2.0.0"; "bytecodehar1.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1607 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1611 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1712, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1664 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1668 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno2 +}, +{ + index: 5 + tag: 5 + val: Anno2 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1712 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A"; "bytecodehar2.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + lda.str @normalized:N&&&myapp/hap-add-file& + dynamicimport + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname A + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~B=#B(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~B=#B, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: A +}, +{ + index: 4 + tag: 5 + val: A +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: Anno1 +}, +{ + index: 7 + tag: 5 + val: Anno1 +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "@normalized:N&&&myapp/hap-add-file&"; "A"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &myapp/hap-add-file&.#*#modTest(any a0, any a1, any a2) { +label_1: +label_0: + lda.str @normalized:N&&&bytecodehar1/bytecodehar1-file2&2.0.0 + dynamicimport + tryldglobalbyname 0x0, test + callarg0 0x1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &myapp/hap-add-file&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-add-file&.#*#modTest, 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-add-file&_0 +------------------------------------ +slot &myapp/hap-add-file&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 0 +}, +{ + index: 5 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-add-file&.#*#modTest"; "@normalized:N&&&bytecodehar1/bytecodehar1-file2&2.0.0"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +{ + index: 8 + tag: 5 + val: test +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file2&2.0.0.#*#test"; "print"; "sourcehar.file2.test"; +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file1&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file1&2.0.0_1844, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1782 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1786 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno1 +}, +{ + index: 9 + tag: 5 + val: Anno1 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file1&2.0.0_1844 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file1&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file1&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file1&2.0.0"; "bytecodehar1.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar1.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + lda.str @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 + dynamicimport + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &bytecodehar1/bytecodehar1-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &bytecodehar1/bytecodehar1-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A, &bytecodehar1/bytecodehar1-file2&2.0.0_1915, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1853 +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1857 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 2 +}, +{ + index: 8 + tag: 5 + val: Anno2 +}, +{ + index: 9 + tag: 5 + val: Anno2 +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 5 + val: test +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +------------------------------------ +slot &bytecodehar1/bytecodehar1-file2&2.0.0_1915 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&bytecodehar1/bytecodehar1-file2&2.0.0.#*#test"; "&bytecodehar1/bytecodehar1-file2&2.0.0.#~A=#A"; "@normalized:N&&&sourcehar/sourcehar-file2&2.0.0"; "bytecodehar1.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1607 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1611 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno1 +}, +{ + index: 5 + tag: 5 + val: Anno1 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file1&2.0.0_1655 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0.#~A=#A"; "bytecodehar2.file1.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x3 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test(any a0, any a1, any a2) { + tryldglobalbyname 0x0, print + sta v0 + lda.str bytecodehar2.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +} + +slotNum = 0x0 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A(any a0, any a1, any a2) { + lda a2 + return +} + +slotNum = 0x4 +.language ECMAScript +.function any &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x1 + ldhole + sta v0 + defineclasswithbuffer 0x1, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A, &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1712, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1664 +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1668 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 2 +}, +{ + index: 4 + tag: 5 + val: Anno2 +}, +{ + index: 5 + tag: 5 + val: Anno2 +}, +{ + index: 6 + tag: 5 + val: test +}, +{ + index: 7 + tag: 5 + val: test +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +------------------------------------ +slot &@ohos/bytecodehar2/bytecodehar2-file2&2.0.0_1712 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#*#test"; "&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0.#~A=#A"; "bytecodehar2.file2.test"; "print"; "prototype"; + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.#*#main(any a0, any a1, any a2) { +label_1: +label_0: + lda.str @normalized:N&&&myapp/hap-add-file& + dynamicimport + ldexternalmodulevar 0x2 + sta v0 + throw.undefinedifholewithname test + lda v0 + callarg0 0x0 + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname A + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x0 +.language ECMAScript +.function any &myapp/hap-file-exec&.#~B=#B(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any &myapp/hap-file-exec&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-file-exec&.#*#main, 0x0 + ldhole + sta v0 + defineclasswithbuffer 0x1, &myapp/hap-file-exec&.#~B=#B, &myapp/hap-file-exec&_2, 0x0, v0 + ldobjbyname 0x2, prototype + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-file-exec&_0 +------------------------------------ +slot &myapp/hap-file-exec&_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 3 +}, +{ + index: 3 + tag: 5 + val: A +}, +{ + index: 4 + tag: 5 + val: A +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 5 + val: Anno1 +}, +{ + index: 7 + tag: 5 + val: Anno1 +}, +{ + index: 8 + tag: 9 + val: 0 +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 5 + val: test +}, +{ + index: 11 + tag: 9 + val: 0 +}, +{ + index: 12 + tag: 2 + val: 0 +}, +{ + index: 13 + tag: 2 + val: 0 +}, +{ + index: 14 + tag: 2 + val: 0 +}, +{ + index: 15 + tag: 2 + val: 0 +}, +------------------------------------ +slot &myapp/hap-file-exec&_2 +{ + index: 0 + tag: 0 + val: 2 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-file-exec&.#*#main"; "&myapp/hap-file-exec&.#~B=#B"; "@normalized:N&&&myapp/hap-add-file&"; "A"; "prototype"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &myapp/hap-add-file&.#*#modTest(any a0, any a1, any a2) { +label_1: +label_0: + lda.str @normalized:N&&&bytecodehar1/bytecodehar1-file2&2.0.0 + dynamicimport + tryldglobalbyname 0x0, test + callarg0 0x1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &myapp/hap-add-file&.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &myapp/hap-add-file&.#*#modTest, 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &myapp/hap-add-file&_0 +------------------------------------ +slot &myapp/hap-add-file&_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 0 +}, +{ + index: 4 + tag: 2 + val: 0 +}, +{ + index: 5 + tag: 2 + val: 0 +}, +======> strings <====== +"&myapp/hap-add-file&.#*#modTest"; "@normalized:N&&&bytecodehar1/bytecodehar1-file2&2.0.0"; "test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file1.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file1&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file1&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file1&2.0.0_1 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: @normalized:N&&&sourcehar/sourcehar-file2&2.0.0 +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: test1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 1 +}, +{ + index: 8 + tag: 5 + val: test +}, +{ + index: 9 + tag: 5 + val: test +}, +{ + index: 10 + tag: 2 + val: 0 +}, +{ + index: 11 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file1&2.0.0.#*#test"; "print"; "sourcehar.file1.test"; +slotNum = 0x3 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.#*#test(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str sourcehar.file2.test + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x1 +.language ECMAScript +.function any &sourcehar/sourcehar-file2&2.0.0.func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, &sourcehar/sourcehar-file2&2.0.0.#*#test, 0x0 + stmodulevar 0x0 + returnundefined +label_2: +} + + +======> literal array buffer <====== +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_0 +------------------------------------ +slot &sourcehar/sourcehar-file2&2.0.0_1 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: test +}, +{ + index: 5 + tag: 5 + val: test +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&sourcehar/sourcehar-file2&2.0.0.#*#test"; "print"; "sourcehar.file2.test"; diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/hap-file-exec.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/hap-file-exec.ts new file mode 100644 index 0000000000000000000000000000000000000000..b50023d9adf7aef2e9ad2161f836c098168cd4e6 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/hap-file-exec.ts @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { test, __$$ETS_ANNOTATION$$__Anno1, A } from "@normalized:N&&&bytecodehar1/bytecodehar1-file1&2.0.0" + +function main() { + import('@normalized:N&&&myapp/hap-add-file&') + test(); + let a = new A(); +} + + +@__$$ETS_ANNOTATION$$__Anno1({ b: true }) +class B { } \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/mod/hap-add-file.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/mod/hap-add-file.ts new file mode 100644 index 0000000000000000000000000000000000000000..d06729e3fa0a08bce25100e75e28f0cd7ba2b0a8 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/mod/hap-add-file.ts @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +function modTest() { + import('@normalized:N&&&bytecodehar1/bytecodehar1-file2&2.0.0'); + test(); +} \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/recordnames.txt b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..92d7f0e7b62ef2bdfa7b8da43b2597890ec30fcb --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/recordnames.txt @@ -0,0 +1,8 @@ +bytecodehar1-file1:&bytecodehar1/bytecodehar1-file1&2.0.0 +bytecodehar1-file2:&bytecodehar1/bytecodehar1-file2&2.0.0 +bytecodehar2-file1:&@ohos/bytecodehar2/bytecodehar2-file1&2.0.0 +bytecodehar2-file2:&@ohos/bytecodehar2/bytecodehar2-file2&2.0.0 +sourcehar-file1:&sourcehar/sourcehar-file1&2.0.0 +sourcehar-file2:&sourcehar/sourcehar-file2&2.0.0 +hap-file-exec:&myapp/hap-file-exec& +mod/hap-add-file:&myapp/hap-add-file& diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/sourcehar-file1.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/sourcehar-file1.ts new file mode 100644 index 0000000000000000000000000000000000000000..f688431373716beb39877a74cd5d87297d0a64e3 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/sourcehar-file1.ts @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {test as test1} from '@normalized:N&&&sourcehar/sourcehar-file2&2.0.0' + +export function test() { + print('sourcehar.file1.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/sourcehar-file2.ts b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/sourcehar-file2.ts new file mode 100644 index 0000000000000000000000000000000000000000..7702af07787a7190c88033b40fe1024e0f5e8e24 --- /dev/null +++ b/es2panda/test/compiler/cache_projects/bytecodehar-annotations-mod-hap-cache-file/sourcehar-file2.ts @@ -0,0 +1,18 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function test() { + print('sourcehar.file2.test'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/debugInfo/test-for-loop-expected.txt b/es2panda/test/compiler/debugInfo/test-for-loop-expected.txt index c581c730f7ff44bef5ea64c2b0acc388c8b1a82a..1de34365394260c519f6047728e4a78fff60c5f9 100644 --- a/es2panda/test/compiler/debugInfo/test-for-loop-expected.txt +++ b/es2panda/test/compiler/debugInfo/test-for-loop-expected.txt @@ -21,8 +21,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 1, "sourceLineNum": -1 } }, @@ -36,8 +34,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 1, - "boundRight": 2, "sourceLineNum": -1 } }, @@ -51,8 +47,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 2, - "boundRight": 3, "sourceLineNum": -1 } }, @@ -65,8 +59,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 3, - "boundRight": 8, "sourceLineNum": 15 } }, @@ -79,8 +71,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 8, - "boundRight": 10, "sourceLineNum": 15 } }, @@ -91,8 +81,6 @@ "imms": [], "label": "LABEL_2", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 15 } }, @@ -105,8 +93,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 10, - "boundRight": 12, "sourceLineNum": 15 } }, @@ -119,8 +105,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 12, - "boundRight": 14, "sourceLineNum": 15 } }, @@ -133,8 +117,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 14, - "boundRight": 19, "sourceLineNum": 15 } }, @@ -149,8 +131,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 19, - "boundRight": 22, "sourceLineNum": 15 } }, @@ -163,8 +143,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 22, - "boundRight": 24, "sourceLineNum": 15 } }, @@ -177,8 +155,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 24, - "boundRight": 29, "sourceLineNum": 16 } }, @@ -191,8 +167,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 29, - "boundRight": 31, "sourceLineNum": 16 } }, @@ -205,8 +179,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 31, - "boundRight": 34, "sourceLineNum": 17 } }, @@ -217,8 +189,6 @@ "imms": [], "label": "LABEL_1", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 15 } }, @@ -231,8 +201,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 34, - "boundRight": 36, "sourceLineNum": 15 } }, @@ -245,8 +213,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 36, - "boundRight": 38, "sourceLineNum": 15 } }, @@ -259,8 +225,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 38, - "boundRight": 40, "sourceLineNum": 15 } }, @@ -273,8 +237,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 40, - "boundRight": 42, "sourceLineNum": 15 } }, @@ -287,8 +249,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 42, - "boundRight": 44, "sourceLineNum": 15 } }, @@ -301,8 +261,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 44, - "boundRight": 46, "sourceLineNum": 15 } }, @@ -315,8 +273,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 46, - "boundRight": 48, "sourceLineNum": 15 } }, @@ -329,8 +285,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 48, - "boundRight": 50, "sourceLineNum": 15 } }, @@ -343,8 +297,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 50, - "boundRight": 52, "sourceLineNum": 15 } }, @@ -357,8 +309,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 52, - "boundRight": 54, "sourceLineNum": 15 } }, @@ -369,8 +319,6 @@ "imms": [], "label": "LABEL_0", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 15 } }, @@ -383,8 +331,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 54, - "boundRight": 59, "sourceLineNum": 19 } }, @@ -399,8 +345,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 59, - "boundRight": 64, "sourceLineNum": 19 } }, @@ -413,8 +357,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 64, - "boundRight": 69, "sourceLineNum": 20 } }, @@ -427,8 +369,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 69, - "boundRight": 71, "sourceLineNum": 20 } }, @@ -439,8 +379,6 @@ "imms": [], "label": "LABEL_5", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 20 } }, @@ -453,8 +391,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 71, - "boundRight": 73, "sourceLineNum": 20 } }, @@ -467,8 +403,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 73, - "boundRight": 75, "sourceLineNum": 20 } }, @@ -481,8 +415,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 75, - "boundRight": 80, "sourceLineNum": 20 } }, @@ -497,8 +429,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 80, - "boundRight": 83, "sourceLineNum": 20 } }, @@ -511,8 +441,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 83, - "boundRight": 85, "sourceLineNum": 20 } }, @@ -525,8 +453,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 85, - "boundRight": 90, "sourceLineNum": 21 } }, @@ -539,8 +465,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 90, - "boundRight": 92, "sourceLineNum": 21 } }, @@ -555,8 +479,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 92, - "boundRight": 96, "sourceLineNum": 22 } }, @@ -569,8 +491,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 96, - "boundRight": 98, "sourceLineNum": 22 } }, @@ -583,8 +503,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 98, - "boundRight": 100, "sourceLineNum": 22 } }, @@ -597,8 +515,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 100, - "boundRight": 102, "sourceLineNum": 22 } }, @@ -611,8 +527,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 102, - "boundRight": 104, "sourceLineNum": 22 } }, @@ -627,8 +541,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 104, - "boundRight": 107, "sourceLineNum": 22 } }, @@ -639,8 +551,6 @@ "imms": [], "label": "LABEL_4", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 19 } }, @@ -653,8 +563,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 107, - "boundRight": 109, "sourceLineNum": 20 } }, @@ -667,8 +575,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 109, - "boundRight": 111, "sourceLineNum": 20 } }, @@ -681,8 +587,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 111, - "boundRight": 113, "sourceLineNum": 20 } }, @@ -695,8 +599,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 113, - "boundRight": 115, "sourceLineNum": 20 } }, @@ -709,8 +611,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 115, - "boundRight": 117, "sourceLineNum": 20 } }, @@ -723,8 +623,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 117, - "boundRight": 119, "sourceLineNum": 20 } }, @@ -737,8 +635,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 119, - "boundRight": 121, "sourceLineNum": 20 } }, @@ -751,8 +647,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 121, - "boundRight": 123, "sourceLineNum": 20 } }, @@ -765,8 +659,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 123, - "boundRight": 125, "sourceLineNum": 20 } }, @@ -779,8 +671,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 125, - "boundRight": 127, "sourceLineNum": 20 } }, @@ -791,8 +681,6 @@ "imms": [], "label": "LABEL_3", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 19 } }, @@ -805,8 +693,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 127, - "boundRight": 132, "sourceLineNum": 24 } }, @@ -819,8 +705,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 132, - "boundRight": 134, "sourceLineNum": 24 } }, @@ -831,8 +715,6 @@ "imms": [], "label": "LABEL_8", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 24 } }, @@ -845,8 +727,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 134, - "boundRight": 136, "sourceLineNum": 24 } }, @@ -859,8 +739,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 136, - "boundRight": 138, "sourceLineNum": 24 } }, @@ -873,8 +751,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 138, - "boundRight": 143, "sourceLineNum": 24 } }, @@ -889,8 +765,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 143, - "boundRight": 146, "sourceLineNum": 24 } }, @@ -903,8 +777,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 146, - "boundRight": 148, "sourceLineNum": 24 } }, @@ -917,8 +789,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 148, - "boundRight": 153, "sourceLineNum": 25 } }, @@ -931,8 +801,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 153, - "boundRight": 155, "sourceLineNum": 25 } }, @@ -943,8 +811,6 @@ "imms": [], "label": "LABEL_11", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 25 } }, @@ -957,8 +823,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 155, - "boundRight": 157, "sourceLineNum": 25 } }, @@ -971,8 +835,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 157, - "boundRight": 159, "sourceLineNum": 25 } }, @@ -985,8 +847,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 159, - "boundRight": 164, "sourceLineNum": 25 } }, @@ -1001,8 +861,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 164, - "boundRight": 167, "sourceLineNum": 25 } }, @@ -1015,8 +873,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 167, - "boundRight": 169, "sourceLineNum": 25 } }, @@ -1029,8 +885,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 169, - "boundRight": 174, "sourceLineNum": 26 } }, @@ -1043,8 +897,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 174, - "boundRight": 176, "sourceLineNum": 26 } }, @@ -1055,8 +907,6 @@ "imms": [], "label": "LABEL_10", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 24 } }, @@ -1069,8 +919,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 176, - "boundRight": 178, "sourceLineNum": 25 } }, @@ -1083,8 +931,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 178, - "boundRight": 180, "sourceLineNum": 25 } }, @@ -1097,8 +943,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 180, - "boundRight": 182, "sourceLineNum": 25 } }, @@ -1111,8 +955,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 182, - "boundRight": 184, "sourceLineNum": 25 } }, @@ -1125,8 +967,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 184, - "boundRight": 186, "sourceLineNum": 25 } }, @@ -1139,8 +979,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 186, - "boundRight": 188, "sourceLineNum": 25 } }, @@ -1153,8 +991,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 188, - "boundRight": 190, "sourceLineNum": 25 } }, @@ -1167,8 +1003,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 190, - "boundRight": 192, "sourceLineNum": 25 } }, @@ -1181,8 +1015,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 192, - "boundRight": 194, "sourceLineNum": 25 } }, @@ -1195,8 +1027,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 194, - "boundRight": 196, "sourceLineNum": 25 } }, @@ -1207,8 +1037,6 @@ "imms": [], "label": "LABEL_9", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 24 } }, @@ -1219,8 +1047,6 @@ "imms": [], "label": "LABEL_7", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 19 } }, @@ -1233,8 +1059,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 196, - "boundRight": 198, "sourceLineNum": 24 } }, @@ -1247,8 +1071,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 198, - "boundRight": 200, "sourceLineNum": 24 } }, @@ -1261,8 +1083,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 200, - "boundRight": 202, "sourceLineNum": 24 } }, @@ -1275,8 +1095,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 202, - "boundRight": 204, "sourceLineNum": 24 } }, @@ -1289,8 +1107,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 204, - "boundRight": 206, "sourceLineNum": 24 } }, @@ -1303,8 +1119,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 206, - "boundRight": 208, "sourceLineNum": 24 } }, @@ -1317,8 +1131,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 208, - "boundRight": 210, "sourceLineNum": 24 } }, @@ -1331,8 +1143,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 210, - "boundRight": 212, "sourceLineNum": 24 } }, @@ -1345,8 +1155,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 212, - "boundRight": 214, "sourceLineNum": 24 } }, @@ -1359,8 +1167,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 214, - "boundRight": 216, "sourceLineNum": 24 } }, @@ -1371,8 +1177,6 @@ "imms": [], "label": "LABEL_6", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": 19 } }, @@ -1383,8 +1187,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": -1 } }, @@ -1395,8 +1197,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": -1 } } diff --git a/es2panda/test/compiler/debugInfo/test-local-variable-expected.txt b/es2panda/test/compiler/debugInfo/test-local-variable-expected.txt index 90556498d0ac47a604fe9baee66cf5e3c3add079..be4b8491f7caf58d8d88913e48c0cffe18ee2c25 100644 --- a/es2panda/test/compiler/debugInfo/test-local-variable-expected.txt +++ b/es2panda/test/compiler/debugInfo/test-local-variable-expected.txt @@ -21,8 +21,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 1, "sourceLineNum": -1 } }, @@ -36,8 +34,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 1, - "boundRight": 2, "sourceLineNum": -1 } }, @@ -51,8 +47,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 2, - "boundRight": 3, "sourceLineNum": -1 } }, @@ -65,8 +59,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 3, - "boundRight": 8, "sourceLineNum": 15 } }, @@ -81,8 +73,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 8, - "boundRight": 13, "sourceLineNum": 15 } }, @@ -95,8 +85,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 13, - "boundRight": 18, "sourceLineNum": 17 } }, @@ -109,8 +97,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 18, - "boundRight": 20, "sourceLineNum": 17 } }, @@ -123,8 +109,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 20, - "boundRight": 23, "sourceLineNum": 18 } }, @@ -137,8 +121,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 23, - "boundRight": 28, "sourceLineNum": 22 } }, @@ -151,8 +133,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 28, - "boundRight": 30, "sourceLineNum": 22 } }, @@ -165,8 +145,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 30, - "boundRight": 33, "sourceLineNum": 23 } }, @@ -179,8 +157,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 33, - "boundRight": 38, "sourceLineNum": 25 } }, @@ -193,8 +169,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 38, - "boundRight": 40, "sourceLineNum": 25 } }, @@ -207,8 +181,6 @@ ], "label": "", "debug_pos_info": { - "boundLeft": 40, - "boundRight": 45, "sourceLineNum": 27 } }, @@ -221,8 +193,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 45, - "boundRight": 47, "sourceLineNum": 27 } }, @@ -233,8 +203,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": -1 } }, @@ -245,8 +213,6 @@ "imms": [], "label": "", "debug_pos_info": { - "boundLeft": 0, - "boundRight": 0, "sourceLineNum": -1 } } diff --git a/es2panda/test/compiler/js/array-literal-1-expected.txt b/es2panda/test/compiler/js/array-literal-1-expected.txt index 1a9c6f0aeb65047698dda549f7fa0dda1d02d7c4..877137e32a7495feb394e0fe13a0f03b81df55a8 100644 --- a/es2panda/test/compiler/js/array-literal-1-expected.txt +++ b/es2panda/test/compiler/js/array-literal-1-expected.txt @@ -1 +1 @@ -TypeError: is not callable +TypeError: Object is not callable diff --git a/es2panda/test/compiler/js/json-parser-expected.txt b/es2panda/test/compiler/js/json-parser-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..09daa6cc4f4d62bf98424fd88eeb6ac120382257 --- /dev/null +++ b/es2panda/test/compiler/js/json-parser-expected.txt @@ -0,0 +1,49 @@ +1,2,3 1,2,3 +1 1 + +https://www.a.com https://www.a.com +https://www.b.com https://www.b.com +https://www.c.com https://www.c.com +[object Object] [object Object] +Infinity Infinity +-Infinity -Infinity +123 123 +SyntaxError SyntaxError +56320 56320 +{"a":"{\"width\": 18}"} {"a":"{\"width\": 18}"} +{"a":"{\"name\": \"张三\"}"} {"a":"{\"name\": \"张三\"}"} +{"1\u0000":"name"} {"1\u0000":"name"} +0 0 +-Infinity -Infinity +JSON.parse with backslash JSON.parse with backslash +"" "" +Uf Uf +啕晦 啕晦 +"" "" +Uf Uf +啕晦 啕晦 +SyntaxError SyntaxError +SyntaxError SyntaxError +SyntaxError SyntaxError +10 10 +hello hello +true true +14 14 +24 24 +29 29 +36 36 +46 46 +1.79e+308 1.79e+308 +Infinity Infinity +Infinity Infinity +2.225e-308 2.225e-308 +2.225e-309 2.225e-309 +3e-320 3e-320 +5e-324 5e-324 +0 0 +0 0 +2.225e-308 +2.225e-309 +3e-320 +5e-324 +SyntaxError SyntaxError diff --git a/es2panda/test/compiler/js/json-parser.js b/es2panda/test/compiler/js/json-parser.js new file mode 100644 index 0000000000000000000000000000000000000000..bb7a92d40a4a7b8322117cd695a9f62f878d3305 --- /dev/null +++ b/es2panda/test/compiler/js/json-parser.js @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +let json = JSON.parse("[ 1, 2, 3]"); +print(json,[1,2,3]); +let json2 = JSON.parse("[ 1 ]"); +print(json2,[1]); +let json3 = JSON.parse("[ ]"); +print(json3,[]); +let data = { + "11111111" : "https://www.a.com", + "22222222" : "https://www.b.com", + "00000000" : "https://www.c.com" +} +let strData = JSON.stringify(data); +let res = JSON.parse(strData); +print(res["11111111"],'https://www.a.com'); +print(res["22222222"],'https://www.b.com'); +print(res["00000000"],'https://www.c.com'); + +var a = `{"code": 0, "msg": "ok"}` +function reviver(k, v) { return v; } +var o = JSON.parse(a, reviver); +print(o.toString(),'[object Object]'); + +let strData2 = "1.7976971348623157e+308"; +let res2 = JSON.parse(strData2); +print(res2,Infinity); + +let strData3 = "-1.7976971348623157e+308"; +let res3 = JSON.parse(strData3); +print(res3,-Infinity); + +let strData4 = "123"; +let res4 = JSON.parse(strData4); +print(res4,123); + +try { + JSON.parse(`{"object": 42, "test":{}`) +} catch (error) { + print(error.name,'SyntaxError') + +} + +let strData5 = "\"\\uDC00\""; +let res5 = JSON.parse(strData5); +print(res5.codePointAt(0),56320) + +let strData6 = '{"a": "{\\"width\\": 18}"}' +print(JSON.stringify(JSON.parse(strData6)),'{"a":"{\\"width\\": 18}"}') + +let strData7 = '{"a": "{\\"name\\": \\"张三\\"}"}' +print(JSON.stringify(JSON.parse(strData7)),'{"a":"{\\"name\\": \\"张三\\"}"}') + +let strData8 = '{"1\\u0000":"name"}' +print(JSON.stringify(JSON.parse(strData8)),'{"1\\u0000":"name"}') + +print(JSON.parse('123.456e-789'),0); +print(1 / JSON.parse('-0'),-Infinity); + +var string = "JSON.parse with backslash"; +print(string,"JSON.parse with backslash"); +print(JSON.parse('"\\"\\""'),'""'); // utf8 -> utf8 +print(JSON.parse('"\\u0055\\u0066"'),'Uf'); // utf8 -> utf8 +print(JSON.parse('"\\u5555\\u6666"'),'啕晦'); // utf8 -> utf16 +print(JSON.parse('["\\"\\"","中文"]')[0],'""'); // utf16 -> utf8 +print(JSON.parse('["\\u0055\\u0066","中文"]')[0],'Uf'); // utf16 -> utf8 +print(JSON.parse('["\\u5555\\u6666","中文"]')[0],'啕晦'); // utf16 -> utf16 + +const strData9 = `{"k1":"hello","k2":3}`; +const strErr = strData9.substring(0, strData9.length - 2); +try { + JSON.parse(strErr); +} catch (err) { + print(err.name,'SyntaxError'); +} + +const strData10 = `{"k1":"hello","k2": 3}`; +const strErr2 = strData10.substring(0, strData10.length - 2); +try { + JSON.parse(strErr2); +} catch (err) { + print(err.name,'SyntaxError'); +} + +const strData11 = `{"k1":"hello","k2":311111}`; +const strErr3 = strData11.substring(0, strData11.length - 2); +try { + JSON.parse(strErr3); +} catch (err) { + print(err.name,'SyntaxError'); +} + +let jsonSingleStr = `{ + "a": 10, + "b": "hello", + "c": true, + "d": null, + "e": 5, + "f": 6, + "g": 7, + "h": 8, + "i": 9, + "j": 10, + "k": 11, + "l": 12, + "m": 13, + "n": 14, + "o": 15, + "p": 16, + "q": 17, + "r": 18, + "s": 19, + "t": 20, + "u": 21, + "v": 22, + "w": 23, + "x": 24, + "y": 25, + "z": 26, + "A": 27, + "B": 28, + "C": 29, + "D": 30, + "E": 31, + "F": 32, + "G": 33, + "H": 34, + "I": 35, + "J": 36, + "K": 37, + "L": 38, + "M": 39, + "N": 40, + "O": 41, + "P": 42, + "Q": 43, + "R": 44, + "S": 45, + "T": 46, + "U": 47, + "V": 48, + "W": 49, + "X": 50, + "Y": 51, + "Z": 52 +}`; + +let parsedObj = JSON.parse(jsonSingleStr); +print(parsedObj.a, 10); +print(parsedObj.b, 'hello'); +print(parsedObj.c, true); +print(parsedObj.n, 14); +print(parsedObj.x, 24); +print(parsedObj.C, 29); +print(parsedObj.J, 36); +print(parsedObj.T, 46); + +let numStr = `{ + "numberval1": 1.79e+308, + "numberval2": 1.7976931348623158e+309, + "numberval3": 5e+320, + "numberval4": 2.225e-308, + "numberval5": 2.225e-309, + "numberval6": 3e-320, + "numberval7": 5e-324, + "numberval8": 5e-325, + "numberval9": 7e-350 +}`; +let numParsedObj = JSON.parse(numStr); +print(numParsedObj.numberval1, 1.79e+308);// DBL_MAX +print(numParsedObj.numberval2, Infinity);// greater than DBL_MAX, expect Infinity +print(numParsedObj.numberval3, Infinity);// greater than DBL_MAX, expect Infinity +print(numParsedObj.numberval4, 2.225e-308);// DBL_MIN +print(numParsedObj.numberval5, 2.225e-309);// less than DBL_MIN +print(numParsedObj.numberval6, 3e-320);// less than DBL_MIN +print(numParsedObj.numberval7, 5e-324);// Number.MIN_VALUE +print(numParsedObj.numberval8, 0);// less than Number.MIN_VALUE, expect 0 +print(numParsedObj.numberval9, 0);// less than Number.MIN_VALUE, expect 0 + +print(2.225e-308); // 2.225e-308 +print(2.225e-309); // 2.225e-309 +print(3e-320); // 3e-320 +print(5e-324); // 5e-324 + +{ + let err = {}; + try { + JSON.parse(`{"object哈哈": 42, "test":{}`) + } catch (error) { + err = error; + } + print(err.name, 'SyntaxError'); +} \ No newline at end of file diff --git a/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-nosuper-exception-expected.txt b/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-nosuper-exception-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..5ab2536e66495936b2204205a550c80b8b4d8355 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-nosuper-exception-expected.txt @@ -0,0 +1,10 @@ +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' +ReferenceError: undefinedsub-class must call super before use 'this' diff --git a/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-nosuper-exception.js b/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-nosuper-exception.js new file mode 100644 index 0000000000000000000000000000000000000000..75672f2a6b9c6964bf738b7dd38462a5a2623f2e --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-nosuper-exception.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class C34 {} +class C35 extends C34 { + constructor(a37, a38 , a39) { + for (let v40 = 0; v40 < 10; v40++) { + try { + let v42; + return v42; + function f43() { + return f43; + } + function f46(a47, a48) { + return C35; + } + } catch (e52) { + print(e52); + } + } + super(); + } +} +new C35(); \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_below_API11_version-expected.txt b/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-super-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_below_API11_version-expected.txt rename to es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-super-expected.txt diff --git a/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-super.js b/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-super.js new file mode 100644 index 0000000000000000000000000000000000000000..d9f14924444f619b6875e940eb75b5f0d896dfc3 --- /dev/null +++ b/es2panda/test/compiler/js/lexicalEnv/classEnv/constructor-try-catch-super.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class C34 {} +class C35 extends C34 { + constructor(a37, a38 , a39) { + super(); + for (let v40 = 0; v40 < 10; v40++) { + try { + let v42; + return v42; + function f43() { + return f43; + } + function f46(a47, a48) { + return C35; + } + } catch (e52) { + print(e52); + } + } + } +} +new C35(); diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/abcinputs/main_hap.txt b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/abcinputs/main_hap.txt new file mode 100644 index 0000000000000000000000000000000000000000..8cf0b55aaaaf93acdb66613576bdfa749ea3c659 --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/abcinputs/main_hap.txt @@ -0,0 +1,2 @@ +main_hap.ts +main_hap_import_file.ts diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/abcinputs/sdk_hap.txt b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/abcinputs/sdk_hap.txt new file mode 100644 index 0000000000000000000000000000000000000000..128e160248bbfe2d832e30a4bb511a0aef8c35da --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/abcinputs/sdk_hap.txt @@ -0,0 +1,2 @@ +sdk_hap.ts +sdk_hap_import_file.ts diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap-expected.pa.txt b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap-expected.pa.txt new file mode 100644 index 0000000000000000000000000000000000000000..f8c85e90b8ac47f49cc3df51a1f80ee4f48d501a --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap-expected.pa.txt @@ -0,0 +1,306 @@ +slotNum = 0x2 +.language ECMAScript +.function any &src_hap_to/main_hap&.#*#main(any a0, any a1, any a2) { + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname mainHapAddTest + lda v0 + callarg0 0x0 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &src_hap_to/main_hap&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &src_hap_to/main_hap&.#*#main, 0x0 + callarg0 0x1 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &src_hap_to/main_hap&_1084 +------------------------------------ +slot &src_hap_to/main_hap&_1088 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: &src_hap_to/main_hap_import_file& +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: mainHapAddTest +}, +{ + index: 4 + tag: 5 + val: mainHapAddTest +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +======> strings <====== +"&src_hap_to/main_hap&.#*#main"; "mainHapAddTest"; +slotNum = 0x1 +.language ECMAScript +.function any &src_hap_to/main_hap_import_file&.#*#mainHapAddTest(any a0, any a1, any a2, any a3, any a4) { + lda a4 + add2 0x0, a3 + return +} + +slotNum = 0x1 +.language ECMAScript +.function any &src_hap_to/main_hap_import_file&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &src_hap_to/main_hap_import_file&.#*#mainHapAddTest, 0x2 + stmodulevar 0x0 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &src_hap_to/main_hap_import_file&_1130 +------------------------------------ +slot &src_hap_to/main_hap_import_file&_1134 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: mainHapAddTest +}, +{ + index: 5 + tag: 5 + val: mainHapAddTest +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&src_hap_to/main_hap_import_file&.#*#mainHapAddTest"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + +slotNum = 0x2 +.language ECMAScript +.function any &src_hap_to/sdk_hap&.#*#main(any a0, any a1, any a2) { + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname sdkHapAddTest + lda v0 + callarg0 0x0 + returnundefined +} + +slotNum = 0x3 +.language ECMAScript +.function any &src_hap_to/sdk_hap&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &src_hap_to/sdk_hap&.#*#main, 0x0 + callarg0 0x1 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &src_hap_to/sdk_hap&_1051 +------------------------------------ +slot &src_hap_to/sdk_hap&_1055 +{ + index: 0 + tag: 2 + val: 1 +}, +{ + index: 1 + tag: 5 + val: &src_hap/sdk_hap_import_file& +}, +{ + index: 2 + tag: 2 + val: 1 +}, +{ + index: 3 + tag: 5 + val: sdkHapAddTest +}, +{ + index: 4 + tag: 5 + val: sdkHapAddTest +}, +{ + index: 5 + tag: 9 + val: 0 +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +{ + index: 8 + tag: 2 + val: 0 +}, +{ + index: 9 + tag: 2 + val: 0 +}, +======> strings <====== +"&src_hap_to/sdk_hap&.#*#main"; "sdkHapAddTest"; +slotNum = 0x1 +.language ECMAScript +.function any &src_hap_to/sdk_hap_import_file&.#*#sdkHapAddTest(any a0, any a1, any a2, any a3, any a4) { + lda a4 + add2 0x0, a3 + return +} + +slotNum = 0x1 +.language ECMAScript +.function any &src_hap_to/sdk_hap_import_file&.func_main_0(any a0, any a1, any a2) { + definefunc 0x0, &src_hap_to/sdk_hap_import_file&.#*#sdkHapAddTest, 0x2 + stmodulevar 0x0 + returnundefined +} + + +======> literal array buffer <====== +------------------------------------ +slot &src_hap_to/sdk_hap_import_file&_1097 +------------------------------------ +slot &src_hap_to/sdk_hap_import_file&_1101 +{ + index: 0 + tag: 2 + val: 0 +}, +{ + index: 1 + tag: 2 + val: 0 +}, +{ + index: 2 + tag: 2 + val: 0 +}, +{ + index: 3 + tag: 2 + val: 1 +}, +{ + index: 4 + tag: 5 + val: sdkHapAddTest +}, +{ + index: 5 + tag: 5 + val: sdkHapAddTest +}, +{ + index: 6 + tag: 2 + val: 0 +}, +{ + index: 7 + tag: 2 + val: 0 +}, +======> strings <====== +"&src_hap_to/sdk_hap_import_file&.#*#sdkHapAddTest"; + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + + +======> literal array buffer <====== +======> strings <====== + diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap.ts b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap.ts new file mode 100644 index 0000000000000000000000000000000000000000..71370610b2920fe8a0eb3db310a42cf0e1251730 --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {mainHapAddTest} from '&src_hap_to/main_hap_import_file&' + +function main(): void { + mainHapAddTest(); +} + +main() diff --git a/ets2panda/test/ast/compiler/ets/esobject_with_string_key_1.ets b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap_import_file.ts similarity index 87% rename from ets2panda/test/ast/compiler/ets/esobject_with_string_key_1.ets rename to es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap_import_file.ts index 925373191271ff263e939dfc9d5c2b58e5e4e6c9..b27f3ac054e476ab6ca42bfb6ebcf1071152f3d1 100644 --- a/ets2panda/test/ast/compiler/ets/esobject_with_string_key_1.ets +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/main_hap_import_file.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -function foo (es: JSValue): string { - let str = 'Ekk' + 'o'; - return es[str]; +export function mainHapAddTest(a: number, b: number): number +{ + return a + b; } \ No newline at end of file diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/modify_pkg_name.txt b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/modify_pkg_name.txt new file mode 100644 index 0000000000000000000000000000000000000000..7a945914df60d5279963503cfc3feffe25c9c5d4 --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/modify_pkg_name.txt @@ -0,0 +1 @@ +src_hap:src_hap_to diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/recordnames.txt b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/recordnames.txt new file mode 100644 index 0000000000000000000000000000000000000000..0fc5ee282130b69148afbc05d4085c2556319ddd --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/recordnames.txt @@ -0,0 +1,4 @@ +main_hap:&src_hap_to/main_hap& +main_hap_import_file:&src_hap_to/main_hap_import_file& +sdk_hap:&src_hap/sdk_hap& +sdk_hap_import_file:&src_hap/sdk_hap_import_file& diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/sdk_hap.ts b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/sdk_hap.ts new file mode 100644 index 0000000000000000000000000000000000000000..8087e36196f4df495ece5b7d5b33a82ecb5cbd77 --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/sdk_hap.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {sdkHapAddTest} from '&src_hap/sdk_hap_import_file&' + +function main(): void { + sdkHapAddTest(); +} + +main() diff --git a/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/sdk_hap_import_file.ts b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/sdk_hap_import_file.ts new file mode 100644 index 0000000000000000000000000000000000000000..041a885320f588cc68f561fb2d7b4fa1446fa172 --- /dev/null +++ b/es2panda/test/compiler/merge_hap/projects/merge_hap_replace_perfix_pkg_name/sdk_hap_import_file.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function sdkHapAddTest(a: number, b: number): number +{ + return a + b; +} \ No newline at end of file diff --git a/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-1-expected.txt b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-1-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..4fd6ce6872b3ca43bf5892e5865ecae098c2c696 --- /dev/null +++ b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-1-expected.txt @@ -0,0 +1,38 @@ +1.79e+308 +Infinity +Infinity +2.225e-308 +2.225e-309 +3e-320 +5e-324 +0 +0 +-1.79e+308 +-Infinity +-Infinity +-2.225e-308 +-2.225e-309 +-3e-320 +-5e-324 +0 +0 +false +false +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true +true diff --git a/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-1.ts b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-1.ts new file mode 100644 index 0000000000000000000000000000000000000000..6f765b620664a54d33c37b3e4d0a211f75484f49 --- /dev/null +++ b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-1.ts @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +let numStr = `{ + "numberval1": 1.79e+308, + "numberval2": 1.7976931348623158e+309, + "numberval3": 5e+320, + "numberval4": 2.225e-308, + "numberval5": 2.225e-309, + "numberval6": 3e-320, + "numberval7": 5e-324, + "numberval8": 5e-325, + "numberval9": 7e-350, + "numberval10": -1.79e+308, + "numberval11": -1.7976931348623158e+309, + "numberval12": -5e+320, + "numberval13": -2.225e-308, + "numberval14": -2.225e-309, + "numberval15": -3e-320, + "numberval16": -5e-324, + "numberval17": -5e-325, + "numberval18": -7e-350 +}`; + +let numParsedObj = JSON.parse(numStr); +print(numParsedObj.numberval1);// DBL_MAX, 1.79e+308 +print(numParsedObj.numberval2);// greater than DBL_MAX, expect Infinity +print(numParsedObj.numberval3);// greater than DBL_MAX, expect Infinity +print(numParsedObj.numberval4);// DBL_MIN, 2.225e-308 +print(numParsedObj.numberval5);// less than DBL_MIN, 2.225e-309 +print(numParsedObj.numberval6);// less than DBL_MIN, 3e-320 +print(numParsedObj.numberval7);// Number.MIN_VALUE, 5e-324 +print(numParsedObj.numberval8);// less than Number.MIN_VALUE, expect 0 +print(numParsedObj.numberval9);// less than Number.MIN_VALUE, expect 0 + +print(numParsedObj.numberval10); // -1.79e+308 +print(numParsedObj.numberval11); // -Infinity +print(numParsedObj.numberval12); // -Infinity +print(numParsedObj.numberval13); // -2.225e-308 +print(numParsedObj.numberval14); // -2.225e-309 +print(numParsedObj.numberval15); // -3e-320 +print(numParsedObj.numberval16); // -5e-324 +print(numParsedObj.numberval17); // -0 +print(numParsedObj.numberval18); // -0 + +print(Object.is(numParsedObj.numberval2, numParsedObj.numberval11)) // false +print(Object.is(numParsedObj.numberval18, numParsedObj.numberval9)) // false + +print(Object.is(numParsedObj.numberval1, 1.79e+308)); // true +print(Object.is(numParsedObj.numberval2, Infinity)); // true +print(Object.is(numParsedObj.numberval3, Infinity)); // true +print(Object.is(numParsedObj.numberval4, 2.225e-308)); // true +print(Object.is(numParsedObj.numberval5, 2.225e-309)); // true +print(Object.is(numParsedObj.numberval6, 3e-320)); // true +print(Object.is(numParsedObj.numberval7, Number.MIN_VALUE)); // true +print(Object.is(numParsedObj.numberval8, 0)); // true +print(Object.is(numParsedObj.numberval9, 0)); // true + +print(Object.is(numParsedObj.numberval10, -1.79e+308)); // true +print(Object.is(numParsedObj.numberval11, -Infinity)); // true +print(Object.is(numParsedObj.numberval12, -Infinity)); // true +print(Object.is(numParsedObj.numberval13, -2.225e-308)); // true +print(Object.is(numParsedObj.numberval14, -2.225e-309)); // true +print(Object.is(numParsedObj.numberval15, -3e-320)); // true +print(Object.is(numParsedObj.numberval16, -5e-324)); // true +print(Object.is(numParsedObj.numberval17, -0)); // true, distinguishes from 0 +print(Object.is(numParsedObj.numberval18, -0)); // true \ No newline at end of file diff --git a/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-2-expected.txt b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-2-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..9ee55078c115a54972821ed3759d4cce4ff5a666 --- /dev/null +++ b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-2-expected.txt @@ -0,0 +1,18 @@ +1.79e+308 +Infinity +Infinity +2.225e-308 +2.225e-309 +3e-320 +5e-324 +0 +0 +-1.79e+308 +-Infinity +-Infinity +-2.225e-308 +-2.225e-309 +-3e-320 +-5e-324 +0 +0 diff --git a/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-2.ts b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-2.ts new file mode 100644 index 0000000000000000000000000000000000000000..bfa7afc80d33026c02b2700f1844cc7e9ef9c0fc --- /dev/null +++ b/es2panda/test/compiler/ts/cases/compiler/test-ts-extremely-number-2.ts @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +print(1.79e+308); +print(1.7976931348623158e+309); +print(5e+320); +print(2.225e-308); +print(2.225e-309); +print(3e-320); +print(5e-324); +print(5e-325); +print(7e-350); + +print(-1.79e+308); +print(-1.7976931348623158e+309); +print(-5e+320); +print(-2.225e-308); +print(-2.225e-309); +print(-3e-320); +print(-5e-324); +print(-5e-325); +print(-7e-350); \ No newline at end of file diff --git a/es2panda/test/compiler/ts/cases/compiler/test-ts-func-param-expected.txt b/es2panda/test/compiler/ts/cases/compiler/test-ts-func-param-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..25d54ae75586b1d426ebc99503cb5141b6319aec --- /dev/null +++ b/es2panda/test/compiler/ts/cases/compiler/test-ts-func-param-expected.txt @@ -0,0 +1,2 @@ +333 +111 1 diff --git a/es2panda/test/compiler/ts/cases/compiler/test-ts-func-param.ts b/es2panda/test/compiler/ts/cases/compiler/test-ts-func-param.ts new file mode 100644 index 0000000000000000000000000000000000000000..717ae2477f4c7617015a2459b60ef6c117980a29 --- /dev/null +++ b/es2panda/test/compiler/ts/cases/compiler/test-ts-func-param.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +let a = "111"; +let b = "222"; +let c = true; +function test1() { + print("333") +} +function test2(aa : string = c ? (test1(),a) : (test1(),b), dd:number = 1) { + print(aa, dd); +} + +test2() diff --git a/es2panda/test/compiler/ts/cases/conformance/functions/test-ts-declare-function-1.ts b/es2panda/test/compiler/ts/cases/conformance/functions/test-ts-declare-function-1.ts index 0cb3633e5b585c7cf1cacae5fd2f579feae7c03b..c2ec7c2624228af689abe066be206a7b6ad13793 100644 --- a/es2panda/test/compiler/ts/cases/conformance/functions/test-ts-declare-function-1.ts +++ b/es2panda/test/compiler/ts/cases/conformance/functions/test-ts-declare-function-1.ts @@ -24,8 +24,8 @@ class C { } let c = new C(); -let env = ArkTools.getLexicalEnv(c.method1); -if (env !== undefined) { +let res = ArkTools.currentEnvIsGlobal(c.method1); +if (res !== true) { print(1); } else { print(2); diff --git a/es2panda/test/config.py b/es2panda/test/config.py index 6e57dedbad40e21ee0b2c5b275cae1cbebdc7e31..6cf0d5ede391eb662cc6c2aa3e066182908d756f 100644 --- a/es2panda/test/config.py +++ b/es2panda/test/config.py @@ -22,7 +22,26 @@ API_VERSION_MAP = { "API12beta2": "12.0.2.0", "API12beta3": "12.0.6.0", "API13": "12.0.6.0", + "API14": "12.0.6.0", + "API15": "12.0.6.0", + "API16": "12.0.6.0", + "API17": "12.0.6.0", + "API18": "13.0.1.0", + "API19": "13.0.1.0", + "API20": "13.0.1.0", } + +ARK_JS_VM_LIST = {"API9", "API10", "API11", "API12beta1", "API12beta3", "API18"} + +ES2ABC_API_SUPPORT = { + "default": ["API9", "API10", "API11", "API12beta1", "API12beta2", "API12beta3", + "API13", "API14", "API15", "API16", "API17", "API18"], + "5.0": ["API9", "API10", "API11", "API12beta1", "API12beta2", "API12beta3", + "API13", "API14", "API15", "API16", "API17"], + "5.1": ["API9", "API10", "API11", "API12beta1", "API12beta2", "API12beta3", + "API13", "API14", "API15", "API16", "API17", "API18"], +} + MIN_SUPPORT_BC_VERSION = "API12beta1" MIX_COMPILE_ENTRY_POINT = "import" diff --git a/es2panda/test/parser/annotations/declaration-3d-array-boolean-expected.txt b/es2panda/test/parser/annotations/declaration-3d-array-boolean-expected.txt index 4c936880569b6656f65a26c70923310db237b381..8c9283391a83cb6213cbd8d5f22274499acdde27 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-boolean-expected.txt +++ b/es2panda/test/parser/annotations/declaration-3d-array-boolean-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -190,7 +190,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -224,7 +224,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -486,7 +486,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, @@ -520,7 +520,7 @@ }, "end": { "line": 24, - "column": 17 + "column": 39 } } }, @@ -812,7 +812,7 @@ "loc": { "start": { "line": 24, - "column": 18 + "column": 40 }, "end": { "line": 26, diff --git a/es2panda/test/parser/annotations/declaration-3d-array-boolean.ts b/es2panda/test/parser/annotations/declaration-3d-array-boolean.ts index 8bb5148dc721dad55760f4cf315cd6dd0f348a4c..b13f16c168dc4afec2966bf489d0c34eafae41d4 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-boolean.ts +++ b/es2panda/test/parser/annotations/declaration-3d-array-boolean.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: boolean[][][]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: boolean[][][] = [[new Array()]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: boolean[][][] = [[[true, false], [true, false]]]; } diff --git a/es2panda/test/parser/annotations/declaration-3d-array-enum-number-expected.txt b/es2panda/test/parser/annotations/declaration-3d-array-enum-number-expected.txt index 0a07759fa1a9fae16b424b80c1fe18d1d238dfa9..8405fb734e1ed811f3b7d1fbfa51343a31f1343a 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-enum-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-3d-array-enum-number-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 17 + "column": 39 } } }, @@ -431,7 +431,7 @@ "loc": { "start": { "line": 21, - "column": 18 + "column": 40 }, "end": { "line": 24, @@ -465,7 +465,7 @@ }, "end": { "line": 26, - "column": 17 + "column": 39 } } }, @@ -770,7 +770,7 @@ "loc": { "start": { "line": 26, - "column": 18 + "column": 40 }, "end": { "line": 29, @@ -804,7 +804,7 @@ }, "end": { "line": 31, - "column": 17 + "column": 39 } } }, @@ -1081,7 +1081,7 @@ "loc": { "start": { "line": 31, - "column": 18 + "column": 40 }, "end": { "line": 33, diff --git a/es2panda/test/parser/annotations/declaration-3d-array-enum-number.ts b/es2panda/test/parser/annotations/declaration-3d-array-enum-number.ts index 744a142fe28730bf84d1f48621bdcdd2254e9126..4a04e01d3ba4e4b68442a5c36ac47339c99bcf5d 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-enum-number.ts +++ b/es2panda/test/parser/annotations/declaration-3d-array-enum-number.ts @@ -18,16 +18,16 @@ const enum E { B = 314 } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying number type a: E[][][] = [[new Array(0)]]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying number type a: E[][][] = [[new Array(1)]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[][][] = [[[42, 314, 42]]]; } diff --git a/es2panda/test/parser/annotations/declaration-3d-array-enum-string-expected.txt b/es2panda/test/parser/annotations/declaration-3d-array-enum-string-expected.txt index 953a3b9d73e3d7aeea255f16224cb373666417f4..bbbcb10019dd63e85b541d61be034a411f8d0c93 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-enum-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-3d-array-enum-string-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 17 + "column": 39 } } }, @@ -431,7 +431,7 @@ "loc": { "start": { "line": 21, - "column": 18 + "column": 40 }, "end": { "line": 24, @@ -465,7 +465,7 @@ }, "end": { "line": 26, - "column": 17 + "column": 39 } } }, @@ -770,7 +770,7 @@ "loc": { "start": { "line": 26, - "column": 18 + "column": 40 }, "end": { "line": 29, @@ -804,7 +804,7 @@ }, "end": { "line": 31, - "column": 17 + "column": 39 } } }, @@ -1081,7 +1081,7 @@ "loc": { "start": { "line": 31, - "column": 18 + "column": 40 }, "end": { "line": 33, diff --git a/es2panda/test/parser/annotations/declaration-3d-array-enum-string.ts b/es2panda/test/parser/annotations/declaration-3d-array-enum-string.ts index 8eeef595d0e2bbd1b6afbe902a3920b97f0c564b..a24f1a805f6938f5b29fa3a66b6379ecdb596eb2 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-enum-string.ts +++ b/es2panda/test/parser/annotations/declaration-3d-array-enum-string.ts @@ -18,16 +18,16 @@ const enum E { B = "world!" } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying string type a: E[][][] = [[new Array(2)]]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying string type a: E[][][] = [[new Array(3)]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[][][] = [[["Hello", "world!", "Hello"]]]; } diff --git a/es2panda/test/parser/annotations/declaration-3d-array-number-expected.txt b/es2panda/test/parser/annotations/declaration-3d-array-number-expected.txt index 6731c66866aef0dcf8cabc5d330d5f8bfc5381ce..6ba651775b65a0184302e9369a8509a191a6197a 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-3d-array-number-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -190,7 +190,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -224,7 +224,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -486,7 +486,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, @@ -520,7 +520,7 @@ }, "end": { "line": 24, - "column": 17 + "column": 39 } } }, @@ -840,7 +840,7 @@ "loc": { "start": { "line": 24, - "column": 18 + "column": 40 }, "end": { "line": 26, diff --git a/es2panda/test/parser/annotations/declaration-3d-array-number.ts b/es2panda/test/parser/annotations/declaration-3d-array-number.ts index 9b4c19e954ca1490a45ff58a91e65a12135e454c..63d77e8e81e28e70cd3e816d7083138190467ea6 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-number.ts +++ b/es2panda/test/parser/annotations/declaration-3d-array-number.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number[][][]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: number[][][] = [[new Array()]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: number[][][] = [[[1, 2, 3], [4, 5, 6]]]; } diff --git a/es2panda/test/parser/annotations/declaration-3d-array-string-expected.txt b/es2panda/test/parser/annotations/declaration-3d-array-string-expected.txt index ab3dd1bc1da156b40340a5f16f8215899cb80ce3..f92907c304a6eb37acfbc8a7c4dc1353e42a2147 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-3d-array-string-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -190,7 +190,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -224,7 +224,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -486,7 +486,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, @@ -520,7 +520,7 @@ }, "end": { "line": 24, - "column": 17 + "column": 39 } } }, @@ -812,7 +812,7 @@ "loc": { "start": { "line": 24, - "column": 18 + "column": 40 }, "end": { "line": 26, diff --git a/es2panda/test/parser/annotations/declaration-3d-array-string.ts b/es2panda/test/parser/annotations/declaration-3d-array-string.ts index 9d2d477d78b5c09c70f7b74b42b74cc38f80640e..09a27904d4751c31a2b11852d7ccb84d003d5461 100644 --- a/es2panda/test/parser/annotations/declaration-3d-array-string.ts +++ b/es2panda/test/parser/annotations/declaration-3d-array-string.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: string[][][]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: string[][][] = [[new Array()]]; } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: string[][][] = [[["hello", "world"], ["hello", "world"]]]; } diff --git a/es2panda/test/parser/annotations/declaration-array-boolean-expected.txt b/es2panda/test/parser/annotations/declaration-array-boolean-expected.txt index 25bca148bd87373a4e9d5520d7d42a6f5b95137d..4d3196200f7b44bc2b28fa13c450dcac9f327fb0 100644 --- a/es2panda/test/parser/annotations/declaration-array-boolean-expected.txt +++ b/es2panda/test/parser/annotations/declaration-array-boolean-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -164,7 +164,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -198,7 +198,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -404,7 +404,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, @@ -438,7 +438,7 @@ }, "end": { "line": 24, - "column": 17 + "column": 39 } } }, @@ -645,7 +645,7 @@ "loc": { "start": { "line": 24, - "column": 18 + "column": 40 }, "end": { "line": 26, diff --git a/es2panda/test/parser/annotations/declaration-array-boolean.ts b/es2panda/test/parser/annotations/declaration-array-boolean.ts index b5e92f592d43e9018fc8ef55a4931d9e1f89c936..c575410d77ecb84c7c4056b56f99dd36be3cc499 100644 --- a/es2panda/test/parser/annotations/declaration-array-boolean.ts +++ b/es2panda/test/parser/annotations/declaration-array-boolean.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: boolean[]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: boolean[] = new Array(); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: boolean[] = [true, false, true]; } diff --git a/es2panda/test/parser/annotations/declaration-array-enum-number-expected.txt b/es2panda/test/parser/annotations/declaration-array-enum-number-expected.txt index 2c0dff61970473caaca69c2548c5c5883b0db7c5..c54ae5762ca19c9250f1caa67d98f03f8276b196 100644 --- a/es2panda/test/parser/annotations/declaration-array-enum-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-array-enum-number-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 17 + "column": 39 } } }, @@ -375,7 +375,7 @@ "loc": { "start": { "line": 21, - "column": 18 + "column": 40 }, "end": { "line": 24, @@ -409,7 +409,7 @@ }, "end": { "line": 26, - "column": 17 + "column": 39 } } }, @@ -658,7 +658,7 @@ "loc": { "start": { "line": 26, - "column": 18 + "column": 40 }, "end": { "line": 29, @@ -692,7 +692,7 @@ }, "end": { "line": 31, - "column": 17 + "column": 39 } } }, @@ -913,7 +913,7 @@ "loc": { "start": { "line": 31, - "column": 18 + "column": 40 }, "end": { "line": 33, diff --git a/es2panda/test/parser/annotations/declaration-array-enum-number.ts b/es2panda/test/parser/annotations/declaration-array-enum-number.ts index 11b05547110aa9349ccd85aab9adc3fb4b3428f0..fe4efedad57d14334d92389152c8be1405d4791c 100644 --- a/es2panda/test/parser/annotations/declaration-array-enum-number.ts +++ b/es2panda/test/parser/annotations/declaration-array-enum-number.ts @@ -18,16 +18,16 @@ const enum E { B = 314 } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying number type a: E[] = new Array(0); } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying number type a: E[] = new Array(1); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[] = [42, 314, 42]; } diff --git a/es2panda/test/parser/annotations/declaration-array-enum-string-expected.txt b/es2panda/test/parser/annotations/declaration-array-enum-string-expected.txt index ee84947486312f1c48dd90ff8ce7b6007bc619f4..e598eac92c747fde49129b7ffcf5d35a59dce700 100644 --- a/es2panda/test/parser/annotations/declaration-array-enum-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-array-enum-string-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 17 + "column": 39 } } }, @@ -375,7 +375,7 @@ "loc": { "start": { "line": 21, - "column": 18 + "column": 40 }, "end": { "line": 24, @@ -409,7 +409,7 @@ }, "end": { "line": 26, - "column": 17 + "column": 39 } } }, @@ -658,7 +658,7 @@ "loc": { "start": { "line": 26, - "column": 18 + "column": 40 }, "end": { "line": 29, @@ -692,7 +692,7 @@ }, "end": { "line": 31, - "column": 17 + "column": 39 } } }, @@ -913,7 +913,7 @@ "loc": { "start": { "line": 31, - "column": 18 + "column": 40 }, "end": { "line": 33, diff --git a/es2panda/test/parser/annotations/declaration-array-enum-string.ts b/es2panda/test/parser/annotations/declaration-array-enum-string.ts index a55745424cd2cbffdff0f6844cd0e61f46a21db3..39e7411e1a54dfec881d36f64e0a08203b809baa 100644 --- a/es2panda/test/parser/annotations/declaration-array-enum-string.ts +++ b/es2panda/test/parser/annotations/declaration-array-enum-string.ts @@ -18,16 +18,16 @@ const enum E { B = "world!" } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // without initializer in .ets source code with underlying string type a: E[] = new Array(2); } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { // with empty array initializer in .ets source code with underlying string type a: E[] = new Array(3); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: E[] = ["Hello", "world!", "Hello"]; } diff --git a/es2panda/test/parser/annotations/declaration-array-number-expected.txt b/es2panda/test/parser/annotations/declaration-array-number-expected.txt index b977d890471435e412d9ee714d8d7d9c027df9da..b157c668a35b22da030fb708c4535819feae6629 100644 --- a/es2panda/test/parser/annotations/declaration-array-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-array-number-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -164,7 +164,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -198,7 +198,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -404,7 +404,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, @@ -438,7 +438,7 @@ }, "end": { "line": 24, - "column": 17 + "column": 39 } } }, @@ -645,7 +645,7 @@ "loc": { "start": { "line": 24, - "column": 18 + "column": 40 }, "end": { "line": 26, diff --git a/es2panda/test/parser/annotations/declaration-array-number.ts b/es2panda/test/parser/annotations/declaration-array-number.ts index 20b83d18433cd15daea94a5042bceed5f01f1aca..e2a8a5567227bf4df2eec0010fd4f1f289df0b1b 100644 --- a/es2panda/test/parser/annotations/declaration-array-number.ts +++ b/es2panda/test/parser/annotations/declaration-array-number.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number[]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: number[] = new Array(); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: number[] = [1, 2, 3]; } diff --git a/es2panda/test/parser/annotations/declaration-array-string-expected.txt b/es2panda/test/parser/annotations/declaration-array-string-expected.txt index 280bb6e06cf931b868ad0e62d3633df7afd6a492..80e6ca76fcc5d3c739644c6365e4f2c32f17b71b 100644 --- a/es2panda/test/parser/annotations/declaration-array-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-array-string-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -164,7 +164,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -198,7 +198,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -404,7 +404,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, @@ -438,7 +438,7 @@ }, "end": { "line": 24, - "column": 17 + "column": 39 } } }, @@ -645,7 +645,7 @@ "loc": { "start": { "line": 24, - "column": 18 + "column": 40 }, "end": { "line": 26, diff --git a/es2panda/test/parser/annotations/declaration-array-string.ts b/es2panda/test/parser/annotations/declaration-array-string.ts index 69cfe97efcf42aa24d331347f690be6f4c018abc..2de6642e2463d14334115eb53fe796878f86bf69 100644 --- a/es2panda/test/parser/annotations/declaration-array-string.ts +++ b/es2panda/test/parser/annotations/declaration-array-string.ts @@ -13,14 +13,14 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: string[]; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: string[] = new Array(); } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { a: string[] = ["Hello", "world", "!"]; } diff --git a/es2panda/test/parser/annotations/declaration-boolean-expected.txt b/es2panda/test/parser/annotations/declaration-boolean-expected.txt index 3ad0c6449779f9e817e4c6cfaa61b6cec77691b9..55945c1f9b4cbb83d40a2f512f8cae5fb0359236 100644 --- a/es2panda/test/parser/annotations/declaration-boolean-expected.txt +++ b/es2panda/test/parser/annotations/declaration-boolean-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -151,7 +151,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -185,7 +185,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -336,7 +336,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-boolean.ts b/es2panda/test/parser/annotations/declaration-boolean.ts index e9bf814b7e14fef3b349fe5c28dd3aefae01d47b..086025dbd9a81925f1c84429f7f88a27a32e022e 100644 --- a/es2panda/test/parser/annotations/declaration-boolean.ts +++ b/es2panda/test/parser/annotations/declaration-boolean.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: boolean; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: boolean = true; } \ No newline at end of file diff --git a/es2panda/test/parser/annotations/declaration-combination-expected.txt b/es2panda/test/parser/annotations/declaration-combination-expected.txt index 43531af2d56bcf038b3e25fc76511057c409a67c..5fac4e23ca8ca8ee7b2c581b97dce5310756cde9 100644 --- a/es2panda/test/parser/annotations/declaration-combination-expected.txt +++ b/es2panda/test/parser/annotations/declaration-combination-expected.txt @@ -279,7 +279,7 @@ }, "end": { "line": 27, - "column": 16 + "column": 38 } } }, @@ -1416,7 +1416,7 @@ "loc": { "start": { "line": 27, - "column": 17 + "column": 39 }, "end": { "line": 38, diff --git a/es2panda/test/parser/annotations/declaration-combination.ts b/es2panda/test/parser/annotations/declaration-combination.ts index 79cb3c6032425101a731f9d8460a3d4ed52ad4e5..2c23ae9d6eb9413ee5b666d0ccc3c6b19788e1ae 100644 --- a/es2panda/test/parser/annotations/declaration-combination.ts +++ b/es2panda/test/parser/annotations/declaration-combination.ts @@ -24,7 +24,7 @@ const enum E1 { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number b: number[] = [13, 10] c: string diff --git a/es2panda/test/parser/annotations/declaration-empty-expected.txt b/es2panda/test/parser/annotations/declaration-empty-expected.txt index 2d482ef3bf7baa0634ec0fdccc8e92a09f22701e..eabbd5ebed59971549630b47a04767fd300cdbb3 100644 --- a/es2panda/test/parser/annotations/declaration-empty-expected.txt +++ b/es2panda/test/parser/annotations/declaration-empty-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -95,7 +95,7 @@ }, "end": { "line": 16, - "column": 19 + "column": 41 } } }, @@ -104,11 +104,11 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 16, - "column": 19 + "column": 41 } } }, @@ -121,7 +121,7 @@ }, "end": { "line": 16, - "column": 19 + "column": 41 } } } diff --git a/es2panda/test/parser/annotations/declaration-empty.ts b/es2panda/test/parser/annotations/declaration-empty.ts index 4d205f1d28c5947498aa920c5ee887ea825a4a16..80ae4e05b8580a0eeb03456386a7854204744303 100644 --- a/es2panda/test/parser/annotations/declaration-empty.ts +++ b/es2panda/test/parser/annotations/declaration-empty.ts @@ -13,4 +13,4 @@ * limitations under the License. */ -@interface Anno {} +@interface __$$ETS_ANNOTATION$$__Anno {} diff --git a/es2panda/test/parser/annotations/declaration-enum-number-expected.txt b/es2panda/test/parser/annotations/declaration-enum-number-expected.txt index 5b5801e6bb461b4c2ab384b471b08bd07244d6b3..2861338efa556be75bb7acb3caf4f7405f7080df 100644 --- a/es2panda/test/parser/annotations/declaration-enum-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-enum-number-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 17 + "column": 39 } } }, @@ -346,7 +346,7 @@ "loc": { "start": { "line": 21, - "column": 18 + "column": 40 }, "end": { "line": 24, @@ -380,7 +380,7 @@ }, "end": { "line": 26, - "column": 17 + "column": 39 } } }, @@ -545,7 +545,7 @@ "loc": { "start": { "line": 26, - "column": 18 + "column": 40 }, "end": { "line": 28, diff --git a/es2panda/test/parser/annotations/declaration-enum-number.ts b/es2panda/test/parser/annotations/declaration-enum-number.ts index 095d97c985d0ca75c019935f770412d0b8878c07..74f82890046248d5b22dae7f8015a8a4ba17b26f 100644 --- a/es2panda/test/parser/annotations/declaration-enum-number.ts +++ b/es2panda/test/parser/annotations/declaration-enum-number.ts @@ -18,11 +18,11 @@ const enum E { B = 314 } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // No initializer with underlying type number a: E = new Number(0) as number; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: E = 42; } \ No newline at end of file diff --git a/es2panda/test/parser/annotations/declaration-enum-string-expected.txt b/es2panda/test/parser/annotations/declaration-enum-string-expected.txt index 090667cd366df32f40a521e0e200c8903bbef1dd..b259e706c72419dadb88d2ca1b5e3ecb850d87aa 100644 --- a/es2panda/test/parser/annotations/declaration-enum-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-enum-string-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 17 + "column": 39 } } }, @@ -277,7 +277,7 @@ "loc": { "start": { "line": 21, - "column": 18 + "column": 40 }, "end": { "line": 24, @@ -311,7 +311,7 @@ }, "end": { "line": 26, - "column": 17 + "column": 39 } } }, @@ -476,7 +476,7 @@ "loc": { "start": { "line": 26, - "column": 18 + "column": 40 }, "end": { "line": 28, diff --git a/es2panda/test/parser/annotations/declaration-enum-string.ts b/es2panda/test/parser/annotations/declaration-enum-string.ts index 668b13ba51d72057b1111438bd928c13bedd489f..e8f77e41a217e4caa3a3db46de289c62347a6b45 100644 --- a/es2panda/test/parser/annotations/declaration-enum-string.ts +++ b/es2panda/test/parser/annotations/declaration-enum-string.ts @@ -18,11 +18,11 @@ const enum E { B = "world!" } -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { // No initializer with underlying type string a: E; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: E = "Hello"; } \ No newline at end of file diff --git a/es2panda/test/parser/annotations/declaration-number-expected.txt b/es2panda/test/parser/annotations/declaration-number-expected.txt index d692da40994e60c33a2b000a841d517bb78f9d95..04bc5cdf91f5fe3fff19898f9e106a9f5d77e311 100644 --- a/es2panda/test/parser/annotations/declaration-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-number-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -151,7 +151,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -185,7 +185,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -336,7 +336,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-number.ts b/es2panda/test/parser/annotations/declaration-number.ts index e5c48f9af641f0f0451ad667183c8164203d6cee..340bf0775121cf0aa3f3e170616d7863fce60745 100644 --- a/es2panda/test/parser/annotations/declaration-number.ts +++ b/es2panda/test/parser/annotations/declaration-number.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: number = 42; } \ No newline at end of file diff --git a/es2panda/test/parser/annotations/declaration-string-expected.txt b/es2panda/test/parser/annotations/declaration-string-expected.txt index 45fdfa8882ac05aca4fb7f6b24c7f01151e4463d..e1d5699252b77da084321058fc483eaafa0f7d18 100644 --- a/es2panda/test/parser/annotations/declaration-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-string-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -151,7 +151,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -185,7 +185,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -336,7 +336,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-string.ts b/es2panda/test/parser/annotations/declaration-string.ts index 2f67dfdc93f9626c754bb871e1a3ea6eda569e78..52e99594617389227a8f3c2e932abc592571d4c2 100644 --- a/es2panda/test/parser/annotations/declaration-string.ts +++ b/es2panda/test/parser/annotations/declaration-string.ts @@ -13,10 +13,10 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: string; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { a: string = "Hello world!"; } \ No newline at end of file diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean-expected.txt b/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean-expected.txt index a4e4f5d1e82d74a12bf142aad26a926ea6095b4d..22b62cab12a136255338cc4739779e359b8553ad 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -190,7 +190,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -304,7 +304,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -563,7 +563,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean.ts b/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean.ts index b228a7be88bbcdc9acf8ad31da5fa7d30d5aea2e..e707f942b5deddf83713a8c326d93162c8f4d590 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean.ts +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-boolean.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: boolean[][][]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number-expected.txt b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number-expected.txt index 2dbeae8061aec5a19f9275fa3397455ebdf8b4dc..2d65b1e6836573fc9368d4c758ca07e138a78bf1 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 16 + "column": 38 } } }, @@ -431,7 +431,7 @@ "loc": { "start": { "line": 21, - "column": 17 + "column": 39 }, "end": { "line": 23, @@ -545,7 +545,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 25, @@ -804,7 +804,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 27, diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number.ts b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number.ts index 112d363eaad046ee58e2504d9f4f2a482b9a3a59..7a8eb2c54925cde23ecd823ed3aef199248372ed 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number.ts +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-number.ts @@ -18,7 +18,7 @@ const enum E { B = 2 } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[][][] = [[new Array(0)]]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string-expected.txt b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string-expected.txt index 8911a2388b26c5728c2a942d27fe3cee8be67c49..6835399a7b9af20e533edc1d5066aec1673417f6 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 16 + "column": 38 } } }, @@ -431,7 +431,7 @@ "loc": { "start": { "line": 21, - "column": 17 + "column": 39 }, "end": { "line": 23, @@ -545,7 +545,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 25, @@ -804,7 +804,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 27, diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string.ts b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string.ts index 3ea8b4242bbbf19418701fbf8dce909f75358500..175a0dcb7a93270affd66c1335480c174a2be5f4 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string.ts +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-enum-string.ts @@ -18,7 +18,7 @@ const enum E { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[][][] = [[new Array(2)]]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-number-expected.txt b/es2panda/test/parser/annotations/declaration-usage-3d-array-number-expected.txt index c53855fdb4153b7457af023d6e0fba035ac87804..c3b2c24a2a206b5d077404a2c2752dec09e0d24c 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-number-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -190,7 +190,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -304,7 +304,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -563,7 +563,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-number.ts b/es2panda/test/parser/annotations/declaration-usage-3d-array-number.ts index 9b32dad4ff7d4870557417742cc733ffaaebb54a..94b2ec54c9e68f424a113447b34d0fac6dfdb6ab 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-number.ts +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-number.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number[][][]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-string-expected.txt b/es2panda/test/parser/annotations/declaration-usage-3d-array-string-expected.txt index a2d10906343c4a3bdd7e54d181b3c7581ebb9984..7c408210768edef8518d3ab714ee90d3397e3aeb 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-string-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -190,7 +190,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -304,7 +304,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -563,7 +563,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-3d-array-string.ts b/es2panda/test/parser/annotations/declaration-usage-3d-array-string.ts index 8bdbb7118e9996f7c99637dd147a82d0e24eb1b6..37e8437d72aa2c3145dca40ffa6691294fcb79e2 100644 --- a/es2panda/test/parser/annotations/declaration-usage-3d-array-string.ts +++ b/es2panda/test/parser/annotations/declaration-usage-3d-array-string.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: string[][][]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-array-boolean-expected.txt b/es2panda/test/parser/annotations/declaration-usage-array-boolean-expected.txt index 7588f64ce7d4636cf24107aa44f1a8cd3fc21df2..0fe8d00444ed91cb40c8bf34aab6f05e8efb409e 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-boolean-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-array-boolean-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -164,7 +164,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -278,7 +278,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -507,7 +507,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-array-boolean.ts b/es2panda/test/parser/annotations/declaration-usage-array-boolean.ts index 06ae0c99571fdd0308b644460b368e65d069b7d4..cd8fece8279a7d132e7a6398b85631455d073d2c 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-boolean.ts +++ b/es2panda/test/parser/annotations/declaration-usage-array-boolean.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: boolean[]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-array-enum-number-expected.txt b/es2panda/test/parser/annotations/declaration-usage-array-enum-number-expected.txt index ac78e9174353a9e1f3747a29e46829417c6f080e..1cf2806754de87b69f771bbcfdcfcfa2a89d4aa9 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-enum-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-array-enum-number-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 16 + "column": 38 } } }, @@ -375,7 +375,7 @@ "loc": { "start": { "line": 21, - "column": 17 + "column": 39 }, "end": { "line": 23, @@ -489,7 +489,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 25, @@ -718,7 +718,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 27, diff --git a/es2panda/test/parser/annotations/declaration-usage-array-enum-number.ts b/es2panda/test/parser/annotations/declaration-usage-array-enum-number.ts index 801fefe3f00ce1065410d499d662429b5fa778cb..0524e6a24061e029b58c17628eab418defb047e1 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-enum-number.ts +++ b/es2panda/test/parser/annotations/declaration-usage-array-enum-number.ts @@ -18,7 +18,7 @@ const enum E { B = 2, } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[] = new Array(0); } diff --git a/es2panda/test/parser/annotations/declaration-usage-array-enum-string-expected.txt b/es2panda/test/parser/annotations/declaration-usage-array-enum-string-expected.txt index b2cc2f5d774d922f1df503732bbbdb4c0dfc9ddc..99c0d05521c5b8f91eb5887ad6cca9ccb24b5189 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-enum-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-array-enum-string-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 16 + "column": 38 } } }, @@ -375,7 +375,7 @@ "loc": { "start": { "line": 21, - "column": 17 + "column": 39 }, "end": { "line": 23, @@ -489,7 +489,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 25, @@ -718,7 +718,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 27, diff --git a/es2panda/test/parser/annotations/declaration-usage-array-enum-string.ts b/es2panda/test/parser/annotations/declaration-usage-array-enum-string.ts index aa3bd9c9fbd145aba6be513f37384ffc078ad36b..52742a3241cc03aafcb0daf8228f2a14bdee1464 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-enum-string.ts +++ b/es2panda/test/parser/annotations/declaration-usage-array-enum-string.ts @@ -18,7 +18,7 @@ const enum E { B = "world", } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E[] = new Array(2); } diff --git a/es2panda/test/parser/annotations/declaration-usage-array-number-expected.txt b/es2panda/test/parser/annotations/declaration-usage-array-number-expected.txt index ffb333697923a4b728f228084459c322c49860c7..1dacb954aa0d193e77ef3eee43ca9ca8f44d8b64 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-array-number-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -164,7 +164,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -278,7 +278,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -507,7 +507,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-array-number.ts b/es2panda/test/parser/annotations/declaration-usage-array-number.ts index 47fc593175b4fa8ff2a64fb04fce8b61adb0fd25..995e9a06345d6a291a308254cec1cf665b13ae11 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-number.ts +++ b/es2panda/test/parser/annotations/declaration-usage-array-number.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number[]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-array-string-expected.txt b/es2panda/test/parser/annotations/declaration-usage-array-string-expected.txt index 78da22a43a7798b5eba6f64c1e246cb2f130bd58..f9baa7b888e95148f6c55ede30d5548e8da0bdfa 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-array-string-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -164,7 +164,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -278,7 +278,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -507,7 +507,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-array-string.ts b/es2panda/test/parser/annotations/declaration-usage-array-string.ts index c14f9d9d8fd68fa1d0756c8f21d84b10da738391..c00fe674fcc5ac3a3cebb385e3c3a25224990fbe 100644 --- a/es2panda/test/parser/annotations/declaration-usage-array-string.ts +++ b/es2panda/test/parser/annotations/declaration-usage-array-string.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: string[]; } diff --git a/es2panda/test/parser/annotations/declaration-usage-boolean-expected.txt b/es2panda/test/parser/annotations/declaration-usage-boolean-expected.txt index b77604f15c3717ae11c95de27463a0a5ed32e4d7..3b769f56fa20cc908626e016fe700e394126d028 100644 --- a/es2panda/test/parser/annotations/declaration-usage-boolean-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-boolean-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -151,7 +151,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -265,7 +265,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -451,7 +451,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-boolean.ts b/es2panda/test/parser/annotations/declaration-usage-boolean.ts index b47a2078487b87c4f8b679c8b12633597c77307a..3e7da49918ef6cf00cac1e7740bc1fb3464bc09a 100644 --- a/es2panda/test/parser/annotations/declaration-usage-boolean.ts +++ b/es2panda/test/parser/annotations/declaration-usage-boolean.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: boolean; } diff --git a/es2panda/test/parser/annotations/declaration-usage-combination-expected.txt b/es2panda/test/parser/annotations/declaration-usage-combination-expected.txt index 22dba78913f600f7fc0cf9a3374c4c167ddc5655..c0ec68a50c611f3551716f35d888876ce82064c4 100644 --- a/es2panda/test/parser/annotations/declaration-usage-combination-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-combination-expected.txt @@ -279,7 +279,7 @@ }, "end": { "line": 27, - "column": 16 + "column": 38 } } }, @@ -1416,7 +1416,7 @@ "loc": { "start": { "line": 27, - "column": 17 + "column": 39 }, "end": { "line": 38, @@ -1530,7 +1530,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 40, @@ -2527,7 +2527,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 42, diff --git a/es2panda/test/parser/annotations/declaration-usage-combination.ts b/es2panda/test/parser/annotations/declaration-usage-combination.ts index 16b861ff38393433f3b5df2683e26b8c8b600c2f..ffac927a7597ccc0c53cde7819c78a833797e666 100644 --- a/es2panda/test/parser/annotations/declaration-usage-combination.ts +++ b/es2panda/test/parser/annotations/declaration-usage-combination.ts @@ -24,7 +24,7 @@ const enum E1 { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number b: number[] = [13, 10] c: string diff --git a/es2panda/test/parser/annotations/declaration-usage-empty-expected.txt b/es2panda/test/parser/annotations/declaration-usage-empty-expected.txt index 4ab2bc897cff30e1458f345db3d9293a17b0bea6..06af843949b5c81d22b6ba07607f5999ddec2c26 100644 --- a/es2panda/test/parser/annotations/declaration-usage-empty-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-empty-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -95,7 +95,7 @@ }, "end": { "line": 16, - "column": 19 + "column": 41 } } }, @@ -104,11 +104,11 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 16, - "column": 19 + "column": 41 } } }, @@ -121,7 +121,7 @@ }, "end": { "line": 16, - "column": 19 + "column": 41 } } }, @@ -216,7 +216,7 @@ "type": "Annotation", "expression": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 18, @@ -328,7 +328,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -452,7 +452,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 23, diff --git a/es2panda/test/parser/annotations/declaration-usage-empty.ts b/es2panda/test/parser/annotations/declaration-usage-empty.ts index badbc9745a1434a8e45996e86aee590e4705958f..b781add198329819f7d9e2290005b6ac08b2e6f2 100644 --- a/es2panda/test/parser/annotations/declaration-usage-empty.ts +++ b/es2panda/test/parser/annotations/declaration-usage-empty.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno {} +@interface __$$ETS_ANNOTATION$$__Anno {} @__$$ETS_ANNOTATION$$__Anno class A { diff --git a/es2panda/test/parser/annotations/declaration-usage-enum-number-expected.txt b/es2panda/test/parser/annotations/declaration-usage-enum-number-expected.txt index 0f2c03ff8ebfb3c93eac4b7f3b291b128297be07..08708ed1c48f95f6e18337769ca142ef79b87730 100644 --- a/es2panda/test/parser/annotations/declaration-usage-enum-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-enum-number-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 16 + "column": 38 } } }, @@ -346,7 +346,7 @@ "loc": { "start": { "line": 21, - "column": 17 + "column": 39 }, "end": { "line": 23, @@ -460,7 +460,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 25, @@ -646,7 +646,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 27, diff --git a/es2panda/test/parser/annotations/declaration-usage-enum-number.ts b/es2panda/test/parser/annotations/declaration-usage-enum-number.ts index 693f1476e14f946bcfb570fdfd52acee7dcb4678..c296d79b90aa1e53f48c5017279bc3a835d56a7f 100644 --- a/es2panda/test/parser/annotations/declaration-usage-enum-number.ts +++ b/es2panda/test/parser/annotations/declaration-usage-enum-number.ts @@ -18,7 +18,7 @@ const enum E { B = 2 } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E = new Number(0) as number; } diff --git a/es2panda/test/parser/annotations/declaration-usage-enum-string-expected.txt b/es2panda/test/parser/annotations/declaration-usage-enum-string-expected.txt index 56ae1cc18a71bfd94c9c18ee16eef70783e08e54..1a8d1d292a7dc96eaa622d319834f6ef94d394a6 100644 --- a/es2panda/test/parser/annotations/declaration-usage-enum-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-enum-string-expected.txt @@ -126,7 +126,7 @@ }, "end": { "line": 21, - "column": 16 + "column": 38 } } }, @@ -277,7 +277,7 @@ "loc": { "start": { "line": 21, - "column": 17 + "column": 39 }, "end": { "line": 23, @@ -391,7 +391,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 25, @@ -577,7 +577,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 27, diff --git a/es2panda/test/parser/annotations/declaration-usage-enum-string.ts b/es2panda/test/parser/annotations/declaration-usage-enum-string.ts index d9c8f8e0477c4cf4d408da1c680efe924ab3e872..320500abe99431974fd5f281561301106df16035 100644 --- a/es2panda/test/parser/annotations/declaration-usage-enum-string.ts +++ b/es2panda/test/parser/annotations/declaration-usage-enum-string.ts @@ -18,7 +18,7 @@ const enum E { B = "world" } -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: E; } diff --git a/es2panda/test/parser/annotations/declaration-usage-number-expected.txt b/es2panda/test/parser/annotations/declaration-usage-number-expected.txt index 96d98fe81f94be154e8c20dbf3a477c614cd3ee6..e43e54db0e5ece96e115e1f39faf0f1da4c1d77b 100644 --- a/es2panda/test/parser/annotations/declaration-usage-number-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-number-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -151,7 +151,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -265,7 +265,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -451,7 +451,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-number.ts b/es2panda/test/parser/annotations/declaration-usage-number.ts index 50b8417b90ae216b9d84b38d781c557cc6ed4631..8fc55a987b0bee2f512ce35370d78c922d2473f8 100644 --- a/es2panda/test/parser/annotations/declaration-usage-number.ts +++ b/es2panda/test/parser/annotations/declaration-usage-number.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: number; } diff --git a/es2panda/test/parser/annotations/declaration-usage-string-expected.txt b/es2panda/test/parser/annotations/declaration-usage-string-expected.txt index b8bec61953d09780cbb5b262a14437bd759ab717..613d0f63c96a41ebce407f627551a2398b8c2c93 100644 --- a/es2panda/test/parser/annotations/declaration-usage-string-expected.txt +++ b/es2panda/test/parser/annotations/declaration-usage-string-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 16 + "column": 38 } } }, @@ -151,7 +151,7 @@ "loc": { "start": { "line": 16, - "column": 17 + "column": 39 }, "end": { "line": 18, @@ -265,7 +265,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 20, @@ -451,7 +451,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno", + "name": "Anno", "loc": { "start": { "line": 22, diff --git a/es2panda/test/parser/annotations/declaration-usage-string.ts b/es2panda/test/parser/annotations/declaration-usage-string.ts index 0c627768fd650a5e4bac6cac31df0b4baaf5d8b6..5ad01ef4ed9394074ca233092f0bf41cc67628ab 100644 --- a/es2panda/test/parser/annotations/declaration-usage-string.ts +++ b/es2panda/test/parser/annotations/declaration-usage-string.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -@interface Anno { +@interface __$$ETS_ANNOTATION$$__Anno { a: string; } diff --git a/es2panda/test/parser/annotations/export-expected.txt b/es2panda/test/parser/annotations/export-expected.txt index 4ae0d3f25dcada0cfeed10792de8c8514bed0a64..ddccdb842b6c87f0b5c286dce968b610d22b49a4 100644 --- a/es2panda/test/parser/annotations/export-expected.txt +++ b/es2panda/test/parser/annotations/export-expected.txt @@ -16,7 +16,7 @@ }, "end": { "line": 16, - "column": 24 + "column": 46 } } }, @@ -97,7 +97,7 @@ }, "end": { "line": 16, - "column": 27 + "column": 49 } } }, @@ -106,11 +106,11 @@ "loc": { "start": { "line": 16, - "column": 25 + "column": 47 }, "end": { "line": 16, - "column": 27 + "column": 49 } } }, @@ -123,7 +123,7 @@ }, "end": { "line": 16, - "column": 27 + "column": 49 } } }, @@ -136,7 +136,7 @@ }, "end": { "line": 16, - "column": 27 + "column": 49 } } }, @@ -155,7 +155,7 @@ }, "end": { "line": 18, - "column": 24 + "column": 46 } } }, @@ -306,7 +306,7 @@ "loc": { "start": { "line": 18, - "column": 25 + "column": 47 }, "end": { "line": 20, @@ -435,7 +435,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno1", + "name": "Anno1", "loc": { "start": { "line": 22, @@ -619,7 +619,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno1", + "name": "Anno1", "loc": { "start": { "line": 25, diff --git a/es2panda/test/parser/annotations/export.ts b/es2panda/test/parser/annotations/export.ts index 8c10cc06288a7c1197e1b1c601491358d987f698..6bea13acdc05d843f551afdf62e7a7d27cc561fd 100644 --- a/es2panda/test/parser/annotations/export.ts +++ b/es2panda/test/parser/annotations/export.ts @@ -13,9 +13,9 @@ * limitations under the License. */ -export @interface Anno1 {} +export @interface __$$ETS_ANNOTATION$$__Anno1 {} -export @interface Anno2 { +export @interface __$$ETS_ANNOTATION$$__Anno2 { a: number = 0; } diff --git a/es2panda/test/parser/annotations/import-qualified-expected.txt b/es2panda/test/parser/annotations/import-qualified-expected.txt index 5f41d5ec6c794cd017804ed80bc6792cc55defa2..4706b8ceea2d07224e35c72f56928d9a05ceb025 100644 --- a/es2panda/test/parser/annotations/import-qualified-expected.txt +++ b/es2panda/test/parser/annotations/import-qualified-expected.txt @@ -152,7 +152,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Namespace1", + "name": "Namespace1", "loc": { "start": { "line": 18, @@ -160,7 +160,7 @@ }, "end": { "line": 18, - "column": 34 + "column": 12 } } }, @@ -170,7 +170,7 @@ "loc": { "start": { "line": 18, - "column": 35 + "column": 13 }, "end": { "line": 18, @@ -348,7 +348,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Namespace1", + "name": "Namespace1", "loc": { "start": { "line": 21, @@ -356,7 +356,7 @@ }, "end": { "line": 21, - "column": 34 + "column": 12 } } }, @@ -366,7 +366,7 @@ "loc": { "start": { "line": 21, - "column": 35 + "column": 13 }, "end": { "line": 21, @@ -533,7 +533,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Namespace1", + "name": "Namespace1", "loc": { "start": { "line": 24, @@ -541,7 +541,7 @@ }, "end": { "line": 24, - "column": 34 + "column": 12 } } }, @@ -551,7 +551,7 @@ "loc": { "start": { "line": 24, - "column": 35 + "column": 13 }, "end": { "line": 24, @@ -841,7 +841,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Namespace1", + "name": "Namespace1", "loc": { "start": { "line": 27, @@ -849,7 +849,7 @@ }, "end": { "line": 27, - "column": 34 + "column": 12 } } }, @@ -859,11 +859,11 @@ "loc": { "start": { "line": 27, - "column": 35 + "column": 13 }, "end": { "line": 27, - "column": 45 + "column": 23 } } }, @@ -876,7 +876,7 @@ }, "end": { "line": 27, - "column": 45 + "column": 23 } } }, @@ -886,11 +886,11 @@ "loc": { "start": { "line": 27, - "column": 46 + "column": 24 }, "end": { "line": 27, - "column": 56 + "column": 34 } } }, @@ -903,7 +903,7 @@ }, "end": { "line": 27, - "column": 56 + "column": 34 } } }, @@ -913,7 +913,7 @@ "loc": { "start": { "line": 27, - "column": 57 + "column": 35 }, "end": { "line": 27, @@ -1095,7 +1095,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Namespace1", + "name": "Namespace1", "loc": { "start": { "line": 30, @@ -1103,7 +1103,7 @@ }, "end": { "line": 30, - "column": 34 + "column": 12 } } }, @@ -1113,11 +1113,11 @@ "loc": { "start": { "line": 30, - "column": 35 + "column": 13 }, "end": { "line": 30, - "column": 45 + "column": 23 } } }, @@ -1130,7 +1130,7 @@ }, "end": { "line": 30, - "column": 45 + "column": 23 } } }, @@ -1140,11 +1140,11 @@ "loc": { "start": { "line": 30, - "column": 46 + "column": 24 }, "end": { "line": 30, - "column": 56 + "column": 34 } } }, @@ -1157,7 +1157,7 @@ }, "end": { "line": 30, - "column": 56 + "column": 34 } } }, @@ -1167,7 +1167,7 @@ "loc": { "start": { "line": 30, - "column": 57 + "column": 35 }, "end": { "line": 30, @@ -1338,7 +1338,7 @@ "type": "MemberExpression", "object": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Namespace1", + "name": "Namespace1", "loc": { "start": { "line": 33, @@ -1346,7 +1346,7 @@ }, "end": { "line": 33, - "column": 34 + "column": 12 } } }, @@ -1356,11 +1356,11 @@ "loc": { "start": { "line": 33, - "column": 35 + "column": 13 }, "end": { "line": 33, - "column": 45 + "column": 23 } } }, @@ -1373,7 +1373,7 @@ }, "end": { "line": 33, - "column": 45 + "column": 23 } } }, @@ -1383,11 +1383,11 @@ "loc": { "start": { "line": 33, - "column": 46 + "column": 24 }, "end": { "line": 33, - "column": 56 + "column": 34 } } }, @@ -1400,7 +1400,7 @@ }, "end": { "line": 33, - "column": 56 + "column": 34 } } }, @@ -1410,7 +1410,7 @@ "loc": { "start": { "line": 33, - "column": 57 + "column": 35 }, "end": { "line": 33, diff --git a/es2panda/test/parser/annotations/import-qualified.ts b/es2panda/test/parser/annotations/import-qualified.ts index 61a16cadc23bdf4093d5231431b3f39fe03730b5..742f0f07ae26c1d3623f306f2097e0fa626ef272 100644 --- a/es2panda/test/parser/annotations/import-qualified.ts +++ b/es2panda/test/parser/annotations/import-qualified.ts @@ -15,20 +15,20 @@ import * as Namespace1 from "./a" -@__$$ETS_ANNOTATION$$__Namespace1.Anno() +@Namespace1.__$$ETS_ANNOTATION$$__Anno() class A {} -@__$$ETS_ANNOTATION$$__Namespace1.Anno +@Namespace1.__$$ETS_ANNOTATION$$__Anno class B {} -@__$$ETS_ANNOTATION$$__Namespace1.Anno1({a: 1, b: "string"}) +@Namespace1.__$$ETS_ANNOTATION$$__Anno1({a: 1, b: "string"}) class C {} -@__$$ETS_ANNOTATION$$__Namespace1.Namespace2.Namespace3.Anno2() +@Namespace1.Namespace2.Namespace3.__$$ETS_ANNOTATION$$__Anno2() class D {} -@__$$ETS_ANNOTATION$$__Namespace1.Namespace2.Namespace3.Anno2 +@Namespace1.Namespace2.Namespace3.__$$ETS_ANNOTATION$$__Anno2 class E {} -@__$$ETS_ANNOTATION$$__Namespace1.Namespace2.Namespace3.Anno3({a: 1, b: "string"}) +@Namespace1.Namespace2.Namespace3.__$$ETS_ANNOTATION$$__Anno3({a: 1, b: "string"}) class F {} \ No newline at end of file diff --git a/es2panda/test/parser/annotations/import-unqualified-expected.txt b/es2panda/test/parser/annotations/import-unqualified-expected.txt index c4468f2f494453208f12eee7054f1022c0fb4b12..cf5699a10342fd0b4634b761277ab5dfc3e71c60 100644 --- a/es2panda/test/parser/annotations/import-unqualified-expected.txt +++ b/es2panda/test/parser/annotations/import-unqualified-expected.txt @@ -205,7 +205,7 @@ "type": "Annotation", "expression": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno1", + "name": "Anno1", "loc": { "start": { "line": 18, @@ -361,7 +361,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno1", + "name": "Anno1", "loc": { "start": { "line": 21, @@ -530,7 +530,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno1", + "name": "Anno1", "loc": { "start": { "line": 24, @@ -714,7 +714,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno2", + "name": "Anno2", "loc": { "start": { "line": 27, diff --git a/es2panda/test/parser/annotations/multiple-annotations-expected.txt b/es2panda/test/parser/annotations/multiple-annotations-expected.txt index 2111cf0e0b4d168abfc132426ef9d37bb30f8176..135d60a478b86545dfa4aa64354bedc0c1a64599 100644 --- a/es2panda/test/parser/annotations/multiple-annotations-expected.txt +++ b/es2panda/test/parser/annotations/multiple-annotations-expected.txt @@ -14,7 +14,7 @@ }, "end": { "line": 16, - "column": 17 + "column": 39 } } }, @@ -165,7 +165,7 @@ "loc": { "start": { "line": 16, - "column": 18 + "column": 40 }, "end": { "line": 18, @@ -199,7 +199,7 @@ }, "end": { "line": 20, - "column": 17 + "column": 39 } } }, @@ -350,7 +350,7 @@ "loc": { "start": { "line": 20, - "column": 18 + "column": 40 }, "end": { "line": 22, @@ -384,7 +384,7 @@ }, "end": { "line": 24, - "column": 17 + "column": 39 } } }, @@ -577,7 +577,7 @@ "loc": { "start": { "line": 24, - "column": 18 + "column": 40 }, "end": { "line": 26, @@ -691,7 +691,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno1", + "name": "Anno1", "loc": { "start": { "line": 28, @@ -796,7 +796,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno2", + "name": "Anno2", "loc": { "start": { "line": 29, @@ -901,7 +901,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno3", + "name": "Anno3", "loc": { "start": { "line": 30, @@ -1116,7 +1116,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno1", + "name": "Anno1", "loc": { "start": { "line": 32, @@ -1221,7 +1221,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno2", + "name": "Anno2", "loc": { "start": { "line": 33, @@ -1326,7 +1326,7 @@ "type": "CallExpression", "callee": { "type": "Identifier", - "name": "__$$ETS_ANNOTATION$$__Anno3", + "name": "Anno3", "loc": { "start": { "line": 34, diff --git a/es2panda/test/parser/annotations/multiple-annotations.ts b/es2panda/test/parser/annotations/multiple-annotations.ts index cf0af17c46b720c83ce8e40a6a328b68010b19f7..246af473b26a6a8d76defe52e36865f928a33bc7 100644 --- a/es2panda/test/parser/annotations/multiple-annotations.ts +++ b/es2panda/test/parser/annotations/multiple-annotations.ts @@ -13,15 +13,15 @@ * limitations under the License. */ -@interface Anno1 { +@interface __$$ETS_ANNOTATION$$__Anno1 { a: number = 1; } -@interface Anno2 { +@interface __$$ETS_ANNOTATION$$__Anno2 { b: string = "string" } -@interface Anno3 { +@interface __$$ETS_ANNOTATION$$__Anno3 { c: boolean[] = [true, false]; } diff --git a/es2panda/test/parser/js/language/import/lazy-import-expected.txt b/es2panda/test/parser/js/language/import/lazy-import-expected.txt index 4954838d6cc001d0aa8dde53ce5f6871eb745642..d8b751d51e8d777383cd772579e8700ea5059229 100644 --- a/es2panda/test/parser/js/language/import/lazy-import-expected.txt +++ b/es2panda/test/parser/js/language/import/lazy-import-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x6 -expectedProperty = 0x3 .language ECMAScript .function any .#~A=#A(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/parser/js/language/import/syntax/api12/beta2/import-lazy-beta2-2-expected.txt b/es2panda/test/parser/js/language/import/syntax/api12/beta2/import-lazy-beta2-2-expected.txt index a5a0f51d284f302b4377ff68cac0556af37b7922..592aff13d028666c9cbf346dcff965e03217645d 100644 --- a/es2panda/test/parser/js/language/import/syntax/api12/beta2/import-lazy-beta2-2-expected.txt +++ b/es2panda/test/parser/js/language/import/syntax/api12/beta2/import-lazy-beta2-2-expected.txt @@ -1,2 +1,2 @@ -SyntaxError: Current configuration does not support using lazy import default.Lazy import can be used in the version of API 18 or higher versions. -Solutions: > Check the compatibleSdkVersion in build-profile.json5.> If compatibleSdkVersion is set to API 18.> If you're running es2abc in commandline without IDE, please check whether target-api-version options are correctly configured. [import-lazy-beta2-2.js:16:13] +SyntaxError: Current configuration does not support using lazy import. Lazy import can be used in the beta3 version of API 12 or higher versions. +Solutions: > Check the compatibleSdkVersion and compatibleSdkVersionStage in build-profile.json5.> If compatibleSdkVersion is set to API 12, then compatibleSdkVersionStage needs to be configured as beta3.> If you're running es2abc in commandline without IDE, please check whether target-api-version and target-api-sub-version options are correctly configured. [import-lazy-beta2-2.js:16:13] diff --git a/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-2-expected.txt b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-2-expected.txt index aeccb2f589e10fd2675de4604f824907e5fb8b80..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-2-expected.txt +++ b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-2-expected.txt @@ -1,2 +0,0 @@ -SyntaxError: Current configuration does not support using lazy import default.Lazy import can be used in the version of API 18 or higher versions. -Solutions: > Check the compatibleSdkVersion in build-profile.json5.> If compatibleSdkVersion is set to API 18.> If you're running es2abc in commandline without IDE, please check whether target-api-version options are correctly configured. [import-lazy-2.js:16:13] diff --git a/es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_supported_runtime_version-expected.txt b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-1-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_supported_runtime_version-expected.txt rename to es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-1-expected.txt diff --git a/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-1.js b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-1.js new file mode 100644 index 0000000000000000000000000000000000000000..1be01909715173e3ac0e62f32098f04778e4eb92 --- /dev/null +++ b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-1.js @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import lazy a from './a' \ No newline at end of file diff --git a/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-2-expected.txt b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-2-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..d9309c18906f21418839b077c5dba619fb60d059 --- /dev/null +++ b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-2-expected.txt @@ -0,0 +1 @@ +SyntaxError: Unexpected token. [import-lazy-defalut-2.js:16:13] diff --git a/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-2.js b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-2.js new file mode 100644 index 0000000000000000000000000000000000000000..9311c81e83a1cb29495c319b4db09175470452e6 --- /dev/null +++ b/es2panda/test/parser/js/language/import/syntax/api12/beta3/import-lazy-defalut-2.js @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import lazy type {a} from './a' \ No newline at end of file diff --git a/es2panda/test/parser/ts/test-func-param10-expected.txt b/es2panda/test/parser/ts/test-func-param10-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..2f0ae83bd703e6bbcaf119efaefcc567093b9794 --- /dev/null +++ b/es2panda/test/parser/ts/test-func-param10-expected.txt @@ -0,0 +1,712 @@ +{ + "type": "Program", + "statements": [ + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 6 + } + } + }, + "init": { + "type": "StringLiteral", + "value": "111", + "loc": { + "start": { + "line": 17, + "column": 9 + }, + "end": { + "line": 17, + "column": 14 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 14 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 17, + "column": 15 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "b", + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 6 + } + } + }, + "init": { + "type": "StringLiteral", + "value": "222", + "loc": { + "start": { + "line": 18, + "column": 9 + }, + "end": { + "line": 18, + "column": 14 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 14 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 18, + "column": 15 + } + } + }, + { + "type": "VariableDeclaration", + "declarations": [ + { + "type": "VariableDeclarator", + "id": { + "type": "Identifier", + "name": "c", + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 6 + } + } + }, + "init": { + "type": "BooleanLiteral", + "value": true, + "loc": { + "start": { + "line": 19, + "column": 9 + }, + "end": { + "line": 19, + "column": 13 + } + } + }, + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 13 + } + } + } + ], + "kind": "let", + "loc": { + "start": { + "line": 19, + "column": 1 + }, + "end": { + "line": 19, + "column": 14 + } + } + }, + { + "type": "FunctionDeclaration", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "test1", + "loc": { + "start": { + "line": 20, + "column": 10 + }, + "end": { + "line": 20, + "column": 15 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "print", + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 10 + } + } + }, + "arguments": [ + { + "type": "StringLiteral", + "value": "333", + "loc": { + "start": { + "line": 21, + "column": 11 + }, + "end": { + "line": 21, + "column": 16 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 17 + } + } + }, + "loc": { + "start": { + "line": 21, + "column": 5 + }, + "end": { + "line": 21, + "column": 17 + } + } + } + ], + "loc": { + "start": { + "line": 20, + "column": 18 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 22, + "column": 2 + } + } + }, + { + "type": "FunctionDeclaration", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "test2", + "loc": { + "start": { + "line": 23, + "column": 10 + }, + "end": { + "line": 23, + "column": 15 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "AssignmentPattern", + "left": { + "type": "Identifier", + "name": "aa", + "typeAnnotation": { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 23, + "column": 21 + }, + "end": { + "line": 23, + "column": 27 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 23, + "column": 18 + } + } + }, + "right": { + "type": "ConditionalExpression", + "test": { + "type": "Identifier", + "name": "c", + "loc": { + "start": { + "line": 23, + "column": 30 + }, + "end": { + "line": 23, + "column": 31 + } + } + }, + "consequent": { + "type": "SequenceExpression", + "expressions": [ + { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "test1", + "loc": { + "start": { + "line": 23, + "column": 35 + }, + "end": { + "line": 23, + "column": 40 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 23, + "column": 35 + }, + "end": { + "line": 23, + "column": 42 + } + } + }, + { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 23, + "column": 43 + }, + "end": { + "line": 23, + "column": 44 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 34 + }, + "end": { + "line": 23, + "column": 45 + } + } + }, + "alternate": { + "type": "SequenceExpression", + "expressions": [ + { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "test1", + "loc": { + "start": { + "line": 23, + "column": 49 + }, + "end": { + "line": 23, + "column": 54 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 23, + "column": 49 + }, + "end": { + "line": 23, + "column": 56 + } + } + }, + { + "type": "Identifier", + "name": "b", + "loc": { + "start": { + "line": 23, + "column": 57 + }, + "end": { + "line": 23, + "column": 58 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 48 + }, + "end": { + "line": 23, + "column": 59 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 30 + }, + "end": { + "line": 23, + "column": 59 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 16 + }, + "end": { + "line": 23, + "column": 59 + } + } + }, + { + "type": "AssignmentPattern", + "left": { + "type": "Identifier", + "name": "dd", + "typeAnnotation": { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 23, + "column": 64 + }, + "end": { + "line": 23, + "column": 70 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 61 + }, + "end": { + "line": 23, + "column": 63 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 23, + "column": 73 + }, + "end": { + "line": 23, + "column": 74 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 61 + }, + "end": { + "line": 23, + "column": 74 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "print", + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 10 + } + } + }, + "arguments": [ + { + "type": "Identifier", + "name": "aa", + "loc": { + "start": { + "line": 24, + "column": 11 + }, + "end": { + "line": 24, + "column": 13 + } + } + }, + { + "type": "Identifier", + "name": "dd", + "loc": { + "start": { + "line": 24, + "column": 15 + }, + "end": { + "line": 24, + "column": 17 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 18 + } + } + }, + "loc": { + "start": { + "line": 24, + "column": 5 + }, + "end": { + "line": 24, + "column": 19 + } + } + } + ], + "loc": { + "start": { + "line": 23, + "column": 76 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 1 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 23, + "column": 1 + }, + "end": { + "line": 25, + "column": 2 + } + } + }, + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "test2", + "loc": { + "start": { + "line": 27, + "column": 1 + }, + "end": { + "line": 27, + "column": 6 + } + } + }, + "arguments": [], + "optional": false, + "loc": { + "start": { + "line": 27, + "column": 1 + }, + "end": { + "line": 27, + "column": 8 + } + } + }, + "loc": { + "start": { + "line": 27, + "column": 1 + }, + "end": { + "line": 27, + "column": 8 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 28, + "column": 1 + } + } +} diff --git a/es2panda/test/parser/ts/test-func-param10.ts b/es2panda/test/parser/ts/test-func-param10.ts new file mode 100644 index 0000000000000000000000000000000000000000..717ae2477f4c7617015a2459b60ef6c117980a29 --- /dev/null +++ b/es2panda/test/parser/ts/test-func-param10.ts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +let a = "111"; +let b = "222"; +let c = true; +function test1() { + print("333") +} +function test2(aa : string = c ? (test1(),a) : (test1(),b), dd:number = 1) { + print(aa, dd); +} + +test2() diff --git a/es2panda/test/parser/ts/test-func-param11-expected.txt b/es2panda/test/parser/ts/test-func-param11-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..610308b8d9c8eb343a7d0be82a445b6439de739f --- /dev/null +++ b/es2panda/test/parser/ts/test-func-param11-expected.txt @@ -0,0 +1,360 @@ +{ + "type": "Program", + "statements": [ + { + "type": "FunctionDeclaration", + "function": { + "type": "ScriptFunction", + "id": { + "type": "Identifier", + "name": "bar", + "loc": { + "start": { + "line": 17, + "column": 10 + }, + "end": { + "line": 17, + "column": 13 + } + } + }, + "generator": false, + "async": false, + "expression": false, + "params": [ + { + "type": "AssignmentPattern", + "left": { + "type": "Identifier", + "name": "fn", + "loc": { + "start": { + "line": 17, + "column": 14 + }, + "end": { + "line": 17, + "column": 16 + } + } + }, + "right": { + "type": "ArrowFunctionExpression", + "function": { + "type": "ScriptFunction", + "id": null, + "generator": false, + "async": false, + "expression": true, + "params": [ + { + "type": "Identifier", + "name": "b", + "typeAnnotation": { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 17, + "column": 23 + }, + "end": { + "line": 17, + "column": 29 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 19 + }, + "end": { + "line": 17, + "column": 30 + } + } + } + ], + "body": { + "type": "BinaryExpression", + "operator": "+", + "left": { + "type": "Identifier", + "name": "b", + "loc": { + "start": { + "line": 17, + "column": 34 + }, + "end": { + "line": 17, + "column": 35 + } + } + }, + "right": { + "type": "NumberLiteral", + "value": 1, + "loc": { + "start": { + "line": 17, + "column": 38 + }, + "end": { + "line": 17, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 34 + }, + "end": { + "line": 17, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 19 + }, + "end": { + "line": 17, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 19 + }, + "end": { + "line": 17, + "column": 39 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 14 + }, + "end": { + "line": 17, + "column": 39 + } + } + }, + { + "type": "Identifier", + "name": "a", + "typeAnnotation": { + "type": "TSStringKeyword", + "loc": { + "start": { + "line": 17, + "column": 44 + }, + "end": { + "line": 17, + "column": 50 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 41 + }, + "end": { + "line": 17, + "column": 42 + } + } + } + ], + "body": { + "type": "BlockStatement", + "statements": [ + { + "type": "ExpressionStatement", + "expression": { + "type": "CallExpression", + "callee": { + "type": "MemberExpression", + "object": { + "type": "Identifier", + "name": "console", + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 12 + } + } + }, + "property": { + "type": "Identifier", + "name": "log", + "loc": { + "start": { + "line": 18, + "column": 13 + }, + "end": { + "line": 18, + "column": 16 + } + } + }, + "computed": false, + "optional": false, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 16 + } + } + }, + "arguments": [ + { + "type": "CallExpression", + "callee": { + "type": "Identifier", + "name": "fn", + "loc": { + "start": { + "line": 18, + "column": 17 + }, + "end": { + "line": 18, + "column": 19 + } + } + }, + "arguments": [ + { + "type": "NumberLiteral", + "value": 5, + "loc": { + "start": { + "line": 18, + "column": 20 + }, + "end": { + "line": 18, + "column": 21 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 18, + "column": 17 + }, + "end": { + "line": 18, + "column": 22 + } + } + }, + { + "type": "Identifier", + "name": "a", + "loc": { + "start": { + "line": 18, + "column": 24 + }, + "end": { + "line": 18, + "column": 25 + } + } + } + ], + "optional": false, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 26 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 27 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 52 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 19, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 20, + "column": 1 + } + } +} diff --git a/es2panda/test/parser/ts/test-func-param11.ts b/es2panda/test/parser/ts/test-func-param11.ts new file mode 100644 index 0000000000000000000000000000000000000000..4e36915b21b10ec5973b188cd6103ddc1c01776b --- /dev/null +++ b/es2panda/test/parser/ts/test-func-param11.ts @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +function bar(fn = (b: number) => b + 1, a: string) { + console.log(fn(5), a); +} diff --git a/es2panda/test/parser/ts/test-readonly-optional-property-expected.txt b/es2panda/test/parser/ts/test-readonly-optional-property-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..970e539cfff96898fc2bc0796450c18f039c6b88 --- /dev/null +++ b/es2panda/test/parser/ts/test-readonly-optional-property-expected.txt @@ -0,0 +1,101 @@ +{ + "type": "Program", + "statements": [ + { + "type": "TSInterfaceDeclaration", + "body": { + "type": "TSInterfaceBody", + "body": [ + { + "type": "TSPropertySignature", + "computed": false, + "optional": true, + "readonly": false, + "key": { + "type": "Identifier", + "name": "readonly", + "loc": { + "start": { + "line": 18, + "column": 2 + }, + "end": { + "line": 18, + "column": 10 + } + } + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "loc": { + "start": { + "line": 18, + "column": 13 + }, + "end": { + "line": 18, + "column": 19 + } + } + }, + "loc": { + "start": { + "line": 18, + "column": 2 + }, + "end": { + "line": 18, + "column": 20 + } + } + } + ], + "loc": { + "start": { + "line": 17, + "column": 16 + }, + "end": { + "line": 19, + "column": 2 + } + } + }, + "id": { + "type": "Identifier", + "name": "test", + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 17, + "column": 15 + } + } + }, + "extends": [], + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 19, + "column": 2 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 19, + "column": 2 + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/esobject_with_string_key.ets b/es2panda/test/parser/ts/test-readonly-optional-property.ts similarity index 89% rename from ets2panda/test/ast/compiler/ets/esobject_with_string_key.ets rename to es2panda/test/parser/ts/test-readonly-optional-property.ts index b2468c1afbf2b44a7ebdef824f8d09a92759bc7c..2f9df72f3a191ca5a7042f06a6057be18afcec25 100644 --- a/ets2panda/test/ast/compiler/ets/esobject_with_string_key.ets +++ b/es2panda/test/parser/ts/test-readonly-optional-property.ts @@ -13,6 +13,7 @@ * limitations under the License. */ -function foo (es: JSValue, str: string): string { - return es[str]; + +interface test { + readonly?: number; } \ No newline at end of file diff --git a/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-1-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-1-transformed-expected.txt index 5b64b2d04215f2c8526ec7f4203e13c5461bbff0..58587ab7649cee422721d48330ede07ad7aa24ba 100644 --- a/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-1-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-1-transformed-expected.txt @@ -63,12 +63,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 14 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 20 } } }, @@ -77,12 +77,12 @@ "name": "###A#auto_accessor_storage#1", "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 14 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 20 } } }, @@ -90,12 +90,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 14 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 20 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-2-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-2-transformed-expected.txt index dc2bdf78115563ca156789f0d64e58c7fee074f2..027f8933cd3e1a0a4975e073ea5d5c7a6f326bc3 100644 --- a/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-2-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases/test-class-auto-accessor-2-transformed-expected.txt @@ -164,12 +164,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 19, + "column": 15 }, "end": { - "line": 1, - "column": 1 + "line": 19, + "column": 27 } } }, @@ -178,12 +178,12 @@ "name": "###Test#auto_accessor_storage#1", "loc": { "start": { - "line": 1, - "column": 1 + "line": 19, + "column": 15 }, "end": { - "line": 1, - "column": 1 + "line": 19, + "column": 27 } } }, @@ -191,12 +191,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 19, + "column": 15 }, "end": { - "line": 1, - "column": 1 + "line": 19, + "column": 27 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases/test-class-constructor1-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases/test-class-constructor1-transformed-expected.txt index 822c6e99a9d91dd8b889bb7eec6b867df5455e1a..46330a78dbf8bae09a48b513da8c3d9809696663 100644 --- a/es2panda/test/parser/ts/transformed_cases/test-class-constructor1-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases/test-class-constructor1-transformed-expected.txt @@ -76,12 +76,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 10 } } }, @@ -90,12 +90,12 @@ "name": "prop1", "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 10 } } }, @@ -103,12 +103,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 10 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases/test-class-constructor2-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases/test-class-constructor2-transformed-expected.txt index 40bb140f3b04ebc6fa0da5af9b1fabc1b5b22e18..b22c158c2321839ba2f7e4d9e4f632f936467935 100644 --- a/es2panda/test/parser/ts/transformed_cases/test-class-constructor2-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases/test-class-constructor2-transformed-expected.txt @@ -103,12 +103,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 9 } } }, @@ -117,12 +117,12 @@ "name": "prop", "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 9 } } }, @@ -130,12 +130,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 18, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 18, + "column": 9 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases/test-class-constructor3-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases/test-class-constructor3-transformed-expected.txt index 7936bfad6d5464516dfeb051a95a18c8c357bc98..57e42ec3ecf1c3acf02fa64cd6498ec09886122e 100644 --- a/es2panda/test/parser/ts/transformed_cases/test-class-constructor3-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases/test-class-constructor3-transformed-expected.txt @@ -268,12 +268,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 9 } } }, @@ -282,12 +282,12 @@ "name": "prop", "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 9 } } }, @@ -295,12 +295,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 9 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases/test-class-constructor4-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases/test-class-constructor4-transformed-expected.txt index 1548646ed413e2fb18d0340788a9f54437f053eb..3e56df7b4fc87decfd290201e0acaa9212495399 100644 --- a/es2panda/test/parser/ts/transformed_cases/test-class-constructor4-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases/test-class-constructor4-transformed-expected.txt @@ -424,12 +424,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 10 } } }, @@ -438,12 +438,12 @@ "name": "prop1", "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 10 } } }, @@ -451,12 +451,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 10 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases/test-class-decorator-1-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases/test-class-decorator-1-transformed-expected.txt index edaef8740c93924aa349706fc2aa271d7de93057..3c0ec91edb6cb0555d1e5b15326e10166eb530ee 100644 --- a/es2panda/test/parser/ts/transformed_cases/test-class-decorator-1-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases/test-class-decorator-1-transformed-expected.txt @@ -890,12 +890,12 @@ "name": "a", "loc": { "start": { - "line": 1, - "column": 1 + "line": 23, + "column": 12 }, "end": { - "line": 1, - "column": 1 + "line": 23, + "column": 13 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-class-constructor1-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-class-constructor1-transformed-expected.txt index 1dad3f2b1e6aa872b39fafea6b97529ab9f48aeb..8a02b47f7b312fd0565b3c89bd30d2c825e38bcf 100644 --- a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-class-constructor1-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-class-constructor1-transformed-expected.txt @@ -424,12 +424,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 10 } } }, @@ -438,12 +438,12 @@ "name": "prop1", "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 10 } } }, @@ -451,12 +451,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 10 } } }, @@ -507,12 +507,12 @@ "type": "ThisExpression", "loc": { "start": { - "line": 1, - "column": 1 + "line": 21, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 21, + "column": 11 } } }, @@ -521,12 +521,12 @@ "name": "###B#prop2#1", "loc": { "start": { - "line": 1, - "column": 1 + "line": 21, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 21, + "column": 11 } } }, @@ -534,12 +534,12 @@ "optional": false, "loc": { "start": { - "line": 1, - "column": 1 + "line": 21, + "column": 5 }, "end": { - "line": 1, - "column": 1 + "line": 21, + "column": 11 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-decorator-1-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-decorator-1-transformed-expected.txt index 4632b52a56404a3d35b63dbbc64130e36e3a1109..f826e0a0dc18e04cf20bb920d1750aaac09da22a 100644 --- a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-decorator-1-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-decorator-1-transformed-expected.txt @@ -948,12 +948,12 @@ "name": "a", "loc": { "start": { - "line": 1, - "column": 1 + "line": 23, + "column": 12 }, "end": { - "line": 1, - "column": 1 + "line": 23, + "column": 13 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-switchCase-statement-1-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-switchCase-statement-1-transformed-expected.txt index e4097e957069196bc9a42731f659f012f900637c..b4d0eec5fba219ed4a9edab52d64ed4764ee0434 100644 --- a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-switchCase-statement-1-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-switchCase-statement-1-transformed-expected.txt @@ -303,12 +303,12 @@ "name": "p", "loc": { "start": { - "line": 1, - "column": 1 + "line": 20, + "column": 26 }, "end": { - "line": 1, - "column": 1 + "line": 20, + "column": 27 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-1-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-1-transformed-expected.txt index 226a8ad0d5f7f246e35cf45f518187618834fadc..173727186b5a3159e87a9afb7ce821d5943b9841 100644 --- a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-1-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-1-transformed-expected.txt @@ -199,12 +199,12 @@ "name": "a", "loc": { "start": { - "line": 1, - "column": 1 + "line": 17, + "column": 30 }, "end": { - "line": 1, - "column": 1 + "line": 17, + "column": 31 } } }, diff --git a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-2-transformed-expected.txt b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-2-transformed-expected.txt index b56614dff42a1bbe4a27afebb3004460da3f147d..8294b94320c35144bdd46fe78af6f2f72edb4bb5 100644 --- a/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-2-transformed-expected.txt +++ b/es2panda/test/parser/ts/transformed_cases_api_version_10/test-ts-export-classes-2-transformed-expected.txt @@ -214,12 +214,12 @@ "name": "a", "loc": { "start": { - "line": 1, - "column": 1 + "line": 17, + "column": 24 }, "end": { - "line": 1, - "column": 1 + "line": 17, + "column": 25 } } }, diff --git a/es2panda/test/runner.py b/es2panda/test/runner.py index f378d108c383ef54f2a3cf610c6d82b24009c76a..9b625b98c185d5cb8247db3621fa5efa990c18bf 100755 --- a/es2panda/test/runner.py +++ b/es2panda/test/runner.py @@ -25,7 +25,7 @@ import re import shutil import subprocess import sys -from config import API_VERSION_MAP, MIN_SUPPORT_BC_VERSION, MIX_COMPILE_ENTRY_POINT +from config import API_VERSION_MAP, ARK_JS_VM_LIST, MIN_SUPPORT_BC_VERSION, MIX_COMPILE_ENTRY_POINT, ES2ABC_API_SUPPORT def is_directory(parser, arg): @@ -974,7 +974,6 @@ class CompilerProjectTest(Test): mod_files_info.append(abc_line) final_file_info_f.writelines(abc_line) - def gen_files_info(self, runner): # After collect_record_mapping, self.file_record_mapping stores {'source file name' : 'source file record name'} self.collect_record_mapping() @@ -1412,7 +1411,9 @@ class BcVersionTest(Test): 15: "12.0.6.0", 16: "12.0.6.0", 17: "12.0.6.0", - 18: "13.0.1.0" + 18: "13.0.1.0", + 19: "13.0.1.0", + 20: "13.0.1.0", } self.es2abc_script_expect = { 8: "0.0.0.2", @@ -1428,7 +1429,9 @@ class BcVersionTest(Test): 15: "12.0.6.0", 16: "12.0.6.0", 17: "12.0.6.0", - 18: "13.0.1.0" + 18: "13.0.1.0", + 19: "13.0.1.0", + 20: "13.0.1.0", } def run(self): @@ -1884,6 +1887,40 @@ class ArkJsVmDownload: # Obtain different versions of ark_js_vm and their depen self.git_clone(self.url, self.local_path) print("\ndownload finish.\n") +class CodeDownloader: + def __init__(self, args, url, components_name, max_retries=3): + self.build_dir = args.build_dir + self.url = url + self.local_path = path.join(self.build_dir, components_name) + self.max_retries = max_retries + + def run_cmd_cwd(self, cmd): + try: + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + _, _ = proc.communicate() + return proc.wait() + except Exception as e: + print(f"Error executing command: {e}") + return -1 + + def git_clone(self, git_url, code_dir): + cmd = ["git", "clone", git_url, code_dir, "--depth=1"] + retries = 1 + while retries <= self.max_retries: + ret = self.run_cmd_cwd(cmd) + if ret == 0: + break + else: + print(f"\nWarning: Attempt #{retries} to clone '{git_url}' failed. Retrying...") + retries += 1 + assert ret == 0, f"\nError: Cloning '{git_url}' failed." + + def run(self): + if not os.path.exists(self.local_path): + print(f"\nStart downloading {self.url}...\n") + self.git_clone(self.url, self.local_path) + print("\nDownload finished.\n") + print(self.local_path) class AbcTestCasesPrepare: def __init__(self, args): @@ -1907,34 +1944,42 @@ class AbcTestCasesPrepare: files = fnmatch.filter(files, self.test_root + "**" + self.args.filter) return files - def gen_abc_versions(self, flags, source_path): - for api_version in API_VERSION_MAP: + def get_output_path(self, source_path, main_version, beta_version, es2abc_version): + base = path.splitext(source_path)[0] + suffix = f"version_API{main_version}{beta_version}" + return f"{base}_{es2abc_version}_{suffix}.abc" if es2abc_version != "default" else f"{base}_{suffix}.abc" + + def gen_abc_versions(self, flags, source_path, es2abc_version): + supported_apis = ES2ABC_API_SUPPORT.get(es2abc_version) + for api_version in supported_apis: main_version, beta_version = AbcTestCasesPrepare.split_api_version(api_version) - output_path = "%s_version_API%s%s.abc" % ( - path.splitext(source_path)[0], - main_version, - beta_version, - ) + output_path = self.get_output_path(source_path, main_version, beta_version, es2abc_version) self.test_abc_path_list.add(output_path) - _, stderr = self.compile_for_target_version(flags, source_path, output_path, main_version, beta_version) + _, stderr = self.compile_for_target_version(flags, source_path, output_path, main_version, beta_version, es2abc_version) if stderr: - raise RuntimeError(f"abc generate error: " % (stderr.decode("utf-8", errors="ignore"))) + raise RuntimeError(f"abc generate error: {stderr}") - def gen_abc_tests(self, directory, extension, flags, abc_mode): + def gen_abc_tests(self, directory, extension, flags, abc_mode, es2abc_versions=["default"]): if abc_mode not in self.valid_mode_list: raise ValueError(f"Invalid abc_mode value: {abc_mode}") test_source_list = self.add_abc_directory(directory, extension) - for input_path in test_source_list: - self.gen_abc_versions(flags, input_path) - def compile_for_target_version(self, flags, input_path, output_path, target_api_version, target_api_sub_version=""): + for es2abc_version in es2abc_versions: + for input_path in test_source_list: + self.gen_abc_versions(flags, input_path, es2abc_version) + + def compile_for_target_version(self, flags, input_path, output_path, target_api_version, target_api_sub_version="", es2abc_version="default"): + es2panda_path = ( + self.es2panda if es2abc_version == "default" + else os.path.join(self.args.build_dir, "es2abc_version", es2abc_version, "es2abc") + ) cmd = [] - cmd.append(self.es2panda) + cmd.append(es2panda_path) cmd.append(input_path) cmd.extend(flags) cmd.append("--target-api-version=%s" % (target_api_version)) cmd.extend(["--output=%s" % (output_path)]) - if target_api_version != "": + if target_api_sub_version != "": cmd.append("--target-api-sub-version=%s" % (target_api_sub_version)) process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate(timeout=10) @@ -1969,7 +2014,6 @@ class AbcVersionControlRunner(Runner): def run(self): for test in self.tests: test.run(self) - self.args.abc_tests_prepare.remove_abc_tests() class VersionControlRunner(Runner): @@ -2046,6 +2090,7 @@ class TestAbcVersionControl(Test): if self.abc_mode == "mix_compile_mode" and test_stage != "runtime": support_name = "" expected_name = path.splitext(self.path)[0].split("_version_API")[0] + expected_name = re.sub(r"_(\d+\.\d+)(?=(_|$))", "", expected_name) expected_path = "%s_%s%s-expected.txt" % (expected_name, support_name, test_stage) return expected_path @@ -2068,51 +2113,74 @@ class TestAbcVersionControl(Test): cmd.extend(self.flags) cmd.append("--target-api-version=%s" % (target_api_version)) cmd.extend(["--output=%s" % (output_path)]) - if target_api_version != "": + if target_api_sub_version != "": cmd.append("--target-api-sub-version=%s" % (target_api_sub_version)) + self.log_cmd(cmd) stdout, stderr = self.run_process(cmd) return stdout, stderr - def generate_abc(self, runner, target_api_version, target_api_sub_version=""): - compile_expected_path = None - target_abc_name = ( - "%s_target_%s%s.abc" % (path.splitext(self.path)[0], target_api_version, target_api_sub_version) - ).replace("/", "_") - self.target_abc_path = path.join(runner.build_dir, target_abc_name) - _, stderr = self.compile_for_target_version( - runner, self.path, self.target_abc_path, target_api_version, target_api_sub_version - ) - format_content = "" - self.is_support = False + def build_abc_filename(self, target_api_version, target_api_sub_version): + prefix = f"{path.splitext(self.path)[0]}" + abc_name = f"{prefix}_target_{target_api_version}{target_api_sub_version}.abc" + return abc_name.replace("/", "_") - # Extract the API versions of the input abc files from the file name of the test case. + def extract_input_versions(self): input_api_versions = self.extract_api_versions(path.split(self.path)[1]) input_version_numbers = [API_VERSION_MAP.get(api) for api in input_api_versions] - sorted(input_version_numbers, key=TestAbcVersionControl.version_number_to_tuple) - min_input_version_number = input_version_numbers[0] - max_input_version_number = input_version_numbers[-1] + return sorted(input_version_numbers, key=TestAbcVersionControl.version_number_to_tuple) + + def determine_expected_behavior(self, target_api_version, target_api_sub_version, input_version_numbers): target_version = "API" + target_api_version + target_api_sub_version target_version_number = API_VERSION_MAP.get(target_version) + min_input_version_number = input_version_numbers[0] + max_input_version_number = input_version_numbers[-1] + if TestAbcVersionControl.compare_version_number(target_version_number, self.min_support_version_number) < 0: compile_expected_path = self.get_path_to_expected( - self.is_support, "compile_target_version_below_min_support" + False, "compile_target_version_below_min_support" ) - format_content = target_api_version + return False, compile_expected_path, target_api_version + elif ( TestAbcVersionControl.compare_version_number(min_input_version_number, self.min_support_version_number) < 0 ): - compile_expected_path = self.get_path_to_expected(self.is_support, "compile_cur_version_below_min_support") - format_content = self.path + compile_expected_path = self.get_path_to_expected(False, "compile_cur_version_below_min_support") + return False, compile_expected_path, self.path + elif TestAbcVersionControl.compare_version_number(target_version_number, max_input_version_number) < 0: - compile_expected_path = self.get_path_to_expected(self.is_support, "compile_target_version_below_cur") - format_content = self.path + compile_expected_path = self.get_path_to_expected(False, "compile_target_version_below_cur") + return False, compile_expected_path, self.path + elif self.is_discard: - compile_expected_path = self.get_path_to_expected(self.is_support, "compile_discard") - else: - self.is_support = True + compile_expected_path = self.get_path_to_expected(False, "compile_discard") + return False, compile_expected_path, "" + + return True, None, None + + def generate_abc(self, runner, target_api_version, target_api_sub_version=""): + compile_expected_path = None + target_abc_name = self.build_abc_filename(target_api_version, target_api_sub_version) + self.target_abc_path = path.join(runner.build_dir, target_abc_name) + + _, stderr = self.compile_for_target_version( + runner, self.path, self.target_abc_path, target_api_version, target_api_sub_version + ) + format_content = "" + self.is_support = False + + # Extract the API versions of the input abc files from the file name of the test case. + input_version_numbers = self.extract_input_versions() + + is_support, compile_expected_path, format_content = self.determine_expected_behavior( + target_api_version, target_api_sub_version, input_version_numbers + ) + self.is_support = is_support + if self.is_support: if stderr: self.passed = False + else: + self.passed = True return stderr try: @@ -2123,18 +2191,12 @@ class TestAbcVersionControl(Test): self.passed = False return stderr - def execute_abc(self, runner, vm_api_version, vm_api_sub_version="", entry_point=""): + def execute_abc(self, runner, vm_version, entry_point=""): cmd = [] - if vm_api_version != "12": - vm_api_sub_version = "" - # there is no virtual machine with version api12beta2 available. - # chosen api12beta1 as a replacement. - elif vm_api_version == "12" and vm_api_sub_version == "beta2": - vm_api_sub_version = "beta1" ark_js_vm_dir = os.path.join( runner.build_dir, "ark_js_vm_version", - "API%s%s" % (vm_api_version, vm_api_sub_version), + vm_version, ) ld_library_path = os.path.join(ark_js_vm_dir, "lib") os.environ["LD_LIBRARY_PATH"] = ld_library_path @@ -2143,6 +2205,7 @@ class TestAbcVersionControl(Test): if entry_point != "": cmd.append("--entry-point=%s" % entry_point) cmd.append(self.target_abc_path) + self.log_cmd(cmd) stdout, stderr = self.run_process(cmd) return stdout, stderr @@ -2150,11 +2213,9 @@ class TestAbcVersionControl(Test): stderr = None target_version = "API" + target_api_version + target_api_sub_version target_version_number = API_VERSION_MAP.get(target_version) - for api_version in API_VERSION_MAP: - vm_api_version, vm_api_sub_version = AbcTestCasesPrepare.split_api_version(api_version) - vm_version = "API" + vm_api_version + vm_api_sub_version + for vm_version in ARK_JS_VM_LIST: vm_version_number = API_VERSION_MAP.get(vm_version) - _, stderr = self.execute_abc(runner, vm_api_version, vm_api_sub_version, self.entry_point) + _, stderr = self.execute_abc(runner, vm_version, self.entry_point) self.is_support = ( TestAbcVersionControl.compare_version_number(vm_version_number, target_version_number) >= 0 ) @@ -2188,26 +2249,141 @@ class TestAbcVersionControl(Test): target_api_version, target_api_sub_version = AbcTestCasesPrepare.split_api_version(api_version) stderr = self.generate_abc(runner, target_api_version, target_api_sub_version) if not self.passed: - self.error = stderr.decode("utf-8", errors="ignore") + self.error = stderr return self if stderr: continue stderr = self.test_abc_execution(runner, target_api_version, target_api_sub_version) self.remove_abc(self.target_abc_path) if not self.passed: - self.error = stderr.decode("utf-8", errors="ignore") + self.error = stderr return self return self +class Es2abcVersionControlRunner(Runner): + def __init__(self, args): + super().__init__(args, "Es2abcVersionControl") + self.valid_mode_list = ["non_merge_mode", "merge_mode"] + + def add_directory(self, directory, extension, flags, abc_mode, is_discard=False): + if abc_mode not in self.valid_mode_list: + raise ValueError(f"Invalid abc_mode value: {abc_mode}") + glob_expression = path.join(self.test_root, directory, "*.%s" % (extension)) + files = glob(glob_expression) + files = fnmatch.filter(files, self.test_root + "**" + self.args.filter) + self.tests += list(map(lambda f: TestEs2abcVersionControl(f, flags, abc_mode, is_discard), files)) + + def test_path(self, src): + return src + + def run(self): + for test in self.tests: + test.run(self) + self.args.abc_tests_prepare.remove_abc_tests() + +class TestEs2abcVersionControl(TestAbcVersionControl): + def __init__(self, test_path, flags, abc_mode, is_discard, es2abc_versions=None): + super().__init__(test_path, flags, abc_mode, is_discard) + self.es2abc_versions = es2abc_versions or list(ES2ABC_API_SUPPORT.keys()) + + @staticmethod + def version_str_to_tuple(version: str): + if isinstance(version, list): + version = ".".join(version) + return tuple(int(x) for x in version.split(".")) + + @classmethod + def get_max_supported_version(cls, es2abc_version: str) -> str: + supported_apis = ES2ABC_API_SUPPORT.get(es2abc_version, ES2ABC_API_SUPPORT["default"]) + max_api = max(supported_apis, key=lambda api: cls.version_str_to_tuple(API_VERSION_MAP[api])) + return API_VERSION_MAP[max_api] + + @classmethod + def should_skip_abc_file(cls, file_version: str, es2abc_version: str) -> bool: + max_supported_version = cls.get_max_supported_version(es2abc_version) + return cls.version_str_to_tuple(file_version) > cls.version_str_to_tuple(max_supported_version) + + def build_abc_filename(self, target_api_version, target_api_sub_version, es2abc_version): + prefix = f"{path.splitext(self.path)[0]}" + if es2abc_version == "default" or es2abc_version is None: + abc_name = f"{prefix}_target_{target_api_version}{target_api_sub_version}.abc" + else: + abc_name = f"{prefix}_{es2abc_version}_target_{target_api_version}{target_api_sub_version}.abc" + return abc_name.replace("/", "_") + + def compile_for_target_version( + self, runner, input_path, output_path, target_api_version, target_api_sub_version="", es2abc_version="default" + ): + cmd = [] + if es2abc_version != "default": + runner.es2panda = os.path.join(runner.build_dir, "es2abc_version", es2abc_version, "es2abc") + cmd.append(runner.es2panda) + cmd.append(input_path) + cmd.extend(self.flags) + cmd.append("--target-api-version=%s" % target_api_version) + cmd.extend(["--output=%s" % output_path]) + if target_api_sub_version: + cmd.append("--target-api-sub-version=%s" % target_api_sub_version) + self.es2abc_cmd = ' '.join(cmd) + stdout, stderr = self.run_process(cmd) + return stdout, stderr + + def generate_abc(self, runner, target_api_version, target_api_sub_version=""): + compile_expected_path = None + input_version_numbers = self.extract_input_versions() + + for es2abc_version in self.es2abc_versions: + target_abc_name = self.build_abc_filename(target_api_version, target_api_sub_version, es2abc_version) + self.target_abc_path = path.join(runner.build_dir, target_abc_name) + + _, stderr = self.compile_for_target_version( + runner, self.path, self.target_abc_path, target_api_version, target_api_sub_version, es2abc_version + ) + + format_content = "" + self.is_support = False + + # The version of the abc file exceeds the maximum supported range of es2abc + if self.should_skip_abc_file(input_version_numbers, es2abc_version): + continue + + is_support, compile_expected_path, format_content = self.determine_expected_behavior( + target_api_version, target_api_sub_version, input_version_numbers + ) + self.is_support = is_support + if self.is_support: + if stderr: + self.passed = False + else: + self.passed = True + return stderr + + try: + with open(compile_expected_path, "r") as fp: + expected = fp.read() + self.passed = expected.format(format_content) in self.output and self.process.returncode in [0, 1] + except Exception: + self.passed = False + return stderr + return None + + def run(self, runner): + for api_version in API_VERSION_MAP: + target_api_version, target_api_sub_version = AbcTestCasesPrepare.split_api_version(api_version) + stderr = self.generate_abc(runner, target_api_version, target_api_sub_version) + if not self.passed: + self.error = stderr + return self + return self class TestVersionControl(Test): def __init__(self, test_path, flags, test_version, feature_type, module_path_list): Test.__init__(self, test_path, flags) self.beta_version_default = 3 - self.version_with_sub_version_list = [12] - self.target_api_version_list = ["9", "10", "11", "12", "18"] + self.version_with_sub_version_list = ["12"] + self.target_api_version_list = ["9", "10", "11", "12", "18", "20"] self.target_api_sub_version_list = ["beta1", "beta2", "beta3"] - self.specific_api_version_list = ["API11", "API12beta3"] + self.specific_api_version_list = ["API18", "API12beta3", "API11"] self.output = None self.process = None self.test_version = test_version @@ -2344,7 +2520,7 @@ class TestVersionControl(Test): def run_process(self, cmd): self.process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = self.process.communicate() - self.output = stdout.decode("utf-8", errors="ignore") + stderr.decode("utf-8", errors="ignore").split("\n")[0] + self.output = stdout.decode("utf-8", errors="ignore") + stderr.decode("utf-8", errors="ignore") return stdout, stderr def run_process_compile(self, runner, target_api_version, target_api_sub_version="bata3", dump_type=""): @@ -2362,6 +2538,7 @@ class TestVersionControl(Test): cmd.append("--dump-ast") elif dump_type == "assembly": cmd.append("--dump-assembly") + self.log_cmd(cmd) stdout, stderr = self.run_process(cmd) return stdout, stderr @@ -2389,12 +2566,13 @@ class TestVersionControl(Test): ark_js_vm_path = os.path.join(ark_js_vm_dir, "ark_js_vm") cmd.append(ark_js_vm_path) cmd.append(self.test_abc_path) + self.log_cmd(cmd) self.process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = self.process.communicate() self.output = stdout.decode("utf-8", errors="ignore") + stderr.decode("utf-8", errors="ignore").split("\n")[0] return stdout, stderr - def run_for_single_version(self, runner, target_api_version, target_api_sub_version="beta3"): + def run_for_single_version(self, runner, target_api_version, target_api_sub_version=""): cur_api_version = "API" + target_api_version + target_api_sub_version is_support = True if self.compare_two_versions(cur_api_version, self.test_version) >= 0 else False compile_expected_path = None @@ -2415,6 +2593,7 @@ class TestVersionControl(Test): self.passed = False if not self.passed or (stderr and self.passed): return stderr + cur_api_version_number = API_VERSION_MAP.get(cur_api_version) for api_version in self.target_api_version_list: # The interception capability of API9 version of ark_js_vm has not yet been launched. if api_version == "9": @@ -2422,9 +2601,18 @@ class TestVersionControl(Test): for api_sub_version in self.target_api_sub_version_list: if not api_version in self.version_with_sub_version_list and api_sub_version != "beta3": continue + elif not api_version in self.version_with_sub_version_list: + api_sub_version = "" cur_runtime_api_version = "API" + api_version + api_sub_version + cur_runtime_api_version_number = API_VERSION_MAP.get(cur_runtime_api_version) is_below_abc_version = ( - False if self.compare_two_versions(cur_runtime_api_version, cur_api_version) >= 0 else True + False + if TestAbcVersionControl.compare_version_number( + cur_runtime_api_version_number, + cur_api_version_number, + ) + >= 0 + else True ) self.generate_module_abc(runner, cur_runtime_api_version) _, stderr = self.runtime_for_target_version(runner, api_version, api_sub_version) @@ -2498,8 +2686,21 @@ def prepare_for_obfuscation(compiler_test_infos, test_root): def add_directory_for_version_control(runners, args): - ark_js_vm_prepared = ArkJsVmDownload(args) - ark_js_vm_prepared.run() + tools = [ + { + "url": "https://gitee.com/zhongmingwei123123/ark_js_vm_version.git", + "components_name": "ark_js_vm_version" + }, + { + "url": "https://gitee.com/li_yue1999/es2abc_version.git", + "components_name": "es2abc_version" + } + ] + + for tool in tools: + downloader = CodeDownloader(args, tool['url'], tool['components_name']) + downloader.run() + runner = VersionControlRunner(args) runner.add_directory( "version_control/API11/syntax_feature", @@ -2591,33 +2792,44 @@ def add_directory_for_version_control(runners, args): "version_control/API12beta3/bytecode_feature/import_target", ) runner.add_directory( - "version_control/API16/bytecode_feature", + "version_control/API18/bytecode_feature", "js", [], - "API16", + "API18", "bytecode_feature", ) runner.add_directory( - "version_control/API16/bytecode_feature", + "version_control/API18/bytecode_feature", "ts", ["--module"], - "API16", + "API18", + "bytecode_feature", + ) + runner.add_directory( + "version_control/API20/bytecode_feature", + "ts", + ["--module", "--enable-annotations"], + "API20", "bytecode_feature", ) runners.append(runner) abc_tests_prepare = AbcTestCasesPrepare(args) + es2abc_versions = list(ES2ABC_API_SUPPORT.keys()) + abc_tests_prepare.gen_abc_tests( "version_control/bytecode_version_control/non_merge_mode", "js", ["--module"], "non_merge_mode", + es2abc_versions ) abc_tests_prepare.gen_abc_tests( "version_control/bytecode_version_control/merge_mode", "js", ["--module", "--merge-abc"], "merge_mode", + es2abc_versions ) abc_tests_prepare.gen_abc_tests( "version_control/bytecode_version_control/mixed_compile", @@ -2648,6 +2860,21 @@ def add_directory_for_version_control(runners, args): ) runners.append(abc_version_control_runner) + es2abc_version_control_runner = Es2abcVersionControlRunner(args) + es2abc_version_control_runner.add_directory( + "version_control/bytecode_version_control/non_merge_mode", + "abc", + ["--module", "--enable-abc-input"], + "non_merge_mode", + ) + es2abc_version_control_runner.add_directory( + "version_control/bytecode_version_control/merge_mode", + "abc", + ["--module", "--enable-abc-input", "--merge-abc"], + "merge_mode", + ) + runners.append(es2abc_version_control_runner) + def add_directory_for_regression(runners, args): runner = RegressionRunner(args) runner.add_directory("parser/concurrent", "js", ["--module", "--dump-ast"]) @@ -2676,7 +2903,8 @@ def add_directory_for_regression(runners, args): runner.add_directory("parser/js/language/import/syntax/api12/beta2", "js", ["--parse-only", "--module", "--target-api-version=12", "--target-api-sub-version=beta2"]) runner.add_directory("parser/js/language/import", "ts", - ["--dump-assembly", "--dump-literal-buffer", "--module", "--target-api-version=18"]) + ["--dump-assembly", "--dump-literal-buffer", "--module", "--target-api-version=12", + "--target-api-sub-version=beta3"]) runner.add_directory("parser/sendable_class", "ts", ["--dump-assembly", "--dump-literal-buffer", "--module", "--target-api-sub-version=beta3"]) runner.add_directory("parser/sendable_class/api12beta2", "ts", @@ -2771,7 +2999,7 @@ def add_directory_for_compiler(runners, args): "--file-threads=8"])) compiler_test_infos.append(CompilerTestInfo("compiler/bytecodehar/projects", "ts", ["--merge-abc", "--dump-assembly", "--enable-abc-input", - "--dump-deps-info", "--remove-redundant-file", + "--dump-deps-info", "--remove-redundant-file", "--enable-annotations", "--dump-literal-buffer", "--dump-string", "--abc-class-threads=4"])) compiler_test_infos.append(CompilerTestInfo("compiler/bytecodehar/js/projects", "js", ["--merge-abc", "--dump-assembly", "--enable-abc-input", @@ -2782,7 +3010,7 @@ def add_directory_for_compiler(runners, args): "--abc-class-threads=4"])) compiler_test_infos.append(CompilerTestInfo("compiler/cache_projects", "ts", ["--merge-abc", "--dump-assembly", "--enable-abc-input", - "--dump-deps-info", "--remove-redundant-file", + "--dump-deps-info", "--remove-redundant-file", "--enable-annotations", "--dump-literal-buffer", "--dump-string", "--abc-class-threads=4", "--cache-file"])) diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 97% rename from es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 2657d967535b7d42723020d9ae130271fc7ca863..eae6c92044b0cfbcaf5744908d034235569763d1 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x1 .language ECMAScript .function any .A(any a0, any a1, any a2, any a3) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index 13a61838909bb08d516049d0f3647ecd0d410330..918314e6e16548c4a76b4f01f92d40354167def8 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x1 .language ECMAScript .function any .#~A=#A(any a0, any a1, any a2, any a3) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..13a61838909bb08d516049d0f3647ecd0d410330 --- /dev/null +++ b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,73 @@ +slotNum = 0x4 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~A=#A(any a0, any a1, any a2, any a3) { +label_1: +label_0: + ldlexvar 0x0, 0x0 + callruntime.callinit 0x0, a2 + lda a3 + stobjbyname 0x2, a, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .#~A>#instance_initializer(any a0, any a1, any a2) { +label_1: +label_0: + lda.str a + definepropertybyname 0x0, a, a2 + returnundefined +label_2: +} + +slotNum = 0xb +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { + nop +label_7: +label_0: + newlexenv 0x1 +label_2: +label_4: + ldhole + sta v1 + defineclasswithbuffer 0x0, .#~A=#A, _2, 0x1, v1 + sta v1 + ldobjbyname 0x1, prototype + definemethod 0x3, .#~A>#instance_initializer, 0x0 + stlexvar 0x0, 0x0 +label_3: +end_label_3: + jmp label_1 +label_9: + sta v0 +label_6: + poplexenv + lda v0 + throw +label_1: + poplexenv + lda.str b + sta v0 + mov v2, v1 + mov v3, v0 + newobjrange 0x4, 0x2, v2 + sta v0 + tryldglobalbyname 0x6, print + sta v1 + lda v0 + ldobjbyname 0x7, a + sta v0 + lda v1 + callarg1 0x9, v0 + returnundefined +label_8: +} + +.catchall label_2, end_label_3, label_9 + + diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_unsupported_compile_asm_version-expected.txt index 477926b113c103bf6b1af54dac9b78cae8e9fbad..f8ea73ca5f3bc2b65c6462279538148ed44ae72d 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/class_init_callinit_unsupported_compile_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .A(any a0, any a1, any a2, any a3) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 98% rename from es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index d5dbb31f3fa9b36d9ef5a5337c872e59d5cdba6d..b7e43e9e1fb3742bb4f8a4bf6d06dbd0363112dd 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x1 .language ECMAScript .function any .TestPrivateProperty(any a0, any a1, any a2, any a3) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index a4e2f5e25d68ac12686740a4b01fa1f00ae5bef0..d568dbc64c403cdaa4f769ffeee74f889a849be6 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x1 .language ECMAScript .function any .#~@0=#TestPrivateProperty(any a0, any a1, any a2, any a3) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt index 90da189592f8d76f107b81ff6da4fef6d3d8229f..2d887353700d529600f18099893bcf0c89261257 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt @@ -1,7 +1,6 @@ .language ECMAScript slotNum = 0x4 -expectedProperty = 0x1 .function any .#~@0=#TestPrivateProperty(any a0, any a1, any a2, any a3) { label_1: label_0: diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..a4e2f5e25d68ac12686740a4b01fa1f00ae5bef0 --- /dev/null +++ b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,103 @@ +slotNum = 0x4 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@0=#TestPrivateProperty(any a0, any a1, any a2, any a3) { +label_1: +label_0: + ldlexvar 0x0, 0x1 + callruntime.callinit 0x0, a2 + lda a3 + stprivateproperty 0x2, 0x0, 0x0, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .#~@0>#getPrivateField(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + ldprivateproperty 0x0, 0x0, 0x0 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .#~@0>#instance_initializer(any a0, any a1, any a2) { +label_1: +label_0: + ldundefined + callruntime.defineprivateproperty 0x0, 0x0, 0x0, a2 + returnundefined +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .#~@0>#setPrivateField(any a0, any a1, any a2, any a3) { +label_1: +label_0: + lda a3 + stprivateproperty 0x0, 0x0, 0x0, a2 + returnundefined +label_2: +} + +slotNum = 0x11 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { + nop +label_7: +label_0: + newlexenv 0x2 +label_2: +label_4: + ldhole + sta v1 + defineclasswithbuffer 0x0, .#~@0=#TestPrivateProperty, _2, 0x1, v1 + sta v1 + ldobjbyname 0x1, prototype + definemethod 0x3, .#~@0>#instance_initializer, 0x0 + stlexvar 0x0, 0x1 + callruntime.createprivateproperty 0x1, _3 +label_3: +end_label_3: + jmp label_1 +label_9: + sta v0 +label_6: + poplexenv + lda v0 + throw +label_1: + poplexenv + ldai 0xa + sta v0 + mov v3, v1 + mov v4, v0 + newobjrange 0x4, 0x2, v3 + sta v0 + ldobjbyname 0x6, setPrivateField + sta v1 + ldai 0x14 + sta v2 + lda v1 + callthis1 0x8, v0, v2 + tryldglobalbyname 0xa, print + sta v1 + lda v0 + ldobjbyname 0xb, getPrivateField + callthis0 0xd, v0 + sta v0 + lda v1 + callarg1 0xf, v0 + returnundefined +label_8: +} + +.catchall label_2, end_label_3, label_9 + + diff --git a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_unsupported_compile_asm_version-expected.txt index f7d4404293294735de27c59e31d20633d84080be..382ae3503f71696fcf11789af52716b4c7944d29 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/class_private_property_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/class_private_property_unsupported_compile_asm_version-expected.txt @@ -1 +1,2 @@ -SyntaxError: Unexpected token in class property [class_private_property.js:17:5] \ No newline at end of file +SyntaxError: Unexpected token in class property [class_private_property.js:17:5] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 98% rename from es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 63208d0f05f24cd30343f28341311e74ff69f5e9..0f3aceeaadb575a70660d8adcccc371c0875166e 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .A(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index e7087b0c6e227f487f71723bf8c89bd06d7fd6a6..2c0f076a938f21a23c07a55def36c83766324f0f 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~A=#A(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..e7087b0c6e227f487f71723bf8c89bd06d7fd6a6 --- /dev/null +++ b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,88 @@ +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + ldlexvar 0x0, 0x1 + callruntime.callinit 0x0, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .#~A>#instance_initializer(any a0, any a1, any a2) { +label_1: +label_0: + ldlexvar 0x0, 0x0 + sta v0 + ldlexvar 0x1, 0x0 + sta v1 + throw.undefinedifholewithname a + lda v1 + callruntime.definefieldbyvalue 0x0, v0, a2 + returnundefined +label_2: +} + +slotNum = 0xc +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { + nop +label_7: +label_0: + newlexenv 0x1 + lda.str a + sta v0 + lda.str b + add2 0x0, v0 + stlexvar 0x0, 0x0 + newlexenv 0x2 +label_2: +label_4: + ldhole + sta v1 + ldlexvar 0x1, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + callruntime.topropertykey + stlexvar 0x0, 0x0 + defineclasswithbuffer 0x1, .#~A=#A, _2, 0x0, v1 + sta v1 + ldobjbyname 0x2, prototype + definemethod 0x4, .#~A>#instance_initializer, 0x0 + stlexvar 0x0, 0x1 +label_3: +end_label_3: + jmp label_1 +label_9: + sta v0 +label_6: + poplexenv + lda v0 + throw +label_1: + poplexenv + mov v3, v1 + newobjrange 0x5, 0x1, v3 + sta v0 + tryldglobalbyname 0x7, print + sta v1 + ldlexvar 0x0, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + ldobjbyvalue 0x8, v0 + sta v0 + lda v1 + callarg1 0xa, v0 + returnundefined +label_8: +} + +.catchall label_2, end_label_3, label_9 + + diff --git a/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_unsupported_compile_asm_version-expected.txt index 71dce896947194f79ee8dd4ff9d03da0dbff9c7a..2146d9664381b09bf5604ff65b464810c9185e3d 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/computed_property_name_as_class_key_unsupported_compile_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x0 -expectedProperty = 0x1 .language ECMAScript .function any .A(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 97% rename from es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 69bb8f2086f3c64df358870bf9f387f7b38ab731..abb8d603e850df27ddec1d97e52b05829581e40d 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -13,7 +13,6 @@ label_2: } slotNum = 0x6 -expectedProperty = 0x2 .language ECMAScript .function any .TestTypeA(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index 67e2e6c37a2ac26739c415cc91543a987fff4b5d..520550704fce57cc575b74d2e3627e27ab3ec0c4 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -13,7 +13,6 @@ label_2: } slotNum = 0x6 -expectedProperty = 0x2 .language ECMAScript .function any .#&X~@0=#TestTypeA(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..67e2e6c37a2ac26739c415cc91543a987fff4b5d --- /dev/null +++ b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,55 @@ +slotNum = 0x1 +.language ECMAScript +.function any .#&#X(any a0, any a1, any a2, any a3) { +label_1: +label_0: + newlexenv 0x1 + ldhole + sta v0 + callruntime.definesendableclass 0x0, .#&X~@0=#TestTypeA, _3, 0x0, v0 + stlexvar 0x0, 0x0 + returnundefined +label_2: +} + +slotNum = 0x6 +expectedProperty = 0x2 +.language ECMAScript +.function any .#&X~@0=#TestTypeA(any a0, any a1, any a2) { +label_1: +label_0: + lda.str A + stobjbyname 0x0, name, a2 + callruntime.ldsendableclass 0x0 + sta v0 + mov v1, v0 + newobjrange 0x2, 0x1, v1 + stobjbyname 0x4, test, a2 + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_4: +label_0: + ldundefined + sta v0 + definefunc 0x0, .#&#X, 0x1 + sta v1 + lda v0 + callruntime.istrue 0x1 + jnez label_3 +label_2: + createemptyobject + sta v0 +label_3: + lda v1 + callarg1 0x2, v0 + returnundefined +label_5: +} + + diff --git a/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_unsupported_compile_asm_version-expected.txt index 6e671f61e26c94990488569cc9bc102a594d6f7d..c24923ed0ec6685bf48c1d87984262c7668e6211 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/define_ld_sendable_class_unsupported_compile_asm_version-expected.txt @@ -32,7 +32,6 @@ label_8: .catchall label_2, end_label_3, label_9 slotNum = 0x6 -expectedProperty = 0x2 .language ECMAScript .function any .TestTypeA(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 98% rename from es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 33c4531ae9437172fdeb6e84393e3cf2c5821524..9809190ee53e5e15cd9e1c0c73483b1c78f1cf93 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x1 .language ECMAScript .function any .InObjSyntax(any a0, any a1, any a2, any a3) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index 4493a6c93d32e6185de7f9864d13c92b06590c83..0674d69a08d2e87afe0fbaee4417b7118392f5db 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -17,7 +17,6 @@ label_4: } slotNum = 0x4 -expectedProperty = 0x1 .language ECMAScript .function any .#~@0=#InObjSyntax(any a0, any a1, any a2, any a3) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt index 46915b5bf72ae6a9e27baadd2e35795017d661f8..6d4c25cbeeedc82abbc28782abf3057b3fb26c02 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt @@ -18,7 +18,6 @@ label_4: } slotNum = 0x4 -expectedProperty = 0x1 .function any .#~@0=#InObjSyntax(any a0, any a1, any a2, any a3) { label_1: label_0: diff --git a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..4493a6c93d32e6185de7f9864d13c92b06590c83 --- /dev/null +++ b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,95 @@ +slotNum = 0x3 +.language ECMAScript +.function any .#~@0<#getPrivateProperty(any a0, any a1, any a2, any a3) { +label_3: +label_0: + lda a3 + testin 0x0, 0x0, 0x0 + callruntime.isfalse 0x2 + jnez label_1 +label_2: + ldtrue + return +label_1: + ldfalse + return +label_4: +} + +slotNum = 0x4 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@0=#InObjSyntax(any a0, any a1, any a2, any a3) { +label_1: +label_0: + ldlexvar 0x0, 0x1 + callruntime.callinit 0x0, a2 + lda a3 + stprivateproperty 0x2, 0x0, 0x0, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .#~@0>#instance_initializer(any a0, any a1, any a2) { +label_1: +label_0: + lda.str private + callruntime.defineprivateproperty 0x0, 0x0, 0x0, a2 + returnundefined +label_2: +} + +slotNum = 0xd +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { + nop +label_7: +label_0: + newlexenv 0x2 +label_2: +label_4: + ldhole + sta v1 + defineclasswithbuffer 0x0, .#~@0=#InObjSyntax, _2, 0x1, v1 + sta v1 + ldobjbyname 0x1, prototype + definemethod 0x3, .#~@0>#instance_initializer, 0x0 + stlexvar 0x0, 0x1 + callruntime.createprivateproperty 0x1, _3 +label_3: +end_label_3: + jmp label_1 +label_9: + sta v0 +label_6: + poplexenv + lda v0 + throw +label_1: + poplexenv + tryldglobalbyname 0x4, print + sta v0 + lda v1 + ldobjbyname 0x5, getPrivateProperty + sta v2 + lda.str foo + sta v3 + mov v4, v1 + mov v5, v3 + newobjrange 0x7, 0x2, v4 + sta v3 + lda v2 + callthis1 0x9, v1, v3 + sta v1 + lda v0 + callarg1 0xb, v1 + returnundefined +label_8: +} + +.catchall label_2, end_label_3, label_9 + + diff --git a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_unsupported_compile_asm_version-expected.txt index 07c1ce9d18fcc7a4de91ff1de1e1e6488c5525a0..6f86f64511d408bb2d3143b64453c710731cced2 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/in_obj_syntax_unsupported_compile_asm_version-expected.txt @@ -1 +1,2 @@ -SyntaxError: Unexpected token in class property [in_obj_syntax.js:17:5] \ No newline at end of file +SyntaxError: Unexpected token in class property [in_obj_syntax.js:17:5] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 98% rename from es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 9358f6779e4f0501600a2ad0be9ceaff35a5efe5..2417ecc1e70054fc2737a7d02af5e1a77b4f4063 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x3 .language ECMAScript .function any .A(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index aa00c9181c2dc6fbfcf0794e14911bc97cad2921..26d24c71b275f5ea1861d5dcb9bcdb5f9d4701cc 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x3 .language ECMAScript .function any .#~A=#A(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..aa00c9181c2dc6fbfcf0794e14911bc97cad2921 --- /dev/null +++ b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,75 @@ +slotNum = 0x2 +expectedProperty = 0x3 +.language ECMAScript +.function any .#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + ldlexvar 0x0, 0x1 + callruntime.callinit 0x0, a2 + lda a2 + return +label_2: +} + +slotNum = 0x6 +.language ECMAScript +.function any .#~A>#instance_initializer(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + callruntime.definefieldbyindex 0x0, 0x1, a2 + ldlexvar 0x0, 0x0 + sta v0 + lda.str a + callruntime.definefieldbyvalue 0x2, v0, a2 + ldlexvar 0x1, 0x0 + sta v0 + throw.undefinedifholewithname a + lda v0 + definepropertybyname 0x4, b, a2 + returnundefined +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { + nop +label_7: +label_0: + newlexenv 0x1 + lda.str a + stlexvar 0x0, 0x0 + newlexenv 0x2 +label_2: +label_4: + ldhole + sta v1 + ldlexvar 0x1, 0x0 + sta v2 + throw.undefinedifholewithname a + lda v2 + callruntime.topropertykey + stlexvar 0x0, 0x0 + defineclasswithbuffer 0x0, .#~A=#A, _2, 0x0, v1 + ldobjbyname 0x1, prototype + definemethod 0x3, .#~A>#instance_initializer, 0x0 + stlexvar 0x0, 0x1 +label_3: +end_label_3: + jmp label_1 +label_9: + sta v0 +label_6: + poplexenv + lda v0 + throw +label_1: + poplexenv + returnundefined +label_8: +} + +.catchall label_2, end_label_3, label_9 + + diff --git a/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_unsupported_compile_asm_version-expected.txt index 302fa2a5806c5d48a639c70dc5d44f0cf7dc3f8e..18d32ff7d158922e027351f151fe92a66bbdc75d 100644 --- a/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API11/bytecode_feature/public_field_replace_set_semantics_as_define_unsupported_compile_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x0 -expectedProperty = 0x3 .language ECMAScript .function any .A(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API11/syntax_feature/class_private_field_unsupported_compile_version-expected.txt b/es2panda/test/version_control/API11/syntax_feature/class_private_field_unsupported_compile_version-expected.txt index 9ebbe0fbe7673aa4767c89a542dfdeea59e23244..55353e1e07b6b90d300363d439cecc2b8247843e 100644 --- a/es2panda/test/version_control/API11/syntax_feature/class_private_field_unsupported_compile_version-expected.txt +++ b/es2panda/test/version_control/API11/syntax_feature/class_private_field_unsupported_compile_version-expected.txt @@ -1 +1,2 @@ -SyntaxError: Unexpected token in class property [class_private_field.js:17:5] \ No newline at end of file +SyntaxError: Unexpected token in class property [class_private_field.js:17:5] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API11/syntax_feature/class_private_method_unsupported_compile_version-expected.txt b/es2panda/test/version_control/API11/syntax_feature/class_private_method_unsupported_compile_version-expected.txt index 3303a190e5551ffebaf8c1f70044d891ffed8b83..7ac858525c0f11da695d238142bdbe6f0e421725 100644 --- a/es2panda/test/version_control/API11/syntax_feature/class_private_method_unsupported_compile_version-expected.txt +++ b/es2panda/test/version_control/API11/syntax_feature/class_private_method_unsupported_compile_version-expected.txt @@ -1 +1,2 @@ -SyntaxError: Unexpected token in class property [class_private_method.js:17:5] \ No newline at end of file +SyntaxError: Unexpected token in class property [class_private_method.js:17:5] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API11/syntax_feature/in_check_private_property_unsupported_compile_version-expected.txt b/es2panda/test/version_control/API11/syntax_feature/in_check_private_property_unsupported_compile_version-expected.txt index 5d5a117bc1f312c0fabed54858d0a50a2fc5239b..d1e3d87e4347f8e0dca9b155a0a3ef12aafbed39 100644 --- a/es2panda/test/version_control/API11/syntax_feature/in_check_private_property_unsupported_compile_version-expected.txt +++ b/es2panda/test/version_control/API11/syntax_feature/in_check_private_property_unsupported_compile_version-expected.txt @@ -1 +1,2 @@ -SyntaxError: Unexpected token in class property [in_check_private_property.js:17:5] \ No newline at end of file +SyntaxError: Unexpected token in class property [in_check_private_property.js:17:5] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 97% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 03c820216f70c914be786fab25909038d65ceacc..c79b8851104d495de84a5b6d3305979d220a82c0 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x2 .language ECMAScript .function any .SendableLazyLoading(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index 048d8311b39588239503c1bdccf78518836e0c27..37095061777d94e7ff7da8abf4fd4ea91c39669f 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x2 .language ECMAScript .function any .#~@0=#SendableLazyLoading(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..048d8311b39588239503c1bdccf78518836e0c27 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,45 @@ +slotNum = 0x4 +expectedProperty = 0x2 +.language ECMAScript +.function any .#~@0=#SendableLazyLoading(any a0, any a1, any a2) { +label_1: +label_0: + callruntime.ldsendableexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname a1 + lda v0 + stobjbyname 0x0, name, a2 + callruntime.wideldsendableexternalmodulevar 0xad + sta v0 + throw.undefinedifholewithname a255 + lda v0 + stobjbyname 0x2, name1, a2 + lda a2 + return +label_2: +} + +slotNum = 0x8 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + callruntime.definesendableclass 0x0, .#~@0=#SendableLazyLoading, _3, 0x0, v0 + sta v0 + mov v2, v0 + newobjrange 0x1, 0x1, v2 + sta v0 + tryldglobalbyname 0x3, print + sta v1 + lda v0 + ldobjbyname 0x4, name + sta v0 + lda v1 + callarg1 0x6, v0 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_below_API11_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_asm_version-expected.txt similarity index 97% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_below_API11_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_asm_version-expected.txt index c856ace10eeee1748a21c2a78b8964fb2d31aed2..dd9c93627ba79c5c22161a560f87f0634730700d 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_below_API11_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x2 .language ECMAScript .function any .SendableLazyLoading(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 96% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 0d29c31ce79b818f12e196979de27cd718248290..6e71af8b31718335b7315424577f2895453596c8 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x4 -expectedProperty = 0x2 .language ECMAScript .function any .SendableLazyLoading(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6e71af8b31718335b7315424577f2895453596c8 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -0,0 +1,44 @@ +slotNum = 0x4 +.language ECMAScript +.function any .SendableLazyLoading(any a0, any a1, any a2) { +label_1: +label_0: + ldexternalmodulevar 0x0 + sta v0 + throw.undefinedifholewithname a1 + lda v0 + stobjbyname 0x0, name, a2 + wide.ldexternalmodulevar 0xad + sta v0 + throw.undefinedifholewithname a255 + lda v0 + stobjbyname 0x2, name1, a2 + lda a2 + return +label_2: +} + +slotNum = 0x8 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + callruntime.definesendableclass 0x0, .SendableLazyLoading, _2, 0x0, v0 + sta v0 + mov v2, v0 + newobjrange 0x1, 0x1, v2 + sta v0 + tryldglobalbyname 0x3, print + sta v1 + lda v0 + ldobjbyname 0x4, name + sta v0 + lda v1 + callarg1 0x6, v0 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_below_API11_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_below_API11_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_below_API12beta3_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_below_API12beta3_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..da0f8ed91a8f2f0f067b3bdf26265d5ca48cf82c --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/lazy_loading_mudule_variables_in_sendable_class_unsupported_runtime_version-expected.txt @@ -0,0 +1 @@ +a1 diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 95% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index c5f203f625fe2cf1c908f4fcb303b354fbe029ed..ab6c662e2d9e5ce394e315d531ed1e6e67eba895 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0xa -expectedProperty = 0x2 .language ECMAScript .function any .SendableTestClass1(any a0, any a1, any a2) { label_1: @@ -20,7 +19,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass1(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index eb032750110552b4b42abde4fea04b03d2e206e7..d85ed5764e9862238e443405563a5636df871cc8 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@0=#TopLevelSendableClass1(any a0, any a1, any a2) { label_1: @@ -12,7 +11,6 @@ label_2: } slotNum = 0xa -expectedProperty = 0x2 .language ECMAScript .function any .#~@1=#SendableTestClass1(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..eb032750110552b4b42abde4fea04b03d2e206e7 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,55 @@ +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@0=#TopLevelSendableClass1(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0xa +expectedProperty = 0x2 +.language ECMAScript +.function any .#~@1=#SendableTestClass1(any a0, any a1, any a2) { +label_1: +label_0: + callruntime.ldsendablevar 0x0, 0x0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass1 + mov v1, v0 + newobjrange 0x0, 0x1, v1 + stobjbyname 0x2, a1, a2 + lda a2 + ldobjbyname 0x4, a1 + ldobjbyname 0x6, o + stobjbyname 0x8, u, a2 + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + callruntime.newsendableenv 0x1 + ldhole + sta v0 + callruntime.definesendableclass 0x0, .#~@0=#TopLevelSendableClass1, _3, 0x0, v0 + callruntime.stsendablevar 0x0, 0x0 + ldhole + sta v0 + callruntime.definesendableclass 0x1, .#~@1=#SendableTestClass1, _5, 0x0, v0 + sta v0 + mov v1, v0 + newobjrange 0x2, 0x1, v1 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_asm_version-expected.txt index cde3ccc64189ca9ddef9c65bb595dd1ba85c7db9..fdad4e6d3a652e370b6ec44e1e7d6ec18ad7bb95 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_asm_version-expected.txt @@ -1,5 +1,5 @@ +slotNum = 0xa .language ECMAScript - .function any .SendableTestClass1(any a0, any a1, any a2) { label_1: label_0: @@ -8,9 +8,9 @@ label_0: throw.undefinedifholewithname TopLevelSendableClass1 mov v1, v0 newobjrange 0x0, 0x1, v1 - stobjbyname 0x2, I1, a2 + stobjbyname 0x2, a1, a2 lda a2 - ldobjbyname 0x4, I1 + ldobjbyname 0x4, a1 ldobjbyname 0x6, o stobjbyname 0x8, u, a2 lda a2 @@ -18,6 +18,8 @@ label_0: label_2: } +slotNum = 0x2 +.language ECMAScript .function any .TopLevelSendableClass1(any a0, any a1, any a2) { label_1: label_0: @@ -28,21 +30,26 @@ label_0: label_2: } +slotNum = 0x8 +.language ECMAScript .function any .func_main_0(any a0, any a1, any a2) { label_1: label_0: newlexenv 0x1 ldhole sta v0 - callruntime.definesendableclass 0x0, .TopLevelSendableClass1, _2, 0x0, v0 + defineclasswithbuffer 0x0, .TopLevelSendableClass1, _1, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 stlexvar 0x0, 0x0 ldhole sta v0 - callruntime.definesendableclass 0x1, .SendableTestClass1, _4, 0x0, v0 + defineclasswithbuffer 0x3, .SendableTestClass1, _2, 0x0, v0 sta v0 + ldobjbyname 0x4, prototype mov v1, v0 - newobjrange 0x2, 0x1, v1 - ldundefined + newobjrange 0x6, 0x1, v1 returnundefined label_2: } diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 95% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 0f14e168d48b3eb32216ad318cf2a3259bab512d..9648548b638686eee08bccbddb4601b37b8817ec 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0xa -expectedProperty = 0x2 .language ECMAScript .function any .SendableTestClass1(any a0, any a1, any a2) { label_1: @@ -20,7 +19,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass1(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_below_API11_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt similarity index 72% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_below_API11_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index d42096de0cb644cf4d6ab10902b64fefe1130ecb..9648548b638686eee08bccbddb4601b37b8817ec 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_below_API11_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0xa -expectedProperty = 0x2 .language ECMAScript .function any .SendableTestClass1(any a0, any a1, any a2) { label_1: @@ -20,7 +19,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass1(any a0, any a1, any a2) { label_1: @@ -32,7 +30,7 @@ label_0: label_2: } -slotNum = 0x8 +slotNum = 0x4 .language ECMAScript .function any .func_main_0(any a0, any a1, any a2) { label_1: @@ -40,18 +38,14 @@ label_0: newlexenv 0x1 ldhole sta v0 - defineclasswithbuffer 0x0, .TopLevelSendableClass1, _1, 0x0, v0 - sta v0 - ldobjbyname 0x1, prototype - lda v0 + callruntime.definesendableclass 0x0, .TopLevelSendableClass1, _2, 0x0, v0 stlexvar 0x0, 0x0 ldhole sta v0 - defineclasswithbuffer 0x3, .SendableTestClass1, _2, 0x0, v0 + callruntime.definesendableclass 0x1, .SendableTestClass1, _4, 0x0, v0 sta v0 - ldobjbyname 0x4, prototype mov v1, v0 - newobjrange 0x6, 0x1, v1 + newobjrange 0x2, 0x1, v1 returnundefined label_2: } diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_below_API12beta3_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_below_API12beta3_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_below_API12beta3_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_below_API12beta3_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_unsupported_runtime_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_unsupported_runtime_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/sendable_lexical_env_unsupported_runtime_version-expected.txt diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 95% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 6407e1d84bc14ce42abeec01422b74291505a244..1517375c8a7909a1c7d8320e7c039ac374d15e8e 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x406 -expectedProperty = 0x101 .language ECMAScript .function any .SendableTestClass1(any a0, any a1, any a2) { label_1: @@ -1546,7 +1545,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass1(any a0, any a1, any a2) { label_1: @@ -1559,7 +1557,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass10(any a0, any a1, any a2) { label_1: @@ -1572,7 +1569,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass100(any a0, any a1, any a2) { label_1: @@ -1585,7 +1581,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass101(any a0, any a1, any a2) { label_1: @@ -1598,7 +1593,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass102(any a0, any a1, any a2) { label_1: @@ -1611,7 +1605,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass103(any a0, any a1, any a2) { label_1: @@ -1624,7 +1617,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass104(any a0, any a1, any a2) { label_1: @@ -1637,7 +1629,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass105(any a0, any a1, any a2) { label_1: @@ -1650,7 +1641,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass106(any a0, any a1, any a2) { label_1: @@ -1663,7 +1653,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass107(any a0, any a1, any a2) { label_1: @@ -1676,7 +1665,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass108(any a0, any a1, any a2) { label_1: @@ -1689,7 +1677,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass109(any a0, any a1, any a2) { label_1: @@ -1702,7 +1689,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass11(any a0, any a1, any a2) { label_1: @@ -1715,7 +1701,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass110(any a0, any a1, any a2) { label_1: @@ -1728,7 +1713,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass111(any a0, any a1, any a2) { label_1: @@ -1741,7 +1725,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass112(any a0, any a1, any a2) { label_1: @@ -1754,7 +1737,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass113(any a0, any a1, any a2) { label_1: @@ -1767,7 +1749,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass114(any a0, any a1, any a2) { label_1: @@ -1780,7 +1761,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass115(any a0, any a1, any a2) { label_1: @@ -1793,7 +1773,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass116(any a0, any a1, any a2) { label_1: @@ -1806,7 +1785,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass117(any a0, any a1, any a2) { label_1: @@ -1819,7 +1797,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass118(any a0, any a1, any a2) { label_1: @@ -1832,7 +1809,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass119(any a0, any a1, any a2) { label_1: @@ -1845,7 +1821,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass12(any a0, any a1, any a2) { label_1: @@ -1858,7 +1833,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass120(any a0, any a1, any a2) { label_1: @@ -1871,7 +1845,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass121(any a0, any a1, any a2) { label_1: @@ -1884,7 +1857,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass122(any a0, any a1, any a2) { label_1: @@ -1897,7 +1869,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass123(any a0, any a1, any a2) { label_1: @@ -1910,7 +1881,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass124(any a0, any a1, any a2) { label_1: @@ -1923,7 +1893,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass125(any a0, any a1, any a2) { label_1: @@ -1936,7 +1905,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass126(any a0, any a1, any a2) { label_1: @@ -1949,7 +1917,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass127(any a0, any a1, any a2) { label_1: @@ -1962,7 +1929,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass128(any a0, any a1, any a2) { label_1: @@ -1975,7 +1941,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass129(any a0, any a1, any a2) { label_1: @@ -1988,7 +1953,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass13(any a0, any a1, any a2) { label_1: @@ -2001,7 +1965,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass130(any a0, any a1, any a2) { label_1: @@ -2014,7 +1977,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass131(any a0, any a1, any a2) { label_1: @@ -2027,7 +1989,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass132(any a0, any a1, any a2) { label_1: @@ -2040,7 +2001,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass133(any a0, any a1, any a2) { label_1: @@ -2053,7 +2013,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass134(any a0, any a1, any a2) { label_1: @@ -2066,7 +2025,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass135(any a0, any a1, any a2) { label_1: @@ -2079,7 +2037,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass136(any a0, any a1, any a2) { label_1: @@ -2092,7 +2049,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass137(any a0, any a1, any a2) { label_1: @@ -2105,7 +2061,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass138(any a0, any a1, any a2) { label_1: @@ -2118,7 +2073,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass139(any a0, any a1, any a2) { label_1: @@ -2131,7 +2085,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass14(any a0, any a1, any a2) { label_1: @@ -2144,7 +2097,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass140(any a0, any a1, any a2) { label_1: @@ -2157,7 +2109,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass141(any a0, any a1, any a2) { label_1: @@ -2170,7 +2121,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass142(any a0, any a1, any a2) { label_1: @@ -2183,7 +2133,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass143(any a0, any a1, any a2) { label_1: @@ -2196,7 +2145,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass144(any a0, any a1, any a2) { label_1: @@ -2209,7 +2157,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass145(any a0, any a1, any a2) { label_1: @@ -2222,7 +2169,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass146(any a0, any a1, any a2) { label_1: @@ -2235,7 +2181,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass147(any a0, any a1, any a2) { label_1: @@ -2248,7 +2193,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass148(any a0, any a1, any a2) { label_1: @@ -2261,7 +2205,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass149(any a0, any a1, any a2) { label_1: @@ -2274,7 +2217,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass15(any a0, any a1, any a2) { label_1: @@ -2287,7 +2229,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass150(any a0, any a1, any a2) { label_1: @@ -2300,7 +2241,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass151(any a0, any a1, any a2) { label_1: @@ -2313,7 +2253,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass152(any a0, any a1, any a2) { label_1: @@ -2326,7 +2265,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass153(any a0, any a1, any a2) { label_1: @@ -2339,7 +2277,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass154(any a0, any a1, any a2) { label_1: @@ -2352,7 +2289,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass155(any a0, any a1, any a2) { label_1: @@ -2365,7 +2301,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass156(any a0, any a1, any a2) { label_1: @@ -2378,7 +2313,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass157(any a0, any a1, any a2) { label_1: @@ -2391,7 +2325,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass158(any a0, any a1, any a2) { label_1: @@ -2404,7 +2337,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass159(any a0, any a1, any a2) { label_1: @@ -2417,7 +2349,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass16(any a0, any a1, any a2) { label_1: @@ -2430,7 +2361,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass160(any a0, any a1, any a2) { label_1: @@ -2443,7 +2373,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass161(any a0, any a1, any a2) { label_1: @@ -2456,7 +2385,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass162(any a0, any a1, any a2) { label_1: @@ -2469,7 +2397,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass163(any a0, any a1, any a2) { label_1: @@ -2482,7 +2409,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass164(any a0, any a1, any a2) { label_1: @@ -2495,7 +2421,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass165(any a0, any a1, any a2) { label_1: @@ -2508,7 +2433,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass166(any a0, any a1, any a2) { label_1: @@ -2521,7 +2445,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass167(any a0, any a1, any a2) { label_1: @@ -2534,7 +2457,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass168(any a0, any a1, any a2) { label_1: @@ -2547,7 +2469,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass169(any a0, any a1, any a2) { label_1: @@ -2560,7 +2481,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass17(any a0, any a1, any a2) { label_1: @@ -2573,7 +2493,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass170(any a0, any a1, any a2) { label_1: @@ -2586,7 +2505,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass171(any a0, any a1, any a2) { label_1: @@ -2599,7 +2517,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass172(any a0, any a1, any a2) { label_1: @@ -2612,7 +2529,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass173(any a0, any a1, any a2) { label_1: @@ -2625,7 +2541,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass174(any a0, any a1, any a2) { label_1: @@ -2638,7 +2553,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass175(any a0, any a1, any a2) { label_1: @@ -2651,7 +2565,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass176(any a0, any a1, any a2) { label_1: @@ -2664,7 +2577,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass177(any a0, any a1, any a2) { label_1: @@ -2677,7 +2589,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass178(any a0, any a1, any a2) { label_1: @@ -2690,7 +2601,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass179(any a0, any a1, any a2) { label_1: @@ -2703,7 +2613,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass18(any a0, any a1, any a2) { label_1: @@ -2716,7 +2625,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass180(any a0, any a1, any a2) { label_1: @@ -2729,7 +2637,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass181(any a0, any a1, any a2) { label_1: @@ -2742,7 +2649,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass182(any a0, any a1, any a2) { label_1: @@ -2755,7 +2661,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass183(any a0, any a1, any a2) { label_1: @@ -2768,7 +2673,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass184(any a0, any a1, any a2) { label_1: @@ -2781,7 +2685,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass185(any a0, any a1, any a2) { label_1: @@ -2794,7 +2697,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass186(any a0, any a1, any a2) { label_1: @@ -2807,7 +2709,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass187(any a0, any a1, any a2) { label_1: @@ -2820,7 +2721,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass188(any a0, any a1, any a2) { label_1: @@ -2833,7 +2733,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass189(any a0, any a1, any a2) { label_1: @@ -2846,7 +2745,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass19(any a0, any a1, any a2) { label_1: @@ -2859,7 +2757,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass190(any a0, any a1, any a2) { label_1: @@ -2872,7 +2769,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass191(any a0, any a1, any a2) { label_1: @@ -2885,7 +2781,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass192(any a0, any a1, any a2) { label_1: @@ -2898,7 +2793,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass193(any a0, any a1, any a2) { label_1: @@ -2911,7 +2805,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass194(any a0, any a1, any a2) { label_1: @@ -2924,7 +2817,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass195(any a0, any a1, any a2) { label_1: @@ -2937,7 +2829,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass196(any a0, any a1, any a2) { label_1: @@ -2950,7 +2841,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass197(any a0, any a1, any a2) { label_1: @@ -2963,7 +2853,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass198(any a0, any a1, any a2) { label_1: @@ -2976,7 +2865,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass199(any a0, any a1, any a2) { label_1: @@ -2989,7 +2877,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass2(any a0, any a1, any a2) { label_1: @@ -3002,7 +2889,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass20(any a0, any a1, any a2) { label_1: @@ -3015,7 +2901,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass200(any a0, any a1, any a2) { label_1: @@ -3028,7 +2913,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass201(any a0, any a1, any a2) { label_1: @@ -3041,7 +2925,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass202(any a0, any a1, any a2) { label_1: @@ -3054,7 +2937,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass203(any a0, any a1, any a2) { label_1: @@ -3067,7 +2949,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass204(any a0, any a1, any a2) { label_1: @@ -3080,7 +2961,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass205(any a0, any a1, any a2) { label_1: @@ -3093,7 +2973,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass206(any a0, any a1, any a2) { label_1: @@ -3106,7 +2985,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass207(any a0, any a1, any a2) { label_1: @@ -3119,7 +2997,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass208(any a0, any a1, any a2) { label_1: @@ -3132,7 +3009,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass209(any a0, any a1, any a2) { label_1: @@ -3145,7 +3021,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass21(any a0, any a1, any a2) { label_1: @@ -3158,7 +3033,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass210(any a0, any a1, any a2) { label_1: @@ -3171,7 +3045,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass211(any a0, any a1, any a2) { label_1: @@ -3184,7 +3057,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass212(any a0, any a1, any a2) { label_1: @@ -3197,7 +3069,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass213(any a0, any a1, any a2) { label_1: @@ -3210,7 +3081,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass214(any a0, any a1, any a2) { label_1: @@ -3223,7 +3093,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass215(any a0, any a1, any a2) { label_1: @@ -3236,7 +3105,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass216(any a0, any a1, any a2) { label_1: @@ -3249,7 +3117,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass217(any a0, any a1, any a2) { label_1: @@ -3262,7 +3129,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass218(any a0, any a1, any a2) { label_1: @@ -3275,7 +3141,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass219(any a0, any a1, any a2) { label_1: @@ -3288,7 +3153,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass22(any a0, any a1, any a2) { label_1: @@ -3301,7 +3165,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass220(any a0, any a1, any a2) { label_1: @@ -3314,7 +3177,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass221(any a0, any a1, any a2) { label_1: @@ -3327,7 +3189,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass222(any a0, any a1, any a2) { label_1: @@ -3340,7 +3201,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass223(any a0, any a1, any a2) { label_1: @@ -3353,7 +3213,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass224(any a0, any a1, any a2) { label_1: @@ -3366,7 +3225,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass225(any a0, any a1, any a2) { label_1: @@ -3379,7 +3237,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass226(any a0, any a1, any a2) { label_1: @@ -3392,7 +3249,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass227(any a0, any a1, any a2) { label_1: @@ -3405,7 +3261,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass228(any a0, any a1, any a2) { label_1: @@ -3418,7 +3273,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass229(any a0, any a1, any a2) { label_1: @@ -3431,7 +3285,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass23(any a0, any a1, any a2) { label_1: @@ -3444,7 +3297,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass230(any a0, any a1, any a2) { label_1: @@ -3457,7 +3309,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass231(any a0, any a1, any a2) { label_1: @@ -3470,7 +3321,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass232(any a0, any a1, any a2) { label_1: @@ -3483,7 +3333,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass233(any a0, any a1, any a2) { label_1: @@ -3496,7 +3345,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass234(any a0, any a1, any a2) { label_1: @@ -3509,7 +3357,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass235(any a0, any a1, any a2) { label_1: @@ -3522,7 +3369,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass236(any a0, any a1, any a2) { label_1: @@ -3535,7 +3381,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass237(any a0, any a1, any a2) { label_1: @@ -3548,7 +3393,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass238(any a0, any a1, any a2) { label_1: @@ -3561,7 +3405,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass239(any a0, any a1, any a2) { label_1: @@ -3574,7 +3417,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass24(any a0, any a1, any a2) { label_1: @@ -3587,7 +3429,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass240(any a0, any a1, any a2) { label_1: @@ -3600,7 +3441,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass241(any a0, any a1, any a2) { label_1: @@ -3613,7 +3453,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass242(any a0, any a1, any a2) { label_1: @@ -3626,7 +3465,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass243(any a0, any a1, any a2) { label_1: @@ -3639,7 +3477,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass244(any a0, any a1, any a2) { label_1: @@ -3652,7 +3489,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass245(any a0, any a1, any a2) { label_1: @@ -3665,7 +3501,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass246(any a0, any a1, any a2) { label_1: @@ -3678,7 +3513,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass247(any a0, any a1, any a2) { label_1: @@ -3691,7 +3525,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass248(any a0, any a1, any a2) { label_1: @@ -3704,7 +3537,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass249(any a0, any a1, any a2) { label_1: @@ -3717,7 +3549,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass25(any a0, any a1, any a2) { label_1: @@ -3730,7 +3561,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass250(any a0, any a1, any a2) { label_1: @@ -3743,7 +3573,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass251(any a0, any a1, any a2) { label_1: @@ -3756,7 +3585,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass252(any a0, any a1, any a2) { label_1: @@ -3769,7 +3597,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass253(any a0, any a1, any a2) { label_1: @@ -3782,7 +3609,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass254(any a0, any a1, any a2) { label_1: @@ -3795,7 +3621,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass255(any a0, any a1, any a2) { label_1: @@ -3808,7 +3633,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass26(any a0, any a1, any a2) { label_1: @@ -3821,7 +3645,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass27(any a0, any a1, any a2) { label_1: @@ -3834,7 +3657,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass28(any a0, any a1, any a2) { label_1: @@ -3847,7 +3669,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass29(any a0, any a1, any a2) { label_1: @@ -3860,7 +3681,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass3(any a0, any a1, any a2) { label_1: @@ -3873,7 +3693,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass30(any a0, any a1, any a2) { label_1: @@ -3886,7 +3705,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass31(any a0, any a1, any a2) { label_1: @@ -3899,7 +3717,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass32(any a0, any a1, any a2) { label_1: @@ -3912,7 +3729,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass33(any a0, any a1, any a2) { label_1: @@ -3925,7 +3741,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass34(any a0, any a1, any a2) { label_1: @@ -3938,7 +3753,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass35(any a0, any a1, any a2) { label_1: @@ -3951,7 +3765,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass36(any a0, any a1, any a2) { label_1: @@ -3964,7 +3777,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass37(any a0, any a1, any a2) { label_1: @@ -3977,7 +3789,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass38(any a0, any a1, any a2) { label_1: @@ -3990,7 +3801,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass39(any a0, any a1, any a2) { label_1: @@ -4003,7 +3813,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass4(any a0, any a1, any a2) { label_1: @@ -4016,7 +3825,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass40(any a0, any a1, any a2) { label_1: @@ -4029,7 +3837,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass41(any a0, any a1, any a2) { label_1: @@ -4042,7 +3849,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass42(any a0, any a1, any a2) { label_1: @@ -4055,7 +3861,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass43(any a0, any a1, any a2) { label_1: @@ -4068,7 +3873,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass44(any a0, any a1, any a2) { label_1: @@ -4081,7 +3885,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass45(any a0, any a1, any a2) { label_1: @@ -4094,7 +3897,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass46(any a0, any a1, any a2) { label_1: @@ -4107,7 +3909,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass47(any a0, any a1, any a2) { label_1: @@ -4120,7 +3921,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass48(any a0, any a1, any a2) { label_1: @@ -4133,7 +3933,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass49(any a0, any a1, any a2) { label_1: @@ -4146,7 +3945,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass5(any a0, any a1, any a2) { label_1: @@ -4159,7 +3957,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass50(any a0, any a1, any a2) { label_1: @@ -4172,7 +3969,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass51(any a0, any a1, any a2) { label_1: @@ -4185,7 +3981,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass52(any a0, any a1, any a2) { label_1: @@ -4198,7 +3993,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass53(any a0, any a1, any a2) { label_1: @@ -4211,7 +4005,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass54(any a0, any a1, any a2) { label_1: @@ -4224,7 +4017,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass55(any a0, any a1, any a2) { label_1: @@ -4237,7 +4029,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass56(any a0, any a1, any a2) { label_1: @@ -4250,7 +4041,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass57(any a0, any a1, any a2) { label_1: @@ -4263,7 +4053,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass58(any a0, any a1, any a2) { label_1: @@ -4276,7 +4065,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass59(any a0, any a1, any a2) { label_1: @@ -4289,7 +4077,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass6(any a0, any a1, any a2) { label_1: @@ -4302,7 +4089,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass60(any a0, any a1, any a2) { label_1: @@ -4315,7 +4101,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass61(any a0, any a1, any a2) { label_1: @@ -4328,7 +4113,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass62(any a0, any a1, any a2) { label_1: @@ -4341,7 +4125,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass63(any a0, any a1, any a2) { label_1: @@ -4354,7 +4137,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass64(any a0, any a1, any a2) { label_1: @@ -4367,7 +4149,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass65(any a0, any a1, any a2) { label_1: @@ -4380,7 +4161,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass66(any a0, any a1, any a2) { label_1: @@ -4393,7 +4173,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass67(any a0, any a1, any a2) { label_1: @@ -4406,7 +4185,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass68(any a0, any a1, any a2) { label_1: @@ -4419,7 +4197,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass69(any a0, any a1, any a2) { label_1: @@ -4432,7 +4209,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass7(any a0, any a1, any a2) { label_1: @@ -4445,7 +4221,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass70(any a0, any a1, any a2) { label_1: @@ -4458,7 +4233,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass71(any a0, any a1, any a2) { label_1: @@ -4471,7 +4245,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass72(any a0, any a1, any a2) { label_1: @@ -4484,7 +4257,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass73(any a0, any a1, any a2) { label_1: @@ -4497,7 +4269,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass74(any a0, any a1, any a2) { label_1: @@ -4510,7 +4281,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass75(any a0, any a1, any a2) { label_1: @@ -4523,7 +4293,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass76(any a0, any a1, any a2) { label_1: @@ -4536,7 +4305,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass77(any a0, any a1, any a2) { label_1: @@ -4549,7 +4317,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass78(any a0, any a1, any a2) { label_1: @@ -4562,7 +4329,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass79(any a0, any a1, any a2) { label_1: @@ -4575,7 +4341,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass8(any a0, any a1, any a2) { label_1: @@ -4588,7 +4353,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass80(any a0, any a1, any a2) { label_1: @@ -4601,7 +4365,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass81(any a0, any a1, any a2) { label_1: @@ -4614,7 +4377,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass82(any a0, any a1, any a2) { label_1: @@ -4627,7 +4389,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass83(any a0, any a1, any a2) { label_1: @@ -4640,7 +4401,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass84(any a0, any a1, any a2) { label_1: @@ -4653,7 +4413,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass85(any a0, any a1, any a2) { label_1: @@ -4666,7 +4425,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass86(any a0, any a1, any a2) { label_1: @@ -4679,7 +4437,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass87(any a0, any a1, any a2) { label_1: @@ -4692,7 +4449,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass88(any a0, any a1, any a2) { label_1: @@ -4705,7 +4461,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass89(any a0, any a1, any a2) { label_1: @@ -4718,7 +4473,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass9(any a0, any a1, any a2) { label_1: @@ -4731,7 +4485,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass90(any a0, any a1, any a2) { label_1: @@ -4744,7 +4497,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass91(any a0, any a1, any a2) { label_1: @@ -4757,7 +4509,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass92(any a0, any a1, any a2) { label_1: @@ -4770,7 +4521,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass93(any a0, any a1, any a2) { label_1: @@ -4783,7 +4533,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass94(any a0, any a1, any a2) { label_1: @@ -4796,7 +4545,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass95(any a0, any a1, any a2) { label_1: @@ -4809,7 +4557,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass96(any a0, any a1, any a2) { label_1: @@ -4822,7 +4569,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass97(any a0, any a1, any a2) { label_1: @@ -4835,7 +4581,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass98(any a0, any a1, any a2) { label_1: @@ -4848,7 +4593,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass99(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index 4eb345368c176d8b5040719e8de9e473f4083ea9..a21d8fc54382d39b1e5412f370182fd5e05e6bb2 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@0=#TopLevelSendableClass1(any a0, any a1, any a2) { label_1: @@ -12,7 +11,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@10=#TopLevelSendableClass17(any a0, any a1, any a2) { label_1: @@ -25,7 +23,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@11=#TopLevelSendableClass18(any a0, any a1, any a2) { label_1: @@ -38,7 +35,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@12=#TopLevelSendableClass19(any a0, any a1, any a2) { label_1: @@ -51,7 +47,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@13=#TopLevelSendableClass20(any a0, any a1, any a2) { label_1: @@ -64,7 +59,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@14=#TopLevelSendableClass21(any a0, any a1, any a2) { label_1: @@ -77,7 +71,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@15=#TopLevelSendableClass22(any a0, any a1, any a2) { label_1: @@ -90,7 +83,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@16=#TopLevelSendableClass23(any a0, any a1, any a2) { label_1: @@ -103,7 +95,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@17=#TopLevelSendableClass24(any a0, any a1, any a2) { label_1: @@ -116,7 +107,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@18=#TopLevelSendableClass25(any a0, any a1, any a2) { label_1: @@ -129,7 +119,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@19=#TopLevelSendableClass26(any a0, any a1, any a2) { label_1: @@ -142,7 +131,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@1=#TopLevelSendableClass2(any a0, any a1, any a2) { label_1: @@ -155,7 +143,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@1a=#TopLevelSendableClass27(any a0, any a1, any a2) { label_1: @@ -168,7 +155,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@1b=#TopLevelSendableClass28(any a0, any a1, any a2) { label_1: @@ -181,7 +167,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@1c=#TopLevelSendableClass29(any a0, any a1, any a2) { label_1: @@ -194,7 +179,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@1d=#TopLevelSendableClass30(any a0, any a1, any a2) { label_1: @@ -207,7 +191,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@1e=#TopLevelSendableClass31(any a0, any a1, any a2) { label_1: @@ -220,7 +203,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@1f=#TopLevelSendableClass32(any a0, any a1, any a2) { label_1: @@ -233,7 +215,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@20=#TopLevelSendableClass33(any a0, any a1, any a2) { label_1: @@ -246,7 +227,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@21=#TopLevelSendableClass34(any a0, any a1, any a2) { label_1: @@ -259,7 +239,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@22=#TopLevelSendableClass35(any a0, any a1, any a2) { label_1: @@ -272,7 +251,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@23=#TopLevelSendableClass36(any a0, any a1, any a2) { label_1: @@ -285,7 +263,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@24=#TopLevelSendableClass37(any a0, any a1, any a2) { label_1: @@ -298,7 +275,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@25=#TopLevelSendableClass38(any a0, any a1, any a2) { label_1: @@ -311,7 +287,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@26=#TopLevelSendableClass39(any a0, any a1, any a2) { label_1: @@ -324,7 +299,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@27=#TopLevelSendableClass40(any a0, any a1, any a2) { label_1: @@ -337,7 +311,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@28=#TopLevelSendableClass41(any a0, any a1, any a2) { label_1: @@ -350,7 +323,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@29=#TopLevelSendableClass42(any a0, any a1, any a2) { label_1: @@ -363,7 +335,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@2=#TopLevelSendableClass3(any a0, any a1, any a2) { label_1: @@ -376,7 +347,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@2a=#TopLevelSendableClass43(any a0, any a1, any a2) { label_1: @@ -389,7 +359,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@2b=#TopLevelSendableClass44(any a0, any a1, any a2) { label_1: @@ -402,7 +371,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@2c=#TopLevelSendableClass45(any a0, any a1, any a2) { label_1: @@ -415,7 +383,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@2d=#TopLevelSendableClass46(any a0, any a1, any a2) { label_1: @@ -428,7 +395,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@2e=#TopLevelSendableClass47(any a0, any a1, any a2) { label_1: @@ -441,7 +407,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@2f=#TopLevelSendableClass48(any a0, any a1, any a2) { label_1: @@ -454,7 +419,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@30=#TopLevelSendableClass49(any a0, any a1, any a2) { label_1: @@ -467,7 +431,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@31=#TopLevelSendableClass50(any a0, any a1, any a2) { label_1: @@ -480,7 +443,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@32=#TopLevelSendableClass51(any a0, any a1, any a2) { label_1: @@ -493,7 +455,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@33=#TopLevelSendableClass52(any a0, any a1, any a2) { label_1: @@ -506,7 +467,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@34=#TopLevelSendableClass53(any a0, any a1, any a2) { label_1: @@ -519,7 +479,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@35=#TopLevelSendableClass54(any a0, any a1, any a2) { label_1: @@ -532,7 +491,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@36=#TopLevelSendableClass55(any a0, any a1, any a2) { label_1: @@ -545,7 +503,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@37=#TopLevelSendableClass56(any a0, any a1, any a2) { label_1: @@ -558,7 +515,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@38=#TopLevelSendableClass57(any a0, any a1, any a2) { label_1: @@ -571,7 +527,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@39=#TopLevelSendableClass58(any a0, any a1, any a2) { label_1: @@ -584,7 +539,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@3=#TopLevelSendableClass4(any a0, any a1, any a2) { label_1: @@ -597,7 +551,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@3a=#TopLevelSendableClass59(any a0, any a1, any a2) { label_1: @@ -610,7 +563,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@3b=#TopLevelSendableClass60(any a0, any a1, any a2) { label_1: @@ -623,7 +575,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@3c=#TopLevelSendableClass61(any a0, any a1, any a2) { label_1: @@ -636,7 +587,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@3d=#TopLevelSendableClass62(any a0, any a1, any a2) { label_1: @@ -649,7 +599,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@3e=#TopLevelSendableClass63(any a0, any a1, any a2) { label_1: @@ -662,7 +611,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@3f=#TopLevelSendableClass64(any a0, any a1, any a2) { label_1: @@ -675,7 +623,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@40=#TopLevelSendableClass65(any a0, any a1, any a2) { label_1: @@ -688,7 +635,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@41=#TopLevelSendableClass66(any a0, any a1, any a2) { label_1: @@ -701,7 +647,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@42=#TopLevelSendableClass67(any a0, any a1, any a2) { label_1: @@ -714,7 +659,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@43=#TopLevelSendableClass68(any a0, any a1, any a2) { label_1: @@ -727,7 +671,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@44=#TopLevelSendableClass69(any a0, any a1, any a2) { label_1: @@ -740,7 +683,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@45=#TopLevelSendableClass70(any a0, any a1, any a2) { label_1: @@ -753,7 +695,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@46=#TopLevelSendableClass71(any a0, any a1, any a2) { label_1: @@ -766,7 +707,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@47=#TopLevelSendableClass72(any a0, any a1, any a2) { label_1: @@ -779,7 +719,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@48=#TopLevelSendableClass73(any a0, any a1, any a2) { label_1: @@ -792,7 +731,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@49=#TopLevelSendableClass74(any a0, any a1, any a2) { label_1: @@ -805,7 +743,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@4=#TopLevelSendableClass5(any a0, any a1, any a2) { label_1: @@ -818,7 +755,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@4a=#TopLevelSendableClass75(any a0, any a1, any a2) { label_1: @@ -831,7 +767,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@4b=#TopLevelSendableClass76(any a0, any a1, any a2) { label_1: @@ -844,7 +779,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@4c=#TopLevelSendableClass77(any a0, any a1, any a2) { label_1: @@ -857,7 +791,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@4d=#TopLevelSendableClass78(any a0, any a1, any a2) { label_1: @@ -870,7 +803,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@4e=#TopLevelSendableClass79(any a0, any a1, any a2) { label_1: @@ -883,7 +815,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@4f=#TopLevelSendableClass80(any a0, any a1, any a2) { label_1: @@ -896,7 +827,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@50=#TopLevelSendableClass81(any a0, any a1, any a2) { label_1: @@ -909,7 +839,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@51=#TopLevelSendableClass82(any a0, any a1, any a2) { label_1: @@ -922,7 +851,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@52=#TopLevelSendableClass83(any a0, any a1, any a2) { label_1: @@ -935,7 +863,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@53=#TopLevelSendableClass84(any a0, any a1, any a2) { label_1: @@ -948,7 +875,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@54=#TopLevelSendableClass85(any a0, any a1, any a2) { label_1: @@ -961,7 +887,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@55=#TopLevelSendableClass86(any a0, any a1, any a2) { label_1: @@ -974,7 +899,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@56=#TopLevelSendableClass87(any a0, any a1, any a2) { label_1: @@ -987,7 +911,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@57=#TopLevelSendableClass88(any a0, any a1, any a2) { label_1: @@ -1000,7 +923,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@58=#TopLevelSendableClass89(any a0, any a1, any a2) { label_1: @@ -1013,7 +935,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@59=#TopLevelSendableClass90(any a0, any a1, any a2) { label_1: @@ -1026,7 +947,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@5=#TopLevelSendableClass6(any a0, any a1, any a2) { label_1: @@ -1039,7 +959,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@5a=#TopLevelSendableClass91(any a0, any a1, any a2) { label_1: @@ -1052,7 +971,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@5b=#TopLevelSendableClass92(any a0, any a1, any a2) { label_1: @@ -1065,7 +983,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@5c=#TopLevelSendableClass93(any a0, any a1, any a2) { label_1: @@ -1078,7 +995,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@5d=#TopLevelSendableClass94(any a0, any a1, any a2) { label_1: @@ -1091,7 +1007,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@5e=#TopLevelSendableClass95(any a0, any a1, any a2) { label_1: @@ -1104,7 +1019,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@5f=#TopLevelSendableClass96(any a0, any a1, any a2) { label_1: @@ -1117,7 +1031,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@60=#TopLevelSendableClass97(any a0, any a1, any a2) { label_1: @@ -1130,7 +1043,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@61=#TopLevelSendableClass98(any a0, any a1, any a2) { label_1: @@ -1143,7 +1055,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@62=#TopLevelSendableClass99(any a0, any a1, any a2) { label_1: @@ -1156,7 +1067,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@63=#TopLevelSendableClass100(any a0, any a1, any a2) { label_1: @@ -1169,7 +1079,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@64=#TopLevelSendableClass101(any a0, any a1, any a2) { label_1: @@ -1182,7 +1091,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@65=#TopLevelSendableClass102(any a0, any a1, any a2) { label_1: @@ -1195,7 +1103,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@66=#TopLevelSendableClass103(any a0, any a1, any a2) { label_1: @@ -1208,7 +1115,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@67=#TopLevelSendableClass104(any a0, any a1, any a2) { label_1: @@ -1221,7 +1127,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@68=#TopLevelSendableClass105(any a0, any a1, any a2) { label_1: @@ -1234,7 +1139,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@69=#TopLevelSendableClass106(any a0, any a1, any a2) { label_1: @@ -1247,7 +1151,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@6=#TopLevelSendableClass7(any a0, any a1, any a2) { label_1: @@ -1260,7 +1163,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@6a=#TopLevelSendableClass107(any a0, any a1, any a2) { label_1: @@ -1273,7 +1175,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@6b=#TopLevelSendableClass108(any a0, any a1, any a2) { label_1: @@ -1286,7 +1187,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@6c=#TopLevelSendableClass109(any a0, any a1, any a2) { label_1: @@ -1299,7 +1199,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@6d=#TopLevelSendableClass110(any a0, any a1, any a2) { label_1: @@ -1312,7 +1211,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@6e=#TopLevelSendableClass111(any a0, any a1, any a2) { label_1: @@ -1325,7 +1223,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@6f=#TopLevelSendableClass112(any a0, any a1, any a2) { label_1: @@ -1338,7 +1235,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@70=#TopLevelSendableClass113(any a0, any a1, any a2) { label_1: @@ -1351,7 +1247,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@71=#TopLevelSendableClass114(any a0, any a1, any a2) { label_1: @@ -1364,7 +1259,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@72=#TopLevelSendableClass115(any a0, any a1, any a2) { label_1: @@ -1377,7 +1271,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@73=#TopLevelSendableClass116(any a0, any a1, any a2) { label_1: @@ -1390,7 +1283,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@74=#TopLevelSendableClass117(any a0, any a1, any a2) { label_1: @@ -1403,7 +1295,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@75=#TopLevelSendableClass118(any a0, any a1, any a2) { label_1: @@ -1416,7 +1307,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@76=#TopLevelSendableClass119(any a0, any a1, any a2) { label_1: @@ -1429,7 +1319,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@77=#TopLevelSendableClass120(any a0, any a1, any a2) { label_1: @@ -1442,7 +1331,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@78=#TopLevelSendableClass121(any a0, any a1, any a2) { label_1: @@ -1455,7 +1343,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@79=#TopLevelSendableClass122(any a0, any a1, any a2) { label_1: @@ -1468,7 +1355,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@7=#TopLevelSendableClass8(any a0, any a1, any a2) { label_1: @@ -1481,7 +1367,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@7a=#TopLevelSendableClass123(any a0, any a1, any a2) { label_1: @@ -1494,7 +1379,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@7b=#TopLevelSendableClass124(any a0, any a1, any a2) { label_1: @@ -1507,7 +1391,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@7c=#TopLevelSendableClass125(any a0, any a1, any a2) { label_1: @@ -1520,7 +1403,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@7d=#TopLevelSendableClass126(any a0, any a1, any a2) { label_1: @@ -1533,7 +1415,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@7e=#TopLevelSendableClass127(any a0, any a1, any a2) { label_1: @@ -1546,7 +1427,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@7f=#TopLevelSendableClass128(any a0, any a1, any a2) { label_1: @@ -1559,7 +1439,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@80=#TopLevelSendableClass129(any a0, any a1, any a2) { label_1: @@ -1572,7 +1451,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@81=#TopLevelSendableClass130(any a0, any a1, any a2) { label_1: @@ -1585,7 +1463,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@82=#TopLevelSendableClass131(any a0, any a1, any a2) { label_1: @@ -1598,7 +1475,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@83=#TopLevelSendableClass132(any a0, any a1, any a2) { label_1: @@ -1611,7 +1487,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@84=#TopLevelSendableClass133(any a0, any a1, any a2) { label_1: @@ -1624,7 +1499,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@85=#TopLevelSendableClass134(any a0, any a1, any a2) { label_1: @@ -1637,7 +1511,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@86=#TopLevelSendableClass135(any a0, any a1, any a2) { label_1: @@ -1650,7 +1523,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@87=#TopLevelSendableClass136(any a0, any a1, any a2) { label_1: @@ -1663,7 +1535,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@88=#TopLevelSendableClass137(any a0, any a1, any a2) { label_1: @@ -1676,7 +1547,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@89=#TopLevelSendableClass138(any a0, any a1, any a2) { label_1: @@ -1689,7 +1559,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@8=#TopLevelSendableClass9(any a0, any a1, any a2) { label_1: @@ -1702,7 +1571,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@8a=#TopLevelSendableClass139(any a0, any a1, any a2) { label_1: @@ -1715,7 +1583,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@8b=#TopLevelSendableClass140(any a0, any a1, any a2) { label_1: @@ -1728,7 +1595,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@8c=#TopLevelSendableClass141(any a0, any a1, any a2) { label_1: @@ -1741,7 +1607,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@8d=#TopLevelSendableClass142(any a0, any a1, any a2) { label_1: @@ -1754,7 +1619,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@8e=#TopLevelSendableClass143(any a0, any a1, any a2) { label_1: @@ -1767,7 +1631,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@8f=#TopLevelSendableClass144(any a0, any a1, any a2) { label_1: @@ -1780,7 +1643,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@90=#TopLevelSendableClass145(any a0, any a1, any a2) { label_1: @@ -1793,7 +1655,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@91=#TopLevelSendableClass146(any a0, any a1, any a2) { label_1: @@ -1806,7 +1667,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@92=#TopLevelSendableClass147(any a0, any a1, any a2) { label_1: @@ -1819,7 +1679,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@93=#TopLevelSendableClass148(any a0, any a1, any a2) { label_1: @@ -1832,7 +1691,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@94=#TopLevelSendableClass149(any a0, any a1, any a2) { label_1: @@ -1845,7 +1703,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@95=#TopLevelSendableClass150(any a0, any a1, any a2) { label_1: @@ -1858,7 +1715,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@96=#TopLevelSendableClass151(any a0, any a1, any a2) { label_1: @@ -1871,7 +1727,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@97=#TopLevelSendableClass152(any a0, any a1, any a2) { label_1: @@ -1884,7 +1739,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@98=#TopLevelSendableClass153(any a0, any a1, any a2) { label_1: @@ -1897,7 +1751,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@99=#TopLevelSendableClass154(any a0, any a1, any a2) { label_1: @@ -1910,7 +1763,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@9=#TopLevelSendableClass10(any a0, any a1, any a2) { label_1: @@ -1923,7 +1775,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@9a=#TopLevelSendableClass155(any a0, any a1, any a2) { label_1: @@ -1936,7 +1787,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@9b=#TopLevelSendableClass156(any a0, any a1, any a2) { label_1: @@ -1949,7 +1799,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@9c=#TopLevelSendableClass157(any a0, any a1, any a2) { label_1: @@ -1962,7 +1811,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@9d=#TopLevelSendableClass158(any a0, any a1, any a2) { label_1: @@ -1975,7 +1823,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@9e=#TopLevelSendableClass159(any a0, any a1, any a2) { label_1: @@ -1988,7 +1835,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@9f=#TopLevelSendableClass160(any a0, any a1, any a2) { label_1: @@ -2001,7 +1847,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a0=#TopLevelSendableClass161(any a0, any a1, any a2) { label_1: @@ -2014,7 +1859,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a1=#TopLevelSendableClass162(any a0, any a1, any a2) { label_1: @@ -2027,7 +1871,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a2=#TopLevelSendableClass163(any a0, any a1, any a2) { label_1: @@ -2040,7 +1883,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a3=#TopLevelSendableClass164(any a0, any a1, any a2) { label_1: @@ -2053,7 +1895,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a4=#TopLevelSendableClass165(any a0, any a1, any a2) { label_1: @@ -2066,7 +1907,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a5=#TopLevelSendableClass166(any a0, any a1, any a2) { label_1: @@ -2079,7 +1919,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a6=#TopLevelSendableClass167(any a0, any a1, any a2) { label_1: @@ -2092,7 +1931,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a7=#TopLevelSendableClass168(any a0, any a1, any a2) { label_1: @@ -2105,7 +1943,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a8=#TopLevelSendableClass169(any a0, any a1, any a2) { label_1: @@ -2118,7 +1955,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a9=#TopLevelSendableClass170(any a0, any a1, any a2) { label_1: @@ -2131,7 +1967,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@a=#TopLevelSendableClass11(any a0, any a1, any a2) { label_1: @@ -2144,7 +1979,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@aa=#TopLevelSendableClass171(any a0, any a1, any a2) { label_1: @@ -2157,7 +1991,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ab=#TopLevelSendableClass172(any a0, any a1, any a2) { label_1: @@ -2170,7 +2003,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ac=#TopLevelSendableClass173(any a0, any a1, any a2) { label_1: @@ -2183,7 +2015,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ad=#TopLevelSendableClass174(any a0, any a1, any a2) { label_1: @@ -2196,7 +2027,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ae=#TopLevelSendableClass175(any a0, any a1, any a2) { label_1: @@ -2209,7 +2039,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@af=#TopLevelSendableClass176(any a0, any a1, any a2) { label_1: @@ -2222,7 +2051,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b0=#TopLevelSendableClass177(any a0, any a1, any a2) { label_1: @@ -2235,7 +2063,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b1=#TopLevelSendableClass178(any a0, any a1, any a2) { label_1: @@ -2248,7 +2075,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b2=#TopLevelSendableClass179(any a0, any a1, any a2) { label_1: @@ -2261,7 +2087,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b3=#TopLevelSendableClass180(any a0, any a1, any a2) { label_1: @@ -2274,7 +2099,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b4=#TopLevelSendableClass181(any a0, any a1, any a2) { label_1: @@ -2287,7 +2111,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b5=#TopLevelSendableClass182(any a0, any a1, any a2) { label_1: @@ -2300,7 +2123,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b6=#TopLevelSendableClass183(any a0, any a1, any a2) { label_1: @@ -2313,7 +2135,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b7=#TopLevelSendableClass184(any a0, any a1, any a2) { label_1: @@ -2326,7 +2147,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b8=#TopLevelSendableClass185(any a0, any a1, any a2) { label_1: @@ -2339,7 +2159,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b9=#TopLevelSendableClass186(any a0, any a1, any a2) { label_1: @@ -2352,7 +2171,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@b=#TopLevelSendableClass12(any a0, any a1, any a2) { label_1: @@ -2365,7 +2183,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ba=#TopLevelSendableClass187(any a0, any a1, any a2) { label_1: @@ -2378,7 +2195,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@bb=#TopLevelSendableClass188(any a0, any a1, any a2) { label_1: @@ -2391,7 +2207,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@bc=#TopLevelSendableClass189(any a0, any a1, any a2) { label_1: @@ -2404,7 +2219,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@bd=#TopLevelSendableClass190(any a0, any a1, any a2) { label_1: @@ -2417,7 +2231,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@be=#TopLevelSendableClass191(any a0, any a1, any a2) { label_1: @@ -2430,7 +2243,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@bf=#TopLevelSendableClass192(any a0, any a1, any a2) { label_1: @@ -2443,7 +2255,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c0=#TopLevelSendableClass193(any a0, any a1, any a2) { label_1: @@ -2456,7 +2267,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c1=#TopLevelSendableClass194(any a0, any a1, any a2) { label_1: @@ -2469,7 +2279,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c2=#TopLevelSendableClass195(any a0, any a1, any a2) { label_1: @@ -2482,7 +2291,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c3=#TopLevelSendableClass196(any a0, any a1, any a2) { label_1: @@ -2495,7 +2303,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c4=#TopLevelSendableClass197(any a0, any a1, any a2) { label_1: @@ -2508,7 +2315,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c5=#TopLevelSendableClass198(any a0, any a1, any a2) { label_1: @@ -2521,7 +2327,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c6=#TopLevelSendableClass199(any a0, any a1, any a2) { label_1: @@ -2534,7 +2339,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c7=#TopLevelSendableClass200(any a0, any a1, any a2) { label_1: @@ -2547,7 +2351,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c8=#TopLevelSendableClass201(any a0, any a1, any a2) { label_1: @@ -2560,7 +2363,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c9=#TopLevelSendableClass202(any a0, any a1, any a2) { label_1: @@ -2573,7 +2375,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@c=#TopLevelSendableClass13(any a0, any a1, any a2) { label_1: @@ -2586,7 +2387,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ca=#TopLevelSendableClass203(any a0, any a1, any a2) { label_1: @@ -2599,7 +2399,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@cb=#TopLevelSendableClass204(any a0, any a1, any a2) { label_1: @@ -2612,7 +2411,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@cc=#TopLevelSendableClass205(any a0, any a1, any a2) { label_1: @@ -2625,7 +2423,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@cd=#TopLevelSendableClass206(any a0, any a1, any a2) { label_1: @@ -2638,7 +2435,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ce=#TopLevelSendableClass207(any a0, any a1, any a2) { label_1: @@ -2651,7 +2447,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@cf=#TopLevelSendableClass208(any a0, any a1, any a2) { label_1: @@ -2664,7 +2459,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d0=#TopLevelSendableClass209(any a0, any a1, any a2) { label_1: @@ -2677,7 +2471,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d1=#TopLevelSendableClass210(any a0, any a1, any a2) { label_1: @@ -2690,7 +2483,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d2=#TopLevelSendableClass211(any a0, any a1, any a2) { label_1: @@ -2703,7 +2495,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d3=#TopLevelSendableClass212(any a0, any a1, any a2) { label_1: @@ -2716,7 +2507,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d4=#TopLevelSendableClass213(any a0, any a1, any a2) { label_1: @@ -2729,7 +2519,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d5=#TopLevelSendableClass214(any a0, any a1, any a2) { label_1: @@ -2742,7 +2531,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d6=#TopLevelSendableClass215(any a0, any a1, any a2) { label_1: @@ -2755,7 +2543,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d7=#TopLevelSendableClass216(any a0, any a1, any a2) { label_1: @@ -2768,7 +2555,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d8=#TopLevelSendableClass217(any a0, any a1, any a2) { label_1: @@ -2781,7 +2567,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d9=#TopLevelSendableClass218(any a0, any a1, any a2) { label_1: @@ -2794,7 +2579,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@d=#TopLevelSendableClass14(any a0, any a1, any a2) { label_1: @@ -2807,7 +2591,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@da=#TopLevelSendableClass219(any a0, any a1, any a2) { label_1: @@ -2820,7 +2603,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@db=#TopLevelSendableClass220(any a0, any a1, any a2) { label_1: @@ -2833,7 +2615,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@dc=#TopLevelSendableClass221(any a0, any a1, any a2) { label_1: @@ -2846,7 +2627,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@dd=#TopLevelSendableClass222(any a0, any a1, any a2) { label_1: @@ -2859,7 +2639,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@de=#TopLevelSendableClass223(any a0, any a1, any a2) { label_1: @@ -2872,7 +2651,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@df=#TopLevelSendableClass224(any a0, any a1, any a2) { label_1: @@ -2885,7 +2663,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e0=#TopLevelSendableClass225(any a0, any a1, any a2) { label_1: @@ -2898,7 +2675,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e1=#TopLevelSendableClass226(any a0, any a1, any a2) { label_1: @@ -2911,7 +2687,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e2=#TopLevelSendableClass227(any a0, any a1, any a2) { label_1: @@ -2924,7 +2699,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e3=#TopLevelSendableClass228(any a0, any a1, any a2) { label_1: @@ -2937,7 +2711,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e4=#TopLevelSendableClass229(any a0, any a1, any a2) { label_1: @@ -2950,7 +2723,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e5=#TopLevelSendableClass230(any a0, any a1, any a2) { label_1: @@ -2963,7 +2735,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e6=#TopLevelSendableClass231(any a0, any a1, any a2) { label_1: @@ -2976,7 +2747,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e7=#TopLevelSendableClass232(any a0, any a1, any a2) { label_1: @@ -2989,7 +2759,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e8=#TopLevelSendableClass233(any a0, any a1, any a2) { label_1: @@ -3002,7 +2771,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e9=#TopLevelSendableClass234(any a0, any a1, any a2) { label_1: @@ -3015,7 +2783,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@e=#TopLevelSendableClass15(any a0, any a1, any a2) { label_1: @@ -3028,7 +2795,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ea=#TopLevelSendableClass235(any a0, any a1, any a2) { label_1: @@ -3041,7 +2807,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@eb=#TopLevelSendableClass236(any a0, any a1, any a2) { label_1: @@ -3054,7 +2819,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ec=#TopLevelSendableClass237(any a0, any a1, any a2) { label_1: @@ -3067,7 +2831,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ed=#TopLevelSendableClass238(any a0, any a1, any a2) { label_1: @@ -3080,7 +2843,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ee=#TopLevelSendableClass239(any a0, any a1, any a2) { label_1: @@ -3093,7 +2855,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@ef=#TopLevelSendableClass240(any a0, any a1, any a2) { label_1: @@ -3106,7 +2867,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f0=#TopLevelSendableClass241(any a0, any a1, any a2) { label_1: @@ -3119,7 +2879,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f1=#TopLevelSendableClass242(any a0, any a1, any a2) { label_1: @@ -3132,7 +2891,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f2=#TopLevelSendableClass243(any a0, any a1, any a2) { label_1: @@ -3145,7 +2903,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f3=#TopLevelSendableClass244(any a0, any a1, any a2) { label_1: @@ -3158,7 +2915,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f4=#TopLevelSendableClass245(any a0, any a1, any a2) { label_1: @@ -3171,7 +2927,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f5=#TopLevelSendableClass246(any a0, any a1, any a2) { label_1: @@ -3184,7 +2939,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f6=#TopLevelSendableClass247(any a0, any a1, any a2) { label_1: @@ -3197,7 +2951,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f7=#TopLevelSendableClass248(any a0, any a1, any a2) { label_1: @@ -3210,7 +2963,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f8=#TopLevelSendableClass249(any a0, any a1, any a2) { label_1: @@ -3223,7 +2975,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f9=#TopLevelSendableClass250(any a0, any a1, any a2) { label_1: @@ -3236,7 +2987,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@f=#TopLevelSendableClass16(any a0, any a1, any a2) { label_1: @@ -3249,7 +2999,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@fa=#TopLevelSendableClass251(any a0, any a1, any a2) { label_1: @@ -3262,7 +3011,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@fb=#TopLevelSendableClass252(any a0, any a1, any a2) { label_1: @@ -3275,7 +3023,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@fc=#TopLevelSendableClass253(any a0, any a1, any a2) { label_1: @@ -3288,7 +3035,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@fd=#TopLevelSendableClass254(any a0, any a1, any a2) { label_1: @@ -3301,7 +3047,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@fe=#TopLevelSendableClass255(any a0, any a1, any a2) { label_1: @@ -3314,7 +3059,6 @@ label_2: } slotNum = 0x406 -expectedProperty = 0x101 .language ECMAScript .function any .#~@ff=#SendableTestClass1(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..4eb345368c176d8b5040719e8de9e473f4083ea9 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,5907 @@ +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@0=#TopLevelSendableClass1(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@10=#TopLevelSendableClass17(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@11=#TopLevelSendableClass18(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@12=#TopLevelSendableClass19(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@13=#TopLevelSendableClass20(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@14=#TopLevelSendableClass21(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@15=#TopLevelSendableClass22(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@16=#TopLevelSendableClass23(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@17=#TopLevelSendableClass24(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@18=#TopLevelSendableClass25(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@19=#TopLevelSendableClass26(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@1=#TopLevelSendableClass2(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@1a=#TopLevelSendableClass27(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@1b=#TopLevelSendableClass28(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@1c=#TopLevelSendableClass29(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@1d=#TopLevelSendableClass30(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@1e=#TopLevelSendableClass31(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@1f=#TopLevelSendableClass32(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@20=#TopLevelSendableClass33(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@21=#TopLevelSendableClass34(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@22=#TopLevelSendableClass35(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@23=#TopLevelSendableClass36(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@24=#TopLevelSendableClass37(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@25=#TopLevelSendableClass38(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@26=#TopLevelSendableClass39(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@27=#TopLevelSendableClass40(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@28=#TopLevelSendableClass41(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@29=#TopLevelSendableClass42(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@2=#TopLevelSendableClass3(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@2a=#TopLevelSendableClass43(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@2b=#TopLevelSendableClass44(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@2c=#TopLevelSendableClass45(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@2d=#TopLevelSendableClass46(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@2e=#TopLevelSendableClass47(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@2f=#TopLevelSendableClass48(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@30=#TopLevelSendableClass49(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@31=#TopLevelSendableClass50(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@32=#TopLevelSendableClass51(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@33=#TopLevelSendableClass52(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@34=#TopLevelSendableClass53(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@35=#TopLevelSendableClass54(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@36=#TopLevelSendableClass55(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@37=#TopLevelSendableClass56(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@38=#TopLevelSendableClass57(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@39=#TopLevelSendableClass58(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@3=#TopLevelSendableClass4(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@3a=#TopLevelSendableClass59(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@3b=#TopLevelSendableClass60(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@3c=#TopLevelSendableClass61(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@3d=#TopLevelSendableClass62(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@3e=#TopLevelSendableClass63(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@3f=#TopLevelSendableClass64(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@40=#TopLevelSendableClass65(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@41=#TopLevelSendableClass66(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@42=#TopLevelSendableClass67(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@43=#TopLevelSendableClass68(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@44=#TopLevelSendableClass69(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@45=#TopLevelSendableClass70(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@46=#TopLevelSendableClass71(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@47=#TopLevelSendableClass72(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@48=#TopLevelSendableClass73(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@49=#TopLevelSendableClass74(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@4=#TopLevelSendableClass5(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@4a=#TopLevelSendableClass75(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@4b=#TopLevelSendableClass76(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@4c=#TopLevelSendableClass77(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@4d=#TopLevelSendableClass78(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@4e=#TopLevelSendableClass79(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@4f=#TopLevelSendableClass80(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@50=#TopLevelSendableClass81(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@51=#TopLevelSendableClass82(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@52=#TopLevelSendableClass83(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@53=#TopLevelSendableClass84(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@54=#TopLevelSendableClass85(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@55=#TopLevelSendableClass86(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@56=#TopLevelSendableClass87(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@57=#TopLevelSendableClass88(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@58=#TopLevelSendableClass89(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@59=#TopLevelSendableClass90(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@5=#TopLevelSendableClass6(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@5a=#TopLevelSendableClass91(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@5b=#TopLevelSendableClass92(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@5c=#TopLevelSendableClass93(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@5d=#TopLevelSendableClass94(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@5e=#TopLevelSendableClass95(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@5f=#TopLevelSendableClass96(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@60=#TopLevelSendableClass97(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@61=#TopLevelSendableClass98(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@62=#TopLevelSendableClass99(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@63=#TopLevelSendableClass100(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@64=#TopLevelSendableClass101(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@65=#TopLevelSendableClass102(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@66=#TopLevelSendableClass103(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@67=#TopLevelSendableClass104(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@68=#TopLevelSendableClass105(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@69=#TopLevelSendableClass106(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@6=#TopLevelSendableClass7(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@6a=#TopLevelSendableClass107(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@6b=#TopLevelSendableClass108(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@6c=#TopLevelSendableClass109(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@6d=#TopLevelSendableClass110(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@6e=#TopLevelSendableClass111(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@6f=#TopLevelSendableClass112(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@70=#TopLevelSendableClass113(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@71=#TopLevelSendableClass114(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@72=#TopLevelSendableClass115(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@73=#TopLevelSendableClass116(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@74=#TopLevelSendableClass117(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@75=#TopLevelSendableClass118(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@76=#TopLevelSendableClass119(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@77=#TopLevelSendableClass120(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@78=#TopLevelSendableClass121(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@79=#TopLevelSendableClass122(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@7=#TopLevelSendableClass8(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@7a=#TopLevelSendableClass123(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@7b=#TopLevelSendableClass124(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@7c=#TopLevelSendableClass125(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@7d=#TopLevelSendableClass126(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@7e=#TopLevelSendableClass127(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@7f=#TopLevelSendableClass128(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@80=#TopLevelSendableClass129(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@81=#TopLevelSendableClass130(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@82=#TopLevelSendableClass131(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@83=#TopLevelSendableClass132(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@84=#TopLevelSendableClass133(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@85=#TopLevelSendableClass134(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@86=#TopLevelSendableClass135(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@87=#TopLevelSendableClass136(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@88=#TopLevelSendableClass137(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@89=#TopLevelSendableClass138(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@8=#TopLevelSendableClass9(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@8a=#TopLevelSendableClass139(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@8b=#TopLevelSendableClass140(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@8c=#TopLevelSendableClass141(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@8d=#TopLevelSendableClass142(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@8e=#TopLevelSendableClass143(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@8f=#TopLevelSendableClass144(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@90=#TopLevelSendableClass145(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@91=#TopLevelSendableClass146(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@92=#TopLevelSendableClass147(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@93=#TopLevelSendableClass148(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@94=#TopLevelSendableClass149(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@95=#TopLevelSendableClass150(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@96=#TopLevelSendableClass151(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@97=#TopLevelSendableClass152(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@98=#TopLevelSendableClass153(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@99=#TopLevelSendableClass154(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@9=#TopLevelSendableClass10(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@9a=#TopLevelSendableClass155(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@9b=#TopLevelSendableClass156(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@9c=#TopLevelSendableClass157(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@9d=#TopLevelSendableClass158(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@9e=#TopLevelSendableClass159(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@9f=#TopLevelSendableClass160(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a0=#TopLevelSendableClass161(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a1=#TopLevelSendableClass162(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a2=#TopLevelSendableClass163(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a3=#TopLevelSendableClass164(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a4=#TopLevelSendableClass165(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a5=#TopLevelSendableClass166(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a6=#TopLevelSendableClass167(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a7=#TopLevelSendableClass168(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a8=#TopLevelSendableClass169(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a9=#TopLevelSendableClass170(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@a=#TopLevelSendableClass11(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@aa=#TopLevelSendableClass171(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ab=#TopLevelSendableClass172(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ac=#TopLevelSendableClass173(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ad=#TopLevelSendableClass174(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ae=#TopLevelSendableClass175(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@af=#TopLevelSendableClass176(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b0=#TopLevelSendableClass177(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b1=#TopLevelSendableClass178(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b2=#TopLevelSendableClass179(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b3=#TopLevelSendableClass180(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b4=#TopLevelSendableClass181(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b5=#TopLevelSendableClass182(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b6=#TopLevelSendableClass183(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b7=#TopLevelSendableClass184(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b8=#TopLevelSendableClass185(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b9=#TopLevelSendableClass186(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@b=#TopLevelSendableClass12(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ba=#TopLevelSendableClass187(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@bb=#TopLevelSendableClass188(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@bc=#TopLevelSendableClass189(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@bd=#TopLevelSendableClass190(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@be=#TopLevelSendableClass191(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@bf=#TopLevelSendableClass192(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c0=#TopLevelSendableClass193(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c1=#TopLevelSendableClass194(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c2=#TopLevelSendableClass195(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c3=#TopLevelSendableClass196(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c4=#TopLevelSendableClass197(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c5=#TopLevelSendableClass198(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c6=#TopLevelSendableClass199(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c7=#TopLevelSendableClass200(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c8=#TopLevelSendableClass201(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c9=#TopLevelSendableClass202(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@c=#TopLevelSendableClass13(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ca=#TopLevelSendableClass203(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@cb=#TopLevelSendableClass204(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@cc=#TopLevelSendableClass205(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@cd=#TopLevelSendableClass206(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ce=#TopLevelSendableClass207(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@cf=#TopLevelSendableClass208(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d0=#TopLevelSendableClass209(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d1=#TopLevelSendableClass210(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d2=#TopLevelSendableClass211(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d3=#TopLevelSendableClass212(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d4=#TopLevelSendableClass213(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d5=#TopLevelSendableClass214(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d6=#TopLevelSendableClass215(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d7=#TopLevelSendableClass216(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d8=#TopLevelSendableClass217(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d9=#TopLevelSendableClass218(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@d=#TopLevelSendableClass14(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@da=#TopLevelSendableClass219(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@db=#TopLevelSendableClass220(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@dc=#TopLevelSendableClass221(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@dd=#TopLevelSendableClass222(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@de=#TopLevelSendableClass223(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@df=#TopLevelSendableClass224(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e0=#TopLevelSendableClass225(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e1=#TopLevelSendableClass226(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e2=#TopLevelSendableClass227(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e3=#TopLevelSendableClass228(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e4=#TopLevelSendableClass229(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e5=#TopLevelSendableClass230(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e6=#TopLevelSendableClass231(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e7=#TopLevelSendableClass232(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e8=#TopLevelSendableClass233(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e9=#TopLevelSendableClass234(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@e=#TopLevelSendableClass15(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ea=#TopLevelSendableClass235(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@eb=#TopLevelSendableClass236(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ec=#TopLevelSendableClass237(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ed=#TopLevelSendableClass238(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ee=#TopLevelSendableClass239(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@ef=#TopLevelSendableClass240(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f0=#TopLevelSendableClass241(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f1=#TopLevelSendableClass242(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f2=#TopLevelSendableClass243(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f3=#TopLevelSendableClass244(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f4=#TopLevelSendableClass245(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f5=#TopLevelSendableClass246(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f6=#TopLevelSendableClass247(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f7=#TopLevelSendableClass248(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f8=#TopLevelSendableClass249(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f9=#TopLevelSendableClass250(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@f=#TopLevelSendableClass16(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@fa=#TopLevelSendableClass251(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@fb=#TopLevelSendableClass252(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@fc=#TopLevelSendableClass253(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@fd=#TopLevelSendableClass254(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@fe=#TopLevelSendableClass255(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x406 +expectedProperty = 0x101 +.language ECMAScript +.function any .#~@ff=#SendableTestClass1(any a0, any a1, any a2) { +label_1: +label_0: + callruntime.ldsendablevar 0x0, 0x0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass1 + mov v1, v0 + newobjrange 0x0, 0x1, v1 + stobjbyname 0x2, a1, a2 + callruntime.ldsendablevar 0x0, 0x1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass2 + mov v1, v0 + newobjrange 0x4, 0x1, v1 + stobjbyname 0x6, a2, a2 + callruntime.ldsendablevar 0x0, 0x2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass3 + mov v1, v0 + newobjrange 0x8, 0x1, v1 + stobjbyname 0xa, a3, a2 + callruntime.ldsendablevar 0x0, 0x3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass4 + mov v1, v0 + newobjrange 0xc, 0x1, v1 + stobjbyname 0xe, a4, a2 + callruntime.ldsendablevar 0x0, 0x4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass5 + mov v1, v0 + newobjrange 0x10, 0x1, v1 + stobjbyname 0x12, a5, a2 + callruntime.ldsendablevar 0x0, 0x5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass6 + mov v1, v0 + newobjrange 0x14, 0x1, v1 + stobjbyname 0x16, a6, a2 + callruntime.ldsendablevar 0x0, 0x6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass7 + mov v1, v0 + newobjrange 0x18, 0x1, v1 + stobjbyname 0x1a, a7, a2 + callruntime.ldsendablevar 0x0, 0x7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass8 + mov v1, v0 + newobjrange 0x1c, 0x1, v1 + stobjbyname 0x1e, a8, a2 + callruntime.ldsendablevar 0x0, 0x8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass9 + mov v1, v0 + newobjrange 0x20, 0x1, v1 + stobjbyname 0x22, a9, a2 + callruntime.ldsendablevar 0x0, 0x9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass10 + mov v1, v0 + newobjrange 0x24, 0x1, v1 + stobjbyname 0x26, a10, a2 + callruntime.ldsendablevar 0x0, 0xa + sta v0 + throw.undefinedifholewithname TopLevelSendableClass11 + mov v1, v0 + newobjrange 0x28, 0x1, v1 + stobjbyname 0x2a, a11, a2 + callruntime.ldsendablevar 0x0, 0xb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass12 + mov v1, v0 + newobjrange 0x2c, 0x1, v1 + stobjbyname 0x2e, a12, a2 + callruntime.ldsendablevar 0x0, 0xc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass13 + mov v1, v0 + newobjrange 0x30, 0x1, v1 + stobjbyname 0x32, a13, a2 + callruntime.ldsendablevar 0x0, 0xd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass14 + mov v1, v0 + newobjrange 0x34, 0x1, v1 + stobjbyname 0x36, a14, a2 + callruntime.ldsendablevar 0x0, 0xe + sta v0 + throw.undefinedifholewithname TopLevelSendableClass15 + mov v1, v0 + newobjrange 0x38, 0x1, v1 + stobjbyname 0x3a, a15, a2 + callruntime.ldsendablevar 0x0, 0xf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass16 + mov v1, v0 + newobjrange 0x3c, 0x1, v1 + stobjbyname 0x3e, a16, a2 + callruntime.ldsendablevar 0x0, 0x10 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass17 + mov v1, v0 + newobjrange 0x40, 0x1, v1 + stobjbyname 0x42, a17, a2 + callruntime.ldsendablevar 0x0, 0x11 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass18 + mov v1, v0 + newobjrange 0x44, 0x1, v1 + stobjbyname 0x46, a18, a2 + callruntime.ldsendablevar 0x0, 0x12 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass19 + mov v1, v0 + newobjrange 0x48, 0x1, v1 + stobjbyname 0x4a, a19, a2 + callruntime.ldsendablevar 0x0, 0x13 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass20 + mov v1, v0 + newobjrange 0x4c, 0x1, v1 + stobjbyname 0x4e, a20, a2 + callruntime.ldsendablevar 0x0, 0x14 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass21 + mov v1, v0 + newobjrange 0x50, 0x1, v1 + stobjbyname 0x52, a21, a2 + callruntime.ldsendablevar 0x0, 0x15 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass22 + mov v1, v0 + newobjrange 0x54, 0x1, v1 + stobjbyname 0x56, a22, a2 + callruntime.ldsendablevar 0x0, 0x16 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass23 + mov v1, v0 + newobjrange 0x58, 0x1, v1 + stobjbyname 0x5a, a23, a2 + callruntime.ldsendablevar 0x0, 0x17 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass24 + mov v1, v0 + newobjrange 0x5c, 0x1, v1 + stobjbyname 0x5e, a24, a2 + callruntime.ldsendablevar 0x0, 0x18 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass25 + mov v1, v0 + newobjrange 0x60, 0x1, v1 + stobjbyname 0x62, a25, a2 + callruntime.ldsendablevar 0x0, 0x19 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass26 + mov v1, v0 + newobjrange 0x64, 0x1, v1 + stobjbyname 0x66, a26, a2 + callruntime.ldsendablevar 0x0, 0x1a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass27 + mov v1, v0 + newobjrange 0x68, 0x1, v1 + stobjbyname 0x6a, a27, a2 + callruntime.ldsendablevar 0x0, 0x1b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass28 + mov v1, v0 + newobjrange 0x6c, 0x1, v1 + stobjbyname 0x6e, a28, a2 + callruntime.ldsendablevar 0x0, 0x1c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass29 + mov v1, v0 + newobjrange 0x70, 0x1, v1 + stobjbyname 0x72, a29, a2 + callruntime.ldsendablevar 0x0, 0x1d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass30 + mov v1, v0 + newobjrange 0x74, 0x1, v1 + stobjbyname 0x76, a30, a2 + callruntime.ldsendablevar 0x0, 0x1e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass31 + mov v1, v0 + newobjrange 0x78, 0x1, v1 + stobjbyname 0x7a, a31, a2 + callruntime.ldsendablevar 0x0, 0x1f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass32 + mov v1, v0 + newobjrange 0x7c, 0x1, v1 + stobjbyname 0x7e, a32, a2 + callruntime.ldsendablevar 0x0, 0x20 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass33 + mov v1, v0 + newobjrange 0x80, 0x1, v1 + stobjbyname 0x82, a33, a2 + callruntime.ldsendablevar 0x0, 0x21 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass34 + mov v1, v0 + newobjrange 0x84, 0x1, v1 + stobjbyname 0x86, a34, a2 + callruntime.ldsendablevar 0x0, 0x22 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass35 + mov v1, v0 + newobjrange 0x88, 0x1, v1 + stobjbyname 0x8a, a35, a2 + callruntime.ldsendablevar 0x0, 0x23 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass36 + mov v1, v0 + newobjrange 0x8c, 0x1, v1 + stobjbyname 0x8e, a36, a2 + callruntime.ldsendablevar 0x0, 0x24 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass37 + mov v1, v0 + newobjrange 0x90, 0x1, v1 + stobjbyname 0x92, a37, a2 + callruntime.ldsendablevar 0x0, 0x25 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass38 + mov v1, v0 + newobjrange 0x94, 0x1, v1 + stobjbyname 0x96, a38, a2 + callruntime.ldsendablevar 0x0, 0x26 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass39 + mov v1, v0 + newobjrange 0x98, 0x1, v1 + stobjbyname 0x9a, a39, a2 + callruntime.ldsendablevar 0x0, 0x27 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass40 + mov v1, v0 + newobjrange 0x9c, 0x1, v1 + stobjbyname 0x9e, a40, a2 + callruntime.ldsendablevar 0x0, 0x28 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass41 + mov v1, v0 + newobjrange 0xa0, 0x1, v1 + stobjbyname 0xa2, a41, a2 + callruntime.ldsendablevar 0x0, 0x29 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass42 + mov v1, v0 + newobjrange 0xa4, 0x1, v1 + stobjbyname 0xa6, a42, a2 + callruntime.ldsendablevar 0x0, 0x2a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass43 + mov v1, v0 + newobjrange 0xa8, 0x1, v1 + stobjbyname 0xaa, a43, a2 + callruntime.ldsendablevar 0x0, 0x2b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass44 + mov v1, v0 + newobjrange 0xac, 0x1, v1 + stobjbyname 0xae, a44, a2 + callruntime.ldsendablevar 0x0, 0x2c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass45 + mov v1, v0 + newobjrange 0xb0, 0x1, v1 + stobjbyname 0xb2, a45, a2 + callruntime.ldsendablevar 0x0, 0x2d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass46 + mov v1, v0 + newobjrange 0xb4, 0x1, v1 + stobjbyname 0xb6, a46, a2 + callruntime.ldsendablevar 0x0, 0x2e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass47 + mov v1, v0 + newobjrange 0xb8, 0x1, v1 + stobjbyname 0xba, a47, a2 + callruntime.ldsendablevar 0x0, 0x2f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass48 + mov v1, v0 + newobjrange 0xbc, 0x1, v1 + stobjbyname 0xbe, a48, a2 + callruntime.ldsendablevar 0x0, 0x30 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass49 + mov v1, v0 + newobjrange 0xc0, 0x1, v1 + stobjbyname 0xc2, a49, a2 + callruntime.ldsendablevar 0x0, 0x31 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass50 + mov v1, v0 + newobjrange 0xc4, 0x1, v1 + stobjbyname 0xc6, a50, a2 + callruntime.ldsendablevar 0x0, 0x32 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass51 + mov v1, v0 + newobjrange 0xc8, 0x1, v1 + stobjbyname 0xca, a51, a2 + callruntime.ldsendablevar 0x0, 0x33 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass52 + mov v1, v0 + newobjrange 0xcc, 0x1, v1 + stobjbyname 0xce, a52, a2 + callruntime.ldsendablevar 0x0, 0x34 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass53 + mov v1, v0 + newobjrange 0xd0, 0x1, v1 + stobjbyname 0xd2, a53, a2 + callruntime.ldsendablevar 0x0, 0x35 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass54 + mov v1, v0 + newobjrange 0xd4, 0x1, v1 + stobjbyname 0xd6, a54, a2 + callruntime.ldsendablevar 0x0, 0x36 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass55 + mov v1, v0 + newobjrange 0xd8, 0x1, v1 + stobjbyname 0xda, a55, a2 + callruntime.ldsendablevar 0x0, 0x37 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass56 + mov v1, v0 + newobjrange 0xdc, 0x1, v1 + stobjbyname 0xde, a56, a2 + callruntime.ldsendablevar 0x0, 0x38 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass57 + mov v1, v0 + newobjrange 0xe0, 0x1, v1 + stobjbyname 0xe2, a57, a2 + callruntime.ldsendablevar 0x0, 0x39 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass58 + mov v1, v0 + newobjrange 0xe4, 0x1, v1 + stobjbyname 0xe6, a58, a2 + callruntime.ldsendablevar 0x0, 0x3a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass59 + mov v1, v0 + newobjrange 0xe8, 0x1, v1 + stobjbyname 0xea, a59, a2 + callruntime.ldsendablevar 0x0, 0x3b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass60 + mov v1, v0 + newobjrange 0xec, 0x1, v1 + stobjbyname 0xee, a60, a2 + callruntime.ldsendablevar 0x0, 0x3c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass61 + mov v1, v0 + newobjrange 0xf0, 0x1, v1 + stobjbyname 0xf2, a61, a2 + callruntime.ldsendablevar 0x0, 0x3d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass62 + mov v1, v0 + newobjrange 0xf4, 0x1, v1 + stobjbyname 0xf6, a62, a2 + callruntime.ldsendablevar 0x0, 0x3e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass63 + mov v1, v0 + newobjrange 0xf8, 0x1, v1 + stobjbyname 0xfa, a63, a2 + callruntime.ldsendablevar 0x0, 0x3f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass64 + mov v1, v0 + newobjrange 0xfc, 0x1, v1 + stobjbyname 0x100, a64, a2 + callruntime.ldsendablevar 0x0, 0x40 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass65 + mov v1, v0 + newobjrange 0x102, 0x1, v1 + stobjbyname 0x104, a65, a2 + callruntime.ldsendablevar 0x0, 0x41 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass66 + mov v1, v0 + newobjrange 0x106, 0x1, v1 + stobjbyname 0x108, a66, a2 + callruntime.ldsendablevar 0x0, 0x42 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass67 + mov v1, v0 + newobjrange 0x10a, 0x1, v1 + stobjbyname 0x10c, a67, a2 + callruntime.ldsendablevar 0x0, 0x43 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass68 + mov v1, v0 + newobjrange 0x10e, 0x1, v1 + stobjbyname 0x110, a68, a2 + callruntime.ldsendablevar 0x0, 0x44 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass69 + mov v1, v0 + newobjrange 0x112, 0x1, v1 + stobjbyname 0x114, a69, a2 + callruntime.ldsendablevar 0x0, 0x45 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass70 + mov v1, v0 + newobjrange 0x116, 0x1, v1 + stobjbyname 0x118, a70, a2 + callruntime.ldsendablevar 0x0, 0x46 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass71 + mov v1, v0 + newobjrange 0x11a, 0x1, v1 + stobjbyname 0x11c, a71, a2 + callruntime.ldsendablevar 0x0, 0x47 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass72 + mov v1, v0 + newobjrange 0x11e, 0x1, v1 + stobjbyname 0x120, a72, a2 + callruntime.ldsendablevar 0x0, 0x48 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass73 + mov v1, v0 + newobjrange 0x122, 0x1, v1 + stobjbyname 0x124, a73, a2 + callruntime.ldsendablevar 0x0, 0x49 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass74 + mov v1, v0 + newobjrange 0x126, 0x1, v1 + stobjbyname 0x128, a74, a2 + callruntime.ldsendablevar 0x0, 0x4a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass75 + mov v1, v0 + newobjrange 0x12a, 0x1, v1 + stobjbyname 0x12c, a75, a2 + callruntime.ldsendablevar 0x0, 0x4b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass76 + mov v1, v0 + newobjrange 0x12e, 0x1, v1 + stobjbyname 0x130, a76, a2 + callruntime.ldsendablevar 0x0, 0x4c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass77 + mov v1, v0 + newobjrange 0x132, 0x1, v1 + stobjbyname 0x134, a77, a2 + callruntime.ldsendablevar 0x0, 0x4d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass78 + mov v1, v0 + newobjrange 0x136, 0x1, v1 + stobjbyname 0x138, a78, a2 + callruntime.ldsendablevar 0x0, 0x4e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass79 + mov v1, v0 + newobjrange 0x13a, 0x1, v1 + stobjbyname 0x13c, a79, a2 + callruntime.ldsendablevar 0x0, 0x4f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass80 + mov v1, v0 + newobjrange 0x13e, 0x1, v1 + stobjbyname 0x140, a80, a2 + callruntime.ldsendablevar 0x0, 0x50 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass81 + mov v1, v0 + newobjrange 0x142, 0x1, v1 + stobjbyname 0x144, a81, a2 + callruntime.ldsendablevar 0x0, 0x51 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass82 + mov v1, v0 + newobjrange 0x146, 0x1, v1 + stobjbyname 0x148, a82, a2 + callruntime.ldsendablevar 0x0, 0x52 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass83 + mov v1, v0 + newobjrange 0x14a, 0x1, v1 + stobjbyname 0x14c, a83, a2 + callruntime.ldsendablevar 0x0, 0x53 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass84 + mov v1, v0 + newobjrange 0x14e, 0x1, v1 + stobjbyname 0x150, a84, a2 + callruntime.ldsendablevar 0x0, 0x54 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass85 + mov v1, v0 + newobjrange 0x152, 0x1, v1 + stobjbyname 0x154, a85, a2 + callruntime.ldsendablevar 0x0, 0x55 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass86 + mov v1, v0 + newobjrange 0x156, 0x1, v1 + stobjbyname 0x158, a86, a2 + callruntime.ldsendablevar 0x0, 0x56 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass87 + mov v1, v0 + newobjrange 0x15a, 0x1, v1 + stobjbyname 0x15c, a87, a2 + callruntime.ldsendablevar 0x0, 0x57 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass88 + mov v1, v0 + newobjrange 0x15e, 0x1, v1 + stobjbyname 0x160, a88, a2 + callruntime.ldsendablevar 0x0, 0x58 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass89 + mov v1, v0 + newobjrange 0x162, 0x1, v1 + stobjbyname 0x164, a89, a2 + callruntime.ldsendablevar 0x0, 0x59 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass90 + mov v1, v0 + newobjrange 0x166, 0x1, v1 + stobjbyname 0x168, a90, a2 + callruntime.ldsendablevar 0x0, 0x5a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass91 + mov v1, v0 + newobjrange 0x16a, 0x1, v1 + stobjbyname 0x16c, a91, a2 + callruntime.ldsendablevar 0x0, 0x5b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass92 + mov v1, v0 + newobjrange 0x16e, 0x1, v1 + stobjbyname 0x170, a92, a2 + callruntime.ldsendablevar 0x0, 0x5c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass93 + mov v1, v0 + newobjrange 0x172, 0x1, v1 + stobjbyname 0x174, a93, a2 + callruntime.ldsendablevar 0x0, 0x5d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass94 + mov v1, v0 + newobjrange 0x176, 0x1, v1 + stobjbyname 0x178, a94, a2 + callruntime.ldsendablevar 0x0, 0x5e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass95 + mov v1, v0 + newobjrange 0x17a, 0x1, v1 + stobjbyname 0x17c, a95, a2 + callruntime.ldsendablevar 0x0, 0x5f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass96 + mov v1, v0 + newobjrange 0x17e, 0x1, v1 + stobjbyname 0x180, a96, a2 + callruntime.ldsendablevar 0x0, 0x60 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass97 + mov v1, v0 + newobjrange 0x182, 0x1, v1 + stobjbyname 0x184, a97, a2 + callruntime.ldsendablevar 0x0, 0x61 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass98 + mov v1, v0 + newobjrange 0x186, 0x1, v1 + stobjbyname 0x188, a98, a2 + callruntime.ldsendablevar 0x0, 0x62 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass99 + mov v1, v0 + newobjrange 0x18a, 0x1, v1 + stobjbyname 0x18c, a99, a2 + callruntime.ldsendablevar 0x0, 0x63 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass100 + mov v1, v0 + newobjrange 0x18e, 0x1, v1 + stobjbyname 0x190, a100, a2 + callruntime.ldsendablevar 0x0, 0x64 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass101 + mov v1, v0 + newobjrange 0x192, 0x1, v1 + stobjbyname 0x194, a101, a2 + callruntime.ldsendablevar 0x0, 0x65 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass102 + mov v1, v0 + newobjrange 0x196, 0x1, v1 + stobjbyname 0x198, a102, a2 + callruntime.ldsendablevar 0x0, 0x66 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass103 + mov v1, v0 + newobjrange 0x19a, 0x1, v1 + stobjbyname 0x19c, a103, a2 + callruntime.ldsendablevar 0x0, 0x67 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass104 + mov v1, v0 + newobjrange 0x19e, 0x1, v1 + stobjbyname 0x1a0, a104, a2 + callruntime.ldsendablevar 0x0, 0x68 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass105 + mov v1, v0 + newobjrange 0x1a2, 0x1, v1 + stobjbyname 0x1a4, a105, a2 + callruntime.ldsendablevar 0x0, 0x69 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass106 + mov v1, v0 + newobjrange 0x1a6, 0x1, v1 + stobjbyname 0x1a8, a106, a2 + callruntime.ldsendablevar 0x0, 0x6a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass107 + mov v1, v0 + newobjrange 0x1aa, 0x1, v1 + stobjbyname 0x1ac, a107, a2 + callruntime.ldsendablevar 0x0, 0x6b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass108 + mov v1, v0 + newobjrange 0x1ae, 0x1, v1 + stobjbyname 0x1b0, a108, a2 + callruntime.ldsendablevar 0x0, 0x6c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass109 + mov v1, v0 + newobjrange 0x1b2, 0x1, v1 + stobjbyname 0x1b4, a109, a2 + callruntime.ldsendablevar 0x0, 0x6d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass110 + mov v1, v0 + newobjrange 0x1b6, 0x1, v1 + stobjbyname 0x1b8, a110, a2 + callruntime.ldsendablevar 0x0, 0x6e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass111 + mov v1, v0 + newobjrange 0x1ba, 0x1, v1 + stobjbyname 0x1bc, a111, a2 + callruntime.ldsendablevar 0x0, 0x6f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass112 + mov v1, v0 + newobjrange 0x1be, 0x1, v1 + stobjbyname 0x1c0, a112, a2 + callruntime.ldsendablevar 0x0, 0x70 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass113 + mov v1, v0 + newobjrange 0x1c2, 0x1, v1 + stobjbyname 0x1c4, a113, a2 + callruntime.ldsendablevar 0x0, 0x71 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass114 + mov v1, v0 + newobjrange 0x1c6, 0x1, v1 + stobjbyname 0x1c8, a114, a2 + callruntime.ldsendablevar 0x0, 0x72 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass115 + mov v1, v0 + newobjrange 0x1ca, 0x1, v1 + stobjbyname 0x1cc, a115, a2 + callruntime.ldsendablevar 0x0, 0x73 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass116 + mov v1, v0 + newobjrange 0x1ce, 0x1, v1 + stobjbyname 0x1d0, a116, a2 + callruntime.ldsendablevar 0x0, 0x74 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass117 + mov v1, v0 + newobjrange 0x1d2, 0x1, v1 + stobjbyname 0x1d4, a117, a2 + callruntime.ldsendablevar 0x0, 0x75 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass118 + mov v1, v0 + newobjrange 0x1d6, 0x1, v1 + stobjbyname 0x1d8, a118, a2 + callruntime.ldsendablevar 0x0, 0x76 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass119 + mov v1, v0 + newobjrange 0x1da, 0x1, v1 + stobjbyname 0x1dc, a119, a2 + callruntime.ldsendablevar 0x0, 0x77 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass120 + mov v1, v0 + newobjrange 0x1de, 0x1, v1 + stobjbyname 0x1e0, a120, a2 + callruntime.ldsendablevar 0x0, 0x78 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass121 + mov v1, v0 + newobjrange 0x1e2, 0x1, v1 + stobjbyname 0x1e4, a121, a2 + callruntime.ldsendablevar 0x0, 0x79 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass122 + mov v1, v0 + newobjrange 0x1e6, 0x1, v1 + stobjbyname 0x1e8, a122, a2 + callruntime.ldsendablevar 0x0, 0x7a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass123 + mov v1, v0 + newobjrange 0x1ea, 0x1, v1 + stobjbyname 0x1ec, a123, a2 + callruntime.ldsendablevar 0x0, 0x7b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass124 + mov v1, v0 + newobjrange 0x1ee, 0x1, v1 + stobjbyname 0x1f0, a124, a2 + callruntime.ldsendablevar 0x0, 0x7c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass125 + mov v1, v0 + newobjrange 0x1f2, 0x1, v1 + stobjbyname 0x1f4, a125, a2 + callruntime.ldsendablevar 0x0, 0x7d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass126 + mov v1, v0 + newobjrange 0x1f6, 0x1, v1 + stobjbyname 0x1f8, a126, a2 + callruntime.ldsendablevar 0x0, 0x7e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass127 + mov v1, v0 + newobjrange 0x1fa, 0x1, v1 + stobjbyname 0x1fc, a127, a2 + callruntime.ldsendablevar 0x0, 0x7f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass128 + mov v1, v0 + newobjrange 0x1fe, 0x1, v1 + stobjbyname 0x200, a128, a2 + callruntime.wideldsendablevar 0x0, 0x80 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass129 + mov v1, v0 + newobjrange 0x202, 0x1, v1 + stobjbyname 0x204, a129, a2 + callruntime.wideldsendablevar 0x0, 0x81 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass130 + mov v1, v0 + newobjrange 0x206, 0x1, v1 + stobjbyname 0x208, a130, a2 + callruntime.wideldsendablevar 0x0, 0x82 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass131 + mov v1, v0 + newobjrange 0x20a, 0x1, v1 + stobjbyname 0x20c, a131, a2 + callruntime.wideldsendablevar 0x0, 0x83 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass132 + mov v1, v0 + newobjrange 0x20e, 0x1, v1 + stobjbyname 0x210, a132, a2 + callruntime.wideldsendablevar 0x0, 0x84 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass133 + mov v1, v0 + newobjrange 0x212, 0x1, v1 + stobjbyname 0x214, a133, a2 + callruntime.wideldsendablevar 0x0, 0x85 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass134 + mov v1, v0 + newobjrange 0x216, 0x1, v1 + stobjbyname 0x218, a134, a2 + callruntime.wideldsendablevar 0x0, 0x86 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass135 + mov v1, v0 + newobjrange 0x21a, 0x1, v1 + stobjbyname 0x21c, a135, a2 + callruntime.wideldsendablevar 0x0, 0x87 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass136 + mov v1, v0 + newobjrange 0x21e, 0x1, v1 + stobjbyname 0x220, a136, a2 + callruntime.wideldsendablevar 0x0, 0x88 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass137 + mov v1, v0 + newobjrange 0x222, 0x1, v1 + stobjbyname 0x224, a137, a2 + callruntime.wideldsendablevar 0x0, 0x89 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass138 + mov v1, v0 + newobjrange 0x226, 0x1, v1 + stobjbyname 0x228, a138, a2 + callruntime.wideldsendablevar 0x0, 0x8a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass139 + mov v1, v0 + newobjrange 0x22a, 0x1, v1 + stobjbyname 0x22c, a139, a2 + callruntime.wideldsendablevar 0x0, 0x8b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass140 + mov v1, v0 + newobjrange 0x22e, 0x1, v1 + stobjbyname 0x230, a140, a2 + callruntime.wideldsendablevar 0x0, 0x8c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass141 + mov v1, v0 + newobjrange 0x232, 0x1, v1 + stobjbyname 0x234, a141, a2 + callruntime.wideldsendablevar 0x0, 0x8d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass142 + mov v1, v0 + newobjrange 0x236, 0x1, v1 + stobjbyname 0x238, a142, a2 + callruntime.wideldsendablevar 0x0, 0x8e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass143 + mov v1, v0 + newobjrange 0x23a, 0x1, v1 + stobjbyname 0x23c, a143, a2 + callruntime.wideldsendablevar 0x0, 0x8f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass144 + mov v1, v0 + newobjrange 0x23e, 0x1, v1 + stobjbyname 0x240, a144, a2 + callruntime.wideldsendablevar 0x0, 0x90 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass145 + mov v1, v0 + newobjrange 0x242, 0x1, v1 + stobjbyname 0x244, a145, a2 + callruntime.wideldsendablevar 0x0, 0x91 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass146 + mov v1, v0 + newobjrange 0x246, 0x1, v1 + stobjbyname 0x248, a146, a2 + callruntime.wideldsendablevar 0x0, 0x92 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass147 + mov v1, v0 + newobjrange 0x24a, 0x1, v1 + stobjbyname 0x24c, a147, a2 + callruntime.wideldsendablevar 0x0, 0x93 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass148 + mov v1, v0 + newobjrange 0x24e, 0x1, v1 + stobjbyname 0x250, a148, a2 + callruntime.wideldsendablevar 0x0, 0x94 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass149 + mov v1, v0 + newobjrange 0x252, 0x1, v1 + stobjbyname 0x254, a149, a2 + callruntime.wideldsendablevar 0x0, 0x95 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass150 + mov v1, v0 + newobjrange 0x256, 0x1, v1 + stobjbyname 0x258, a150, a2 + callruntime.wideldsendablevar 0x0, 0x96 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass151 + mov v1, v0 + newobjrange 0x25a, 0x1, v1 + stobjbyname 0x25c, a151, a2 + callruntime.wideldsendablevar 0x0, 0x97 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass152 + mov v1, v0 + newobjrange 0x25e, 0x1, v1 + stobjbyname 0x260, a152, a2 + callruntime.wideldsendablevar 0x0, 0x98 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass153 + mov v1, v0 + newobjrange 0x262, 0x1, v1 + stobjbyname 0x264, a153, a2 + callruntime.wideldsendablevar 0x0, 0x99 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass154 + mov v1, v0 + newobjrange 0x266, 0x1, v1 + stobjbyname 0x268, a154, a2 + callruntime.wideldsendablevar 0x0, 0x9a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass155 + mov v1, v0 + newobjrange 0x26a, 0x1, v1 + stobjbyname 0x26c, a155, a2 + callruntime.wideldsendablevar 0x0, 0x9b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass156 + mov v1, v0 + newobjrange 0x26e, 0x1, v1 + stobjbyname 0x270, a156, a2 + callruntime.wideldsendablevar 0x0, 0x9c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass157 + mov v1, v0 + newobjrange 0x272, 0x1, v1 + stobjbyname 0x274, a157, a2 + callruntime.wideldsendablevar 0x0, 0x9d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass158 + mov v1, v0 + newobjrange 0x276, 0x1, v1 + stobjbyname 0x278, a158, a2 + callruntime.wideldsendablevar 0x0, 0x9e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass159 + mov v1, v0 + newobjrange 0x27a, 0x1, v1 + stobjbyname 0x27c, a159, a2 + callruntime.wideldsendablevar 0x0, 0x9f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass160 + mov v1, v0 + newobjrange 0x27e, 0x1, v1 + stobjbyname 0x280, a160, a2 + callruntime.wideldsendablevar 0x0, 0xa0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass161 + mov v1, v0 + newobjrange 0x282, 0x1, v1 + stobjbyname 0x284, a161, a2 + callruntime.wideldsendablevar 0x0, 0xa1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass162 + mov v1, v0 + newobjrange 0x286, 0x1, v1 + stobjbyname 0x288, a162, a2 + callruntime.wideldsendablevar 0x0, 0xa2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass163 + mov v1, v0 + newobjrange 0x28a, 0x1, v1 + stobjbyname 0x28c, a163, a2 + callruntime.wideldsendablevar 0x0, 0xa3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass164 + mov v1, v0 + newobjrange 0x28e, 0x1, v1 + stobjbyname 0x290, a164, a2 + callruntime.wideldsendablevar 0x0, 0xa4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass165 + mov v1, v0 + newobjrange 0x292, 0x1, v1 + stobjbyname 0x294, a165, a2 + callruntime.wideldsendablevar 0x0, 0xa5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass166 + mov v1, v0 + newobjrange 0x296, 0x1, v1 + stobjbyname 0x298, a166, a2 + callruntime.wideldsendablevar 0x0, 0xa6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass167 + mov v1, v0 + newobjrange 0x29a, 0x1, v1 + stobjbyname 0x29c, a167, a2 + callruntime.wideldsendablevar 0x0, 0xa7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass168 + mov v1, v0 + newobjrange 0x29e, 0x1, v1 + stobjbyname 0x2a0, a168, a2 + callruntime.wideldsendablevar 0x0, 0xa8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass169 + mov v1, v0 + newobjrange 0x2a2, 0x1, v1 + stobjbyname 0x2a4, a169, a2 + callruntime.wideldsendablevar 0x0, 0xa9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass170 + mov v1, v0 + newobjrange 0x2a6, 0x1, v1 + stobjbyname 0x2a8, a170, a2 + callruntime.wideldsendablevar 0x0, 0xaa + sta v0 + throw.undefinedifholewithname TopLevelSendableClass171 + mov v1, v0 + newobjrange 0x2aa, 0x1, v1 + stobjbyname 0x2ac, a171, a2 + callruntime.wideldsendablevar 0x0, 0xab + sta v0 + throw.undefinedifholewithname TopLevelSendableClass172 + mov v1, v0 + newobjrange 0x2ae, 0x1, v1 + stobjbyname 0x2b0, a172, a2 + callruntime.wideldsendablevar 0x0, 0xac + sta v0 + throw.undefinedifholewithname TopLevelSendableClass173 + mov v1, v0 + newobjrange 0x2b2, 0x1, v1 + stobjbyname 0x2b4, a173, a2 + callruntime.wideldsendablevar 0x0, 0xad + sta v0 + throw.undefinedifholewithname TopLevelSendableClass174 + mov v1, v0 + newobjrange 0x2b6, 0x1, v1 + stobjbyname 0x2b8, a174, a2 + callruntime.wideldsendablevar 0x0, 0xae + sta v0 + throw.undefinedifholewithname TopLevelSendableClass175 + mov v1, v0 + newobjrange 0x2ba, 0x1, v1 + stobjbyname 0x2bc, a175, a2 + callruntime.wideldsendablevar 0x0, 0xaf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass176 + mov v1, v0 + newobjrange 0x2be, 0x1, v1 + stobjbyname 0x2c0, a176, a2 + callruntime.wideldsendablevar 0x0, 0xb0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass177 + mov v1, v0 + newobjrange 0x2c2, 0x1, v1 + stobjbyname 0x2c4, a177, a2 + callruntime.wideldsendablevar 0x0, 0xb1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass178 + mov v1, v0 + newobjrange 0x2c6, 0x1, v1 + stobjbyname 0x2c8, a178, a2 + callruntime.wideldsendablevar 0x0, 0xb2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass179 + mov v1, v0 + newobjrange 0x2ca, 0x1, v1 + stobjbyname 0x2cc, a179, a2 + callruntime.wideldsendablevar 0x0, 0xb3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass180 + mov v1, v0 + newobjrange 0x2ce, 0x1, v1 + stobjbyname 0x2d0, a180, a2 + callruntime.wideldsendablevar 0x0, 0xb4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass181 + mov v1, v0 + newobjrange 0x2d2, 0x1, v1 + stobjbyname 0x2d4, a181, a2 + callruntime.wideldsendablevar 0x0, 0xb5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass182 + mov v1, v0 + newobjrange 0x2d6, 0x1, v1 + stobjbyname 0x2d8, a182, a2 + callruntime.wideldsendablevar 0x0, 0xb6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass183 + mov v1, v0 + newobjrange 0x2da, 0x1, v1 + stobjbyname 0x2dc, a183, a2 + callruntime.wideldsendablevar 0x0, 0xb7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass184 + mov v1, v0 + newobjrange 0x2de, 0x1, v1 + stobjbyname 0x2e0, a184, a2 + callruntime.wideldsendablevar 0x0, 0xb8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass185 + mov v1, v0 + newobjrange 0x2e2, 0x1, v1 + stobjbyname 0x2e4, a185, a2 + callruntime.wideldsendablevar 0x0, 0xb9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass186 + mov v1, v0 + newobjrange 0x2e6, 0x1, v1 + stobjbyname 0x2e8, a186, a2 + callruntime.wideldsendablevar 0x0, 0xba + sta v0 + throw.undefinedifholewithname TopLevelSendableClass187 + mov v1, v0 + newobjrange 0x2ea, 0x1, v1 + stobjbyname 0x2ec, a187, a2 + callruntime.wideldsendablevar 0x0, 0xbb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass188 + mov v1, v0 + newobjrange 0x2ee, 0x1, v1 + stobjbyname 0x2f0, a188, a2 + callruntime.wideldsendablevar 0x0, 0xbc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass189 + mov v1, v0 + newobjrange 0x2f2, 0x1, v1 + stobjbyname 0x2f4, a189, a2 + callruntime.wideldsendablevar 0x0, 0xbd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass190 + mov v1, v0 + newobjrange 0x2f6, 0x1, v1 + stobjbyname 0x2f8, a190, a2 + callruntime.wideldsendablevar 0x0, 0xbe + sta v0 + throw.undefinedifholewithname TopLevelSendableClass191 + mov v1, v0 + newobjrange 0x2fa, 0x1, v1 + stobjbyname 0x2fc, a191, a2 + callruntime.wideldsendablevar 0x0, 0xbf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass192 + mov v1, v0 + newobjrange 0x2fe, 0x1, v1 + stobjbyname 0x300, a192, a2 + callruntime.wideldsendablevar 0x0, 0xc0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass193 + mov v1, v0 + newobjrange 0x302, 0x1, v1 + stobjbyname 0x304, a193, a2 + callruntime.wideldsendablevar 0x0, 0xc1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass194 + mov v1, v0 + newobjrange 0x306, 0x1, v1 + stobjbyname 0x308, a194, a2 + callruntime.wideldsendablevar 0x0, 0xc2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass195 + mov v1, v0 + newobjrange 0x30a, 0x1, v1 + stobjbyname 0x30c, a195, a2 + callruntime.wideldsendablevar 0x0, 0xc3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass196 + mov v1, v0 + newobjrange 0x30e, 0x1, v1 + stobjbyname 0x310, a196, a2 + callruntime.wideldsendablevar 0x0, 0xc4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass197 + mov v1, v0 + newobjrange 0x312, 0x1, v1 + stobjbyname 0x314, a197, a2 + callruntime.wideldsendablevar 0x0, 0xc5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass198 + mov v1, v0 + newobjrange 0x316, 0x1, v1 + stobjbyname 0x318, a198, a2 + callruntime.wideldsendablevar 0x0, 0xc6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass199 + mov v1, v0 + newobjrange 0x31a, 0x1, v1 + stobjbyname 0x31c, a199, a2 + callruntime.wideldsendablevar 0x0, 0xc7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass200 + mov v1, v0 + newobjrange 0x31e, 0x1, v1 + stobjbyname 0x320, a200, a2 + callruntime.wideldsendablevar 0x0, 0xc8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass201 + mov v1, v0 + newobjrange 0x322, 0x1, v1 + stobjbyname 0x324, a201, a2 + callruntime.wideldsendablevar 0x0, 0xc9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass202 + mov v1, v0 + newobjrange 0x326, 0x1, v1 + stobjbyname 0x328, a202, a2 + callruntime.wideldsendablevar 0x0, 0xca + sta v0 + throw.undefinedifholewithname TopLevelSendableClass203 + mov v1, v0 + newobjrange 0x32a, 0x1, v1 + stobjbyname 0x32c, a203, a2 + callruntime.wideldsendablevar 0x0, 0xcb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass204 + mov v1, v0 + newobjrange 0x32e, 0x1, v1 + stobjbyname 0x330, a204, a2 + callruntime.wideldsendablevar 0x0, 0xcc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass205 + mov v1, v0 + newobjrange 0x332, 0x1, v1 + stobjbyname 0x334, a205, a2 + callruntime.wideldsendablevar 0x0, 0xcd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass206 + mov v1, v0 + newobjrange 0x336, 0x1, v1 + stobjbyname 0x338, a206, a2 + callruntime.wideldsendablevar 0x0, 0xce + sta v0 + throw.undefinedifholewithname TopLevelSendableClass207 + mov v1, v0 + newobjrange 0x33a, 0x1, v1 + stobjbyname 0x33c, a207, a2 + callruntime.wideldsendablevar 0x0, 0xcf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass208 + mov v1, v0 + newobjrange 0x33e, 0x1, v1 + stobjbyname 0x340, a208, a2 + callruntime.wideldsendablevar 0x0, 0xd0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass209 + mov v1, v0 + newobjrange 0x342, 0x1, v1 + stobjbyname 0x344, a209, a2 + callruntime.wideldsendablevar 0x0, 0xd1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass210 + mov v1, v0 + newobjrange 0x346, 0x1, v1 + stobjbyname 0x348, a210, a2 + callruntime.wideldsendablevar 0x0, 0xd2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass211 + mov v1, v0 + newobjrange 0x34a, 0x1, v1 + stobjbyname 0x34c, a211, a2 + callruntime.wideldsendablevar 0x0, 0xd3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass212 + mov v1, v0 + newobjrange 0x34e, 0x1, v1 + stobjbyname 0x350, a212, a2 + callruntime.wideldsendablevar 0x0, 0xd4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass213 + mov v1, v0 + newobjrange 0x352, 0x1, v1 + stobjbyname 0x354, a213, a2 + callruntime.wideldsendablevar 0x0, 0xd5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass214 + mov v1, v0 + newobjrange 0x356, 0x1, v1 + stobjbyname 0x358, a214, a2 + callruntime.wideldsendablevar 0x0, 0xd6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass215 + mov v1, v0 + newobjrange 0x35a, 0x1, v1 + stobjbyname 0x35c, a215, a2 + callruntime.wideldsendablevar 0x0, 0xd7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass216 + mov v1, v0 + newobjrange 0x35e, 0x1, v1 + stobjbyname 0x360, a216, a2 + callruntime.wideldsendablevar 0x0, 0xd8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass217 + mov v1, v0 + newobjrange 0x362, 0x1, v1 + stobjbyname 0x364, a217, a2 + callruntime.wideldsendablevar 0x0, 0xd9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass218 + mov v1, v0 + newobjrange 0x366, 0x1, v1 + stobjbyname 0x368, a218, a2 + callruntime.wideldsendablevar 0x0, 0xda + sta v0 + throw.undefinedifholewithname TopLevelSendableClass219 + mov v1, v0 + newobjrange 0x36a, 0x1, v1 + stobjbyname 0x36c, a219, a2 + callruntime.wideldsendablevar 0x0, 0xdb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass220 + mov v1, v0 + newobjrange 0x36e, 0x1, v1 + stobjbyname 0x370, a220, a2 + callruntime.wideldsendablevar 0x0, 0xdc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass221 + mov v1, v0 + newobjrange 0x372, 0x1, v1 + stobjbyname 0x374, a221, a2 + callruntime.wideldsendablevar 0x0, 0xdd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass222 + mov v1, v0 + newobjrange 0x376, 0x1, v1 + stobjbyname 0x378, a222, a2 + callruntime.wideldsendablevar 0x0, 0xde + sta v0 + throw.undefinedifholewithname TopLevelSendableClass223 + mov v1, v0 + newobjrange 0x37a, 0x1, v1 + stobjbyname 0x37c, a223, a2 + callruntime.wideldsendablevar 0x0, 0xdf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass224 + mov v1, v0 + newobjrange 0x37e, 0x1, v1 + stobjbyname 0x380, a224, a2 + callruntime.wideldsendablevar 0x0, 0xe0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass225 + mov v1, v0 + newobjrange 0x382, 0x1, v1 + stobjbyname 0x384, a225, a2 + callruntime.wideldsendablevar 0x0, 0xe1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass226 + mov v1, v0 + newobjrange 0x386, 0x1, v1 + stobjbyname 0x388, a226, a2 + callruntime.wideldsendablevar 0x0, 0xe2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass227 + mov v1, v0 + newobjrange 0x38a, 0x1, v1 + stobjbyname 0x38c, a227, a2 + callruntime.wideldsendablevar 0x0, 0xe3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass228 + mov v1, v0 + newobjrange 0x38e, 0x1, v1 + stobjbyname 0x390, a228, a2 + callruntime.wideldsendablevar 0x0, 0xe4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass229 + mov v1, v0 + newobjrange 0x392, 0x1, v1 + stobjbyname 0x394, a229, a2 + callruntime.wideldsendablevar 0x0, 0xe5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass230 + mov v1, v0 + newobjrange 0x396, 0x1, v1 + stobjbyname 0x398, a230, a2 + callruntime.wideldsendablevar 0x0, 0xe6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass231 + mov v1, v0 + newobjrange 0x39a, 0x1, v1 + stobjbyname 0x39c, a231, a2 + callruntime.wideldsendablevar 0x0, 0xe7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass232 + mov v1, v0 + newobjrange 0x39e, 0x1, v1 + stobjbyname 0x3a0, a232, a2 + callruntime.wideldsendablevar 0x0, 0xe8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass233 + mov v1, v0 + newobjrange 0x3a2, 0x1, v1 + stobjbyname 0x3a4, a233, a2 + callruntime.wideldsendablevar 0x0, 0xe9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass234 + mov v1, v0 + newobjrange 0x3a6, 0x1, v1 + stobjbyname 0x3a8, a234, a2 + callruntime.wideldsendablevar 0x0, 0xea + sta v0 + throw.undefinedifholewithname TopLevelSendableClass235 + mov v1, v0 + newobjrange 0x3aa, 0x1, v1 + stobjbyname 0x3ac, a235, a2 + callruntime.wideldsendablevar 0x0, 0xeb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass236 + mov v1, v0 + newobjrange 0x3ae, 0x1, v1 + stobjbyname 0x3b0, a236, a2 + callruntime.wideldsendablevar 0x0, 0xec + sta v0 + throw.undefinedifholewithname TopLevelSendableClass237 + mov v1, v0 + newobjrange 0x3b2, 0x1, v1 + stobjbyname 0x3b4, a237, a2 + callruntime.wideldsendablevar 0x0, 0xed + sta v0 + throw.undefinedifholewithname TopLevelSendableClass238 + mov v1, v0 + newobjrange 0x3b6, 0x1, v1 + stobjbyname 0x3b8, a238, a2 + callruntime.wideldsendablevar 0x0, 0xee + sta v0 + throw.undefinedifholewithname TopLevelSendableClass239 + mov v1, v0 + newobjrange 0x3ba, 0x1, v1 + stobjbyname 0x3bc, a239, a2 + callruntime.wideldsendablevar 0x0, 0xef + sta v0 + throw.undefinedifholewithname TopLevelSendableClass240 + mov v1, v0 + newobjrange 0x3be, 0x1, v1 + stobjbyname 0x3c0, a240, a2 + callruntime.wideldsendablevar 0x0, 0xf0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass241 + mov v1, v0 + newobjrange 0x3c2, 0x1, v1 + stobjbyname 0x3c4, a241, a2 + callruntime.wideldsendablevar 0x0, 0xf1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass242 + mov v1, v0 + newobjrange 0x3c6, 0x1, v1 + stobjbyname 0x3c8, a242, a2 + callruntime.wideldsendablevar 0x0, 0xf2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass243 + mov v1, v0 + newobjrange 0x3ca, 0x1, v1 + stobjbyname 0x3cc, a243, a2 + callruntime.wideldsendablevar 0x0, 0xf3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass244 + mov v1, v0 + newobjrange 0x3ce, 0x1, v1 + stobjbyname 0x3d0, a244, a2 + callruntime.wideldsendablevar 0x0, 0xf4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass245 + mov v1, v0 + newobjrange 0x3d2, 0x1, v1 + stobjbyname 0x3d4, a245, a2 + callruntime.wideldsendablevar 0x0, 0xf5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass246 + mov v1, v0 + newobjrange 0x3d6, 0x1, v1 + stobjbyname 0x3d8, a246, a2 + callruntime.wideldsendablevar 0x0, 0xf6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass247 + mov v1, v0 + newobjrange 0x3da, 0x1, v1 + stobjbyname 0x3dc, a247, a2 + callruntime.wideldsendablevar 0x0, 0xf7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass248 + mov v1, v0 + newobjrange 0x3de, 0x1, v1 + stobjbyname 0x3e0, a248, a2 + callruntime.wideldsendablevar 0x0, 0xf8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass249 + mov v1, v0 + newobjrange 0x3e2, 0x1, v1 + stobjbyname 0x3e4, a249, a2 + callruntime.wideldsendablevar 0x0, 0xf9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass250 + mov v1, v0 + newobjrange 0x3e6, 0x1, v1 + stobjbyname 0x3e8, a250, a2 + callruntime.wideldsendablevar 0x0, 0xfa + sta v0 + throw.undefinedifholewithname TopLevelSendableClass251 + mov v1, v0 + newobjrange 0x3ea, 0x1, v1 + stobjbyname 0x3ec, a251, a2 + callruntime.wideldsendablevar 0x0, 0xfb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass252 + mov v1, v0 + newobjrange 0x3ee, 0x1, v1 + stobjbyname 0x3f0, a252, a2 + callruntime.wideldsendablevar 0x0, 0xfc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass253 + mov v1, v0 + newobjrange 0x3f2, 0x1, v1 + stobjbyname 0x3f4, a253, a2 + callruntime.wideldsendablevar 0x0, 0xfd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass254 + mov v1, v0 + newobjrange 0x3f6, 0x1, v1 + stobjbyname 0x3f8, a254, a2 + callruntime.wideldsendablevar 0x0, 0xfe + sta v0 + throw.undefinedifholewithname TopLevelSendableClass255 + mov v1, v0 + newobjrange 0x3fa, 0x1, v1 + stobjbyname 0x3fc, a255, a2 + lda a2 + ldobjbyname 0x3fe, a1 + ldobjbyname 0x400, o + stobjbyname 0x402, u, a2 + lda.str wide_sendable_test + stobjbyname 0x404, v, a2 + lda a2 + return +label_2: +} + +slotNum = 0x108 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + callruntime.widenewsendableenv 0xff + ldhole + sta v0 + callruntime.definesendableclass 0x2, .#~@0=#TopLevelSendableClass1, _3, 0x0, v0 + callruntime.stsendablevar 0x0, 0x0 + ldhole + sta v0 + callruntime.definesendableclass 0x3, .#~@1=#TopLevelSendableClass2, _5, 0x0, v0 + callruntime.stsendablevar 0x0, 0x1 + ldhole + sta v0 + callruntime.definesendableclass 0x4, .#~@2=#TopLevelSendableClass3, _7, 0x0, v0 + callruntime.stsendablevar 0x0, 0x2 + ldhole + sta v0 + callruntime.definesendableclass 0x5, .#~@3=#TopLevelSendableClass4, _9, 0x0, v0 + callruntime.stsendablevar 0x0, 0x3 + ldhole + sta v0 + callruntime.definesendableclass 0x6, .#~@4=#TopLevelSendableClass5, _11, 0x0, v0 + callruntime.stsendablevar 0x0, 0x4 + ldhole + sta v0 + callruntime.definesendableclass 0x7, .#~@5=#TopLevelSendableClass6, _13, 0x0, v0 + callruntime.stsendablevar 0x0, 0x5 + ldhole + sta v0 + callruntime.definesendableclass 0x8, .#~@6=#TopLevelSendableClass7, _15, 0x0, v0 + callruntime.stsendablevar 0x0, 0x6 + ldhole + sta v0 + callruntime.definesendableclass 0x9, .#~@7=#TopLevelSendableClass8, _17, 0x0, v0 + callruntime.stsendablevar 0x0, 0x7 + ldhole + sta v0 + callruntime.definesendableclass 0xa, .#~@8=#TopLevelSendableClass9, _19, 0x0, v0 + callruntime.stsendablevar 0x0, 0x8 + ldhole + sta v0 + callruntime.definesendableclass 0xb, .#~@9=#TopLevelSendableClass10, _21, 0x0, v0 + callruntime.stsendablevar 0x0, 0x9 + ldhole + sta v0 + callruntime.definesendableclass 0xc, .#~@a=#TopLevelSendableClass11, _23, 0x0, v0 + callruntime.stsendablevar 0x0, 0xa + ldhole + sta v0 + callruntime.definesendableclass 0xd, .#~@b=#TopLevelSendableClass12, _25, 0x0, v0 + callruntime.stsendablevar 0x0, 0xb + ldhole + sta v0 + callruntime.definesendableclass 0xe, .#~@c=#TopLevelSendableClass13, _27, 0x0, v0 + callruntime.stsendablevar 0x0, 0xc + ldhole + sta v0 + callruntime.definesendableclass 0xf, .#~@d=#TopLevelSendableClass14, _29, 0x0, v0 + callruntime.stsendablevar 0x0, 0xd + ldhole + sta v0 + callruntime.definesendableclass 0x10, .#~@e=#TopLevelSendableClass15, _31, 0x0, v0 + callruntime.stsendablevar 0x0, 0xe + ldhole + sta v0 + callruntime.definesendableclass 0x11, .#~@f=#TopLevelSendableClass16, _33, 0x0, v0 + callruntime.stsendablevar 0x0, 0xf + ldhole + sta v0 + callruntime.definesendableclass 0x12, .#~@10=#TopLevelSendableClass17, _35, 0x0, v0 + callruntime.stsendablevar 0x0, 0x10 + ldhole + sta v0 + callruntime.definesendableclass 0x13, .#~@11=#TopLevelSendableClass18, _37, 0x0, v0 + callruntime.stsendablevar 0x0, 0x11 + ldhole + sta v0 + callruntime.definesendableclass 0x14, .#~@12=#TopLevelSendableClass19, _39, 0x0, v0 + callruntime.stsendablevar 0x0, 0x12 + ldhole + sta v0 + callruntime.definesendableclass 0x15, .#~@13=#TopLevelSendableClass20, _41, 0x0, v0 + callruntime.stsendablevar 0x0, 0x13 + ldhole + sta v0 + callruntime.definesendableclass 0x16, .#~@14=#TopLevelSendableClass21, _43, 0x0, v0 + callruntime.stsendablevar 0x0, 0x14 + ldhole + sta v0 + callruntime.definesendableclass 0x17, .#~@15=#TopLevelSendableClass22, _45, 0x0, v0 + callruntime.stsendablevar 0x0, 0x15 + ldhole + sta v0 + callruntime.definesendableclass 0x18, .#~@16=#TopLevelSendableClass23, _47, 0x0, v0 + callruntime.stsendablevar 0x0, 0x16 + ldhole + sta v0 + callruntime.definesendableclass 0x19, .#~@17=#TopLevelSendableClass24, _49, 0x0, v0 + callruntime.stsendablevar 0x0, 0x17 + ldhole + sta v0 + callruntime.definesendableclass 0x1a, .#~@18=#TopLevelSendableClass25, _51, 0x0, v0 + callruntime.stsendablevar 0x0, 0x18 + ldhole + sta v0 + callruntime.definesendableclass 0x1b, .#~@19=#TopLevelSendableClass26, _53, 0x0, v0 + callruntime.stsendablevar 0x0, 0x19 + ldhole + sta v0 + callruntime.definesendableclass 0x1c, .#~@1a=#TopLevelSendableClass27, _55, 0x0, v0 + callruntime.stsendablevar 0x0, 0x1a + ldhole + sta v0 + callruntime.definesendableclass 0x1d, .#~@1b=#TopLevelSendableClass28, _57, 0x0, v0 + callruntime.stsendablevar 0x0, 0x1b + ldhole + sta v0 + callruntime.definesendableclass 0x1e, .#~@1c=#TopLevelSendableClass29, _59, 0x0, v0 + callruntime.stsendablevar 0x0, 0x1c + ldhole + sta v0 + callruntime.definesendableclass 0x1f, .#~@1d=#TopLevelSendableClass30, _61, 0x0, v0 + callruntime.stsendablevar 0x0, 0x1d + ldhole + sta v0 + callruntime.definesendableclass 0x20, .#~@1e=#TopLevelSendableClass31, _63, 0x0, v0 + callruntime.stsendablevar 0x0, 0x1e + ldhole + sta v0 + callruntime.definesendableclass 0x21, .#~@1f=#TopLevelSendableClass32, _65, 0x0, v0 + callruntime.stsendablevar 0x0, 0x1f + ldhole + sta v0 + callruntime.definesendableclass 0x22, .#~@20=#TopLevelSendableClass33, _67, 0x0, v0 + callruntime.stsendablevar 0x0, 0x20 + ldhole + sta v0 + callruntime.definesendableclass 0x23, .#~@21=#TopLevelSendableClass34, _69, 0x0, v0 + callruntime.stsendablevar 0x0, 0x21 + ldhole + sta v0 + callruntime.definesendableclass 0x24, .#~@22=#TopLevelSendableClass35, _71, 0x0, v0 + callruntime.stsendablevar 0x0, 0x22 + ldhole + sta v0 + callruntime.definesendableclass 0x25, .#~@23=#TopLevelSendableClass36, _73, 0x0, v0 + callruntime.stsendablevar 0x0, 0x23 + ldhole + sta v0 + callruntime.definesendableclass 0x26, .#~@24=#TopLevelSendableClass37, _75, 0x0, v0 + callruntime.stsendablevar 0x0, 0x24 + ldhole + sta v0 + callruntime.definesendableclass 0x27, .#~@25=#TopLevelSendableClass38, _77, 0x0, v0 + callruntime.stsendablevar 0x0, 0x25 + ldhole + sta v0 + callruntime.definesendableclass 0x28, .#~@26=#TopLevelSendableClass39, _79, 0x0, v0 + callruntime.stsendablevar 0x0, 0x26 + ldhole + sta v0 + callruntime.definesendableclass 0x29, .#~@27=#TopLevelSendableClass40, _81, 0x0, v0 + callruntime.stsendablevar 0x0, 0x27 + ldhole + sta v0 + callruntime.definesendableclass 0x2a, .#~@28=#TopLevelSendableClass41, _83, 0x0, v0 + callruntime.stsendablevar 0x0, 0x28 + ldhole + sta v0 + callruntime.definesendableclass 0x2b, .#~@29=#TopLevelSendableClass42, _85, 0x0, v0 + callruntime.stsendablevar 0x0, 0x29 + ldhole + sta v0 + callruntime.definesendableclass 0x2c, .#~@2a=#TopLevelSendableClass43, _87, 0x0, v0 + callruntime.stsendablevar 0x0, 0x2a + ldhole + sta v0 + callruntime.definesendableclass 0x2d, .#~@2b=#TopLevelSendableClass44, _89, 0x0, v0 + callruntime.stsendablevar 0x0, 0x2b + ldhole + sta v0 + callruntime.definesendableclass 0x2e, .#~@2c=#TopLevelSendableClass45, _91, 0x0, v0 + callruntime.stsendablevar 0x0, 0x2c + ldhole + sta v0 + callruntime.definesendableclass 0x2f, .#~@2d=#TopLevelSendableClass46, _93, 0x0, v0 + callruntime.stsendablevar 0x0, 0x2d + ldhole + sta v0 + callruntime.definesendableclass 0x30, .#~@2e=#TopLevelSendableClass47, _95, 0x0, v0 + callruntime.stsendablevar 0x0, 0x2e + ldhole + sta v0 + callruntime.definesendableclass 0x31, .#~@2f=#TopLevelSendableClass48, _97, 0x0, v0 + callruntime.stsendablevar 0x0, 0x2f + ldhole + sta v0 + callruntime.definesendableclass 0x32, .#~@30=#TopLevelSendableClass49, _99, 0x0, v0 + callruntime.stsendablevar 0x0, 0x30 + ldhole + sta v0 + callruntime.definesendableclass 0x33, .#~@31=#TopLevelSendableClass50, _101, 0x0, v0 + callruntime.stsendablevar 0x0, 0x31 + ldhole + sta v0 + callruntime.definesendableclass 0x34, .#~@32=#TopLevelSendableClass51, _103, 0x0, v0 + callruntime.stsendablevar 0x0, 0x32 + ldhole + sta v0 + callruntime.definesendableclass 0x35, .#~@33=#TopLevelSendableClass52, _105, 0x0, v0 + callruntime.stsendablevar 0x0, 0x33 + ldhole + sta v0 + callruntime.definesendableclass 0x36, .#~@34=#TopLevelSendableClass53, _107, 0x0, v0 + callruntime.stsendablevar 0x0, 0x34 + ldhole + sta v0 + callruntime.definesendableclass 0x37, .#~@35=#TopLevelSendableClass54, _109, 0x0, v0 + callruntime.stsendablevar 0x0, 0x35 + ldhole + sta v0 + callruntime.definesendableclass 0x38, .#~@36=#TopLevelSendableClass55, _111, 0x0, v0 + callruntime.stsendablevar 0x0, 0x36 + ldhole + sta v0 + callruntime.definesendableclass 0x39, .#~@37=#TopLevelSendableClass56, _113, 0x0, v0 + callruntime.stsendablevar 0x0, 0x37 + ldhole + sta v0 + callruntime.definesendableclass 0x3a, .#~@38=#TopLevelSendableClass57, _115, 0x0, v0 + callruntime.stsendablevar 0x0, 0x38 + ldhole + sta v0 + callruntime.definesendableclass 0x3b, .#~@39=#TopLevelSendableClass58, _117, 0x0, v0 + callruntime.stsendablevar 0x0, 0x39 + ldhole + sta v0 + callruntime.definesendableclass 0x3c, .#~@3a=#TopLevelSendableClass59, _119, 0x0, v0 + callruntime.stsendablevar 0x0, 0x3a + ldhole + sta v0 + callruntime.definesendableclass 0x3d, .#~@3b=#TopLevelSendableClass60, _121, 0x0, v0 + callruntime.stsendablevar 0x0, 0x3b + ldhole + sta v0 + callruntime.definesendableclass 0x3e, .#~@3c=#TopLevelSendableClass61, _123, 0x0, v0 + callruntime.stsendablevar 0x0, 0x3c + ldhole + sta v0 + callruntime.definesendableclass 0x3f, .#~@3d=#TopLevelSendableClass62, _125, 0x0, v0 + callruntime.stsendablevar 0x0, 0x3d + ldhole + sta v0 + callruntime.definesendableclass 0x40, .#~@3e=#TopLevelSendableClass63, _127, 0x0, v0 + callruntime.stsendablevar 0x0, 0x3e + ldhole + sta v0 + callruntime.definesendableclass 0x41, .#~@3f=#TopLevelSendableClass64, _129, 0x0, v0 + callruntime.stsendablevar 0x0, 0x3f + ldhole + sta v0 + callruntime.definesendableclass 0x42, .#~@40=#TopLevelSendableClass65, _131, 0x0, v0 + callruntime.stsendablevar 0x0, 0x40 + ldhole + sta v0 + callruntime.definesendableclass 0x43, .#~@41=#TopLevelSendableClass66, _133, 0x0, v0 + callruntime.stsendablevar 0x0, 0x41 + ldhole + sta v0 + callruntime.definesendableclass 0x44, .#~@42=#TopLevelSendableClass67, _135, 0x0, v0 + callruntime.stsendablevar 0x0, 0x42 + ldhole + sta v0 + callruntime.definesendableclass 0x45, .#~@43=#TopLevelSendableClass68, _137, 0x0, v0 + callruntime.stsendablevar 0x0, 0x43 + ldhole + sta v0 + callruntime.definesendableclass 0x46, .#~@44=#TopLevelSendableClass69, _139, 0x0, v0 + callruntime.stsendablevar 0x0, 0x44 + ldhole + sta v0 + callruntime.definesendableclass 0x47, .#~@45=#TopLevelSendableClass70, _141, 0x0, v0 + callruntime.stsendablevar 0x0, 0x45 + ldhole + sta v0 + callruntime.definesendableclass 0x48, .#~@46=#TopLevelSendableClass71, _143, 0x0, v0 + callruntime.stsendablevar 0x0, 0x46 + ldhole + sta v0 + callruntime.definesendableclass 0x49, .#~@47=#TopLevelSendableClass72, _145, 0x0, v0 + callruntime.stsendablevar 0x0, 0x47 + ldhole + sta v0 + callruntime.definesendableclass 0x4a, .#~@48=#TopLevelSendableClass73, _147, 0x0, v0 + callruntime.stsendablevar 0x0, 0x48 + ldhole + sta v0 + callruntime.definesendableclass 0x4b, .#~@49=#TopLevelSendableClass74, _149, 0x0, v0 + callruntime.stsendablevar 0x0, 0x49 + ldhole + sta v0 + callruntime.definesendableclass 0x4c, .#~@4a=#TopLevelSendableClass75, _151, 0x0, v0 + callruntime.stsendablevar 0x0, 0x4a + ldhole + sta v0 + callruntime.definesendableclass 0x4d, .#~@4b=#TopLevelSendableClass76, _153, 0x0, v0 + callruntime.stsendablevar 0x0, 0x4b + ldhole + sta v0 + callruntime.definesendableclass 0x4e, .#~@4c=#TopLevelSendableClass77, _155, 0x0, v0 + callruntime.stsendablevar 0x0, 0x4c + ldhole + sta v0 + callruntime.definesendableclass 0x4f, .#~@4d=#TopLevelSendableClass78, _157, 0x0, v0 + callruntime.stsendablevar 0x0, 0x4d + ldhole + sta v0 + callruntime.definesendableclass 0x50, .#~@4e=#TopLevelSendableClass79, _159, 0x0, v0 + callruntime.stsendablevar 0x0, 0x4e + ldhole + sta v0 + callruntime.definesendableclass 0x51, .#~@4f=#TopLevelSendableClass80, _161, 0x0, v0 + callruntime.stsendablevar 0x0, 0x4f + ldhole + sta v0 + callruntime.definesendableclass 0x52, .#~@50=#TopLevelSendableClass81, _163, 0x0, v0 + callruntime.stsendablevar 0x0, 0x50 + ldhole + sta v0 + callruntime.definesendableclass 0x53, .#~@51=#TopLevelSendableClass82, _165, 0x0, v0 + callruntime.stsendablevar 0x0, 0x51 + ldhole + sta v0 + callruntime.definesendableclass 0x54, .#~@52=#TopLevelSendableClass83, _167, 0x0, v0 + callruntime.stsendablevar 0x0, 0x52 + ldhole + sta v0 + callruntime.definesendableclass 0x55, .#~@53=#TopLevelSendableClass84, _169, 0x0, v0 + callruntime.stsendablevar 0x0, 0x53 + ldhole + sta v0 + callruntime.definesendableclass 0x56, .#~@54=#TopLevelSendableClass85, _171, 0x0, v0 + callruntime.stsendablevar 0x0, 0x54 + ldhole + sta v0 + callruntime.definesendableclass 0x57, .#~@55=#TopLevelSendableClass86, _173, 0x0, v0 + callruntime.stsendablevar 0x0, 0x55 + ldhole + sta v0 + callruntime.definesendableclass 0x58, .#~@56=#TopLevelSendableClass87, _175, 0x0, v0 + callruntime.stsendablevar 0x0, 0x56 + ldhole + sta v0 + callruntime.definesendableclass 0x59, .#~@57=#TopLevelSendableClass88, _177, 0x0, v0 + callruntime.stsendablevar 0x0, 0x57 + ldhole + sta v0 + callruntime.definesendableclass 0x5a, .#~@58=#TopLevelSendableClass89, _179, 0x0, v0 + callruntime.stsendablevar 0x0, 0x58 + ldhole + sta v0 + callruntime.definesendableclass 0x5b, .#~@59=#TopLevelSendableClass90, _181, 0x0, v0 + callruntime.stsendablevar 0x0, 0x59 + ldhole + sta v0 + callruntime.definesendableclass 0x5c, .#~@5a=#TopLevelSendableClass91, _183, 0x0, v0 + callruntime.stsendablevar 0x0, 0x5a + ldhole + sta v0 + callruntime.definesendableclass 0x5d, .#~@5b=#TopLevelSendableClass92, _185, 0x0, v0 + callruntime.stsendablevar 0x0, 0x5b + ldhole + sta v0 + callruntime.definesendableclass 0x5e, .#~@5c=#TopLevelSendableClass93, _187, 0x0, v0 + callruntime.stsendablevar 0x0, 0x5c + ldhole + sta v0 + callruntime.definesendableclass 0x5f, .#~@5d=#TopLevelSendableClass94, _189, 0x0, v0 + callruntime.stsendablevar 0x0, 0x5d + ldhole + sta v0 + callruntime.definesendableclass 0x60, .#~@5e=#TopLevelSendableClass95, _191, 0x0, v0 + callruntime.stsendablevar 0x0, 0x5e + ldhole + sta v0 + callruntime.definesendableclass 0x61, .#~@5f=#TopLevelSendableClass96, _193, 0x0, v0 + callruntime.stsendablevar 0x0, 0x5f + ldhole + sta v0 + callruntime.definesendableclass 0x62, .#~@60=#TopLevelSendableClass97, _195, 0x0, v0 + callruntime.stsendablevar 0x0, 0x60 + ldhole + sta v0 + callruntime.definesendableclass 0x63, .#~@61=#TopLevelSendableClass98, _197, 0x0, v0 + callruntime.stsendablevar 0x0, 0x61 + ldhole + sta v0 + callruntime.definesendableclass 0x64, .#~@62=#TopLevelSendableClass99, _199, 0x0, v0 + callruntime.stsendablevar 0x0, 0x62 + ldhole + sta v0 + callruntime.definesendableclass 0x65, .#~@63=#TopLevelSendableClass100, _201, 0x0, v0 + callruntime.stsendablevar 0x0, 0x63 + ldhole + sta v0 + callruntime.definesendableclass 0x66, .#~@64=#TopLevelSendableClass101, _203, 0x0, v0 + callruntime.stsendablevar 0x0, 0x64 + ldhole + sta v0 + callruntime.definesendableclass 0x67, .#~@65=#TopLevelSendableClass102, _205, 0x0, v0 + callruntime.stsendablevar 0x0, 0x65 + ldhole + sta v0 + callruntime.definesendableclass 0x68, .#~@66=#TopLevelSendableClass103, _207, 0x0, v0 + callruntime.stsendablevar 0x0, 0x66 + ldhole + sta v0 + callruntime.definesendableclass 0x69, .#~@67=#TopLevelSendableClass104, _209, 0x0, v0 + callruntime.stsendablevar 0x0, 0x67 + ldhole + sta v0 + callruntime.definesendableclass 0x6a, .#~@68=#TopLevelSendableClass105, _211, 0x0, v0 + callruntime.stsendablevar 0x0, 0x68 + ldhole + sta v0 + callruntime.definesendableclass 0x6b, .#~@69=#TopLevelSendableClass106, _213, 0x0, v0 + callruntime.stsendablevar 0x0, 0x69 + ldhole + sta v0 + callruntime.definesendableclass 0x6c, .#~@6a=#TopLevelSendableClass107, _215, 0x0, v0 + callruntime.stsendablevar 0x0, 0x6a + ldhole + sta v0 + callruntime.definesendableclass 0x6d, .#~@6b=#TopLevelSendableClass108, _217, 0x0, v0 + callruntime.stsendablevar 0x0, 0x6b + ldhole + sta v0 + callruntime.definesendableclass 0x6e, .#~@6c=#TopLevelSendableClass109, _219, 0x0, v0 + callruntime.stsendablevar 0x0, 0x6c + ldhole + sta v0 + callruntime.definesendableclass 0x6f, .#~@6d=#TopLevelSendableClass110, _221, 0x0, v0 + callruntime.stsendablevar 0x0, 0x6d + ldhole + sta v0 + callruntime.definesendableclass 0x70, .#~@6e=#TopLevelSendableClass111, _223, 0x0, v0 + callruntime.stsendablevar 0x0, 0x6e + ldhole + sta v0 + callruntime.definesendableclass 0x71, .#~@6f=#TopLevelSendableClass112, _225, 0x0, v0 + callruntime.stsendablevar 0x0, 0x6f + ldhole + sta v0 + callruntime.definesendableclass 0x72, .#~@70=#TopLevelSendableClass113, _227, 0x0, v0 + callruntime.stsendablevar 0x0, 0x70 + ldhole + sta v0 + callruntime.definesendableclass 0x73, .#~@71=#TopLevelSendableClass114, _229, 0x0, v0 + callruntime.stsendablevar 0x0, 0x71 + ldhole + sta v0 + callruntime.definesendableclass 0x74, .#~@72=#TopLevelSendableClass115, _231, 0x0, v0 + callruntime.stsendablevar 0x0, 0x72 + ldhole + sta v0 + callruntime.definesendableclass 0x75, .#~@73=#TopLevelSendableClass116, _233, 0x0, v0 + callruntime.stsendablevar 0x0, 0x73 + ldhole + sta v0 + callruntime.definesendableclass 0x76, .#~@74=#TopLevelSendableClass117, _235, 0x0, v0 + callruntime.stsendablevar 0x0, 0x74 + ldhole + sta v0 + callruntime.definesendableclass 0x77, .#~@75=#TopLevelSendableClass118, _237, 0x0, v0 + callruntime.stsendablevar 0x0, 0x75 + ldhole + sta v0 + callruntime.definesendableclass 0x78, .#~@76=#TopLevelSendableClass119, _239, 0x0, v0 + callruntime.stsendablevar 0x0, 0x76 + ldhole + sta v0 + callruntime.definesendableclass 0x79, .#~@77=#TopLevelSendableClass120, _241, 0x0, v0 + callruntime.stsendablevar 0x0, 0x77 + ldhole + sta v0 + callruntime.definesendableclass 0x7a, .#~@78=#TopLevelSendableClass121, _243, 0x0, v0 + callruntime.stsendablevar 0x0, 0x78 + ldhole + sta v0 + callruntime.definesendableclass 0x7b, .#~@79=#TopLevelSendableClass122, _245, 0x0, v0 + callruntime.stsendablevar 0x0, 0x79 + ldhole + sta v0 + callruntime.definesendableclass 0x7c, .#~@7a=#TopLevelSendableClass123, _247, 0x0, v0 + callruntime.stsendablevar 0x0, 0x7a + ldhole + sta v0 + callruntime.definesendableclass 0x7d, .#~@7b=#TopLevelSendableClass124, _249, 0x0, v0 + callruntime.stsendablevar 0x0, 0x7b + ldhole + sta v0 + callruntime.definesendableclass 0x7e, .#~@7c=#TopLevelSendableClass125, _251, 0x0, v0 + callruntime.stsendablevar 0x0, 0x7c + ldhole + sta v0 + callruntime.definesendableclass 0x7f, .#~@7d=#TopLevelSendableClass126, _253, 0x0, v0 + callruntime.stsendablevar 0x0, 0x7d + ldhole + sta v0 + callruntime.definesendableclass 0x80, .#~@7e=#TopLevelSendableClass127, _255, 0x0, v0 + callruntime.stsendablevar 0x0, 0x7e + ldhole + sta v0 + callruntime.definesendableclass 0x81, .#~@7f=#TopLevelSendableClass128, _257, 0x0, v0 + callruntime.stsendablevar 0x0, 0x7f + ldhole + sta v0 + callruntime.definesendableclass 0x82, .#~@80=#TopLevelSendableClass129, _259, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x80 + ldhole + sta v0 + callruntime.definesendableclass 0x83, .#~@81=#TopLevelSendableClass130, _261, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x81 + ldhole + sta v0 + callruntime.definesendableclass 0x84, .#~@82=#TopLevelSendableClass131, _263, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x82 + ldhole + sta v0 + callruntime.definesendableclass 0x85, .#~@83=#TopLevelSendableClass132, _265, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x83 + ldhole + sta v0 + callruntime.definesendableclass 0x86, .#~@84=#TopLevelSendableClass133, _267, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x84 + ldhole + sta v0 + callruntime.definesendableclass 0x87, .#~@85=#TopLevelSendableClass134, _269, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x85 + ldhole + sta v0 + callruntime.definesendableclass 0x88, .#~@86=#TopLevelSendableClass135, _271, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x86 + ldhole + sta v0 + callruntime.definesendableclass 0x89, .#~@87=#TopLevelSendableClass136, _273, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x87 + ldhole + sta v0 + callruntime.definesendableclass 0x8a, .#~@88=#TopLevelSendableClass137, _275, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x88 + ldhole + sta v0 + callruntime.definesendableclass 0x8b, .#~@89=#TopLevelSendableClass138, _277, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x89 + ldhole + sta v0 + callruntime.definesendableclass 0x8c, .#~@8a=#TopLevelSendableClass139, _279, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x8a + ldhole + sta v0 + callruntime.definesendableclass 0x8d, .#~@8b=#TopLevelSendableClass140, _281, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x8b + ldhole + sta v0 + callruntime.definesendableclass 0x8e, .#~@8c=#TopLevelSendableClass141, _283, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x8c + ldhole + sta v0 + callruntime.definesendableclass 0x8f, .#~@8d=#TopLevelSendableClass142, _285, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x8d + ldhole + sta v0 + callruntime.definesendableclass 0x90, .#~@8e=#TopLevelSendableClass143, _287, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x8e + ldhole + sta v0 + callruntime.definesendableclass 0x91, .#~@8f=#TopLevelSendableClass144, _289, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x8f + ldhole + sta v0 + callruntime.definesendableclass 0x92, .#~@90=#TopLevelSendableClass145, _291, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x90 + ldhole + sta v0 + callruntime.definesendableclass 0x93, .#~@91=#TopLevelSendableClass146, _293, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x91 + ldhole + sta v0 + callruntime.definesendableclass 0x94, .#~@92=#TopLevelSendableClass147, _295, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x92 + ldhole + sta v0 + callruntime.definesendableclass 0x95, .#~@93=#TopLevelSendableClass148, _297, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x93 + ldhole + sta v0 + callruntime.definesendableclass 0x96, .#~@94=#TopLevelSendableClass149, _299, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x94 + ldhole + sta v0 + callruntime.definesendableclass 0x97, .#~@95=#TopLevelSendableClass150, _301, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x95 + ldhole + sta v0 + callruntime.definesendableclass 0x98, .#~@96=#TopLevelSendableClass151, _303, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x96 + ldhole + sta v0 + callruntime.definesendableclass 0x99, .#~@97=#TopLevelSendableClass152, _305, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x97 + ldhole + sta v0 + callruntime.definesendableclass 0x9a, .#~@98=#TopLevelSendableClass153, _307, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x98 + ldhole + sta v0 + callruntime.definesendableclass 0x9b, .#~@99=#TopLevelSendableClass154, _309, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x99 + ldhole + sta v0 + callruntime.definesendableclass 0x9c, .#~@9a=#TopLevelSendableClass155, _311, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x9a + ldhole + sta v0 + callruntime.definesendableclass 0x9d, .#~@9b=#TopLevelSendableClass156, _313, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x9b + ldhole + sta v0 + callruntime.definesendableclass 0x9e, .#~@9c=#TopLevelSendableClass157, _315, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x9c + ldhole + sta v0 + callruntime.definesendableclass 0x9f, .#~@9d=#TopLevelSendableClass158, _317, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x9d + ldhole + sta v0 + callruntime.definesendableclass 0xa0, .#~@9e=#TopLevelSendableClass159, _319, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x9e + ldhole + sta v0 + callruntime.definesendableclass 0xa1, .#~@9f=#TopLevelSendableClass160, _321, 0x0, v0 + callruntime.widestsendablevar 0x0, 0x9f + ldhole + sta v0 + callruntime.definesendableclass 0xa2, .#~@a0=#TopLevelSendableClass161, _323, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa0 + ldhole + sta v0 + callruntime.definesendableclass 0xa3, .#~@a1=#TopLevelSendableClass162, _325, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa1 + ldhole + sta v0 + callruntime.definesendableclass 0xa4, .#~@a2=#TopLevelSendableClass163, _327, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa2 + ldhole + sta v0 + callruntime.definesendableclass 0xa5, .#~@a3=#TopLevelSendableClass164, _329, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa3 + ldhole + sta v0 + callruntime.definesendableclass 0xa6, .#~@a4=#TopLevelSendableClass165, _331, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa4 + ldhole + sta v0 + callruntime.definesendableclass 0xa7, .#~@a5=#TopLevelSendableClass166, _333, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa5 + ldhole + sta v0 + callruntime.definesendableclass 0xa8, .#~@a6=#TopLevelSendableClass167, _335, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa6 + ldhole + sta v0 + callruntime.definesendableclass 0xa9, .#~@a7=#TopLevelSendableClass168, _337, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa7 + ldhole + sta v0 + callruntime.definesendableclass 0xaa, .#~@a8=#TopLevelSendableClass169, _339, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa8 + ldhole + sta v0 + callruntime.definesendableclass 0xab, .#~@a9=#TopLevelSendableClass170, _341, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xa9 + ldhole + sta v0 + callruntime.definesendableclass 0xac, .#~@aa=#TopLevelSendableClass171, _343, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xaa + ldhole + sta v0 + callruntime.definesendableclass 0xad, .#~@ab=#TopLevelSendableClass172, _345, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xab + ldhole + sta v0 + callruntime.definesendableclass 0xae, .#~@ac=#TopLevelSendableClass173, _347, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xac + ldhole + sta v0 + callruntime.definesendableclass 0xaf, .#~@ad=#TopLevelSendableClass174, _349, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xad + ldhole + sta v0 + callruntime.definesendableclass 0xb0, .#~@ae=#TopLevelSendableClass175, _351, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xae + ldhole + sta v0 + callruntime.definesendableclass 0xb1, .#~@af=#TopLevelSendableClass176, _353, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xaf + ldhole + sta v0 + callruntime.definesendableclass 0xb2, .#~@b0=#TopLevelSendableClass177, _355, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb0 + ldhole + sta v0 + callruntime.definesendableclass 0xb3, .#~@b1=#TopLevelSendableClass178, _357, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb1 + ldhole + sta v0 + callruntime.definesendableclass 0xb4, .#~@b2=#TopLevelSendableClass179, _359, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb2 + ldhole + sta v0 + callruntime.definesendableclass 0xb5, .#~@b3=#TopLevelSendableClass180, _361, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb3 + ldhole + sta v0 + callruntime.definesendableclass 0xb6, .#~@b4=#TopLevelSendableClass181, _363, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb4 + ldhole + sta v0 + callruntime.definesendableclass 0xb7, .#~@b5=#TopLevelSendableClass182, _365, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb5 + ldhole + sta v0 + callruntime.definesendableclass 0xb8, .#~@b6=#TopLevelSendableClass183, _367, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb6 + ldhole + sta v0 + callruntime.definesendableclass 0xb9, .#~@b7=#TopLevelSendableClass184, _369, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb7 + ldhole + sta v0 + callruntime.definesendableclass 0xba, .#~@b8=#TopLevelSendableClass185, _371, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb8 + ldhole + sta v0 + callruntime.definesendableclass 0xbb, .#~@b9=#TopLevelSendableClass186, _373, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xb9 + ldhole + sta v0 + callruntime.definesendableclass 0xbc, .#~@ba=#TopLevelSendableClass187, _375, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xba + ldhole + sta v0 + callruntime.definesendableclass 0xbd, .#~@bb=#TopLevelSendableClass188, _377, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xbb + ldhole + sta v0 + callruntime.definesendableclass 0xbe, .#~@bc=#TopLevelSendableClass189, _379, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xbc + ldhole + sta v0 + callruntime.definesendableclass 0xbf, .#~@bd=#TopLevelSendableClass190, _381, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xbd + ldhole + sta v0 + callruntime.definesendableclass 0xc0, .#~@be=#TopLevelSendableClass191, _383, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xbe + ldhole + sta v0 + callruntime.definesendableclass 0xc1, .#~@bf=#TopLevelSendableClass192, _385, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xbf + ldhole + sta v0 + callruntime.definesendableclass 0xc2, .#~@c0=#TopLevelSendableClass193, _387, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc0 + ldhole + sta v0 + callruntime.definesendableclass 0xc3, .#~@c1=#TopLevelSendableClass194, _389, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc1 + ldhole + sta v0 + callruntime.definesendableclass 0xc4, .#~@c2=#TopLevelSendableClass195, _391, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc2 + ldhole + sta v0 + callruntime.definesendableclass 0xc5, .#~@c3=#TopLevelSendableClass196, _393, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc3 + ldhole + sta v0 + callruntime.definesendableclass 0xc6, .#~@c4=#TopLevelSendableClass197, _395, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc4 + ldhole + sta v0 + callruntime.definesendableclass 0xc7, .#~@c5=#TopLevelSendableClass198, _397, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc5 + ldhole + sta v0 + callruntime.definesendableclass 0xc8, .#~@c6=#TopLevelSendableClass199, _399, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc6 + ldhole + sta v0 + callruntime.definesendableclass 0xc9, .#~@c7=#TopLevelSendableClass200, _401, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc7 + ldhole + sta v0 + callruntime.definesendableclass 0xca, .#~@c8=#TopLevelSendableClass201, _403, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc8 + ldhole + sta v0 + callruntime.definesendableclass 0xcb, .#~@c9=#TopLevelSendableClass202, _405, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xc9 + ldhole + sta v0 + callruntime.definesendableclass 0xcc, .#~@ca=#TopLevelSendableClass203, _407, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xca + ldhole + sta v0 + callruntime.definesendableclass 0xcd, .#~@cb=#TopLevelSendableClass204, _409, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xcb + ldhole + sta v0 + callruntime.definesendableclass 0xce, .#~@cc=#TopLevelSendableClass205, _411, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xcc + ldhole + sta v0 + callruntime.definesendableclass 0xcf, .#~@cd=#TopLevelSendableClass206, _413, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xcd + ldhole + sta v0 + callruntime.definesendableclass 0xd0, .#~@ce=#TopLevelSendableClass207, _415, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xce + ldhole + sta v0 + callruntime.definesendableclass 0xd1, .#~@cf=#TopLevelSendableClass208, _417, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xcf + ldhole + sta v0 + callruntime.definesendableclass 0xd2, .#~@d0=#TopLevelSendableClass209, _419, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd0 + ldhole + sta v0 + callruntime.definesendableclass 0xd3, .#~@d1=#TopLevelSendableClass210, _421, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd1 + ldhole + sta v0 + callruntime.definesendableclass 0xd4, .#~@d2=#TopLevelSendableClass211, _423, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd2 + ldhole + sta v0 + callruntime.definesendableclass 0xd5, .#~@d3=#TopLevelSendableClass212, _425, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd3 + ldhole + sta v0 + callruntime.definesendableclass 0xd6, .#~@d4=#TopLevelSendableClass213, _427, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd4 + ldhole + sta v0 + callruntime.definesendableclass 0xd7, .#~@d5=#TopLevelSendableClass214, _429, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd5 + ldhole + sta v0 + callruntime.definesendableclass 0xd8, .#~@d6=#TopLevelSendableClass215, _431, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd6 + ldhole + sta v0 + callruntime.definesendableclass 0xd9, .#~@d7=#TopLevelSendableClass216, _433, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd7 + ldhole + sta v0 + callruntime.definesendableclass 0xda, .#~@d8=#TopLevelSendableClass217, _435, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd8 + ldhole + sta v0 + callruntime.definesendableclass 0xdb, .#~@d9=#TopLevelSendableClass218, _437, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xd9 + ldhole + sta v0 + callruntime.definesendableclass 0xdc, .#~@da=#TopLevelSendableClass219, _439, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xda + ldhole + sta v0 + callruntime.definesendableclass 0xdd, .#~@db=#TopLevelSendableClass220, _441, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xdb + ldhole + sta v0 + callruntime.definesendableclass 0xde, .#~@dc=#TopLevelSendableClass221, _443, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xdc + ldhole + sta v0 + callruntime.definesendableclass 0xdf, .#~@dd=#TopLevelSendableClass222, _445, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xdd + ldhole + sta v0 + callruntime.definesendableclass 0xe0, .#~@de=#TopLevelSendableClass223, _447, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xde + ldhole + sta v0 + callruntime.definesendableclass 0xe1, .#~@df=#TopLevelSendableClass224, _449, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xdf + ldhole + sta v0 + callruntime.definesendableclass 0xe2, .#~@e0=#TopLevelSendableClass225, _451, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe0 + ldhole + sta v0 + callruntime.definesendableclass 0xe3, .#~@e1=#TopLevelSendableClass226, _453, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe1 + ldhole + sta v0 + callruntime.definesendableclass 0xe4, .#~@e2=#TopLevelSendableClass227, _455, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe2 + ldhole + sta v0 + callruntime.definesendableclass 0xe5, .#~@e3=#TopLevelSendableClass228, _457, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe3 + ldhole + sta v0 + callruntime.definesendableclass 0xe6, .#~@e4=#TopLevelSendableClass229, _459, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe4 + ldhole + sta v0 + callruntime.definesendableclass 0xe7, .#~@e5=#TopLevelSendableClass230, _461, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe5 + ldhole + sta v0 + callruntime.definesendableclass 0xe8, .#~@e6=#TopLevelSendableClass231, _463, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe6 + ldhole + sta v0 + callruntime.definesendableclass 0xe9, .#~@e7=#TopLevelSendableClass232, _465, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe7 + ldhole + sta v0 + callruntime.definesendableclass 0xea, .#~@e8=#TopLevelSendableClass233, _467, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe8 + ldhole + sta v0 + callruntime.definesendableclass 0xeb, .#~@e9=#TopLevelSendableClass234, _469, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xe9 + ldhole + sta v0 + callruntime.definesendableclass 0xec, .#~@ea=#TopLevelSendableClass235, _471, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xea + ldhole + sta v0 + callruntime.definesendableclass 0xed, .#~@eb=#TopLevelSendableClass236, _473, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xeb + ldhole + sta v0 + callruntime.definesendableclass 0xee, .#~@ec=#TopLevelSendableClass237, _475, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xec + ldhole + sta v0 + callruntime.definesendableclass 0xef, .#~@ed=#TopLevelSendableClass238, _477, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xed + ldhole + sta v0 + callruntime.definesendableclass 0xf0, .#~@ee=#TopLevelSendableClass239, _479, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xee + ldhole + sta v0 + callruntime.definesendableclass 0xf1, .#~@ef=#TopLevelSendableClass240, _481, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xef + ldhole + sta v0 + callruntime.definesendableclass 0xf2, .#~@f0=#TopLevelSendableClass241, _483, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf0 + ldhole + sta v0 + callruntime.definesendableclass 0xf3, .#~@f1=#TopLevelSendableClass242, _485, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf1 + ldhole + sta v0 + callruntime.definesendableclass 0xf4, .#~@f2=#TopLevelSendableClass243, _487, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf2 + ldhole + sta v0 + callruntime.definesendableclass 0xf5, .#~@f3=#TopLevelSendableClass244, _489, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf3 + ldhole + sta v0 + callruntime.definesendableclass 0xf6, .#~@f4=#TopLevelSendableClass245, _491, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf4 + ldhole + sta v0 + callruntime.definesendableclass 0xf7, .#~@f5=#TopLevelSendableClass246, _493, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf5 + ldhole + sta v0 + callruntime.definesendableclass 0xf8, .#~@f6=#TopLevelSendableClass247, _495, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf6 + ldhole + sta v0 + callruntime.definesendableclass 0xf9, .#~@f7=#TopLevelSendableClass248, _497, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf7 + ldhole + sta v0 + callruntime.definesendableclass 0xfa, .#~@f8=#TopLevelSendableClass249, _499, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf8 + ldhole + sta v0 + callruntime.definesendableclass 0xfb, .#~@f9=#TopLevelSendableClass250, _501, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xf9 + ldhole + sta v0 + callruntime.definesendableclass 0xfc, .#~@fa=#TopLevelSendableClass251, _503, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xfa + ldhole + sta v0 + callruntime.definesendableclass 0xfd, .#~@fb=#TopLevelSendableClass252, _505, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xfb + ldhole + sta v0 + callruntime.definesendableclass 0xfe, .#~@fc=#TopLevelSendableClass253, _507, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xfc + ldhole + sta v0 + callruntime.definesendableclass 0x100, .#~@fd=#TopLevelSendableClass254, _509, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xfd + ldhole + sta v0 + callruntime.definesendableclass 0x101, .#~@fe=#TopLevelSendableClass255, _511, 0x0, v0 + callruntime.widestsendablevar 0x0, 0xfe + ldhole + sta v0 + callruntime.definesendableclass 0x102, .#~@ff=#SendableTestClass1, _513, 0x0, v0 + sta v0 + mov v2, v0 + newobjrange 0x103, 0x1, v2 + sta v0 + tryldglobalbyname 0x105, print + sta v1 + lda v0 + ldobjbyname 0x106, v + sta v0 + lda v1 + callarg1 0x0, v0 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_below_API11_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_asm_version-expected.txt similarity index 95% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_below_API11_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_asm_version-expected.txt index 6cb40f7fb76e67872aeb9a7de77c205dbd96c971..6abb6478b6ef3dd027a05faf1bc024db17fc498c 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_below_API11_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x406 -expectedProperty = 0x101 .language ECMAScript .function any .SendableTestClass1(any a0, any a1, any a2) { label_1: @@ -1546,7 +1545,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass1(any a0, any a1, any a2) { label_1: @@ -1559,7 +1557,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass10(any a0, any a1, any a2) { label_1: @@ -1572,7 +1569,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass100(any a0, any a1, any a2) { label_1: @@ -1585,7 +1581,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass101(any a0, any a1, any a2) { label_1: @@ -1598,7 +1593,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass102(any a0, any a1, any a2) { label_1: @@ -1611,7 +1605,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass103(any a0, any a1, any a2) { label_1: @@ -1624,7 +1617,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass104(any a0, any a1, any a2) { label_1: @@ -1637,7 +1629,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass105(any a0, any a1, any a2) { label_1: @@ -1650,7 +1641,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass106(any a0, any a1, any a2) { label_1: @@ -1663,7 +1653,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass107(any a0, any a1, any a2) { label_1: @@ -1676,7 +1665,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass108(any a0, any a1, any a2) { label_1: @@ -1689,7 +1677,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass109(any a0, any a1, any a2) { label_1: @@ -1702,7 +1689,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass11(any a0, any a1, any a2) { label_1: @@ -1715,7 +1701,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass110(any a0, any a1, any a2) { label_1: @@ -1728,7 +1713,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass111(any a0, any a1, any a2) { label_1: @@ -1741,7 +1725,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass112(any a0, any a1, any a2) { label_1: @@ -1754,7 +1737,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass113(any a0, any a1, any a2) { label_1: @@ -1767,7 +1749,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass114(any a0, any a1, any a2) { label_1: @@ -1780,7 +1761,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass115(any a0, any a1, any a2) { label_1: @@ -1793,7 +1773,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass116(any a0, any a1, any a2) { label_1: @@ -1806,7 +1785,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass117(any a0, any a1, any a2) { label_1: @@ -1819,7 +1797,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass118(any a0, any a1, any a2) { label_1: @@ -1832,7 +1809,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass119(any a0, any a1, any a2) { label_1: @@ -1845,7 +1821,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass12(any a0, any a1, any a2) { label_1: @@ -1858,7 +1833,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass120(any a0, any a1, any a2) { label_1: @@ -1871,7 +1845,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass121(any a0, any a1, any a2) { label_1: @@ -1884,7 +1857,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass122(any a0, any a1, any a2) { label_1: @@ -1897,7 +1869,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass123(any a0, any a1, any a2) { label_1: @@ -1910,7 +1881,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass124(any a0, any a1, any a2) { label_1: @@ -1923,7 +1893,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass125(any a0, any a1, any a2) { label_1: @@ -1936,7 +1905,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass126(any a0, any a1, any a2) { label_1: @@ -1949,7 +1917,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass127(any a0, any a1, any a2) { label_1: @@ -1962,7 +1929,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass128(any a0, any a1, any a2) { label_1: @@ -1975,7 +1941,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass129(any a0, any a1, any a2) { label_1: @@ -1988,7 +1953,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass13(any a0, any a1, any a2) { label_1: @@ -2001,7 +1965,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass130(any a0, any a1, any a2) { label_1: @@ -2014,7 +1977,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass131(any a0, any a1, any a2) { label_1: @@ -2027,7 +1989,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass132(any a0, any a1, any a2) { label_1: @@ -2040,7 +2001,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass133(any a0, any a1, any a2) { label_1: @@ -2053,7 +2013,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass134(any a0, any a1, any a2) { label_1: @@ -2066,7 +2025,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass135(any a0, any a1, any a2) { label_1: @@ -2079,7 +2037,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass136(any a0, any a1, any a2) { label_1: @@ -2092,7 +2049,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass137(any a0, any a1, any a2) { label_1: @@ -2105,7 +2061,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass138(any a0, any a1, any a2) { label_1: @@ -2118,7 +2073,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass139(any a0, any a1, any a2) { label_1: @@ -2131,7 +2085,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass14(any a0, any a1, any a2) { label_1: @@ -2144,7 +2097,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass140(any a0, any a1, any a2) { label_1: @@ -2157,7 +2109,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass141(any a0, any a1, any a2) { label_1: @@ -2170,7 +2121,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass142(any a0, any a1, any a2) { label_1: @@ -2183,7 +2133,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass143(any a0, any a1, any a2) { label_1: @@ -2196,7 +2145,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass144(any a0, any a1, any a2) { label_1: @@ -2209,7 +2157,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass145(any a0, any a1, any a2) { label_1: @@ -2222,7 +2169,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass146(any a0, any a1, any a2) { label_1: @@ -2235,7 +2181,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass147(any a0, any a1, any a2) { label_1: @@ -2248,7 +2193,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass148(any a0, any a1, any a2) { label_1: @@ -2261,7 +2205,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass149(any a0, any a1, any a2) { label_1: @@ -2274,7 +2217,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass15(any a0, any a1, any a2) { label_1: @@ -2287,7 +2229,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass150(any a0, any a1, any a2) { label_1: @@ -2300,7 +2241,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass151(any a0, any a1, any a2) { label_1: @@ -2313,7 +2253,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass152(any a0, any a1, any a2) { label_1: @@ -2326,7 +2265,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass153(any a0, any a1, any a2) { label_1: @@ -2339,7 +2277,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass154(any a0, any a1, any a2) { label_1: @@ -2352,7 +2289,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass155(any a0, any a1, any a2) { label_1: @@ -2365,7 +2301,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass156(any a0, any a1, any a2) { label_1: @@ -2378,7 +2313,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass157(any a0, any a1, any a2) { label_1: @@ -2391,7 +2325,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass158(any a0, any a1, any a2) { label_1: @@ -2404,7 +2337,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass159(any a0, any a1, any a2) { label_1: @@ -2417,7 +2349,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass16(any a0, any a1, any a2) { label_1: @@ -2430,7 +2361,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass160(any a0, any a1, any a2) { label_1: @@ -2443,7 +2373,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass161(any a0, any a1, any a2) { label_1: @@ -2456,7 +2385,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass162(any a0, any a1, any a2) { label_1: @@ -2469,7 +2397,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass163(any a0, any a1, any a2) { label_1: @@ -2482,7 +2409,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass164(any a0, any a1, any a2) { label_1: @@ -2495,7 +2421,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass165(any a0, any a1, any a2) { label_1: @@ -2508,7 +2433,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass166(any a0, any a1, any a2) { label_1: @@ -2521,7 +2445,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass167(any a0, any a1, any a2) { label_1: @@ -2534,7 +2457,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass168(any a0, any a1, any a2) { label_1: @@ -2547,7 +2469,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass169(any a0, any a1, any a2) { label_1: @@ -2560,7 +2481,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass17(any a0, any a1, any a2) { label_1: @@ -2573,7 +2493,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass170(any a0, any a1, any a2) { label_1: @@ -2586,7 +2505,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass171(any a0, any a1, any a2) { label_1: @@ -2599,7 +2517,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass172(any a0, any a1, any a2) { label_1: @@ -2612,7 +2529,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass173(any a0, any a1, any a2) { label_1: @@ -2625,7 +2541,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass174(any a0, any a1, any a2) { label_1: @@ -2638,7 +2553,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass175(any a0, any a1, any a2) { label_1: @@ -2651,7 +2565,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass176(any a0, any a1, any a2) { label_1: @@ -2664,7 +2577,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass177(any a0, any a1, any a2) { label_1: @@ -2677,7 +2589,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass178(any a0, any a1, any a2) { label_1: @@ -2690,7 +2601,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass179(any a0, any a1, any a2) { label_1: @@ -2703,7 +2613,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass18(any a0, any a1, any a2) { label_1: @@ -2716,7 +2625,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass180(any a0, any a1, any a2) { label_1: @@ -2729,7 +2637,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass181(any a0, any a1, any a2) { label_1: @@ -2742,7 +2649,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass182(any a0, any a1, any a2) { label_1: @@ -2755,7 +2661,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass183(any a0, any a1, any a2) { label_1: @@ -2768,7 +2673,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass184(any a0, any a1, any a2) { label_1: @@ -2781,7 +2685,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass185(any a0, any a1, any a2) { label_1: @@ -2794,7 +2697,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass186(any a0, any a1, any a2) { label_1: @@ -2807,7 +2709,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass187(any a0, any a1, any a2) { label_1: @@ -2820,7 +2721,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass188(any a0, any a1, any a2) { label_1: @@ -2833,7 +2733,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass189(any a0, any a1, any a2) { label_1: @@ -2846,7 +2745,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass19(any a0, any a1, any a2) { label_1: @@ -2859,7 +2757,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass190(any a0, any a1, any a2) { label_1: @@ -2872,7 +2769,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass191(any a0, any a1, any a2) { label_1: @@ -2885,7 +2781,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass192(any a0, any a1, any a2) { label_1: @@ -2898,7 +2793,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass193(any a0, any a1, any a2) { label_1: @@ -2911,7 +2805,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass194(any a0, any a1, any a2) { label_1: @@ -2924,7 +2817,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass195(any a0, any a1, any a2) { label_1: @@ -2937,7 +2829,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass196(any a0, any a1, any a2) { label_1: @@ -2950,7 +2841,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass197(any a0, any a1, any a2) { label_1: @@ -2963,7 +2853,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass198(any a0, any a1, any a2) { label_1: @@ -2976,7 +2865,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass199(any a0, any a1, any a2) { label_1: @@ -2989,7 +2877,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass2(any a0, any a1, any a2) { label_1: @@ -3002,7 +2889,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass20(any a0, any a1, any a2) { label_1: @@ -3015,7 +2901,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass200(any a0, any a1, any a2) { label_1: @@ -3028,7 +2913,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass201(any a0, any a1, any a2) { label_1: @@ -3041,7 +2925,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass202(any a0, any a1, any a2) { label_1: @@ -3054,7 +2937,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass203(any a0, any a1, any a2) { label_1: @@ -3067,7 +2949,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass204(any a0, any a1, any a2) { label_1: @@ -3080,7 +2961,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass205(any a0, any a1, any a2) { label_1: @@ -3093,7 +2973,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass206(any a0, any a1, any a2) { label_1: @@ -3106,7 +2985,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass207(any a0, any a1, any a2) { label_1: @@ -3119,7 +2997,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass208(any a0, any a1, any a2) { label_1: @@ -3132,7 +3009,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass209(any a0, any a1, any a2) { label_1: @@ -3145,7 +3021,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass21(any a0, any a1, any a2) { label_1: @@ -3158,7 +3033,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass210(any a0, any a1, any a2) { label_1: @@ -3171,7 +3045,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass211(any a0, any a1, any a2) { label_1: @@ -3184,7 +3057,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass212(any a0, any a1, any a2) { label_1: @@ -3197,7 +3069,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass213(any a0, any a1, any a2) { label_1: @@ -3210,7 +3081,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass214(any a0, any a1, any a2) { label_1: @@ -3223,7 +3093,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass215(any a0, any a1, any a2) { label_1: @@ -3236,7 +3105,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass216(any a0, any a1, any a2) { label_1: @@ -3249,7 +3117,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass217(any a0, any a1, any a2) { label_1: @@ -3262,7 +3129,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass218(any a0, any a1, any a2) { label_1: @@ -3275,7 +3141,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass219(any a0, any a1, any a2) { label_1: @@ -3288,7 +3153,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass22(any a0, any a1, any a2) { label_1: @@ -3301,7 +3165,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass220(any a0, any a1, any a2) { label_1: @@ -3314,7 +3177,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass221(any a0, any a1, any a2) { label_1: @@ -3327,7 +3189,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass222(any a0, any a1, any a2) { label_1: @@ -3340,7 +3201,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass223(any a0, any a1, any a2) { label_1: @@ -3353,7 +3213,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass224(any a0, any a1, any a2) { label_1: @@ -3366,7 +3225,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass225(any a0, any a1, any a2) { label_1: @@ -3379,7 +3237,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass226(any a0, any a1, any a2) { label_1: @@ -3392,7 +3249,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass227(any a0, any a1, any a2) { label_1: @@ -3405,7 +3261,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass228(any a0, any a1, any a2) { label_1: @@ -3418,7 +3273,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass229(any a0, any a1, any a2) { label_1: @@ -3431,7 +3285,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass23(any a0, any a1, any a2) { label_1: @@ -3444,7 +3297,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass230(any a0, any a1, any a2) { label_1: @@ -3457,7 +3309,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass231(any a0, any a1, any a2) { label_1: @@ -3470,7 +3321,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass232(any a0, any a1, any a2) { label_1: @@ -3483,7 +3333,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass233(any a0, any a1, any a2) { label_1: @@ -3496,7 +3345,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass234(any a0, any a1, any a2) { label_1: @@ -3509,7 +3357,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass235(any a0, any a1, any a2) { label_1: @@ -3522,7 +3369,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass236(any a0, any a1, any a2) { label_1: @@ -3535,7 +3381,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass237(any a0, any a1, any a2) { label_1: @@ -3548,7 +3393,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass238(any a0, any a1, any a2) { label_1: @@ -3561,7 +3405,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass239(any a0, any a1, any a2) { label_1: @@ -3574,7 +3417,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass24(any a0, any a1, any a2) { label_1: @@ -3587,7 +3429,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass240(any a0, any a1, any a2) { label_1: @@ -3600,7 +3441,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass241(any a0, any a1, any a2) { label_1: @@ -3613,7 +3453,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass242(any a0, any a1, any a2) { label_1: @@ -3626,7 +3465,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass243(any a0, any a1, any a2) { label_1: @@ -3639,7 +3477,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass244(any a0, any a1, any a2) { label_1: @@ -3652,7 +3489,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass245(any a0, any a1, any a2) { label_1: @@ -3665,7 +3501,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass246(any a0, any a1, any a2) { label_1: @@ -3678,7 +3513,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass247(any a0, any a1, any a2) { label_1: @@ -3691,7 +3525,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass248(any a0, any a1, any a2) { label_1: @@ -3704,7 +3537,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass249(any a0, any a1, any a2) { label_1: @@ -3717,7 +3549,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass25(any a0, any a1, any a2) { label_1: @@ -3730,7 +3561,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass250(any a0, any a1, any a2) { label_1: @@ -3743,7 +3573,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass251(any a0, any a1, any a2) { label_1: @@ -3756,7 +3585,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass252(any a0, any a1, any a2) { label_1: @@ -3769,7 +3597,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass253(any a0, any a1, any a2) { label_1: @@ -3782,7 +3609,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass254(any a0, any a1, any a2) { label_1: @@ -3795,7 +3621,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass255(any a0, any a1, any a2) { label_1: @@ -3808,7 +3633,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass26(any a0, any a1, any a2) { label_1: @@ -3821,7 +3645,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass27(any a0, any a1, any a2) { label_1: @@ -3834,7 +3657,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass28(any a0, any a1, any a2) { label_1: @@ -3847,7 +3669,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass29(any a0, any a1, any a2) { label_1: @@ -3860,7 +3681,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass3(any a0, any a1, any a2) { label_1: @@ -3873,7 +3693,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass30(any a0, any a1, any a2) { label_1: @@ -3886,7 +3705,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass31(any a0, any a1, any a2) { label_1: @@ -3899,7 +3717,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass32(any a0, any a1, any a2) { label_1: @@ -3912,7 +3729,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass33(any a0, any a1, any a2) { label_1: @@ -3925,7 +3741,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass34(any a0, any a1, any a2) { label_1: @@ -3938,7 +3753,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass35(any a0, any a1, any a2) { label_1: @@ -3951,7 +3765,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass36(any a0, any a1, any a2) { label_1: @@ -3964,7 +3777,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass37(any a0, any a1, any a2) { label_1: @@ -3977,7 +3789,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass38(any a0, any a1, any a2) { label_1: @@ -3990,7 +3801,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass39(any a0, any a1, any a2) { label_1: @@ -4003,7 +3813,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass4(any a0, any a1, any a2) { label_1: @@ -4016,7 +3825,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass40(any a0, any a1, any a2) { label_1: @@ -4029,7 +3837,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass41(any a0, any a1, any a2) { label_1: @@ -4042,7 +3849,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass42(any a0, any a1, any a2) { label_1: @@ -4055,7 +3861,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass43(any a0, any a1, any a2) { label_1: @@ -4068,7 +3873,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass44(any a0, any a1, any a2) { label_1: @@ -4081,7 +3885,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass45(any a0, any a1, any a2) { label_1: @@ -4094,7 +3897,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass46(any a0, any a1, any a2) { label_1: @@ -4107,7 +3909,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass47(any a0, any a1, any a2) { label_1: @@ -4120,7 +3921,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass48(any a0, any a1, any a2) { label_1: @@ -4133,7 +3933,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass49(any a0, any a1, any a2) { label_1: @@ -4146,7 +3945,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass5(any a0, any a1, any a2) { label_1: @@ -4159,7 +3957,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass50(any a0, any a1, any a2) { label_1: @@ -4172,7 +3969,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass51(any a0, any a1, any a2) { label_1: @@ -4185,7 +3981,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass52(any a0, any a1, any a2) { label_1: @@ -4198,7 +3993,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass53(any a0, any a1, any a2) { label_1: @@ -4211,7 +4005,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass54(any a0, any a1, any a2) { label_1: @@ -4224,7 +4017,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass55(any a0, any a1, any a2) { label_1: @@ -4237,7 +4029,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass56(any a0, any a1, any a2) { label_1: @@ -4250,7 +4041,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass57(any a0, any a1, any a2) { label_1: @@ -4263,7 +4053,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass58(any a0, any a1, any a2) { label_1: @@ -4276,7 +4065,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass59(any a0, any a1, any a2) { label_1: @@ -4289,7 +4077,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass6(any a0, any a1, any a2) { label_1: @@ -4302,7 +4089,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass60(any a0, any a1, any a2) { label_1: @@ -4315,7 +4101,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass61(any a0, any a1, any a2) { label_1: @@ -4328,7 +4113,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass62(any a0, any a1, any a2) { label_1: @@ -4341,7 +4125,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass63(any a0, any a1, any a2) { label_1: @@ -4354,7 +4137,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass64(any a0, any a1, any a2) { label_1: @@ -4367,7 +4149,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass65(any a0, any a1, any a2) { label_1: @@ -4380,7 +4161,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass66(any a0, any a1, any a2) { label_1: @@ -4393,7 +4173,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass67(any a0, any a1, any a2) { label_1: @@ -4406,7 +4185,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass68(any a0, any a1, any a2) { label_1: @@ -4419,7 +4197,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass69(any a0, any a1, any a2) { label_1: @@ -4432,7 +4209,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass7(any a0, any a1, any a2) { label_1: @@ -4445,7 +4221,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass70(any a0, any a1, any a2) { label_1: @@ -4458,7 +4233,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass71(any a0, any a1, any a2) { label_1: @@ -4471,7 +4245,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass72(any a0, any a1, any a2) { label_1: @@ -4484,7 +4257,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass73(any a0, any a1, any a2) { label_1: @@ -4497,7 +4269,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass74(any a0, any a1, any a2) { label_1: @@ -4510,7 +4281,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass75(any a0, any a1, any a2) { label_1: @@ -4523,7 +4293,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass76(any a0, any a1, any a2) { label_1: @@ -4536,7 +4305,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass77(any a0, any a1, any a2) { label_1: @@ -4549,7 +4317,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass78(any a0, any a1, any a2) { label_1: @@ -4562,7 +4329,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass79(any a0, any a1, any a2) { label_1: @@ -4575,7 +4341,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass8(any a0, any a1, any a2) { label_1: @@ -4588,7 +4353,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass80(any a0, any a1, any a2) { label_1: @@ -4601,7 +4365,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass81(any a0, any a1, any a2) { label_1: @@ -4614,7 +4377,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass82(any a0, any a1, any a2) { label_1: @@ -4627,7 +4389,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass83(any a0, any a1, any a2) { label_1: @@ -4640,7 +4401,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass84(any a0, any a1, any a2) { label_1: @@ -4653,7 +4413,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass85(any a0, any a1, any a2) { label_1: @@ -4666,7 +4425,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass86(any a0, any a1, any a2) { label_1: @@ -4679,7 +4437,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass87(any a0, any a1, any a2) { label_1: @@ -4692,7 +4449,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass88(any a0, any a1, any a2) { label_1: @@ -4705,7 +4461,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass89(any a0, any a1, any a2) { label_1: @@ -4718,7 +4473,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass9(any a0, any a1, any a2) { label_1: @@ -4731,7 +4485,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass90(any a0, any a1, any a2) { label_1: @@ -4744,7 +4497,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass91(any a0, any a1, any a2) { label_1: @@ -4757,7 +4509,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass92(any a0, any a1, any a2) { label_1: @@ -4770,7 +4521,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass93(any a0, any a1, any a2) { label_1: @@ -4783,7 +4533,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass94(any a0, any a1, any a2) { label_1: @@ -4796,7 +4545,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass95(any a0, any a1, any a2) { label_1: @@ -4809,7 +4557,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass96(any a0, any a1, any a2) { label_1: @@ -4822,7 +4569,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass97(any a0, any a1, any a2) { label_1: @@ -4835,7 +4581,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass98(any a0, any a1, any a2) { label_1: @@ -4848,7 +4593,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass99(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 95% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt index 50cd83163e1619f04dccf5fb1330d1e4e68be958..33c3a51f3e1e56de69ef1b5e5c28fb7435018554 100644 --- a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_below_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x406 -expectedProperty = 0x101 .language ECMAScript .function any .SendableTestClass1(any a0, any a1, any a2) { label_1: @@ -1546,7 +1545,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass1(any a0, any a1, any a2) { label_1: @@ -1559,7 +1557,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass10(any a0, any a1, any a2) { label_1: @@ -1572,7 +1569,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass100(any a0, any a1, any a2) { label_1: @@ -1585,7 +1581,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass101(any a0, any a1, any a2) { label_1: @@ -1598,7 +1593,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass102(any a0, any a1, any a2) { label_1: @@ -1611,7 +1605,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass103(any a0, any a1, any a2) { label_1: @@ -1624,7 +1617,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass104(any a0, any a1, any a2) { label_1: @@ -1637,7 +1629,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass105(any a0, any a1, any a2) { label_1: @@ -1650,7 +1641,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass106(any a0, any a1, any a2) { label_1: @@ -1663,7 +1653,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass107(any a0, any a1, any a2) { label_1: @@ -1676,7 +1665,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass108(any a0, any a1, any a2) { label_1: @@ -1689,7 +1677,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass109(any a0, any a1, any a2) { label_1: @@ -1702,7 +1689,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass11(any a0, any a1, any a2) { label_1: @@ -1715,7 +1701,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass110(any a0, any a1, any a2) { label_1: @@ -1728,7 +1713,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass111(any a0, any a1, any a2) { label_1: @@ -1741,7 +1725,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass112(any a0, any a1, any a2) { label_1: @@ -1754,7 +1737,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass113(any a0, any a1, any a2) { label_1: @@ -1767,7 +1749,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass114(any a0, any a1, any a2) { label_1: @@ -1780,7 +1761,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass115(any a0, any a1, any a2) { label_1: @@ -1793,7 +1773,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass116(any a0, any a1, any a2) { label_1: @@ -1806,7 +1785,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass117(any a0, any a1, any a2) { label_1: @@ -1819,7 +1797,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass118(any a0, any a1, any a2) { label_1: @@ -1832,7 +1809,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass119(any a0, any a1, any a2) { label_1: @@ -1845,7 +1821,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass12(any a0, any a1, any a2) { label_1: @@ -1858,7 +1833,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass120(any a0, any a1, any a2) { label_1: @@ -1871,7 +1845,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass121(any a0, any a1, any a2) { label_1: @@ -1884,7 +1857,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass122(any a0, any a1, any a2) { label_1: @@ -1897,7 +1869,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass123(any a0, any a1, any a2) { label_1: @@ -1910,7 +1881,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass124(any a0, any a1, any a2) { label_1: @@ -1923,7 +1893,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass125(any a0, any a1, any a2) { label_1: @@ -1936,7 +1905,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass126(any a0, any a1, any a2) { label_1: @@ -1949,7 +1917,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass127(any a0, any a1, any a2) { label_1: @@ -1962,7 +1929,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass128(any a0, any a1, any a2) { label_1: @@ -1975,7 +1941,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass129(any a0, any a1, any a2) { label_1: @@ -1988,7 +1953,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass13(any a0, any a1, any a2) { label_1: @@ -2001,7 +1965,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass130(any a0, any a1, any a2) { label_1: @@ -2014,7 +1977,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass131(any a0, any a1, any a2) { label_1: @@ -2027,7 +1989,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass132(any a0, any a1, any a2) { label_1: @@ -2040,7 +2001,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass133(any a0, any a1, any a2) { label_1: @@ -2053,7 +2013,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass134(any a0, any a1, any a2) { label_1: @@ -2066,7 +2025,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass135(any a0, any a1, any a2) { label_1: @@ -2079,7 +2037,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass136(any a0, any a1, any a2) { label_1: @@ -2092,7 +2049,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass137(any a0, any a1, any a2) { label_1: @@ -2105,7 +2061,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass138(any a0, any a1, any a2) { label_1: @@ -2118,7 +2073,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass139(any a0, any a1, any a2) { label_1: @@ -2131,7 +2085,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass14(any a0, any a1, any a2) { label_1: @@ -2144,7 +2097,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass140(any a0, any a1, any a2) { label_1: @@ -2157,7 +2109,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass141(any a0, any a1, any a2) { label_1: @@ -2170,7 +2121,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass142(any a0, any a1, any a2) { label_1: @@ -2183,7 +2133,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass143(any a0, any a1, any a2) { label_1: @@ -2196,7 +2145,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass144(any a0, any a1, any a2) { label_1: @@ -2209,7 +2157,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass145(any a0, any a1, any a2) { label_1: @@ -2222,7 +2169,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass146(any a0, any a1, any a2) { label_1: @@ -2235,7 +2181,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass147(any a0, any a1, any a2) { label_1: @@ -2248,7 +2193,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass148(any a0, any a1, any a2) { label_1: @@ -2261,7 +2205,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass149(any a0, any a1, any a2) { label_1: @@ -2274,7 +2217,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass15(any a0, any a1, any a2) { label_1: @@ -2287,7 +2229,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass150(any a0, any a1, any a2) { label_1: @@ -2300,7 +2241,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass151(any a0, any a1, any a2) { label_1: @@ -2313,7 +2253,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass152(any a0, any a1, any a2) { label_1: @@ -2326,7 +2265,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass153(any a0, any a1, any a2) { label_1: @@ -2339,7 +2277,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass154(any a0, any a1, any a2) { label_1: @@ -2352,7 +2289,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass155(any a0, any a1, any a2) { label_1: @@ -2365,7 +2301,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass156(any a0, any a1, any a2) { label_1: @@ -2378,7 +2313,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass157(any a0, any a1, any a2) { label_1: @@ -2391,7 +2325,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass158(any a0, any a1, any a2) { label_1: @@ -2404,7 +2337,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass159(any a0, any a1, any a2) { label_1: @@ -2417,7 +2349,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass16(any a0, any a1, any a2) { label_1: @@ -2430,7 +2361,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass160(any a0, any a1, any a2) { label_1: @@ -2443,7 +2373,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass161(any a0, any a1, any a2) { label_1: @@ -2456,7 +2385,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass162(any a0, any a1, any a2) { label_1: @@ -2469,7 +2397,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass163(any a0, any a1, any a2) { label_1: @@ -2482,7 +2409,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass164(any a0, any a1, any a2) { label_1: @@ -2495,7 +2421,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass165(any a0, any a1, any a2) { label_1: @@ -2508,7 +2433,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass166(any a0, any a1, any a2) { label_1: @@ -2521,7 +2445,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass167(any a0, any a1, any a2) { label_1: @@ -2534,7 +2457,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass168(any a0, any a1, any a2) { label_1: @@ -2547,7 +2469,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass169(any a0, any a1, any a2) { label_1: @@ -2560,7 +2481,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass17(any a0, any a1, any a2) { label_1: @@ -2573,7 +2493,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass170(any a0, any a1, any a2) { label_1: @@ -2586,7 +2505,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass171(any a0, any a1, any a2) { label_1: @@ -2599,7 +2517,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass172(any a0, any a1, any a2) { label_1: @@ -2612,7 +2529,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass173(any a0, any a1, any a2) { label_1: @@ -2625,7 +2541,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass174(any a0, any a1, any a2) { label_1: @@ -2638,7 +2553,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass175(any a0, any a1, any a2) { label_1: @@ -2651,7 +2565,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass176(any a0, any a1, any a2) { label_1: @@ -2664,7 +2577,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass177(any a0, any a1, any a2) { label_1: @@ -2677,7 +2589,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass178(any a0, any a1, any a2) { label_1: @@ -2690,7 +2601,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass179(any a0, any a1, any a2) { label_1: @@ -2703,7 +2613,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass18(any a0, any a1, any a2) { label_1: @@ -2716,7 +2625,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass180(any a0, any a1, any a2) { label_1: @@ -2729,7 +2637,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass181(any a0, any a1, any a2) { label_1: @@ -2742,7 +2649,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass182(any a0, any a1, any a2) { label_1: @@ -2755,7 +2661,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass183(any a0, any a1, any a2) { label_1: @@ -2768,7 +2673,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass184(any a0, any a1, any a2) { label_1: @@ -2781,7 +2685,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass185(any a0, any a1, any a2) { label_1: @@ -2794,7 +2697,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass186(any a0, any a1, any a2) { label_1: @@ -2807,7 +2709,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass187(any a0, any a1, any a2) { label_1: @@ -2820,7 +2721,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass188(any a0, any a1, any a2) { label_1: @@ -2833,7 +2733,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass189(any a0, any a1, any a2) { label_1: @@ -2846,7 +2745,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass19(any a0, any a1, any a2) { label_1: @@ -2859,7 +2757,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass190(any a0, any a1, any a2) { label_1: @@ -2872,7 +2769,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass191(any a0, any a1, any a2) { label_1: @@ -2885,7 +2781,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass192(any a0, any a1, any a2) { label_1: @@ -2898,7 +2793,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass193(any a0, any a1, any a2) { label_1: @@ -2911,7 +2805,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass194(any a0, any a1, any a2) { label_1: @@ -2924,7 +2817,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass195(any a0, any a1, any a2) { label_1: @@ -2937,7 +2829,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass196(any a0, any a1, any a2) { label_1: @@ -2950,7 +2841,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass197(any a0, any a1, any a2) { label_1: @@ -2963,7 +2853,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass198(any a0, any a1, any a2) { label_1: @@ -2976,7 +2865,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass199(any a0, any a1, any a2) { label_1: @@ -2989,7 +2877,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass2(any a0, any a1, any a2) { label_1: @@ -3002,7 +2889,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass20(any a0, any a1, any a2) { label_1: @@ -3015,7 +2901,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass200(any a0, any a1, any a2) { label_1: @@ -3028,7 +2913,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass201(any a0, any a1, any a2) { label_1: @@ -3041,7 +2925,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass202(any a0, any a1, any a2) { label_1: @@ -3054,7 +2937,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass203(any a0, any a1, any a2) { label_1: @@ -3067,7 +2949,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass204(any a0, any a1, any a2) { label_1: @@ -3080,7 +2961,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass205(any a0, any a1, any a2) { label_1: @@ -3093,7 +2973,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass206(any a0, any a1, any a2) { label_1: @@ -3106,7 +2985,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass207(any a0, any a1, any a2) { label_1: @@ -3119,7 +2997,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass208(any a0, any a1, any a2) { label_1: @@ -3132,7 +3009,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass209(any a0, any a1, any a2) { label_1: @@ -3145,7 +3021,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass21(any a0, any a1, any a2) { label_1: @@ -3158,7 +3033,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass210(any a0, any a1, any a2) { label_1: @@ -3171,7 +3045,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass211(any a0, any a1, any a2) { label_1: @@ -3184,7 +3057,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass212(any a0, any a1, any a2) { label_1: @@ -3197,7 +3069,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass213(any a0, any a1, any a2) { label_1: @@ -3210,7 +3081,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass214(any a0, any a1, any a2) { label_1: @@ -3223,7 +3093,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass215(any a0, any a1, any a2) { label_1: @@ -3236,7 +3105,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass216(any a0, any a1, any a2) { label_1: @@ -3249,7 +3117,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass217(any a0, any a1, any a2) { label_1: @@ -3262,7 +3129,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass218(any a0, any a1, any a2) { label_1: @@ -3275,7 +3141,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass219(any a0, any a1, any a2) { label_1: @@ -3288,7 +3153,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass22(any a0, any a1, any a2) { label_1: @@ -3301,7 +3165,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass220(any a0, any a1, any a2) { label_1: @@ -3314,7 +3177,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass221(any a0, any a1, any a2) { label_1: @@ -3327,7 +3189,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass222(any a0, any a1, any a2) { label_1: @@ -3340,7 +3201,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass223(any a0, any a1, any a2) { label_1: @@ -3353,7 +3213,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass224(any a0, any a1, any a2) { label_1: @@ -3366,7 +3225,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass225(any a0, any a1, any a2) { label_1: @@ -3379,7 +3237,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass226(any a0, any a1, any a2) { label_1: @@ -3392,7 +3249,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass227(any a0, any a1, any a2) { label_1: @@ -3405,7 +3261,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass228(any a0, any a1, any a2) { label_1: @@ -3418,7 +3273,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass229(any a0, any a1, any a2) { label_1: @@ -3431,7 +3285,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass23(any a0, any a1, any a2) { label_1: @@ -3444,7 +3297,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass230(any a0, any a1, any a2) { label_1: @@ -3457,7 +3309,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass231(any a0, any a1, any a2) { label_1: @@ -3470,7 +3321,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass232(any a0, any a1, any a2) { label_1: @@ -3483,7 +3333,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass233(any a0, any a1, any a2) { label_1: @@ -3496,7 +3345,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass234(any a0, any a1, any a2) { label_1: @@ -3509,7 +3357,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass235(any a0, any a1, any a2) { label_1: @@ -3522,7 +3369,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass236(any a0, any a1, any a2) { label_1: @@ -3535,7 +3381,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass237(any a0, any a1, any a2) { label_1: @@ -3548,7 +3393,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass238(any a0, any a1, any a2) { label_1: @@ -3561,7 +3405,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass239(any a0, any a1, any a2) { label_1: @@ -3574,7 +3417,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass24(any a0, any a1, any a2) { label_1: @@ -3587,7 +3429,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass240(any a0, any a1, any a2) { label_1: @@ -3600,7 +3441,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass241(any a0, any a1, any a2) { label_1: @@ -3613,7 +3453,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass242(any a0, any a1, any a2) { label_1: @@ -3626,7 +3465,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass243(any a0, any a1, any a2) { label_1: @@ -3639,7 +3477,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass244(any a0, any a1, any a2) { label_1: @@ -3652,7 +3489,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass245(any a0, any a1, any a2) { label_1: @@ -3665,7 +3501,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass246(any a0, any a1, any a2) { label_1: @@ -3678,7 +3513,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass247(any a0, any a1, any a2) { label_1: @@ -3691,7 +3525,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass248(any a0, any a1, any a2) { label_1: @@ -3704,7 +3537,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass249(any a0, any a1, any a2) { label_1: @@ -3717,7 +3549,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass25(any a0, any a1, any a2) { label_1: @@ -3730,7 +3561,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass250(any a0, any a1, any a2) { label_1: @@ -3743,7 +3573,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass251(any a0, any a1, any a2) { label_1: @@ -3756,7 +3585,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass252(any a0, any a1, any a2) { label_1: @@ -3769,7 +3597,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass253(any a0, any a1, any a2) { label_1: @@ -3782,7 +3609,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass254(any a0, any a1, any a2) { label_1: @@ -3795,7 +3621,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass255(any a0, any a1, any a2) { label_1: @@ -3808,7 +3633,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass26(any a0, any a1, any a2) { label_1: @@ -3821,7 +3645,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass27(any a0, any a1, any a2) { label_1: @@ -3834,7 +3657,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass28(any a0, any a1, any a2) { label_1: @@ -3847,7 +3669,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass29(any a0, any a1, any a2) { label_1: @@ -3860,7 +3681,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass3(any a0, any a1, any a2) { label_1: @@ -3873,7 +3693,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass30(any a0, any a1, any a2) { label_1: @@ -3886,7 +3705,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass31(any a0, any a1, any a2) { label_1: @@ -3899,7 +3717,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass32(any a0, any a1, any a2) { label_1: @@ -3912,7 +3729,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass33(any a0, any a1, any a2) { label_1: @@ -3925,7 +3741,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass34(any a0, any a1, any a2) { label_1: @@ -3938,7 +3753,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass35(any a0, any a1, any a2) { label_1: @@ -3951,7 +3765,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass36(any a0, any a1, any a2) { label_1: @@ -3964,7 +3777,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass37(any a0, any a1, any a2) { label_1: @@ -3977,7 +3789,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass38(any a0, any a1, any a2) { label_1: @@ -3990,7 +3801,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass39(any a0, any a1, any a2) { label_1: @@ -4003,7 +3813,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass4(any a0, any a1, any a2) { label_1: @@ -4016,7 +3825,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass40(any a0, any a1, any a2) { label_1: @@ -4029,7 +3837,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass41(any a0, any a1, any a2) { label_1: @@ -4042,7 +3849,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass42(any a0, any a1, any a2) { label_1: @@ -4055,7 +3861,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass43(any a0, any a1, any a2) { label_1: @@ -4068,7 +3873,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass44(any a0, any a1, any a2) { label_1: @@ -4081,7 +3885,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass45(any a0, any a1, any a2) { label_1: @@ -4094,7 +3897,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass46(any a0, any a1, any a2) { label_1: @@ -4107,7 +3909,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass47(any a0, any a1, any a2) { label_1: @@ -4120,7 +3921,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass48(any a0, any a1, any a2) { label_1: @@ -4133,7 +3933,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass49(any a0, any a1, any a2) { label_1: @@ -4146,7 +3945,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass5(any a0, any a1, any a2) { label_1: @@ -4159,7 +3957,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass50(any a0, any a1, any a2) { label_1: @@ -4172,7 +3969,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass51(any a0, any a1, any a2) { label_1: @@ -4185,7 +3981,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass52(any a0, any a1, any a2) { label_1: @@ -4198,7 +3993,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass53(any a0, any a1, any a2) { label_1: @@ -4211,7 +4005,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass54(any a0, any a1, any a2) { label_1: @@ -4224,7 +4017,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass55(any a0, any a1, any a2) { label_1: @@ -4237,7 +4029,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass56(any a0, any a1, any a2) { label_1: @@ -4250,7 +4041,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass57(any a0, any a1, any a2) { label_1: @@ -4263,7 +4053,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass58(any a0, any a1, any a2) { label_1: @@ -4276,7 +4065,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass59(any a0, any a1, any a2) { label_1: @@ -4289,7 +4077,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass6(any a0, any a1, any a2) { label_1: @@ -4302,7 +4089,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass60(any a0, any a1, any a2) { label_1: @@ -4315,7 +4101,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass61(any a0, any a1, any a2) { label_1: @@ -4328,7 +4113,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass62(any a0, any a1, any a2) { label_1: @@ -4341,7 +4125,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass63(any a0, any a1, any a2) { label_1: @@ -4354,7 +4137,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass64(any a0, any a1, any a2) { label_1: @@ -4367,7 +4149,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass65(any a0, any a1, any a2) { label_1: @@ -4380,7 +4161,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass66(any a0, any a1, any a2) { label_1: @@ -4393,7 +4173,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass67(any a0, any a1, any a2) { label_1: @@ -4406,7 +4185,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass68(any a0, any a1, any a2) { label_1: @@ -4419,7 +4197,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass69(any a0, any a1, any a2) { label_1: @@ -4432,7 +4209,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass7(any a0, any a1, any a2) { label_1: @@ -4445,7 +4221,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass70(any a0, any a1, any a2) { label_1: @@ -4458,7 +4233,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass71(any a0, any a1, any a2) { label_1: @@ -4471,7 +4245,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass72(any a0, any a1, any a2) { label_1: @@ -4484,7 +4257,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass73(any a0, any a1, any a2) { label_1: @@ -4497,7 +4269,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass74(any a0, any a1, any a2) { label_1: @@ -4510,7 +4281,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass75(any a0, any a1, any a2) { label_1: @@ -4523,7 +4293,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass76(any a0, any a1, any a2) { label_1: @@ -4536,7 +4305,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass77(any a0, any a1, any a2) { label_1: @@ -4549,7 +4317,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass78(any a0, any a1, any a2) { label_1: @@ -4562,7 +4329,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass79(any a0, any a1, any a2) { label_1: @@ -4575,7 +4341,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass8(any a0, any a1, any a2) { label_1: @@ -4588,7 +4353,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass80(any a0, any a1, any a2) { label_1: @@ -4601,7 +4365,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass81(any a0, any a1, any a2) { label_1: @@ -4614,7 +4377,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass82(any a0, any a1, any a2) { label_1: @@ -4627,7 +4389,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass83(any a0, any a1, any a2) { label_1: @@ -4640,7 +4401,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass84(any a0, any a1, any a2) { label_1: @@ -4653,7 +4413,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass85(any a0, any a1, any a2) { label_1: @@ -4666,7 +4425,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass86(any a0, any a1, any a2) { label_1: @@ -4679,7 +4437,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass87(any a0, any a1, any a2) { label_1: @@ -4692,7 +4449,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass88(any a0, any a1, any a2) { label_1: @@ -4705,7 +4461,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass89(any a0, any a1, any a2) { label_1: @@ -4718,7 +4473,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass9(any a0, any a1, any a2) { label_1: @@ -4731,7 +4485,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass90(any a0, any a1, any a2) { label_1: @@ -4744,7 +4497,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass91(any a0, any a1, any a2) { label_1: @@ -4757,7 +4509,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass92(any a0, any a1, any a2) { label_1: @@ -4770,7 +4521,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass93(any a0, any a1, any a2) { label_1: @@ -4783,7 +4533,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass94(any a0, any a1, any a2) { label_1: @@ -4796,7 +4545,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass95(any a0, any a1, any a2) { label_1: @@ -4809,7 +4557,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass96(any a0, any a1, any a2) { label_1: @@ -4822,7 +4569,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass97(any a0, any a1, any a2) { label_1: @@ -4835,7 +4581,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass98(any a0, any a1, any a2) { label_1: @@ -4848,7 +4593,6 @@ label_2: } slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .TopLevelSendableClass99(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..33c3a51f3e1e56de69ef1b5e5c28fb7435018554 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -0,0 +1,5651 @@ +slotNum = 0x406 +.language ECMAScript +.function any .SendableTestClass1(any a0, any a1, any a2) { +label_1: +label_0: + ldlexvar 0x0, 0x0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass1 + mov v1, v0 + newobjrange 0x0, 0x1, v1 + stobjbyname 0x2, a1, a2 + ldlexvar 0x0, 0x1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass2 + mov v1, v0 + newobjrange 0x4, 0x1, v1 + stobjbyname 0x6, a2, a2 + ldlexvar 0x0, 0x2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass3 + mov v1, v0 + newobjrange 0x8, 0x1, v1 + stobjbyname 0xa, a3, a2 + ldlexvar 0x0, 0x3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass4 + mov v1, v0 + newobjrange 0xc, 0x1, v1 + stobjbyname 0xe, a4, a2 + ldlexvar 0x0, 0x4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass5 + mov v1, v0 + newobjrange 0x10, 0x1, v1 + stobjbyname 0x12, a5, a2 + ldlexvar 0x0, 0x5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass6 + mov v1, v0 + newobjrange 0x14, 0x1, v1 + stobjbyname 0x16, a6, a2 + ldlexvar 0x0, 0x6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass7 + mov v1, v0 + newobjrange 0x18, 0x1, v1 + stobjbyname 0x1a, a7, a2 + ldlexvar 0x0, 0x7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass8 + mov v1, v0 + newobjrange 0x1c, 0x1, v1 + stobjbyname 0x1e, a8, a2 + ldlexvar 0x0, 0x8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass9 + mov v1, v0 + newobjrange 0x20, 0x1, v1 + stobjbyname 0x22, a9, a2 + ldlexvar 0x0, 0x9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass10 + mov v1, v0 + newobjrange 0x24, 0x1, v1 + stobjbyname 0x26, a10, a2 + ldlexvar 0x0, 0xa + sta v0 + throw.undefinedifholewithname TopLevelSendableClass11 + mov v1, v0 + newobjrange 0x28, 0x1, v1 + stobjbyname 0x2a, a11, a2 + ldlexvar 0x0, 0xb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass12 + mov v1, v0 + newobjrange 0x2c, 0x1, v1 + stobjbyname 0x2e, a12, a2 + ldlexvar 0x0, 0xc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass13 + mov v1, v0 + newobjrange 0x30, 0x1, v1 + stobjbyname 0x32, a13, a2 + ldlexvar 0x0, 0xd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass14 + mov v1, v0 + newobjrange 0x34, 0x1, v1 + stobjbyname 0x36, a14, a2 + ldlexvar 0x0, 0xe + sta v0 + throw.undefinedifholewithname TopLevelSendableClass15 + mov v1, v0 + newobjrange 0x38, 0x1, v1 + stobjbyname 0x3a, a15, a2 + ldlexvar 0x0, 0xf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass16 + mov v1, v0 + newobjrange 0x3c, 0x1, v1 + stobjbyname 0x3e, a16, a2 + ldlexvar 0x0, 0x10 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass17 + mov v1, v0 + newobjrange 0x40, 0x1, v1 + stobjbyname 0x42, a17, a2 + ldlexvar 0x0, 0x11 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass18 + mov v1, v0 + newobjrange 0x44, 0x1, v1 + stobjbyname 0x46, a18, a2 + ldlexvar 0x0, 0x12 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass19 + mov v1, v0 + newobjrange 0x48, 0x1, v1 + stobjbyname 0x4a, a19, a2 + ldlexvar 0x0, 0x13 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass20 + mov v1, v0 + newobjrange 0x4c, 0x1, v1 + stobjbyname 0x4e, a20, a2 + ldlexvar 0x0, 0x14 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass21 + mov v1, v0 + newobjrange 0x50, 0x1, v1 + stobjbyname 0x52, a21, a2 + ldlexvar 0x0, 0x15 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass22 + mov v1, v0 + newobjrange 0x54, 0x1, v1 + stobjbyname 0x56, a22, a2 + ldlexvar 0x0, 0x16 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass23 + mov v1, v0 + newobjrange 0x58, 0x1, v1 + stobjbyname 0x5a, a23, a2 + ldlexvar 0x0, 0x17 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass24 + mov v1, v0 + newobjrange 0x5c, 0x1, v1 + stobjbyname 0x5e, a24, a2 + ldlexvar 0x0, 0x18 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass25 + mov v1, v0 + newobjrange 0x60, 0x1, v1 + stobjbyname 0x62, a25, a2 + ldlexvar 0x0, 0x19 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass26 + mov v1, v0 + newobjrange 0x64, 0x1, v1 + stobjbyname 0x66, a26, a2 + ldlexvar 0x0, 0x1a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass27 + mov v1, v0 + newobjrange 0x68, 0x1, v1 + stobjbyname 0x6a, a27, a2 + ldlexvar 0x0, 0x1b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass28 + mov v1, v0 + newobjrange 0x6c, 0x1, v1 + stobjbyname 0x6e, a28, a2 + ldlexvar 0x0, 0x1c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass29 + mov v1, v0 + newobjrange 0x70, 0x1, v1 + stobjbyname 0x72, a29, a2 + ldlexvar 0x0, 0x1d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass30 + mov v1, v0 + newobjrange 0x74, 0x1, v1 + stobjbyname 0x76, a30, a2 + ldlexvar 0x0, 0x1e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass31 + mov v1, v0 + newobjrange 0x78, 0x1, v1 + stobjbyname 0x7a, a31, a2 + ldlexvar 0x0, 0x1f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass32 + mov v1, v0 + newobjrange 0x7c, 0x1, v1 + stobjbyname 0x7e, a32, a2 + ldlexvar 0x0, 0x20 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass33 + mov v1, v0 + newobjrange 0x80, 0x1, v1 + stobjbyname 0x82, a33, a2 + ldlexvar 0x0, 0x21 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass34 + mov v1, v0 + newobjrange 0x84, 0x1, v1 + stobjbyname 0x86, a34, a2 + ldlexvar 0x0, 0x22 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass35 + mov v1, v0 + newobjrange 0x88, 0x1, v1 + stobjbyname 0x8a, a35, a2 + ldlexvar 0x0, 0x23 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass36 + mov v1, v0 + newobjrange 0x8c, 0x1, v1 + stobjbyname 0x8e, a36, a2 + ldlexvar 0x0, 0x24 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass37 + mov v1, v0 + newobjrange 0x90, 0x1, v1 + stobjbyname 0x92, a37, a2 + ldlexvar 0x0, 0x25 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass38 + mov v1, v0 + newobjrange 0x94, 0x1, v1 + stobjbyname 0x96, a38, a2 + ldlexvar 0x0, 0x26 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass39 + mov v1, v0 + newobjrange 0x98, 0x1, v1 + stobjbyname 0x9a, a39, a2 + ldlexvar 0x0, 0x27 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass40 + mov v1, v0 + newobjrange 0x9c, 0x1, v1 + stobjbyname 0x9e, a40, a2 + ldlexvar 0x0, 0x28 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass41 + mov v1, v0 + newobjrange 0xa0, 0x1, v1 + stobjbyname 0xa2, a41, a2 + ldlexvar 0x0, 0x29 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass42 + mov v1, v0 + newobjrange 0xa4, 0x1, v1 + stobjbyname 0xa6, a42, a2 + ldlexvar 0x0, 0x2a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass43 + mov v1, v0 + newobjrange 0xa8, 0x1, v1 + stobjbyname 0xaa, a43, a2 + ldlexvar 0x0, 0x2b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass44 + mov v1, v0 + newobjrange 0xac, 0x1, v1 + stobjbyname 0xae, a44, a2 + ldlexvar 0x0, 0x2c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass45 + mov v1, v0 + newobjrange 0xb0, 0x1, v1 + stobjbyname 0xb2, a45, a2 + ldlexvar 0x0, 0x2d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass46 + mov v1, v0 + newobjrange 0xb4, 0x1, v1 + stobjbyname 0xb6, a46, a2 + ldlexvar 0x0, 0x2e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass47 + mov v1, v0 + newobjrange 0xb8, 0x1, v1 + stobjbyname 0xba, a47, a2 + ldlexvar 0x0, 0x2f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass48 + mov v1, v0 + newobjrange 0xbc, 0x1, v1 + stobjbyname 0xbe, a48, a2 + ldlexvar 0x0, 0x30 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass49 + mov v1, v0 + newobjrange 0xc0, 0x1, v1 + stobjbyname 0xc2, a49, a2 + ldlexvar 0x0, 0x31 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass50 + mov v1, v0 + newobjrange 0xc4, 0x1, v1 + stobjbyname 0xc6, a50, a2 + ldlexvar 0x0, 0x32 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass51 + mov v1, v0 + newobjrange 0xc8, 0x1, v1 + stobjbyname 0xca, a51, a2 + ldlexvar 0x0, 0x33 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass52 + mov v1, v0 + newobjrange 0xcc, 0x1, v1 + stobjbyname 0xce, a52, a2 + ldlexvar 0x0, 0x34 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass53 + mov v1, v0 + newobjrange 0xd0, 0x1, v1 + stobjbyname 0xd2, a53, a2 + ldlexvar 0x0, 0x35 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass54 + mov v1, v0 + newobjrange 0xd4, 0x1, v1 + stobjbyname 0xd6, a54, a2 + ldlexvar 0x0, 0x36 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass55 + mov v1, v0 + newobjrange 0xd8, 0x1, v1 + stobjbyname 0xda, a55, a2 + ldlexvar 0x0, 0x37 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass56 + mov v1, v0 + newobjrange 0xdc, 0x1, v1 + stobjbyname 0xde, a56, a2 + ldlexvar 0x0, 0x38 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass57 + mov v1, v0 + newobjrange 0xe0, 0x1, v1 + stobjbyname 0xe2, a57, a2 + ldlexvar 0x0, 0x39 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass58 + mov v1, v0 + newobjrange 0xe4, 0x1, v1 + stobjbyname 0xe6, a58, a2 + ldlexvar 0x0, 0x3a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass59 + mov v1, v0 + newobjrange 0xe8, 0x1, v1 + stobjbyname 0xea, a59, a2 + ldlexvar 0x0, 0x3b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass60 + mov v1, v0 + newobjrange 0xec, 0x1, v1 + stobjbyname 0xee, a60, a2 + ldlexvar 0x0, 0x3c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass61 + mov v1, v0 + newobjrange 0xf0, 0x1, v1 + stobjbyname 0xf2, a61, a2 + ldlexvar 0x0, 0x3d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass62 + mov v1, v0 + newobjrange 0xf4, 0x1, v1 + stobjbyname 0xf6, a62, a2 + ldlexvar 0x0, 0x3e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass63 + mov v1, v0 + newobjrange 0xf8, 0x1, v1 + stobjbyname 0xfa, a63, a2 + ldlexvar 0x0, 0x3f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass64 + mov v1, v0 + newobjrange 0xfc, 0x1, v1 + stobjbyname 0x100, a64, a2 + ldlexvar 0x0, 0x40 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass65 + mov v1, v0 + newobjrange 0x102, 0x1, v1 + stobjbyname 0x104, a65, a2 + ldlexvar 0x0, 0x41 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass66 + mov v1, v0 + newobjrange 0x106, 0x1, v1 + stobjbyname 0x108, a66, a2 + ldlexvar 0x0, 0x42 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass67 + mov v1, v0 + newobjrange 0x10a, 0x1, v1 + stobjbyname 0x10c, a67, a2 + ldlexvar 0x0, 0x43 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass68 + mov v1, v0 + newobjrange 0x10e, 0x1, v1 + stobjbyname 0x110, a68, a2 + ldlexvar 0x0, 0x44 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass69 + mov v1, v0 + newobjrange 0x112, 0x1, v1 + stobjbyname 0x114, a69, a2 + ldlexvar 0x0, 0x45 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass70 + mov v1, v0 + newobjrange 0x116, 0x1, v1 + stobjbyname 0x118, a70, a2 + ldlexvar 0x0, 0x46 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass71 + mov v1, v0 + newobjrange 0x11a, 0x1, v1 + stobjbyname 0x11c, a71, a2 + ldlexvar 0x0, 0x47 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass72 + mov v1, v0 + newobjrange 0x11e, 0x1, v1 + stobjbyname 0x120, a72, a2 + ldlexvar 0x0, 0x48 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass73 + mov v1, v0 + newobjrange 0x122, 0x1, v1 + stobjbyname 0x124, a73, a2 + ldlexvar 0x0, 0x49 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass74 + mov v1, v0 + newobjrange 0x126, 0x1, v1 + stobjbyname 0x128, a74, a2 + ldlexvar 0x0, 0x4a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass75 + mov v1, v0 + newobjrange 0x12a, 0x1, v1 + stobjbyname 0x12c, a75, a2 + ldlexvar 0x0, 0x4b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass76 + mov v1, v0 + newobjrange 0x12e, 0x1, v1 + stobjbyname 0x130, a76, a2 + ldlexvar 0x0, 0x4c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass77 + mov v1, v0 + newobjrange 0x132, 0x1, v1 + stobjbyname 0x134, a77, a2 + ldlexvar 0x0, 0x4d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass78 + mov v1, v0 + newobjrange 0x136, 0x1, v1 + stobjbyname 0x138, a78, a2 + ldlexvar 0x0, 0x4e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass79 + mov v1, v0 + newobjrange 0x13a, 0x1, v1 + stobjbyname 0x13c, a79, a2 + ldlexvar 0x0, 0x4f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass80 + mov v1, v0 + newobjrange 0x13e, 0x1, v1 + stobjbyname 0x140, a80, a2 + ldlexvar 0x0, 0x50 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass81 + mov v1, v0 + newobjrange 0x142, 0x1, v1 + stobjbyname 0x144, a81, a2 + ldlexvar 0x0, 0x51 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass82 + mov v1, v0 + newobjrange 0x146, 0x1, v1 + stobjbyname 0x148, a82, a2 + ldlexvar 0x0, 0x52 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass83 + mov v1, v0 + newobjrange 0x14a, 0x1, v1 + stobjbyname 0x14c, a83, a2 + ldlexvar 0x0, 0x53 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass84 + mov v1, v0 + newobjrange 0x14e, 0x1, v1 + stobjbyname 0x150, a84, a2 + ldlexvar 0x0, 0x54 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass85 + mov v1, v0 + newobjrange 0x152, 0x1, v1 + stobjbyname 0x154, a85, a2 + ldlexvar 0x0, 0x55 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass86 + mov v1, v0 + newobjrange 0x156, 0x1, v1 + stobjbyname 0x158, a86, a2 + ldlexvar 0x0, 0x56 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass87 + mov v1, v0 + newobjrange 0x15a, 0x1, v1 + stobjbyname 0x15c, a87, a2 + ldlexvar 0x0, 0x57 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass88 + mov v1, v0 + newobjrange 0x15e, 0x1, v1 + stobjbyname 0x160, a88, a2 + ldlexvar 0x0, 0x58 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass89 + mov v1, v0 + newobjrange 0x162, 0x1, v1 + stobjbyname 0x164, a89, a2 + ldlexvar 0x0, 0x59 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass90 + mov v1, v0 + newobjrange 0x166, 0x1, v1 + stobjbyname 0x168, a90, a2 + ldlexvar 0x0, 0x5a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass91 + mov v1, v0 + newobjrange 0x16a, 0x1, v1 + stobjbyname 0x16c, a91, a2 + ldlexvar 0x0, 0x5b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass92 + mov v1, v0 + newobjrange 0x16e, 0x1, v1 + stobjbyname 0x170, a92, a2 + ldlexvar 0x0, 0x5c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass93 + mov v1, v0 + newobjrange 0x172, 0x1, v1 + stobjbyname 0x174, a93, a2 + ldlexvar 0x0, 0x5d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass94 + mov v1, v0 + newobjrange 0x176, 0x1, v1 + stobjbyname 0x178, a94, a2 + ldlexvar 0x0, 0x5e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass95 + mov v1, v0 + newobjrange 0x17a, 0x1, v1 + stobjbyname 0x17c, a95, a2 + ldlexvar 0x0, 0x5f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass96 + mov v1, v0 + newobjrange 0x17e, 0x1, v1 + stobjbyname 0x180, a96, a2 + ldlexvar 0x0, 0x60 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass97 + mov v1, v0 + newobjrange 0x182, 0x1, v1 + stobjbyname 0x184, a97, a2 + ldlexvar 0x0, 0x61 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass98 + mov v1, v0 + newobjrange 0x186, 0x1, v1 + stobjbyname 0x188, a98, a2 + ldlexvar 0x0, 0x62 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass99 + mov v1, v0 + newobjrange 0x18a, 0x1, v1 + stobjbyname 0x18c, a99, a2 + ldlexvar 0x0, 0x63 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass100 + mov v1, v0 + newobjrange 0x18e, 0x1, v1 + stobjbyname 0x190, a100, a2 + ldlexvar 0x0, 0x64 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass101 + mov v1, v0 + newobjrange 0x192, 0x1, v1 + stobjbyname 0x194, a101, a2 + ldlexvar 0x0, 0x65 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass102 + mov v1, v0 + newobjrange 0x196, 0x1, v1 + stobjbyname 0x198, a102, a2 + ldlexvar 0x0, 0x66 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass103 + mov v1, v0 + newobjrange 0x19a, 0x1, v1 + stobjbyname 0x19c, a103, a2 + ldlexvar 0x0, 0x67 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass104 + mov v1, v0 + newobjrange 0x19e, 0x1, v1 + stobjbyname 0x1a0, a104, a2 + ldlexvar 0x0, 0x68 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass105 + mov v1, v0 + newobjrange 0x1a2, 0x1, v1 + stobjbyname 0x1a4, a105, a2 + ldlexvar 0x0, 0x69 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass106 + mov v1, v0 + newobjrange 0x1a6, 0x1, v1 + stobjbyname 0x1a8, a106, a2 + ldlexvar 0x0, 0x6a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass107 + mov v1, v0 + newobjrange 0x1aa, 0x1, v1 + stobjbyname 0x1ac, a107, a2 + ldlexvar 0x0, 0x6b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass108 + mov v1, v0 + newobjrange 0x1ae, 0x1, v1 + stobjbyname 0x1b0, a108, a2 + ldlexvar 0x0, 0x6c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass109 + mov v1, v0 + newobjrange 0x1b2, 0x1, v1 + stobjbyname 0x1b4, a109, a2 + ldlexvar 0x0, 0x6d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass110 + mov v1, v0 + newobjrange 0x1b6, 0x1, v1 + stobjbyname 0x1b8, a110, a2 + ldlexvar 0x0, 0x6e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass111 + mov v1, v0 + newobjrange 0x1ba, 0x1, v1 + stobjbyname 0x1bc, a111, a2 + ldlexvar 0x0, 0x6f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass112 + mov v1, v0 + newobjrange 0x1be, 0x1, v1 + stobjbyname 0x1c0, a112, a2 + ldlexvar 0x0, 0x70 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass113 + mov v1, v0 + newobjrange 0x1c2, 0x1, v1 + stobjbyname 0x1c4, a113, a2 + ldlexvar 0x0, 0x71 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass114 + mov v1, v0 + newobjrange 0x1c6, 0x1, v1 + stobjbyname 0x1c8, a114, a2 + ldlexvar 0x0, 0x72 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass115 + mov v1, v0 + newobjrange 0x1ca, 0x1, v1 + stobjbyname 0x1cc, a115, a2 + ldlexvar 0x0, 0x73 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass116 + mov v1, v0 + newobjrange 0x1ce, 0x1, v1 + stobjbyname 0x1d0, a116, a2 + ldlexvar 0x0, 0x74 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass117 + mov v1, v0 + newobjrange 0x1d2, 0x1, v1 + stobjbyname 0x1d4, a117, a2 + ldlexvar 0x0, 0x75 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass118 + mov v1, v0 + newobjrange 0x1d6, 0x1, v1 + stobjbyname 0x1d8, a118, a2 + ldlexvar 0x0, 0x76 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass119 + mov v1, v0 + newobjrange 0x1da, 0x1, v1 + stobjbyname 0x1dc, a119, a2 + ldlexvar 0x0, 0x77 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass120 + mov v1, v0 + newobjrange 0x1de, 0x1, v1 + stobjbyname 0x1e0, a120, a2 + ldlexvar 0x0, 0x78 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass121 + mov v1, v0 + newobjrange 0x1e2, 0x1, v1 + stobjbyname 0x1e4, a121, a2 + ldlexvar 0x0, 0x79 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass122 + mov v1, v0 + newobjrange 0x1e6, 0x1, v1 + stobjbyname 0x1e8, a122, a2 + ldlexvar 0x0, 0x7a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass123 + mov v1, v0 + newobjrange 0x1ea, 0x1, v1 + stobjbyname 0x1ec, a123, a2 + ldlexvar 0x0, 0x7b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass124 + mov v1, v0 + newobjrange 0x1ee, 0x1, v1 + stobjbyname 0x1f0, a124, a2 + ldlexvar 0x0, 0x7c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass125 + mov v1, v0 + newobjrange 0x1f2, 0x1, v1 + stobjbyname 0x1f4, a125, a2 + ldlexvar 0x0, 0x7d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass126 + mov v1, v0 + newobjrange 0x1f6, 0x1, v1 + stobjbyname 0x1f8, a126, a2 + ldlexvar 0x0, 0x7e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass127 + mov v1, v0 + newobjrange 0x1fa, 0x1, v1 + stobjbyname 0x1fc, a127, a2 + ldlexvar 0x0, 0x7f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass128 + mov v1, v0 + newobjrange 0x1fe, 0x1, v1 + stobjbyname 0x200, a128, a2 + wide.ldlexvar 0x0, 0x80 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass129 + mov v1, v0 + newobjrange 0x202, 0x1, v1 + stobjbyname 0x204, a129, a2 + wide.ldlexvar 0x0, 0x81 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass130 + mov v1, v0 + newobjrange 0x206, 0x1, v1 + stobjbyname 0x208, a130, a2 + wide.ldlexvar 0x0, 0x82 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass131 + mov v1, v0 + newobjrange 0x20a, 0x1, v1 + stobjbyname 0x20c, a131, a2 + wide.ldlexvar 0x0, 0x83 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass132 + mov v1, v0 + newobjrange 0x20e, 0x1, v1 + stobjbyname 0x210, a132, a2 + wide.ldlexvar 0x0, 0x84 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass133 + mov v1, v0 + newobjrange 0x212, 0x1, v1 + stobjbyname 0x214, a133, a2 + wide.ldlexvar 0x0, 0x85 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass134 + mov v1, v0 + newobjrange 0x216, 0x1, v1 + stobjbyname 0x218, a134, a2 + wide.ldlexvar 0x0, 0x86 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass135 + mov v1, v0 + newobjrange 0x21a, 0x1, v1 + stobjbyname 0x21c, a135, a2 + wide.ldlexvar 0x0, 0x87 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass136 + mov v1, v0 + newobjrange 0x21e, 0x1, v1 + stobjbyname 0x220, a136, a2 + wide.ldlexvar 0x0, 0x88 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass137 + mov v1, v0 + newobjrange 0x222, 0x1, v1 + stobjbyname 0x224, a137, a2 + wide.ldlexvar 0x0, 0x89 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass138 + mov v1, v0 + newobjrange 0x226, 0x1, v1 + stobjbyname 0x228, a138, a2 + wide.ldlexvar 0x0, 0x8a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass139 + mov v1, v0 + newobjrange 0x22a, 0x1, v1 + stobjbyname 0x22c, a139, a2 + wide.ldlexvar 0x0, 0x8b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass140 + mov v1, v0 + newobjrange 0x22e, 0x1, v1 + stobjbyname 0x230, a140, a2 + wide.ldlexvar 0x0, 0x8c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass141 + mov v1, v0 + newobjrange 0x232, 0x1, v1 + stobjbyname 0x234, a141, a2 + wide.ldlexvar 0x0, 0x8d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass142 + mov v1, v0 + newobjrange 0x236, 0x1, v1 + stobjbyname 0x238, a142, a2 + wide.ldlexvar 0x0, 0x8e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass143 + mov v1, v0 + newobjrange 0x23a, 0x1, v1 + stobjbyname 0x23c, a143, a2 + wide.ldlexvar 0x0, 0x8f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass144 + mov v1, v0 + newobjrange 0x23e, 0x1, v1 + stobjbyname 0x240, a144, a2 + wide.ldlexvar 0x0, 0x90 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass145 + mov v1, v0 + newobjrange 0x242, 0x1, v1 + stobjbyname 0x244, a145, a2 + wide.ldlexvar 0x0, 0x91 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass146 + mov v1, v0 + newobjrange 0x246, 0x1, v1 + stobjbyname 0x248, a146, a2 + wide.ldlexvar 0x0, 0x92 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass147 + mov v1, v0 + newobjrange 0x24a, 0x1, v1 + stobjbyname 0x24c, a147, a2 + wide.ldlexvar 0x0, 0x93 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass148 + mov v1, v0 + newobjrange 0x24e, 0x1, v1 + stobjbyname 0x250, a148, a2 + wide.ldlexvar 0x0, 0x94 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass149 + mov v1, v0 + newobjrange 0x252, 0x1, v1 + stobjbyname 0x254, a149, a2 + wide.ldlexvar 0x0, 0x95 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass150 + mov v1, v0 + newobjrange 0x256, 0x1, v1 + stobjbyname 0x258, a150, a2 + wide.ldlexvar 0x0, 0x96 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass151 + mov v1, v0 + newobjrange 0x25a, 0x1, v1 + stobjbyname 0x25c, a151, a2 + wide.ldlexvar 0x0, 0x97 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass152 + mov v1, v0 + newobjrange 0x25e, 0x1, v1 + stobjbyname 0x260, a152, a2 + wide.ldlexvar 0x0, 0x98 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass153 + mov v1, v0 + newobjrange 0x262, 0x1, v1 + stobjbyname 0x264, a153, a2 + wide.ldlexvar 0x0, 0x99 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass154 + mov v1, v0 + newobjrange 0x266, 0x1, v1 + stobjbyname 0x268, a154, a2 + wide.ldlexvar 0x0, 0x9a + sta v0 + throw.undefinedifholewithname TopLevelSendableClass155 + mov v1, v0 + newobjrange 0x26a, 0x1, v1 + stobjbyname 0x26c, a155, a2 + wide.ldlexvar 0x0, 0x9b + sta v0 + throw.undefinedifholewithname TopLevelSendableClass156 + mov v1, v0 + newobjrange 0x26e, 0x1, v1 + stobjbyname 0x270, a156, a2 + wide.ldlexvar 0x0, 0x9c + sta v0 + throw.undefinedifholewithname TopLevelSendableClass157 + mov v1, v0 + newobjrange 0x272, 0x1, v1 + stobjbyname 0x274, a157, a2 + wide.ldlexvar 0x0, 0x9d + sta v0 + throw.undefinedifholewithname TopLevelSendableClass158 + mov v1, v0 + newobjrange 0x276, 0x1, v1 + stobjbyname 0x278, a158, a2 + wide.ldlexvar 0x0, 0x9e + sta v0 + throw.undefinedifholewithname TopLevelSendableClass159 + mov v1, v0 + newobjrange 0x27a, 0x1, v1 + stobjbyname 0x27c, a159, a2 + wide.ldlexvar 0x0, 0x9f + sta v0 + throw.undefinedifholewithname TopLevelSendableClass160 + mov v1, v0 + newobjrange 0x27e, 0x1, v1 + stobjbyname 0x280, a160, a2 + wide.ldlexvar 0x0, 0xa0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass161 + mov v1, v0 + newobjrange 0x282, 0x1, v1 + stobjbyname 0x284, a161, a2 + wide.ldlexvar 0x0, 0xa1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass162 + mov v1, v0 + newobjrange 0x286, 0x1, v1 + stobjbyname 0x288, a162, a2 + wide.ldlexvar 0x0, 0xa2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass163 + mov v1, v0 + newobjrange 0x28a, 0x1, v1 + stobjbyname 0x28c, a163, a2 + wide.ldlexvar 0x0, 0xa3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass164 + mov v1, v0 + newobjrange 0x28e, 0x1, v1 + stobjbyname 0x290, a164, a2 + wide.ldlexvar 0x0, 0xa4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass165 + mov v1, v0 + newobjrange 0x292, 0x1, v1 + stobjbyname 0x294, a165, a2 + wide.ldlexvar 0x0, 0xa5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass166 + mov v1, v0 + newobjrange 0x296, 0x1, v1 + stobjbyname 0x298, a166, a2 + wide.ldlexvar 0x0, 0xa6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass167 + mov v1, v0 + newobjrange 0x29a, 0x1, v1 + stobjbyname 0x29c, a167, a2 + wide.ldlexvar 0x0, 0xa7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass168 + mov v1, v0 + newobjrange 0x29e, 0x1, v1 + stobjbyname 0x2a0, a168, a2 + wide.ldlexvar 0x0, 0xa8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass169 + mov v1, v0 + newobjrange 0x2a2, 0x1, v1 + stobjbyname 0x2a4, a169, a2 + wide.ldlexvar 0x0, 0xa9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass170 + mov v1, v0 + newobjrange 0x2a6, 0x1, v1 + stobjbyname 0x2a8, a170, a2 + wide.ldlexvar 0x0, 0xaa + sta v0 + throw.undefinedifholewithname TopLevelSendableClass171 + mov v1, v0 + newobjrange 0x2aa, 0x1, v1 + stobjbyname 0x2ac, a171, a2 + wide.ldlexvar 0x0, 0xab + sta v0 + throw.undefinedifholewithname TopLevelSendableClass172 + mov v1, v0 + newobjrange 0x2ae, 0x1, v1 + stobjbyname 0x2b0, a172, a2 + wide.ldlexvar 0x0, 0xac + sta v0 + throw.undefinedifholewithname TopLevelSendableClass173 + mov v1, v0 + newobjrange 0x2b2, 0x1, v1 + stobjbyname 0x2b4, a173, a2 + wide.ldlexvar 0x0, 0xad + sta v0 + throw.undefinedifholewithname TopLevelSendableClass174 + mov v1, v0 + newobjrange 0x2b6, 0x1, v1 + stobjbyname 0x2b8, a174, a2 + wide.ldlexvar 0x0, 0xae + sta v0 + throw.undefinedifholewithname TopLevelSendableClass175 + mov v1, v0 + newobjrange 0x2ba, 0x1, v1 + stobjbyname 0x2bc, a175, a2 + wide.ldlexvar 0x0, 0xaf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass176 + mov v1, v0 + newobjrange 0x2be, 0x1, v1 + stobjbyname 0x2c0, a176, a2 + wide.ldlexvar 0x0, 0xb0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass177 + mov v1, v0 + newobjrange 0x2c2, 0x1, v1 + stobjbyname 0x2c4, a177, a2 + wide.ldlexvar 0x0, 0xb1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass178 + mov v1, v0 + newobjrange 0x2c6, 0x1, v1 + stobjbyname 0x2c8, a178, a2 + wide.ldlexvar 0x0, 0xb2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass179 + mov v1, v0 + newobjrange 0x2ca, 0x1, v1 + stobjbyname 0x2cc, a179, a2 + wide.ldlexvar 0x0, 0xb3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass180 + mov v1, v0 + newobjrange 0x2ce, 0x1, v1 + stobjbyname 0x2d0, a180, a2 + wide.ldlexvar 0x0, 0xb4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass181 + mov v1, v0 + newobjrange 0x2d2, 0x1, v1 + stobjbyname 0x2d4, a181, a2 + wide.ldlexvar 0x0, 0xb5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass182 + mov v1, v0 + newobjrange 0x2d6, 0x1, v1 + stobjbyname 0x2d8, a182, a2 + wide.ldlexvar 0x0, 0xb6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass183 + mov v1, v0 + newobjrange 0x2da, 0x1, v1 + stobjbyname 0x2dc, a183, a2 + wide.ldlexvar 0x0, 0xb7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass184 + mov v1, v0 + newobjrange 0x2de, 0x1, v1 + stobjbyname 0x2e0, a184, a2 + wide.ldlexvar 0x0, 0xb8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass185 + mov v1, v0 + newobjrange 0x2e2, 0x1, v1 + stobjbyname 0x2e4, a185, a2 + wide.ldlexvar 0x0, 0xb9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass186 + mov v1, v0 + newobjrange 0x2e6, 0x1, v1 + stobjbyname 0x2e8, a186, a2 + wide.ldlexvar 0x0, 0xba + sta v0 + throw.undefinedifholewithname TopLevelSendableClass187 + mov v1, v0 + newobjrange 0x2ea, 0x1, v1 + stobjbyname 0x2ec, a187, a2 + wide.ldlexvar 0x0, 0xbb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass188 + mov v1, v0 + newobjrange 0x2ee, 0x1, v1 + stobjbyname 0x2f0, a188, a2 + wide.ldlexvar 0x0, 0xbc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass189 + mov v1, v0 + newobjrange 0x2f2, 0x1, v1 + stobjbyname 0x2f4, a189, a2 + wide.ldlexvar 0x0, 0xbd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass190 + mov v1, v0 + newobjrange 0x2f6, 0x1, v1 + stobjbyname 0x2f8, a190, a2 + wide.ldlexvar 0x0, 0xbe + sta v0 + throw.undefinedifholewithname TopLevelSendableClass191 + mov v1, v0 + newobjrange 0x2fa, 0x1, v1 + stobjbyname 0x2fc, a191, a2 + wide.ldlexvar 0x0, 0xbf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass192 + mov v1, v0 + newobjrange 0x2fe, 0x1, v1 + stobjbyname 0x300, a192, a2 + wide.ldlexvar 0x0, 0xc0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass193 + mov v1, v0 + newobjrange 0x302, 0x1, v1 + stobjbyname 0x304, a193, a2 + wide.ldlexvar 0x0, 0xc1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass194 + mov v1, v0 + newobjrange 0x306, 0x1, v1 + stobjbyname 0x308, a194, a2 + wide.ldlexvar 0x0, 0xc2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass195 + mov v1, v0 + newobjrange 0x30a, 0x1, v1 + stobjbyname 0x30c, a195, a2 + wide.ldlexvar 0x0, 0xc3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass196 + mov v1, v0 + newobjrange 0x30e, 0x1, v1 + stobjbyname 0x310, a196, a2 + wide.ldlexvar 0x0, 0xc4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass197 + mov v1, v0 + newobjrange 0x312, 0x1, v1 + stobjbyname 0x314, a197, a2 + wide.ldlexvar 0x0, 0xc5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass198 + mov v1, v0 + newobjrange 0x316, 0x1, v1 + stobjbyname 0x318, a198, a2 + wide.ldlexvar 0x0, 0xc6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass199 + mov v1, v0 + newobjrange 0x31a, 0x1, v1 + stobjbyname 0x31c, a199, a2 + wide.ldlexvar 0x0, 0xc7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass200 + mov v1, v0 + newobjrange 0x31e, 0x1, v1 + stobjbyname 0x320, a200, a2 + wide.ldlexvar 0x0, 0xc8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass201 + mov v1, v0 + newobjrange 0x322, 0x1, v1 + stobjbyname 0x324, a201, a2 + wide.ldlexvar 0x0, 0xc9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass202 + mov v1, v0 + newobjrange 0x326, 0x1, v1 + stobjbyname 0x328, a202, a2 + wide.ldlexvar 0x0, 0xca + sta v0 + throw.undefinedifholewithname TopLevelSendableClass203 + mov v1, v0 + newobjrange 0x32a, 0x1, v1 + stobjbyname 0x32c, a203, a2 + wide.ldlexvar 0x0, 0xcb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass204 + mov v1, v0 + newobjrange 0x32e, 0x1, v1 + stobjbyname 0x330, a204, a2 + wide.ldlexvar 0x0, 0xcc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass205 + mov v1, v0 + newobjrange 0x332, 0x1, v1 + stobjbyname 0x334, a205, a2 + wide.ldlexvar 0x0, 0xcd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass206 + mov v1, v0 + newobjrange 0x336, 0x1, v1 + stobjbyname 0x338, a206, a2 + wide.ldlexvar 0x0, 0xce + sta v0 + throw.undefinedifholewithname TopLevelSendableClass207 + mov v1, v0 + newobjrange 0x33a, 0x1, v1 + stobjbyname 0x33c, a207, a2 + wide.ldlexvar 0x0, 0xcf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass208 + mov v1, v0 + newobjrange 0x33e, 0x1, v1 + stobjbyname 0x340, a208, a2 + wide.ldlexvar 0x0, 0xd0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass209 + mov v1, v0 + newobjrange 0x342, 0x1, v1 + stobjbyname 0x344, a209, a2 + wide.ldlexvar 0x0, 0xd1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass210 + mov v1, v0 + newobjrange 0x346, 0x1, v1 + stobjbyname 0x348, a210, a2 + wide.ldlexvar 0x0, 0xd2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass211 + mov v1, v0 + newobjrange 0x34a, 0x1, v1 + stobjbyname 0x34c, a211, a2 + wide.ldlexvar 0x0, 0xd3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass212 + mov v1, v0 + newobjrange 0x34e, 0x1, v1 + stobjbyname 0x350, a212, a2 + wide.ldlexvar 0x0, 0xd4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass213 + mov v1, v0 + newobjrange 0x352, 0x1, v1 + stobjbyname 0x354, a213, a2 + wide.ldlexvar 0x0, 0xd5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass214 + mov v1, v0 + newobjrange 0x356, 0x1, v1 + stobjbyname 0x358, a214, a2 + wide.ldlexvar 0x0, 0xd6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass215 + mov v1, v0 + newobjrange 0x35a, 0x1, v1 + stobjbyname 0x35c, a215, a2 + wide.ldlexvar 0x0, 0xd7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass216 + mov v1, v0 + newobjrange 0x35e, 0x1, v1 + stobjbyname 0x360, a216, a2 + wide.ldlexvar 0x0, 0xd8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass217 + mov v1, v0 + newobjrange 0x362, 0x1, v1 + stobjbyname 0x364, a217, a2 + wide.ldlexvar 0x0, 0xd9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass218 + mov v1, v0 + newobjrange 0x366, 0x1, v1 + stobjbyname 0x368, a218, a2 + wide.ldlexvar 0x0, 0xda + sta v0 + throw.undefinedifholewithname TopLevelSendableClass219 + mov v1, v0 + newobjrange 0x36a, 0x1, v1 + stobjbyname 0x36c, a219, a2 + wide.ldlexvar 0x0, 0xdb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass220 + mov v1, v0 + newobjrange 0x36e, 0x1, v1 + stobjbyname 0x370, a220, a2 + wide.ldlexvar 0x0, 0xdc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass221 + mov v1, v0 + newobjrange 0x372, 0x1, v1 + stobjbyname 0x374, a221, a2 + wide.ldlexvar 0x0, 0xdd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass222 + mov v1, v0 + newobjrange 0x376, 0x1, v1 + stobjbyname 0x378, a222, a2 + wide.ldlexvar 0x0, 0xde + sta v0 + throw.undefinedifholewithname TopLevelSendableClass223 + mov v1, v0 + newobjrange 0x37a, 0x1, v1 + stobjbyname 0x37c, a223, a2 + wide.ldlexvar 0x0, 0xdf + sta v0 + throw.undefinedifholewithname TopLevelSendableClass224 + mov v1, v0 + newobjrange 0x37e, 0x1, v1 + stobjbyname 0x380, a224, a2 + wide.ldlexvar 0x0, 0xe0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass225 + mov v1, v0 + newobjrange 0x382, 0x1, v1 + stobjbyname 0x384, a225, a2 + wide.ldlexvar 0x0, 0xe1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass226 + mov v1, v0 + newobjrange 0x386, 0x1, v1 + stobjbyname 0x388, a226, a2 + wide.ldlexvar 0x0, 0xe2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass227 + mov v1, v0 + newobjrange 0x38a, 0x1, v1 + stobjbyname 0x38c, a227, a2 + wide.ldlexvar 0x0, 0xe3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass228 + mov v1, v0 + newobjrange 0x38e, 0x1, v1 + stobjbyname 0x390, a228, a2 + wide.ldlexvar 0x0, 0xe4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass229 + mov v1, v0 + newobjrange 0x392, 0x1, v1 + stobjbyname 0x394, a229, a2 + wide.ldlexvar 0x0, 0xe5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass230 + mov v1, v0 + newobjrange 0x396, 0x1, v1 + stobjbyname 0x398, a230, a2 + wide.ldlexvar 0x0, 0xe6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass231 + mov v1, v0 + newobjrange 0x39a, 0x1, v1 + stobjbyname 0x39c, a231, a2 + wide.ldlexvar 0x0, 0xe7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass232 + mov v1, v0 + newobjrange 0x39e, 0x1, v1 + stobjbyname 0x3a0, a232, a2 + wide.ldlexvar 0x0, 0xe8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass233 + mov v1, v0 + newobjrange 0x3a2, 0x1, v1 + stobjbyname 0x3a4, a233, a2 + wide.ldlexvar 0x0, 0xe9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass234 + mov v1, v0 + newobjrange 0x3a6, 0x1, v1 + stobjbyname 0x3a8, a234, a2 + wide.ldlexvar 0x0, 0xea + sta v0 + throw.undefinedifholewithname TopLevelSendableClass235 + mov v1, v0 + newobjrange 0x3aa, 0x1, v1 + stobjbyname 0x3ac, a235, a2 + wide.ldlexvar 0x0, 0xeb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass236 + mov v1, v0 + newobjrange 0x3ae, 0x1, v1 + stobjbyname 0x3b0, a236, a2 + wide.ldlexvar 0x0, 0xec + sta v0 + throw.undefinedifholewithname TopLevelSendableClass237 + mov v1, v0 + newobjrange 0x3b2, 0x1, v1 + stobjbyname 0x3b4, a237, a2 + wide.ldlexvar 0x0, 0xed + sta v0 + throw.undefinedifholewithname TopLevelSendableClass238 + mov v1, v0 + newobjrange 0x3b6, 0x1, v1 + stobjbyname 0x3b8, a238, a2 + wide.ldlexvar 0x0, 0xee + sta v0 + throw.undefinedifholewithname TopLevelSendableClass239 + mov v1, v0 + newobjrange 0x3ba, 0x1, v1 + stobjbyname 0x3bc, a239, a2 + wide.ldlexvar 0x0, 0xef + sta v0 + throw.undefinedifholewithname TopLevelSendableClass240 + mov v1, v0 + newobjrange 0x3be, 0x1, v1 + stobjbyname 0x3c0, a240, a2 + wide.ldlexvar 0x0, 0xf0 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass241 + mov v1, v0 + newobjrange 0x3c2, 0x1, v1 + stobjbyname 0x3c4, a241, a2 + wide.ldlexvar 0x0, 0xf1 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass242 + mov v1, v0 + newobjrange 0x3c6, 0x1, v1 + stobjbyname 0x3c8, a242, a2 + wide.ldlexvar 0x0, 0xf2 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass243 + mov v1, v0 + newobjrange 0x3ca, 0x1, v1 + stobjbyname 0x3cc, a243, a2 + wide.ldlexvar 0x0, 0xf3 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass244 + mov v1, v0 + newobjrange 0x3ce, 0x1, v1 + stobjbyname 0x3d0, a244, a2 + wide.ldlexvar 0x0, 0xf4 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass245 + mov v1, v0 + newobjrange 0x3d2, 0x1, v1 + stobjbyname 0x3d4, a245, a2 + wide.ldlexvar 0x0, 0xf5 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass246 + mov v1, v0 + newobjrange 0x3d6, 0x1, v1 + stobjbyname 0x3d8, a246, a2 + wide.ldlexvar 0x0, 0xf6 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass247 + mov v1, v0 + newobjrange 0x3da, 0x1, v1 + stobjbyname 0x3dc, a247, a2 + wide.ldlexvar 0x0, 0xf7 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass248 + mov v1, v0 + newobjrange 0x3de, 0x1, v1 + stobjbyname 0x3e0, a248, a2 + wide.ldlexvar 0x0, 0xf8 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass249 + mov v1, v0 + newobjrange 0x3e2, 0x1, v1 + stobjbyname 0x3e4, a249, a2 + wide.ldlexvar 0x0, 0xf9 + sta v0 + throw.undefinedifholewithname TopLevelSendableClass250 + mov v1, v0 + newobjrange 0x3e6, 0x1, v1 + stobjbyname 0x3e8, a250, a2 + wide.ldlexvar 0x0, 0xfa + sta v0 + throw.undefinedifholewithname TopLevelSendableClass251 + mov v1, v0 + newobjrange 0x3ea, 0x1, v1 + stobjbyname 0x3ec, a251, a2 + wide.ldlexvar 0x0, 0xfb + sta v0 + throw.undefinedifholewithname TopLevelSendableClass252 + mov v1, v0 + newobjrange 0x3ee, 0x1, v1 + stobjbyname 0x3f0, a252, a2 + wide.ldlexvar 0x0, 0xfc + sta v0 + throw.undefinedifholewithname TopLevelSendableClass253 + mov v1, v0 + newobjrange 0x3f2, 0x1, v1 + stobjbyname 0x3f4, a253, a2 + wide.ldlexvar 0x0, 0xfd + sta v0 + throw.undefinedifholewithname TopLevelSendableClass254 + mov v1, v0 + newobjrange 0x3f6, 0x1, v1 + stobjbyname 0x3f8, a254, a2 + wide.ldlexvar 0x0, 0xfe + sta v0 + throw.undefinedifholewithname TopLevelSendableClass255 + mov v1, v0 + newobjrange 0x3fa, 0x1, v1 + stobjbyname 0x3fc, a255, a2 + lda a2 + ldobjbyname 0x3fe, a1 + ldobjbyname 0x400, o + stobjbyname 0x402, u, a2 + lda.str wide_sendable_test + stobjbyname 0x404, v, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass1(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass10(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass100(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass101(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass102(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass103(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass104(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass105(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass106(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass107(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass108(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass109(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass11(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass110(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass111(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass112(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass113(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass114(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass115(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass116(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass117(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass118(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass119(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass12(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass120(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass121(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass122(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass123(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass124(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass125(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass126(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass127(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass128(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass129(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass13(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass130(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass131(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass132(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass133(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass134(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass135(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass136(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass137(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass138(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass139(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass14(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass140(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass141(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass142(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass143(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass144(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass145(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass146(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass147(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass148(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass149(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass15(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass150(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass151(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass152(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass153(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass154(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass155(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass156(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass157(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass158(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass159(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass16(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass160(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass161(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass162(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass163(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass164(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass165(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass166(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass167(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass168(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass169(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass17(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass170(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass171(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass172(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass173(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass174(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass175(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass176(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass177(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass178(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass179(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass18(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass180(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass181(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass182(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass183(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass184(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass185(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass186(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass187(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass188(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass189(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass19(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass190(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass191(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass192(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass193(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass194(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass195(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass196(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass197(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass198(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass199(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass2(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass20(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass200(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass201(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass202(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass203(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass204(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass205(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass206(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass207(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass208(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass209(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass21(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass210(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass211(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass212(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass213(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass214(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass215(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass216(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass217(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass218(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass219(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass22(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass220(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass221(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass222(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass223(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass224(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass225(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass226(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass227(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass228(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass229(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass23(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass230(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass231(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass232(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass233(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass234(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass235(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass236(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass237(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass238(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass239(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass24(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass240(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass241(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass242(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass243(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass244(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass245(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass246(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass247(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass248(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass249(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass25(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass250(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass251(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass252(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass253(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass254(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass255(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass26(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass27(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass28(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass29(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass3(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass30(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass31(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass32(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass33(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass34(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass35(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass36(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass37(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass38(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass39(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass4(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass40(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass41(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass42(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass43(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass44(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass45(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass46(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass47(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass48(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass49(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass5(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass50(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass51(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass52(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass53(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass54(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass55(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass56(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass57(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass58(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass59(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass6(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass60(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass61(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass62(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass63(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass64(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass65(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass66(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass67(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass68(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass69(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass7(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass70(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass71(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass72(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass73(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass74(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass75(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass76(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass77(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass78(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass79(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass8(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass80(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass81(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass82(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass83(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass84(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass85(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass86(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass87(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass88(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass89(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass9(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass90(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass91(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass92(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass93(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass94(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass95(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass96(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass97(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass98(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .TopLevelSendableClass99(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + stobjbyname 0x0, o, a2 + lda a2 + return +label_2: +} + +slotNum = 0x108 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + wide.newlexenv 0xff + ldhole + sta v0 + callruntime.definesendableclass 0x2, .TopLevelSendableClass1, _2, 0x0, v0 + stlexvar 0x0, 0x0 + ldhole + sta v0 + callruntime.definesendableclass 0x3, .TopLevelSendableClass2, _4, 0x0, v0 + stlexvar 0x0, 0x1 + ldhole + sta v0 + callruntime.definesendableclass 0x4, .TopLevelSendableClass3, _6, 0x0, v0 + stlexvar 0x0, 0x2 + ldhole + sta v0 + callruntime.definesendableclass 0x5, .TopLevelSendableClass4, _8, 0x0, v0 + stlexvar 0x0, 0x3 + ldhole + sta v0 + callruntime.definesendableclass 0x6, .TopLevelSendableClass5, _10, 0x0, v0 + stlexvar 0x0, 0x4 + ldhole + sta v0 + callruntime.definesendableclass 0x7, .TopLevelSendableClass6, _12, 0x0, v0 + stlexvar 0x0, 0x5 + ldhole + sta v0 + callruntime.definesendableclass 0x8, .TopLevelSendableClass7, _14, 0x0, v0 + stlexvar 0x0, 0x6 + ldhole + sta v0 + callruntime.definesendableclass 0x9, .TopLevelSendableClass8, _16, 0x0, v0 + stlexvar 0x0, 0x7 + ldhole + sta v0 + callruntime.definesendableclass 0xa, .TopLevelSendableClass9, _18, 0x0, v0 + stlexvar 0x0, 0x8 + ldhole + sta v0 + callruntime.definesendableclass 0xb, .TopLevelSendableClass10, _20, 0x0, v0 + stlexvar 0x0, 0x9 + ldhole + sta v0 + callruntime.definesendableclass 0xc, .TopLevelSendableClass11, _22, 0x0, v0 + stlexvar 0x0, 0xa + ldhole + sta v0 + callruntime.definesendableclass 0xd, .TopLevelSendableClass12, _24, 0x0, v0 + stlexvar 0x0, 0xb + ldhole + sta v0 + callruntime.definesendableclass 0xe, .TopLevelSendableClass13, _26, 0x0, v0 + stlexvar 0x0, 0xc + ldhole + sta v0 + callruntime.definesendableclass 0xf, .TopLevelSendableClass14, _28, 0x0, v0 + stlexvar 0x0, 0xd + ldhole + sta v0 + callruntime.definesendableclass 0x10, .TopLevelSendableClass15, _30, 0x0, v0 + stlexvar 0x0, 0xe + ldhole + sta v0 + callruntime.definesendableclass 0x11, .TopLevelSendableClass16, _32, 0x0, v0 + stlexvar 0x0, 0xf + ldhole + sta v0 + callruntime.definesendableclass 0x12, .TopLevelSendableClass17, _34, 0x0, v0 + stlexvar 0x0, 0x10 + ldhole + sta v0 + callruntime.definesendableclass 0x13, .TopLevelSendableClass18, _36, 0x0, v0 + stlexvar 0x0, 0x11 + ldhole + sta v0 + callruntime.definesendableclass 0x14, .TopLevelSendableClass19, _38, 0x0, v0 + stlexvar 0x0, 0x12 + ldhole + sta v0 + callruntime.definesendableclass 0x15, .TopLevelSendableClass20, _40, 0x0, v0 + stlexvar 0x0, 0x13 + ldhole + sta v0 + callruntime.definesendableclass 0x16, .TopLevelSendableClass21, _42, 0x0, v0 + stlexvar 0x0, 0x14 + ldhole + sta v0 + callruntime.definesendableclass 0x17, .TopLevelSendableClass22, _44, 0x0, v0 + stlexvar 0x0, 0x15 + ldhole + sta v0 + callruntime.definesendableclass 0x18, .TopLevelSendableClass23, _46, 0x0, v0 + stlexvar 0x0, 0x16 + ldhole + sta v0 + callruntime.definesendableclass 0x19, .TopLevelSendableClass24, _48, 0x0, v0 + stlexvar 0x0, 0x17 + ldhole + sta v0 + callruntime.definesendableclass 0x1a, .TopLevelSendableClass25, _50, 0x0, v0 + stlexvar 0x0, 0x18 + ldhole + sta v0 + callruntime.definesendableclass 0x1b, .TopLevelSendableClass26, _52, 0x0, v0 + stlexvar 0x0, 0x19 + ldhole + sta v0 + callruntime.definesendableclass 0x1c, .TopLevelSendableClass27, _54, 0x0, v0 + stlexvar 0x0, 0x1a + ldhole + sta v0 + callruntime.definesendableclass 0x1d, .TopLevelSendableClass28, _56, 0x0, v0 + stlexvar 0x0, 0x1b + ldhole + sta v0 + callruntime.definesendableclass 0x1e, .TopLevelSendableClass29, _58, 0x0, v0 + stlexvar 0x0, 0x1c + ldhole + sta v0 + callruntime.definesendableclass 0x1f, .TopLevelSendableClass30, _60, 0x0, v0 + stlexvar 0x0, 0x1d + ldhole + sta v0 + callruntime.definesendableclass 0x20, .TopLevelSendableClass31, _62, 0x0, v0 + stlexvar 0x0, 0x1e + ldhole + sta v0 + callruntime.definesendableclass 0x21, .TopLevelSendableClass32, _64, 0x0, v0 + stlexvar 0x0, 0x1f + ldhole + sta v0 + callruntime.definesendableclass 0x22, .TopLevelSendableClass33, _66, 0x0, v0 + stlexvar 0x0, 0x20 + ldhole + sta v0 + callruntime.definesendableclass 0x23, .TopLevelSendableClass34, _68, 0x0, v0 + stlexvar 0x0, 0x21 + ldhole + sta v0 + callruntime.definesendableclass 0x24, .TopLevelSendableClass35, _70, 0x0, v0 + stlexvar 0x0, 0x22 + ldhole + sta v0 + callruntime.definesendableclass 0x25, .TopLevelSendableClass36, _72, 0x0, v0 + stlexvar 0x0, 0x23 + ldhole + sta v0 + callruntime.definesendableclass 0x26, .TopLevelSendableClass37, _74, 0x0, v0 + stlexvar 0x0, 0x24 + ldhole + sta v0 + callruntime.definesendableclass 0x27, .TopLevelSendableClass38, _76, 0x0, v0 + stlexvar 0x0, 0x25 + ldhole + sta v0 + callruntime.definesendableclass 0x28, .TopLevelSendableClass39, _78, 0x0, v0 + stlexvar 0x0, 0x26 + ldhole + sta v0 + callruntime.definesendableclass 0x29, .TopLevelSendableClass40, _80, 0x0, v0 + stlexvar 0x0, 0x27 + ldhole + sta v0 + callruntime.definesendableclass 0x2a, .TopLevelSendableClass41, _82, 0x0, v0 + stlexvar 0x0, 0x28 + ldhole + sta v0 + callruntime.definesendableclass 0x2b, .TopLevelSendableClass42, _84, 0x0, v0 + stlexvar 0x0, 0x29 + ldhole + sta v0 + callruntime.definesendableclass 0x2c, .TopLevelSendableClass43, _86, 0x0, v0 + stlexvar 0x0, 0x2a + ldhole + sta v0 + callruntime.definesendableclass 0x2d, .TopLevelSendableClass44, _88, 0x0, v0 + stlexvar 0x0, 0x2b + ldhole + sta v0 + callruntime.definesendableclass 0x2e, .TopLevelSendableClass45, _90, 0x0, v0 + stlexvar 0x0, 0x2c + ldhole + sta v0 + callruntime.definesendableclass 0x2f, .TopLevelSendableClass46, _92, 0x0, v0 + stlexvar 0x0, 0x2d + ldhole + sta v0 + callruntime.definesendableclass 0x30, .TopLevelSendableClass47, _94, 0x0, v0 + stlexvar 0x0, 0x2e + ldhole + sta v0 + callruntime.definesendableclass 0x31, .TopLevelSendableClass48, _96, 0x0, v0 + stlexvar 0x0, 0x2f + ldhole + sta v0 + callruntime.definesendableclass 0x32, .TopLevelSendableClass49, _98, 0x0, v0 + stlexvar 0x0, 0x30 + ldhole + sta v0 + callruntime.definesendableclass 0x33, .TopLevelSendableClass50, _100, 0x0, v0 + stlexvar 0x0, 0x31 + ldhole + sta v0 + callruntime.definesendableclass 0x34, .TopLevelSendableClass51, _102, 0x0, v0 + stlexvar 0x0, 0x32 + ldhole + sta v0 + callruntime.definesendableclass 0x35, .TopLevelSendableClass52, _104, 0x0, v0 + stlexvar 0x0, 0x33 + ldhole + sta v0 + callruntime.definesendableclass 0x36, .TopLevelSendableClass53, _106, 0x0, v0 + stlexvar 0x0, 0x34 + ldhole + sta v0 + callruntime.definesendableclass 0x37, .TopLevelSendableClass54, _108, 0x0, v0 + stlexvar 0x0, 0x35 + ldhole + sta v0 + callruntime.definesendableclass 0x38, .TopLevelSendableClass55, _110, 0x0, v0 + stlexvar 0x0, 0x36 + ldhole + sta v0 + callruntime.definesendableclass 0x39, .TopLevelSendableClass56, _112, 0x0, v0 + stlexvar 0x0, 0x37 + ldhole + sta v0 + callruntime.definesendableclass 0x3a, .TopLevelSendableClass57, _114, 0x0, v0 + stlexvar 0x0, 0x38 + ldhole + sta v0 + callruntime.definesendableclass 0x3b, .TopLevelSendableClass58, _116, 0x0, v0 + stlexvar 0x0, 0x39 + ldhole + sta v0 + callruntime.definesendableclass 0x3c, .TopLevelSendableClass59, _118, 0x0, v0 + stlexvar 0x0, 0x3a + ldhole + sta v0 + callruntime.definesendableclass 0x3d, .TopLevelSendableClass60, _120, 0x0, v0 + stlexvar 0x0, 0x3b + ldhole + sta v0 + callruntime.definesendableclass 0x3e, .TopLevelSendableClass61, _122, 0x0, v0 + stlexvar 0x0, 0x3c + ldhole + sta v0 + callruntime.definesendableclass 0x3f, .TopLevelSendableClass62, _124, 0x0, v0 + stlexvar 0x0, 0x3d + ldhole + sta v0 + callruntime.definesendableclass 0x40, .TopLevelSendableClass63, _126, 0x0, v0 + stlexvar 0x0, 0x3e + ldhole + sta v0 + callruntime.definesendableclass 0x41, .TopLevelSendableClass64, _128, 0x0, v0 + stlexvar 0x0, 0x3f + ldhole + sta v0 + callruntime.definesendableclass 0x42, .TopLevelSendableClass65, _130, 0x0, v0 + stlexvar 0x0, 0x40 + ldhole + sta v0 + callruntime.definesendableclass 0x43, .TopLevelSendableClass66, _132, 0x0, v0 + stlexvar 0x0, 0x41 + ldhole + sta v0 + callruntime.definesendableclass 0x44, .TopLevelSendableClass67, _134, 0x0, v0 + stlexvar 0x0, 0x42 + ldhole + sta v0 + callruntime.definesendableclass 0x45, .TopLevelSendableClass68, _136, 0x0, v0 + stlexvar 0x0, 0x43 + ldhole + sta v0 + callruntime.definesendableclass 0x46, .TopLevelSendableClass69, _138, 0x0, v0 + stlexvar 0x0, 0x44 + ldhole + sta v0 + callruntime.definesendableclass 0x47, .TopLevelSendableClass70, _140, 0x0, v0 + stlexvar 0x0, 0x45 + ldhole + sta v0 + callruntime.definesendableclass 0x48, .TopLevelSendableClass71, _142, 0x0, v0 + stlexvar 0x0, 0x46 + ldhole + sta v0 + callruntime.definesendableclass 0x49, .TopLevelSendableClass72, _144, 0x0, v0 + stlexvar 0x0, 0x47 + ldhole + sta v0 + callruntime.definesendableclass 0x4a, .TopLevelSendableClass73, _146, 0x0, v0 + stlexvar 0x0, 0x48 + ldhole + sta v0 + callruntime.definesendableclass 0x4b, .TopLevelSendableClass74, _148, 0x0, v0 + stlexvar 0x0, 0x49 + ldhole + sta v0 + callruntime.definesendableclass 0x4c, .TopLevelSendableClass75, _150, 0x0, v0 + stlexvar 0x0, 0x4a + ldhole + sta v0 + callruntime.definesendableclass 0x4d, .TopLevelSendableClass76, _152, 0x0, v0 + stlexvar 0x0, 0x4b + ldhole + sta v0 + callruntime.definesendableclass 0x4e, .TopLevelSendableClass77, _154, 0x0, v0 + stlexvar 0x0, 0x4c + ldhole + sta v0 + callruntime.definesendableclass 0x4f, .TopLevelSendableClass78, _156, 0x0, v0 + stlexvar 0x0, 0x4d + ldhole + sta v0 + callruntime.definesendableclass 0x50, .TopLevelSendableClass79, _158, 0x0, v0 + stlexvar 0x0, 0x4e + ldhole + sta v0 + callruntime.definesendableclass 0x51, .TopLevelSendableClass80, _160, 0x0, v0 + stlexvar 0x0, 0x4f + ldhole + sta v0 + callruntime.definesendableclass 0x52, .TopLevelSendableClass81, _162, 0x0, v0 + stlexvar 0x0, 0x50 + ldhole + sta v0 + callruntime.definesendableclass 0x53, .TopLevelSendableClass82, _164, 0x0, v0 + stlexvar 0x0, 0x51 + ldhole + sta v0 + callruntime.definesendableclass 0x54, .TopLevelSendableClass83, _166, 0x0, v0 + stlexvar 0x0, 0x52 + ldhole + sta v0 + callruntime.definesendableclass 0x55, .TopLevelSendableClass84, _168, 0x0, v0 + stlexvar 0x0, 0x53 + ldhole + sta v0 + callruntime.definesendableclass 0x56, .TopLevelSendableClass85, _170, 0x0, v0 + stlexvar 0x0, 0x54 + ldhole + sta v0 + callruntime.definesendableclass 0x57, .TopLevelSendableClass86, _172, 0x0, v0 + stlexvar 0x0, 0x55 + ldhole + sta v0 + callruntime.definesendableclass 0x58, .TopLevelSendableClass87, _174, 0x0, v0 + stlexvar 0x0, 0x56 + ldhole + sta v0 + callruntime.definesendableclass 0x59, .TopLevelSendableClass88, _176, 0x0, v0 + stlexvar 0x0, 0x57 + ldhole + sta v0 + callruntime.definesendableclass 0x5a, .TopLevelSendableClass89, _178, 0x0, v0 + stlexvar 0x0, 0x58 + ldhole + sta v0 + callruntime.definesendableclass 0x5b, .TopLevelSendableClass90, _180, 0x0, v0 + stlexvar 0x0, 0x59 + ldhole + sta v0 + callruntime.definesendableclass 0x5c, .TopLevelSendableClass91, _182, 0x0, v0 + stlexvar 0x0, 0x5a + ldhole + sta v0 + callruntime.definesendableclass 0x5d, .TopLevelSendableClass92, _184, 0x0, v0 + stlexvar 0x0, 0x5b + ldhole + sta v0 + callruntime.definesendableclass 0x5e, .TopLevelSendableClass93, _186, 0x0, v0 + stlexvar 0x0, 0x5c + ldhole + sta v0 + callruntime.definesendableclass 0x5f, .TopLevelSendableClass94, _188, 0x0, v0 + stlexvar 0x0, 0x5d + ldhole + sta v0 + callruntime.definesendableclass 0x60, .TopLevelSendableClass95, _190, 0x0, v0 + stlexvar 0x0, 0x5e + ldhole + sta v0 + callruntime.definesendableclass 0x61, .TopLevelSendableClass96, _192, 0x0, v0 + stlexvar 0x0, 0x5f + ldhole + sta v0 + callruntime.definesendableclass 0x62, .TopLevelSendableClass97, _194, 0x0, v0 + stlexvar 0x0, 0x60 + ldhole + sta v0 + callruntime.definesendableclass 0x63, .TopLevelSendableClass98, _196, 0x0, v0 + stlexvar 0x0, 0x61 + ldhole + sta v0 + callruntime.definesendableclass 0x64, .TopLevelSendableClass99, _198, 0x0, v0 + stlexvar 0x0, 0x62 + ldhole + sta v0 + callruntime.definesendableclass 0x65, .TopLevelSendableClass100, _200, 0x0, v0 + stlexvar 0x0, 0x63 + ldhole + sta v0 + callruntime.definesendableclass 0x66, .TopLevelSendableClass101, _202, 0x0, v0 + stlexvar 0x0, 0x64 + ldhole + sta v0 + callruntime.definesendableclass 0x67, .TopLevelSendableClass102, _204, 0x0, v0 + stlexvar 0x0, 0x65 + ldhole + sta v0 + callruntime.definesendableclass 0x68, .TopLevelSendableClass103, _206, 0x0, v0 + stlexvar 0x0, 0x66 + ldhole + sta v0 + callruntime.definesendableclass 0x69, .TopLevelSendableClass104, _208, 0x0, v0 + stlexvar 0x0, 0x67 + ldhole + sta v0 + callruntime.definesendableclass 0x6a, .TopLevelSendableClass105, _210, 0x0, v0 + stlexvar 0x0, 0x68 + ldhole + sta v0 + callruntime.definesendableclass 0x6b, .TopLevelSendableClass106, _212, 0x0, v0 + stlexvar 0x0, 0x69 + ldhole + sta v0 + callruntime.definesendableclass 0x6c, .TopLevelSendableClass107, _214, 0x0, v0 + stlexvar 0x0, 0x6a + ldhole + sta v0 + callruntime.definesendableclass 0x6d, .TopLevelSendableClass108, _216, 0x0, v0 + stlexvar 0x0, 0x6b + ldhole + sta v0 + callruntime.definesendableclass 0x6e, .TopLevelSendableClass109, _218, 0x0, v0 + stlexvar 0x0, 0x6c + ldhole + sta v0 + callruntime.definesendableclass 0x6f, .TopLevelSendableClass110, _220, 0x0, v0 + stlexvar 0x0, 0x6d + ldhole + sta v0 + callruntime.definesendableclass 0x70, .TopLevelSendableClass111, _222, 0x0, v0 + stlexvar 0x0, 0x6e + ldhole + sta v0 + callruntime.definesendableclass 0x71, .TopLevelSendableClass112, _224, 0x0, v0 + stlexvar 0x0, 0x6f + ldhole + sta v0 + callruntime.definesendableclass 0x72, .TopLevelSendableClass113, _226, 0x0, v0 + stlexvar 0x0, 0x70 + ldhole + sta v0 + callruntime.definesendableclass 0x73, .TopLevelSendableClass114, _228, 0x0, v0 + stlexvar 0x0, 0x71 + ldhole + sta v0 + callruntime.definesendableclass 0x74, .TopLevelSendableClass115, _230, 0x0, v0 + stlexvar 0x0, 0x72 + ldhole + sta v0 + callruntime.definesendableclass 0x75, .TopLevelSendableClass116, _232, 0x0, v0 + stlexvar 0x0, 0x73 + ldhole + sta v0 + callruntime.definesendableclass 0x76, .TopLevelSendableClass117, _234, 0x0, v0 + stlexvar 0x0, 0x74 + ldhole + sta v0 + callruntime.definesendableclass 0x77, .TopLevelSendableClass118, _236, 0x0, v0 + stlexvar 0x0, 0x75 + ldhole + sta v0 + callruntime.definesendableclass 0x78, .TopLevelSendableClass119, _238, 0x0, v0 + stlexvar 0x0, 0x76 + ldhole + sta v0 + callruntime.definesendableclass 0x79, .TopLevelSendableClass120, _240, 0x0, v0 + stlexvar 0x0, 0x77 + ldhole + sta v0 + callruntime.definesendableclass 0x7a, .TopLevelSendableClass121, _242, 0x0, v0 + stlexvar 0x0, 0x78 + ldhole + sta v0 + callruntime.definesendableclass 0x7b, .TopLevelSendableClass122, _244, 0x0, v0 + stlexvar 0x0, 0x79 + ldhole + sta v0 + callruntime.definesendableclass 0x7c, .TopLevelSendableClass123, _246, 0x0, v0 + stlexvar 0x0, 0x7a + ldhole + sta v0 + callruntime.definesendableclass 0x7d, .TopLevelSendableClass124, _248, 0x0, v0 + stlexvar 0x0, 0x7b + ldhole + sta v0 + callruntime.definesendableclass 0x7e, .TopLevelSendableClass125, _250, 0x0, v0 + stlexvar 0x0, 0x7c + ldhole + sta v0 + callruntime.definesendableclass 0x7f, .TopLevelSendableClass126, _252, 0x0, v0 + stlexvar 0x0, 0x7d + ldhole + sta v0 + callruntime.definesendableclass 0x80, .TopLevelSendableClass127, _254, 0x0, v0 + stlexvar 0x0, 0x7e + ldhole + sta v0 + callruntime.definesendableclass 0x81, .TopLevelSendableClass128, _256, 0x0, v0 + stlexvar 0x0, 0x7f + ldhole + sta v0 + callruntime.definesendableclass 0x82, .TopLevelSendableClass129, _258, 0x0, v0 + wide.stlexvar 0x0, 0x80 + ldhole + sta v0 + callruntime.definesendableclass 0x83, .TopLevelSendableClass130, _260, 0x0, v0 + wide.stlexvar 0x0, 0x81 + ldhole + sta v0 + callruntime.definesendableclass 0x84, .TopLevelSendableClass131, _262, 0x0, v0 + wide.stlexvar 0x0, 0x82 + ldhole + sta v0 + callruntime.definesendableclass 0x85, .TopLevelSendableClass132, _264, 0x0, v0 + wide.stlexvar 0x0, 0x83 + ldhole + sta v0 + callruntime.definesendableclass 0x86, .TopLevelSendableClass133, _266, 0x0, v0 + wide.stlexvar 0x0, 0x84 + ldhole + sta v0 + callruntime.definesendableclass 0x87, .TopLevelSendableClass134, _268, 0x0, v0 + wide.stlexvar 0x0, 0x85 + ldhole + sta v0 + callruntime.definesendableclass 0x88, .TopLevelSendableClass135, _270, 0x0, v0 + wide.stlexvar 0x0, 0x86 + ldhole + sta v0 + callruntime.definesendableclass 0x89, .TopLevelSendableClass136, _272, 0x0, v0 + wide.stlexvar 0x0, 0x87 + ldhole + sta v0 + callruntime.definesendableclass 0x8a, .TopLevelSendableClass137, _274, 0x0, v0 + wide.stlexvar 0x0, 0x88 + ldhole + sta v0 + callruntime.definesendableclass 0x8b, .TopLevelSendableClass138, _276, 0x0, v0 + wide.stlexvar 0x0, 0x89 + ldhole + sta v0 + callruntime.definesendableclass 0x8c, .TopLevelSendableClass139, _278, 0x0, v0 + wide.stlexvar 0x0, 0x8a + ldhole + sta v0 + callruntime.definesendableclass 0x8d, .TopLevelSendableClass140, _280, 0x0, v0 + wide.stlexvar 0x0, 0x8b + ldhole + sta v0 + callruntime.definesendableclass 0x8e, .TopLevelSendableClass141, _282, 0x0, v0 + wide.stlexvar 0x0, 0x8c + ldhole + sta v0 + callruntime.definesendableclass 0x8f, .TopLevelSendableClass142, _284, 0x0, v0 + wide.stlexvar 0x0, 0x8d + ldhole + sta v0 + callruntime.definesendableclass 0x90, .TopLevelSendableClass143, _286, 0x0, v0 + wide.stlexvar 0x0, 0x8e + ldhole + sta v0 + callruntime.definesendableclass 0x91, .TopLevelSendableClass144, _288, 0x0, v0 + wide.stlexvar 0x0, 0x8f + ldhole + sta v0 + callruntime.definesendableclass 0x92, .TopLevelSendableClass145, _290, 0x0, v0 + wide.stlexvar 0x0, 0x90 + ldhole + sta v0 + callruntime.definesendableclass 0x93, .TopLevelSendableClass146, _292, 0x0, v0 + wide.stlexvar 0x0, 0x91 + ldhole + sta v0 + callruntime.definesendableclass 0x94, .TopLevelSendableClass147, _294, 0x0, v0 + wide.stlexvar 0x0, 0x92 + ldhole + sta v0 + callruntime.definesendableclass 0x95, .TopLevelSendableClass148, _296, 0x0, v0 + wide.stlexvar 0x0, 0x93 + ldhole + sta v0 + callruntime.definesendableclass 0x96, .TopLevelSendableClass149, _298, 0x0, v0 + wide.stlexvar 0x0, 0x94 + ldhole + sta v0 + callruntime.definesendableclass 0x97, .TopLevelSendableClass150, _300, 0x0, v0 + wide.stlexvar 0x0, 0x95 + ldhole + sta v0 + callruntime.definesendableclass 0x98, .TopLevelSendableClass151, _302, 0x0, v0 + wide.stlexvar 0x0, 0x96 + ldhole + sta v0 + callruntime.definesendableclass 0x99, .TopLevelSendableClass152, _304, 0x0, v0 + wide.stlexvar 0x0, 0x97 + ldhole + sta v0 + callruntime.definesendableclass 0x9a, .TopLevelSendableClass153, _306, 0x0, v0 + wide.stlexvar 0x0, 0x98 + ldhole + sta v0 + callruntime.definesendableclass 0x9b, .TopLevelSendableClass154, _308, 0x0, v0 + wide.stlexvar 0x0, 0x99 + ldhole + sta v0 + callruntime.definesendableclass 0x9c, .TopLevelSendableClass155, _310, 0x0, v0 + wide.stlexvar 0x0, 0x9a + ldhole + sta v0 + callruntime.definesendableclass 0x9d, .TopLevelSendableClass156, _312, 0x0, v0 + wide.stlexvar 0x0, 0x9b + ldhole + sta v0 + callruntime.definesendableclass 0x9e, .TopLevelSendableClass157, _314, 0x0, v0 + wide.stlexvar 0x0, 0x9c + ldhole + sta v0 + callruntime.definesendableclass 0x9f, .TopLevelSendableClass158, _316, 0x0, v0 + wide.stlexvar 0x0, 0x9d + ldhole + sta v0 + callruntime.definesendableclass 0xa0, .TopLevelSendableClass159, _318, 0x0, v0 + wide.stlexvar 0x0, 0x9e + ldhole + sta v0 + callruntime.definesendableclass 0xa1, .TopLevelSendableClass160, _320, 0x0, v0 + wide.stlexvar 0x0, 0x9f + ldhole + sta v0 + callruntime.definesendableclass 0xa2, .TopLevelSendableClass161, _322, 0x0, v0 + wide.stlexvar 0x0, 0xa0 + ldhole + sta v0 + callruntime.definesendableclass 0xa3, .TopLevelSendableClass162, _324, 0x0, v0 + wide.stlexvar 0x0, 0xa1 + ldhole + sta v0 + callruntime.definesendableclass 0xa4, .TopLevelSendableClass163, _326, 0x0, v0 + wide.stlexvar 0x0, 0xa2 + ldhole + sta v0 + callruntime.definesendableclass 0xa5, .TopLevelSendableClass164, _328, 0x0, v0 + wide.stlexvar 0x0, 0xa3 + ldhole + sta v0 + callruntime.definesendableclass 0xa6, .TopLevelSendableClass165, _330, 0x0, v0 + wide.stlexvar 0x0, 0xa4 + ldhole + sta v0 + callruntime.definesendableclass 0xa7, .TopLevelSendableClass166, _332, 0x0, v0 + wide.stlexvar 0x0, 0xa5 + ldhole + sta v0 + callruntime.definesendableclass 0xa8, .TopLevelSendableClass167, _334, 0x0, v0 + wide.stlexvar 0x0, 0xa6 + ldhole + sta v0 + callruntime.definesendableclass 0xa9, .TopLevelSendableClass168, _336, 0x0, v0 + wide.stlexvar 0x0, 0xa7 + ldhole + sta v0 + callruntime.definesendableclass 0xaa, .TopLevelSendableClass169, _338, 0x0, v0 + wide.stlexvar 0x0, 0xa8 + ldhole + sta v0 + callruntime.definesendableclass 0xab, .TopLevelSendableClass170, _340, 0x0, v0 + wide.stlexvar 0x0, 0xa9 + ldhole + sta v0 + callruntime.definesendableclass 0xac, .TopLevelSendableClass171, _342, 0x0, v0 + wide.stlexvar 0x0, 0xaa + ldhole + sta v0 + callruntime.definesendableclass 0xad, .TopLevelSendableClass172, _344, 0x0, v0 + wide.stlexvar 0x0, 0xab + ldhole + sta v0 + callruntime.definesendableclass 0xae, .TopLevelSendableClass173, _346, 0x0, v0 + wide.stlexvar 0x0, 0xac + ldhole + sta v0 + callruntime.definesendableclass 0xaf, .TopLevelSendableClass174, _348, 0x0, v0 + wide.stlexvar 0x0, 0xad + ldhole + sta v0 + callruntime.definesendableclass 0xb0, .TopLevelSendableClass175, _350, 0x0, v0 + wide.stlexvar 0x0, 0xae + ldhole + sta v0 + callruntime.definesendableclass 0xb1, .TopLevelSendableClass176, _352, 0x0, v0 + wide.stlexvar 0x0, 0xaf + ldhole + sta v0 + callruntime.definesendableclass 0xb2, .TopLevelSendableClass177, _354, 0x0, v0 + wide.stlexvar 0x0, 0xb0 + ldhole + sta v0 + callruntime.definesendableclass 0xb3, .TopLevelSendableClass178, _356, 0x0, v0 + wide.stlexvar 0x0, 0xb1 + ldhole + sta v0 + callruntime.definesendableclass 0xb4, .TopLevelSendableClass179, _358, 0x0, v0 + wide.stlexvar 0x0, 0xb2 + ldhole + sta v0 + callruntime.definesendableclass 0xb5, .TopLevelSendableClass180, _360, 0x0, v0 + wide.stlexvar 0x0, 0xb3 + ldhole + sta v0 + callruntime.definesendableclass 0xb6, .TopLevelSendableClass181, _362, 0x0, v0 + wide.stlexvar 0x0, 0xb4 + ldhole + sta v0 + callruntime.definesendableclass 0xb7, .TopLevelSendableClass182, _364, 0x0, v0 + wide.stlexvar 0x0, 0xb5 + ldhole + sta v0 + callruntime.definesendableclass 0xb8, .TopLevelSendableClass183, _366, 0x0, v0 + wide.stlexvar 0x0, 0xb6 + ldhole + sta v0 + callruntime.definesendableclass 0xb9, .TopLevelSendableClass184, _368, 0x0, v0 + wide.stlexvar 0x0, 0xb7 + ldhole + sta v0 + callruntime.definesendableclass 0xba, .TopLevelSendableClass185, _370, 0x0, v0 + wide.stlexvar 0x0, 0xb8 + ldhole + sta v0 + callruntime.definesendableclass 0xbb, .TopLevelSendableClass186, _372, 0x0, v0 + wide.stlexvar 0x0, 0xb9 + ldhole + sta v0 + callruntime.definesendableclass 0xbc, .TopLevelSendableClass187, _374, 0x0, v0 + wide.stlexvar 0x0, 0xba + ldhole + sta v0 + callruntime.definesendableclass 0xbd, .TopLevelSendableClass188, _376, 0x0, v0 + wide.stlexvar 0x0, 0xbb + ldhole + sta v0 + callruntime.definesendableclass 0xbe, .TopLevelSendableClass189, _378, 0x0, v0 + wide.stlexvar 0x0, 0xbc + ldhole + sta v0 + callruntime.definesendableclass 0xbf, .TopLevelSendableClass190, _380, 0x0, v0 + wide.stlexvar 0x0, 0xbd + ldhole + sta v0 + callruntime.definesendableclass 0xc0, .TopLevelSendableClass191, _382, 0x0, v0 + wide.stlexvar 0x0, 0xbe + ldhole + sta v0 + callruntime.definesendableclass 0xc1, .TopLevelSendableClass192, _384, 0x0, v0 + wide.stlexvar 0x0, 0xbf + ldhole + sta v0 + callruntime.definesendableclass 0xc2, .TopLevelSendableClass193, _386, 0x0, v0 + wide.stlexvar 0x0, 0xc0 + ldhole + sta v0 + callruntime.definesendableclass 0xc3, .TopLevelSendableClass194, _388, 0x0, v0 + wide.stlexvar 0x0, 0xc1 + ldhole + sta v0 + callruntime.definesendableclass 0xc4, .TopLevelSendableClass195, _390, 0x0, v0 + wide.stlexvar 0x0, 0xc2 + ldhole + sta v0 + callruntime.definesendableclass 0xc5, .TopLevelSendableClass196, _392, 0x0, v0 + wide.stlexvar 0x0, 0xc3 + ldhole + sta v0 + callruntime.definesendableclass 0xc6, .TopLevelSendableClass197, _394, 0x0, v0 + wide.stlexvar 0x0, 0xc4 + ldhole + sta v0 + callruntime.definesendableclass 0xc7, .TopLevelSendableClass198, _396, 0x0, v0 + wide.stlexvar 0x0, 0xc5 + ldhole + sta v0 + callruntime.definesendableclass 0xc8, .TopLevelSendableClass199, _398, 0x0, v0 + wide.stlexvar 0x0, 0xc6 + ldhole + sta v0 + callruntime.definesendableclass 0xc9, .TopLevelSendableClass200, _400, 0x0, v0 + wide.stlexvar 0x0, 0xc7 + ldhole + sta v0 + callruntime.definesendableclass 0xca, .TopLevelSendableClass201, _402, 0x0, v0 + wide.stlexvar 0x0, 0xc8 + ldhole + sta v0 + callruntime.definesendableclass 0xcb, .TopLevelSendableClass202, _404, 0x0, v0 + wide.stlexvar 0x0, 0xc9 + ldhole + sta v0 + callruntime.definesendableclass 0xcc, .TopLevelSendableClass203, _406, 0x0, v0 + wide.stlexvar 0x0, 0xca + ldhole + sta v0 + callruntime.definesendableclass 0xcd, .TopLevelSendableClass204, _408, 0x0, v0 + wide.stlexvar 0x0, 0xcb + ldhole + sta v0 + callruntime.definesendableclass 0xce, .TopLevelSendableClass205, _410, 0x0, v0 + wide.stlexvar 0x0, 0xcc + ldhole + sta v0 + callruntime.definesendableclass 0xcf, .TopLevelSendableClass206, _412, 0x0, v0 + wide.stlexvar 0x0, 0xcd + ldhole + sta v0 + callruntime.definesendableclass 0xd0, .TopLevelSendableClass207, _414, 0x0, v0 + wide.stlexvar 0x0, 0xce + ldhole + sta v0 + callruntime.definesendableclass 0xd1, .TopLevelSendableClass208, _416, 0x0, v0 + wide.stlexvar 0x0, 0xcf + ldhole + sta v0 + callruntime.definesendableclass 0xd2, .TopLevelSendableClass209, _418, 0x0, v0 + wide.stlexvar 0x0, 0xd0 + ldhole + sta v0 + callruntime.definesendableclass 0xd3, .TopLevelSendableClass210, _420, 0x0, v0 + wide.stlexvar 0x0, 0xd1 + ldhole + sta v0 + callruntime.definesendableclass 0xd4, .TopLevelSendableClass211, _422, 0x0, v0 + wide.stlexvar 0x0, 0xd2 + ldhole + sta v0 + callruntime.definesendableclass 0xd5, .TopLevelSendableClass212, _424, 0x0, v0 + wide.stlexvar 0x0, 0xd3 + ldhole + sta v0 + callruntime.definesendableclass 0xd6, .TopLevelSendableClass213, _426, 0x0, v0 + wide.stlexvar 0x0, 0xd4 + ldhole + sta v0 + callruntime.definesendableclass 0xd7, .TopLevelSendableClass214, _428, 0x0, v0 + wide.stlexvar 0x0, 0xd5 + ldhole + sta v0 + callruntime.definesendableclass 0xd8, .TopLevelSendableClass215, _430, 0x0, v0 + wide.stlexvar 0x0, 0xd6 + ldhole + sta v0 + callruntime.definesendableclass 0xd9, .TopLevelSendableClass216, _432, 0x0, v0 + wide.stlexvar 0x0, 0xd7 + ldhole + sta v0 + callruntime.definesendableclass 0xda, .TopLevelSendableClass217, _434, 0x0, v0 + wide.stlexvar 0x0, 0xd8 + ldhole + sta v0 + callruntime.definesendableclass 0xdb, .TopLevelSendableClass218, _436, 0x0, v0 + wide.stlexvar 0x0, 0xd9 + ldhole + sta v0 + callruntime.definesendableclass 0xdc, .TopLevelSendableClass219, _438, 0x0, v0 + wide.stlexvar 0x0, 0xda + ldhole + sta v0 + callruntime.definesendableclass 0xdd, .TopLevelSendableClass220, _440, 0x0, v0 + wide.stlexvar 0x0, 0xdb + ldhole + sta v0 + callruntime.definesendableclass 0xde, .TopLevelSendableClass221, _442, 0x0, v0 + wide.stlexvar 0x0, 0xdc + ldhole + sta v0 + callruntime.definesendableclass 0xdf, .TopLevelSendableClass222, _444, 0x0, v0 + wide.stlexvar 0x0, 0xdd + ldhole + sta v0 + callruntime.definesendableclass 0xe0, .TopLevelSendableClass223, _446, 0x0, v0 + wide.stlexvar 0x0, 0xde + ldhole + sta v0 + callruntime.definesendableclass 0xe1, .TopLevelSendableClass224, _448, 0x0, v0 + wide.stlexvar 0x0, 0xdf + ldhole + sta v0 + callruntime.definesendableclass 0xe2, .TopLevelSendableClass225, _450, 0x0, v0 + wide.stlexvar 0x0, 0xe0 + ldhole + sta v0 + callruntime.definesendableclass 0xe3, .TopLevelSendableClass226, _452, 0x0, v0 + wide.stlexvar 0x0, 0xe1 + ldhole + sta v0 + callruntime.definesendableclass 0xe4, .TopLevelSendableClass227, _454, 0x0, v0 + wide.stlexvar 0x0, 0xe2 + ldhole + sta v0 + callruntime.definesendableclass 0xe5, .TopLevelSendableClass228, _456, 0x0, v0 + wide.stlexvar 0x0, 0xe3 + ldhole + sta v0 + callruntime.definesendableclass 0xe6, .TopLevelSendableClass229, _458, 0x0, v0 + wide.stlexvar 0x0, 0xe4 + ldhole + sta v0 + callruntime.definesendableclass 0xe7, .TopLevelSendableClass230, _460, 0x0, v0 + wide.stlexvar 0x0, 0xe5 + ldhole + sta v0 + callruntime.definesendableclass 0xe8, .TopLevelSendableClass231, _462, 0x0, v0 + wide.stlexvar 0x0, 0xe6 + ldhole + sta v0 + callruntime.definesendableclass 0xe9, .TopLevelSendableClass232, _464, 0x0, v0 + wide.stlexvar 0x0, 0xe7 + ldhole + sta v0 + callruntime.definesendableclass 0xea, .TopLevelSendableClass233, _466, 0x0, v0 + wide.stlexvar 0x0, 0xe8 + ldhole + sta v0 + callruntime.definesendableclass 0xeb, .TopLevelSendableClass234, _468, 0x0, v0 + wide.stlexvar 0x0, 0xe9 + ldhole + sta v0 + callruntime.definesendableclass 0xec, .TopLevelSendableClass235, _470, 0x0, v0 + wide.stlexvar 0x0, 0xea + ldhole + sta v0 + callruntime.definesendableclass 0xed, .TopLevelSendableClass236, _472, 0x0, v0 + wide.stlexvar 0x0, 0xeb + ldhole + sta v0 + callruntime.definesendableclass 0xee, .TopLevelSendableClass237, _474, 0x0, v0 + wide.stlexvar 0x0, 0xec + ldhole + sta v0 + callruntime.definesendableclass 0xef, .TopLevelSendableClass238, _476, 0x0, v0 + wide.stlexvar 0x0, 0xed + ldhole + sta v0 + callruntime.definesendableclass 0xf0, .TopLevelSendableClass239, _478, 0x0, v0 + wide.stlexvar 0x0, 0xee + ldhole + sta v0 + callruntime.definesendableclass 0xf1, .TopLevelSendableClass240, _480, 0x0, v0 + wide.stlexvar 0x0, 0xef + ldhole + sta v0 + callruntime.definesendableclass 0xf2, .TopLevelSendableClass241, _482, 0x0, v0 + wide.stlexvar 0x0, 0xf0 + ldhole + sta v0 + callruntime.definesendableclass 0xf3, .TopLevelSendableClass242, _484, 0x0, v0 + wide.stlexvar 0x0, 0xf1 + ldhole + sta v0 + callruntime.definesendableclass 0xf4, .TopLevelSendableClass243, _486, 0x0, v0 + wide.stlexvar 0x0, 0xf2 + ldhole + sta v0 + callruntime.definesendableclass 0xf5, .TopLevelSendableClass244, _488, 0x0, v0 + wide.stlexvar 0x0, 0xf3 + ldhole + sta v0 + callruntime.definesendableclass 0xf6, .TopLevelSendableClass245, _490, 0x0, v0 + wide.stlexvar 0x0, 0xf4 + ldhole + sta v0 + callruntime.definesendableclass 0xf7, .TopLevelSendableClass246, _492, 0x0, v0 + wide.stlexvar 0x0, 0xf5 + ldhole + sta v0 + callruntime.definesendableclass 0xf8, .TopLevelSendableClass247, _494, 0x0, v0 + wide.stlexvar 0x0, 0xf6 + ldhole + sta v0 + callruntime.definesendableclass 0xf9, .TopLevelSendableClass248, _496, 0x0, v0 + wide.stlexvar 0x0, 0xf7 + ldhole + sta v0 + callruntime.definesendableclass 0xfa, .TopLevelSendableClass249, _498, 0x0, v0 + wide.stlexvar 0x0, 0xf8 + ldhole + sta v0 + callruntime.definesendableclass 0xfb, .TopLevelSendableClass250, _500, 0x0, v0 + wide.stlexvar 0x0, 0xf9 + ldhole + sta v0 + callruntime.definesendableclass 0xfc, .TopLevelSendableClass251, _502, 0x0, v0 + wide.stlexvar 0x0, 0xfa + ldhole + sta v0 + callruntime.definesendableclass 0xfd, .TopLevelSendableClass252, _504, 0x0, v0 + wide.stlexvar 0x0, 0xfb + ldhole + sta v0 + callruntime.definesendableclass 0xfe, .TopLevelSendableClass253, _506, 0x0, v0 + wide.stlexvar 0x0, 0xfc + ldhole + sta v0 + callruntime.definesendableclass 0x100, .TopLevelSendableClass254, _508, 0x0, v0 + wide.stlexvar 0x0, 0xfd + ldhole + sta v0 + callruntime.definesendableclass 0x101, .TopLevelSendableClass255, _510, 0x0, v0 + wide.stlexvar 0x0, 0xfe + ldhole + sta v0 + callruntime.definesendableclass 0x102, .SendableTestClass1, _512, 0x0, v0 + sta v0 + mov v2, v0 + newobjrange 0x103, 0x1, v2 + sta v0 + tryldglobalbyname 0x105, print + sta v1 + lda v0 + ldobjbyname 0x106, v + sta v0 + lda v1 + callarg1 0x0, v0 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_below_API12beta3_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_below_API12beta3_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..8e9b9b9398e71ab25449388cb75f674b5ef96e19 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt @@ -0,0 +1 @@ +TypeError: Constructor is false \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_below_API11_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_for_below_API11_version-expected.txt rename to es2panda/test/version_control/API12beta1_and_beta2/bytecode_feature/wide_sendable_lexical_env_unsupported_runtime_version-expected.txt diff --git a/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..8e9b9b9398e71ab25449388cb75f674b5ef96e19 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt @@ -0,0 +1 @@ +TypeError: Constructor is false \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..8e9b9b9398e71ab25449388cb75f674b5ef96e19 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_for_higher_or_equal_to_API12beta3_version-expected.txt @@ -0,0 +1 @@ +TypeError: Constructor is false \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_version-expected.txt b/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..8e9b9b9398e71ab25449388cb75f674b5ef96e19 --- /dev/null +++ b/es2panda/test/version_control/API12beta1_and_beta2/syntax_feature/top_level_sendable_class_as_closure_unsupported_runtime_version-expected.txt @@ -0,0 +1 @@ +TypeError: Constructor is false \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..85b14f1a81252a13aef8763a543c9a5fea4bd020 --- /dev/null +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,50 @@ +slotNum = 0x4 +.language ECMAScript +.function any .#~@0=#PropertyByName(any a0, any a1, any a2, any a3, any a4) { +label_1: +label_0: + lda a3 + stobjbyname 0x0, name, a2 + lda a4 + stobjbyname 0x2, age, a2 + lda a2 + return +label_2: +} + +slotNum = 0xa +.language ECMAScript +.function any .#~@0>#init(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, Object + sta v0 + ldobjbyname 0x1, defineProperty + sta v1 + lda.str name + sta v2 + createobjectwithbuffer 0x3, _2 + sta v3 + lda a2 + ldobjbyname 0x4, name + definepropertybyname 0x6, value, v3 + lda v1 + callthis3 0x8, v0, a2, v2, v3 + returnundefined +label_2: +} + +slotNum = 0x3 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + defineclasswithbuffer 0x0, .#~@0=#PropertyByName, _3, 0x2, v0 + ldobjbyname 0x1, prototype + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_below_API11_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_below_API11_asm_version-expected.txt rename to es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_asm_version-expected.txt diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..601217c7f803b481980dfa92b43bbc592ea37673 --- /dev/null +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/define_property_by_name_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -0,0 +1,50 @@ +slotNum = 0x4 +.language ECMAScript +.function any .PropertyByName(any a0, any a1, any a2, any a3, any a4) { +label_1: +label_0: + lda a3 + stobjbyname 0x0, name, a2 + lda a4 + stobjbyname 0x2, age, a2 + lda a2 + return +label_2: +} + +slotNum = 0x3 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + defineclasswithbuffer 0x0, .PropertyByName, _2, 0x2, v0 + ldobjbyname 0x1, prototype + returnundefined +label_2: +} + +slotNum = 0xa +.language ECMAScript +.function any .init(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, Object + sta v0 + ldobjbyname 0x1, defineProperty + sta v1 + lda.str name + sta v2 + createobjectwithbuffer 0x3, _1 + sta v3 + lda a2 + ldobjbyname 0x4, name + definefieldbyname 0x6, value, v3 + lda v1 + callthis3 0x8, v0, a2, v2, v3 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/import_target/import_target.ts b/es2panda/test/version_control/API12beta3/bytecode_feature/import_target/import_target.ts index 28f0f7ccd60b1c00cf6384d36d67b262bcadf414..7621af1e5d9b3862daa9db2cfd7f44f7e1fd3162 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/import_target/import_target.ts +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/import_target/import_target.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +const defaultImportValue = 'a0'; +export default defaultImportValue; export const a1 = 'a1'; export const a2 = 'a2'; export const a3 = 'a3'; diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/istrue_isfalse_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/istrue_isfalse_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..674e91d58380a2a0a9c4e4ddc2a293b056139088 --- /dev/null +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/istrue_isfalse_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,42 @@ +slotNum = 0x9 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_8: +label_0: + ldtrue + sta v0 + callruntime.isfalse 0x0 + jnez label_1 +label_2: + tryldglobalbyname 0x1, print + sta v0 + lda.str true + sta v1 + lda v0 + callarg1 0x2, v1 + jmp label_3 +label_1: + lda v0 + callruntime.istrue 0x4 + jnez label_4 +label_5: + ldtrue + jmp label_6 +label_4: + ldfalse +label_6: + callruntime.isfalse 0x5 + jnez label_3 +label_7: + tryldglobalbyname 0x6, print + sta v0 + lda.str false + sta v1 + lda v0 + callarg1 0x7, v1 +label_3: + returnundefined +label_9: +} + + diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode.ts b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode.ts index c6d38d659cc2f08b4ecbf4c2f85fd5aba971105b..af97b159ccf940eba25d768165c7c433c3030665 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode.ts +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import lazy { a1, a2 } from 'import_target/import_target' +import lazy defaultImportValue, { a1, a2 } from 'import_target/import_target'; class SendableLazyLoading { name: string = a1; @@ -23,4 +23,5 @@ class SendableLazyLoading { } let a: SendableLazyLoading = new SendableLazyLoading(); let b: string = a2; -print(a.name); \ No newline at end of file +print(a.name); +print(defaultImportValue); \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index c16a17b509eec682c34ca20b640b22acbe916705..fffe779103603c565c59ed4291b3e8f845472983 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@0=#SendableLazyLoading(any a0, any a1, any a2) { label_1: @@ -14,7 +13,7 @@ label_0: label_2: } -slotNum = 0x8 +slotNum = 0xb .language ECMAScript .function any .func_main_0(any a0, any a1, any a2) { label_1: @@ -35,6 +34,13 @@ label_0: sta v0 lda v1 callarg1 0x6, v0 + tryldglobalbyname 0x8, print + sta v0 + callruntime.ldlazymodulevar 0x2 + sta v1 + throw.undefinedifholewithname defaultImportValue + lda v0 + callarg1 0x9, v1 returnundefined label_2: } diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt index c92d705a82f60af9eb8e273ccbe4ff80b91f30a2..4eb3781c08365867a1d3f2c902f364bb6d80f7a6 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt @@ -1,7 +1,6 @@ .language ECMAScript slotNum = 0x2 -expectedProperty = 0x1 .function any .#~@0=#SendableLazyLoading(any a0, any a1, any a2) { label_1: label_0: diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..3e0604bf53bd57fc0fb37f1192e47543d62d32e6 --- /dev/null +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,49 @@ +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@0=#SendableLazyLoading(any a0, any a1, any a2) { +label_1: +label_0: + callruntime.ldlazysendablemodulevar 0x0 + sta v0 + throw.undefinedifholewithname a1 + lda v0 + stobjbyname 0x0, name, a2 + lda a2 + return +label_2: +} + +slotNum = 0xb +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + callruntime.definesendableclass 0x0, .#~@0=#SendableLazyLoading, _4, 0x0, v0 + sta v0 + mov v2, v0 + newobjrange 0x1, 0x1, v2 + sta v0 + callruntime.ldlazymodulevar 0x1 + throw.undefinedifholewithname a2 + tryldglobalbyname 0x3, print + sta v1 + lda v0 + ldobjbyname 0x4, name + sta v0 + lda v1 + callarg1 0x6, v0 + tryldglobalbyname 0x8, print + sta v0 + callruntime.ldlazymodulevar 0x2 + sta v1 + throw.undefinedifholewithname defaultImportValue + lda v0 + callarg1 0x9, v1 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_runtime_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_runtime_version-expected.txt index da0f8ed91a8f2f0f067b3bdf26265d5ca48cf82c..6e9673b4dea09d930a094450f02c1da3fd633950 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_runtime_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_supported_runtime_version-expected.txt @@ -1 +1,2 @@ a1 +a0 diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_unsupported_compile_asm_version-expected.txt index ae2da4fe1eac68cf9cbea7fc61ae98dea21247b5..7511f0e00ccb5dcc6989df72d90e24f0f5c69ad0 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/lazy_import_bytecode_unsupported_compile_asm_version-expected.txt @@ -1 +1,3 @@ -SyntaxError: Current configuration does not support using lazy import. Lazy import can be used in the beta3 version of API 12 or higher versions. \ No newline at end of file +SyntaxError: Current configuration does not support using lazy import. Lazy import can be used in the beta3 version of API 12 or higher versions. +Solutions: > Check the compatibleSdkVersion and compatibleSdkVersionStage in build-profile.json5.> If compatibleSdkVersion is set to API 12, then compatibleSdkVersionStage needs to be configured as beta3.> If you're running es2abc in commandline without IDE, please check whether target-api-version and target-api-sub-version options are correctly configured. [lazy_import_bytecode.ts:16:13] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt index 3222f27c481265e6493a5d9c8a663a84d4cf2e67..851a53ce7363f5ce7229777de047982dffe9ffa1 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt @@ -1,5 +1,4 @@ slotNum = 0x2 -expectedProperty = 0x1 .language ECMAScript .function any .#~@0=#WideSendableLazyLoading(any a0, any a1, any a2) { label_1: diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt index 3b520c914cdad34fd6e22aa8273715778451727a..568f9fd81ef5d8aecb3c1e95d412ecb4c4a301e3 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API16beta3_asm_version-expected.txt @@ -1,7 +1,6 @@ .language ECMAScript slotNum = 0x2 -expectedProperty = 0x1 .function any .#~@0=#WideSendableLazyLoading(any a0, any a1, any a2) { label_1: label_0: diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..3222f27c481265e6493a5d9c8a663a84d4cf2e67 --- /dev/null +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_supported_compile_for_higher_or_equal_to_API18_asm_version-expected.txt @@ -0,0 +1,40 @@ +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~@0=#WideSendableLazyLoading(any a0, any a1, any a2) { +label_1: +label_0: + callruntime.wideldlazysendablemodulevar 0xad + sta v0 + throw.undefinedifholewithname a255 + lda v0 + stobjbyname 0x0, name1, a2 + lda a2 + return +label_2: +} + +slotNum = 0x9 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + callruntime.definesendableclass 0x0, .#~@0=#WideSendableLazyLoading, _4, 0x0, v0 + sta v0 + mov v2, v0 + newobjrange 0x1, 0x1, v2 + sta v0 + callruntime.wideldlazymodulevar 0xae + sta v1 + throw.undefinedifholewithname a256 + tryldglobalbyname 0x3, print + callarg1 0x4, v0 + tryldglobalbyname 0x6, print + callarg1 0x7, v1 + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_unsupported_compile_asm_version-expected.txt index ae2da4fe1eac68cf9cbea7fc61ae98dea21247b5..ab88cd29d06de314c32b532b9e460ea3ccadb4a7 100644 --- a/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_unsupported_compile_asm_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/bytecode_feature/wide_lazy_import_bytecode_unsupported_compile_asm_version-expected.txt @@ -1 +1,3 @@ -SyntaxError: Current configuration does not support using lazy import. Lazy import can be used in the beta3 version of API 12 or higher versions. \ No newline at end of file +SyntaxError: Current configuration does not support using lazy import. Lazy import can be used in the beta3 version of API 12 or higher versions. +Solutions: > Check the compatibleSdkVersion and compatibleSdkVersionStage in build-profile.json5.> If compatibleSdkVersion is set to API 12, then compatibleSdkVersionStage needs to be configured as beta3.> If you're running es2abc in commandline without IDE, please check whether target-api-version and target-api-sub-version options are correctly configured. [wide_lazy_import_bytecode.ts:16:13] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API12beta3/syntax_feature/import_target/import_target.ts b/es2panda/test/version_control/API12beta3/syntax_feature/import_target/import_target.ts index 4e0ec5ce3ab1c2dbfbc76e0dcf6f3974f995bf1c..6b52c1d49d3212a5ab1716ca26a88c2a636ae681 100644 --- a/es2panda/test/version_control/API12beta3/syntax_feature/import_target/import_target.ts +++ b/es2panda/test/version_control/API12beta3/syntax_feature/import_target/import_target.ts @@ -17,4 +17,9 @@ export function lazyImportFunc(resolve) { print("lazy ImportFunc called"); resolve(1); +} + +export default function defaultImportFunc(resolve) { + print("lazy ImportFunc called"); + resolve(1); } \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import.ts b/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import.ts index 985261dcad35bd3a0ee8f8f2eec6acc94905daa8..d3081c17aadfef6b27544ed7204bd47e478c0229 100644 --- a/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import.ts +++ b/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import.ts @@ -13,5 +13,5 @@ * limitations under the License. */ -import lazy { lazyImportFunc } from 'import_target/import_target' +import lazy defaultImportFunc, { lazyImportFunc } from 'import_target/import_target' print("lazy import"); \ No newline at end of file diff --git a/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_supported_compile_version-expected.txt b/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_supported_compile_version-expected.txt index bacfd1f3f009771155f2b5d30da1fb280e2bcc99..cdf751cc03236b839a427060c322ff6d998b627f 100644 --- a/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_supported_compile_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_supported_compile_version-expected.txt @@ -9,15 +9,42 @@ "loc": { "start": { "line": 16, - "column": 37 + "column": 56 }, "end": { "line": 16, - "column": 66 + "column": 85 } } }, "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "local": { + "type": "Identifier", + "name": "defaultImportFunc", + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 16, + "column": 30 + } + } + }, { "type": "ImportSpecifier", "local": { @@ -26,11 +53,11 @@ "loc": { "start": { "line": 16, - "column": 15 + "column": 34 }, "end": { "line": 16, - "column": 29 + "column": 48 } } }, @@ -40,11 +67,11 @@ "loc": { "start": { "line": 16, - "column": 15 + "column": 34 }, "end": { "line": 16, - "column": 29 + "column": 48 } } }, @@ -52,11 +79,11 @@ "loc": { "start": { "line": 16, - "column": 15 + "column": 34 }, "end": { "line": 16, - "column": 29 + "column": 48 } } } @@ -69,7 +96,7 @@ }, "end": { "line": 16, - "column": 66 + "column": 85 } } }, diff --git a/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_unsupported_compile_version-expected.txt b/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_unsupported_compile_version-expected.txt index ae2da4fe1eac68cf9cbea7fc61ae98dea21247b5..6792ee776f64a7c5434c432c6e78250ea6cdb999 100644 --- a/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_unsupported_compile_version-expected.txt +++ b/es2panda/test/version_control/API12beta3/syntax_feature/lazy_import_unsupported_compile_version-expected.txt @@ -1 +1,3 @@ -SyntaxError: Current configuration does not support using lazy import. Lazy import can be used in the beta3 version of API 12 or higher versions. \ No newline at end of file +SyntaxError: Current configuration does not support using lazy import. Lazy import can be used in the beta3 version of API 12 or higher versions. +Solutions: > Check the compatibleSdkVersion and compatibleSdkVersionStage in build-profile.json5.> If compatibleSdkVersion is set to API 12, then compatibleSdkVersionStage needs to be configured as beta3.> If you're running es2abc in commandline without IDE, please check whether target-api-version and target-api-sub-version options are correctly configured. [lazy_import.ts:16:13] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/test/version_control/API12beta3/syntax_feature/sendable_function_unsupported_runtime_for_below_API12beta3_version-expected.txt b/es2panda/test/version_control/API12beta3/syntax_feature/sendable_function_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API12beta3/syntax_feature/sendable_function_unsupported_runtime_for_below_API12beta3_version-expected.txt rename to es2panda/test/version_control/API12beta3/syntax_feature/sendable_function_unsupported_runtime_for_higher_or_equal_to_API11_version-expected.txt diff --git a/es2panda/test/version_control/API12beta3/syntax_feature/sendable_function_unsupported_runtime_version-expected.txt b/es2panda/test/version_control/API12beta3/syntax_feature/sendable_function_unsupported_runtime_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..71d2c9ab90d726207311beb677d5ff4e2f418031 --- /dev/null +++ b/es2panda/test/version_control/API12beta3/syntax_feature/sendable_function_unsupported_runtime_version-expected.txt @@ -0,0 +1 @@ +TypeError: is not callable \ No newline at end of file diff --git a/es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt.js b/es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt.js similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt.js rename to es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt.js diff --git a/es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_runtime_below_abc_api_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_runtime_below_abc_api_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_runtime_below_abc_api_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_runtime_below_abc_api_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_supported_compile_asm_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_supported_compile_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_supported_compile_asm_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_supported_compile_asm_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_supported_runtime_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_supported_runtime_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_supported_runtime_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_supported_runtime_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_for_below_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_for_below_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_asm_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_runtime_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_unsupported_runtime_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_runtime_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/derived-class-default-constructor-opt_unsupported_runtime_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export.ts b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export.ts similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export.ts rename to es2panda/test/version_control/API18/bytecode_feature/sendable-class-export.ts diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_runtime_below_abc_api_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_runtime_below_abc_api_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_runtime_below_abc_api_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_runtime_below_abc_api_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_supported_compile_asm_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_supported_compile_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_supported_compile_asm_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_supported_compile_asm_version-expected.txt diff --git a/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_supported_runtime_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_supported_runtime_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_compile_for_below_API11_asm_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_compile_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_compile_for_below_API11_asm_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_compile_asm_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_compile_asm_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_compile_for_higher_or_equal_to_API11_asm_version-expected.txt diff --git a/es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt similarity index 100% rename from es2panda/test/version_control/API16/bytecode_feature/sendable-class-export_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt rename to es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_compile_for_higher_or_equal_to_API12beta3_asm_version-expected.txt diff --git a/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_runtime_version-expected.txt b/es2panda/test/version_control/API18/bytecode_feature/sendable-class-export_unsupported_runtime_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/es2panda/test/version_control/API20/bytecode_feature/annotations.ts b/es2panda/test/version_control/API20/bytecode_feature/annotations.ts new file mode 100644 index 0000000000000000000000000000000000000000..7cad18eb174c49ba7ea02d55265561848ba7c808 --- /dev/null +++ b/es2panda/test/version_control/API20/bytecode_feature/annotations.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +@interface __$$ETS_ANNOTATION$$__Anno { + b: boolean = true +} + +@__$$ETS_ANNOTATION$$__Anno() +class A { } \ No newline at end of file diff --git a/es2panda/test/version_control/API20/bytecode_feature/annotations_runtime_below_abc_api_version-expected.txt b/es2panda/test/version_control/API20/bytecode_feature/annotations_runtime_below_abc_api_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..13510081b9bc44b4192aa01dadb03e5c04ca5537 --- /dev/null +++ b/es2panda/test/version_control/API20/bytecode_feature/annotations_runtime_below_abc_api_version-expected.txt @@ -0,0 +1 @@ +pandafile \ No newline at end of file diff --git a/es2panda/test/version_control/API20/bytecode_feature/annotations_supported_compile_asm_version-expected.txt b/es2panda/test/version_control/API20/bytecode_feature/annotations_supported_compile_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..11dd37ab8b3eba4994f5ecd5ed78a1770745580d --- /dev/null +++ b/es2panda/test/version_control/API20/bytecode_feature/annotations_supported_compile_asm_version-expected.txt @@ -0,0 +1,24 @@ +slotNum = 0x0 +.language ECMAScript +.function any .#~A=#A(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x3 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + defineclasswithbuffer 0x0, .#~A=#A, _2, 0x0, v0 + ldobjbyname 0x1, prototype + returnundefined +label_2: +} + + diff --git a/es2panda/test/version_control/API20/bytecode_feature/annotations_supported_runtime_version-expected.txt b/es2panda/test/version_control/API20/bytecode_feature/annotations_supported_runtime_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/es2panda/test/version_control/API20/bytecode_feature/annotations_unsupported_compile_asm_version-expected.txt b/es2panda/test/version_control/API20/bytecode_feature/annotations_unsupported_compile_asm_version-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..d327c04a727e2e2662cbd9470a2e080282f675a7 --- /dev/null +++ b/es2panda/test/version_control/API20/bytecode_feature/annotations_unsupported_compile_asm_version-expected.txt @@ -0,0 +1,3 @@ +SyntaxError: Current configuration does not support using annotations. Annotations can be used in the version of API 20 or higher versions. +Solutions: > Check the compatibleSdkVersion in build-profile.json5.> If compatibleSdkVersion is set to API 20 or higher version.> If you're running es2abc in commandline without IDE, please check whether target-api-version and enable-annotations options are correctly configured. [annotations.ts:17:12] +The size of programs is expected to be 1, but is 0 diff --git a/es2panda/typescript/core/destructuringContext.cpp b/es2panda/typescript/core/destructuringContext.cpp index 2243a62b95c8e8002b90d50c923695fbcf11f142..9c84408246194670a97f54c63ad062f409e6b010 100644 --- a/es2panda/typescript/core/destructuringContext.cpp +++ b/es2panda/typescript/core/destructuringContext.cpp @@ -197,6 +197,7 @@ void DestructuringContext::HandleIdentifierPattern(const ir::AssignmentExpressio void ArrayDestructuringContext::ValidateInferedType() { + CHECK_NOT_NULL(inferedType_); if (!inferedType_->IsArrayType() && !inferedType_->IsUnionType() && (!inferedType_->IsObjectType() || !inferedType_->AsObjectType()->IsTupleType())) { checker_->ThrowTypeError( @@ -521,6 +522,7 @@ void ArrayDestructuringContext::Start() void ObjectDestructuringContext::ValidateInferedType() { + CHECK_NOT_NULL(inferedType_); if (!inferedType_->IsObjectType()) { return; } diff --git a/es2panda/typescript/types/typeRelation.cpp b/es2panda/typescript/types/typeRelation.cpp index b87d32b1352c06959645e7d7cb9b7a7495d4cc7f..0603f632c4802834130b8bdfd4316d6f5201c83d 100644 --- a/es2panda/typescript/types/typeRelation.cpp +++ b/es2panda/typescript/types/typeRelation.cpp @@ -82,6 +82,7 @@ bool TypeRelation::IsIdenticalTo(Type *source, Type *target) CHECK_NOT_NULL(target); result_ = CacheLookup(source, target, checker_->IdenticalResults(), RelationType::IDENTICAL); if (result_ == RelationResult::CACHE_MISS) { + CHECK_NOT_NULL(source); checker_->ResolveStructuredTypeMembers(source); checker_->ResolveStructuredTypeMembers(target); result_ = RelationResult::FALSE; diff --git a/es2panda/util/commonUtil.h b/es2panda/util/commonUtil.h index f63afffa7dcf694a46b4aa674ab996b0c5499e1e..036d49c7658dd5c9e9d12878a744cdc23d9d976e 100644 --- a/es2panda/util/commonUtil.h +++ b/es2panda/util/commonUtil.h @@ -48,6 +48,7 @@ constexpr char NORMALIZED_OHMURL_PREFIX = '@'; constexpr char SLASH_TAG = '/'; constexpr char CHAR_VERTICAL_LINE = '|'; constexpr char COLON_SEPARATOR = ':'; +constexpr char DOT_SEPARATOR = '.'; constexpr size_t ORIGINAL_PKG_NAME_POS = 0U; constexpr size_t TARGET_PKG_NAME_POS = 1U; @@ -104,15 +105,15 @@ void VisitDyanmicImports(ConstReferenceIf function, // The dynamicimport bytecode should not have label, otherwise the dyanmicimport might be a jump // target and its parameter is a variable instead of a constant string expression (Check // AbcCodeProcessor::AddJumpLabels for more details). - if (iter->opcode != pandasm::Opcode::DYNAMICIMPORT || iter->set_label) { + if ((*iter)->opcode != pandasm::Opcode::DYNAMICIMPORT || (*iter)->IsLabel()) { continue; } auto prevIns = iter - 1; - if (prevIns->opcode != pandasm::Opcode::LDA_STR) { + if ((*prevIns)->opcode != pandasm::Opcode::LDA_STR) { continue; } - ASSERT(prevIns->ids.size() == 1); - cb(prevIns->ids[0]); // 0: index of the string in lda.str bytecode + ASSERT((*prevIns)->Ids().size() == 1); + cb((*prevIns)->GetId(0)); // 0: index of the string in lda.str bytecode } } } // namespace panda::es2panda::util diff --git a/es2panda/util/helpers.cpp b/es2panda/util/helpers.cpp index 8d4d486be4f8b9264dec4c84b074eff9086cb9ea..e0cd4127024cff5e8002f30f66880dc8fc786b29 100644 --- a/es2panda/util/helpers.cpp +++ b/es2panda/util/helpers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,6 +15,7 @@ #include "helpers.h" +#include #include #include #include @@ -31,6 +32,7 @@ #include #include #include +#include #include #ifdef ENABLE_BYTECODE_OPT @@ -675,10 +677,9 @@ static std::string GetTempOutputName(const std::string &inputFile) void Helpers::AnalysisProgram(panda::pandasm::Program *prog, const std::string &inputFile) { +#ifdef PANDA_WITH_BYTECODE_OPTIMIZER std::map stat; std::map *statp = &stat; - -#ifdef PANDA_WITH_BYTECODE_OPTIMIZER auto tempOutput = GetTempOutputName(inputFile); bool exists = false; auto mapsp = &panda::bytecodeopt::BytecodeAnalysisResults::GetOrCreateBytecodeMaps(tempOutput, exists); @@ -699,11 +700,11 @@ void Helpers::AnalysisProgram(panda::pandasm::Program *prog, const std::string & void Helpers::OptimizeProgram(panda::pandasm::Program *prog, const std::string &inputFile) { - std::map stat; - std::map *statp = &stat; auto tempOutput = GetTempOutputName(inputFile); #ifdef PANDA_WITH_BYTECODE_OPTIMIZER + std::map stat; + std::map *statp = &stat; const uint32_t COMPONENT_MASK = panda::Logger::Component::ASSEMBLER | panda::Logger::Component::BYTECODE_OPTIMIZER | panda::Logger::Component::COMPILER; @@ -958,13 +959,41 @@ bool Helpers::BelongingToRecords(const std::string &name, const std::unordered_s return retainRecordSet.find(recordName) != retainRecordSet.end(); } +bool Helpers::IsInnerAnnotationRecordName(const std::string &name) +{ + return name == panda::abc2program::CONCURRENT_MODULE_REQUEST_RECORD_NAME || + name == panda::abc2program::SLOT_NUMBER_RECORD_NAME || + name == panda::abc2program::EXPECTED_PROPERTY_COUNT_RECORD_NAME; +} + +std::string Helpers::RemoveRecordSuffixAnnotationName(const std::string &name) +{ + auto pos = name.rfind(util::DOT_SEPARATOR); + if (pos == std::string::npos) { + return name; + } + return name.substr(0, pos); +} + void Helpers::RemoveProgramsRedundantData(std::map &progsInfo, const std::map> &resolvedDepsRelation) { auto progInfoIter = progsInfo.begin(); while (progInfoIter != progsInfo.end()) { + auto name = progInfoIter->first; + auto &program = progInfoIter->second->program; + /** + * The record name of a user-defined annotation is the annotation name concatenated with the record name of the + * file where it is declared. In order to preserve the annotated record, it is necessary to remove the + * concatenated annotation name from the record name before perform dependency matching. + */ + if (!util::RecordNotGeneratedFromBytecode(name) && + (program.record_table.begin()->second.metadata->GetAccessFlags() & ACC_ANNOTATION) != 0 && + !IsInnerAnnotationRecordName(program.record_table.begin()->first)) { + name = RemoveRecordSuffixAnnotationName(name); + } // remove redundant sourcefiles and bytecodefile data which are not dependant in compilation - if (resolvedDepsRelation.find(progInfoIter->first) == resolvedDepsRelation.end()) { + if (resolvedDepsRelation.find(name) == resolvedDepsRelation.end()) { progInfoIter = progsInfo.erase(progInfoIter); continue; } @@ -986,9 +1015,14 @@ bool Helpers::IsSupportLazyImportVersion(int apiVersion, std::string subApiVersi (subApiVersion == SUB_API_VERSION_1 || subApiVersion == SUB_API_VERSION_2))); } -bool Helpers::IsSupportLazyImportDefaultVersion(int apiVersion) +bool Helpers::IsEnableExpectedPropertyCountApiVersion(int apiVersion) +{ + return !(apiVersion < ENABLE_EXPECTED_PROPERTY_COUNT_MIN_SUPPORTED_API_VERSION); +} + +bool Helpers::IsSupportAnnotationVersion(int apiVersion) { - return !(apiVersion < LAZY_IMPORT_DEFAULT_MIN_SUPPORTED_API_VERSION); + return !(apiVersion < ANNOTATION_SUPPORTED_API_VERSION); } } // namespace panda::es2panda::util diff --git a/es2panda/util/helpers.h b/es2panda/util/helpers.h index e831d3727518480f2b2fdabb8bd3c57c335b558a..d2a0614fab33466bdd8a5d1c8f5ba974435d1b5f 100644 --- a/es2panda/util/helpers.h +++ b/es2panda/util/helpers.h @@ -182,11 +182,14 @@ public: static bool IsSpecialScopeName(const util::StringView &str); static bool BelongingToRecords(const std::string &name, const std::unordered_set &retainRecordSet, const std::string &delimiter = std::string(DOT)); + static bool IsInnerAnnotationRecordName(const std::string &name); + static std::string RemoveRecordSuffixAnnotationName(const std::string &name); static void RemoveProgramsRedundantData(std::map &progsInfo, const std::map> &resolveDepsRelation); static bool IsDefaultApiVersion(int apiVersion, std::string subApiVersion); static bool IsSupportLazyImportVersion(int apiVersion, std::string subApiVersion); - static bool IsSupportLazyImportDefaultVersion(int apiVersion); + static bool IsEnableExpectedPropertyCountApiVersion(int apiVersion); + static bool IsSupportAnnotationVersion(int apiVersion); static bool IsSupportEtsImplementsVersion(int apiVersion); static const uint32_t MAX_DOUBLE_DIGIT = 310; @@ -224,10 +227,11 @@ public: ABC_TO_PROGRAM_MIN_SUPPORTED_BYTECODE_VERSION {12, 0, 2, 0}; static const int32_t SENDABLE_FUNCTION_MIN_SUPPORTED_API_VERSION = 12; static const int32_t LAZY_IMPORT_MIN_SUPPORTED_API_VERSION = 12; - static const int32_t LAZY_IMPORT_DEFAULT_MIN_SUPPORTED_API_VERSION = 18; static const int32_t SENDABLE_LAZY_LOADING_MIN_SUPPORTED_API_VERSION = 12; static const int8_t SUPER_CALL_OPT_MIN_SUPPORTED_API_VERSION = 18; static const int8_t SENDABLE_CLASS_USING_LOCAL_MODULE_VAR_MIN_SUPPORTED_API_VERSION = 18; + static const int8_t ENABLE_EXPECTED_PROPERTY_COUNT_MIN_SUPPORTED_API_VERSION = 18; + static const int8_t ANNOTATION_SUPPORTED_API_VERSION = 20; static constexpr std::string_view SUB_API_VERSION_1 = "beta1"; static constexpr std::string_view SUB_API_VERSION_2 = "beta2"; static constexpr std::string_view DEFAULT_SUB_API_VERSION = SUB_API_VERSION_1; diff --git a/es2panda/util/patchFix.cpp b/es2panda/util/patchFix.cpp index e7c0dd5646409d14733a4461a33274cede0fc5a3..4a05c01108ebe254a14ca8a36e829325cfce24c3 100644 --- a/es2panda/util/patchFix.cpp +++ b/es2panda/util/patchFix.cpp @@ -176,18 +176,18 @@ std::vector> PatchFix::GenerateFunctionAndCl ss << ") {" << std::endl; for (const auto &ins : func->ins) { - ss << (ins.set_label ? "" : "\t") << ins.ToString("", true, func->GetTotalRegs()) << " "; - if (ins.opcode == panda::pandasm::Opcode::CREATEARRAYWITHBUFFER || - ins.opcode == panda::pandasm::Opcode::CREATEOBJECTWITHBUFFER) { - int64_t bufferIdx = GetLiteralIdxFromStringId(ins.ids[0]); + ss << (ins->IsLabel() ? "" : "\t") << ins->ToString("", true, func->GetTotalRegs()) << " "; + if (ins->opcode == panda::pandasm::Opcode::CREATEARRAYWITHBUFFER || + ins->opcode == panda::pandasm::Opcode::CREATEOBJECTWITHBUFFER) { + int64_t bufferIdx = GetLiteralIdxFromStringId(ins->GetId(0)); ss << ExpandLiteral(bufferIdx, literalBuffers) << " "; - } else if (ins.opcode == panda::pandasm::Opcode::DEFINECLASSWITHBUFFER) { - CollectFunctionsWithDefinedClasses(func->name, ins.ids[0]); - int64_t bufferIdx = GetLiteralIdxFromStringId(ins.ids[1]); + } else if (ins->opcode == panda::pandasm::Opcode::DEFINECLASSWITHBUFFER) { + CollectFunctionsWithDefinedClasses(func->name, ins->GetId(0)); + int64_t bufferIdx = GetLiteralIdxFromStringId(ins->GetId(1)); std::string literalStr = ExpandLiteral(bufferIdx, literalBuffers); auto classHash = Helpers::GetHashString(literalStr); - hashList.push_back(std::pair(ins.ids[0], classHash)); - CollectClassMemberFunctions(ins.ids[0], bufferIdx, literalBuffers); + hashList.push_back(std::pair(ins->GetId(0), classHash)); + CollectClassMemberFunctions(ins->GetId(0), bufferIdx, literalBuffers); } ss << " "; } @@ -319,27 +319,27 @@ uint32_t PatchFix::GetPatchLexicalIdx(const std::string &variableName) return topScopeLexEnvs_[variableName]; } -bool IsFunctionOrClassDefineIns(panda::pandasm::Ins &ins) +bool IsFunctionOrClassDefineIns(panda::pandasm::Ins *ins) { - if (ins.opcode == panda::pandasm::Opcode::DEFINEMETHOD || - ins.opcode == panda::pandasm::Opcode::DEFINEFUNC || - ins.opcode == panda::pandasm::Opcode::DEFINECLASSWITHBUFFER) { + if (ins->opcode == panda::pandasm::Opcode::DEFINEMETHOD || + ins->opcode == panda::pandasm::Opcode::DEFINEFUNC || + ins->opcode == panda::pandasm::Opcode::DEFINECLASSWITHBUFFER) { return true; } return false; } -bool IsStPatchVarIns(panda::pandasm::Ins &ins) +bool IsStPatchVarIns(panda::pandasm::Ins *ins) { - return ins.opcode == panda::pandasm::Opcode::WIDE_STPATCHVAR; + return ins->opcode == panda::pandasm::Opcode::WIDE_STPATCHVAR; } void PatchFix::CollectFuncDefineIns(panda::pandasm::Function *func) { for (size_t i = 0; i < func->ins.size(); ++i) { - if (IsFunctionOrClassDefineIns(func->ins[i])) { - funcDefineIns_.push_back(func->ins[i]); // push define ins - funcDefineIns_.push_back(func->ins[i + 1]); // push store ins + if (IsFunctionOrClassDefineIns(func->ins[i].get())) { + funcDefineIns_.push_back(func->ins[i].get()); // push define ins + funcDefineIns_.push_back(func->ins[i + 1].get()); // push store ins } } } @@ -377,31 +377,23 @@ void PatchFix::HandleModifiedDefinedClassFunc(panda::pandasm::Program *prog) } } -void PatchFix::AddHeadAndTailInsForPatchFuncMain0(std::vector &ins) +void PatchFix::AddHeadAndTailInsForPatchFuncMain0(std::vector &ins) { - panda::pandasm::Ins returnUndefine; - returnUndefine.opcode = pandasm::Opcode::RETURNUNDEFINED; - + auto returnUndefined = new pandasm::Returnundefined(); if (ins.size() == 0) { - ins.push_back(returnUndefine); + ins.emplace_back(returnUndefined); return; } - panda::pandasm::Ins newLexenv; - newLexenv.opcode = pandasm::Opcode::NEWLEXENV; - newLexenv.imms.reserve(1); - auto newFuncNum = long(ins.size() / 2); // each new function has 2 ins: define and store - newLexenv.imms.emplace_back(newFuncNum); - - ins.insert(ins.begin(), newLexenv); - ins.push_back(returnUndefine); + auto newLexenv = new pandasm::Newlexenv(long(ins.size() / 2)); // each new function has 2 ins: define and stor + ins.emplace(ins.begin(), newLexenv); + ins.emplace_back(returnUndefined); } -void PatchFix::AddTailInsForPatchFuncMain1(std::vector &ins) +void PatchFix::AddTailInsForPatchFuncMain1(std::vector &ins) { - panda::pandasm::Ins returnUndefined; - returnUndefined.opcode = pandasm::Opcode::RETURNUNDEFINED; - ins.push_back(returnUndefined); + auto returnUndefined = new pandasm::Returnundefined(); + ins.emplace_back(returnUndefined); } void PatchFix::CreateFunctionPatchMain0AndMain1(panda::pandasm::Function &patchFuncMain0, @@ -415,19 +407,19 @@ void PatchFix::CreateFunctionPatchMain0AndMain1(panda::pandasm::Function &patchF patchFuncMain1.params.emplace_back(panda::pandasm::Type("any", 0), patchFuncMain1.language); } - std::vector patchMain0DefineIns; - std::vector patchMain1DefineIns; + std::vector patchMain0DefineIns; + std::vector patchMain1DefineIns; for (size_t i = 0; i < funcDefineIns_.size(); ++i) { if (IsFunctionOrClassDefineIns(funcDefineIns_[i])) { - auto &name = funcDefineIns_[i].ids[0]; + auto name = funcDefineIns_[i]->GetId(0); if (newFuncNames_.count(name) && IsStPatchVarIns(funcDefineIns_[i + 1])) { - patchMain0DefineIns.push_back(funcDefineIns_[i]); - patchMain0DefineIns.push_back(funcDefineIns_[i + 1]); + patchMain0DefineIns.emplace_back(funcDefineIns_[i]->DeepCopy()); + patchMain0DefineIns.emplace_back(funcDefineIns_[i + 1]->DeepCopy()); continue; } if (patchFuncNames_.count(name) || modifiedClassNames_.count(name)) { - patchMain1DefineIns.push_back(funcDefineIns_[i]); + patchMain1DefineIns.emplace_back(funcDefineIns_[i]->DeepCopy()); continue; } } @@ -436,8 +428,8 @@ void PatchFix::CreateFunctionPatchMain0AndMain1(panda::pandasm::Function &patchF AddHeadAndTailInsForPatchFuncMain0(patchMain0DefineIns); AddTailInsForPatchFuncMain1(patchMain1DefineIns); - patchFuncMain0.ins = patchMain0DefineIns; - patchFuncMain1.ins = patchMain1DefineIns; + patchFuncMain0.ins = std::move(patchMain0DefineIns); + patchFuncMain1.ins = std::move(patchMain1DefineIns); patchFuncMain0.return_type = panda::pandasm::Type("any", 0); patchFuncMain1.return_type = panda::pandasm::Type("any", 0); diff --git a/es2panda/util/patchFix.h b/es2panda/util/patchFix.h index 1802233e0edb3f484bb2a6db2931bf0a9f43d2ee..db26b4a25e12f078c2755562b9858b636c8bd9b3 100644 --- a/es2panda/util/patchFix.h +++ b/es2panda/util/patchFix.h @@ -99,8 +99,8 @@ private: std::string ExpandLiteral(int64_t bufferIdx, LiteralBuffers &literalBuffers); std::string ConvertLiteralToString(std::vector &literalBuffer); void CollectFuncDefineIns(panda::pandasm::Function *func); - void AddHeadAndTailInsForPatchFuncMain0(std::vector &ins); - void AddTailInsForPatchFuncMain1(std::vector &ins); + void AddHeadAndTailInsForPatchFuncMain0(std::vector &ins); + void AddTailInsForPatchFuncMain1(std::vector &ins); void CreateFunctionPatchMain0AndMain1(panda::pandasm::Function &patchFuncMain0, panda::pandasm::Function &patchFuncMain1); bool IsAnonymousOrSpecialOrDuplicateFunction(const std::string &funcName); @@ -135,7 +135,7 @@ private: ArenaUnorderedMap topScopeLexEnvs_; ArenaSet patchFuncNames_; ArenaSet newFuncNames_; - ArenaVector funcDefineIns_; + ArenaVector funcDefineIns_; ArenaSet modifiedClassNames_; ArenaUnorderedMap> classMemberFunctions_; ArenaUnorderedMap> funcDefinedClasses_; diff --git a/ets2panda/BUILD.gn b/ets2panda/BUILD.gn index dec0dc9a48863188dfa0892241c4f7db468f1392..60c32ea888d672fd753514e638086c66492cc36b 100644 --- a/ets2panda/BUILD.gn +++ b/ets2panda/BUILD.gn @@ -11,7 +11,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//arkcompiler/runtime_core/static_core/ark_config.gni") +if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + import("//arkcompiler/runtime_core/static_core/ark_config.gni") +} else { + import( + "//build/config/components/runtime_core/static_core/ark_common_config.gni") +} if (ark_standalone_build) { import("$build_root/ark.gni") @@ -23,12 +29,22 @@ config("libes2panda_public_config") { include_dirs = [ "$target_gen_dir", "$target_gen_dir/include", - "$target_gen_dir/generated", - "//third_party/icu/icu4c/source/common", - "//third_party/icu/icu4c/source/i18n", - "//third_party/icu/icu4c/source", "$ark_es2panda_root", ] + if (ark_standalone_build || ark_static_standalone_build) { + include_dirs += [ + "$target_gen_dir/generated", + "//third_party/icu/icu4c/source/common", + "//third_party/icu/icu4c/source/i18n", + "//third_party/icu/icu4c/source", + ] + } +} + +action("check_build_system_consistency") { + script = "./scripts/check_build_system_consistency.py" + args = [ rebase_path(".", root_build_dir) ] + outputs = [ "$target_gen_dir/consistency_check.stamp" ] } libes2panda_sources = [ @@ -59,7 +75,6 @@ libes2panda_sources = [ "checker/ETSAnalyzerHelpers.cpp", "checker/ETSAnalyzerUnreachable.cpp", "checker/ETSchecker.cpp", - "checker/IsolatedDeclgenChecker.cpp", "checker/JSchecker.cpp", "checker/TSAnalyzer.cpp", "checker/TSAnalyzerUnreachable.cpp", @@ -74,12 +89,9 @@ libes2panda_sources = [ "checker/ets/castingContext.cpp", "checker/ets/conversion.cpp", "checker/ets/dynamic.cpp", - "checker/ets/dynamic/dynamicCall.cpp", "checker/ets/etsWarningAnalyzer.cpp", "checker/ets/function.cpp", "checker/ets/helpers.cpp", - "checker/ets/narrowingConverter.cpp", - "checker/ets/narrowingWideningConverter.cpp", "checker/ets/object.cpp", "checker/ets/typeCheckingHelpers.cpp", "checker/ets/typeConverter.cpp", @@ -101,11 +113,11 @@ libes2panda_sources = [ "checker/types/ets/byteType.cpp", "checker/types/ets/charType.cpp", "checker/types/ets/doubleType.cpp", + "checker/types/ets/etsAnyType.cpp", "checker/types/ets/etsArrayType.cpp", "checker/types/ets/etsAsyncFuncReturnType.cpp", "checker/types/ets/etsBigIntType.cpp", "checker/types/ets/etsBooleanType.cpp", - "checker/types/ets/etsDynamicType.cpp", "checker/types/ets/etsEnumType.cpp", "checker/types/ets/etsExtensionFuncHelperType.cpp", "checker/types/ets/etsFunctionType.cpp", @@ -128,6 +140,7 @@ libes2panda_sources = [ "checker/types/ets/shortType.cpp", "checker/types/ets/wildcardType.cpp", "checker/types/globalTypesHolder.cpp", + "checker/types/gradualType.cpp", "checker/types/signature.cpp", "checker/types/ts/anyType.cpp", "checker/types/ts/arrayType.cpp", @@ -203,46 +216,52 @@ libes2panda_sources = [ "compiler/function/generatorFunctionBuilder.cpp", "compiler/lowering/checkerPhase.cpp", "compiler/lowering/ets/ambientLowering.cpp", + "compiler/lowering/ets/annotationCopyLowering.cpp", + "compiler/lowering/ets/annotationCopyPostLowering.cpp", "compiler/lowering/ets/arrayLiteralLowering.cpp", "compiler/lowering/ets/asyncMethodLowering.cpp", "compiler/lowering/ets/bigintLowering.cpp", - "compiler/lowering/ets/boxedTypeLowering.cpp", "compiler/lowering/ets/boxingForLocals.cpp", "compiler/lowering/ets/capturedVariables.cpp", "compiler/lowering/ets/cfgBuilderPhase.cpp", "compiler/lowering/ets/constantExpressionLowering.cpp", "compiler/lowering/ets/convertPrimitiveCastMethodCall.cpp", + "compiler/lowering/ets/declGenPhase.cpp", "compiler/lowering/ets/declareOverloadLowering.cpp", "compiler/lowering/ets/defaultParametersInConstructorLowering.cpp", "compiler/lowering/ets/defaultParametersLowering.cpp", - "compiler/lowering/ets/dynamicImportLowering.cpp", + "compiler/lowering/ets/dynamicImport.cpp", "compiler/lowering/ets/enumLowering.cpp", "compiler/lowering/ets/enumPostCheckLowering.cpp", + "compiler/lowering/ets/enumPropertiesInAnnotationsLowering.cpp", "compiler/lowering/ets/expandBrackets.cpp", "compiler/lowering/ets/exportAnonymousConst.cpp", "compiler/lowering/ets/expressionLambdaLowering.cpp", "compiler/lowering/ets/extensionAccessorLowering.cpp", "compiler/lowering/ets/genericBridgesLowering.cpp", + "compiler/lowering/ets/gradualTypeNarrowing.cpp", "compiler/lowering/ets/insertOptionalParametersAnnotation.cpp", "compiler/lowering/ets/interfaceObjectLiteralLowering.cpp", "compiler/lowering/ets/interfacePropertyDeclarations.cpp", - "compiler/lowering/ets/lateInitialization.cpp", "compiler/lowering/ets/lambdaLowering.cpp", - "compiler/lowering/ets/localClassLowering.cpp", + "compiler/lowering/ets/lateInitialization.cpp", "compiler/lowering/ets/objectIndexAccess.cpp", "compiler/lowering/ets/objectIterator.cpp", "compiler/lowering/ets/objectLiteralLowering.cpp", "compiler/lowering/ets/opAssignment.cpp", "compiler/lowering/ets/optionalArgumentsLowering.cpp", "compiler/lowering/ets/optionalLowering.cpp", + "compiler/lowering/ets/overloadMappingLowering.cpp", "compiler/lowering/ets/packageImplicitImport.cpp", "compiler/lowering/ets/partialExportClassGen.cpp", + "compiler/lowering/ets/primitiveConversionPhase.cpp", "compiler/lowering/ets/promiseVoid.cpp", "compiler/lowering/ets/recordLowering.cpp", "compiler/lowering/ets/resizableArrayLowering.cpp", "compiler/lowering/ets/restArgsLowering.cpp", "compiler/lowering/ets/restTupleLowering.cpp", "compiler/lowering/ets/setJumpTarget.cpp", + "compiler/lowering/ets/setterLowering.cpp", "compiler/lowering/ets/spreadLowering.cpp", "compiler/lowering/ets/stringComparison.cpp", "compiler/lowering/ets/stringConstantsLowering.cpp", @@ -252,6 +271,7 @@ libes2panda_sources = [ "compiler/lowering/ets/topLevelStmts/importExportDecls.cpp", "compiler/lowering/ets/topLevelStmts/topLevelStmts.cpp", "compiler/lowering/ets/typeFromLowering.cpp", + "compiler/lowering/ets/unboxLowering.cpp", "compiler/lowering/ets/unionLowering.cpp", "compiler/lowering/phase.cpp", "compiler/lowering/plugin_phase.cpp", @@ -285,6 +305,7 @@ libes2panda_sources = [ "ir/base/decorator.cpp", "ir/base/metaProperty.cpp", "ir/base/methodDefinition.cpp", + "ir/base/overloadDeclaration.cpp", "ir/base/property.cpp", "ir/base/scriptFunction.cpp", "ir/base/scriptFunctionSignature.cpp", @@ -297,6 +318,7 @@ libes2panda_sources = [ "ir/brokenTypeNode.cpp", "ir/ets/etsClassLiteral.cpp", "ir/ets/etsFunctionType.cpp", + "ir/ets/etsIntrinsicNode.cpp", "ir/ets/etsKeyofType.cpp", "ir/ets/etsModule.cpp", "ir/ets/etsNeverType.cpp", @@ -478,6 +500,7 @@ libes2panda_sources = [ "parser/program/program.cpp", "parser/statementParser.cpp", "parser/statementTSParser.cpp", + "public/public.cpp", "util/arktsconfig.cpp", "util/bitset.cpp", "util/diagnostic.cpp", @@ -488,6 +511,7 @@ libes2panda_sources = [ "util/helpers.cpp", "util/importPathManager.cpp", "util/path.cpp", + "util/perfMetrics.cpp", "util/plugin.cpp", "util/ustring.cpp", "varbinder/ASBinder.cpp", @@ -530,6 +554,7 @@ HEADERS_TO_BE_PARSED = [ "ir/statement.h", "ir/irnode.h", "checker/types/typeRelation.h", + "ir/ets/etsIntrinsicNode.h", "ir/visitor/AstVisitor.h", "ir/statements/classDeclaration.h", "ir/base/tsMethodSignature.h", @@ -538,7 +563,6 @@ HEADERS_TO_BE_PARSED = [ "checker/types/ts/nonPrimitiveType.h", "ir/ts/tsTypeParameterInstantiation.h", "ir/module/importDeclaration.h", - "checker/types/ets/etsDynamicType.h", "ir/statements/doWhileStatement.h", "ir/expressions/literals/bigIntLiteral.h", "ir/expressions/assignmentExpression.h", @@ -626,7 +650,6 @@ HEADERS_TO_BE_PARSED = [ "ir/ts/tsParenthesizedType.h", "ir/ts/tsModuleDeclaration.h", "ir/ets/etsPackageDeclaration.h", - "checker/types/ets/etsDynamicFunctionType.h", "ir/expressions/literals/regExpLiteral.h", "ir/ets/etsNewArrayInstanceExpression.h", "checker/types/ets/etsVoidType.h", @@ -716,6 +739,7 @@ HEADERS_TO_BE_PARSED = [ "ir/ts/tsImportEqualsDeclaration.h", "ir/validationInfo.h", "ir/base/methodDefinition.h", + "ir/base/overloadDeclaration.h", "ir/ts/tsIntersectionType.h", "checker/types/ts/nullType.h", "checker/types/ts/unknownType.h", @@ -770,6 +794,9 @@ HEADERS_TO_BE_PARSED = [ "es2panda.h", "ast_verifier/ASTVerifier.h", "util/importPathManager.h", + "util/options.h", + "util/path.h", + "util/arktsconfig.h", ] ES2PANDA_API_GENERATED = [ @@ -799,7 +826,6 @@ ES2PANDA_API_GENERATED = [ "$LIBGEN_DIR/gen/headers/ir/expressions/objectExpression.yaml", "$LIBGEN_DIR/gen/headers/ir/module/importSpecifier.yaml", "$LIBGEN_DIR/gen/headers/ir/expressions/conditionalExpression.yaml", - "$LIBGEN_DIR/gen/headers/checker/types/ets/etsDynamicFunctionType.yaml", "$LIBGEN_DIR/gen/headers/ir/expressions/callExpression.yaml", "$LIBGEN_DIR/gen/headers/ir/expressions/literals/bigIntLiteral.yaml", "$LIBGEN_DIR/gen/headers/ir/base/classElement.yaml", @@ -809,6 +835,7 @@ ES2PANDA_API_GENERATED = [ "$LIBGEN_DIR/gen/headers/ir/visitor/IterateAstVisitor.yaml", "$LIBGEN_DIR/gen/headers/ir/statements/functionDeclaration.yaml", "$LIBGEN_DIR/gen/headers/ir/ets/etsTypeReference.yaml", + "$LIBGEN_DIR/gen/headers/ir/ets/etsIntrinsicNode.yaml", "$LIBGEN_DIR/gen/headers/checker/types/ts/tupleType.yaml", "$LIBGEN_DIR/gen/headers/ir/ts/tsTypeReference.yaml", "$LIBGEN_DIR/gen/headers/checker/types/ts/functionType.yaml", @@ -923,7 +950,6 @@ ES2PANDA_API_GENERATED = [ "$LIBGEN_DIR/gen/headers/ir/expressions/blockExpression.yaml", "$LIBGEN_DIR/gen/headers/ir/ts/tsTypeLiteral.yaml", "$LIBGEN_DIR/gen/headers/ir/ts/tsTypeParameter.yaml", - "$LIBGEN_DIR/gen/headers/checker/types/ets/etsDynamicType.yaml", "$LIBGEN_DIR/gen/headers/checker/types/ets/charType.yaml", "$LIBGEN_DIR/gen/headers/ir/ts/tsBooleanKeyword.yaml", "$LIBGEN_DIR/gen/headers/ir/base/spreadElement.yaml", @@ -963,6 +989,7 @@ ES2PANDA_API_GENERATED = [ "$LIBGEN_DIR/gen/headers/ir/expressions/directEvalExpression.yaml", "$LIBGEN_DIR/gen/headers/ir/ts/tsTypeParameterDeclaration.yaml", "$LIBGEN_DIR/gen/headers/ir/base/methodDefinition.yaml", + "$LIBGEN_DIR/gen/headers/ir/base/overloadDeclaration.yaml", "$LIBGEN_DIR/gen/headers/ir/ts/tsNullKeyword.yaml", "$LIBGEN_DIR/gen/headers/ir/ts/tsInterfaceHeritage.yaml", "$LIBGEN_DIR/gen/headers/checker/types/ts/enumLiteralType.yaml", @@ -1037,6 +1064,9 @@ ES2PANDA_API_GENERATED = [ "$LIBGEN_DIR/gen/headers/parser/program/program.yaml", "$LIBGEN_DIR/gen/headers/ast_verifier/ASTVerifier.yaml", "$LIBGEN_DIR/gen/headers/util/importPathManager.yaml", + "$LIBGEN_DIR/gen/headers/util/path.yaml", + "$LIBGEN_DIR/gen/headers/util/arktsconfig.yaml", + "$LIBGEN_DIR/gen/headers/util/options.yaml", ] ES2PANDA_API = [ @@ -1054,6 +1084,7 @@ action("libes2panda_public_parse_headers") { script = "./public/headers_parser/main.py" deps = [ + ":check_build_system_consistency", ":es2panda_options_gen_options_h", ":gen_es2panda_lexer_tokenType_h", ] @@ -1096,6 +1127,7 @@ ark_gen("gen") { # libarkruntime, and conflict with JIT setup ensues libes2panda_public_sources = [ "declgen_ets2ts/declgenEts2Ts.cpp", + "declgen_ets2ts/isolatedDeclgenChecker.cpp", "public/${LIB_NAME}.cpp", "util/generateBin.cpp", "util/options.cpp", @@ -1108,25 +1140,45 @@ config("libes2panda_config") { ] } -libes2panda_configs = [ - "$ark_root/assembler:arkassembler_public_config", - "$ark_root:ark_config", +if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + libes2panda_configs = [ "$ark_root:ark_config" ] + libes2panda_public_configs = [ "$ark_root:ark_config" ] +} else { + libes2panda_configs = + [ "//build/config/components/runtime_core/static_core:ark_common_config" ] + libes2panda_public_configs = + [ "//build/config/components/runtime_core/static_core:ark_common_config" ] +} + +if (ark_standalone_build || ark_static_standalone_build) { + libes2panda_configs += [ + "$ark_root/assembler:arkassembler_public_config", + "$ark_root/libpandabase:arkbase_public_config", + "$ark_root/libpandafile:arkfile_public_config", + "$ark_root/abc2program:arkts_abc2program_public_config", + ] +} + +libes2panda_configs += [ ":libes2panda_public_config", ":libes2panda_config", - "$ark_root/libpandabase:arkbase_public_config", - "$ark_root/libpandafile:arkfile_public_config", ] -libes2panda_public_configs = [ - "$ark_root/assembler:arkassembler_public_config", - "$ark_root:ark_config", +if (ark_standalone_build || ark_static_standalone_build) { + libes2panda_public_configs += [ + "$ark_root/assembler:arkassembler_public_config", + "$ark_root/libpandabase:arkbase_public_config", + "$ark_root/libpandafile:arkfile_public_config", + "$ark_root/bytecode_optimizer:bytecodeopt_public_config", + "$ark_root/runtime:arkruntime_public_config", + "$ark_root/compiler:arkcompiler_public_config", + ] +} + +libes2panda_public_configs += [ ":libes2panda_public_config", ":libes2panda_config", - "$ark_root/libpandabase:arkbase_public_config", - "$ark_root/libpandafile:arkfile_public_config", - "$ark_root/bytecode_optimizer:bytecodeopt_public_config", - "$ark_root/compiler:arkcompiler_public_config", - "$ark_root/runtime:arkruntime_public_config", ] ohos_shared_library("libes2panda") { @@ -1146,26 +1198,41 @@ ohos_source_set("libes2panda_frontend_static") { ":es2panda_options_gen_options_h", ":gen_${LIB_NAME}_decl_inc", ":gen_${LIB_NAME}_enums_inc", + ":gen_${LIB_NAME}_idl", ":gen_${LIB_NAME}_impl_inc", ":gen_${LIB_NAME}_include_inc", ":gen_${LIB_NAME}_list_inc", - ":gen_${LIB_NAME}_idl", ":gen_es2panda_compiler_signatures_h", ":gen_es2panda_lexer_keywords_h", ":gen_es2panda_lexer_tokenType_h", ":gen_es2panda_lexer_token_inl", ":isa_gen_es2panda_formats_h", ":isa_gen_es2panda_isa_h", - "$ark_third_party_root/icu/icu4c:static_icui18n", - "$ark_third_party_root/icu/icu4c:static_icuuc", ] external_deps = [ + "runtime_core:libarktsabc2program_package", "runtime_core:libarktsassembler_package", "runtime_core:libarktsbase_package", "runtime_core:libarktscompiler_package", "runtime_core:libarktsfile_package", sdk_libc_secshared_dep, ] + if (ark_standalone_build || ark_static_standalone_build) { + deps += [ + "$ark_third_party_root/icu/icu4c:static_icui18n", + "$ark_third_party_root/icu/icu4c:static_icuuc", + ] + } else { + external_deps += [ + "icu:static_icui18n", + "icu:static_icuuc", + "runtime_core:arkts_abc2program_public_headers", + "runtime_core:assembler_headers", + "runtime_core:libpandabase_headers", + "runtime_core:libpandafile_headers", + "runtime_core:runtime_gen_headers", + ] + } part_name = "ets_frontend" subsystem_name = "arkcompiler" } @@ -1203,19 +1270,39 @@ ohos_source_set("libes2panda_public_frontend_static") { deps = [ ":libes2panda_frontend_static" ] - if (ark_standalone_build || ark_static_standalone_build) { - deps += [ "$ark_root/bytecode_optimizer:libarktsbytecodeopt_package" ] - } - if (target_os != "win" && target_os != "mingw" && target_os != "winuwp") { deps += [ ":generate_ets2panda_info" ] defines = [ "ES2PANDA_COMPILE_BY_GN" ] } external_deps = [ + "runtime_core:libarktsabc2program_package", "runtime_core:libarktsbytecodeopt_package", sdk_libc_secshared_dep, ] + + if (ark_standalone_build || ark_static_standalone_build) { + deps += [ + "$ark_root/abc2program:libarktsabc2program_package", + "$ark_root/assembler:libarktsassembler", + "$ark_root/bytecode_optimizer:libarktsbytecodeopt_package", + "$ark_root/compiler:libarktscompiler", + "$ark_root/libpandabase:libarktsbase", + "$ark_root/libpandafile:libarktsfile", + ] + } else { + external_deps += [ + "runtime_core:assembler_headers", + "runtime_core:bytecode_optimizer_headers", + "runtime_core:compiler_headers", + "runtime_core:libpandabase_headers", + "runtime_core:libpandafile_headers", + "runtime_core:runtime_gen_headers", + "runtime_core:runtime_headers", + "runtime_core:verification_headers", + ] + } + part_name = "ets_frontend" subsystem_name = "arkcompiler" } @@ -1243,9 +1330,9 @@ ark_gen("es2panda_diagnostic_gen") { "util/diagnostic/semantic.yaml", "util/diagnostic/warning.yaml", "util/diagnostic/fatal.yaml", - "util/diagnostic/isolated_declgen.yaml", "declgen_ets2ts/declgen_ets2ts_error.yaml", "declgen_ets2ts/declgen_ets2ts_warning.yaml", + "declgen_ets2ts/isolated_declgen.yaml", "util/diagnostic/arktsconfig_error.yaml", ] template_files = [ "diagnostic.h.erb" ] @@ -1288,3 +1375,41 @@ ark_gen("gen_es2panda_compiler") { destination = "$target_gen_dir/generated" api = [ "compiler/scripts/signatures.rb" ] } + +template("panda_code_fix_gen") { + code_fix_api = "$ark_es2panda_root/lsp/code_fix_register.rb" + api_list = [] + foreach(i, invoker.data) { + api_list += [ code_fix_api ] + } + + ark_gen("$target_name") { + data = invoker.data + template_files = invoker.template_files + sources = invoker.sources + destination = invoker.destination + api = api_list + if (defined(invoker.requires)) { + requires = invoker.requires + } + if (defined(invoker.extra_dependencies)) { + extra_dependencies = invoker.extra_dependencies + } + } +} + +panda_code_fix_gen("es2panda_lsp_code_fix_register_gen") { + data = [ + "util/diagnostic/syntax.yaml", + "util/diagnostic/semantic.yaml", + "util/diagnostic/warning.yaml", + "util/diagnostic/fatal.yaml", + "declgen_ets2ts/declgen_ets2ts_error.yaml", + "declgen_ets2ts/declgen_ets2ts_warning.yaml", + "declgen_ets2ts/isolated_declgen.yaml", + "util/diagnostic/arktsconfig_error.yaml", + ] + template_files = [ "code_fix_register.h.erb" ] + sources = "lsp" + destination = "$target_gen_dir/generated" +} diff --git a/ets2panda/CMakeLists.txt b/ets2panda/CMakeLists.txt index 10cf792e9428eca26e159cbc97f4d69be8c48b6a..73d465ae3641b94bb806b297268f3b89e79e5884 100644 --- a/ets2panda/CMakeLists.txt +++ b/ets2panda/CMakeLists.txt @@ -73,10 +73,10 @@ if(PANDA_WITH_ETS) " \"@arkts.collections\": [\"${STATIC_CORE}${DELIM}plugins${DELIM}ets${DELIM}sdk${DELIM}arkts${DELIM}@arkts.collections.ets\"],\n" " \"import_tests\": [\"${CMAKE_CURRENT_SOURCE_DIR}/test/parser/ets/import_tests\"]\n" " },\n" - " \"dynamicPaths\": {\n" + " \"dependencies\": {\n" " \"dynamic_import_tests\": {\"language\": \"js\", \"ohmUrl\": \"dynamic_import_tests\"},\n" - " \"dynamic_import_tests/modules/instanceof\": {\"language\": \"js\", \"declPath\": \"${CMAKE_CURRENT_SOURCE_DIR}/test/parser/ets/dynamic_import_tests/modules/instanceof.ets\", \"ohmUrl\": \"${CMAKE_CURRENT_SOURCE_DIR}/test/parser/ets/dynamic_import_tests/modules/instanceof.ets\"},\n" - " \"dynamic_import_tests/modules/module\": {\"language\": \"js\", \"declPath\": \"${CMAKE_CURRENT_SOURCE_DIR}/test/parser/ets/dynamic_import_tests/modules/module.ets\", \"ohmUrl\": \"${CMAKE_CURRENT_SOURCE_DIR}/test/parser/ets/dynamic_import_tests/modules/module.ets\"}\n" + " \"dynamic_import_tests/modules/instanceof\": {\"language\": \"js\", \"path\": \"${CMAKE_CURRENT_SOURCE_DIR}/test/parser/ets/dynamic_import_tests/modules/instanceof.ets\", \"ohmUrl\": \"${CMAKE_CURRENT_SOURCE_DIR}/test/parser/ets/dynamic_import_tests/modules/instanceof.ets\"},\n" + " \"dynamic_import_tests/modules/module\": {\"language\": \"js\", \"path\": \"${CMAKE_CURRENT_SOURCE_DIR}/test/parser/ets/dynamic_import_tests/modules/module.ets\", \"ohmUrl\": \"${CMAKE_CURRENT_SOURCE_DIR}/test/parser/ets/dynamic_import_tests/modules/module.ets\"}\n" " }\n" " }\n" "}\n" @@ -144,8 +144,8 @@ panda_gen( ${DIAGNOSTIC_DIR}/fatal.yaml ${CMAKE_CURRENT_SOURCE_DIR}/declgen_ets2ts/declgen_ets2ts_error.yaml ${CMAKE_CURRENT_SOURCE_DIR}/declgen_ets2ts/declgen_ets2ts_warning.yaml + ${CMAKE_CURRENT_SOURCE_DIR}/declgen_ets2ts/isolated_declgen.yaml ${DIAGNOSTIC_DIR}/arktsconfig_error.yaml - ${DIAGNOSTIC_DIR}/isolated_declgen.yaml TARGET_NAME es2panda_diagnostic_gen TEMPLATES diagnostic.h.erb SOURCE ${DIAGNOSTIC_DIR} @@ -276,23 +276,23 @@ set(ES2PANDA_LIB_SRC compiler/lowering/ets/expressionLambdaLowering.cpp compiler/lowering/ets/extensionAccessorLowering.cpp compiler/lowering/ets/genericBridgesLowering.cpp + compiler/lowering/ets/gradualTypeNarrowing.cpp compiler/lowering/ets/arrayLiteralLowering.cpp - compiler/lowering/ets/boxedTypeLowering.cpp compiler/lowering/ets/boxingForLocals.cpp compiler/lowering/ets/capturedVariables.cpp compiler/lowering/ets/cfgBuilderPhase.cpp compiler/lowering/ets/constantExpressionLowering.cpp compiler/lowering/ets/convertPrimitiveCastMethodCall.cpp compiler/lowering/ets/declareOverloadLowering.cpp + compiler/lowering/ets/declGenPhase.cpp compiler/lowering/ets/defaultParametersInConstructorLowering.cpp compiler/lowering/ets/defaultParametersLowering.cpp - compiler/lowering/ets/dynamicImportLowering.cpp compiler/lowering/ets/exportAnonymousConst.cpp compiler/lowering/ets/lateInitialization.cpp compiler/lowering/ets/lambdaLowering.cpp + compiler/lowering/ets/dynamicImport.cpp compiler/lowering/ets/restTupleLowering.cpp compiler/lowering/ets/spreadLowering.cpp - compiler/lowering/ets/localClassLowering.cpp compiler/lowering/ets/objectIndexAccess.cpp compiler/lowering/ets/objectIterator.cpp compiler/lowering/ets/insertOptionalParametersAnnotation.cpp @@ -307,6 +307,7 @@ set(ES2PANDA_LIB_SRC compiler/lowering/ets/unionLowering.cpp compiler/lowering/ets/optionalArgumentsLowering.cpp compiler/lowering/ets/optionalLowering.cpp + compiler/lowering/ets/overloadMappingLowering.cpp compiler/lowering/ets/expandBrackets.cpp compiler/lowering/ets/packageImplicitImport.cpp compiler/lowering/ets/partialExportClassGen.cpp @@ -319,7 +320,13 @@ set(ES2PANDA_LIB_SRC compiler/lowering/ets/typeFromLowering.cpp compiler/lowering/ets/enumLowering.cpp compiler/lowering/ets/enumPostCheckLowering.cpp + compiler/lowering/ets/enumPropertiesInAnnotationsLowering.cpp compiler/lowering/ets/setJumpTarget.cpp + compiler/lowering/ets/setterLowering.cpp + compiler/lowering/ets/annotationCopyLowering.cpp + compiler/lowering/ets/annotationCopyPostLowering.cpp + compiler/lowering/ets/primitiveConversionPhase.cpp + compiler/lowering/ets/unboxLowering.cpp ir/astDump.cpp ir/srcDump.cpp ir/astNode.cpp @@ -336,6 +343,7 @@ set(ES2PANDA_LIB_SRC ir/base/decorator.cpp ir/base/metaProperty.cpp ir/base/methodDefinition.cpp + ir/base/overloadDeclaration.cpp ir/base/property.cpp ir/base/scriptFunction.cpp ir/base/scriptFunctionSignature.cpp @@ -423,6 +431,7 @@ set(ES2PANDA_LIB_SRC ir/as/namedType.cpp ir/as/prefixAssertionExpression.cpp ir/ets/etsClassLiteral.cpp + ir/ets/etsIntrinsicNode.cpp ir/ets/etsFunctionType.cpp ir/ets/etsKeyofType.cpp ir/ets/etsNewArrayInstanceExpression.cpp @@ -526,6 +535,7 @@ set(ES2PANDA_LIB_SRC parser/program/program.cpp parser/statementParser.cpp parser/statementTSParser.cpp + public/public.cpp checker/checker.cpp checker/checkerContext.cpp checker/ETSAnalyzer.cpp @@ -537,7 +547,6 @@ set(ES2PANDA_LIB_SRC checker/TSAnalyzer.cpp checker/TSAnalyzerUnreachable.cpp checker/JSchecker.cpp - checker/IsolatedDeclgenChecker.cpp checker/typeChecker/TypeChecker.cpp checker/ets/aliveAnalyzer.cpp checker/ets/etsWarningAnalyzer.cpp @@ -548,13 +557,10 @@ set(ES2PANDA_LIB_SRC checker/ets/castingContext.cpp checker/ets/conversion.cpp checker/ets/dynamic.cpp - checker/ets/dynamic/dynamicCall.cpp checker/ets/function.cpp checker/ets/validateHelpers.cpp checker/ets/typeCheckingHelpers.cpp checker/ets/helpers.cpp - checker/ets/narrowingConverter.cpp - checker/ets/narrowingWideningConverter.cpp checker/ets/object.cpp checker/ets/typeConverter.cpp checker/ets/typeCreation.cpp @@ -574,6 +580,7 @@ set(ES2PANDA_LIB_SRC checker/types/type.cpp checker/types/typeRelation.cpp checker/types/globalTypesHolder.cpp + checker/types/gradualType.cpp checker/types/ets/byteType.cpp checker/types/ets/charType.cpp checker/types/ets/doubleType.cpp @@ -581,9 +588,9 @@ set(ES2PANDA_LIB_SRC checker/types/ets/intType.cpp checker/types/ets/longType.cpp checker/types/ets/shortType.cpp + checker/types/ets/etsAnyType.cpp checker/types/ets/etsArrayType.cpp checker/types/ets/etsBooleanType.cpp - checker/types/ets/etsDynamicType.cpp checker/types/ets/etsEnumType.cpp checker/types/ets/etsExtensionFuncHelperType.cpp checker/types/ets/etsFunctionType.cpp @@ -642,8 +649,9 @@ set(ES2PANDA_LIB_SRC util/helpers.cpp util/importPathManager.cpp util/path.cpp + util/plugin.cpp + util/perfMetrics.cpp util/ustring.cpp - test/utils/panda_executable_path_getter.cpp evaluate/debugInfoDeserialization/debugInfoDeserializer.cpp evaluate/debugInfoDeserialization/inheritanceResolution.cpp evaluate/debugInfoDeserialization/methodBuilder.cpp @@ -682,9 +690,16 @@ panda_target_compile_options(es2panda-lib PRIVATE -fexceptions -Werror=shadow ) +if (EN_ISOLATED_DECLGEN) + message(STATUS "Isolated declgen enabled") + panda_target_compile_definitions(es2panda-lib + PRIVATE -DENABLE_ISOLATED_DECLGEN + ) +endif() + panda_target_link_libraries(es2panda-lib PUBLIC arkbase hmicuuc.z - PRIVATE arkassembler arkdisassembler arkfile + PRIVATE arkassembler arkdisassembler arkfile abc2program ) if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.1) OR diff --git a/ets2panda/REVIEWERS b/ets2panda/REVIEWERS index 8d77d323397036b4d93f79d93de652a9c8d5840c..9305160b98b4c953fad028c5484fbb8bdcb85cb0 100644 --- a/ets2panda/REVIEWERS +++ b/ets2panda/REVIEWERS @@ -14,16 +14,17 @@ * @gavin1012_hw @zhuoli72 .* @zhuoli72 @Prof1983 @igelhaus -/arkguard/ @zhangchen168 +/arkguard/ @xiao-peiyang /es2panda/ @gavin1012_hw /ets2panda/ @igelhaus @Prof1983 -/ets2panda/ast_verifier @mbolshov ^igelhaus ^Prof1983 +/ets2panda/aot @dkofanov @gavin1012_hw ^igelhaus ^Prof1983 +/ets2panda/ast_verifier @mbolshov @dkofanov ^yyang16 ^igelhaus ^Prof1983 /ets2panda/bindings ^igelhaus ^Prof1983 @dreamdoomwalker @Ascnbio ^muhammet-fevzi-bayiroglu @utkugursel /ets2panda/lexer @chernykhsergey @igelhaus ^zelentsovdmitry @Prof1983 /ets2panda/lsp ^igelhaus ^Prof1983 @dreamdoomwalker @Ascnbio ^muhammet-fevzi-bayiroglu @utkugursel /ets2panda/parser @chernykhsergey ^igelhaus ^Prof1983 -/ets2panda/public @mbolshov ^igelhaus ^Prof1983 -/ets2panda/test ^igelhaus ^Prof1983 +/ets2panda/public @mbolshov @yyang16 ^igelhaus ^Prof1983 +/ets2panda/test ^akmaevaleksey ^igelhaus ^Prof1983 /legacy_bin/ @ctw-ian /merge_abc/ @gavin1012_hw /test/ @gavin1012_hw @@ -32,43 +33,62 @@ /test262/*.py @shirunova_viktoria @gavin1012_hw @zhuheng27 /test262/ignored*.txt @shirunova_viktoria @gavin1012_hw @kuchkovairina @zhuheng27 /test_ecma_bcopt/ @gavin1012_hw -/ets2panda/checker/ETS*.* @zelentsovdmitry ^igelhaus ^Prof1983 @chernykhsergey -/ets2panda/checker/ETSAnalyzer.cpp @akmaevaleksey ^vpukhov ^igelhaus ^Prof1983 -/ets2panda/declgen_ets2ts/ @dreamdoomwalker ^trubachevilya ^ivagin ^hufeng20 ^igelhaus ^Prof1983 -/ets2panda/driver/ ^trubachevilya @dreamdoomwalker @chenqy930 @hufeng20 ^igelhaus ^Prof1983 -/ets2panda/linter/ @ragnvald @rosinskiyigor @eokolnov1 -/ets2panda/parser/ETSparser*.* @zelentsovdmitry ^igelhaus ^Prof1983 @chernykhsergey -/ets2panda/parser/expressionParser.cpp @zelentsovdmitry ^igelhaus ^Prof1983 @chernykhsergey -/ets2panda/parser/parser*.* @zelentsovdmitry ^igelhaus ^Prof1983 @chernykhsergey -/ets2panda/parser/statementParser.cpp @zelentsovdmitry ^igelhaus ^Prof1983 @chernykhsergey +/ets2panda/checker/ @akmaevaleksey @zelentsovdmitry ^lirismankarina ^igelhaus ^Prof1983 +/ets2panda/checker/ETS*.* @zelentsovdmitry ^igelhaus ^Prof1983 +/ets2panda/checker/ETSAnalyzer.cpp ^akmaevaleksey @Ekkoruse ^igelhaus ^Prof1983 +/ets2panda/checker/ETSAnalyzerHelpers.* @lirismankarina ^igelhaus ^Prof1983 +/ets2panda/compiler/ @xuxjeeee @gogabr ^igelhaus ^Prof1983 ^zelentsovdmitry +/ets2panda/declgen_ets2ts/ @dreamdoomwalker ^trubachevilya ^ivagin ^hufeng20 ^igelhaus ^Prof1983 @zenghang11 +/ets2panda/driver/ @trubachevilya @dreamdoomwalker ^chenqy930 ^hufeng20 ^igelhaus ^Prof1983 @zenghang11 +/ets2panda/ir/ @ziziziiziziz @gavin1012_hw ^igelhaus ^Prof1983 +/ets2panda/linter/ @ragnvald @rosinskiyigor @eokolnov1 @liwentao_uiw ^utkugursel +/ets2panda/parser/ @mkaskov ^igelhaus ^Prof1983 ^chernykhsergey ^zelentsovdmitry /ets2panda/scripts/*-build.sh @titovatatiana ^igelhaus ^Prof1983 /ets2panda/scripts/arkui* @titovatatiana ^igelhaus ^Prof1983 -/ets2panda/util/arktsconfig* @dreamdoomwalker ^trubachevilya ^igelhaus ^Prof1983 -/ets2panda/util/diagnostic* @chernykhsergey ^igelhaus ^Prof1983 -/ets2panda/util/importPathManager* @dreamdoomwalker ^trubachevilya ^igelhaus ^Prof1983 +/ets2panda/test/ast @mbolshov ^igelhaus ^Prof1983 +/ets2panda/test/depanalyzer @trubachevilya @dreamdoomwalker ^igelhaus ^Prof1983 +/ets2panda/test/srcdump @mbolshov ^igelhaus ^Prof1983 +/ets2panda/test/test-lists @igelhaus ^Prof1983 +/ets2panda/test/utils @mbolshov ^igelhaus ^Prof1983 +/ets2panda/util/ @mkaskov @dkofanov ^igelhaus ^Prof1983 +/ets2panda/util/arktsconfig* @dreamdoomwalker @trubachevilya ^igelhaus ^Prof1983 +/ets2panda/util/diagnostic* @chernykhsergey @mkaskov ^igelhaus ^Prof1983 +/ets2panda/util/importPathManager* @dreamdoomwalker @trubachevilya ^igelhaus ^Prof1983 +/ets2panda/util/plugin.* @yyang16 @mbolshov ^igelhaus ^Prof1983 +/ets2panda/varbinder/ @lirismankarina @akmaevaleksey ^Ekkoruse ^zelentsovdmitry ^igelhaus ^Prof1983 /test/workload/ignored*.txt @shirunova_viktoria @kuchkovairina @gavin1012_hw @zhuheng27 -/ets2panda/checker/ets/dynamic.cpp @akmaevaleksey ^vpukhov ^igelhaus ^Prof1983 /ets2panda/checker/ets/function.cpp ^vpukhov @gogabr ^igelhaus ^Prof1983 /ets2panda/checker/ets/helpers.cpp @zelentsovdmitry ^igelhaus ^Prof1983 /ets2panda/checker/ets/object.cpp @zelentsovdmitry ^vpukhov ^igelhaus ^Prof1983 /ets2panda/checker/types/ets @gogabr ^igelhaus ^Prof1983 @zelentsovdmitry /ets2panda/checker/types/signature.* ^vpukhov ^igelhaus ^Prof1983 @zelentsovdmitry -/ets2panda/checker/types/typeFlag.h ^vpukhov ^igelhaus ^Prof1983 @zelentsovdmitry -/ets2panda/checker/types/typeRelation.* ^vpukhov ^igelhaus ^Prof1983 @zelentsovdmitry -/ets2panda/compiler/core/ @zelentsovdmitry ^vpukhov ^igelhaus ^Prof1983 +/ets2panda/checker/types/typeFlag.h ^vpukhov ^igelhaus ^Prof1983 @mkaskov +/ets2panda/checker/types/typeRelation.* ^vpukhov ^igelhaus ^Prof1983 @mkaskov +/ets2panda/compiler/core/ @zelentsovdmitry @xuxjeeee ^vpukhov ^igelhaus ^Prof1983 +/ets2panda/compiler/core/compilerImpl.* @yyang16 @dkofanov ^xuxjeeee ^igelhaus ^Prof1983 +/ets2panda/compiler/lowering/phase.* @yyang16 ^mbolshov ^igelhaus ^Prof1983 +/ets2panda/compiler/lowering/plugin_phase.* @yyang16 ^mbolshov ^igelhaus ^Prof1983 +/ets2panda/compiler/lowering/util.* @yyang16 ^mbolshov ^igelhaus ^Prof1983 +/ets2panda/ir/ets/ @lirismankarina @xuxjeeee ^igelhaus ^Prof1983 +/ets2panda/ir/expressions/ @mkaskov @ziziziiziziz ^igelhaus ^Prof1983 +/ets2panda/ir/statements/ @dkofanov @Ekkoruse ^akmaevaleksey ^igelhaus ^Prof1983 +/ets2panda/ir/statements/annotation* @lirismankarina @xuxjeeee ^igelhaus ^Prof1983 /ets2panda/test/test-lists/astchecker @chernykhsergey ^igelhaus ^Prof1983 -/ets2panda/test/test-lists/declgenets2ts @dreamdoomwalker ^hufeng20 ^igelhaus ^Prof1983 +/ets2panda/test/test-lists/declgenets2ts @dreamdoomwalker ^hufeng20 ^igelhaus ^Prof1983 @zenghang11 /ets2panda/test/test-lists/parser @chernykhsergey ^igelhaus ^Prof1983 -/ets2panda/test/unit/lsp ^igelhaus ^Prof1983 @dreamdoomwalker @Ascnbio ^muhammet-fevzi-bayiroglu @utkugursel +/ets2panda/test/unit/arktsconfig-parser @trubachevilya @dreamdoomwalker ^igelhaus ^Prof1983 +/ets2panda/test/unit/lsp @dreamdoomwalker @utkugursel ^igelhaus ^Prof1983 +/ets2panda/test/unit/plugin* @mbolshov ^igelhaus ^Prof1983 +/ets2panda/test/unit/public @mbolshov ^igelhaus ^Prof1983 /ets2panda/checker/types/ets/Nullish.* ^vpukhov @gogabr ^igelhaus ^Prof1983 -/ets2panda/checker/types/ets/etsDynamicType.* ^vpukhov @gogabr ^igelhaus ^Prof1983 /ets2panda/checker/types/ets/etsFunctionType.* ^vpukhov @gogabr ^igelhaus ^Prof1983 +/ets2panda/checker/types/ets/etsN* @ziziziiziziz ^zelentsovdmitry ^igelhaus ^Prof1983 +/ets2panda/checker/types/ets/etsT* @xuxjeeee ^gogabr ^igelhaus ^Prof1983 /ets2panda/checker/types/ets/etsTypeParameter.* ^vpukhov @gogabr ^igelhaus ^Prof1983 -/ets2panda/checker/types/ets/etsUnionType.* @akmaevaleksey ^vpukhov @gogabr ^igelhaus ^Prof1983 +/ets2panda/checker/types/ets/etsUnionType.* @akmaevaleksey ^vpukhov ^igelhaus ^Prof1983 /ets2panda/checker/types/ets/wildcardType.* ^vpukhov @gogabr ^igelhaus ^Prof1983 /ets2panda/compiler/lowering/ets/ @akmaevaleksey ^igelhaus ^Prof1983 ^zelentsovdmitry /ets2panda/compiler/lowering/ets/lambdaLowering.cpp ^vpukhov @akmaevaleksey @gogabr ^igelhaus ^Prof1983 -/ets2panda/compiler/lowering/ets/localClassLowering.cpp @gogabr ^igelhaus ^Prof1983 /ets2panda/compiler/lowering/ets/optionalLowering.cpp ^vpukhov @akmaevaleksey ^igelhaus ^Prof1983 /ets2panda/compiler/lowering/ets/unionLowering.cpp ^vpukhov @akmaevaleksey ^igelhaus ^Prof1983 /ets2panda/compiler/lowering/ets/topLevelStmts/.* ^vpukhov @akmaevaleksey ^igelhaus ^Prof1983 diff --git a/ets2panda/aot/BUILD.gn b/ets2panda/aot/BUILD.gn index 2a76c53b3d2214e54eb8041d586d43d357d518bf..a3a533b320f2393e94521c43ace7559dde162b22 100644 --- a/ets2panda/aot/BUILD.gn +++ b/ets2panda/aot/BUILD.gn @@ -11,7 +11,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//arkcompiler/runtime_core/static_core/ark_config.gni") +if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + import("//arkcompiler/runtime_core/static_core/ark_config.gni") +} else { + import( + "//build/config/components/runtime_core/static_core/ark_common_config.gni") +} if (ark_standalone_build) { import("$build_root/ark.gni") @@ -26,16 +32,28 @@ ohos_executable("ets2panda") { "$target_gen_dir", "$target_gen_dir/include", ] + if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + configs = [ "$ark_root:ark_config" ] + } else { + configs = [ + "//build/config/components/runtime_core/static_core:ark_common_config", + ] + } + + if (ark_standalone_build || ark_static_standalone_build) { + configs += [ + "$ark_root/assembler:arkassembler_public_config", + "$ark_root/libpandafile:arkfile_public_config", + "$ark_root/libpandabase:arkbase_public_config", + "$ark_root/bytecode_optimizer:bytecodeopt_public_config", + "$ark_root/runtime:arkruntime_public_config", + "$ark_root/compiler:arkcompiler_public_config", + ] + } - configs = [ - "$ark_root:ark_config", - "$ark_root/assembler:arkassembler_public_config", - "$ark_es2panda_root:libes2panda_public_config", - "$ark_root/libpandafile:arkfile_public_config", - "$ark_root/libpandabase:arkbase_public_config", - "$ark_root/bytecode_optimizer:bytecodeopt_public_config", - "$ark_root/compiler:arkcompiler_public_config", - "$ark_root/runtime:arkruntime_public_config", + configs += [ + "$ark_es2panda_root:libes2panda_public_config" ] deps = [ @@ -57,9 +75,27 @@ ohos_executable("ets2panda") { "runtime_core:libarktsbytecodeopt_package", "runtime_core:libarktscompiler_package", "runtime_core:libarktsfile_package", + "runtime_core:libarktsabc2program_package", sdk_libc_secshared_dep, ] + if (!(ark_standalone_build || ark_static_standalone_build)) { + external_deps += [ + "runtime_core:assembler_headers", + "runtime_core:bytecode_optimizer_headers", + "runtime_core:libpandabase_headers", + "runtime_core:libpandafile_headers", + "runtime_core:runtime_gen_headers", + "runtime_core:runtime_headers", + "runtime_core:compiler_headers", + "runtime_core:verification_headers", + ] + } + + if (defined(ohos_indep_compiler_enable) && ohos_indep_compiler_enable) { + external_deps += [ "icu:shared_icuuc" ] + } + libs = platform_libs ldflags = platform_ldflags if (is_linux) { diff --git a/ets2panda/aot/main.cpp b/ets2panda/aot/main.cpp index 411df8364a29cccacefe03a517ccd368f2658b63..420240cb0ee8c3f829f32ba08e3e68afa017d0f0 100644 --- a/ets2panda/aot/main.cpp +++ b/ets2panda/aot/main.cpp @@ -24,6 +24,7 @@ #include "util/generateBin.h" #include "util/options.h" #include "util/plugin.h" +#include "util/perfMetrics.h" #include "libpandabase/os/stacktrace.h" #include "generated/diagnostic.h" @@ -100,8 +101,17 @@ static int CompileMultipleFiles(es2panda::Compiler &compiler, std::vector &parserInputs, unsigned int returnCode) +{ + for (auto *input : parserInputs) { + delete input; + } + parserInputs.clear(); + return returnCode; +} + +static int CompileFromConfig(es2panda::Compiler &compiler, util::Options *options, + util::DiagnosticEngine &diagnosticEngine) { auto compilationList = FindProjectSources(options->ArkTSConfig()); if (compilationList.empty()) { @@ -110,6 +120,7 @@ static unsigned int CompileFromConfig(es2panda::Compiler &compiler, util::Option } std::vector inputs {}; + std::vector parserInputs; unsigned int overallRes = 0; for (auto &[src, dst] : compilationList) { std::ifstream inputStream(src); @@ -119,14 +130,14 @@ static unsigned int CompileFromConfig(es2panda::Compiler &compiler, util::Option } std::stringstream ss; ss << inputStream.rdbuf(); - auto *parserInput = new std::string(ss.str()); + parserInputs.push_back(new std::string(ss.str())); inputStream.close(); - es2panda::SourceFile input(src, *parserInput, options->IsModule(), std::string_view(dst)); + es2panda::SourceFile input(src, *parserInputs.back(), options->IsModule(), std::string_view(dst)); inputs.push_back(input); } if (options->IsPermArena() && (options->GetExtension() == util::gen::extension::ETS)) { - return CompileMultipleFiles(compiler, inputs, options, diagnosticEngine); + return ReleaseInputsAndReturn(parserInputs, CompileMultipleFiles(compiler, inputs, options, diagnosticEngine)); } for (auto &input : inputs) { @@ -140,7 +151,7 @@ static unsigned int CompileFromConfig(es2panda::Compiler &compiler, util::Option overallRes |= static_cast(res); } } - return overallRes; + return ReleaseInputsAndReturn(parserInputs, overallRes); } static std::optional> InitializePlugins(std::vector const &names, @@ -165,6 +176,7 @@ static int Run(Span args) auto diagnosticEngine = util::DiagnosticEngine(); auto options = std::make_unique(args[0], diagnosticEngine); if (!options->Parse(args)) { + diagnosticEngine.FlushDiagnostic(); return 1; } diagnosticEngine.SetWError(options->IsEtsWarningsWerror()); @@ -175,6 +187,7 @@ static int Run(Span args) auto pluginsOpt = InitializePlugins(options->GetPlugins(), diagnosticEngine); if (!pluginsOpt.has_value()) { + diagnosticEngine.FlushDiagnostic(); return 1; } @@ -182,25 +195,32 @@ static int Run(Span args) if (options->IsListPhases()) { std::cerr << "Available phases:" << std::endl; std::cerr << compiler.GetPhasesList(); + diagnosticEngine.FlushDiagnostic(); return 1; } + int res; if (options->GetCompilationMode() == CompilationMode::PROJECT) { - return CompileFromConfig(compiler, options.get(), diagnosticEngine); - } - - std::string sourceFile; - std::string_view parserInput; - if (options->GetCompilationMode() == CompilationMode::GEN_STD_LIB) { - sourceFile = "etsstdlib.ets"; - parserInput = ""; + res = CompileFromConfig(compiler, options.get(), diagnosticEngine); } else { - sourceFile = options->SourceFileName(); - auto [buf, size] = options->CStrParserInputContents(); - parserInput = std::string_view(buf, size); + std::string sourceFile; + std::string_view parserInput; + if (options->GetCompilationMode() == CompilationMode::GEN_STD_LIB) { + sourceFile = "etsstdlib.ets"; + parserInput = ""; + } else { + sourceFile = options->SourceFileName(); + auto [buf, size] = options->CStrParserInputContents(); + parserInput = std::string_view(buf, size); + } + es2panda::SourceFile input(sourceFile, parserInput, options->IsModule(), options->GetOutput()); + res = CompileFromSource(compiler, input, *options.get(), diagnosticEngine); + } + if (options->IsDumpPerfMetrics()) { + util::DumpPerfMetrics(); } - es2panda::SourceFile input(sourceFile, parserInput, options->IsModule(), options->GetOutput()); - return CompileFromSource(compiler, input, *options.get(), diagnosticEngine); + diagnosticEngine.FlushDiagnostic(); + return res; } } // namespace ark::es2panda::aot diff --git a/ets2panda/ast_verifier/ASTVerifier.h b/ets2panda/ast_verifier/ASTVerifier.h index 9aaa1aecc3e55d08feea243f73b2f6329e0b46f7..1bd190ef7657372f5f3b05fa905c94602a9fbac7 100644 --- a/ets2panda/ast_verifier/ASTVerifier.h +++ b/ets2panda/ast_verifier/ASTVerifier.h @@ -129,7 +129,8 @@ public: i <= VerifierInvariants::AFTER_CHECKER_PHASE_LAST; i++) { allowed_[i] = true; } - // NOTE(dkofanov): This should be called after "NumberLowering" phase: + } + if (occurredPhaseName == "Unbox") { Get()->SetNumberLoweringOccured(); } if (occurredPhaseName == "UnionLowering") { diff --git a/ets2panda/ast_verifier/helpers.cpp b/ets2panda/ast_verifier/helpers.cpp index 13d55e496cb3a1ff72fa56415462b0b8b08664a9..a2179fc411ba0b24db631a82db400ba318fc1b32 100644 --- a/ets2panda/ast_verifier/helpers.cpp +++ b/ets2panda/ast_verifier/helpers.cpp @@ -19,6 +19,7 @@ #include "checker/types/type.h" #include "checker/types/ets/etsObjectType.h" #include "checker/types/ets/etsUnionType.h" +#include "checker/types/gradualType.h" #include "ir/statements/blockStatement.h" #include "ir/ets/etsModule.h" #include "parser/program/program.h" @@ -50,18 +51,17 @@ bool IsBooleanType(const ir::AstNode *ast) } auto typedAst = static_cast(ast); - if (typedAst->TsType() == nullptr) { return false; } - if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT) && - ast->HasBoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOXING_FLAG)) { - return typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_BOOLEAN); + auto type = + typedAst->TsType()->IsGradualType() ? typedAst->TsType()->AsGradualType()->GetBaseType() : typedAst->TsType(); + if (type->HasTypeFlag(checker::TypeFlag::ETS_OBJECT)) { + return type->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_BOOLEAN); } - return typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_BOOLEAN) || - typedAst->TsType()->HasTypeFlag(checker::TypeFlag::BOOLEAN_LIKE); + return type->HasTypeFlag(checker::TypeFlag::ETS_BOOLEAN) || type->HasTypeFlag(checker::TypeFlag::BOOLEAN_LIKE); } bool IsValidTypeForBinaryOp(const ir::AstNode *ast, bool isBitwise) @@ -75,30 +75,29 @@ bool IsValidTypeForBinaryOp(const ir::AstNode *ast, bool isBitwise) } auto typedAst = static_cast(ast); - if (typedAst->TsType() == nullptr) { return false; } + auto type = + typedAst->TsType()->IsGradualType() ? typedAst->TsType()->AsGradualType()->GetBaseType() : typedAst->TsType(); if (IsBooleanType(ast)) { return isBitwise; } - if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT) && - typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_BIGINT)) { + if (type->HasTypeFlag(checker::TypeFlag::ETS_OBJECT) && + type->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_BIGINT)) { return true; } - if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT) && - ast->HasBoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOXING_FLAG)) { - return typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_TYPE) && - !typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_BOOLEAN); + if (type->HasTypeFlag(checker::TypeFlag::ETS_OBJECT)) { + return type->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_TYPE) && + !type->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_BOOLEAN); } - return typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) || - typedAst->TsType()->HasTypeFlag(checker::TypeFlag::NUMBER_LITERAL) || - typedAst->TsType()->HasTypeFlag(checker::TypeFlag::BIGINT) || - typedAst->TsType()->HasTypeFlag(checker::TypeFlag::BIGINT_LITERAL); + return type->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) || + type->HasTypeFlag(checker::TypeFlag::NUMBER_LITERAL) || type->HasTypeFlag(checker::TypeFlag::BIGINT) || + type->HasTypeFlag(checker::TypeFlag::BIGINT_LITERAL); } bool IsStringType(const ir::AstNode *ast) @@ -112,17 +111,18 @@ bool IsStringType(const ir::AstNode *ast) } auto typedAst = static_cast(ast); - if (typedAst->TsType() == nullptr) { return false; } - if (typedAst->TsType()->HasTypeFlag(checker::TypeFlag::ETS_OBJECT)) { - return typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::STRING) || - typedAst->TsType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_STRING); + auto type = + typedAst->TsType()->IsGradualType() ? typedAst->TsType()->AsGradualType()->GetBaseType() : typedAst->TsType(); + if (type->HasTypeFlag(checker::TypeFlag::ETS_OBJECT)) { + return type->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::STRING) || + type->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_STRING); } - return typedAst->TsType()->HasTypeFlag(checker::TypeFlag::STRING_LIKE); + return type->HasTypeFlag(checker::TypeFlag::STRING_LIKE); } bool IsVisibleInternalNode(const ir::AstNode *ast, const ir::AstNode *objTypeDeclNode) @@ -156,7 +156,8 @@ const checker::Type *GetClassDefinitionType(const ir::AstNode *ast) return nullptr; } auto *classDefinition = tmpNode->AsClassDefinition(); - return classDefinition->TsType(); + return classDefinition->TsType()->IsGradualType() ? classDefinition->TsType()->AsGradualType()->GetBaseType() + : classDefinition->TsType(); } const checker::Type *GetTSInterfaceDeclarationType(const ir::AstNode *ast) @@ -169,7 +170,9 @@ const checker::Type *GetTSInterfaceDeclarationType(const ir::AstNode *ast) return nullptr; } auto *tsInterfaceDeclaration = tmpNode->AsTSInterfaceDeclaration(); - return tsInterfaceDeclaration->TsType(); + return tsInterfaceDeclaration->TsType()->IsGradualType() + ? tsInterfaceDeclaration->TsType()->AsGradualType()->GetBaseType() + : tsInterfaceDeclaration->TsType(); } bool ValidateMethodAccessForClass(const ir::AstNode *ast, const ir::AstNode *ownerSignDeclNode, @@ -325,8 +328,8 @@ bool ValidateMethodAccess(const ir::MemberExpression *memberExpression, const ir } if (memberObjType->HasObjectFlag(checker::ETSObjectFlags::RESOLVED_SUPER) && memberObjType->SuperType() != nullptr && - memberObjType->SuperType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_TYPE | - checker::ETSObjectFlags::GLOBAL)) { + memberObjType->SuperType()->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::BUILTIN_TYPE | + checker::ETSObjectFlags::GLOBAL)) { return true; } const auto *memberObjTypeDeclNode = memberObjType->GetDeclNode(); diff --git a/ets2panda/ast_verifier/invariants/arithmeticOperationValid.cpp b/ets2panda/ast_verifier/invariants/arithmeticOperationValid.cpp index bb77859aed5faaa10db8e382b720112625617808..bf6ab126463ef72bdd5fcff959bce8227691f80f 100644 --- a/ets2panda/ast_verifier/invariants/arithmeticOperationValid.cpp +++ b/ets2panda/ast_verifier/invariants/arithmeticOperationValid.cpp @@ -19,7 +19,7 @@ #include "ir/ts/tsInterfaceDeclaration.h" #include "ir/ts/tsEnumDeclaration.h" #include "ir/ts/tsInterfaceBody.h" -#include "../helpers.h" +#include "ast_verifier/helpers.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/arithmeticOperationValid.h b/ets2panda/ast_verifier/invariants/arithmeticOperationValid.h index 1afed1ea7fb3564257f089b7ccda30e024f3bbd2..ba478d93ecc064ff547ac87b49e9e25f7581289d 100644 --- a/ets2panda/ast_verifier/invariants/arithmeticOperationValid.h +++ b/ets2panda/ast_verifier/invariants/arithmeticOperationValid.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_ARITHMETICOPERATIONVALID_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_ARITHMETICOPERATIONVALID_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/checkAbstractMethod.h b/ets2panda/ast_verifier/invariants/checkAbstractMethod.h index d2534f5483ea3017becd4dd6108ce2d7d4efde2a..174a685564664f5fa77352c57287319530a1a39b 100644 --- a/ets2panda/ast_verifier/invariants/checkAbstractMethod.h +++ b/ets2panda/ast_verifier/invariants/checkAbstractMethod.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKABSTRACTMETHOD_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKABSTRACTMETHOD_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/checkConstProperties.h b/ets2panda/ast_verifier/invariants/checkConstProperties.h index 379e446e7a90a5c09a018c1be19cf2a41f616c09..a4a042b1212389809609131311f4f1504535df00 100644 --- a/ets2panda/ast_verifier/invariants/checkConstProperties.h +++ b/ets2panda/ast_verifier/invariants/checkConstProperties.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKCONSTPROPERTIES_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKCONSTPROPERTIES_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/checkScopeDeclaration.h b/ets2panda/ast_verifier/invariants/checkScopeDeclaration.h index f7766ab0b8370e8bb76bbada509f4aec9589033d..1137ee9848c28dc9418a75da18189c88b6a979a4 100644 --- a/ets2panda/ast_verifier/invariants/checkScopeDeclaration.h +++ b/ets2panda/ast_verifier/invariants/checkScopeDeclaration.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKSCOPEDECLARATION_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKSCOPEDECLARATION_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/checkStructDeclaration.h b/ets2panda/ast_verifier/invariants/checkStructDeclaration.h index 931279a83c25db407b4612749cf19ec4b4849ee6..aa6d9ffe53e9dfe000c59308e950b81569f70848 100644 --- a/ets2panda/ast_verifier/invariants/checkStructDeclaration.h +++ b/ets2panda/ast_verifier/invariants/checkStructDeclaration.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKSTRUCTDECLARATION_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_CHECKSTRUCTDECLARATION_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/everyChildHasValidParent.h b/ets2panda/ast_verifier/invariants/everyChildHasValidParent.h index d18220f781f94a2e7563cdc420aca729529d7714..a2a3070c25b20d307a04d462dc0904490e2fbdc2 100644 --- a/ets2panda/ast_verifier/invariants/everyChildHasValidParent.h +++ b/ets2panda/ast_verifier/invariants/everyChildHasValidParent.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_EVERYCHILDHASVALIDPARENT_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_EVERYCHILDHASVALIDPARENT_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/everyChildInParentRange.h b/ets2panda/ast_verifier/invariants/everyChildInParentRange.h index c3406de3e0b04c9285e9b1b5dc8c4abb2ff482e2..fa25a4654465dc45f4304593faf99b1b32f2a6af 100644 --- a/ets2panda/ast_verifier/invariants/everyChildInParentRange.h +++ b/ets2panda/ast_verifier/invariants/everyChildInParentRange.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_EVERYCHILDINPARENTRANGE_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_EVERYCHILDINPARENTRANGE_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/forLoopCorrectlyInitialized.h b/ets2panda/ast_verifier/invariants/forLoopCorrectlyInitialized.h index 15c3e45451cf0457a420023a642fbadd4140f302..ea2fa365dd30501f0cd0cb33c8340796e660956b 100644 --- a/ets2panda/ast_verifier/invariants/forLoopCorrectlyInitialized.h +++ b/ets2panda/ast_verifier/invariants/forLoopCorrectlyInitialized.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_FORLOOPCORRECTLYINITIALIZED_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_FORLOOPCORRECTLYINITIALIZED_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/getterSetterValidation.h b/ets2panda/ast_verifier/invariants/getterSetterValidation.h index 4f4b1d4aed1ca3c3c5f867e857d62e619cb102f0..9d6bd4f22121c8a260a0d4c52f8f110a992fe170 100644 --- a/ets2panda/ast_verifier/invariants/getterSetterValidation.h +++ b/ets2panda/ast_verifier/invariants/getterSetterValidation.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_GETTERSETTERVALIDATION_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_GETTERSETTERVALIDATION_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/identifierHasVariable.cpp b/ets2panda/ast_verifier/invariants/identifierHasVariable.cpp index 930ac3249abec15f18214163607aa72b5c6a036b..4eae5c316c003fd8e3545f5390611a2bd0418a13 100644 --- a/ets2panda/ast_verifier/invariants/identifierHasVariable.cpp +++ b/ets2panda/ast_verifier/invariants/identifierHasVariable.cpp @@ -25,8 +25,8 @@ public: ExceptionsMatcher(const IdentifierHasVariable *inv, const ir::Identifier *ast) : inv_(inv), ast_(ast) {} bool Match() { - auto res = IsLengthProp() || IsEmptyName() || IsInObjectExpr() || IsInPackageDecl() || IsUtilityType() || - IsUnionMemberAccess() || IsFixedArrayType(); + auto res = IsLengthProp() || IsEmptyName() || IsInObjectExpr() || IsInPackageDecl() || IsBuiltinType() || + IsUnionMemberAccess(); return res; } @@ -69,16 +69,13 @@ private: return false; } - bool IsUtilityType() + bool IsBuiltinType() { + auto name = ast_->Name(); // NOTE(mmartin): find a better solution to handle utility type resolution - return ast_->Name().Is(Signatures::PARTIAL_TYPE_NAME) || ast_->Name().Is(Signatures::REQUIRED_TYPE_NAME) || - ast_->Name().Is(Signatures::READONLY_TYPE_NAME); - } - - bool IsFixedArrayType() - { - return ast_->Name().Is(Signatures::FIXED_ARRAY_TYPE_NAME); + return name.Is(Signatures::PARTIAL_TYPE_NAME) || name.Is(Signatures::REQUIRED_TYPE_NAME) || + name.Is(Signatures::READONLY_TYPE_NAME) || name.Is(Signatures::FIXED_ARRAY_TYPE_NAME) || + name.Is(compiler::Signatures::ANY_TYPE_NAME); } bool IsUnionMemberAccess() diff --git a/ets2panda/ast_verifier/invariants/identifierHasVariable.h b/ets2panda/ast_verifier/invariants/identifierHasVariable.h index 8fc17ff9bba58291a17e394043688350b22342f1..72f9d271903f2d9c8246248651cea73ff2ad392f 100644 --- a/ets2panda/ast_verifier/invariants/identifierHasVariable.h +++ b/ets2panda/ast_verifier/invariants/identifierHasVariable.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_IDENTIFIERHASVARIABLE_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_IDENTIFIERHASVARIABLE_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" #include "ir/expressions/identifier.h" diff --git a/ets2panda/ast_verifier/invariants/importExportAccessValid.cpp b/ets2panda/ast_verifier/invariants/importExportAccessValid.cpp index bf7351956a7b3bae812a360c9c28f6a777633fae..d865ebe9c913cab99f60c8b6be357d8bb9ff4c90 100644 --- a/ets2panda/ast_verifier/invariants/importExportAccessValid.cpp +++ b/ets2panda/ast_verifier/invariants/importExportAccessValid.cpp @@ -14,7 +14,7 @@ */ #include "importExportAccessValid.h" -#include "../helpers.h" +#include "ast_verifier/helpers.h" #include "ir/expressions/callExpression.h" #include "checker/types/ets/etsObjectType.h" #include "ir/module/importSpecifier.h" @@ -78,13 +78,6 @@ bool ImportExportAccessValid::InvariantImportExportMethod(const std::unordered_s const ir::AstNode *callExpr, util::StringView name) { auto *signature = callExpr->AsCallExpression()->Signature(); - if (signature == nullptr || signature->Owner() == nullptr) { - // NOTE(vpukhov): Add a synthetic owner for dynamic signatures - ES2PANDA_ASSERT( - callExpr->AsCallExpression()->Callee()->TsType()->HasTypeFlag(checker::TypeFlag::ETS_DYNAMIC_FLAG)); - return true; - } - if (signature != nullptr && varCallee->Declaration() != nullptr && varCallee->Declaration()->Node() != nullptr && !IsContainedIn(varCallee->Declaration()->Node(), signature->Owner()->GetDeclNode()) && varCallee->Declaration()->Node() != signature->Owner()->GetDeclNode()) { diff --git a/ets2panda/ast_verifier/invariants/importExportAccessValid.h b/ets2panda/ast_verifier/invariants/importExportAccessValid.h index 7977ee3a56e9059fec269c1bc737b4122cf94bf6..1eaf3cb642f7e24867e7d38924b43e4ca0a11fbf 100644 --- a/ets2panda/ast_verifier/invariants/importExportAccessValid.h +++ b/ets2panda/ast_verifier/invariants/importExportAccessValid.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_IMPORTEXPORTACCESSVALID_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_IMPORTEXPORTACCESSVALID_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/modifierAccessValid.cpp b/ets2panda/ast_verifier/invariants/modifierAccessValid.cpp index 58ce2de70a8439b4446c9198aa3a03bd1de71147..7f8875f7a9a3ca63873ae1d15b0ea23875505acb 100644 --- a/ets2panda/ast_verifier/invariants/modifierAccessValid.cpp +++ b/ets2panda/ast_verifier/invariants/modifierAccessValid.cpp @@ -14,7 +14,7 @@ */ #include "modifierAccessValid.h" -#include "../helpers.h" +#include "ast_verifier/helpers.h" #include "varbinder/variableFlags.h" #include "ir/expressions/memberExpression.h" #include "ir/expressions/callExpression.h" diff --git a/ets2panda/ast_verifier/invariants/modifierAccessValid.h b/ets2panda/ast_verifier/invariants/modifierAccessValid.h index a5fe690286f0f832a3e92b8a55a558cc8be340b4..5889a24cb725fc596c25d1e2e93abbe8c8f32456 100644 --- a/ets2panda/ast_verifier/invariants/modifierAccessValid.h +++ b/ets2panda/ast_verifier/invariants/modifierAccessValid.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_MODIFIERACCESSVALID_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_MODIFIERACCESSVALID_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/nodeHasParent.h b/ets2panda/ast_verifier/invariants/nodeHasParent.h index c3f583c8d9b7cc72bbe2bdec15904481e9817b95..f5a77f9a3e09b316bf68b22e5cc50f9ebfd6ba13 100644 --- a/ets2panda/ast_verifier/invariants/nodeHasParent.h +++ b/ets2panda/ast_verifier/invariants/nodeHasParent.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_NODEHASPARENT_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_NODEHASPARENT_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/nodeHasSourceRange.h b/ets2panda/ast_verifier/invariants/nodeHasSourceRange.h index fed802ecb7d531d87106868fedb7def3bebbd026..a797369d03867595e09ca1f1fe4d9cb40b428e1b 100644 --- a/ets2panda/ast_verifier/invariants/nodeHasSourceRange.h +++ b/ets2panda/ast_verifier/invariants/nodeHasSourceRange.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_NODEHASSOURCERANGE_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_NODEHASSOURCERANGE_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/nodeHasType.cpp b/ets2panda/ast_verifier/invariants/nodeHasType.cpp index 4cfa95f5ca829f7252625b4821008f7f71411770..a269292f9f5a330eba313720803c4c29fe209b32 100644 --- a/ets2panda/ast_verifier/invariants/nodeHasType.cpp +++ b/ets2panda/ast_verifier/invariants/nodeHasType.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "../helpers.h" +#include "ast_verifier/helpers.h" #include "nodeHasType.h" #include "ir/base/classDefinition.h" #include "ir/base/methodDefinition.h" @@ -38,7 +38,8 @@ public: { return nulltypeNode_->IsIdentifier() || MatchFunctionExpression() || nulltypeNode_->IsTSClassImplements() || nulltypeNode_->IsSpreadElement() || nulltypeNode_->IsTSThisType() || nulltypeNode_->IsETSNullType() || - nulltypeNode_->IsStringLiteral() || AnyChildStringLiteral(); + nulltypeNode_->IsStringLiteral() || AnyChildStringLiteral() || nulltypeNode_->IsOverloadDeclaration() || + nulltypeNode_->IsProperty(); } auto ShouldSkipSubtree() const diff --git a/ets2panda/ast_verifier/invariants/nodeHasType.h b/ets2panda/ast_verifier/invariants/nodeHasType.h index 81769166cf67988b5c87153d932072722614aca2..c48d97ce8095479c72c9335c9ee02d918353aac1 100644 --- a/ets2panda/ast_verifier/invariants/nodeHasType.h +++ b/ets2panda/ast_verifier/invariants/nodeHasType.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_NODEHASTYPE_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_NODEHASTYPE_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" #include "checker/types/type.h" namespace ark::es2panda::compiler::ast_verifier { @@ -49,7 +49,8 @@ public: if (type == nullptr) { return {CheckDecision::CORRECT, CheckAction::CONTINUE}; } - if (!numberLoweringOccurred_ && type->IsETSPrimitiveType()) { + // NOTE(dkofanov): Broken extension functions. + if (!numberLoweringOccurred_ && !type->IsETSExtensionFuncHelperType() && type->IsETSPrimitiveType()) { AddCheckMessage("PRIMITIVE_BEFORE_LOWERING", *ast); return {CheckDecision::INCORRECT, CheckAction::CONTINUE}; } diff --git a/ets2panda/ast_verifier/invariants/referenceTypeAnnotationIsNull.h b/ets2panda/ast_verifier/invariants/referenceTypeAnnotationIsNull.h index e0e7bcaf36f3583d834edf86ef9372a467920f48..562cc47cb18bdc5215a4513bda732e3b479f1c14 100644 --- a/ets2panda/ast_verifier/invariants/referenceTypeAnnotationIsNull.h +++ b/ets2panda/ast_verifier/invariants/referenceTypeAnnotationIsNull.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_REFERENCETYPEANNOTATIONISNULL_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_REFERENCETYPEANNOTATIONISNULL_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/sequenceExpressionHasLastType.h b/ets2panda/ast_verifier/invariants/sequenceExpressionHasLastType.h index c39f50507244ae115b4c818cee22b899a8daface..7b4f0760cbf77bcc1cf48b68eaefb77467ae2e13 100644 --- a/ets2panda/ast_verifier/invariants/sequenceExpressionHasLastType.h +++ b/ets2panda/ast_verifier/invariants/sequenceExpressionHasLastType.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_SEQUENCEEXPRESSIONHASLASTTYPE_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_SEQUENCEEXPRESSIONHASLASTTYPE_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.cpp b/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.cpp index 1aa6f1abf062c4b37663c31cb50160668839ef1a..08ae83ddcbbfc6f587371a7b93c306f0e8cd9491 100644 --- a/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.cpp +++ b/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.cpp @@ -15,7 +15,7 @@ #include "variableHasEnclosingScope.h" #include "variableHasScope.h" -#include "../helpers.h" +#include "ast_verifier/helpers.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.h b/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.h index 5d0cf636988ba868da9edffb947b4f22d6c8520f..fa75e280f00225ea0eb15b2ce99c99f252bcfe59 100644 --- a/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.h +++ b/ets2panda/ast_verifier/invariants/variableHasEnclosingScope.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_VARIABLEHASENCLOSINGSCOPE_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_VARIABLEHASENCLOSINGSCOPE_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/ast_verifier/invariants/variableHasScope.cpp b/ets2panda/ast_verifier/invariants/variableHasScope.cpp index 0e072bf3845a13c8cda5f40a7d28c8ad2923d890..9b18ba8289d4d4a1a03daeedead8c049c92d4d73 100644 --- a/ets2panda/ast_verifier/invariants/variableHasScope.cpp +++ b/ets2panda/ast_verifier/invariants/variableHasScope.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "../helpers.h" +#include "ast_verifier/helpers.h" #include "variableHasScope.h" #include "ir/base/scriptFunction.h" #include "ir/ts/tsEnumDeclaration.h" diff --git a/ets2panda/ast_verifier/invariants/variableHasScope.h b/ets2panda/ast_verifier/invariants/variableHasScope.h index 41d067774e285f773fc3c74c63f29a431abb515a..a6c7741c94677e9dcd630ef135ac1b1a0989069b 100644 --- a/ets2panda/ast_verifier/invariants/variableHasScope.h +++ b/ets2panda/ast_verifier/invariants/variableHasScope.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_VARIABLEHASSCOPE_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_VARIABLEHASSCOPE_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" #include "varbinder/varbinder.h" diff --git a/ets2panda/ast_verifier/invariants/variableNameIdentifierNameSame.h b/ets2panda/ast_verifier/invariants/variableNameIdentifierNameSame.h index 5eb9e85e2162d29c4f8d695879da3c12cc63d44d..211c166828bcfc0c26dd1310fbc857d0fe2bebf2 100644 --- a/ets2panda/ast_verifier/invariants/variableNameIdentifierNameSame.h +++ b/ets2panda/ast_verifier/invariants/variableNameIdentifierNameSame.h @@ -16,7 +16,7 @@ #ifndef ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_VARIABLENAMEIDENTIFIERNAMESAME_H #define ES2PANDA_COMPILER_CORE_AST_VERIFIER_INVARIANTS_VARIABLENAMEIDENTIFIERNAMESAME_H -#include "../invariantBase.h" +#include "ast_verifier/invariantBase.h" namespace ark::es2panda::compiler::ast_verifier { diff --git a/ets2panda/bindings/BUILD.gn b/ets2panda/bindings/BUILD.gn index e6dbc5c5f4c3b2c6b686a994dcb23a4d4493a693..a6f48462abf2b042df65d9c0eefb692587a09565 100644 --- a/ets2panda/bindings/BUILD.gn +++ b/ets2panda/bindings/BUILD.gn @@ -11,7 +11,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//arkcompiler/runtime_core/static_core/ark_config.gni") +if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + import("//arkcompiler/runtime_core/static_core/ark_config.gni") +} else { + import( + "//build/config/components/runtime_core/static_core/ark_common_config.gni") +} + if (ark_standalone_build) { import("$build_root/ark.gni") } else { @@ -22,14 +29,20 @@ npm_path = "//prebuilts/build-tools/common/nodejs/current/bin/npm" shared_library("ts_bindings") { sources = [ - "./native/src/callback-resource.cpp", "./native/src/common-interop.cpp", "./native/src/convertors-napi.cpp", "./native/src/lsp.cpp", ] + if ((defined(ark_standalone_build) && ark_standalone_build) || + (defined(ark_static_standalone_build) && ark_static_standalone_build)) { + configs += [ "$ark_root:ark_config" ] + } else { + configs += [ + "//build/config/components/runtime_core/static_core:ark_common_config", + ] + } configs += [ "$ark_root/assembler:arkassembler_public_config", - "$ark_root:ark_config", "../:libes2panda_public_config", "../:libes2panda_config", "$ark_root/libpandabase:arkbase_public_config", @@ -184,7 +197,6 @@ shared_library("ts_bindings") { shared_library("public") { sources = [ "./native/src/bridges.cpp", - "./native/src/callback-resource.cpp", "./native/src/common-interop.cpp", "./native/src/common.cpp", "./native/src/convertors-napi.cpp", @@ -339,24 +351,33 @@ action("build_bindings") { ":ts_bindings", ] sources = [ - "./src/Es2pandaNativeModule.ts", - "./src/InteropNativeModule.ts", - "./src/InteropTypes.ts", - "./src/Platform.ts", - "./src/Wrapper.ts", - "./src/arrays.ts", - "./src/generated/Es2pandaEnums.ts", - "./src/generated/Es2pandaNativeModule.ts", - "./src/global.ts", - "./src/index.ts", - "./src/loadLibraries.ts", - "./src/lspNode.ts", - "./src/mainWrapper.ts", - "./src/private.ts", - "./src/strings.ts", - "./src/ts-reflection.ts", - "./src/types.ts", - "./src/utils.ts", + "src/common/Es2pandaNativeModule.ts", + "src/common/InteropNativeModule.ts", + "src/common/InteropTypes.ts", + "src/common/Platform.ts", + "src/common/Wrapper.ts", + "src/common/arrays.ts", + "src/common/driver_helper.ts", + "src/common/global.ts", + "src/common/loadLibraries.ts", + "src/common/mainWrapper.ts", + "src/common/preDefine.ts", + "src/common/private.ts", + "src/common/strings.ts", + "src/common/ts-reflection.ts", + "src/common/types.ts", + "src/common/ui_plugins_driver.ts", + "src/common/utils.ts", + "src/common/arkTSConfigGenerator.ts", + "src/generated/Es2pandaEnums.ts", + "src/generated/Es2pandaNativeModule.ts", + "src/index.ts", + "src/lsp/compile_thread_worker.ts", + "src/lsp/generateArkTSConfig.ts", + "src/lsp/generateBuildConfig.ts", + "src/lsp/index.ts", + "src/lsp/lspNode.ts", + "src/lsp/lsp_helper.ts", ] script = "build_bindings.py" diff --git a/ets2panda/bindings/native/src/bridges.cpp b/ets2panda/bindings/native/src/bridges.cpp index 2757d4b9efc5081982efaa7c6d2959a303405bd9..b4f7bfdc24a1c97389df0e12cfda66fb76eaa250 100644 --- a/ets2panda/bindings/native/src/bridges.cpp +++ b/ets2panda/bindings/native/src/bridges.cpp @@ -37,13 +37,13 @@ KNativePointer impl_CreateContextFromString(KNativePointer configPtr, KStringPtr TS_INTEROP_3(CreateContextFromString, KNativePointer, KNativePointer, KStringPtr, KStringPtr) KInt impl_GenerateTsDeclarationsFromContext(KNativePointer contextPtr, KStringPtr &outputDeclEts, KStringPtr &outputEts, - KBoolean exportAll) + KBoolean exportAll, KBoolean isolated) { auto context = reinterpret_cast(contextPtr); - return static_cast(GetPublicImpl()->GenerateTsDeclarationsFromContext(context, outputDeclEts.data(), - outputEts.data(), exportAll != 0)); + return static_cast(GetPublicImpl()->GenerateTsDeclarationsFromContext( + context, outputDeclEts.data(), outputEts.data(), exportAll != 0, isolated != 0)); } -TS_INTEROP_4(GenerateTsDeclarationsFromContext, KInt, KNativePointer, KStringPtr, KStringPtr, KBoolean) +TS_INTEROP_5(GenerateTsDeclarationsFromContext, KInt, KNativePointer, KStringPtr, KStringPtr, KBoolean, KBoolean) KNativePointer impl_CreateContextFromFile(KNativePointer configPtr, KStringPtr &filenamePtr) { @@ -66,3 +66,10 @@ KNativePointer impl_ContextErrorMessage(KNativePointer contextPtr) return new std::string(GetPublicImpl()->ContextErrorMessage(context)); } TS_INTEROP_1(ContextErrorMessage, KNativePointer, KNativePointer) + +KNativePointer impl_GetAllErrorMessages(KNativePointer contextPtr) +{ + auto context = reinterpret_cast(contextPtr); + return new std::string(GetPublicImpl()->GetAllErrorMessages(context)); +} +TS_INTEROP_1(GetAllErrorMessages, KNativePointer, KNativePointer) diff --git a/ets2panda/bindings/native/src/common.cpp b/ets2panda/bindings/native/src/common.cpp index 78f051246e1ae3d1ab4313b6e2f5dc18a2581b35..7bc499ea450df7025d1792365cdbe0873ca271e2 100644 --- a/ets2panda/bindings/native/src/common.cpp +++ b/ets2panda/bindings/native/src/common.cpp @@ -131,4 +131,79 @@ KNativePointer impl_DestroyContext(KNativePointer contextPtr) } TS_INTEROP_1(DestroyContext, KNativePointer, KNativePointer) +void impl_MemInitialize(KStringPtr &pandaLibPath) +{ + g_pandaLibPath = GetStringView(pandaLibPath); + GetPublicImpl()->MemInitialize(); +} +TS_INTEROP_V1(MemInitialize, KStringPtr) + +void impl_MemFinalize() +{ + GetPublicImpl()->MemFinalize(); +} +TS_INTEROP_V0(MemFinalize) + +KNativePointer impl_CreateGlobalContext(KNativePointer configPtr, KStringArray externalFileListPtr, KInt fileNum) +{ + auto config = reinterpret_cast(configPtr); + + const std::size_t headerLen = 4; + if (fileNum <= 0) { + return nullptr; + } + const char **externalFileList = new const char *[fileNum]; + std::size_t position = headerLen; + std::size_t strLen; + for (std::size_t i = 0; i < static_cast(fileNum); ++i) { + strLen = UnpackUInt(externalFileListPtr + position); + position += headerLen; + externalFileList[i] = + strdup(std::string(reinterpret_cast(externalFileListPtr + position), strLen).c_str()); + position += strLen; + } + + return GetPublicImpl()->CreateGlobalContext(config, externalFileList, fileNum, true); +} +TS_INTEROP_3(CreateGlobalContext, KNativePointer, KNativePointer, KStringArray, KInt) + +void impl_DestroyGlobalContext(KNativePointer globalContextPtr) +{ + auto context = reinterpret_cast(globalContextPtr); + GetPublicImpl()->DestroyGlobalContext(context); +} +TS_INTEROP_V1(DestroyGlobalContext, KNativePointer) + +KNativePointer impl_CreateCacheContextFromString(KNativePointer configPtr, KStringPtr &sourcePtr, + KStringPtr &filenamePtr, KNativePointer globalContext, + KBoolean isExternal) +{ + auto config = reinterpret_cast(configPtr); + auto context = reinterpret_cast(globalContext); + return GetPublicImpl()->CreateCacheContextFromString(config, sourcePtr.data(), filenamePtr.data(), context, + isExternal); +} +TS_INTEROP_5(CreateCacheContextFromString, KNativePointer, KNativePointer, KStringPtr, KStringPtr, KNativePointer, + KBoolean) + +void impl_RemoveFileCache(KNativePointer globalContextPtr, KStringPtr &filenamePtr) +{ + auto context = reinterpret_cast(globalContextPtr); + return GetPublicImpl()->RemoveFileCache(context, filenamePtr.data()); +} +TS_INTEROP_V2(RemoveFileCache, KNativePointer, KStringPtr) + +void impl_AddFileCache(KNativePointer globalContextPtr, KStringPtr &filenamePtr) +{ + auto context = reinterpret_cast(globalContextPtr); + return GetPublicImpl()->AddFileCache(context, filenamePtr.data()); +} +TS_INTEROP_V2(AddFileCache, KNativePointer, KStringPtr) + +void impl_InvalidateFileCache(KNativePointer globalContextPtr, KStringPtr &filenamePtr) +{ + auto context = reinterpret_cast(globalContextPtr); + return GetPublicImpl()->InvalidateFileCache(context, filenamePtr.data()); +} +TS_INTEROP_V2(InvalidateFileCache, KNativePointer, KStringPtr) // NOLINTEND diff --git a/ets2panda/bindings/native/src/lsp.cpp b/ets2panda/bindings/native/src/lsp.cpp index a74ee5ae805bb827e2a30cb215af6fa3861b3af5..95a5fd779514ee81c73ddd7ad7b24dc1c6bba506 100644 --- a/ets2panda/bindings/native/src/lsp.cpp +++ b/ets2panda/bindings/native/src/lsp.cpp @@ -15,20 +15,19 @@ #include "convertors-napi.h" #include "lsp/include/api.h" -#include "lsp/include/completions.h" #include "common.h" #include "panda_types.h" #include "public/es2panda_lib.h" - +#include "lsp/include/refactors/refactor_types.h" #include -#include #include -#include namespace { using ark::es2panda::lsp::ClassHierarchy; using ark::es2panda::lsp::ClassHierarchyInfo; +using ark::es2panda::lsp::ClassHierarchyItem; using ark::es2panda::lsp::ClassMethodItem; +using ark::es2panda::lsp::ClassPropertyItem; } // namespace char *GetStringCopy(KStringPtr &ptr) @@ -63,6 +62,198 @@ KNativePointer impl_getClassPropertyInfo(KNativePointer context, KInt position, } TS_INTEROP_3(getClassPropertyInfo, KNativePointer, KNativePointer, KInt, KBoolean) +KNativePointer impl_getRenameLocationFileName(KNativePointer renameLocationPtr) +{ + auto *renameLocationRef = reinterpret_cast(renameLocationPtr); + return &renameLocationRef->fileName; +} +TS_INTEROP_1(getRenameLocationFileName, KNativePointer, KNativePointer) + +KNativePointer impl_getRenameLocationPrefixText(KNativePointer renameLocationPtr) +{ + auto *renameLocationRef = reinterpret_cast(renameLocationPtr); + return new std::string(renameLocationRef->prefixText); +} +TS_INTEROP_1(getRenameLocationPrefixText, KNativePointer, KNativePointer) + +KNativePointer impl_getRenameLocationSuffixText(KNativePointer renameLocationPtr) +{ + auto *renameLocationRef = reinterpret_cast(renameLocationPtr); + return new std::string(renameLocationRef->suffixText); +} +TS_INTEROP_1(getRenameLocationSuffixText, KNativePointer, KNativePointer) + +KInt impl_getRenameLocationStart(KNativePointer renameLocationPtr) +{ + auto *renameLocationRef = reinterpret_cast(renameLocationPtr); + return renameLocationRef->start; +} +TS_INTEROP_1(getRenameLocationStart, KInt, KNativePointer) + +KInt impl_getRenameLocationEnd(KNativePointer renameLocationPtr) +{ + auto *renameLocationRef = reinterpret_cast(renameLocationPtr); + return renameLocationRef->end; +} +TS_INTEROP_1(getRenameLocationEnd, KInt, KNativePointer) + +KInt impl_getRenameLocationLine(KNativePointer renameLocationPtr) +{ + auto *renameLocationRef = reinterpret_cast(renameLocationPtr); + return renameLocationRef->line; +} +TS_INTEROP_1(getRenameLocationLine, KInt, KNativePointer) + +// NOLINTBEGIN +inline KUInt UnpackUInt(const KByte *bytes) +{ + return (bytes[0] | (bytes[1] << 8U) | (bytes[2U] << 16U) | (bytes[3U] << 24U)); +} +// NOLINTEND + +/* + * Parses an array of pointers from a KStringArray. + * format: + * | header(4 bytes) | strLen(4 bytes) | strData(strLen bytes) | strLen(4 bytes) | strData(strLen bytes) | ... + */ +static std::vector ParsePointerArray(KInt argc, KStringArray pointerArrayPtr) +{ + const std::size_t headerLen = 4; + auto bigintPtrs = std::vector(); + bigintPtrs.reserve(static_cast(argc)); + std::size_t offset = headerLen; + std::size_t strLen = 0; + + for (std::size_t i = 0; i < static_cast(argc); ++i) { + strLen = UnpackUInt(pointerArrayPtr + offset); + offset += headerLen; + std::string bigintStr(reinterpret_cast(pointerArrayPtr + offset), strLen); + offset += strLen; + + uintptr_t ptrValue = 0; + const size_t prefixLen = 2; + const size_t hex = 16; + const size_t decimal = 10; + if (bigintStr.substr(0, prefixLen) == "0x" || bigintStr.substr(0, prefixLen) == "0X") { + ptrValue = std::stoull(bigintStr, nullptr, hex); + } else { + ptrValue = std::stoull(bigintStr, nullptr, decimal); + } + bigintPtrs.push_back(reinterpret_cast(ptrValue)); + } + + return bigintPtrs; +} + +KNativePointer impl_findRenameLocations(KInt argc, KStringArray pointerArrayPtr, KNativePointer context, KInt position) +{ + auto pointerArray = ParsePointerArray(argc, pointerArrayPtr); + auto fileContexts = std::vector {}; + fileContexts.reserve(argc); + for (std::size_t i = 0; i < static_cast(argc); ++i) { + auto contextPtr = reinterpret_cast(pointerArray[i]); + if (contextPtr != nullptr) { + fileContexts.push_back(contextPtr); + } + } + LSPAPI const *ctx = GetImpl(); + auto result = ctx->findRenameLocations(fileContexts, reinterpret_cast(context), + static_cast(position)); + auto ptrs = std::make_unique>(); + ptrs->reserve(result.size()); + for (auto &el : result) { + ptrs->push_back(new ark::es2panda::lsp::RenameLocation(std::move(el))); + } + return ptrs.release(); +} +TS_INTEROP_4(findRenameLocations, KNativePointer, KInt, KStringArray, KNativePointer, KInt) + +KNativePointer impl_getRenameSuccessFileName(KNativePointer successPtr) +{ + auto successInfo = reinterpret_cast(successPtr); + return new std::string(successInfo->GetFileToRename()); +} +TS_INTEROP_1(getRenameSuccessFileName, KNativePointer, KNativePointer) + +KNativePointer impl_getRenameSuccessKind(KNativePointer successPtr) +{ + auto successInfo = reinterpret_cast(successPtr); + return new std::string(successInfo->GetKind()); +} +TS_INTEROP_1(getRenameSuccessKind, KNativePointer, KNativePointer) + +KNativePointer impl_getRenameSuccessDisplayName(KNativePointer successPtr) +{ + auto successInfo = reinterpret_cast(successPtr); + return new std::string(successInfo->GetDisplayName()); +} +TS_INTEROP_1(getRenameSuccessDisplayName, KNativePointer, KNativePointer) + +KNativePointer impl_getRenameSuccessFullDisplayName(KNativePointer successPtr) +{ + auto successInfo = reinterpret_cast(successPtr); + return new std::string(successInfo->GetFullDisplayName()); +} +TS_INTEROP_1(getRenameSuccessFullDisplayName, KNativePointer, KNativePointer) + +KNativePointer impl_getRenameSuccessKindModifiers(KNativePointer successPtr) +{ + auto successInfo = reinterpret_cast(successPtr); + return new std::string(successInfo->GetKindModifiers()); +} +TS_INTEROP_1(getRenameSuccessKindModifiers, KNativePointer, KNativePointer) + +KNativePointer impl_getRenameSuccessTriggerSpan(KNativePointer successPtr) +{ + auto successInfo = reinterpret_cast(successPtr); + return new TextSpan(successInfo->GetTriggerSpan()); +} +TS_INTEROP_1(getRenameSuccessTriggerSpan, KNativePointer, KNativePointer) + +KNativePointer impl_getRenameFailureLocalizedErrorMessage(KNativePointer failurePtr) +{ + auto failureInfo = reinterpret_cast(failurePtr); + return new std::string(failureInfo->GetLocalizedErrorMessage()); +} +TS_INTEROP_1(getRenameFailureLocalizedErrorMessage, KNativePointer, KNativePointer) + +KBoolean impl_getRenameInfoIsSuccess(KNativePointer renameInfoPtr) +{ + auto renameInfo = reinterpret_cast *>(renameInfoPtr); + return std::get<0>(*renameInfo) ? 1 : 0; +} +TS_INTEROP_1(getRenameInfoIsSuccess, KBoolean, KNativePointer) + +KNativePointer impl_getRenameInfoSuccess(KNativePointer renameInfoPtr) +{ + auto renameInfo = reinterpret_cast *>(renameInfoPtr); + auto [flag, successInfo] = *renameInfo; + return flag ? successInfo : nullptr; +} +TS_INTEROP_1(getRenameInfoSuccess, KNativePointer, KNativePointer) + +KNativePointer impl_getRenameInfoFailure(KNativePointer renameInfoPtr) +{ + auto renameInfo = reinterpret_cast *>(renameInfoPtr); + auto [flag, failureInfo] = *renameInfo; + return flag ? nullptr : failureInfo; +} +TS_INTEROP_1(getRenameInfoFailure, KNativePointer, KNativePointer) + +KNativePointer impl_getRenameInfo(KNativePointer context, KInt position, KStringPtr &pandaLibPath) +{ + LSPAPI const *ctx = GetImpl(); + auto result = ctx->getRenameInfo(reinterpret_cast(context), static_cast(position), + GetStringCopy(pandaLibPath)); + if (std::holds_alternative(result)) { + auto &successInfo = std::get(result); + return new std::tuple(true, new ark::es2panda::lsp::RenameInfoSuccess(std::move(successInfo))); + } + auto &failureInfo = std::get(result); + return new std::tuple(false, new ark::es2panda::lsp::RenameInfoFailure(std::move(failureInfo))); +} +TS_INTEROP_3(getRenameInfo, KNativePointer, KNativePointer, KInt, KStringPtr) + KNativePointer impl_getFieldsInfoFromPropertyInfo(KNativePointer infoPtr) { auto info = reinterpret_cast *>(infoPtr); @@ -117,19 +308,19 @@ KNativePointer impl_getDisplayNameFromPropertyInfo(KNativePointer infoPtr) } TS_INTEROP_1(getDisplayNameFromPropertyInfo, KNativePointer, KNativePointer) -KNativePointer impl_getStartFromPropertyInfo(KNativePointer infoPtr) +KInt impl_getStartFromPropertyInfo(KNativePointer infoPtr) { auto info = reinterpret_cast(infoPtr); - return new std::size_t(info->start); + return info->start; } -TS_INTEROP_1(getStartFromPropertyInfo, KNativePointer, KNativePointer) +TS_INTEROP_1(getStartFromPropertyInfo, KInt, KNativePointer) -KNativePointer impl_getEndFromPropertyInfo(KNativePointer infoPtr) +KInt impl_getEndFromPropertyInfo(KNativePointer infoPtr) { auto info = reinterpret_cast(infoPtr); - return new std::size_t(info->end); + return info->end; } -TS_INTEROP_1(getEndFromPropertyInfo, KNativePointer, KNativePointer) +TS_INTEROP_1(getEndFromPropertyInfo, KInt, KNativePointer) KNativePointer impl_getSyntacticDiagnostics(KNativePointer context) { @@ -318,15 +509,15 @@ KNativePointer impl_getClassConstructorInfo(KNativePointer context, KInt positio properties.emplace_back(GetStringCopy(const_cast(el))); } LSPAPI const *ctx = GetImpl(); - auto *info = new RefactorEditInfo(ctx->getClassConstructorInfo(reinterpret_cast(context), - static_cast(position), properties)); + auto *info = new ark::es2panda::lsp::RefactorEditInfo(ctx->getClassConstructorInfo( + reinterpret_cast(context), static_cast(position), properties)); return info; } TS_INTEROP_3(getClassConstructorInfo, KNativePointer, KNativePointer, KInt, KStringArray) KNativePointer impl_getFileTextChangesFromConstructorInfo(KNativePointer infoPtr) { - auto *info = reinterpret_cast(infoPtr); + auto *info = reinterpret_cast(infoPtr); std::vector ptrs; for (auto &el : info->GetFileTextChanges()) { ptrs.push_back(new FileTextChanges(el)); @@ -367,57 +558,6 @@ KNativePointer impl_getTextSpanFromConstructorInfo(KNativePointer infoPtr) } TS_INTEROP_1(getTextSpanFromConstructorInfo, KNativePointer, KNativePointer) -KNativePointer impl_getRefactorActionName(KNativePointer refactorActionPtr) -{ - auto *refactorAction = reinterpret_cast(refactorActionPtr); - return new std::string(refactorAction->name); -} -TS_INTEROP_1(getRefactorActionName, KNativePointer, KNativePointer) - -KNativePointer impl_getRefactorActionDescription(KNativePointer refactorActionPtr) -{ - auto *refactorAction = reinterpret_cast(refactorActionPtr); - return new std::string(refactorAction->description); -} -TS_INTEROP_1(getRefactorActionDescription, KNativePointer, KNativePointer) - -KNativePointer impl_getRefactorActionKind(KNativePointer refactorActionPtr) -{ - auto *refactorAction = reinterpret_cast(refactorActionPtr); - return new std::string(refactorAction->kind); -} -TS_INTEROP_1(getRefactorActionKind, KNativePointer, KNativePointer) - -KNativePointer impl_getApplicableRefactors(KNativePointer context, KStringPtr &kindPtr, KInt position) -{ - LSPAPI const *ctx = GetImpl(); - auto *applicableRefactorInfo = new ark::es2panda::lsp::ApplicableRefactorInfo(ctx->getApplicableRefactors( - reinterpret_cast(context), GetStringCopy(kindPtr), static_cast(position))); - return applicableRefactorInfo; -} -TS_INTEROP_3(getApplicableRefactors, KNativePointer, KNativePointer, KStringPtr, KInt) - -KNativePointer impl_getApplicableRefactorName(KNativePointer applRefsPtr) -{ - auto *applRefsInfo = reinterpret_cast(applRefsPtr); - return new std::string(applRefsInfo->name); -} -TS_INTEROP_1(getApplicableRefactorName, KNativePointer, KNativePointer) - -KNativePointer impl_getApplicableRefactorDescription(KNativePointer applRefsPtr) -{ - auto *applRefsInfo = reinterpret_cast(applRefsPtr); - return new std::string(applRefsInfo->description); -} -TS_INTEROP_1(getApplicableRefactorDescription, KNativePointer, KNativePointer) - -KNativePointer impl_getRefactorAction(KNativePointer applRefsPtr) -{ - auto *applRefsInfo = reinterpret_cast(applRefsPtr); - return new ark::es2panda::lsp::RefactorAction(applRefsInfo->action); -} -TS_INTEROP_1(getRefactorAction, KNativePointer, KNativePointer) - KNativePointer impl_getCompletionEntryDetailsSymbolDisplayPart(KNativePointer completionEntryDetailsPtr) { auto *completionEntryDetails = reinterpret_cast(completionEntryDetailsPtr); @@ -773,14 +913,14 @@ KNativePointer impl_getClassNameFromClassHierarchyInfo(KNativePointer info) } TS_INTEROP_1(getClassNameFromClassHierarchyInfo, KNativePointer, KNativePointer) -KNativePointer impl_getMethodListFromClassHierarchyInfo(KNativePointer info) +KNativePointer impl_getMethodItemsFromClassHierarchyInfo(KNativePointer info) { auto *infoPtr = reinterpret_cast(info); if (infoPtr == nullptr) { return nullptr; } std::vector ptrs; - for (const auto &element : infoPtr->GetMethodList()) { + for (const auto &element : infoPtr->GetMethodItemList()) { if (element.second == nullptr) { continue; } @@ -788,17 +928,34 @@ KNativePointer impl_getMethodListFromClassHierarchyInfo(KNativePointer info) } return new std::vector(ptrs); } -TS_INTEROP_1(getMethodListFromClassHierarchyInfo, KNativePointer, KNativePointer) +TS_INTEROP_1(getMethodItemsFromClassHierarchyInfo, KNativePointer, KNativePointer) -KNativePointer impl_getDetailFromClassMethodItem(KNativePointer item) +KNativePointer impl_getPropertyItemsFromClassHierarchyInfo(KNativePointer info) { - auto *itemPtr = reinterpret_cast(item); + auto *infoPtr = reinterpret_cast(info); + if (infoPtr == nullptr) { + return nullptr; + } + std::vector ptrs; + for (const auto &element : infoPtr->GetPropertyItemList()) { + if (element.second == nullptr) { + continue; + } + ptrs.push_back(new ClassPropertyItem(*(element.second))); + } + return new std::vector(ptrs); +} +TS_INTEROP_1(getPropertyItemsFromClassHierarchyInfo, KNativePointer, KNativePointer) + +KNativePointer impl_getDetailFromClassHierarchyItem(KNativePointer item) +{ + auto *itemPtr = reinterpret_cast(item); if (itemPtr == nullptr) { return nullptr; } - return new std::string(itemPtr->GetFunctionDetail()); + return new std::string(itemPtr->GetDetail()); } -TS_INTEROP_1(getDetailFromClassMethodItem, KNativePointer, KNativePointer) +TS_INTEROP_1(getDetailFromClassHierarchyItem, KNativePointer, KNativePointer) KInt impl_getSetterStyleFromClassMethodItem(KNativePointer item) { @@ -810,15 +967,15 @@ KInt impl_getSetterStyleFromClassMethodItem(KNativePointer item) } TS_INTEROP_1(getSetterStyleFromClassMethodItem, KInt, KNativePointer) -KInt impl_getAccessModifierStyleFromClassMethodItem(KNativePointer item) +KInt impl_getAccessModifierStyleFromClassHierarchyItem(KNativePointer item) { - auto *itemPtr = reinterpret_cast(item); + auto *itemPtr = reinterpret_cast(item); if (itemPtr == nullptr) { return 0; } return static_cast(itemPtr->GetAccessModifierStyle()); } -TS_INTEROP_1(getAccessModifierStyleFromClassMethodItem, KInt, KNativePointer) +TS_INTEROP_1(getAccessModifierStyleFromClassHierarchyItem, KInt, KNativePointer) KInt impl_getAliasScriptElementKind(KNativePointer context, KInt position) { @@ -832,14 +989,28 @@ KInt impl_getAliasScriptElementKind(KNativePointer context, KInt position) } TS_INTEROP_2(getAliasScriptElementKind, KInt, KNativePointer, KInt) +KNativePointer impl_pushBackToNativeContextVector(KNativePointer context, KNativePointer contextList, KBoolean isNew) +{ + auto contextPtr = reinterpret_cast(context); + if (isNew != 0) { + auto *newVector = new std::vector(); + newVector->push_back(contextPtr); + return newVector; + } + auto contextVector = reinterpret_cast *>(contextList); + contextVector->push_back(contextPtr); + return contextVector; +} +TS_INTEROP_3(pushBackToNativeContextVector, KNativePointer, KNativePointer, KNativePointer, KBoolean) + KNativePointer impl_getClassHierarchies(KNativePointer context, KStringPtr &fileNamePtr, KInt pos) { LSPAPI const *ctx = GetImpl(); if (ctx == nullptr) { return nullptr; } - auto infos = - ctx->getClassHierarchiesImpl(reinterpret_cast(context), GetStringCopy(fileNamePtr), pos); + auto *contextlist = reinterpret_cast *>(context); + auto infos = ctx->getClassHierarchiesImpl(contextlist, GetStringCopy(fileNamePtr), pos); std::vector ptrs; ptrs.reserve(infos.size()); for (auto &info : infos) { @@ -849,12 +1020,74 @@ KNativePointer impl_getClassHierarchies(KNativePointer context, KStringPtr &file } TS_INTEROP_3(getClassHierarchies, KNativePointer, KNativePointer, KStringPtr, KInt) +KNativePointer impl_getApplicableRefactors(KNativePointer context, KStringPtr &kindPtr, KInt position) +{ + LSPAPI const *ctx = GetImpl(); + auto *result = new std::vector(ctx->getApplicableRefactors( + reinterpret_cast(context), GetStringCopy(kindPtr), static_cast(position))); + return result; +} +TS_INTEROP_3(getApplicableRefactors, KNativePointer, KNativePointer, KStringPtr, KInt) + +KNativePointer impl_getApplicableRefactorInfoList(KNativePointer infosPtr) +{ + auto *infos = reinterpret_cast *>(infosPtr); + std::vector ptrs; + for (auto &info : *infos) { + ptrs.push_back(new ark::es2panda::lsp::ApplicableRefactorInfo(info)); + } + return new std::vector(ptrs); +} +TS_INTEROP_1(getApplicableRefactorInfoList, KNativePointer, KNativePointer) + +KNativePointer impl_getRefactorActionName(KNativePointer refactorActionPtr) +{ + auto *refactorAction = reinterpret_cast(refactorActionPtr); + return new std::string(refactorAction->name); +} +TS_INTEROP_1(getRefactorActionName, KNativePointer, KNativePointer) + +KNativePointer impl_getRefactorActionDescription(KNativePointer refactorActionPtr) +{ + auto *refactorAction = reinterpret_cast(refactorActionPtr); + return new std::string(refactorAction->description); +} +TS_INTEROP_1(getRefactorActionDescription, KNativePointer, KNativePointer) + +KNativePointer impl_getRefactorActionKind(KNativePointer refactorActionPtr) +{ + auto *refactorAction = reinterpret_cast(refactorActionPtr); + return new std::string(refactorAction->kind); +} +TS_INTEROP_1(getRefactorActionKind, KNativePointer, KNativePointer) + +KNativePointer impl_getApplicableRefactorName(KNativePointer applRefsPtr) +{ + auto *applRefsInfo = reinterpret_cast(applRefsPtr); + return new std::string(applRefsInfo->name); +} +TS_INTEROP_1(getApplicableRefactorName, KNativePointer, KNativePointer) + +KNativePointer impl_getApplicableRefactorDescription(KNativePointer applRefsPtr) +{ + auto *applRefsInfo = reinterpret_cast(applRefsPtr); + return new std::string(applRefsInfo->description); +} +TS_INTEROP_1(getApplicableRefactorDescription, KNativePointer, KNativePointer) + +KNativePointer impl_getApplicableRefactorAction(KNativePointer applRefsPtr) +{ + auto *applRefsInfo = reinterpret_cast(applRefsPtr); + return new ark::es2panda::lsp::RefactorAction(applRefsInfo->action); +} +TS_INTEROP_1(getApplicableRefactorAction, KNativePointer, KNativePointer) + KNativePointer impl_getClassHierarchyList(KNativePointer infosPtr) { - auto *infos = reinterpret_cast *>(infosPtr); + auto *infos = reinterpret_cast *>(infosPtr); std::vector infoPtrList; for (auto &info : *infos) { - infoPtrList.push_back(new ark::es2panda::lsp::ClassHierarchyItemInfo(info)); + infoPtrList.push_back(info); } return new std::vector(infoPtrList); } @@ -888,9 +1121,8 @@ KNativePointer impl_getOverriddenFromClassHierarchyItemInfo(KNativePointer infoP auto &overridden = info->overridden; std::vector overriddenPtrList; overriddenPtrList.reserve(overridden.size()); - size_t idx = 0; for (auto &details : overridden) { - overriddenPtrList[idx++] = new ark::es2panda::lsp::ClassRelationDetails(details); + overriddenPtrList.push_back(new ark::es2panda::lsp::ClassRelationDetails(details)); } return new std::vector(std::move(overriddenPtrList)); } @@ -902,9 +1134,8 @@ KNativePointer impl_getOverridingFromClassHierarchyItemInfo(KNativePointer infoP auto &overriding = info->overriding; std::vector overridingPtrList; overridingPtrList.reserve(overriding.size()); - size_t idx = 0; for (auto &details : overriding) { - overridingPtrList[idx++] = new ark::es2panda::lsp::ClassRelationDetails(details); + overridingPtrList.push_back(new ark::es2panda::lsp::ClassRelationDetails(details)); } return new std::vector(std::move(overridingPtrList)); } @@ -916,9 +1147,8 @@ KNativePointer impl_getImplementedFromClassHierarchyItemInfo(KNativePointer info auto implemented = info->implemented; std::vector implementedPtrList; implementedPtrList.reserve(implemented.size()); - size_t idx = 0; for (auto &details : implemented) { - implementedPtrList[idx++] = new ark::es2panda::lsp::ClassRelationDetails(details); + implementedPtrList.push_back(new ark::es2panda::lsp::ClassRelationDetails(details)); } return new std::vector(std::move(implementedPtrList)); } @@ -930,9 +1160,8 @@ KNativePointer impl_getImplementingFromClassHierarchyItemInfo(KNativePointer inf auto implementing = info->implementing; std::vector implementingPtrList; implementingPtrList.reserve(implementing.size()); - size_t idx = 0; for (auto &details : implementing) { - implementingPtrList[idx++] = new ark::es2panda::lsp::ClassRelationDetails(details); + implementingPtrList.push_back(new ark::es2panda::lsp::ClassRelationDetails(details)); } return new std::vector(std::move(implementingPtrList)); } @@ -1187,13 +1416,12 @@ KNativePointer impl_getLocationFromList(KNativePointer listPtr) } TS_INTEROP_1(getLocationFromList, KNativePointer, KNativePointer) -KBoolean impl_getSafeDeleteInfo(KNativePointer context, KInt position, KStringPtr &path) +KBoolean impl_getSafeDeleteInfo(KNativePointer context, KInt position) { LSPAPI const *ctx = GetImpl(); - return static_cast( - ctx->getSafeDeleteInfo(reinterpret_cast(context), position, GetStringCopy(path))); + return static_cast(ctx->getSafeDeleteInfo(reinterpret_cast(context), position)); } -TS_INTEROP_3(getSafeDeleteInfo, KBoolean, KNativePointer, KInt, KStringPtr) +TS_INTEROP_2(getSafeDeleteInfo, KBoolean, KNativePointer, KInt) KNativePointer impl_toLineColumnOffset(KNativePointer context, KInt position) { @@ -1309,6 +1537,74 @@ KInt impl_getTypeFromTypeHierarchies(KNativePointer infoPtr) } TS_INTEROP_1(getTypeFromTypeHierarchies, KInt, KNativePointer) +KNativePointer impl_getCodeFixesAtPosition(KNativePointer context, KInt startPosition, KInt endPosition, + KInt *errorCodesPtr, KInt codeLength) +{ + CodeFixOptions emptyOptions; + std::vector errorCodesInt; + if (errorCodesPtr != nullptr && codeLength > 0) { + // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic,-warnings-as-errors) + errorCodesInt = std::vector(reinterpret_cast(errorCodesPtr), + reinterpret_cast(errorCodesPtr) + codeLength); + // NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic,-warnings-as-errors) + } + LSPAPI const *ctx = GetImpl(); + auto autofix = ctx->getCodeFixesAtPosition(reinterpret_cast(context), startPosition, + endPosition, errorCodesInt, emptyOptions); + return new std::vector(autofix); +} +TS_INTEROP_5(getCodeFixesAtPosition, KNativePointer, KNativePointer, KInt, KInt, KInt *, KInt) + +KNativePointer impl_getCodeFixActionInfos(KNativePointer codeFixActionInfoListPtr) +{ + auto *getCodeFixActionInfoList = reinterpret_cast(codeFixActionInfoListPtr); + std::vector ptrs; + for (auto &el : getCodeFixActionInfoList->infos_) { + ptrs.push_back(new CodeFixActionInfo(el)); + } + return new std::vector(ptrs); +} +TS_INTEROP_1(getCodeFixActionInfos, KNativePointer, KNativePointer) + +KNativePointer impl_getFileTextChangesFromCodeActionInfo(KNativePointer infoPtr) +{ + auto *info = reinterpret_cast(infoPtr); + std::vector ptrs; + for (auto &el : info->changes_) { + ptrs.push_back(new FileTextChanges(el)); + } + return new std::vector(ptrs); +} +TS_INTEROP_1(getFileTextChangesFromCodeActionInfo, KNativePointer, KNativePointer) + +KNativePointer impl_getDescriptionFromCodeActionInfo(KNativePointer infoPtr) +{ + auto *info = reinterpret_cast(infoPtr); + return new std::string(info->description_); +} +TS_INTEROP_1(getDescriptionFromCodeActionInfo, KNativePointer, KNativePointer) + +KNativePointer impl_getFixNameFromCodeFixActionInfo(KNativePointer infoPtr) +{ + auto *info = reinterpret_cast(infoPtr); + return new std::string(info->fixName_); +} +TS_INTEROP_1(getFixNameFromCodeFixActionInfo, KNativePointer, KNativePointer) + +KNativePointer impl_getFixIdFromCodeFixActionInfo(KNativePointer infoPtr) +{ + auto *info = reinterpret_cast(infoPtr); + return new std::string(info->fixId_); +} +TS_INTEROP_1(getFixIdFromCodeFixActionInfo, KNativePointer, KNativePointer) + +KNativePointer impl_getFixAllDescriptionFromCodeFixActionInfo(KNativePointer infoPtr) +{ + auto *info = reinterpret_cast(infoPtr); + return new std::string(info->fixAllDescription_); +} +TS_INTEROP_1(getFixAllDescriptionFromCodeFixActionInfo, KNativePointer, KNativePointer) + KNativePointer impl_getSpanOfEnclosingComment(KNativePointer context, KInt position, KBoolean onlyMultiLine) { LSPAPI const *ctx = GetImpl(); diff --git a/ets2panda/bindings/package.json b/ets2panda/bindings/package.json index 92d680af8d08a135101997e4752810d95b16fca5..61b96b42af3c19fb49cd8a46736b6a6db2c776ee 100644 --- a/ets2panda/bindings/package.json +++ b/ets2panda/bindings/package.json @@ -7,8 +7,7 @@ "@types/node": "^18.0.0", "prettier": "latest", "rimraf": "^6.0.1", - "typescript": "4.9.5", - "node-api-headers": "^1.4.0" + "typescript": "4.9.5" }, "main": "dist/index.js", "scripts": { diff --git a/ets2panda/bindings/src/arktsConfigGenerate.ts b/ets2panda/bindings/src/arktsConfigGenerate.ts deleted file mode 100644 index 56f00052edfbf3e3b8fa7090facefb977730077b..0000000000000000000000000000000000000000 --- a/ets2panda/bindings/src/arktsConfigGenerate.ts +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { BuildMode } from './build/buildMode'; -import { BuildConfig } from './types'; -import { ModuleDescriptor, generateBuildConfigs } from './buildConfigGenerate'; -import { PANDA_SDK_PATH_FROM_SDK } from './preDefine'; - -import * as fs from 'fs'; -import * as path from 'path'; -import { PluginDriver } from './ui_plugins_driver'; - -function processBuildConfig(projectConfig: BuildConfig): BuildConfig { - let buildConfig: BuildConfig = { ...projectConfig }; - let buildSdkPath: string = buildConfig.buildSdkPath as string; - buildConfig.pandaSdkPath = buildConfig.pandaSdkPath ?? path.resolve(buildSdkPath, PANDA_SDK_PATH_FROM_SDK); - PluginDriver.getInstance().initPlugins(buildConfig); - return buildConfig; -} - -export function generateArkTsConfigByModules( - buildSdkPath: string, - projectRoot: string, - modules?: ModuleDescriptor[] -): void { - const allBuildConfig = generateBuildConfigs(buildSdkPath, projectRoot, modules); - let compileFileInfos: Record = {}; - const cacheDir = path.join(projectRoot, '.idea', '.deveco'); - const compileFileInfosPath = path.join(cacheDir, 'lsp_compileFileInfos.json'); - Object.keys(allBuildConfig).forEach((moduleName) => { - const moduleConfig = allBuildConfig[moduleName] as BuildConfig; - const processedConfig = processBuildConfig(moduleConfig); - - const buildMode = new BuildMode(processedConfig); - buildMode.generateArkTSConfig(compileFileInfos); - }); - try { - const jsonCompileFileInfos = JSON.stringify(compileFileInfos, null, 2); - if (!fs.existsSync(cacheDir)) { - fs.mkdirSync(cacheDir, { recursive: true }); - } - fs.writeFileSync(compileFileInfosPath, jsonCompileFileInfos, 'utf-8'); - } catch (err) { - console.error(`Failed to write compileFileInfos to ${compileFileInfosPath} with error: ${err}`); - } -} diff --git a/ets2panda/bindings/src/build/buildMode.ts b/ets2panda/bindings/src/build/buildMode.ts deleted file mode 100644 index d1be834b99fda47c40eb4787f8670bfa76be6268..0000000000000000000000000000000000000000 --- a/ets2panda/bindings/src/build/buildMode.ts +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import * as path from 'path'; - -import { ABC_SUFFIX, ARKTSCONFIG_JSON_FILE, LANGUAGE_VERSION } from '../preDefine'; -import { changeFileExtension } from '../utils'; -import { BuildConfig, DependentModuleConfig, ModuleInfo, CompileFileInfo } from '../types'; -import { ArkTSConfigGenerator } from './generateArkTSConfig'; - -export class BuildMode { - buildConfig: BuildConfig; - entryFiles: Set; - compileFiles: Map; - cacheDir: string; - pandaSdkPath: string; - buildSdkPath: string; - packageName: string; - sourceRoots: string[]; - moduleRootPath: string; - moduleType: string; - dependentModuleList: DependentModuleConfig[]; - moduleInfos: Map; - declgenV1OutPath: string | undefined; - declgenBridgeCodePath: string | undefined; - hasMainModule: boolean; - - constructor(buildConfig: BuildConfig) { - this.buildConfig = buildConfig; - this.entryFiles = new Set(buildConfig.compileFiles as string[]); - this.cacheDir = buildConfig.cachePath as string; - this.pandaSdkPath = buildConfig.pandaSdkPath as string; - this.buildSdkPath = buildConfig.buildSdkPath as string; - this.packageName = buildConfig.packageName as string; - this.sourceRoots = buildConfig.sourceRoots as string[]; - this.moduleRootPath = buildConfig.moduleRootPath as string; - this.moduleType = buildConfig.moduleType as string; - this.dependentModuleList = buildConfig.dependentModuleList; - this.hasMainModule = buildConfig.hasMainModule; - - this.declgenV1OutPath = buildConfig.declgenV1OutPath as string | undefined; - this.declgenBridgeCodePath = buildConfig.declgenBridgeCodePath as string | undefined; - - this.moduleInfos = new Map(); - this.compileFiles = new Map(); - } - - private getDependentModules(moduleInfo: ModuleInfo): Map[] { - let dynamicDepModules: Map = new Map(); - let staticDepModules: Map = new Map(); - - if (moduleInfo.isMainModule) { - this.moduleInfos.forEach((module: ModuleInfo, packageName: string) => { - if (module.isMainModule) { - return; - } - module.language === LANGUAGE_VERSION.ARKTS_1_2 - ? staticDepModules.set(packageName, module) - : dynamicDepModules.set(packageName, module); - }); - return [dynamicDepModules, staticDepModules]; - } - - if (moduleInfo.dependencies) { - moduleInfo.dependencies.forEach((packageName: string) => { - let depModuleInfo: ModuleInfo | undefined = this.moduleInfos.get(packageName); - if (!depModuleInfo) { - console.error(`Module ${packageName} not found in moduleInfos`); - } else { - depModuleInfo.language === LANGUAGE_VERSION.ARKTS_1_2 - ? staticDepModules.set(packageName, depModuleInfo) - : dynamicDepModules.set(packageName, depModuleInfo); - } - }); - } - return [dynamicDepModules, staticDepModules]; - } - - private generateArkTSConfigForModules(compileFileInfos: Record): void { - let generator = ArkTSConfigGenerator.getGenerator(this.buildConfig, this.moduleInfos); - this.moduleInfos.forEach((moduleInfo: ModuleInfo, moduleRootPath: string) => { - for (const fileInfo of moduleInfo.compileFileInfos) { - compileFileInfos[fileInfo.filePath] = fileInfo.arktsConfigFile; - } - generator.writeArkTSConfigFile(moduleInfo); - }); - } - - private collectDepModuleInfos(): void { - this.moduleInfos.forEach((moduleInfo) => { - let [dynamicDepModules, staticDepModules] = this.getDependentModules(moduleInfo); - moduleInfo.dynamicDepModuleInfos = dynamicDepModules; - moduleInfo.staticDepModuleInfos = staticDepModules; - }); - } - - private collectModuleInfos(): void { - if (this.hasMainModule && (!this.packageName || !this.moduleRootPath || !this.sourceRoots)) { - console.error('Main module info from hvigor is not correct.'); - } - let mainModuleInfo: ModuleInfo = { - isMainModule: this.hasMainModule, - packageName: this.packageName, - moduleRootPath: this.moduleRootPath, - moduleType: this.moduleType, - sourceRoots: this.sourceRoots, - entryFile: '', - arktsConfigFile: path.resolve(this.cacheDir, this.packageName, ARKTSCONFIG_JSON_FILE), - dynamicDepModuleInfos: new Map(), - staticDepModuleInfos: new Map(), - compileFileInfos: [], - declgenV1OutPath: this.declgenV1OutPath, - declgenBridgeCodePath: this.declgenBridgeCodePath - }; - this.moduleInfos.set(this.packageName, mainModuleInfo); - this.dependentModuleList.forEach((module: DependentModuleConfig) => { - if (!module.packageName || !module.modulePath || !module.sourceRoots || !module.entryFile) { - console.error('Dependent module info from hvigor is not correct.'); - } - let moduleInfo: ModuleInfo = { - isMainModule: false, - packageName: module.packageName, - moduleRootPath: module.modulePath, - moduleType: module.moduleType, - sourceRoots: module.sourceRoots, - entryFile: module.entryFile, - arktsConfigFile: path.resolve(this.cacheDir, module.packageName, ARKTSCONFIG_JSON_FILE), - compileFileInfos: [], - dynamicDepModuleInfos: new Map(), - staticDepModuleInfos: new Map(), - declgenV1OutPath: undefined, - declgenBridgeCodePath: undefined, - language: module.language, - declFilesPath: module.declFilesPath, - dependencies: module.dependencies - }; - this.moduleInfos.set(module.packageName, moduleInfo); - }); - this.collectDepModuleInfos(); - } - - private collectCompileFiles(): void { - this.entryFiles.forEach((file: string) => { - for (const [packageName, moduleInfo] of this.moduleInfos) { - if (!file.startsWith(moduleInfo.moduleRootPath)) { - continue; - } - let filePathFromModuleRoot: string = path.relative(moduleInfo.moduleRootPath, file); - let filePathInCache: string = path.join(this.cacheDir, moduleInfo.packageName, filePathFromModuleRoot); - let abcFilePath: string = path.resolve(changeFileExtension(filePathInCache, ABC_SUFFIX)); - - let fileInfo: CompileFileInfo = { - filePath: file, - dependentFiles: [], - abcFilePath: abcFilePath, - arktsConfigFile: moduleInfo.arktsConfigFile, - packageName: moduleInfo.packageName - }; - moduleInfo.compileFileInfos.push(fileInfo); - this.compileFiles.set(file, fileInfo); - return; - } - console.error('File does not belong to any module in moduleInfos.'); - }); - } - - public generateModuleInfos(): void { - this.collectModuleInfos(); - this.collectCompileFiles(); - } - - public async generateArkTSConfig(compileFileInfos: Record): Promise { - this.generateModuleInfos(); - this.generateArkTSConfigForModules(compileFileInfos); - } -} diff --git a/ets2panda/bindings/src/Es2pandaNativeModule.ts b/ets2panda/bindings/src/common/Es2pandaNativeModule.ts similarity index 82% rename from ets2panda/bindings/src/Es2pandaNativeModule.ts rename to ets2panda/bindings/src/common/Es2pandaNativeModule.ts index 210ad83e1cdbc4ee92919e027e49b61c61c67017..94c9d9f76efa61c03ba9fea68e9558f3b5fed460 100644 --- a/ets2panda/bindings/src/Es2pandaNativeModule.ts +++ b/ets2panda/bindings/src/common/Es2pandaNativeModule.ts @@ -14,8 +14,17 @@ import * as fs from 'fs'; import * as path from 'path'; -import { KNativePointer as KPtr, KInt, KBoolean, KNativePointer, KDouble, KUInt, KStringPtr } from './InteropTypes'; -import { Es2pandaNativeModule as GeneratedEs2pandaNativeModule } from './generated/Es2pandaNativeModule'; +import { + KNativePointer as KPtr, + KInt, + KBoolean, + KNativePointer, + KDouble, + KUInt, + KStringPtr, + KInt32ArrayPtr +} from './InteropTypes'; +import { Es2pandaNativeModule as GeneratedEs2pandaNativeModule } from '../generated/Es2pandaNativeModule'; import { loadNativeModuleLibrary, registerNativeModuleLibraryName } from './loadLibraries'; import { throwError } from './utils'; @@ -45,6 +54,10 @@ export class Es2pandaNativeModule { throw new Error('Not implemented'); } + _GetAllErrorMessages(context: KPtr): KPtr { + throw new Error('Not implemented'); + } + _AstNodeDumpModifiers(context: KPtr, node: KPtr): KPtr { throw new Error('Not implemented'); } @@ -65,7 +78,8 @@ export class Es2pandaNativeModule { config: KPtr, outputDeclEts: String, outputEts: String, - exportAll: KBoolean + exportAll: KBoolean, + isolated: KBoolean ): KPtr { throw new Error('Not implemented'); } @@ -205,19 +219,23 @@ export class Es2pandaNativeModule { throw new Error('Not implemented'); } - _getMethodListFromClassHierarchyInfo(ptr: KNativePointer): KPtr { + _getMethodItemsFromClassHierarchyInfo(ptr: KNativePointer): KPtr { throw new Error('Not implemented'); } - _getDetailFromClassMethodItem(ptr: KNativePointer): KPtr { + _getPropertyItemsFromClassHierarchyInfo(ptr: KNativePointer): KPtr { throw new Error('Not implemented'); } - _getSetterStyleFromClassMethodItem(ptr: KNativePointer): KInt { + _getDetailFromClassHierarchyItem(ptr: KNativePointer): KPtr { throw new Error('Not implemented'); } - _getAccessModifierStyleFromClassMethodItem(ptr: KNativePointer): KInt { + _getAccessModifierStyleFromClassHierarchyItem(ptr: KNativePointer): KInt { + throw new Error('Not implemented'); + } + + _getSetterStyleFromClassMethodItem(ptr: KNativePointer): KInt { throw new Error('Not implemented'); } @@ -341,19 +359,23 @@ export class Es2pandaNativeModule { throw new Error('Not implemented'); } - _getRefactorAction(ptr: KNativePointer): KPtr { + _getApplicableRefactorAction(ptr: KNativePointer): KPtr { throw new Error('Not implemented'); } - _getApplicableRefactors(context: KNativePointer, kind: String, position: number): KPtr { + _getApplicableRefactorName(ptr: KNativePointer): KPtr { throw new Error('Not implemented'); } - _getApplicableRefactorName(ptr: KNativePointer): KPtr { + _getApplicableRefactorDescription(ptr: KNativePointer): KPtr { throw new Error('Not implemented'); } - _getApplicableRefactorDescription(ptr: KNativePointer): KPtr { + _getApplicableRefactors(context: KNativePointer, kind: String, position: KInt): KPtr { + throw new Error('Not implemented'); + } + + _getApplicableRefactorInfoList(ptr: KNativePointer): KPtr { throw new Error('Not implemented'); } @@ -385,6 +407,10 @@ export class Es2pandaNativeModule { throw new Error('Not implemented'); } + _pushBackToNativeContextVector(context: KNativePointer, contextList: KNativePointer, isNew: KBoolean): KPtr { + throw new Error('Not implemented'); + } + _getClassHierarchyList(ptr: KNativePointer): KPtr { throw new Error('Not implemented'); } @@ -716,7 +742,41 @@ export class Es2pandaNativeModule { throw new Error('Not implemented'); } - _getSafeDeleteInfo(context: KNativePointer, position: KInt, path: String): boolean { + _getSafeDeleteInfo(context: KNativePointer, position: KInt): boolean { + throw new Error('Not implemented'); + } + + _getCodeFixesAtPosition( + context: KNativePointer, + startPosition: KInt, + endPosition: KInt, + errorCodesPtr: KInt32ArrayPtr, + codeLength: KInt + ): KPtr { + throw new Error('Not implemented'); + } + + _getCodeFixActionInfos(infoPtr: KNativePointer): KPtr { + throw new Error('Not implemented'); + } + + _getFileTextChangesFromCodeActionInfo(infoPtr: KNativePointer): KPtr { + throw new Error('Not implemented'); + } + + _getDescriptionFromCodeActionInfo(infoPtr: KNativePointer): KPtr { + throw new Error('Not implemented'); + } + + _getFixNameFromCodeFixActionInfo(infoPtr: KNativePointer): KPtr { + throw new Error('Not implemented'); + } + + _getFixIdFromCodeFixActionInfo(infoPtr: KNativePointer): KPtr { + throw new Error('Not implemented'); + } + + _getFixAllDescriptionFromCodeFixActionInfo(infoPtr: KNativePointer): KPtr { throw new Error('Not implemented'); } @@ -748,6 +808,78 @@ export class Es2pandaNativeModule { throw new Error('Not implemented'); } + _getRenameLocationFileName(ptr: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _getRenameLocationStart(ptr: KPtr): KInt { + throw new Error('Not implemented'); + } + + _getRenameLocationEnd(ptr: KPtr): KInt { + throw new Error('Not implemented'); + } + + _getRenameLocationLine(ptr: KPtr): KInt { + throw new Error('Not implemented'); + } + + _getRenameLocationPrefixText(ptr: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _getRenameLocationSuffixText(ptr: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _findRenameLocations(argc: KInt, fileContexts: Uint8Array, context: KNativePointer, position: KInt): KPtr { + throw new Error('Not implemented'); + } + + _getRenameSuccessFileName(ptr: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _getRenameSuccessKind(ptr: KPtr): KInt { + throw new Error('Not implemented'); + } + + _getRenameSuccessDisplayName(ptr: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _getRenameSuccessFullDisplayName(ptr: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _getRenameSuccessKindModifiers(ptr: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _getRenameSuccessTriggerSpan(ptr: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _getRenameFailureLocalizedErrorMessage(ptr: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _getRenameInfoIsSuccess(ptr: KPtr): KBoolean { + throw new Error('Not implemented'); + } + + _getRenameInfoSuccess(ptr: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _getRenameInfoFailure(ptr: KPtr): KPtr { + throw new Error('Not implemented'); + } + + _getRenameInfo(context: KNativePointer, position: KInt, pandaLibPath: String): KPtr { + throw new Error('Not implemented'); + } + _createTextSpan(start: KInt, length: KInt): KPtr { throw new Error('Not implemented'); } @@ -808,12 +940,49 @@ export class Es2pandaNativeModule { throw new Error('Not implemented'); } + _MemInitialize(pandaLibPath: KStringPtr): void { + throw new Error('Not implemented'); + } + + _MemFinalize(): void { + throw new Error('Not implemented'); + } + + _CreateGlobalContext(configPtr: KNativePointer, externalFileList: string[] | Uint8Array, fileNum: KInt): KPtr { + throw new Error('Not implemented'); + } + + _DestroyGlobalContext(contextPtr: KPtr): void { + throw new Error('Not implemented'); + } + + _CreateCacheContextFromString( + config: KPtr, + source: String, + filename: String, + globalContext: KPtr, + isExternal: boolean + ): KPtr { + throw new Error('Not implemented'); + } + + _RemoveFileCache(globalContextPtr: KPtr, filename: String): void { + throw new Error('Not implemented'); + } + + _AddFileCache(globalContextPtr: KPtr, filename: String): void { + throw new Error('Not implemented'); + } + + _InvalidateFileCache(globalContextPtr: KPtr, filename: String): void { + throw new Error('Not implemented'); + } } export function initEs2panda(): Es2pandaNativeModule { let libPath = process.env.BINDINGS_PATH; if (libPath === undefined) { - libPath = path.resolve(__dirname, '../ts_bindings.node'); + libPath = path.resolve(__dirname, '../../ts_bindings.node'); } else { libPath = path.join(libPath, 'ts_bindings.node'); } @@ -829,7 +998,7 @@ export function initEs2panda(): Es2pandaNativeModule { export function initGeneratedEs2panda(): GeneratedEs2pandaNativeModule { let libPath = process.env.BINDINGS_PATH; if (libPath === undefined) { - libPath = path.resolve(__dirname, '../ts_bindings.node'); + libPath = path.resolve(__dirname, '../../ts_bindings.node'); } else { libPath = path.join(libPath, 'ts_bindings.node'); } @@ -845,7 +1014,7 @@ export function initGeneratedEs2panda(): GeneratedEs2pandaNativeModule { export function initPublicEs2panda(): Es2pandaNativeModule { let libPath = process.env.BINDINGS_PATH; if (libPath === undefined) { - libPath = path.resolve(__dirname, '../public.node'); + libPath = path.resolve(__dirname, '../../public.node'); } else { libPath = path.join(libPath, 'public.node'); } @@ -861,7 +1030,7 @@ export function initPublicEs2panda(): Es2pandaNativeModule { export function initPublicGeneratedEs2panda(): GeneratedEs2pandaNativeModule { let libPath = process.env.BINDINGS_PATH; if (libPath === undefined) { - libPath = path.resolve(__dirname, '../public.node'); + libPath = path.resolve(__dirname, '../../public.node'); } else { libPath = path.join(libPath, 'public.node'); } diff --git a/ets2panda/bindings/src/InteropNativeModule.ts b/ets2panda/bindings/src/common/InteropNativeModule.ts similarity index 95% rename from ets2panda/bindings/src/InteropNativeModule.ts rename to ets2panda/bindings/src/common/InteropNativeModule.ts index 35eac9b80641b233c9e1c5e4add9fb2f7d995224..fcc82a57ebd647d95e660ab6b75c63fa29074b72 100644 --- a/ets2panda/bindings/src/InteropNativeModule.ts +++ b/ets2panda/bindings/src/common/InteropNativeModule.ts @@ -60,7 +60,7 @@ export class InteropNativeModule { export function initInterop(): InteropNativeModule { let libPath = process.env.BINDINGS_PATH; if (libPath === undefined) { - libPath = path.resolve(__dirname, '../ts_bindings.node'); + libPath = path.resolve(__dirname, '../../ts_bindings.node'); } else { libPath = path.join(libPath, 'ts_bindings.node'); } @@ -76,7 +76,7 @@ export function initInterop(): InteropNativeModule { export function initPublicInterop(): InteropNativeModule { let libPath = process.env.BINDINGS_PATH; if (libPath === undefined) { - libPath = path.resolve(__dirname, '../public.node'); + libPath = path.resolve(__dirname, '../../public.node'); } else { libPath = path.join(libPath, 'public.node'); } diff --git a/ets2panda/bindings/src/InteropTypes.ts b/ets2panda/bindings/src/common/InteropTypes.ts similarity index 100% rename from ets2panda/bindings/src/InteropTypes.ts rename to ets2panda/bindings/src/common/InteropTypes.ts diff --git a/ets2panda/bindings/src/Platform.ts b/ets2panda/bindings/src/common/Platform.ts similarity index 100% rename from ets2panda/bindings/src/Platform.ts rename to ets2panda/bindings/src/common/Platform.ts diff --git a/ets2panda/bindings/src/Wrapper.ts b/ets2panda/bindings/src/common/Wrapper.ts similarity index 100% rename from ets2panda/bindings/src/Wrapper.ts rename to ets2panda/bindings/src/common/Wrapper.ts diff --git a/ets2panda/bindings/src/build/generateArkTSConfig.ts b/ets2panda/bindings/src/common/arkTSConfigGenerator.ts similarity index 62% rename from ets2panda/bindings/src/build/generateArkTSConfig.ts rename to ets2panda/bindings/src/common/arkTSConfigGenerator.ts index fe1dc108fc57d5604614ef0e4498e76d8f1b21c5..5b2a1ee5f9b999b9ebe4a6ba658caaf301ddb078 100644 --- a/ets2panda/bindings/src/build/generateArkTSConfig.ts +++ b/ets2panda/bindings/src/common/arkTSConfigGenerator.ts @@ -16,14 +16,14 @@ import * as path from 'path'; import * as fs from 'fs'; -import { changeFileExtension, ensurePathExists } from '../utils'; -import { BuildConfig, ModuleInfo } from '../types'; -import { LANGUAGE_VERSION, SYSTEM_SDK_PATH_FROM_SDK } from '../preDefine'; +import { changeFileExtension, ensurePathExists } from './utils'; +import { BuildConfig, ModuleInfo } from './types'; +import { LANGUAGE_VERSION, PANDA_SDK_PATH_FROM_SDK, SYSTEM_SDK_PATH_FROM_SDK } from './preDefine'; -interface DynamicPathItem { +interface DependencyItem { language: string; - declPath: string; - runtimeName: string; + path: string; + ohmUrl: string; } interface ArkTSConfigObject { @@ -31,9 +31,8 @@ interface ArkTSConfigObject { package: string; baseUrl: string; paths: Record; - dependencies: string[] | undefined; entry: string; - dynamicPaths: Record; + dependencies: Record; }; } @@ -42,22 +41,24 @@ export class ArkTSConfigGenerator { private stdlibStdPath: string; private stdlibEscompatPath: string; private systemSdkPath: string; + private externalApiPath: string; - private moduleInfos: Map; + private moduleInfos: Record; private pathSection: Record; - private constructor(buildConfig: BuildConfig, moduleInfos: Map) { - let pandaStdlibPath: string = - buildConfig.pandaStdlibPath ?? path.resolve(buildConfig.pandaSdkPath!!, 'lib', 'stdlib'); + private constructor(buildConfig: BuildConfig, moduleInfos: Record) { + let pandaSdkPath = path.resolve(buildConfig.buildSdkPath, PANDA_SDK_PATH_FROM_SDK); + let pandaStdlibPath: string = path.resolve(pandaSdkPath, 'lib', 'stdlib'); this.stdlibStdPath = path.resolve(pandaStdlibPath, 'std'); this.stdlibEscompatPath = path.resolve(pandaStdlibPath, 'escompat'); this.systemSdkPath = path.resolve(buildConfig.buildSdkPath, SYSTEM_SDK_PATH_FROM_SDK); + this.externalApiPath = buildConfig.externalApiPath !== undefined ? buildConfig.externalApiPath : ''; this.moduleInfos = moduleInfos; this.pathSection = {}; } - public static getInstance(buildConfig?: BuildConfig, moduleInfos?: Map): ArkTSConfigGenerator { + public static getInstance(buildConfig?: BuildConfig, moduleInfos?: Record): ArkTSConfigGenerator { if (!ArkTSConfigGenerator.instance) { if (!buildConfig || !moduleInfos) { throw new Error('buildConfig and moduleInfos is required for the first instantiation of ArkTSConfigGenerator.'); @@ -67,7 +68,7 @@ export class ArkTSConfigGenerator { return ArkTSConfigGenerator.instance; } - public static getGenerator(buildConfig: BuildConfig, moduleInfos: Map): ArkTSConfigGenerator { + public static getGenerator(buildConfig: BuildConfig, moduleInfos: Record): ArkTSConfigGenerator { return new ArkTSConfigGenerator(buildConfig, moduleInfos); } @@ -76,11 +77,20 @@ export class ArkTSConfigGenerator { } private generateSystemSdkPathSection(pathSection: Record): void { - function traverse(currentDir: string, relativePath: string = '', isExcludedDir: boolean = false): void { + function traverse( + currentDir: string, + relativePath: string = '', + isExcludedDir: boolean = false, + allowedExtensions: string[] = ['.d.ets'] + ): void { const items = fs.readdirSync(currentDir); for (const item of items) { const itemPath = path.join(currentDir, item); const stat = fs.statSync(itemPath); + const isAllowedFile = allowedExtensions.some((ext) => item.endsWith(ext)); + if (stat.isFile() && !isAllowedFile) { + continue; + } if (stat.isFile()) { const basename = path.basename(item, '.d.ets'); @@ -88,9 +98,9 @@ export class ArkTSConfigGenerator { pathSection[key] = [changeFileExtension(itemPath, '', '.d.ets')]; } if (stat.isDirectory()) { - // For non-arkui files under api dir, + // For files under api dir excluding arkui/runtime-api dir, // fill path section with `"pathFromApi.subdir.fileName" = [${absolute_path_to_file}]`; - // For arkui files under api dir, + // For @koalaui files under arkui/runtime-api dir, // fill path section with `"fileName" = [${absolute_path_to_file}]`. const isCurrentDirExcluded = path.basename(currentDir) === 'arkui' && item === 'runtime-api'; const newRelativePath = isCurrentDirExcluded ? '' : relativePath ? `${relativePath}.${item}` : item; @@ -99,17 +109,18 @@ export class ArkTSConfigGenerator { } } - let apiPath: string = path.resolve(this.systemSdkPath, 'api'); - fs.existsSync(apiPath) ? traverse(apiPath) : console.error(`sdk path ${apiPath} not exist.`); - - let arktsPath: string = path.resolve(this.systemSdkPath, 'arkts'); - fs.existsSync(arktsPath) ? traverse(arktsPath) : console.error(`sdk path ${arktsPath} not exist.`); - - let kitsPath: string = path.resolve(this.systemSdkPath, 'kits'); - fs.existsSync(kitsPath) ? traverse(kitsPath) : console.error(`sdk path ${kitsPath} not exist.`); + let directoryNames: string[] = ['api', 'arkts', 'kits']; + directoryNames.forEach((dir) => { + let systemSdkPath = path.resolve(this.systemSdkPath, dir); + let externalApiPath = path.resolve(this.externalApiPath, dir); + fs.existsSync(systemSdkPath) ? traverse(systemSdkPath) : console.warn(`sdk path ${systemSdkPath} not exist.`); + fs.existsSync(externalApiPath) + ? traverse(externalApiPath) + : console.warn(`sdk path ${externalApiPath} not exist.`); + }); } - private getPathSection(): Record { + private getPathSection(moduleInfo: ModuleInfo): Record { if (Object.keys(this.pathSection).length !== 0) { return this.pathSection; } @@ -119,32 +130,24 @@ export class ArkTSConfigGenerator { this.generateSystemSdkPathSection(this.pathSection); - this.moduleInfos.forEach((moduleInfo: ModuleInfo, packageName: string) => { - if (moduleInfo.language === LANGUAGE_VERSION.ARKTS_1_2) { - this.pathSection[moduleInfo.packageName] = [path.resolve(moduleInfo.moduleRootPath, moduleInfo.sourceRoots[0])]; - } + Object.values(moduleInfo.staticDepModuleInfos).forEach((depModuleName: string) => { + let depModuleInfo = this.moduleInfos[depModuleName]; + this.pathSection[depModuleInfo.packageName] = [path.resolve(depModuleInfo.moduleRootPath)]; }); return this.pathSection; } - private getDependenciesSection(moduleInfo: ModuleInfo, dependenciesSection: string[]): void { - let depModules: Map = moduleInfo.staticDepModuleInfos; - depModules.forEach((depModuleInfo: ModuleInfo) => { - dependenciesSection.push(depModuleInfo.arktsConfigFile); - }); - } - private getOhmurl(file: string, moduleInfo: ModuleInfo): string { let unixFilePath: string = file.replace(/\\/g, '/'); let ohmurl: string = moduleInfo.packageName + '/' + unixFilePath; return changeFileExtension(ohmurl, ''); } - private getDynamicPathSection(moduleInfo: ModuleInfo, dynamicPathSection: Record): void { - let depModules: Map = moduleInfo.dynamicDepModuleInfos; - - depModules.forEach((depModuleInfo: ModuleInfo) => { + private getDependenciesSection(moduleInfo: ModuleInfo, dependencySection: Record): void { + let depModules: string[] = moduleInfo.dynamicDepModuleInfos; + depModules.forEach((depModuleName: string) => { + let depModuleInfo = this.moduleInfos[depModuleName]; if (!depModuleInfo.declFilesPath || !fs.existsSync(depModuleInfo.declFilesPath)) { console.error(`Module ${moduleInfo.packageName} depends on dynamic module ${depModuleInfo.packageName}, but decl file not found on path ${depModuleInfo.declFilesPath}`); @@ -153,39 +156,34 @@ export class ArkTSConfigGenerator { let declFilesObject = JSON.parse(fs.readFileSync(depModuleInfo.declFilesPath, 'utf-8')); Object.keys(declFilesObject.files).forEach((file: string) => { let ohmurl: string = this.getOhmurl(file, depModuleInfo); - dynamicPathSection[ohmurl] = { + dependencySection[ohmurl] = { language: 'js', - declPath: declFilesObject.files[file].declPath, - runtimeName: declFilesObject.files[file].ohmUrl + path: declFilesObject.files[file].declPath, + ohmUrl: declFilesObject.files[file].ohmUrl }; let absFilePath: string = path.resolve(depModuleInfo.moduleRootPath, file); let entryFileWithoutExtension: string = changeFileExtension(depModuleInfo.entryFile, ''); if (absFilePath === entryFileWithoutExtension) { - dynamicPathSection[depModuleInfo.packageName] = dynamicPathSection[ohmurl]; + dependencySection[depModuleInfo.packageName] = dependencySection[ohmurl]; } }); }); } public writeArkTSConfigFile(moduleInfo: ModuleInfo): void { - if (!moduleInfo.sourceRoots || moduleInfo.sourceRoots.length === 0) { - console.error('SourceRoots not set from hvigor.'); - } - let pathSection = this.getPathSection(); - let dependenciesSection: string[] = []; - let dynamicPathSection: Record = {}; - this.getDynamicPathSection(moduleInfo, dynamicPathSection); + let pathSection = this.getPathSection(moduleInfo); + let dependencySection: Record = {}; + this.getDependenciesSection(moduleInfo, dependencySection); - let baseUrl: string = path.resolve(moduleInfo.moduleRootPath, moduleInfo.sourceRoots[0]); + let baseUrl: string = path.resolve(moduleInfo.moduleRootPath); let arktsConfig: ArkTSConfigObject = { compilerOptions: { package: moduleInfo.packageName, baseUrl: baseUrl, paths: pathSection, - dependencies: dependenciesSection.length === 0 ? undefined : dependenciesSection, entry: moduleInfo.entryFile, - dynamicPaths: dynamicPathSection + dependencies: dependencySection } }; diff --git a/ets2panda/bindings/src/arrays.ts b/ets2panda/bindings/src/common/arrays.ts similarity index 94% rename from ets2panda/bindings/src/arrays.ts rename to ets2panda/bindings/src/common/arrays.ts index d0fe7499458c408d5b0467407f3d97bfc65007ab..75483d12dbba15e807d3867b1afadc17fafa3002 100644 --- a/ets2panda/bindings/src/arrays.ts +++ b/ets2panda/bindings/src/common/arrays.ts @@ -42,6 +42,15 @@ export function withStringArray(strings: Array | undefined): Uint8Array return array; } +export function withBigingArray(bigints: Array | undefined): Uint8Array { + if (bigints === undefined || bigints.length === 0) { + throwError('Error in strings array'); + } + + let array = encoder.encodeBigintArray(bigints); + return array; +} + function withArray(data: C | undefined, exec: ExecWithLength): R { return exec(data ?? null, data?.length ?? 0); } diff --git a/ets2panda/bindings/src/driver_helper.ts b/ets2panda/bindings/src/common/driver_helper.ts similarity index 73% rename from ets2panda/bindings/src/driver_helper.ts rename to ets2panda/bindings/src/common/driver_helper.ts index 29f82f3d0133095d21558faa4e4d3a501234b6ac..4bd68da844cfb88951afb8fa9b857efc8856deeb 100644 --- a/ets2panda/bindings/src/driver_helper.ts +++ b/ets2panda/bindings/src/common/driver_helper.ts @@ -16,9 +16,10 @@ import { Context, Config } from './types'; import { global } from './global'; import { throwError } from './utils'; -import { Es2pandaContextState } from './generated/Es2pandaEnums'; +import { Es2pandaContextState } from '../generated/Es2pandaEnums'; import { withStringResult } from './Platform'; -import { KBoolean, KNativePointer, KPointer } from './InteropTypes'; +import { KBoolean, KInt, KNativePointer, KPointer } from './InteropTypes'; +import { passStringArray } from './private'; export class DriverHelper { constructor(filePath: string, cmd: string[]) { @@ -76,19 +77,46 @@ export class DriverHelper { global.destroyCfg(); } - public generateTsDecl(declOutPath: string, etsOutPath: string, exportAll: boolean): void { + public generateTsDecl(declOutPath: string, etsOutPath: string, exportAll: boolean, isolated: boolean): void { let exportAll_: KBoolean = exportAll ? 1 : 0; - global.es2panda._GenerateTsDeclarationsFromContext(this._cfg.peer, declOutPath, etsOutPath, exportAll_); + let isolated_: KBoolean = isolated ? 1 : 0; + global.es2panda._GenerateTsDeclarationsFromContext(this._cfg.peer, declOutPath, etsOutPath, exportAll_, isolated_); } } export class LspDriverHelper { - public createCfg(cmd: string[], filePath: string, pandaLibPath: string): Config { + public memInitialize(pandaLibPath: string): void { + global.es2pandaPublic._MemInitialize(pandaLibPath); + } + + public memFinalize(): void { + global.es2pandaPublic._MemFinalize(); + } + + public createGlobalContext(config: KNativePointer, externalFileList: string[], fileNum: KInt): KNativePointer { + return global.es2pandaPublic._CreateGlobalContext(config, passStringArray(externalFileList), fileNum); + } + + public destroyGlobalContext(context: KNativePointer): void { + global.es2pandaPublic._DestroyGlobalContext(context); + } + + public createCfg(cmd: string[], filePath: string, pandaLibPath: string = ''): Config { return Config.create(cmd, filePath, pandaLibPath, true); } - public createCtx(source: string, filePath: string, cfg: Config): KNativePointer { - return Context.lspCreateFromString(source, filePath, cfg); + public createCtx( + source: string, + filePath: string, + cfg: Config, + globalContextPtr?: KNativePointer, + isExternal: boolean = false + ): KNativePointer { + if (globalContextPtr) { + return Context.lspCreateCacheContextFromString(source, filePath, cfg, globalContextPtr, isExternal); + } else { + return Context.lspCreateFromString(source, filePath, cfg); + } } public proceedToState(ctx: KNativePointer, state: Es2pandaContextState): void { diff --git a/ets2panda/bindings/src/global.ts b/ets2panda/bindings/src/common/global.ts similarity index 97% rename from ets2panda/bindings/src/global.ts rename to ets2panda/bindings/src/common/global.ts index 2c99dce5caf8834048741b4c88d1f713df2cd8d1..b6841d5e5fb6dd6ecd41df67f522238b72bdc3ce 100644 --- a/ets2panda/bindings/src/global.ts +++ b/ets2panda/bindings/src/common/global.ts @@ -22,9 +22,8 @@ import { initPublicEs2panda, initPublicGeneratedEs2panda } from './Es2pandaNativeModule'; -import { Es2pandaNativeModule as GeneratedEs2pandaNativeModule } from './generated/Es2pandaNativeModule'; +import { Es2pandaNativeModule as GeneratedEs2pandaNativeModule } from '../generated/Es2pandaNativeModule'; import { initInterop, InteropNativeModule, initPublicInterop } from './InteropNativeModule'; -import { Context } from './types'; // CC-OFFNXT(G.NAM.01) project code style export class global { diff --git a/ets2panda/bindings/src/loadLibraries.ts b/ets2panda/bindings/src/common/loadLibraries.ts similarity index 100% rename from ets2panda/bindings/src/loadLibraries.ts rename to ets2panda/bindings/src/common/loadLibraries.ts diff --git a/ets2panda/bindings/src/mainWrapper.ts b/ets2panda/bindings/src/common/mainWrapper.ts similarity index 100% rename from ets2panda/bindings/src/mainWrapper.ts rename to ets2panda/bindings/src/common/mainWrapper.ts diff --git a/ets2panda/bindings/src/preDefine.ts b/ets2panda/bindings/src/common/preDefine.ts similarity index 77% rename from ets2panda/bindings/src/preDefine.ts rename to ets2panda/bindings/src/common/preDefine.ts index b0dc4d7f85d7414a5494160cebb02e6b18b62b68..79f470bd73f3d0e57f550c3dbafd4d309fe08aba 100644 --- a/ets2panda/bindings/src/preDefine.ts +++ b/ets2panda/bindings/src/common/preDefine.ts @@ -15,13 +15,16 @@ export const ARKTSCONFIG_JSON_FILE: string = 'arktsconfig.json'; -export const ABC_SUFFIX: string = '.abc'; - export enum LANGUAGE_VERSION { ARKTS_1_2 = '1.2', ARKTS_1_1 = '1.1', ARKTS_HYBRID = 'hybrid' } +export const DECL_ETS_SUFFIX: string = '.d.ets'; export const PANDA_SDK_PATH_FROM_SDK: string = './build-tools/ets2panda'; export const SYSTEM_SDK_PATH_FROM_SDK: string = './'; +export const EXTERNAL_API_PATH_FROM_SDK: string = '../../../hms/ets/ets1.2'; +export const DEFAULT_CACHE_DIR: string = './.idea/.deveco'; +export const ETS_SUFFIX: string = '.ets'; +export const TS_SUFFIX: string = '.ts'; diff --git a/ets2panda/bindings/src/private.ts b/ets2panda/bindings/src/common/private.ts similarity index 87% rename from ets2panda/bindings/src/private.ts rename to ets2panda/bindings/src/common/private.ts index 777aad9066bcee2f3e76ede341d48ea2057b884e..3ad06d3be69edede57a0f02e5bcbaafbca66c6b8 100644 --- a/ets2panda/bindings/src/private.ts +++ b/ets2panda/bindings/src/common/private.ts @@ -15,9 +15,9 @@ import { throwError } from './utils'; import { KNativePointer, nullptr } from './InteropTypes'; -import { withString, withStringArray } from './arrays'; +import { withString, withStringArray, withBigingArray } from './arrays'; import { NativePtrDecoder, withStringResult } from './Platform'; -import { LspDiagsNode, LspNode } from './lspNode'; +import { LspDiagsNode, LspNode } from '../lsp/lspNode'; export function lspData(peer: KNativePointer): LspNode { return new LspDiagsNode(peer); @@ -63,3 +63,7 @@ export function passString(str: string | undefined): string { export function passStringArray(strings: string[]): Uint8Array { return withStringArray(strings); } + +export function passPointerArray(pointers: KNativePointer[]): Uint8Array { + return withBigingArray(pointers.map((pointer) => BigInt(Number(pointer)))); +} diff --git a/ets2panda/bindings/src/strings.ts b/ets2panda/bindings/src/common/strings.ts similarity index 86% rename from ets2panda/bindings/src/strings.ts rename to ets2panda/bindings/src/common/strings.ts index ff72c1626e279be2e4e2a098b25fac2aaa3d84f5..4e0a118ad1b41663ae8cdcfa330936b90eaf35d1 100644 --- a/ets2panda/bindings/src/strings.ts +++ b/ets2panda/bindings/src/common/strings.ts @@ -122,6 +122,37 @@ export class CustomTextEncoder { return array; } + encodedBigintLength(value: bigint): int32 { + let str = value.toString(); + return this.encodedLength(str); + } + + encodeBigintInto(value: bigint, result: Uint8Array, position: int32): Uint8Array { + let str = value.toString(); + return this.encodeInto(str, result, position); + } + + encodeBigintArray(bigints: Array): Uint8Array { + let totalBytes = CustomTextEncoder.HeaderLen; + let lengths = new Int32Array(bigints.length); + for (let i = 0; i < lengths.length; i++) { + let len = this.encodedBigintLength(bigints[i]); + lengths[i] = len; + totalBytes += len + CustomTextEncoder.HeaderLen; + } + let array = new Uint8Array(totalBytes); + let position = 0; + this.addLength(array, position, lengths.length); + position += CustomTextEncoder.HeaderLen; + for (let i = 0; i < lengths.length; i++) { + this.addLength(array, position, lengths[i]); + position += CustomTextEncoder.HeaderLen; + this.encodeBigintInto(bigints[i], array, position); + position += lengths[i]; + } + return array; + } + encodeInto(input: string, result: Uint8Array, position: int32): Uint8Array { if (this.encoder !== undefined) { this.encoder!.encodeInto(input, result.subarray(position, result.length)); diff --git a/ets2panda/bindings/src/ts-reflection.ts b/ets2panda/bindings/src/common/ts-reflection.ts similarity index 100% rename from ets2panda/bindings/src/ts-reflection.ts rename to ets2panda/bindings/src/common/ts-reflection.ts diff --git a/ets2panda/bindings/src/types.ts b/ets2panda/bindings/src/common/types.ts similarity index 73% rename from ets2panda/bindings/src/types.ts rename to ets2panda/bindings/src/common/types.ts index 2a34d968b7c5a540cb7d7cfa7f17e0c7622eb623..4cfa5e7b12bae48ed41be89a8f085b868e8d5e28 100644 --- a/ets2panda/bindings/src/types.ts +++ b/ets2panda/bindings/src/common/types.ts @@ -13,11 +13,12 @@ * limitations under the License. */ -import { KNativePointer as KPtr } from './InteropTypes'; +import { KNativePointer, KNativePointer as KPtr } from './InteropTypes'; import { global } from './global'; import { throwError } from './utils'; import { passString, passStringArray, unpackString } from './private'; import { isNullPtr } from './Wrapper'; +import { Worker as ThreadWorker } from 'worker_threads'; export const arrayOfNullptr = new BigUint64Array([BigInt(0)]); @@ -109,6 +110,25 @@ export class Context extends ArktsObject { } return global.es2pandaPublic._CreateContextFromString(cfg.peer, passString(source), passString(filePath)); } + + static lspCreateCacheContextFromString( + source: string, + filePath: string, + cfg: Config, + globalContextPtr: KNativePointer, + isExternal: boolean + ): KPtr { + if (cfg === undefined) { + throwError(`Config not initialized`); + } + return global.es2pandaPublic._CreateCacheContextFromString( + cfg.peer, + passString(source), + passString(filePath), + globalContextPtr, + isExternal + ); + } } // ProjectConfig begins @@ -116,30 +136,22 @@ export interface PluginsConfig { [pluginName: string]: string; } -export interface BuildBaseConfig { - buildType: 'build' | 'preview' | 'hotreload' | 'coldreload'; - buildMode: 'Debug' | 'Release'; - hasMainModule: boolean; - arkts: object; - arktsGlobal: object; -} - export interface ModuleConfig { packageName: string; moduleType: string; moduleRootPath: string; - sourceRoots: string[]; + language: string; + declFilesPath?: string; + dependencies?: string[]; } export interface PathConfig { - loaderOutPath: string; - declgenDtsOutPath: string; - declgenTsOutPath: string; - cachePath: string; buildSdkPath: string; - pandaSdkPath?: string; // path to panda sdk lib/bin, for local test - pandaStdlibPath?: string; // path to panda sdk stdlib, for local test - abcLinkerPath?: string; + projectPath: string; + declgenOutDir: string; + cacheDir?: string; + externalApiPath?: string; + aceModuleJsonPath?: string; } export interface DeclgenConfig { @@ -148,51 +160,59 @@ export interface DeclgenConfig { declgenBridgeCodePath?: string; } -export interface LoggerConfig { - getHvigorConsoleLogger?: Function; -} - -export interface DependentModuleConfig { - packageName: string; - moduleName: string; - moduleType: string; - modulePath: string; - sourceRoots: string[]; - entryFile: string; - language: string; - declFilesPath?: string; - dependencies?: string[]; -} - -export interface BuildConfig extends BuildBaseConfig, DeclgenConfig, LoggerConfig, ModuleConfig, PathConfig { +export interface BuildConfig extends DeclgenConfig, ModuleConfig, PathConfig { plugins: PluginsConfig; compileFiles: string[]; - dependentModuleList: DependentModuleConfig[]; } // ProjectConfig ends -export interface CompileFileInfo { - filePath: string; - dependentFiles: string[]; - abcFilePath: string; - arktsConfigFile: string; - packageName: string; -} - export interface ModuleInfo { - isMainModule: boolean; packageName: string; moduleRootPath: string; moduleType: string; - sourceRoots: string[]; entryFile: string; arktsConfigFile: string; - compileFileInfos: CompileFileInfo[]; + compileFiles: string[]; declgenV1OutPath: string | undefined; declgenBridgeCodePath: string | undefined; + staticDepModuleInfos: string[]; + dynamicDepModuleInfos: string[]; + language: string; dependencies?: string[]; - staticDepModuleInfos: Map; - dynamicDepModuleInfos: Map; - language?: string; declFilesPath?: string; } + +export interface Job { + id: string; + isDeclFile: boolean; + isInCycle?: boolean; + fileList: string[]; + dependencies: string[]; + dependants: string[]; + isValid: boolean; +} + +export interface JobInfo { + id: string; + filePath: string; + arktsConfigFile: string; + globalContextPtr: KNativePointer; + buildConfig: BuildConfig; + isValid: boolean; +} + +export interface FileDepsInfo { + dependencies: Record; + dependants: Record; +} + +export interface WorkerInfo { + worker: ThreadWorker; + isIdle: boolean; +} +export interface TextDocumentChangeInfo { + newDoc: string; + rangeStart?: number; + rangeEnd?: number; + updateText?: string; +} diff --git a/ets2panda/bindings/src/ui_plugins_driver.ts b/ets2panda/bindings/src/common/ui_plugins_driver.ts similarity index 93% rename from ets2panda/bindings/src/ui_plugins_driver.ts rename to ets2panda/bindings/src/common/ui_plugins_driver.ts index 1d30fb980313a62dfab333d979f6b776ca207725..464cd6b396dc8ef61bd9036fdb0dd07084331c12 100644 --- a/ets2panda/bindings/src/ui_plugins_driver.ts +++ b/ets2panda/bindings/src/common/ui_plugins_driver.ts @@ -65,12 +65,14 @@ class PluginContext { private program: object | undefined; private projectConfig: object | undefined; private contextPtr: KNativePointer | undefined; + private codingFilePath: string | undefined; constructor() { this.ast = undefined; this.program = undefined; this.projectConfig = undefined; this.contextPtr = undefined; + this.codingFilePath = undefined; } public setArkTSAst(ast: object): void { @@ -104,6 +106,18 @@ class PluginContext { public getContextPtr(): KNativePointer | undefined { return this.contextPtr; } + + public setCodingFilePath(codingFilePath: string): void { + this.codingFilePath = codingFilePath; + } + + public getCodingFilePath(): string | undefined { + return this.codingFilePath; + } + + public isCoding(): boolean { + return this.codingFilePath !== undefined; + } } export class PluginDriver { diff --git a/ets2panda/bindings/src/utils.ts b/ets2panda/bindings/src/common/utils.ts similarity index 64% rename from ets2panda/bindings/src/utils.ts rename to ets2panda/bindings/src/common/utils.ts index 5e21866cc6fe8a7bfe6763bde7ce076f6abf8ea2..800f92b064490f638bf0e71299ed0809ab6bcf76 100644 --- a/ets2panda/bindings/src/utils.ts +++ b/ets2panda/bindings/src/common/utils.ts @@ -15,6 +15,8 @@ import * as fs from 'fs'; import * as path from 'path'; +import * as os from 'os'; +import { DECL_ETS_SUFFIX } from './preDefine'; export function throwError(error: string): never { throw new Error(error); @@ -43,3 +45,25 @@ export function ensurePathExists(filePath: string): void { } } } + +export function isMac(): boolean { + return os.type() === 'Darwin'; +} + +export function changeDeclgenFileExtension(file: string, targetExt: string): string { + if (file.endsWith(DECL_ETS_SUFFIX)) { + return changeFileExtension(file, targetExt, DECL_ETS_SUFFIX); + } + return changeFileExtension(file, targetExt); +} + +export function getModuleNameAndPath(filePath: string, projectPath: string): [string, string] { + let moduleName: string = ''; + let moduleRootPath: string = ''; + if (filePath.indexOf(projectPath) >= 0) { + const relativePath = path.relative(projectPath, filePath); + moduleName = relativePath.split(path.sep)[0]; + moduleRootPath = path.join(projectPath, moduleName); + } + return [moduleName, moduleRootPath]; +} diff --git a/ets2panda/bindings/src/generated/Es2pandaNativeModule.ts b/ets2panda/bindings/src/generated/Es2pandaNativeModule.ts index 8bd49b74b2f0d7c05b5b93ba613015467b5282c1..bb53f1d512a49c81af2aaf9a797748ea9f96f4d7 100644 --- a/ets2panda/bindings/src/generated/Es2pandaNativeModule.ts +++ b/ets2panda/bindings/src/generated/Es2pandaNativeModule.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import { KBoolean, KInt, KNativePointer } from '../InteropTypes'; +import { KBoolean, KInt, KNativePointer } from '../common/InteropTypes'; export class Es2pandaNativeModule { _CreateMemberExpression( diff --git a/ets2panda/bindings/src/index.ts b/ets2panda/bindings/src/index.ts index 7f572287111d7951aa275ad6f477cfece9b7cc24..d508b948c88a327860440a69dc67f46dfc34172e 100644 --- a/ets2panda/bindings/src/index.ts +++ b/ets2panda/bindings/src/index.ts @@ -13,19 +13,4 @@ * limitations under the License. */ -export { Lsp } from './lsp_helper'; -export { DriverHelper } from './driver_helper'; -export { Es2pandaContextState } from './generated/Es2pandaEnums'; -export { - LspCompletionInfo, - LspCompletionEntryKind, - LspDefinitionData, - LspDiagsNode, - LspDiagnosticNode, - LspDiagSeverity, - LspQuickInfo, - LspSymbolDisplayPart -} from './lspNode'; -export { generateArkTsConfigByModules } from './arktsConfigGenerate'; -export type { ModuleDescriptor } from './buildConfigGenerate'; -export type { TextDocumentChangeInfo } from './lsp_helper'; +export * from './lsp/index'; diff --git a/ets2panda/bindings/src/lsp/compile_thread_worker.ts b/ets2panda/bindings/src/lsp/compile_thread_worker.ts new file mode 100644 index 0000000000000000000000000000000000000000..14cdbd600444e40a33e91fe7a298586216cdaa7f --- /dev/null +++ b/ets2panda/bindings/src/lsp/compile_thread_worker.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { parentPort, workerData } from 'worker_threads'; +import * as fs from 'fs'; +import { PluginDriver, PluginHook } from '../common/ui_plugins_driver'; +import { LspDriverHelper } from '../common/driver_helper'; +import { Es2pandaContextState } from '../generated/Es2pandaEnums'; +import { JobInfo } from '../common/types'; + +const { workerId } = workerData; + +function compileExternalProgram(jobInfo: JobInfo): void { + PluginDriver.getInstance().initPlugins(jobInfo.buildConfig); + let ets2pandaCmd = ['-', '--extension', 'ets', '--arktsconfig', jobInfo.arktsConfigFile]; + let lspDriverHelper = new LspDriverHelper(); + let config = lspDriverHelper.createCfg(ets2pandaCmd, jobInfo.filePath); + if (!fs.existsSync(jobInfo.filePath)) { + return; + } + const source = fs.readFileSync(jobInfo.filePath, 'utf8').replace(/\r\n/g, '\n'); + let context = lspDriverHelper.createCtx(source, jobInfo.filePath, config, jobInfo.globalContextPtr, true); + PluginDriver.getInstance().getPluginContext().setContextPtr(context); + lspDriverHelper.proceedToState(context, Es2pandaContextState.ES2PANDA_STATE_PARSED); + PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + lspDriverHelper.proceedToState(context, Es2pandaContextState.ES2PANDA_STATE_LOWERED); +} + +parentPort?.on('message', (msg) => { + if (msg.type === 'ASSIGN_TASK') { + const job = msg.jobInfo; + if (!job.isValid) { + compileExternalProgram(job); + } + + parentPort?.postMessage({ + type: 'TASK_FINISH', + jobId: job.id, + workerId + }); + } else if (msg.type === 'EXIT') { + process.exit(0); + } +}); diff --git a/ets2panda/bindings/src/lsp/generateArkTSConfig.ts b/ets2panda/bindings/src/lsp/generateArkTSConfig.ts new file mode 100644 index 0000000000000000000000000000000000000000..fae5a16029d155265c52a0df422300ce6b748559 --- /dev/null +++ b/ets2panda/bindings/src/lsp/generateArkTSConfig.ts @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as path from 'path'; + +import { ARKTSCONFIG_JSON_FILE, LANGUAGE_VERSION } from '../common/preDefine'; +import { BuildConfig, ModuleInfo } from '../common/types'; +import { ArkTSConfigGenerator } from '../common/arkTSConfigGenerator'; + +function collectDepModuleInfos(moduleInfo: ModuleInfo, allBuildConfig: Record): void { + let dynamicDepModules: string[] = []; + let staticDepModules: string[] = []; + + if (moduleInfo.dependencies) { + moduleInfo.dependencies.forEach((moduleName: string) => { + let depModule = allBuildConfig[moduleName]; + depModule.language === LANGUAGE_VERSION.ARKTS_1_2 + ? staticDepModules.push(depModule.packageName) + : dynamicDepModules.push(depModule.packageName); + }); + } + moduleInfo.dynamicDepModuleInfos = dynamicDepModules; + moduleInfo.staticDepModuleInfos = staticDepModules; +} + +function collectModuleInfos(allBuildConfig: Record): Record { + let moduleInfos: Record = {}; + Object.values(allBuildConfig).forEach((buildConfig) => { + let moduleInfo = generateModuleInfo(allBuildConfig, buildConfig); + moduleInfos[moduleInfo.packageName] = moduleInfo; + }); + return moduleInfos; +} + +export function generateModuleInfo(allBuildConfig: Record, buildConfig: BuildConfig): ModuleInfo { + if (!buildConfig.packageName || !buildConfig.moduleRootPath) { + console.error('Main buildConfig info from hvigor is not correct.'); + } + let moduleInfo: ModuleInfo = { + packageName: buildConfig.packageName, + moduleRootPath: buildConfig.moduleRootPath, + moduleType: buildConfig.moduleType, + entryFile: buildConfig.packageName !== 'entry' ? path.join(buildConfig.moduleRootPath, 'Index.ets') : '', + arktsConfigFile: path.resolve(buildConfig.cacheDir!, buildConfig.packageName, ARKTSCONFIG_JSON_FILE), + compileFiles: buildConfig.compileFiles, + declgenV1OutPath: buildConfig.declgenV1OutPath, + declgenBridgeCodePath: buildConfig.declgenBridgeCodePath, + staticDepModuleInfos: [], + dynamicDepModuleInfos: [], + language: buildConfig.language, + dependencies: buildConfig.dependencies, + declFilesPath: buildConfig.declFilesPath + }; + collectDepModuleInfos(moduleInfo, allBuildConfig); + return moduleInfo; +} + +export function generateArkTsConfigs(allBuildConfig: Record): Record { + let moduleInfos: Record = collectModuleInfos(allBuildConfig); + Object.keys(moduleInfos).forEach((filePath: string) => { + let packageName = moduleInfos[filePath].packageName; + let generator = ArkTSConfigGenerator.getGenerator(allBuildConfig[packageName], moduleInfos); + generator.writeArkTSConfigFile(moduleInfos[filePath]); + }); + let fileToModuleInfo: Record = {}; + Object.values(moduleInfos).forEach((moduleInfo: ModuleInfo) => { + moduleInfo.compileFiles.forEach((file: string) => { + fileToModuleInfo[file] = moduleInfo; + }); + }); + return fileToModuleInfo; +} diff --git a/ets2panda/bindings/src/buildConfigGenerate.ts b/ets2panda/bindings/src/lsp/generateBuildConfig.ts similarity index 63% rename from ets2panda/bindings/src/buildConfigGenerate.ts rename to ets2panda/bindings/src/lsp/generateBuildConfig.ts index 4d1b1c34d1b2f17fc3f4695db8601732c24d72e6..7eace71cb11d0a6bd3f9445e2a25b66f473516e2 100644 --- a/ets2panda/bindings/src/buildConfigGenerate.ts +++ b/ets2panda/bindings/src/lsp/generateBuildConfig.ts @@ -16,13 +16,15 @@ import * as fs from 'fs'; import * as path from 'path'; import * as JSON5 from 'json5'; -import { BuildConfig } from './types'; +import { BuildConfig, PathConfig } from '../common/types'; +import { DEFAULT_CACHE_DIR, EXTERNAL_API_PATH_FROM_SDK } from '../common/preDefine'; export interface ModuleDescriptor { arktsversion: string; name: string; moduleType: string; srcPath: string; + aceModuleJsonPath?: string; } interface Json5Object { @@ -92,9 +94,8 @@ function getEtsFiles(modulePath: string): string[] { const files: string[] = []; const shouldSkipDirectory = (relativePath: string): boolean => { - const testDir1 = `src${path.sep}test`; - const testDir2 = `src${path.sep}ohosTest`; - return relativePath.startsWith(testDir1) || relativePath.startsWith(testDir2); + const filterList = [`src${path.sep}test`, `src${path.sep}ohosTest`, `build${path.sep}`, `oh_modules${path.sep}`]; + return filterList.some((directoryPrefix: string) => relativePath.startsWith(directoryPrefix)); }; const processEntry = (dir: string, entry: fs.Dirent): void => { @@ -150,81 +151,96 @@ function getModuleDependencies(modulePath: string, visited = new Set()): } }; - const resolveNestedDependencies = (deps: string[]): string[] => { - return deps.flatMap((depPath) => - visited.has(depPath) ? [] : [depPath, ...getModuleDependencies(depPath, visited)] - ); - }; - const dependencies = extractDependencies(); - const nestedDependencies = resolveNestedDependencies(dependencies); - return Array.from(new Set([...dependencies, ...nestedDependencies])); + return Array.from(new Set([...dependencies])); +} + +function createMapEntryForPlugin(buildSdkPath: string, pluginName: string): string { + return path.join(buildSdkPath, 'build-tools', 'ui-plugins', 'lib', pluginName, 'index'); +} + +function createPluginMap(buildSdkPath: string): Record { + let pluginMap: Record = {}; + const pluginList: string[] = ['ui-syntax-plugins', 'ui-plugins', 'memo-plugins']; + for (const plugin of pluginList) { + pluginMap[plugin] = createMapEntryForPlugin(buildSdkPath, plugin); + } + return pluginMap; +} + +function addPluginPathConfigs(buildConfig: BuildConfig, module: ModuleDescriptor): void { + buildConfig.aceModuleJsonPath = module.aceModuleJsonPath; } export function generateBuildConfigs( - buildSdkPath: string, - projectRoot: string, + pathConfig: PathConfig, modules?: ModuleDescriptor[] ): Record { const allBuildConfigs: Record = {}; if (!modules) { - const buildProfilePath = path.join(projectRoot, 'build-profile.json5'); + const buildProfilePath = path.join(pathConfig.projectPath, 'build-profile.json5'); modules = getModulesFromBuildProfile(buildProfilePath); } const definedModules = modules; - const cacheDir = path.join(projectRoot, '.idea', '.deveco'); + + const enableDeclgen: Map = new Map(modules.map((module) => [module.name, false])); for (const module of definedModules) { const modulePath = module.srcPath; const compileFiles = new Set(getEtsFiles(modulePath)); + const pluginMap = createPluginMap(pathConfig.buildSdkPath); // Get recursive dependencies const dependencies = getModuleDependencies(modulePath); for (const depPath of dependencies) { getEtsFiles(depPath).forEach((file) => compileFiles.add(file)); + const depModule = definedModules.find((m) => m.srcPath === depPath); + if (module.arktsversion === '1.1' && depModule?.arktsversion === '1.2') { + enableDeclgen.set(depModule.name, true); + } } allBuildConfigs[module.name] = { - plugins: { - 'ui-plugins': path.join(buildSdkPath, 'build-tools', 'ui-plugins', 'lib', 'ui-plugins', 'index'), - 'memo-plugin': path.join(buildSdkPath, 'build-tools', 'ui-plugins', 'lib', 'memo-plugins', 'index') - }, - arkts: {}, - arktsGlobal: {}, + plugins: pluginMap, compileFiles: Array.from(compileFiles), packageName: module.name, moduleType: module.moduleType, - buildType: 'build', - buildMode: 'Debug', moduleRootPath: modulePath, - sourceRoots: ['./'], - hasMainModule: true, - loaderOutPath: path.join(modulePath, 'build', 'default', 'cache'), - cachePath: cacheDir, - buildSdkPath: buildSdkPath, + language: module.arktsversion, + buildSdkPath: pathConfig.buildSdkPath, + projectPath: pathConfig.projectPath, + declgenOutDir: pathConfig.declgenOutDir, + externalApiPath: pathConfig.externalApiPath + ? pathConfig.externalApiPath + : path.resolve(pathConfig.buildSdkPath, EXTERNAL_API_PATH_FROM_SDK), + cacheDir: + pathConfig.cacheDir !== undefined ? pathConfig.cacheDir : path.join(pathConfig.projectPath, DEFAULT_CACHE_DIR), enableDeclgenEts2Ts: false, - declgenDtsOutPath: path.join(modulePath, 'build', 'default', 'cache'), - declgenTsOutPath: path.join(modulePath, 'build', 'default', 'cache'), - dependentModuleList: dependencies.map((dep) => { + declFilesPath: + module.arktsversion === '1.1' + ? path.join(pathConfig.declgenOutDir, 'static', module.name, 'decl-fileInfo.json') + : undefined, + dependencies: dependencies.map((dep) => { const depModule = definedModules.find((m) => m.srcPath === dep); - return { - packageName: path.basename(dep), - moduleName: path.basename(dep), - moduleType: depModule ? depModule.moduleType : 'har', - modulePath: dep, - sourceRoots: ['./'], - entryFile: 'index.ets', - language: depModule ? depModule.arktsversion : '1.1' - }; + return depModule!.name; }) }; + addPluginPathConfigs(allBuildConfigs[module.name], module); } - const outputPath = path.join(cacheDir, 'lsp_build_config.json'); - if (!fs.existsSync(cacheDir)) { - fs.mkdirSync(cacheDir, { recursive: true }); - } - fs.writeFileSync(outputPath, JSON.stringify(allBuildConfigs, null, 4)); + Object.entries(allBuildConfigs).forEach(([key, config]) => { + if (enableDeclgen.get(key) === true) { + config.enableDeclgenEts2Ts = true; + config.declgenV1OutPath = path.join(pathConfig.declgenOutDir, 'dynamic', key, 'declgenV1'); + config.declgenBridgeCodePath = path.join(pathConfig.declgenOutDir, 'dynamic', key, 'declgenBridgeCode'); + if (!fs.existsSync(config.declgenV1OutPath)) { + fs.mkdirSync(config.declgenV1OutPath, { recursive: true }); + } + if (!fs.existsSync(config.declgenBridgeCodePath)) { + fs.mkdirSync(config.declgenBridgeCodePath, { recursive: true }); + } + } + }); return allBuildConfigs; } diff --git a/ets2panda/bindings/src/lsp/index.ts b/ets2panda/bindings/src/lsp/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..effe67f08670ee67f0bfb3e486fd3060c32c7470 --- /dev/null +++ b/ets2panda/bindings/src/lsp/index.ts @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { Lsp } from './lsp_helper'; +export { Es2pandaContextState } from '../generated/Es2pandaEnums'; +export { + LspCompletionInfo, + LspCompletionEntryKind, + LspDefinitionData, + LspDiagsNode, + LspDiagnosticNode, + LspDiagSeverity, + LspQuickInfo, + LspSymbolDisplayPart +} from './lspNode'; +export type { ModuleDescriptor } from './generateBuildConfig'; +export type { PathConfig, TextDocumentChangeInfo } from '../common/types'; diff --git a/ets2panda/bindings/src/lspNode.ts b/ets2panda/bindings/src/lsp/lspNode.ts similarity index 83% rename from ets2panda/bindings/src/lspNode.ts rename to ets2panda/bindings/src/lsp/lspNode.ts index 17f846fce21df036fb1b966dca1ac0218aeff665..492350d708ede2822d13b30c4aa46f007edb110b 100644 --- a/ets2panda/bindings/src/lspNode.ts +++ b/ets2panda/bindings/src/lsp/lspNode.ts @@ -13,17 +13,21 @@ * limitations under the License. */ -import { KBoolean, KInt, KNativePointer, KUInt } from './InteropTypes'; -import { unpackString, VariantTypes } from './private'; -import { throwError } from './utils'; -import { isNullPtr } from './Wrapper'; -import { global } from './global'; -import { NativePtrDecoder } from './Platform'; +import { KBoolean, KInt, KNativePointer, KUInt } from '../common/InteropTypes'; +import { unpackString, VariantTypes } from '../common/private'; +import { throwError } from '../common/utils'; +import { isNullPtr } from '../common/Wrapper'; +import { global } from '../common/global'; +import { NativePtrDecoder } from '../common/Platform'; -enum HierarchyType { OTHERS, INTERFACE, CLASS }; +enum HierarchyType { + OTHERS, + INTERFACE, + CLASS +} export enum SetterStyle { - METHOD = 0, + NONE = 0, SETTER, GETTER } @@ -34,7 +38,19 @@ export enum AccessModifierStyle { PRIVATE } -enum ClassRelationKind { UNKNOWN, INTERFACE, CLASS, FIELD, METHOD, PROPERTY }; +enum ClassRelationKind { + UNKNOWN, + INTERFACE, + CLASS, + FIELD, + METHOD, + PROPERTY +} + +export enum ClassDefinitionStyle { + FIELD = 0, + METHOD +} export abstract class LspNode { readonly peer: KNativePointer; @@ -228,30 +244,50 @@ export class LspSymbolDisplayPart extends LspNode { readonly kind: String; } -export class LspClassMethodItem extends LspNode { - constructor(peer: KNativePointer) { +export class LspClassHierarchyItem extends LspNode { + constructor(peer: KNativePointer, style: ClassDefinitionStyle) { super(peer); - this.functionDetail = unpackString(global.es2panda._getDetailFromClassMethodItem(this.peer)); + this.style = style; + this.detail = unpackString(global.es2panda._getDetailFromClassHierarchyItem(this.peer)); + this.accessModifier = global.es2panda._getAccessModifierStyleFromClassHierarchyItem(this.peer); + } + readonly detail: string; + readonly accessModifier: AccessModifierStyle; + readonly style: ClassDefinitionStyle; +} + +export class LspClassMethodItem extends LspClassHierarchyItem { + constructor(peer: KNativePointer) { + super(peer, ClassDefinitionStyle.METHOD); this.setter = global.es2panda._getSetterStyleFromClassMethodItem(this.peer); - this.accessModifier = global.es2panda._getAccessModifierStyleFromClassMethodItem(this.peer); } - readonly functionDetail: string; readonly setter: SetterStyle; - readonly accessModifier: AccessModifierStyle; +} + +export class LspClassPropertyItem extends LspClassHierarchyItem { + constructor(peer: KNativePointer) { + super(peer, ClassDefinitionStyle.FIELD); + } } export class LspClassHierarchyInfo extends LspNode { constructor(peer: KNativePointer) { super(peer); this.className = unpackString(global.es2panda._getClassNameFromClassHierarchyInfo(this.peer)); - this.items = new NativePtrDecoder() - .decode(global.es2panda._getMethodListFromClassHierarchyInfo(this.peer)) + this.methodItems = new NativePtrDecoder() + .decode(global.es2panda._getMethodItemsFromClassHierarchyInfo(this.peer)) .map((elPeer: KNativePointer) => { return new LspClassMethodItem(elPeer); }); + this.fieldItems = new NativePtrDecoder() + .decode(global.es2panda._getPropertyItemsFromClassHierarchyInfo(this.peer)) + .map((elPeer: KNativePointer) => { + return new LspClassPropertyItem(elPeer); + }); } readonly className: string; - readonly items: LspClassMethodItem[]; + readonly methodItems: LspClassMethodItem[]; + readonly fieldItems: LspClassPropertyItem[]; } export class LspClassHierarchy extends LspNode { @@ -299,7 +335,7 @@ export class FieldListProperty extends LspNode { this.modifierKinds = new NativePtrDecoder() .decode(global.es2panda._getModifierKindsFromPropertyInfo(peer)) .map((elPeer: KNativePointer) => { - return new String(elPeer); + return new String(unpackString(elPeer)); }); this.displayName = unpackString(global.es2panda._getDisplayNameFromPropertyInfo(peer)); this.start = global.es2panda._getStartFromPropertyInfo(peer); @@ -464,7 +500,8 @@ export enum LspCompletionEntryKind { STRUCT = 22, EVENT = 23, OPERATOR = 24, - TYPE_PARAMETER = 25 + TYPE_PARAMETER = 25, + ALIAS_TYPE = 26 } export enum ResolutionStatus { @@ -644,6 +681,43 @@ export class FileTextChanges extends LspNode { readonly textChanges: TextChange[]; } +export class CodeActionInfo extends LspNode { + constructor(peer: KNativePointer) { + super(peer); + this.changes = new NativePtrDecoder() + .decode(global.es2panda._getFileTextChangesFromCodeActionInfo(peer)) + .map((elPeer: KNativePointer) => { + return new FileTextChanges(elPeer); + }); + this.description = unpackString(global.es2panda._getDescriptionFromCodeActionInfo(peer)); + } + readonly changes: FileTextChanges[]; + readonly description: String; +} + +export class CodeFixActionInfo extends CodeActionInfo { + constructor(peer: KNativePointer) { + super(peer); + this.fixName = unpackString(global.es2panda._getFixNameFromCodeFixActionInfo(peer)); + this.fixId_ = unpackString(global.es2panda._getFixIdFromCodeFixActionInfo(peer)); + this.fixAllDescription_ = unpackString(global.es2panda._getFixAllDescriptionFromCodeFixActionInfo(peer)); + } + readonly fixName: String; + readonly fixId_: String; + readonly fixAllDescription_: String; +} + +export class CodeFixActionInfoList extends LspNode { + constructor(peer: KNativePointer) { + super(peer); + this.codeFixActionInfos = new NativePtrDecoder() + .decode(global.es2panda._getCodeFixActionInfos(peer)) + .map((elPeer: KNativePointer) => { + return new CodeFixActionInfo(elPeer); + }); + } + readonly codeFixActionInfos: CodeFixActionInfo[]; +} export class LspFileTextChanges extends LspNode { constructor(peer: KNativePointer) { @@ -681,7 +755,7 @@ export class LspSafeDeleteLocation extends LspNode { readonly safeDeleteLocationInfos: LspSafeDeleteLocationInfo[]; } -export class LspRefactorAction extends LspNode { +export class RefactorAction extends LspNode { constructor(peer: KNativePointer) { super(peer); this.name = unpackString(global.es2panda._getRefactorActionName(peer)); @@ -693,17 +767,30 @@ export class LspRefactorAction extends LspNode { readonly kind: String; } -export class LspApplicableRefactorInfo extends LspNode { +export class ApplicableRefactorItemInfo extends LspNode { constructor(peer: KNativePointer) { super(peer); this.name = unpackString(global.es2panda._getApplicableRefactorName(peer)); this.description = unpackString(global.es2panda._getApplicableRefactorDescription(peer)); - this.action = new LspRefactorAction(global.es2panda._getRefactorAction(peer)); + this.action = new RefactorAction(global.es2panda._getApplicableRefactorAction(peer)); } readonly name: String; readonly description: String; - readonly action: LspRefactorAction; + readonly action: RefactorAction; +} + +export class LspApplicableRefactorInfo extends LspNode { + constructor(peer: KNativePointer) { + super(peer); + this.applicableRefactorInfo = new NativePtrDecoder() + .decode(global.es2panda._getApplicableRefactorInfoList(peer)) + .map((elPeer: KNativePointer) => { + return new ApplicableRefactorItemInfo(elPeer); + }); + } + + readonly applicableRefactorInfo: ApplicableRefactorItemInfo[]; } export class LspTypeHierarchies extends LspNode { @@ -853,3 +940,53 @@ export class LspSignatureHelpItems extends LspNode { readonly argumentIndex: number; readonly argumentCount: number; } + +export class LspRenameInfoSuccess extends LspNode { + constructor(peer: KNativePointer) { + super(peer); + this.canRenameSuccess = true; + this.fileToRename = unpackString(global.es2panda._getRenameSuccessFileName(peer)); + this.kind = unpackString(global.es2panda._getRenameSuccessKind(peer)); + this.displayName = unpackString(global.es2panda._getRenameSuccessDisplayName(peer)); + this.fullDisplayName = unpackString(global.es2panda._getRenameSuccessFullDisplayName(peer)); + this.kindModifiers = unpackString(global.es2panda._getRenameSuccessKindModifiers(peer)); + this.triggerSpan = new LspTextSpan(global.es2panda._getRenameSuccessTriggerSpan(peer)); + } + readonly canRenameSuccess: boolean; + readonly fileToRename: string; + readonly kind: string; + readonly displayName: string; + readonly fullDisplayName: string; + readonly kindModifiers: string; + readonly triggerSpan: LspTextSpan; +} + +export class LspRenameInfoFailure extends LspNode { + constructor(peer: KNativePointer) { + super(peer); + this.canRenameFailure = false; + this.localizedErrorMessage = unpackString(global.es2panda._getRenameFailureLocalizedErrorMessage(peer)); + } + readonly canRenameFailure: boolean; + readonly localizedErrorMessage: string; +} + +export type LspRenameInfoType = LspRenameInfoSuccess | LspRenameInfoFailure; + +export class LspRenameLocation extends LspNode { + constructor(peer: KNativePointer) { + super(peer); + this.fileName = unpackString(global.es2panda._getRenameLocationFileName(peer)); + this.start = global.es2panda._getRenameLocationStart(peer); + this.end = global.es2panda._getRenameLocationEnd(peer); + this.line = global.es2panda._getRenameLocationLine(peer); + this.prefixText = unpackString(global.es2panda._getRenameLocationPrefixText(peer)); + this.suffixText = unpackString(global.es2panda._getRenameLocationSuffixText(peer)); + } + readonly fileName: string; + readonly start: number; + readonly end: number; + readonly line: number; + readonly prefixText: string; + readonly suffixText: string; +} diff --git a/ets2panda/bindings/src/lsp_helper.ts b/ets2panda/bindings/src/lsp/lsp_helper.ts similarity index 41% rename from ets2panda/bindings/src/lsp_helper.ts rename to ets2panda/bindings/src/lsp/lsp_helper.ts index b543a2b07ea6fb3041a82eb9e609208085c3fd45..a797b21ca44ad5fe39fa31f576f452fd44f29b6c 100644 --- a/ets2panda/bindings/src/lsp_helper.ts +++ b/ets2panda/bindings/src/lsp/lsp_helper.ts @@ -13,8 +13,8 @@ * limitations under the License. */ -import { LspDriverHelper } from './driver_helper'; -import { global } from './global'; +import { LspDriverHelper } from '../common/driver_helper'; +import { global } from '../common/global'; import { LspDefinitionData, LspDiagsNode, @@ -30,6 +30,7 @@ import { LspLineAndCharacter, LspReferenceData, LspClassConstructorInfo, + ApplicableRefactorItemInfo, LspApplicableRefactorInfo, CompletionEntryDetails, LspFileTextChanges, @@ -40,51 +41,105 @@ import { LspInlayHint, LspInlayHintList, TextSpan, - LspSignatureHelpItems + LspSignatureHelpItems, + CodeFixActionInfo, + CodeFixActionInfoList, + LspRenameLocation, + LspRenameInfoType, + LspRenameInfoSuccess, + LspRenameInfoFailure } from './lspNode'; -import { passStringArray, unpackString } from './private'; -import { Es2pandaContextState } from './generated/Es2pandaEnums'; -import { BuildConfig } from './types'; -import { PluginDriver, PluginHook } from './ui_plugins_driver'; -import { ModuleDescriptor } from './buildConfigGenerate'; -import { generateArkTsConfigByModules } from './arktsConfigGenerate'; +import { passStringArray, unpackString } from '../common/private'; +import { Es2pandaContextState } from '../generated/Es2pandaEnums'; +import { + BuildConfig, + Config, + FileDepsInfo, + Job, + JobInfo, + WorkerInfo, + ModuleInfo, + PathConfig, + TextDocumentChangeInfo +} from '../common/types'; +import { PluginDriver, PluginHook } from '../common/ui_plugins_driver'; +import { ModuleDescriptor, generateBuildConfigs } from './generateBuildConfig'; +import { generateArkTsConfigs, generateModuleInfo } from './generateArkTSConfig'; import * as fs from 'fs'; import * as path from 'path'; +import { KNativePointer, KPointer } from '../common/InteropTypes'; +import { passPointerArray } from '../common/private'; +import { NativePtrDecoder } from '../common/Platform'; +import { Worker as ThreadWorker } from 'worker_threads'; +import { ensurePathExists } from '../common/utils'; +import * as child_process from 'child_process'; +import { DECL_ETS_SUFFIX, DEFAULT_CACHE_DIR, TS_SUFFIX } from '../common/preDefine'; +import * as crypto from 'crypto'; +import * as os from 'os'; +import { + changeDeclgenFileExtension, + getModuleNameAndPath +} from '../common/utils'; const ets2pandaCmdPrefix = ['-', '--extension', 'ets', '--arktsconfig']; function initBuildEnv(): void { const currentPath: string | undefined = process.env.PATH; - let pandaLibPath: string = path.resolve(__dirname, '../../ets2panda/lib'); + let pandaLibPath: string = process.env.PANDA_LIB_PATH + ? process.env.PANDA_LIB_PATH + : path.resolve(__dirname, '../../../ets2panda/lib'); process.env.PATH = `${currentPath}${path.delimiter}${pandaLibPath}`; } -export interface TextDocumentChangeInfo { - newDoc: string; - rangeStart?: number; - rangeEnd?: number; - updateText?: string; -} - export class Lsp { private pandaLibPath: string; - private projectPath: string; - private fileNameToArktsconfig: Record; // Map - private moduleToBuildConfig: Record; // Map + private pandaBinPath: string; private getFileContent: (filePath: string) => string; private filesMap: Map; // Map + private cacheDir: string; + private globalContextPtr?: KNativePointer; + private globalConfig?: Config; + private globalLspDriverHelper?: LspDriverHelper; + private entryArkTsConfig: string; + private fileDependencies: string; + private buildConfigs: Record; // Map + private moduleInfos: Record; // Map + private pathConfig: PathConfig; - constructor(projectPath: string, getContentCallback?: (filePath: string) => string) { + constructor(pathConfig: PathConfig, getContentCallback?: (filePath: string) => string, modules?: ModuleDescriptor[]) { initBuildEnv(); - this.pandaLibPath = path.resolve(__dirname, '../../ets2panda/lib'); - this.projectPath = projectPath; - let compileFileInfoPath = path.join(projectPath, '.idea', '.deveco', 'lsp_compileFileInfos.json'); - this.fileNameToArktsconfig = JSON.parse(fs.readFileSync(compileFileInfoPath, 'utf-8')); - let buildConfigPath = path.join(projectPath, '.idea', '.deveco', 'lsp_build_config.json'); - this.moduleToBuildConfig = JSON.parse(fs.readFileSync(buildConfigPath, 'utf-8')); + this.cacheDir = + pathConfig.cacheDir !== undefined ? pathConfig.cacheDir : path.join(pathConfig.projectPath, DEFAULT_CACHE_DIR); + this.fileDependencies = path.join(this.cacheDir, 'file_dependencies.json'); + this.entryArkTsConfig = path.join(this.cacheDir, 'entry', 'arktsconfig.json'); + this.pandaLibPath = process.env.PANDA_LIB_PATH + ? process.env.PANDA_LIB_PATH + : path.resolve(__dirname, '../../../ets2panda/lib'); + this.pandaBinPath = process.env.PANDA_BIN_PATH + ? process.env.PANDA_BIN_PATH + : path.resolve(__dirname, '../../../ets2panda/bin'); this.filesMap = new Map(); this.getFileContent = getContentCallback || ((path: string): string => fs.readFileSync(path, 'utf8')); + this.buildConfigs = generateBuildConfigs(pathConfig, modules); + this.moduleInfos = generateArkTsConfigs(this.buildConfigs); + this.pathConfig = pathConfig; + PluginDriver.getInstance().initPlugins(Object.values(this.buildConfigs)[0]); + this.generateDeclFile(); + } + + // Partially update for new file + updateModuleInfos(module: ModuleDescriptor, newFilePath: String): void { + let buildConfig = this.buildConfigs[module.name]; + buildConfig.compileFiles.push(newFilePath.valueOf()); + let moduleInfo = generateModuleInfo(this.buildConfigs, buildConfig); + this.moduleInfos[newFilePath.valueOf()] = moduleInfo; + } + + // Full update for `Sync Now` + update(modules: ModuleDescriptor[]): void { + this.buildConfigs = generateBuildConfigs(this.pathConfig, modules); + this.moduleInfos = generateArkTsConfigs(this.buildConfigs); } modifyFilesMap(fileName: string, fileContent: TextDocumentChangeInfo): void { @@ -95,30 +150,178 @@ export class Lsp { this.filesMap.delete(fileName); } - updateConfig(buildSdkPath: string, modules?: ModuleDescriptor[]): void { - generateArkTsConfigByModules(buildSdkPath, this.projectPath, modules); - let compileFileInfoPath = path.join(this.projectPath, '.idea', '.deveco', 'lsp_compileFileInfos.json'); - this.fileNameToArktsconfig = JSON.parse(fs.readFileSync(compileFileInfoPath, 'utf-8')); - let buildConfigPath = path.join(this.projectPath, '.idea', '.deveco', 'lsp_build_config.json'); - this.moduleToBuildConfig = JSON.parse(fs.readFileSync(buildConfigPath, 'utf-8')); - } - private getFileSource(filePath: string): string { - const getSource = this.filesMap.get(filePath) || this.getFileContent(filePath); - if (!getSource) { + const getSource = this.filesMap.get(filePath) || this.getFileContent(filePath) || fs.readFileSync(filePath, 'utf8'); + if (getSource === undefined) { throw new Error(`File content not found for path: ${filePath}`); } return getSource.replace(/\r\n/g, '\n'); } + generateDeclFile(): void { + let lspDriverHelper = new LspDriverHelper(); + for (const [moduleName, buildConfig] of Object.entries(this.buildConfigs)) { + if (!buildConfig.enableDeclgenEts2Ts) { + continue; + } + if (!buildConfig.declgenOutDir || buildConfig.declgenOutDir === '') { + return; + } + buildConfig.compileFiles.forEach((compilefilePath: string) => { + if (!this.moduleInfos.hasOwnProperty(compilefilePath)) { + return; + } + let sourceFilePath = path.resolve(compilefilePath); + const moduleInfo = this.moduleInfos[compilefilePath]; + let arktsconfig = moduleInfo.arktsConfigFile; + let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); + let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, sourceFilePath, this.pandaLibPath); + const source = this.getFileSource(compilefilePath); + let localCtx = lspDriverHelper.createCtx(source, compilefilePath, localCfg); + PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); + lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); + PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); + // declgen file + let modulePath: string = path.relative(buildConfig.moduleRootPath, compilefilePath); + let declOut: string = ''; + let declBridgeOut: string = ''; + if (!moduleInfo.declgenV1OutPath) { + declOut = path.join(buildConfig.declgenOutDir, moduleName); + } + if (!moduleInfo.declgenBridgeCodePath) { + declBridgeOut = path.join(buildConfig.declgenOutDir, moduleName); + } + let declEtsOutputPath: string = changeDeclgenFileExtension( + path.join(moduleInfo.declgenV1OutPath ?? declOut, modulePath), + DECL_ETS_SUFFIX + ); + let etsOutputPath: string = changeDeclgenFileExtension( + path.join(moduleInfo.declgenBridgeCodePath ?? declBridgeOut, modulePath), + TS_SUFFIX + ); + ensurePathExists(declEtsOutputPath); + ensurePathExists(etsOutputPath); + global.es2pandaPublic._GenerateTsDeclarationsFromContext( + localCtx, + declEtsOutputPath, + etsOutputPath, + 1, + 0 + ); + let declfilePath = path.resolve(declEtsOutputPath); + let declgLocalCfg = lspDriverHelper.createCfg(ets2pandaCmd, declfilePath, this.pandaLibPath); + const declgSource = this.getFileSource(declfilePath); + let declgLocalCtx = lspDriverHelper.createCtx(declgSource, declfilePath, declgLocalCfg); + PluginDriver.getInstance().getPluginContext().setContextPtr(declgLocalCtx); + lspDriverHelper.proceedToState(declgLocalCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); + PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + lspDriverHelper.proceedToState(declgLocalCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); + // clean and destroy + PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); + lspDriverHelper.destroyContext(localCtx); + lspDriverHelper.destroyContext(declgLocalCtx); + }); + } + } + + modifyDeclFile(modifyFilePath: string, arktsConfigFile?: string): void { + // source file + let lspDriverHelper = new LspDriverHelper(); + let sourceFilePath = path.resolve(modifyFilePath.valueOf()); + let moduleInfo: ModuleInfo; + if (this.moduleInfos.hasOwnProperty(sourceFilePath)) { + moduleInfo = this.moduleInfos[sourceFilePath]; + } else { + const [newModuleName, newModuleRootPath] = getModuleNameAndPath(modifyFilePath, this.pathConfig.projectPath); + if (newModuleName && newModuleName !== '' && newModuleRootPath && newModuleRootPath !== '') { + moduleInfo = { + packageName: newModuleName, + moduleRootPath: newModuleRootPath, + moduleType: '', + entryFile: '', + arktsConfigFile: arktsConfigFile ?? '', + compileFiles: [], + declgenV1OutPath: '', + declgenBridgeCodePath: '', + staticDepModuleInfos: [], + dynamicDepModuleInfos: [], + language: '' + }; + } else { + return; + } + } + const moduleName = moduleInfo.packageName; + const moduleRootPath = moduleInfo.moduleRootPath; + if (!this.buildConfigs.hasOwnProperty(moduleName)) { + return; + } + const buildConfig = this.buildConfigs[moduleName]; + if (!buildConfig.enableDeclgenEts2Ts) { + return; + } + let arktsconfig = moduleInfo.arktsConfigFile; + let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); + let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, sourceFilePath, this.pandaLibPath); + const source = this.getFileSource(sourceFilePath); + let localCtx = lspDriverHelper.createCtx(source, sourceFilePath, localCfg); + PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); + lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); + PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); + // declgen file + let declOut: string = ''; + let declBridgeOut: string = ''; + if (!moduleInfo.declgenV1OutPath) { + declOut = path.join(buildConfig.declgenOutDir, moduleName); + } + if (!moduleInfo.declgenBridgeCodePath) { + declBridgeOut = path.join(buildConfig.declgenOutDir, moduleName); + } + let filePathFromModuleRoot: string = path.relative(moduleRootPath, modifyFilePath); + let declEtsOutputPath: string = changeDeclgenFileExtension( + path.join(moduleInfo.declgenV1OutPath ?? declOut, filePathFromModuleRoot), + DECL_ETS_SUFFIX + ); + let etsOutputPath: string = changeDeclgenFileExtension( + path.join(moduleInfo.declgenBridgeCodePath ?? declBridgeOut, filePathFromModuleRoot), + TS_SUFFIX + ); + ensurePathExists(declEtsOutputPath); + ensurePathExists(etsOutputPath); + global.es2pandaPublic._GenerateTsDeclarationsFromContext( + localCtx, + declEtsOutputPath, + etsOutputPath, + 1, + 0 + ); + let filePath = path.resolve(declEtsOutputPath); + let declgLocalCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); + const declgSource = this.getFileSource(filePath); + let declgLocalCtx = lspDriverHelper.createCtx(declgSource, filePath, declgLocalCfg); + PluginDriver.getInstance().getPluginContext().setContextPtr(declgLocalCtx); + lspDriverHelper.proceedToState(declgLocalCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); + PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + lspDriverHelper.proceedToState(declgLocalCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); + lspDriverHelper.destroyContext(declgLocalCtx); + PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); + lspDriverHelper.destroyContext(localCtx); + } + getDefinitionAtPosition(filename: String, offset: number): LspDefinitionData { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -133,12 +336,15 @@ export class Lsp { getSemanticDiagnostics(filename: String): LspDiagsNode { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let pandaLibPath: string = path.resolve(__dirname, '../../ets2panda/lib'); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, pandaLibPath); + let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -153,11 +359,15 @@ export class Lsp { getCurrentTokenValue(filename: String, offset: number): string { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -172,11 +382,15 @@ export class Lsp { getImplementationAtPosition(filename: String, offset: number): LspDefinitionData { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -191,11 +405,15 @@ export class Lsp { getFileReferences(filename: String): LspReferenceData[] { let lspDriverHelper = new LspDriverHelper(); let searchFilePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[searchFilePath]; + let arktsconfig = this.moduleInfos[searchFilePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, searchFilePath, this.pandaLibPath); const source = this.getFileSource(searchFilePath); - let localCtx = lspDriverHelper.createCtx(source, searchFilePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, searchFilePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[searchFilePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(searchFilePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -205,15 +423,18 @@ export class Lsp { lspDriverHelper.destroyContext(localCtx); lspDriverHelper.destroyConfig(localCfg); let result: LspReferenceData[] = []; - let moduleName = path.basename(path.dirname(arktsconfig)); - let buildConfig: BuildConfig = this.moduleToBuildConfig[moduleName]; - for (let i = 0; i < buildConfig.compileFiles.length; i++) { - let filePath = path.resolve(buildConfig.compileFiles[i]); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let compileFiles = this.moduleInfos[searchFilePath].compileFiles; + for (let i = 0; i < compileFiles.length; i++) { + let filePath = path.resolve(compileFiles[i]); + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -235,11 +456,15 @@ export class Lsp { getReferencesAtPosition(filename: String, offset: number): LspReferenceData[] { let lspDriverHelper = new LspDriverHelper(); let searchFilePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[searchFilePath]; + let arktsconfig = this.moduleInfos[searchFilePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, searchFilePath, this.pandaLibPath); const source = this.getFileSource(searchFilePath); - let localCtx = lspDriverHelper.createCtx(source, searchFilePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, searchFilePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[searchFilePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(searchFilePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -249,15 +474,18 @@ export class Lsp { lspDriverHelper.destroyContext(localCtx); lspDriverHelper.destroyConfig(localCfg); let result: LspReferenceData[] = []; - let moduleName = path.basename(path.dirname(arktsconfig)); - let buildConfig: BuildConfig = this.moduleToBuildConfig[moduleName]; - for (let i = 0; i < buildConfig.compileFiles.length; i++) { - let filePath = path.resolve(buildConfig.compileFiles[i]); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let compileFiles = this.moduleInfos[searchFilePath].compileFiles; + for (let i = 0; i < compileFiles.length; i++) { + let filePath = path.resolve(compileFiles[i]); + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -275,11 +503,15 @@ export class Lsp { getTypeHierarchies(filename: String, offset: number): LspTypeHierarchiesInfo | null { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -293,15 +525,18 @@ export class Lsp { return null; } let result: LspTypeHierarchiesInfo[] = []; - let moduleName = path.basename(path.dirname(arktsconfig)); - let buildConfig: BuildConfig = this.moduleToBuildConfig[moduleName]; - for (let i = 0; i < buildConfig.compileFiles.length; i++) { - let filePath = path.resolve(buildConfig.compileFiles[i]); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let compileFiles = this.moduleInfos[filePath].compileFiles; + for (let i = 0; i < compileFiles.length; i++) { + let filePath = path.resolve(compileFiles[i]); + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let searchCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let searchCtx = lspDriverHelper.createCtx(source, filePath, searchCfg); + let searchCtx = lspDriverHelper.createCtx(source, filePath, searchCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(searchCtx); lspDriverHelper.proceedToState(searchCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -312,17 +547,24 @@ export class Lsp { lspDriverHelper.destroyConfig(searchCfg); let refs = new LspTypeHierarchiesInfo(ptr); if (i > 0) { - result[0].subHierarchies.subOrSuper = result[0].subHierarchies.subOrSuper.concat(refs.subHierarchies.subOrSuper); + result[0].subHierarchies.subOrSuper = result[0].subHierarchies.subOrSuper.concat( + refs.subHierarchies.subOrSuper + ); } else { result.push(refs); } } for (let j = 0; j < result[0].subHierarchies.subOrSuper.length; j++) { - let res = this.getTypeHierarchies(result[0].subHierarchies.subOrSuper[j].fileName, result[0].subHierarchies.subOrSuper[j].pos); + let res = this.getTypeHierarchies( + result[0].subHierarchies.subOrSuper[j].fileName, + result[0].subHierarchies.subOrSuper[j].pos + ); if (res !== null) { let subOrSuperTmp = result[0].subHierarchies.subOrSuper[j].subOrSuper.concat(res.subHierarchies.subOrSuper); result[0].subHierarchies.subOrSuper[j].subOrSuper = Array.from( - new Map(subOrSuperTmp.map(item => [`${item.fileName}-${item.type}-${item.pos}-${item.name}`, item])).values() + new Map( + subOrSuperTmp.map((item) => [`${item.fileName}-${item.type}-${item.pos}-${item.name}`, item]) + ).values() ); } } @@ -332,11 +574,15 @@ export class Lsp { getClassHierarchyInfo(filename: String, offset: number): LspClassHierarchy { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileContent(filePath).replace(/\r\n/g, '\n'); + const source = this.getFileSource(filePath); let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -351,11 +597,15 @@ export class Lsp { getAliasScriptElementKind(filename: String, offset: number): LspCompletionEntryKind { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileContent(filePath).replace(/\r\n/g, '\n'); + const source = this.getFileSource(filePath); let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -368,32 +618,71 @@ export class Lsp { } getClassHierarchies(filename: String, offset: number): LspClassHierarchies { + let contextList = []; let lspDriverHelper = new LspDriverHelper(); - let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let localFilePath = path.resolve(filename.valueOf()); + let arktsconfig = this.moduleInfos[localFilePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); - let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileContent(filePath).replace(/\r\n/g, '\n'); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, localFilePath, this.pandaLibPath); + const source = this.getFileSource(localFilePath); + let localCtx = lspDriverHelper.createCtx(source, localFilePath, localCfg); + const packageName = this.moduleInfos[localFilePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(localFilePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let ptr = global.es2panda._getClassHierarchies(localCtx, filename, offset); + contextList.push({ ctx: localCtx, cfg: localCfg }); + let nativeContextList = global.es2panda._pushBackToNativeContextVector(localCtx, localCtx, 1); + let compileFiles = this.moduleInfos[localFilePath].compileFiles; + for (let i = 0; i < compileFiles.length; i++) { + let filePath = path.resolve(compileFiles[i]); + if (localFilePath === filePath) { + continue; + } + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; + let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); + let searchCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); + const source = this.getFileSource(filePath); + let searchCtx = lspDriverHelper.createCtx(source, filePath, searchCfg); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); + PluginDriver.getInstance().getPluginContext().setContextPtr(searchCtx); + lspDriverHelper.proceedToState(searchCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); + PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + lspDriverHelper.proceedToState(searchCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); + contextList.push({ ctx: searchCtx, cfg: searchCfg }); + global.es2panda._pushBackToNativeContextVector(searchCtx, nativeContextList, 0); + } + let ptr = global.es2panda._getClassHierarchies(nativeContextList, filename, offset); PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); - lspDriverHelper.destroyContext(localCtx); - lspDriverHelper.destroyConfig(localCfg); + for (const { ctx, cfg } of contextList) { + lspDriverHelper.destroyContext(ctx); + lspDriverHelper.destroyConfig(cfg); + } return new LspClassHierarchies(ptr); } - getClassPropertyInfo(filename: String, offset: number, shouldCollectInherited: boolean = false): LspClassPropertyInfo { + getClassPropertyInfo( + filename: String, + offset: number, + shouldCollectInherited: boolean = false + ): LspClassPropertyInfo { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); - const source = this.getFileContent(filePath).replace(/\r\n/g, '\n'); + const source = this.getFileSource(filePath); let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -408,11 +697,15 @@ export class Lsp { getOrganizeImports(filename: String): LspFileTextChanges { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -427,11 +720,15 @@ export class Lsp { findSafeDeleteLocation(filename: String, offset: number): LspSafeDeleteLocationInfo[] { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -441,15 +738,18 @@ export class Lsp { lspDriverHelper.destroyContext(localCtx); lspDriverHelper.destroyConfig(localCfg); let result: LspSafeDeleteLocationInfo[] = []; - let moduleName = path.basename(path.dirname(arktsconfig)); - let buildConfig: BuildConfig = this.moduleToBuildConfig[moduleName]; - for (let i = 0; i < buildConfig.compileFiles.length; i++) { - let filePath = path.resolve(buildConfig.compileFiles[i]); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let compileFiles = this.moduleInfos[filePath].compileFiles; + for (let i = 0; i < compileFiles.length; i++) { + let filePath = path.resolve(compileFiles[i]); + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -467,11 +767,15 @@ export class Lsp { getCompletionEntryDetails(filename: String, offset: number, entryName: String): CompletionEntryDetails { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -483,33 +787,44 @@ export class Lsp { return new CompletionEntryDetails(ptr); } - getApplicableRefactors(filename: String, kind: String, offset: number): LspApplicableRefactorInfo { + getApplicableRefactors(filename: String, kind: String, offset: number): ApplicableRefactorItemInfo[] { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); + let result: ApplicableRefactorItemInfo[] = []; let ptr = global.es2panda._getApplicableRefactors(localCtx, kind, offset); PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); lspDriverHelper.destroyContext(localCtx); lspDriverHelper.destroyConfig(localCfg); - return new LspApplicableRefactorInfo(ptr); + let refs = new LspApplicableRefactorInfo(ptr); + result.push(...refs.applicableRefactorInfo); + return Array.from(new Set(result)); } getClassConstructorInfo(filename: String, offset: number, properties: string[]): LspClassConstructorInfo { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -524,11 +839,15 @@ export class Lsp { getSyntacticDiagnostics(filename: String): LspDiagsNode { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -543,11 +862,15 @@ export class Lsp { getSuggestionDiagnostics(filename: String): LspDiagsNode { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -562,11 +885,15 @@ export class Lsp { getQuickInfoAtPosition(filename: String, offset: number): LspQuickInfo { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -581,11 +908,15 @@ export class Lsp { getDocumentHighlights(filename: String, offset: number): LspDocumentHighlightsReferences { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -600,7 +931,7 @@ export class Lsp { getCompletionAtPosition(filename: String, offset: number): LspCompletionInfo { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); let source = this.getFileSource(filePath); @@ -614,7 +945,11 @@ export class Lsp { } offset += wildcard.length; } - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -629,11 +964,15 @@ export class Lsp { toLineColumnOffset(filename: String, offset: number): LspLineAndCharacter { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -648,30 +987,125 @@ export class Lsp { getSafeDeleteInfo(filename: String, position: number): boolean { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); - let result = global.es2panda._getSafeDeleteInfo(localCtx, position, path.resolve(__dirname, '../../..')); + let result = global.es2panda._getSafeDeleteInfo(localCtx, position); PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); lspDriverHelper.destroyContext(localCtx); lspDriverHelper.destroyConfig(localCfg); return result; } + findRenameLocations(filename: String, offset: number): LspRenameLocation[] { + let lspDriverHelper = new LspDriverHelper(); + let filePath = path.resolve(filename.valueOf()); + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; + let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); + let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); + const source = this.getFileSource(filePath); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); + PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); + lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); + PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); + let compileFiles = this.moduleInfos[filePath].compileFiles; + const fileContexts: KPointer[] = []; + const fileConfigs: Config[] = [localCfg]; + for (let i = 0; i < compileFiles.length; i++) { + let filePath = path.resolve(compileFiles[i]); + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; + let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); + let compileFileCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); + const source = this.getFileSource(filePath); + let compileFileCtx = lspDriverHelper.createCtx(source, filePath, compileFileCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); + PluginDriver.getInstance().getPluginContext().setContextPtr(compileFileCtx); + lspDriverHelper.proceedToState(compileFileCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); + PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + lspDriverHelper.proceedToState(compileFileCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); + fileContexts.push(compileFileCtx); + fileConfigs.push(compileFileCfg); + } + const ptr = global.es2panda._findRenameLocations( + fileContexts.length, + passPointerArray(fileContexts), + localCtx, + offset + ); + PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); + const result: LspRenameLocation[] = new NativePtrDecoder().decode(ptr).map((elPeer: KPointer) => { + return new LspRenameLocation(elPeer); + }); + for (let i = 0; i < fileContexts.length; i++) { + lspDriverHelper.destroyContext(fileContexts[i]); + } + lspDriverHelper.destroyContext(localCtx); + for (const cfg of fileConfigs) { + lspDriverHelper.destroyConfig(cfg); + } + return Array.from(new Set(result)); + } + + getRenameInfo(filename: String, offset: number): LspRenameInfoType { + let lspDriverHelper = new LspDriverHelper(); + let filePath = path.resolve(filename.valueOf()); + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; + let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); + let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); + const source = this.getFileSource(filePath); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); + PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); + lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); + PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); + let ptr = global.es2panda._getRenameInfo(localCtx, offset, this.pandaLibPath); + const success = global.es2panda._getRenameInfoIsSuccess(ptr); + let res: LspRenameInfoType; + if (success) { + res = new LspRenameInfoSuccess(global.es2panda._getRenameInfoSuccess(ptr)); + } else { + res = new LspRenameInfoFailure(global.es2panda._getRenameInfoFailure(ptr)); + } + PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); + lspDriverHelper.destroyContext(localCtx); + lspDriverHelper.destroyConfig(localCfg); + return res; + } + getSpanOfEnclosingComment(filename: String, offset: number, onlyMultiLine: boolean): LspTextSpan { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -683,14 +1117,50 @@ export class Lsp { return new LspTextSpan(ptr); } - provideInlayHints(filename: String, span: TextSpan): LspInlayHint[] { + getCodeFixesAtPosition(filename: String, start: number, end: number, errorCodes: number[]): CodeFixActionInfo[] { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); + PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); + lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); + PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_CHECKED); + let ptr = global.es2panda._getCodeFixesAtPosition( + localCtx, + start, + end, + new Int32Array(errorCodes), + errorCodes.length + ); + PluginDriver.getInstance().runPluginHook(PluginHook.CLEAN); + lspDriverHelper.destroyContext(localCtx); + lspDriverHelper.destroyConfig(localCfg); + const codeFixActionInfoList = new CodeFixActionInfoList(ptr); + const codeFixActionInfos: CodeFixActionInfo[] = []; + codeFixActionInfos.push(...codeFixActionInfoList.codeFixActionInfos); + return codeFixActionInfos; + } + + provideInlayHints(filename: String, span: TextSpan): LspInlayHint[] { + let lspDriverHelper = new LspDriverHelper(); + let filePath = path.resolve(filename.valueOf()); + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; + let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); + let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); + const source = this.getFileSource(filePath); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -709,11 +1179,15 @@ export class Lsp { getSignatureHelpItems(filename: String, offset: number): LspSignatureHelpItems { let lspDriverHelper = new LspDriverHelper(); let filePath = path.resolve(filename.valueOf()); - let arktsconfig = this.fileNameToArktsconfig[filePath]; + let arktsconfig = this.moduleInfos[filePath].arktsConfigFile; let ets2pandaCmd = ets2pandaCmdPrefix.concat(arktsconfig); let localCfg = lspDriverHelper.createCfg(ets2pandaCmd, filePath, this.pandaLibPath); const source = this.getFileSource(filePath); - let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg); + let localCtx = lspDriverHelper.createCtx(source, filePath, localCfg, this.globalContextPtr); + const packageName = this.moduleInfos[filePath].packageName; + const buildConfig = this.buildConfigs[packageName]; + PluginDriver.getInstance().getPluginContext().setCodingFilePath(filePath); + PluginDriver.getInstance().getPluginContext().setProjectConfig(buildConfig); PluginDriver.getInstance().getPluginContext().setContextPtr(localCtx); lspDriverHelper.proceedToState(localCtx, Es2pandaContextState.ES2PANDA_STATE_PARSED); PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); @@ -724,4 +1198,540 @@ export class Lsp { lspDriverHelper.destroyConfig(localCfg); return new LspSignatureHelpItems(ptr); } + + // Use AST cache start + private getFileDependencies(inputs: string[], output: string): void { + let depInputContent = ''; + let outputFile: string = output; + let depAnalyzerPath: string = path.join(this.pandaBinPath, 'dependency_analyzer'); + let depInputFile = path.join(this.cacheDir, 'depInput.txt'); + inputs.forEach((file) => { + depInputContent += file + os.EOL; + }); + fs.writeFileSync(depInputFile, depInputContent); + ensurePathExists(outputFile); + const result = child_process.spawnSync( + depAnalyzerPath, + [`@${depInputFile}`, `--output=${output}`, `--arktsconfig=${this.entryArkTsConfig}`], + { + encoding: 'utf-8', + windowsHide: true + } + ); + if (result.error || result.status !== 0) { + console.error('getFileDependencies failed: ', result.stderr || result.error); + } + } + + // Collect circular dependencies, like: A→B→C→A + private findStronglyConnectedComponents(graph: FileDepsInfo): Map> { + const adjacencyList: Record = {}; + const reverseAdjacencyList: Record = {}; + const allNodes = new Set(); + + for (const node in graph.dependencies) { + allNodes.add(node); + graph.dependencies[node].forEach((dep) => allNodes.add(dep)); + } + for (const node in graph.dependants) { + allNodes.add(node); + graph.dependants[node].forEach((dep) => allNodes.add(dep)); + } + + Array.from(allNodes).forEach((node) => { + adjacencyList[node] = graph.dependencies[node] || []; + reverseAdjacencyList[node] = graph.dependants[node] || []; + }); + + const visited = new Set(); + const order: string[] = []; + + function dfs(node: string): void { + visited.add(node); + for (const neighbor of adjacencyList[node]) { + if (!visited.has(neighbor)) { + dfs(neighbor); + } + } + order.push(node); + } + + Array.from(allNodes).forEach((node) => { + if (!visited.has(node)) { + dfs(node); + } + }); + + visited.clear(); + const components = new Map>(); + + function reverseDfs(node: string, component: Set): void { + visited.add(node); + component.add(node); + for (const neighbor of reverseAdjacencyList[node]) { + if (!visited.has(neighbor)) { + reverseDfs(neighbor, component); + } + } + } + + for (let i = order.length - 1; i >= 0; i--) { + const node = order[i]; + if (!visited.has(node)) { + const component = new Set(); + reverseDfs(node, component); + if (component.size > 1) { + const sortedFiles = Array.from(component).sort(); + const hashKey = createHash(sortedFiles.join('|')); + components.set(hashKey, component); + } + } + } + + return components; + } + + private getJobDependencies(fileDeps: string[], cycleFiles: Map): Set { + let depJobList: Set = new Set(); + fileDeps.forEach((file) => { + if (!cycleFiles.has(file)) { + depJobList.add('0' + file); + } else { + cycleFiles.get(file)?.forEach((f) => { + depJobList.add(f); + }); + } + }); + + return depJobList; + } + + private getJobDependants(fileDeps: string[], cycleFiles: Map): Set { + let depJobList: Set = new Set(); + fileDeps.forEach((file) => { + if (!file.endsWith(DECL_ETS_SUFFIX)) { + depJobList.add('1' + file); + } + if (cycleFiles.has(file)) { + cycleFiles.get(file)?.forEach((f) => { + depJobList.add(f); + }); + } else { + depJobList.add('0' + file); + } + }); + + return depJobList; + } + + private collectCompileJobs(jobs: Record, isValid: boolean = false): void { + let entryFileList: string[] = Object.keys(this.moduleInfos); + this.getFileDependencies(entryFileList, this.fileDependencies); + const data = fs.readFileSync(this.fileDependencies, 'utf-8'); + let fileDepsInfo: FileDepsInfo = JSON.parse(data) as FileDepsInfo; + + Object.keys(fileDepsInfo.dependants).forEach((file) => { + if (!(file in fileDepsInfo.dependencies)) { + fileDepsInfo.dependencies[file] = []; + } + }); + + let cycleGroups = this.findStronglyConnectedComponents(fileDepsInfo); + + let cycleFiles: Map = new Map(); + cycleGroups.forEach((value: Set, key: string) => { + value.forEach((file) => { + cycleFiles.set(file, [key]); + }); + }); + + Object.entries(fileDepsInfo.dependencies).forEach(([key, value]) => { + let dependencies = this.getJobDependencies(value, cycleFiles); + if (cycleFiles.has(key)) { + const externalProgramJobIds = cycleFiles.get(key)!; + externalProgramJobIds.forEach((id) => { + let fileList: string[] = Array.from(cycleGroups.get(id)!); + this.createExternalProgramJob(id, fileList, jobs, dependencies, isValid, true); + }); + } else { + const id = '0' + key; + let fileList: string[] = [key]; + this.createExternalProgramJob(id, fileList, jobs, dependencies, isValid); + } + }); + + Object.entries(fileDepsInfo.dependants).forEach(([key, value]) => { + const dependants = this.getJobDependants(value, cycleFiles); + const jobIds = cycleFiles.has(key) ? cycleFiles.get(key)! : ['0' + key]; + + jobIds.forEach((jobId) => { + const currentDependants = new Set(dependants); + jobs[jobId].dependants.forEach((dep) => currentDependants.add(dep)); + currentDependants.delete(jobId); + jobs[jobId].dependants = Array.from(currentDependants); + }); + }); + } + + private createExternalProgramJob( + id: string, + fileList: string[], + jobs: Record, + dependencies: Set, + isValid: boolean, + isInCycle?: boolean + ): void { + if (dependencies.has(id)) { + dependencies.delete(id); + } + if (jobs[id]) { + const existingJob = jobs[id]; + const mergedFileList = [...new Set([...existingJob.fileList, ...fileList])]; + const mergedDependencies = [...new Set([...existingJob.dependencies, ...Array.from(dependencies)])]; + const mergedIsInCycle = existingJob.isInCycle || isInCycle; + + existingJob.fileList = mergedFileList; + existingJob.dependencies = mergedDependencies; + existingJob.isInCycle = mergedIsInCycle; + } else { + jobs[id] = { + id, + fileList, + isDeclFile: true, + isInCycle, + dependencies: Array.from(dependencies), + dependants: [], + isValid + }; + } + } + + private addJobToQueues(job: Job, queues: Job[]): void { + if (queues.some((j) => j.id === job.id)) { + return; + } + queues.push(job); + } + + private initCompileQueues(jobs: Record, queues: Job[], dependantJobs?: Record): void { + Object.values(jobs).forEach((job) => { + if (job.dependencies.length === 0) { + if (dependantJobs && job.id in dependantJobs) { + job.isValid = false; + this.invalidateFileCache(job.fileList); + } + this.addJobToQueues(job, queues); + } + }); + } + + private checkAllTasksDone(queues: Job[], workerPool: WorkerInfo[]): boolean { + if (queues.length === 0) { + for (let i = 0; i < workerPool.length; i++) { + if (!workerPool[i].isIdle) { + return false; + } + } + return true; + } + return false; + } + + private initGlobalContext(jobs: Record): void { + let files: string[] = []; + Object.entries(jobs).forEach(([key, job]) => { + for (let i = 0; i < job.fileList.length; i++) { + files.push(job.fileList[i]); + } + }); + + let ets2pandaCmd: string[] = [ + '_', + '--extension', + 'ets', + '--arktsconfig', + this.entryArkTsConfig, + Object.keys(this.moduleInfos)[0] + ]; + + this.globalLspDriverHelper = new LspDriverHelper(); + this.globalLspDriverHelper.memInitialize(this.pandaLibPath); + this.globalConfig = this.globalLspDriverHelper.createCfg(ets2pandaCmd, files[0], this.pandaLibPath); + this.globalContextPtr = this.globalLspDriverHelper.createGlobalContext(this.globalConfig.peer, files, files.length); + } + + private updateQueues( + jobs: Record, + queues: Job[], + jobId: string, + dependantJobs?: Record + ): void { + const completedJob = jobs[jobId]; + completedJob.dependants.forEach((depJobId) => { + const depJob = jobs[depJobId]; + if (!depJob) { + return; + } + const depIndex = depJob.dependencies.indexOf(jobId); + if (depIndex === -1) { + return; + } + depJob.dependencies.splice(depIndex, 1); + if (depJob.dependencies.length > 0) { + return; + } + this.processCompletedDependencies(depJob, queues, dependantJobs); + }); + } + + private processCompletedDependencies(depJob: Job, queues: Job[], dependantJobs?: Record): void { + if (dependantJobs && depJob.id in dependantJobs) { + depJob.isValid = false; + this.invalidateFileCache(depJob.fileList); + } + this.addJobToQueues(depJob, queues); + } + + private invalidateFileCache(fileList: string[]): void { + fileList.forEach((file) => { + global.es2pandaPublic._InvalidateFileCache(this.globalContextPtr!, file); + }); + } + + private async invokeWorkers( + jobs: Record, + queues: Job[], + processingJobs: Set, + workers: ThreadWorker[], + numWorkers: number, + dependantJobs?: Record + ): Promise { + return new Promise((resolve) => { + const workerPool = this.createWorkerPool(numWorkers, workers); + + workerPool.forEach((workerInfo) => { + this.setupWorkerListeners(workerInfo.worker, workerPool, jobs, queues, processingJobs, resolve, dependantJobs); + this.assignTaskToIdleWorker(workerInfo, queues, processingJobs); + }); + }); + } + + private createWorkerPool(numWorkers: number, workers: ThreadWorker[]): WorkerInfo[] { + const workerPool: WorkerInfo[] = []; + + for (let i = 0; i < numWorkers; i++) { + const worker = new ThreadWorker(path.resolve(__dirname, 'compile_thread_worker.js'), { + workerData: { workerId: i } + }); + workers.push(worker); + workerPool.push({ worker, isIdle: true }); + } + + return workerPool; + } + + private setupWorkerListeners( + worker: ThreadWorker, + workerPool: WorkerInfo[], + jobs: Record, + queues: Job[], + processingJobs: Set, + resolve: () => void, + dependantJobs?: Record + ): void { + worker.on('message', (msg) => { + if (msg.type !== 'TASK_FINISH') { + return; + } + + this.handleTaskCompletion(msg.jobId, worker, workerPool, jobs, queues, processingJobs, dependantJobs); + + if (this.checkAllTasksDone(queues, workerPool)) { + this.terminateWorkers(workerPool); + resolve(); + } + }); + } + + private handleTaskCompletion( + jobId: string, + worker: ThreadWorker, + workerPool: WorkerInfo[], + jobs: Record, + queues: Job[], + processingJobs: Set, + dependantJobs?: Record + ): void { + const workerInfo = workerPool.find((w) => w.worker === worker); + if (workerInfo) { + workerInfo.isIdle = true; + } + processingJobs.delete(jobId); + this.updateQueues(jobs, queues, jobId, dependantJobs); + workerPool.forEach((workerInfo) => { + if (workerInfo.isIdle) { + this.assignTaskToIdleWorker(workerInfo, queues, processingJobs); + } + }); + } + + private terminateWorkers(workerPool: WorkerInfo[]): void { + workerPool.forEach(({ worker }) => { + worker.postMessage({ type: 'EXIT' }); + }); + } + + private assignTaskToIdleWorker(workerInfo: WorkerInfo, queues: Job[], processingJobs: Set): void { + let job: Job | undefined; + let jobInfo: JobInfo | undefined; + + if (queues.length > 0) { + job = queues.shift()!; + jobInfo = { + id: job.id, + filePath: job.fileList[0], + arktsConfigFile: this.entryArkTsConfig, + globalContextPtr: this.globalContextPtr!, + buildConfig: Object.values(this.buildConfigs)[0], + isValid: job.isValid + }; + } + + if (job) { + processingJobs.add(job.id); + workerInfo.worker.postMessage({ type: 'ASSIGN_TASK', jobInfo }); + workerInfo.isIdle = false; + } + } + + // AST caching is not enabled by default. + // Call `initAstCache` before invoking the language service interface to enable AST cache + public async initAstCache(numWorkers: number = 1): Promise { + const jobs: Record = {}; + const queues: Job[] = []; + this.collectCompileJobs(jobs); + this.initGlobalContext(jobs); + this.initCompileQueues(jobs, queues); + + const processingJobs = new Set(); + const workers: ThreadWorker[] = []; + await this.invokeWorkers(jobs, queues, processingJobs, workers, numWorkers); + } + + private compileExternalProgram(jobInfo: JobInfo): void { + PluginDriver.getInstance().initPlugins(jobInfo.buildConfig); + let ets2pandaCmd = ['-', '--extension', 'ets', '--arktsconfig', jobInfo.arktsConfigFile]; + let lspDriverHelper = new LspDriverHelper(); + let config = lspDriverHelper.createCfg(ets2pandaCmd, jobInfo.filePath); + const source = fs.readFileSync(jobInfo.filePath, 'utf8').replace(/\r\n/g, '\n'); + let context = lspDriverHelper.createCtx(source, jobInfo.filePath, config, jobInfo.globalContextPtr, true); + PluginDriver.getInstance().getPluginContext().setContextPtr(context); + lspDriverHelper.proceedToState(context, Es2pandaContextState.ES2PANDA_STATE_PARSED); + PluginDriver.getInstance().runPluginHook(PluginHook.PARSED); + lspDriverHelper.proceedToState(context, Es2pandaContextState.ES2PANDA_STATE_LOWERED); + } + + public addFileCache(filename: String): void { + global.es2pandaPublic._AddFileCache(this.globalContextPtr!, filename); + let jobInfo = { + id: filename.valueOf(), + filePath: filename.valueOf(), + arktsConfigFile: this.entryArkTsConfig, + globalContextPtr: this.globalContextPtr!, + buildConfig: Object.values(this.buildConfigs)[0], + isValid: true + }; + this.compileExternalProgram(jobInfo); + } + + public removeFileCache(filename: String): void { + global.es2pandaPublic._RemoveFileCache(this.globalContextPtr!, filename); + } + + public async updateFileCache(filename: String, numWorkers: number = 1): Promise { + const queues: Job[] = []; + const jobs: Record = {}; + this.collectCompileJobs(jobs, true); + const dependantJobs = this.findJobDependants(jobs, filename.valueOf()); + this.initCompileQueues(jobs, queues, dependantJobs); + const processingJobs = new Set(); + const workers: ThreadWorker[] = []; + await this.invokeWorkers(jobs, queues, processingJobs, workers, numWorkers, dependantJobs); + } + + private findJobDependants(jobs: Record, filePath: string): Record { + const targetJobs = this.findTargetJobs(jobs, filePath); + const { visited, dependantJobs } = this.collectDependantJobs(jobs, targetJobs); + + return this.mergeJobs(targetJobs, dependantJobs); + } + + private findTargetJobs(jobs: Record, filePath: string): Job[] { + return Object.values(jobs).filter( + (job) => job.fileList.includes(filePath) || (job.isInCycle && job.fileList.some((f) => f === filePath)) + ); + } + + private collectDependantJobs( + jobs: Record, + targetJobs: Job[] + ): { visited: Set; dependantJobs: Map } { + const visited = new Set(); + const dependantJobs = new Map(); + const queue: Job[] = []; + + targetJobs.forEach((job) => { + if (!visited.has(job.id)) { + visited.add(job.id); + queue.push(job); + } + + while (queue.length) { + const current = queue.shift()!; + this.processDependants(jobs, current, visited, queue, dependantJobs); + } + }); + + return { visited, dependantJobs }; + } + + private processDependants( + jobs: Record, + current: Job, + visited: Set, + queue: Job[], + dependantJobs: Map + ): void { + current.dependants.forEach((dependantId) => { + const dependantJob = jobs[dependantId]; + if (dependantJob && !visited.has(dependantId)) { + visited.add(dependantId); + queue.push(dependantJob); + dependantJobs.set(dependantId, dependantJob); + } + }); + } + + private mergeJobs(targetJobs: Job[], dependantJobs: Map): Record { + return [...targetJobs, ...dependantJobs.values()].reduce( + (acc, job) => { + acc[job.id] = job; + return acc; + }, + {} as Record + ); + } + + public dispose(): void { + this.globalLspDriverHelper!.destroyGlobalContext(this.globalContextPtr!); + this.globalLspDriverHelper!.destroyConfig(this.globalConfig!); + this.globalLspDriverHelper!.memFinalize(); + } +} + +function createHash(str: string): string { + const hash = crypto.createHash('sha256'); + hash.update(str); + return hash.digest('hex'); } +// Use AST cache end diff --git a/ets2panda/bindings/test/BUILD.gn b/ets2panda/bindings/test/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..83a299be121b1c897c8351347ee6ac00f76f1524 --- /dev/null +++ b/ets2panda/bindings/test/BUILD.gn @@ -0,0 +1,25 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/version.gni") + +action("bindings_test") { + script = "run_bindings.sh" + args = [ + rebase_path("./"), + rebase_path( + "//prebuilts/build-tools/common/nodejs/node-v16.20.2-linux-x64/bin"), + rebase_path("//prebuilts/ohos-sdk/linux/${api_version}/ets"), + ] + outputs = [ "$target_out_dir/$target_name.timestamp" ] +} diff --git a/ets2panda/bindings/test/cases.ts b/ets2panda/bindings/test/cases.ts index 87a87dc23edfadbc4ea23f8aae2bb3eec115032d..3fe2a53d24f8961606a910a0c3cbcad654c3925f 100644 --- a/ets2panda/bindings/test/cases.ts +++ b/ets2panda/bindings/test/cases.ts @@ -14,7 +14,7 @@ */ import path from 'path'; -import { TextSpan } from '../src/lspNode'; +import { TextSpan } from '../src/lsp/lspNode'; export interface TestConfig { expectedFilePath: string; @@ -44,7 +44,7 @@ export const testCases: TestCases = { '7': [resolveTestPath('test/testcases/getDefinitionAtPosition/getDefinitionAtPosition13.ets'), 664], '8': [resolveTestPath('test/testcases/getDefinitionAtPosition/getDefinitionAtPosition15.ets'), 617], '9': [resolveTestPath('test/testcases/getDefinitionAtPosition/getDefinitionAtPosition17.ets'), 677], - '10': [resolveTestPath('test/testcases/getDefinitionAtPosition/getDefinitionAtPosition18.ets'), 930] + '11': [resolveTestPath('test/testcases/getDefinitionAtPosition/getDefinitionAtPosition19.ets'), 634] }, getSemanticDiagnostics: { expectedFilePath: resolveTestPath('test/expected/getSemanticDiagnostics.json'), @@ -62,6 +62,10 @@ export const testCases: TestCases = { expectedFilePath: resolveTestPath('test/expected/getFileReferences.json'), '1': [resolveTestPath('test/testcases/getFileReferences/getFileReferences1_export.ets')] }, + getFileSource: { + expectedFilePath: resolveTestPath('test/expected/getFileSource.json'), + '1': [resolveTestPath('test/testcases/getFileSource/getFileSource1.ets')] + }, getReferencesAtPosition: { expectedFilePath: resolveTestPath('test/expected/getReferencesAtPosition.json'), '1': [resolveTestPath('test/testcases/getReferencesAtPosition/getReferencesAtPosition1.ets'), 613], @@ -128,11 +132,41 @@ export const testCases: TestCases = { { start: 712, length: 11 } as TextSpan ] }, + getCodeFixesAtPosition: { + expectedFilePath: resolveTestPath('test/expected/getCodeFixesAtPosition.json'), + '1': [resolveTestPath('test/testcases/getCodeFixesAtPosition/getCodeFixesAtPosition1.ets'), 994, 995, [4000]] + }, getSignatureHelpItems: { expectedFilePath: resolveTestPath('test/expected/getSignatureHelpItems.json'), '1': [resolveTestPath('test/testcases/getSignatureHelpItems/getSignatureHelpItems1.ets'), 613], '2': [resolveTestPath('test/testcases/getSignatureHelpItems/getSignatureHelpItems1.ets'), 620], '3': [resolveTestPath('test/testcases/getSignatureHelpItems/getSignatureHelpItems1.ets'), 678] + }, + findRenameLocations: { + expectedFilePath: resolveTestPath('test/expected/findRenameLocations.json'), + '1': [resolveTestPath('test/testcases/findRenameLocations/findRenameLocations2.ets'), 632], + '2': [resolveTestPath('test/testcases/findRenameLocations/findRenameLocations1.ets'), 627], + '3': [resolveTestPath('test/testcases/findRenameLocations/findRenameLocations1.ets'), 670], + '4': [resolveTestPath('test/testcases/findRenameLocations/findRenameLocations1.ets'), 721] + }, + getRenameInfo: { + expectedFilePath: resolveTestPath('test/expected/getRenameInfo.json'), + '1': [resolveTestPath('test/testcases/getRenameInfo/getRenameInfo1.ets'), 615] + }, + entry: { + expectedFilePath: '', + '1': [resolveTestPath('test/testcases/entry/Index.ets'), 615] + } +}; + +export const testSingleModuleCases: TestCases = { + generateDeclFile: { + expectedFilePath: resolveTestPath('test/expected/generateDeclFile.json'), + '1': [] + }, + modifyDeclFile: { + expectedFilePath: resolveTestPath('test/expected/modifyDeclFile.json'), + '1': [resolveTestPath('test/testcases/modifyDeclFile/entry/index.ets')] } }; diff --git a/ets2panda/bindings/test/expected/findRenameLocations.json b/ets2panda/bindings/test/expected/findRenameLocations.json new file mode 100644 index 0000000000000000000000000000000000000000..cc8a6bac0ead6eaad0dd130117507f0be5854a05 --- /dev/null +++ b/ets2panda/bindings/test/expected/findRenameLocations.json @@ -0,0 +1,178 @@ +{ + "1": [ + { + "fileName": "findRenameLocations1.ets", + "start": 708, + "end": 711, + "line": 21, + "prefixText": "export class ", + "suffixText": " {" + }, + { + "fileName": "findRenameLocations2.ets", + "start": 630, + "end": 633, + "line": 15, + "prefixText": "import { dummy, abc, ", + "suffixText": " } from \"./findRenameLocations1.ets\";" + }, + { + "fileName": "findRenameLocations2.ets", + "start": 738, + "end": 741, + "line": 23, + "prefixText": "let myfoo = new ", + "suffixText": "(\"apples\", 1, 2, 3);" + }, + { + "fileName": "findRenameLocations2.ets", + "start": 781, + "end": 784, + "line": 24, + "prefixText": "let otherfoo = new ", + "suffixText": "(\"oranges\", 4, 5, 6);" + } + ], + "2": [ + { + "fileName": "findRenameLocations1.ets", + "start": 625, + "end": 628, + "line": 15, + "prefixText": "export function ", + "suffixText": "(x: number): void {" + }, + { + "fileName": "findRenameLocations1.ets", + "start": 1259, + "end": 1262, + "line": 49, + "prefixText": "", + "suffixText": "(2);" + }, + { + "fileName": "findRenameLocations1.ets", + "start": 1267, + "end": 1270, + "line": 50, + "prefixText": "", + "suffixText": "(3);" + }, + { + "fileName": "findRenameLocations1.ets", + "start": 1275, + "end": 1278, + "line": 51, + "prefixText": "", + "suffixText": "(4);" + }, + { + "fileName": "findRenameLocations2.ets", + "start": 625, + "end": 628, + "line": 15, + "prefixText": "import { dummy, ", + "suffixText": ", Foo } from \"./findRenameLocations1.ets\";" + }, + { + "fileName": "findRenameLocations2.ets", + "start": 694, + "end": 697, + "line": 19, + "prefixText": "", + "suffixText": "(5);" + }, + { + "fileName": "findRenameLocations2.ets", + "start": 702, + "end": 705, + "line": 20, + "prefixText": "", + "suffixText": "(55);" + }, + { + "fileName": "findRenameLocations2.ets", + "start": 711, + "end": 714, + "line": 21, + "prefixText": "", + "suffixText": "(555);" + } + ], + "3": [ + { + "fileName": "findRenameLocations1.ets", + "start": 667, + "end": 672, + "line": 18, + "prefixText": "export function ", + "suffixText": "(x: number): void {" + }, + { + "fileName": "findRenameLocations1.ets", + "start": 1239, + "end": 1244, + "line": 47, + "prefixText": "", + "suffixText": "(0);" + }, + { + "fileName": "findRenameLocations1.ets", + "start": 1249, + "end": 1254, + "line": 48, + "prefixText": "", + "suffixText": "(1);" + }, + { + "fileName": "findRenameLocations2.ets", + "start": 618, + "end": 623, + "line": 15, + "prefixText": "import { ", + "suffixText": ", abc, Foo } from \"./findRenameLocations1.ets\";" + }, + { + "fileName": "findRenameLocations2.ets", + "start": 673, + "end": 678, + "line": 17, + "prefixText": "", + "suffixText": "(4);" + }, + { + "fileName": "findRenameLocations2.ets", + "start": 683, + "end": 688, + "line": 18, + "prefixText": "", + "suffixText": "(44);" + } + ], + "4": [ + { + "fileName": "findRenameLocations1.ets", + "start": 718, + "end": 722, + "line": 22, + "prefixText": " ", + "suffixText": ": string = \"unassigned\";" + }, + { + "fileName": "findRenameLocations1.ets", + "start": 882, + "end": 886, + "line": 27, + "prefixText": " this.", + "suffixText": " = name;" + }, + { + "fileName": "findRenameLocations2.ets", + "start": 866, + "end": 870, + "line": 28, + "prefixText": "console.log(myfoo.", + "suffixText": ")" + } + ] +} \ No newline at end of file diff --git a/ets2panda/bindings/test/expected/generateDeclFile.json b/ets2panda/bindings/test/expected/generateDeclFile.json new file mode 100644 index 0000000000000000000000000000000000000000..adaa8c41ba026024e8124327c13034438725b998 --- /dev/null +++ b/ets2panda/bindings/test/expected/generateDeclFile.json @@ -0,0 +1,13 @@ +{ + "1": [ + "generateDeclFile1.d.ets", + "generateDeclFile2.d.ets", + "generateDeclFile3.d.ets", + "generateDeclFile4.d.ets", + "generateDeclFile5.d.ets", + "generateDeclFile6.d.ets", + "generateDeclFile7.d.ets", + "generateDeclFile8.d.ets", + "generateDeclFile9.d.ets" + ] +} \ No newline at end of file diff --git a/ets2panda/bindings/test/expected/getCodeFixesAtPosition.json b/ets2panda/bindings/test/expected/getCodeFixesAtPosition.json new file mode 100644 index 0000000000000000000000000000000000000000..25c2eb7e13218222427922320ac403ee47fcf2ea --- /dev/null +++ b/ets2panda/bindings/test/expected/getCodeFixesAtPosition.json @@ -0,0 +1,28 @@ +{ + "1": [ + { + "changes": [ + { + "fileName": "getCodeFixesAtPosition1.ets", + "textChanges": [ + { + "span": { + "start": 991, + "length": 5 + }, + "newText": "" + } + ] + }, + { + "fileName": "getCodeFixesAtPosition1.ets", + "textChanges": [] + } + ], + "description": "Fix Description", + "fixName": "Fix", + "fixId_": "UI_PLUGIN_SUGGEST", + "fixAllDescription_": "Fix All Description" + } +] + } \ No newline at end of file diff --git a/ets2panda/bindings/test/expected/getDefinitionAtPosition.json b/ets2panda/bindings/test/expected/getDefinitionAtPosition.json index 74bd51b3c26f3f49e8838394eed310a2e59b72d1..73b133987606044ddbf101795a4e7b21a1110a15 100644 --- a/ets2panda/bindings/test/expected/getDefinitionAtPosition.json +++ b/ets2panda/bindings/test/expected/getDefinitionAtPosition.json @@ -48,5 +48,10 @@ "fileName": "text.d.ets", "start": 7586, "length": 4 + }, + "11": { + "fileName": "taskpool.ets", + "start": 686, + "length": 4 } } \ No newline at end of file diff --git a/ets2panda/bindings/test/expected/getFileSource.json b/ets2panda/bindings/test/expected/getFileSource.json new file mode 100644 index 0000000000000000000000000000000000000000..e893655add4e990ee5dee52a66bfe7be02fb141d --- /dev/null +++ b/ets2panda/bindings/test/expected/getFileSource.json @@ -0,0 +1,3 @@ +{ + "1": "/*\n * Copyright (c) 2025 Huawei Device Co., Ltd.\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nlet a = 1;" +} \ No newline at end of file diff --git a/ets2panda/bindings/test/expected/getRenameInfo.json b/ets2panda/bindings/test/expected/getRenameInfo.json new file mode 100644 index 0000000000000000000000000000000000000000..269aac96696f681ad622fee6587b90a272bf69cc --- /dev/null +++ b/ets2panda/bindings/test/expected/getRenameInfo.json @@ -0,0 +1,14 @@ +{ + "1": { + "canRenameSuccess": true, + "fileToRename": "", + "kind": "property", + "displayName": "aaa", + "fullDisplayName": "aaa", + "kindModifiers": "", + "triggerSpan": { + "start": 613, + "length": 3 + } + } +} \ No newline at end of file diff --git a/ets2panda/bindings/test/expected/getSemanticDiagnostics.json b/ets2panda/bindings/test/expected/getSemanticDiagnostics.json index 679a81c0565df7ffcaec412a54ad8a473b295304..96a6551b8dfa9c62b550d290056103419fae7360 100644 --- a/ets2panda/bindings/test/expected/getSemanticDiagnostics.json +++ b/ets2panda/bindings/test/expected/getSemanticDiagnostics.json @@ -5,7 +5,7 @@ "2": { "diagnostics": [ { - "message": "Type '\"1\"' is not compatible with type 'double' at index 1", + "message": "Type '\"1\"' is not compatible with type 'Double' at index 1", "source": "\"1\"", "range": { "start": { @@ -19,7 +19,7 @@ }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 2046, "data": 0, "severity": 1, "codeDescription": { @@ -27,7 +27,7 @@ } }, { - "message": "No matching call signature for add(\"1\", int)", + "message": "No matching call signature for add(\"1\", Int)", "source": "add", "range": { "start": { @@ -41,7 +41,7 @@ }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 2127, "data": 0, "severity": 1, "codeDescription": { @@ -49,7 +49,7 @@ } }, { - "message": "Type '\"hello\"' cannot be assigned to type 'double'", + "message": "Type '\"hello\"' cannot be assigned to type 'Double'", "source": "\"hello\"", "range": { "start": { @@ -63,7 +63,7 @@ }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 2318, "data": 0, "severity": 1, "codeDescription": { diff --git a/ets2panda/bindings/test/expected/getSignatureHelpItems.json b/ets2panda/bindings/test/expected/getSignatureHelpItems.json index 51881ad082d114fead94544196db25c846c52d88..77744cd4ecdd2bac58b079393195563b2bc8fd99 100644 --- a/ets2panda/bindings/test/expected/getSignatureHelpItems.json +++ b/ets2panda/bindings/test/expected/getSignatureHelpItems.json @@ -37,7 +37,7 @@ "kind": "punctuation" }, { - "text": "double", + "text": "Double", "kind": "typeName" }, { @@ -114,7 +114,7 @@ "kind": "punctuation" }, { - "text": "double", + "text": "Double", "kind": "typeName" }, { @@ -191,7 +191,7 @@ "kind": "punctuation" }, { - "text": "double", + "text": "Double", "kind": "typeName" }, { @@ -257,7 +257,7 @@ "kind": "punctuation" }, { - "text": "double", + "text": "Double", "kind": "typeName" }, { diff --git a/ets2panda/bindings/test/expected/getSyntacticDiagnostics.json b/ets2panda/bindings/test/expected/getSyntacticDiagnostics.json index 2ed128d561f1f5ac1426fe6fbeabf5752a076545..37ff72da0fa39654a354aa2434f21d8f43e66507 100644 --- a/ets2panda/bindings/test/expected/getSyntacticDiagnostics.json +++ b/ets2panda/bindings/test/expected/getSyntacticDiagnostics.json @@ -19,7 +19,7 @@ }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 1227, "data": 0, "severity": 1, "codeDescription": { @@ -41,7 +41,7 @@ }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 1229, "data": 0, "severity": 1, "codeDescription": { @@ -63,7 +63,7 @@ }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 1227, "data": 0, "severity": 1, "codeDescription": { @@ -85,7 +85,7 @@ }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 1227, "data": 0, "severity": 1, "codeDescription": { @@ -93,21 +93,21 @@ } }, { - "message": "Unexpected token ':'.", - "source": "*ERROR_LITERAL*", + "message": "Unexpected token 'number'.", + "source": "number", "range": { "start": { "line": 16, - "character": 14 + "character": 16 }, "end": { "line": 16, - "character": 15 + "character": 22 } }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 1227, "data": 0, "severity": 1, "codeDescription": { @@ -129,7 +129,7 @@ }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 1227, "data": 0, "severity": 1, "codeDescription": { @@ -151,7 +151,7 @@ }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 1227, "data": 0, "severity": 1, "codeDescription": { @@ -159,21 +159,21 @@ } }, { - "message": "Unexpected token ','.", - "source": "*ERROR_LITERAL*", + "message": "Unexpected token 'b'.", + "source": "functon;\nadd(a);\n*ERROR_LITERAL*;\nnumber;\n*ERROR_LITERAL*;\n\nnumber;\n*ERROR_LITERAL*;\n{\n return ((a) + (b));\n}\nn = 333;\nres = add(n, n);", "range": { "start": { "line": 16, - "character": 22 + "character": 1 }, "end": { - "line": 16, - "character": 23 + "line": 20, + "character": 20 } }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 1227, "data": 0, "severity": 1, "codeDescription": { @@ -195,7 +195,7 @@ }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 1038, "data": 0, "severity": 1, "codeDescription": { @@ -217,7 +217,7 @@ }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 1227, "data": 0, "severity": 1, "codeDescription": { @@ -239,7 +239,7 @@ }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 1227, "data": 0, "severity": 1, "codeDescription": { @@ -247,21 +247,21 @@ } }, { - "message": "Unexpected token ')'.", - "source": "*ERROR_LITERAL*", + "message": "Unexpected token '{'.", + "source": "{\n return ((a) + (b));\n}", "range": { "start": { "line": 16, - "character": 33 + "character": 35 }, "end": { - "line": 16, - "character": 34 + "line": 18, + "character": 2 } }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 1227, "data": 0, "severity": 1, "codeDescription": { @@ -283,7 +283,7 @@ }, "tags": [], "relatedInfo": [], - "code": 1, + "code": 1163, "data": 0, "severity": 1, "codeDescription": { diff --git a/ets2panda/bindings/test/expected/modifyDeclFile.json b/ets2panda/bindings/test/expected/modifyDeclFile.json new file mode 100644 index 0000000000000000000000000000000000000000..7fdd0ca29e096b806eabf4df9e425542065d18be --- /dev/null +++ b/ets2panda/bindings/test/expected/modifyDeclFile.json @@ -0,0 +1,7 @@ +{ + "1": [ + "modifyDeclFile1.d.ets", + "modifyDeclFile2.d.ets", + "modifyDeclFile3.d.ets" + ] +} \ No newline at end of file diff --git a/ets2panda/bindings/test/monitor_node.js b/ets2panda/bindings/test/monitor_node.js new file mode 100644 index 0000000000000000000000000000000000000000..aade7588cfa828f60cbb067cb4f692eaf18b54e8 --- /dev/null +++ b/ets2panda/bindings/test/monitor_node.js @@ -0,0 +1,48 @@ +#!/usr/bin/env node +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const { spawn } = require('child_process'); + +const child = spawn(process.argv[2], process.argv.slice(3), { + stdio: 'inherit', + detached: true, + windowsHide: true +}); + +const timeout = setTimeout(() => { + console.error('process timeout'); + child.kill('SIGKILL'); + process.exit(124); +}, 900000); + +child.on('exit', (code, signal) => { + clearTimeout(timeout); + + if (signal === 'SIGSEGV' || signal === 'SIGABRT') { + console.error(`process crashe: ${signal}`); + process.exit(128 + signal); + } else { + process.exit(code ?? 0); + } +}); + +child.on('error', (err) => { + clearTimeout(timeout); + console.error(`Promoter process failure: ${err.message}`); + process.exit(127); +}); + +child.unref(); \ No newline at end of file diff --git a/ets2panda/bindings/test/run_bindings.sh b/ets2panda/bindings/test/run_bindings.sh new file mode 100755 index 0000000000000000000000000000000000000000..7fef1f2f16c23a3fbecf887dbaab90835f1141e3 --- /dev/null +++ b/ets2panda/bindings/test/run_bindings.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +readonly TEST_DIR="$1" +readonly NODE_DIR="$2" +readonly SDK_DIR="$3" +readonly CWD="${TEST_DIR}/../" +readonly CURRENT_NPM="${NODE_DIR}/npm" +readonly CURRENT_NODE="${NODE_DIR}/node" + +cp -rfp -- "$SDK_DIR" "$TEST_DIR" +cd "$CWD" && "$CURRENT_NPM" run test:build +if [ $? -eq 0 ]; then + echo "bindings test build successfully" +else + echo "bindings test build failed" + exit 1 +fi + +"$CURRENT_NODE" test/monitor_node.js "$CURRENT_NODE" --unhandled-rejections=strict dist-test/test/run_tests.js ./test +exit_code=$? +if [ $exit_code -eq 0 ]; then + echo "test execution successfully" +else + echo "test execution failed" + exit $exit_code +fi diff --git a/ets2panda/bindings/test/run_tests.ts b/ets2panda/bindings/test/run_tests.ts index ecb0adaa1651af5c538924461a4f880994f960d2..9e7ae34818e84998d3016c9f7b9d30f82a1b702f 100644 --- a/ets2panda/bindings/test/run_tests.ts +++ b/ets2panda/bindings/test/run_tests.ts @@ -15,16 +15,9 @@ import path from 'path'; import fs from 'fs'; -import { - Lsp, - LspDefinitionData, - LspCompletionInfo, - LspDiagsNode, - ModuleDescriptor, - generateArkTsConfigByModules -} from '../src/index'; -import { testCases } from './cases'; -import { LspCompletionEntry } from '../src/lspNode'; +import { Lsp, LspDefinitionData, LspCompletionInfo, LspDiagsNode, ModuleDescriptor, PathConfig } from '../src/index'; +import { testCases, testSingleModuleCases } from './cases'; +import { LspCompletionEntry } from '../src/lsp/lspNode'; interface ComparisonOptions { subMatch?: boolean; @@ -60,6 +53,19 @@ function getExpectedResult(filePath: string): any { } } +// CC-OFFNXT(no_explicit_any) project code style +function getFilesByDir(dirPath: string): string[] { + try { + return fs.readdirSync(dirPath) + .filter(file => + fs.statSync(path.join(dirPath, file)).isFile() + ); + } catch (err) { + console.error(`Failed to load files from ${dirPath}: ${err}`); + return []; + } +} + function sortCompletions(completionResult: LspCompletionInfo): LspCompletionInfo { if (!completionResult || !completionResult.entries || !Array.isArray(completionResult.entries)) { return completionResult; @@ -227,6 +233,15 @@ function compareGetCompletionResult(testName: string, actual: unknown, expected: } as ComparisonOptions); } +function compareDeclFileResult(testName: string, declgenOutDir: string, expected: unknown): boolean { + let fileList: string[] = getFilesByDir(declgenOutDir); + const actualEntries = fileList.filter(file => file.endsWith('.d.ets')); + const expectedEntries = expected as string[]; + return compareResultsHelper(testName, normalizeData(actualEntries), expectedEntries, { + subMatch: true + } as ComparisonOptions); +} + function findTextDefinitionPosition(sourceCode: string): number { const textDefinitionPattern = /export\s+declare\s+function\s+Text\(/; const match = textDefinitionPattern.exec(sourceCode); @@ -241,6 +256,21 @@ function findTextDefinitionPosition(sourceCode: string): number { throw new Error('Could not find Text definition in source code'); } +// CC-OFFNXT(huge_cyclomatic_complexity, huge_depth, huge_method) false positive +function findTaskDefinitionPosition(sourceCode: string): number { + const taskDefinitionPattern = /export\s+class\s+Task\s+{/; + const match = taskDefinitionPattern.exec(sourceCode); + if (match) { + const classTaskPattern = /class\s+Task\s+{/; + const subMatch = classTaskPattern.exec(sourceCode.substring(match.index)); + if (subMatch) { + const positionOfT = match.index + subMatch.index + 'class '.length; + return positionOfT; + } + } + throw new Error('Could not find Task definition in source code'); +} + function compareGetDefinitionResult(testName: string, actual: any, expected: Record): boolean { // This is the definition info for the UI component. // File in the SDK might changed, so the offset needs to be checked dynamically. @@ -255,11 +285,24 @@ function compareGetDefinitionResult(testName: string, actual: any, expected: Rec }; return compareResultsHelper(testName, normalizeData(actual), expectedResult); } + // This is the definition info for the class in std library. + // File in the SDK might changed, so the offset needs to be checked dynamically. + if (expected['fileName'] === 'taskpool.ets') { + const actualDef = actual as LspDefinitionData; + const fileName = actualDef.fileName as string; + const fileContent = fs.readFileSync(fileName, 'utf8'); + const expectedStart = findTaskDefinitionPosition(fileContent); + const expectedResult = { + ...expected, + start: expectedStart + }; + return compareResultsHelper(testName, normalizeData(actual), expectedResult); + } return compareResultsHelper(testName, normalizeData(actual), expected); } // CC-OFFNXT(no_explicit_any) project code style -function compareResults(testName: string, index: string, actual: unknown, expected: unknown): boolean { +function compareResults(testName: string, index: string, actual: unknown, expected: unknown, declgenOutDir: string = ''): boolean { const name = `${testName}:${index}`; if (testName === 'getDefinitionAtPosition') { return compareGetDefinitionResult(name, actual, expected as Record); @@ -267,15 +310,17 @@ function compareResults(testName: string, index: string, actual: unknown, expect if (testName === 'getCompletionAtPosition') { return compareGetCompletionResult(name, actual, expected); } - + if (testName === 'generateDeclFile' || testName === 'modifyDeclFile') { + const declOutPath = path.join(declgenOutDir, 'dynamic', 'dep', 'declgenV1'); + return compareDeclFileResult(name, declOutPath, expected); + } return compareResultsHelper(name, normalizeData(actual), expected); } -function runTests(testDir: string, lsp: Lsp) { +function runTests(lsp: Lsp): string[] { console.log('Running tests...'); if (!testCases) { - console.error('Failed to load test cases'); - return; + return []; } let failedList: string[] = []; @@ -317,13 +362,133 @@ function runTests(testDir: string, lsp: Lsp) { console.log(`Finished test: ${testName}`); console.log('-----------------------------------'); } + return failedList; +} + +function runSingleTests(testDir: string, failedList: string[]): string[] { + console.log('Running single tests...'); + if (!testSingleModuleCases) { + return []; + } + const testSrcPath = path.join(testDir, 'testcases'); + for (const [testName, testConfig] of Object.entries(testSingleModuleCases)) { + const testBuildPath = path.join(testSrcPath, '.idea', '.deveco', testName); + let pathConfig: PathConfig = { + buildSdkPath: path.join(testDir, 'ets', 'ets1.2'), + projectPath: testBuildPath, + declgenOutDir: testBuildPath + }; + const moduleList: ModuleDescriptor[] = [ + { + arktsversion: '1.1', + name: 'entry', + moduleType: 'har', + srcPath: path.join(testSrcPath, testName, 'entry') + }, + { + arktsversion: '1.2', + name: 'dep', + moduleType: 'har', + srcPath: path.join(testSrcPath, testName, 'dep') + } + ] as ModuleDescriptor[]; + const lsp = new Lsp(pathConfig, undefined, moduleList); + const { expectedFilePath, ...testCaseVariants } = testConfig; + const expectedResult = getExpectedResult(expectedFilePath); + if (expectedResult === null) { + console.error(`[${testName}] Skipped (expected result not found)`); + continue; + } + // CC-OFFNXT(no_explicit_any) project code style + if (typeof (lsp as any)[testName] !== 'function') { + console.error(`[${testName}] ❌ Error: Method "${testName}" not found on Lsp object`); + continue; + } + + for (const [index, params] of Object.entries(testCaseVariants)) { + let pass = false; + let actualResult = null; + try { + // CC-OFFNXT(no_explicit_any) project code style + actualResult = (lsp as any)[testName](...params); + actualResult = sortActualResult(testName, actualResult); + pass = compareResults(testName, index, actualResult, expectedResult[index], pathConfig.declgenOutDir); + } catch (error) { + console.error(`[${testName}:${index}] ❌ Error: ${error}`); + } + if (!pass) { + failedList.push(`${testName}:${index}`); + } + if (!pass && updateMode) { + console.log(`Updating expected result for ${testName}:${index}`); + expectedResult[index] = normalizeData(actualResult); + } + } + if (updateMode) { + fs.writeFileSync(expectedFilePath, JSON.stringify(expectedResult, null, 2)); + } + console.log(`Finished test: ${testName}`); + console.log('-----------------------------------'); + } + return failedList; +} + +function run(lsp: Lsp, testDir: string): void { + let failedList = runTests(lsp); + failedList = runSingleTests(testDir, failedList); + console.log('Tests completed.'); if (failedList.length > 0) { console.log('❌ Failed tests:'); - failedList.forEach((failedCase) => { + failedList.forEach((failedCase: string) => { console.log(`- ${failedCase}`); }); + + console.error('Tests failed without AST cache'); + process.exit(1); + } else { + if (!testCases) { + console.error('Failed to load test cases'); + } + if (!testSingleModuleCases) { + console.error('Failed to load single module test cases'); + } + if (!testCases && !testSingleModuleCases) { + console.error('Tests failed without AST cache'); + process.exit(1); + } + } + console.log('Finished test without ast cache'); +} + +async function runWithAstCache(lsp: Lsp, modules: ModuleDescriptor[], testDir: string): Promise { + await lsp.initAstCache(); + lsp.update(modules); + let failedList = runTests(lsp); + failedList = runSingleTests(testDir, failedList); + + console.log('Tests completed.'); + if (failedList.length > 0) { + console.log('❌ Failed tests:'); + failedList.forEach((failedCase: string) => { + console.log(`- ${failedCase}`); + }); + + console.error('Tests failed with AST cache'); + process.exit(1); + } else { + if (!testCases) { + console.error('Failed to load test cases'); + } + if (!testSingleModuleCases) { + console.error('Failed to load single module test cases'); + } + if (!testCases && !testSingleModuleCases) { + console.error('Tests failed without AST cache'); + process.exit(1); + } } + console.log('Finished test with ast cache'); } if (require.main === module) { @@ -336,13 +501,27 @@ if (require.main === module) { updateMode = true; } const testDir = path.resolve(process.argv[2]); - const buildSdkPath = path.join(testDir, 'ets', 'ets1.2'); - const projectRoot = path.join(testDir, 'testcases'); - const modules = getModules(projectRoot); - - generateArkTsConfigByModules(buildSdkPath, projectRoot, modules); - const lsp = new Lsp(projectRoot); + let pathConfig: PathConfig = { + buildSdkPath: path.join(testDir, 'ets', 'ets1.2'), + projectPath: path.join(testDir, 'testcases'), + declgenOutDir: '' + }; - process.env.BINDINGS_PATH = path.join(buildSdkPath, 'build-tools', 'bindings'); - runTests(testDir, lsp); + const modules = getModules(pathConfig.projectPath); + process.env.BINDINGS_PATH = path.join(pathConfig.buildSdkPath, 'build-tools', 'bindings'); + process.env.PANDA_LIB_PATH = path.join(pathConfig.buildSdkPath, 'build-tools', 'ets2panda', 'lib'); + process.env.PANDA_BIN_PATH = path.join(pathConfig.buildSdkPath, 'build-tools', 'ets2panda', 'bin'); + const lsp = new Lsp(pathConfig, undefined, modules); + run(lsp, testDir); + // for generate ast cache + const entry_module = [ + { + arktsversion: '1.2', + name: 'entry', + moduleType: 'har', + srcPath: path.join(pathConfig.projectPath, 'entry') + } + ]; + const lsp_1 = new Lsp(pathConfig, undefined, entry_module); + runWithAstCache(lsp_1, modules, testDir).then(() => {}); } diff --git a/ets2panda/bindings/test/testcases/cases.json b/ets2panda/bindings/test/testcases/cases.json new file mode 100644 index 0000000000000000000000000000000000000000..6e708b142563391b18964014fc043fa85f472664 --- /dev/null +++ b/ets2panda/bindings/test/testcases/cases.json @@ -0,0 +1,225 @@ +{ + "getDefinitionAtPosition": { + "expectedFilePath": "path/to/bindings/test/expected/getDefinitionAtPosition.json", + "1": [ + "path/to/bindings/test/testcases/getDefinitionAtPosition/getDefinitionAtPosition2.ets", + 655 + ], + "2": [ + "path/to/bindings/test/testcases/getDefinitionAtPosition/getDefinitionAtPosition3.ets", + 662 + ], + "3": [ + "path/to/bindings/test/testcases/getDefinitionAtPosition/getDefinitionAtPosition5.ets", + 664 + ], + "4": [ + "path/to/bindings/test/testcases/getDefinitionAtPosition/getDefinitionAtPosition7.ets", + 683 + ], + "5": [ + "path/to/bindings/test/testcases/getDefinitionAtPosition/getDefinitionAtPosition9.ets", + 666 + ], + "6": [ + "path/to/bindings/test/testcases/getDefinitionAtPosition/getDefinitionAtPosition11.ets", + 675 + ], + "7": [ + "path/to/bindings/test/testcases/getDefinitionAtPosition/getDefinitionAtPosition13.ets", + 664 + ], + "8": [ + "path/to/bindings/test/testcases/getDefinitionAtPosition/getDefinitionAtPosition15.ets", + 617 + ], + "9": [ + "path/to/bindings/test/testcases/getDefinitionAtPosition/getDefinitionAtPosition17.ets", + 677 + ], + "10": [ + "path/to/bindings/test/testcases/getDefinitionAtPosition/getDefinitionAtPosition18.ets", + 930 + ] + }, + "getSemanticDiagnostics": { + "expectedFilePath": "path/to/bindings/test/expected/getSemanticDiagnostics.json", + "1": [ + "path/to/bindings/test/testcases/getSemanticDiagnostics/getSemanticDiagnostics1.ets" + ], + "2": [ + "path/to/bindings/test/testcases/getSemanticDiagnostics/getSemanticDiagnostics2.ets" + ] + }, + "getCurrentTokenValue": { + "expectedFilePath": "path/to/bindings/test/expected/getCurrentTokenValue.json", + "1": [ + "path/to/bindings/test/testcases/getCurrentTokenValue/getCurrentTokenValue1.ets", + 611 + ], + "2": [ + "path/to/bindings/test/testcases/getCurrentTokenValue/getCurrentTokenValue2.ets", + 612 + ], + "3": [ + "path/to/bindings/test/testcases/getCurrentTokenValue/getCurrentTokenValue3.ets", + 612 + ], + "4": [ + "path/to/bindings/test/testcases/getCurrentTokenValue/getCurrentTokenValue4.ets", + 611 + ] + }, + "getFileReferences": { + "expectedFilePath": "path/to/bindings/test/expected/getFileReferences.json", + "1": [ + "path/to/bindings/test/testcases/getFileReferences/getFileReferences1_export.ets" + ] + }, + "getReferencesAtPosition": { + "expectedFilePath": "path/to/bindings/test/expected/getReferencesAtPosition.json", + "1": [ + "path/to/bindings/test/testcases/getReferencesAtPosition/getReferencesAtPosition1.ets", + 613 + ], + "2": [ + "path/to/bindings/test/testcases/getReferencesAtPosition/getReferencesAtPosition2.ets", + 635 + ], + "3": [ + "path/to/bindings/test/testcases/getReferencesAtPosition/getReferencesAtPosition4.ets", + 625 + ] + }, + "getSyntacticDiagnostics": { + "expectedFilePath": "path/to/bindings/test/expected/getSyntacticDiagnostics.json", + "1": [ + "path/to/bindings/test/testcases/getSyntacticDiagnostics/getSyntacticDiagnostics1.ets" + ], + "2": [ + "path/to/bindings/test/testcases/getSyntacticDiagnostics/getSyntacticDiagnostics2.ets" + ] + }, + "getSuggestionDiagnostics": { + "expectedFilePath": "path/to/bindings/test/expected/getSuggestionDiagnostics.json", + "1": [ + "path/to/bindings/test/testcases/getSuggestionDiagnostics/getSuggestionDiagnostics1.ets" + ] + }, + "getQuickInfoAtPosition": { + "expectedFilePath": "path/to/bindings/test/expected/getQuickInfoAtPosition.json", + "1": [ + "path/to/bindings/test/testcases/getQuickInfoAtPosition/getQuickInfoAtPosition1.ets", + 626 + ], + "2": [ + "path/to/bindings/test/testcases/getQuickInfoAtPosition/getQuickInfoAtPosition2.ets", + 618 + ], + "3": [ + "path/to/bindings/test/testcases/getQuickInfoAtPosition/getQuickInfoAtPosition3.ets", + 663 + ] + }, + "getDocumentHighlights": { + "expectedFilePath": "path/to/bindings/test/expected/getDocumentHighlights.json", + "1": [ + "path/to/bindings/test/testcases/getDocumentHighlights/getDocumentHighlights1.ets", + 614 + ], + "2": [ + "path/to/bindings/test/testcases/getDocumentHighlights/getDocumentHighlights2.ets", + 717 + ], + "3": [ + "path/to/bindings/test/testcases/getDocumentHighlights/getDocumentHighlights3.ets", + 616 + ], + "4": [ + "path/to/bindings/test/testcases/getDocumentHighlights/getDocumentHighlights4.ets", + 626 + ], + "5": [ + "path/to/bindings/test/testcases/getDocumentHighlights/getDocumentHighlights5.ets", + 619 + ], + "6": [ + "path/to/bindings/test/testcases/getDocumentHighlights/getDocumentHighlights6.ets", + 657 + ], + "7": [ + "path/to/bindings/test/testcases/getDocumentHighlights/getDocumentHighlights7.ets", + 733 + ] + }, + "getCompletionAtPosition": { + "expectedFilePath": "path/to/bindings/test/expected/getCompletionAtPosition.json", + "1": [ + "path/to/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition1.ets", + 705 + ], + "2": [ + "path/to/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition2.ets", + 735 + ], + "3": [ + "path/to/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition3.ets", + 789 + ], + "4": [ + "path/to/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition4.ets", + 767 + ], + "5": [ + "path/to/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition5.ets", + 728 + ], + "6": [ + "path/to/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition6.ets", + 718 + ], + "7": [ + "path/to/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition7.ets", + 683 + ], + "8": [ + "path/to/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition8.ets", + 614 + ], + "9": [ + "path/to/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition9.ets", + 619 + ], + "10": [ + "path/to/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition10.ets", + 712 + ], + "11": [ + "path/to/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition11.ets", + 682 + ], + "12": [ + "path/to/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition12.ets", + 720 + ], + "13": [ + "path/to/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition13.ets", + 658 + ], + "14": [ + "path/to/bindings/test/testcases/getCompletionAtPosition/getCompletionsAtPosition14.ets", + 659 + ] + }, + "toLineColumnOffset": { + "expectedFilePath": "path/to/bindings/test/expected/toLineColumnOffset.json", + "1": [ + "path/to/bindings/test/testcases/toLineColumnOffset/toLineColumnOffset1.ets", + 0 + ], + "2": [ + "path/to/bindings/test/testcases/toLineColumnOffset/toLineColumnOffset1.ets", + 642 + ] + } +} \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/entry/Index.ets b/ets2panda/bindings/test/testcases/entry/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a665975076ca05f9e8111b218136fdbff21f123c --- /dev/null +++ b/ets2panda/bindings/test/testcases/entry/Index.ets @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Text, Column, Component, Entry, Button, ClickEvent } from "@ohos.arkui.component" +import { State, Link, Prop } from "@ohos.arkui.stateManagement" +import hilog from '@ohos.hilog' + +@Entry +@Component +struct MyStateSample { + @State stateVar: string = "state var"; + message: string = `click to change state variable, add **`; + changeValue() { + this.stateVar+="**" + } + build() { + Column() { + Button("clean variable").onClick((e: ClickEvent) => { this.stateVar = "state var" }) + Text("Hello World").fontSize(20) + Button(this.message).backgroundColor("#FFFF00FF") + .onClick((e: ClickEvent) => { + hilog.info(0x0000, 'testTag', 'On Click'); + this.changeValue() + }) + Text(this.stateVar).fontSize(20) + Child({linkVar: this.stateVar, propVar: this.stateVar}) + }.margin(10) + } +} + +@Component +struct Child { + @Link linkVar: string = ""; // TODO: remove this + @Prop propVar: string = "Prop"; + + changeValue1() { + this.linkVar+="!!" + } + + changeValue2() { + this.propVar+="~~" + } + + build() { + Column() { + Button(`click to change Link variable, add symbol !!`) + .backgroundColor("#4169E1") + .onClick((e: ClickEvent) => { + hilog.info(0x0000, 'testTag', 'On Click'); + this.changeValue1() + }) + Button(`click to change Prop variable, add symbol ~~`) + .backgroundColor("#3CB371") + .onClick((e: ClickEvent) => { + hilog.info(0x0000, 'testTag', 'On Click'); + this.changeValue2() + }) + Text(`Link variable in child: ${this.linkVar}`).fontSize(30) + Text(`Prop variable in child: ${this.propVar}`).fontSize(30) + } + } +} \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/findRenameLocations/findRenameLocations1.ets b/ets2panda/bindings/test/testcases/findRenameLocations/findRenameLocations1.ets new file mode 100644 index 0000000000000000000000000000000000000000..8fe412caf8c78831989ab3ffafb3794ee73091af --- /dev/null +++ b/ets2panda/bindings/test/testcases/findRenameLocations/findRenameLocations1.ets @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export function abc(x: number): void { +} + +export function dummy(x: number): void { +} + +export class Foo { + name: string = "unassigned"; + x: number = 1; + y: number = 2; + z: number = 3; + constructor(name: string, x: number, y: number, z: number) { + this.name = name; + this.x = x; + this.y = y; + this.z = z; + } +}; + +export class Oranges { + name: string = "unassigned"; + x: number = 1; + y: number = 2; + z: number = 3; + constructor(name: string, x: number, y: number, z: number) { + this.name = name; + this.x = x; + this.y = y; + this.z = z; + } +}; + +dummy(0); +dummy(1); +abc(2); +abc(3); +abc(4); diff --git a/ets2panda/bindings/test/testcases/findRenameLocations/findRenameLocations2.ets b/ets2panda/bindings/test/testcases/findRenameLocations/findRenameLocations2.ets new file mode 100644 index 0000000000000000000000000000000000000000..e37a0e5fc26bcbe61b345858655df093f17a14ed --- /dev/null +++ b/ets2panda/bindings/test/testcases/findRenameLocations/findRenameLocations2.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { dummy, abc, Foo } from "./findRenameLocations1.ets"; + +dummy(4); +dummy(44); +abc(5); +abc(55); +abc(555); + +let myfoo = new Foo("apples", 1, 2, 3); +let otherfoo = new Foo("oranges", 4, 5, 6); + +console.log(myfoo) +console.log(otherfoo) +console.log(myfoo.name) diff --git a/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile1.ets b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile1.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f033b2c0310beab1cecebeb2efb412fd53521a1 --- /dev/null +++ b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile1.ets @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let currentValue: string = 'currentValue'; + +let resultValue: number = -1; + +let mathRandom: number = 14; + +function getCurrentValue(): number { + let firstValue = getFirstValue(); + let secondValue = getSecondValue(); + let thridValue = getThridValue(); + resultValue = currentValue.length; + return currentValue.length; +} + +function getFirstValue(): number { + let c = 15; + let value = c * mathRandom; + mathRandom++; + EtsStepArkTest() + return value; +} + +function getSecondValue(): number { + let d = 11; + let value1 = getFirstValue(); + return value1 * d; +} + +function getThridValue(): number { + let value1 = getFirstValue(); + let value2 = getSecondValue(); + return value1 * value2; +} + +function getValue(): string { + return getCurrentValue() + currentValue; +} + +getValue(); \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile2.ets b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile2.ets new file mode 100644 index 0000000000000000000000000000000000000000..d86e832dddad78e9c7c27228d4c1c1635ffe34fa --- /dev/null +++ b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile2.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class Foo { + Foo(a:number, b:number): number { + return a + b; + } +} diff --git a/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile3.ets b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile3.ets new file mode 100644 index 0000000000000000000000000000000000000000..74e5fc562609d051b80763d02a9004b538ef7c5d --- /dev/null +++ b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile3.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function A(a:number, b:number): number { + return a + b; +} +A(1, 2); +function A(a:number): number { + return a; +} +A(1); diff --git a/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile4.ets b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile4.ets new file mode 100644 index 0000000000000000000000000000000000000000..7b762ba46101e5106cf2329ceb9fb4250b9e4439 --- /dev/null +++ b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile4.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class A { + Foo(a:number, b:number): number { + return a + b; + } + readTest1(c:number, d:number): number { + return a - b; + } + + readTest2(e:number, f:number): number { + return a * b; + } + + readTest3(e:number, f:number): number { + return a / b; + } +}; \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile5.ets b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile5.ets new file mode 100644 index 0000000000000000000000000000000000000000..50e29bb12fe3e8702274b4d541f47003f79e7de9 --- /dev/null +++ b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile5.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class A { + Foo(a:number, b:number): number { + return a + b; + } +} diff --git a/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile6.ets b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile6.ets new file mode 100644 index 0000000000000000000000000000000000000000..c54a0d1535beb24b839528d630e01201cd4010fa --- /dev/null +++ b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile6.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { memo, __memo_context_type, __memo_id_type } from "@ohos.arkui.stateManagement"; +import { Text, Column, Component, Button, ClickEvent } from "@ohos.arkui.component"; + +import hilog from '@ohos.hilog'; + +@Component +export struct MyStateSample { + message: string = "Click"; + + build() { + Column(undefined) { + Text("Hello World") + .fontSize(20) + Button(this.message) + .backgroundColor("#FFFF00FF") + .onClick((e: ClickEvent) => { + hilog.info(0x0000, 'testTag', 'On Click'); + }) + Child() + } + } +} + +@Component +export struct Child { + stateVar: string = "Child"; + + build() { + Text(this.stateVar) + .fontSize(50) + } +} diff --git a/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile7.ets b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile7.ets new file mode 100644 index 0000000000000000000000000000000000000000..3f8d64d3fa9e7cc595245dbc303453427804d928 --- /dev/null +++ b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile7.ets @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +interface DataValue { + a: number; + b: string; + c: string; + d: number; +} + +let currentValue: DataValue = { + a: 12, + b: 'da', + c: 'vk', + d: 1111 +}; + +let result: number = 0; + +let resultStr: number = 0; + +let resultValue: number = -1; + +let mathRandom: number = 14; + +function getPath(c: number, d: number): number { + return c * d; +} + +function getPathDate(c: number): number { + return c * 2 + 6; +} + +function getCurrentValue(): DataValue { + let currentValue: DataValue = { + a: 12, + b: 'da', + c: 'vk', + d: 1111 + }; + currentValue.a = getFirstValue(); + currentValue.d = getSecondValue(); + currentValue.c = getThridValue() + getSecondValue() + getFirstValue(); + currentValue.b = getThridValue() + getSecondValue() + getFirstValue() + resultValue; + EtsStepArkTest() + while(currentValue.a < 12) { + if (resultValue % 2 === 0) { + currentValue.a = currentValue.a++; + } else { + currentValue.d = currentValue.d--; + } + } + return currentValue; +} + +function getFirstValue(): number { + let currentFirstValue: DataValue = { + a: 23, + b: '124f', + c: 'gfr', + d: 767 + }; + EtsStepArkTest() + return getPath(currentFirstValue.a, currentFirstValue.d); +} + +function getSecondValue(): number { + for(let index = 0; index < 2; index++) { + result = getPathDate(index); + } + return result; +} + +function getThridValue(): string { + let dd: string = ''; + for(let index = 0; index< 2; index++) { + dd = resultStr + getPathDate(index) + 'abc'; + } + EtsStepArkTest() + return dd; +} + +function getValueStr(): string { + return getCurrentValue().b + currentValue; +} + +getValueStr(); diff --git a/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile8.ets b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile8.ets new file mode 100644 index 0000000000000000000000000000000000000000..10859e929cf149305acef118db4e74f319c4d69c --- /dev/null +++ b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile8.ets @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function func06(): void { + EtsStepArkTest(); +} + +function func05(): void { + func06(); + EtsStepArkTest(); +} + +function func04(): void { + func05(); + EtsStepArkTest(); +} + +function func03(): void { + let id = 0; + for (let i = 0; i < 10; ++i) { + id++ + } + func04(); + EtsStepArkTest(); +} + +function func02(): void { + func03(); + EtsStepArkTest(); +} + +function func01(): void { + func02(); + EtsStepArkTest(); +} + +function main(argc:string[]): void { + func01(); +} diff --git a/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile9.ets b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile9.ets new file mode 100644 index 0000000000000000000000000000000000000000..a38038cd9c441a688778cffb05f72e5692d9ac9f --- /dev/null +++ b/ets2panda/bindings/test/testcases/generateDeclFile/dep/generateDeclFile9.ets @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +interface FileDataValue { + fileName: string; + filePath: string; + data: DataValue; +} + +interface DataValue { + dataLength: number; + dataOffset: number; + dataStr: string; +} + +class OperationFactory { + private currentType: string = 'add'; + + createOperation(type: 'add' | 'subtract' | 'multiply' | 'divide', a: number, b: number): number { + this.currentType = type; + switch (type) { + case 'add': + return a + b; + case 'subtract': + return a - b; + case 'multiply': + return a * b; + case 'divide': + if (b === 0) { + throw new Error("Division by zero is not allowed."); + } + return a / b; + default: + throw new Error("Unknown operation type"); + } + } +} + +function getFileDate(): FileDataValue[] { + let FileDataValues: FileDataValue[] = [{ + fileName: 'OperationFactoryFile', + filePath: 'source/url/OperationFactoryFile', + data: { + dataLength: 10, + dataOffset: 2, + dataStr: 'This is a test data!' + } + }]; + EtsStepArkTest(); + return FileDataValues; +} + +function getOperationFactory(): void { + getFileDate(); + const factory = new OperationFactory(); + factory.createOperation('add', 2, 3); + factory.createOperation('subtract', 5, 5); + factory.createOperation('multiply', 3, 6); + factory.createOperation('divide', 2, 2); +} + +getOperationFactory(); diff --git a/ets2panda/bindings/test/testcases/generateDeclFile/entry/index.ets b/ets2panda/bindings/test/testcases/generateDeclFile/entry/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6fc34b5b10bc306f7613a62e1b441e9669e4b02e --- /dev/null +++ b/ets2panda/bindings/test/testcases/generateDeclFile/entry/index.ets @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + let indexStr: string = "generateDeclFile"; \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/generateDeclFile/entry/oh-package.json5 b/ets2panda/bindings/test/testcases/generateDeclFile/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8ee2596efddc104b26b6ec83ed6fac9ac144acf8 --- /dev/null +++ b/ets2panda/bindings/test/testcases/generateDeclFile/entry/oh-package.json5 @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "5.0.1", + "description": "Please describe the basic information.", + "dependencies": { + "myDep": "file:../dep" + }, + "devDependencies": { + } +} diff --git a/ets2panda/bindings/test/testcases/getCodeFixesAtPosition/getCodeFixesAtPosition1.ets b/ets2panda/bindings/test/testcases/getCodeFixesAtPosition/getCodeFixesAtPosition1.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ac051ca62dbfb06be443f68172bf3ed900b0101 --- /dev/null +++ b/ets2panda/bindings/test/testcases/getCodeFixesAtPosition/getCodeFixesAtPosition1.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { memo, __memo_context_type, __memo_id_type } from '@ohos.arkui.stateManagement' +import { + Entry + Text, + TextAttributes, + Column, + Component, + Button, + ButtonAttribute, + ClickEvent, + UserView +} from '@ohos.arkui.component' +import { State, MutableSate, stateOf, observableProxy } from '@ohos.arkui.stateManagement' +import hilog from '@ohos.hilog' + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .onClick(() => { + console.info("hello, :") + console.log(result.toString()) + }) + .width('100%') + } + .height('100%') + } +} + +@Entry +@Component +struct Index { + build() {} +} \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/getDefinitionAtPosition/getDefinitionAtPosition19.ets b/ets2panda/bindings/test/testcases/getDefinitionAtPosition/getDefinitionAtPosition19.ets new file mode 100755 index 0000000000000000000000000000000000000000..fc811ab595deb7697c8748ef83cea4f1b3a609eb --- /dev/null +++ b/ets2panda/bindings/test/testcases/getDefinitionAtPosition/getDefinitionAtPosition19.ets @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const task = new taskpool.Task(()=>{}); diff --git a/ets2panda/bindings/test/testcases/getFileSource/getFileSource1.ets b/ets2panda/bindings/test/testcases/getFileSource/getFileSource1.ets new file mode 100644 index 0000000000000000000000000000000000000000..119751e901726748feeeb271b61fd5633db5b46b --- /dev/null +++ b/ets2panda/bindings/test/testcases/getFileSource/getFileSource1.ets @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let a = 1; \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/getRenameInfo/getRenameInfo1.ets b/ets2panda/bindings/test/testcases/getRenameInfo/getRenameInfo1.ets new file mode 100644 index 0000000000000000000000000000000000000000..1986e1b330712c668afd67acde59f9da86f426be --- /dev/null +++ b/ets2panda/bindings/test/testcases/getRenameInfo/getRenameInfo1.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +let aaa = 123; +let bbb = aaa + 123; +console.log(aaa + ""); \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/modifyDeclFile/dep/modifyDeclFile1.ets b/ets2panda/bindings/test/testcases/modifyDeclFile/dep/modifyDeclFile1.ets new file mode 100644 index 0000000000000000000000000000000000000000..6056b864f5a8aabc2d32242444578acb24417502 --- /dev/null +++ b/ets2panda/bindings/test/testcases/modifyDeclFile/dep/modifyDeclFile1.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +interface Employee { + name: string; + salary: number; + hasBonus: boolean; +} + +function calculateTotalSalary(employees: Employee[]): number { + const bonusAmount = 500; + + let totalSalary = 0; + EtsStepArkTest(); + + for (const employee of employees) { + let adjustedSalary = employee.salary; + if (employee.hasBonus) { + adjustedSalary += bonusAmount; + } + totalSalary += adjustedSalary; + } + return totalSalary; +} + +const employees: Employee[] = [ + { name: "Alice", salary: 3000, hasBonus: true }, + { name: "Bob", salary: 2800, hasBonus: false }, + { name: "Charlie", salary: 3200, hasBonus: true }, + { name: "David", salary: 2900, hasBonus: false } +]; + +const totalSalary = calculateTotalSalary(employees); diff --git a/ets2panda/bindings/test/testcases/modifyDeclFile/dep/modifyDeclFile2.ets b/ets2panda/bindings/test/testcases/modifyDeclFile/dep/modifyDeclFile2.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd7b2efb5ffc195a9655e062398f0124caa5c5b7 --- /dev/null +++ b/ets2panda/bindings/test/testcases/modifyDeclFile/dep/modifyDeclFile2.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class ChainCalculator { + private result: number; + + constructor(initialValue: number) { + this.result = initialValue; + } + + add(value: number): ChainCalculator { + this.result += value; + return this; + } + + subtract(value: number): ChainCalculator { + this.result -= value; + return this; + } + + multiply(value: number): ChainCalculator { + this.result *= value; + return this; + } + + divide(value: number): ChainCalculator { + EtsStepArkTest(); + if (value === 0) { + throw new Error("Division by zero is not allowed."); + } + this.result /= value; + return this; + } + + getResult(): number { + return this.result; + } + + geFinalResult(addValue: number, subtractValue: number, multiplyValue: number, divideValue: number): number { + return chainCalc.add(addValue).subtract(subtractValue).multiply(multiplyValue).divide(divideValue).getResult(); + } +} + +const chainCalc = new ChainCalculator(10); +chainCalc.geFinalResult(2, 4, 6, 3); diff --git a/ets2panda/bindings/test/testcases/modifyDeclFile/dep/modifyDeclFile3.ets b/ets2panda/bindings/test/testcases/modifyDeclFile/dep/modifyDeclFile3.ets new file mode 100644 index 0000000000000000000000000000000000000000..901ff0e5a05e58b5e6f4bce30d02198555876b88 --- /dev/null +++ b/ets2panda/bindings/test/testcases/modifyDeclFile/dep/modifyDeclFile3.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function getC(a:number, b:number): number { + return a + b; +} + +getC(1, 120); diff --git a/ets2panda/bindings/test/testcases/modifyDeclFile/entry/index.ets b/ets2panda/bindings/test/testcases/modifyDeclFile/entry/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b342f515ec93e1b84cf24499e987b66f03f7c43b --- /dev/null +++ b/ets2panda/bindings/test/testcases/modifyDeclFile/entry/index.ets @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + let indexStr: string = "modifyDeclFile"; \ No newline at end of file diff --git a/ets2panda/bindings/test/testcases/modifyDeclFile/entry/oh-package.json5 b/ets2panda/bindings/test/testcases/modifyDeclFile/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8ee2596efddc104b26b6ec83ed6fac9ac144acf8 --- /dev/null +++ b/ets2panda/bindings/test/testcases/modifyDeclFile/entry/oh-package.json5 @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "5.0.1", + "description": "Please describe the basic information.", + "dependencies": { + "myDep": "file:../dep" + }, + "devDependencies": { + } +} diff --git a/ets2panda/checker/ASchecker.cpp b/ets2panda/checker/ASchecker.cpp index 3a3cb8e6919aafd41329ac9b4fa2d6880ee55fff..ee3cd234f8fcdb5e5d20957c1ff19f7d17086b66 100644 --- a/ets2panda/checker/ASchecker.cpp +++ b/ets2panda/checker/ASchecker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -21,8 +21,6 @@ namespace ark::es2panda::checker { bool ASChecker::StartChecker([[maybe_unused]] varbinder::VarBinder *varbinder, const util::Options &options) { - Initialize(varbinder); - if (options.IsDumpAst()) { std::cout << Program()->Dump() << std::endl; } diff --git a/ets2panda/checker/ASchecker.h b/ets2panda/checker/ASchecker.h index 69a80488abb56b310d61bc7464e0480245f93cb7..84ba809e5b0d673bdfc99f006a9ea7a649a2b281 100644 --- a/ets2panda/checker/ASchecker.h +++ b/ets2panda/checker/ASchecker.h @@ -23,8 +23,9 @@ namespace ark::es2panda::checker { class ASChecker : public Checker { public: // NOLINTNEXTLINE(readability-redundant-member-init) - explicit ASChecker(util::DiagnosticEngine &diagnosticEngine, [[maybe_unused]] ArenaAllocator *allocator) - : Checker(diagnosticEngine) + explicit ASChecker([[maybe_unused]] ThreadSafeArenaAllocator *allocator, util::DiagnosticEngine &diagnosticEngine, + [[maybe_unused]] ArenaAllocator *programAllocator) + : Checker(allocator, diagnosticEngine) { } diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 0f45d111230087bf9b67c43a94a752eaa24e628f..50390d0209c6e53a92617c2fbd8685d7c4a81a3a 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -19,16 +19,23 @@ #include "generated/diagnostic.h" #include "checker/types/globalTypesHolder.h" #include "checker/types/ets/etsTupleType.h" +#include "checker/types/gradualType.h" #include "evaluate/scopedDebugInfoPlugin.h" #include "types/signature.h" #include "compiler/lowering/ets/setJumpTarget.h" +#include "compiler/lowering/util.h" #include "checker/types/ets/etsAsyncFuncReturnType.h" +#include "types/ts/nullType.h" +#include "types/type.h" +#include "types/typeFlag.h" #include "util/es2pandaMacros.h" #include namespace ark::es2panda::checker { +static Type *GetAppropriatePreferredType(Type *originalType, std::function const &predicate); + ETSChecker *ETSAnalyzer::GetETSChecker() const { return static_cast(GetChecker()); @@ -160,6 +167,7 @@ checker::Type *ETSAnalyzer::Check(ir::ClassStaticBlock *st) const static void HandleNativeAndAsyncMethods(ETSChecker *checker, ir::MethodDefinition *node) { auto *scriptFunc = node->Function(); + ES2PANDA_ASSERT(scriptFunc != nullptr); if (node->IsNative() && !node->IsConstructor() && !scriptFunc->IsSetter()) { if (scriptFunc->ReturnTypeAnnotation() == nullptr) { checker->LogError(diagnostic::NATIVE_WITHOUT_RETURN, {}, scriptFunc->Start()); @@ -303,6 +311,79 @@ void ETSAnalyzer::CheckMethodModifiers(ir::MethodDefinition *node) const } } +static void CheckDuplicationInOverloadDeclaration(ETSChecker *const checker, ir::OverloadDeclaration *const node) +{ + auto overloadedNameSet = ArenaSet(checker->ProgramAllocator()->Adapter()); + for (ir::Expression *const overloadedName : node->OverloadedList()) { + bool isQualifiedName = true; + std::function getFullOverloadedName = + [&isQualifiedName, &getFullOverloadedName](ir::Expression *const expr) -> std::string { + if (!isQualifiedName) { + return ""; + } + if (expr->IsIdentifier()) { + return expr->AsIdentifier()->Name().Mutf8(); + } + if (expr->IsMemberExpression()) { + return getFullOverloadedName(expr->AsMemberExpression()->Object()) + "." + + getFullOverloadedName(expr->AsMemberExpression()->Property()); + } + isQualifiedName = false; + return ""; + }; + std::string fullOverloadedName = getFullOverloadedName(overloadedName); + if (!isQualifiedName) { + continue; + } + if (overloadedNameSet.find(fullOverloadedName) != overloadedNameSet.end()) { + checker->LogError(diagnostic::DUPLICATE_OVERLOADED_NAME, overloadedName->Start()); + continue; + } + overloadedNameSet.insert(fullOverloadedName); + } +} + +checker::Type *ETSAnalyzer::Check(ir::OverloadDeclaration *node) const +{ + ETSChecker *checker = GetETSChecker(); + ES2PANDA_ASSERT(node != nullptr); + ES2PANDA_ASSERT(node->Key()); + + CheckDuplicationInOverloadDeclaration(checker, node); + + if (!node->Key()->IsIdentifier()) { + checker->LogError(diagnostic::OVERLOAD_NAME_MUST_BE_IDENTIFIER, {}, node->Key()->Start()); + } + + if (node->IsConstructorOverloadDeclaration()) { + ES2PANDA_ASSERT(node->Parent()->IsClassDefinition()); + checker->CheckConstructorOverloadDeclaration(checker, node); + return nullptr; + } + + if (node->IsFunctionOverloadDeclaration()) { + ES2PANDA_ASSERT( + node->Parent()->IsClassDefinition() && + (compiler::HasGlobalClassParent(node) || node->Parent()->AsClassDefinition()->IsNamespaceTransformed())); + checker->CheckFunctionOverloadDeclaration(checker, node); + return nullptr; + } + + if (node->IsClassMethodOverloadDeclaration()) { + ES2PANDA_ASSERT(node->Parent()->IsClassDefinition()); + checker->CheckClassMethodOverloadDeclaration(checker, node); + return nullptr; + } + + if (node->IsInterfaceMethodOverloadDeclaration()) { + ES2PANDA_ASSERT(node->Parent()->Parent()->IsTSInterfaceDeclaration()); + checker->CheckInterfaceMethodOverloadDeclaration(checker, node); + return nullptr; + } + + return nullptr; +} + checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::Property *expr) const { ETSChecker *checker = GetETSChecker(); @@ -316,7 +397,11 @@ checker::Type *ETSAnalyzer::Check(ir::SpreadElement *expr) const } ETSChecker *checker = GetETSChecker(); - Type *exprType = expr->AsSpreadElement()->Argument()->Check(checker); + if (expr->PreferredType() != nullptr) { + expr->Argument()->SetPreferredType(expr->PreferredType()); + } + auto type = expr->AsSpreadElement()->Argument()->Check(checker); + Type *exprType = type->MaybeBaseTypeOfGradualType(); if (exprType->IsETSResizableArrayType()) { return expr->SetTsType(exprType->AsETSObjectType()->TypeArguments().front()); @@ -330,7 +415,7 @@ checker::Type *ETSAnalyzer::Check(ir::SpreadElement *expr) const return checker->InvalidateType(expr); } - checker::Type *const elementType = exprType->IsETSTupleType() ? exprType : checker->GetElementTypeOfArray(exprType); + checker::Type *const elementType = exprType->IsETSTupleType() ? type : checker->GetElementTypeOfArray(exprType); return expr->SetTsType(elementType); } @@ -377,7 +462,11 @@ checker::Type *ETSAnalyzer::Check(ir::ETSFunctionType *node) const checker->CheckFunctionSignatureAnnotations(node->Params(), node->TypeParams(), node->ReturnType()); auto *signatureInfo = checker->ComposeSignatureInfo(node->TypeParams(), node->Params()); - auto *returnType = checker->ComposeReturnType(node->ReturnType(), node->IsAsync()); + ES2PANDA_ASSERT(signatureInfo != nullptr); + auto *returnType = node->IsExtensionFunction() && node->ReturnType()->IsTSThisType() + ? signatureInfo->params.front()->TsType() + : checker->ComposeReturnType(node->ReturnType(), node->IsAsync()); + auto *const signature = checker->CreateSignature(signatureInfo, returnType, node->Flags(), node->IsExtensionFunction()); if (signature == nullptr) { // #23134 @@ -396,7 +485,8 @@ static bool CheckArrayElementType(ETSChecker *checker, T *newArrayInstanceExpr) ES2PANDA_ASSERT(checker != nullptr); ES2PANDA_ASSERT(newArrayInstanceExpr != nullptr); - checker::Type *elementType = newArrayInstanceExpr->TypeReference()->GetType(checker); + checker::Type *elementType = newArrayInstanceExpr->TypeReference()->GetType(checker)->MaybeBaseTypeOfGradualType(); + ES2PANDA_ASSERT(elementType != nullptr); if (elementType->IsETSPrimitiveType()) { return true; } @@ -437,17 +527,20 @@ static bool NeedCreateETSResizableArrayType(ETSChecker *checker, Type *type) checker::Type *ETSAnalyzer::Check(ir::ETSNewArrayInstanceExpression *expr) const { + if (expr->TsType() != nullptr) { + return expr->TsType(); + } + ETSChecker *checker = GetETSChecker(); auto *elementType = expr->TypeReference()->GetType(checker); checker->ValidateArrayIndex(expr->Dimension(), true); CheckArrayElementType(checker, expr); - GetUnionPreferredType(expr, expr->GetPreferredType()); - - auto *preferredType = expr->GetPreferredType(); + auto *preferredType = GetAppropriatePreferredType( + expr->PreferredType(), [](Type *tp) -> bool { return tp->IsETSArrayType() || tp->IsETSResizableArrayType(); }); - if (NeedCreateETSResizableArrayType(checker, expr->GetPreferredType()) || + if (NeedCreateETSResizableArrayType(checker, expr->PreferredType()) || preferredType == nullptr || preferredType->IsETSResizableArrayType()) { expr->SetTsType(checker->CreateETSResizableArrayType(elementType)); } else { @@ -462,7 +555,8 @@ checker::Type *ETSAnalyzer::Check(ir::ETSNewArrayInstanceExpression *expr) const static checker::Type *CheckInstantiatedNewType(ETSChecker *checker, ir::ETSNewClassInstanceExpression *expr) { - checker::Type *calleeType = expr->GetTypeRef()->Check(checker); + checker::Type *res = expr->GetTypeRef()->Check(checker); + auto calleeType = res->MaybeBaseTypeOfGradualType(); if (calleeType->IsTypeError()) { return checker->InvalidateType(expr->GetTypeRef()); } @@ -493,7 +587,7 @@ static checker::Type *CheckInstantiatedNewType(ETSChecker *checker, ir::ETSNewCl return checker->GlobalTypeError(); } - return calleeType; + return res; } checker::Type *ETSAnalyzer::Check(ir::ETSNewClassInstanceExpression *expr) const @@ -506,38 +600,29 @@ checker::Type *ETSAnalyzer::Check(ir::ETSNewClassInstanceExpression *expr) const if (calleeType->IsTypeError()) { return checker->InvalidateType(expr); } - auto *calleeObj = calleeType->AsETSObjectType(); - expr->SetTsType(calleeObj); + auto *calleeObj = calleeType->MaybeBaseTypeOfGradualType()->AsETSObjectType(); + expr->SetTsType(calleeType); - if (calleeType->IsETSDynamicType() && !calleeType->AsETSDynamicType()->HasDecl()) { - auto lang = calleeType->AsETSDynamicType()->Language(); - expr->SetSignature(checker->ResolveDynamicCallExpression(expr->GetTypeRef(), expr->GetArguments(), lang, true)); - } else { - auto *signature = checker->ResolveConstructExpression(calleeObj, expr->GetArguments(), expr->Start()); + auto *signature = checker->ResolveConstructExpression(calleeObj, expr->GetArguments(), expr->Start()); - if (signature == nullptr) { - return checker->InvalidateType(expr); - } + if (signature == nullptr) { + return checker->InvalidateType(expr); + } - checker->CheckObjectLiteralArguments(signature, expr->GetArguments()); + checker->CheckObjectLiteralArguments(signature, expr->GetArguments()); - checker->ValidateSignatureAccessibility(calleeObj, signature, expr->Start()); + checker->ValidateSignatureAccessibility(calleeObj, signature, expr->Start()); - if (calleeType->IsETSDynamicType()) { - ES2PANDA_ASSERT(signature->Function()->IsDynamic()); - auto lang = calleeType->AsETSDynamicType()->Language(); - expr->SetSignature( - checker->ResolveDynamicCallExpression(expr->GetTypeRef(), signature->Params(), lang, true)); - } else { - expr->SetSignature(signature); - } - } + expr->SetSignature(signature); return expr->TsType(); } checker::Type *ETSAnalyzer::Check(ir::ETSNewMultiDimArrayInstanceExpression *expr) const { + if (expr->TsType() != nullptr) { + return expr->TsType(); + } ETSChecker *checker = GetETSChecker(); CheckArrayElementType(checker, expr); @@ -548,11 +633,10 @@ checker::Type *ETSAnalyzer::Check(ir::ETSNewMultiDimArrayInstanceExpression *exp checker->ValidateArrayIndex(dim, true); fixedArrayType = checker->CreateETSArrayType(fixedArrayType); } - GetUnionPreferredType(expr, expr->GetPreferredType()); + auto *preferredType = GetAppropriatePreferredType( + expr->PreferredType(), [](Type *tp) -> bool { return tp->IsETSArrayType() || tp->IsETSResizableArrayType(); }); - auto *preferredType = expr->GetPreferredType(); - if (NeedCreateETSResizableArrayType(checker, expr->GetPreferredType()) || - preferredType->IsETSResizableArrayType()) { + if (NeedCreateETSResizableArrayType(checker, preferredType) || preferredType->IsETSResizableArrayType()) { expr->SetTsType(checker->CreateETSMultiDimResizableArrayType(elementType, expr->Dimensions().size())); } else { expr->SetTsType(fixedArrayType); @@ -623,11 +707,7 @@ checker::Type *ETSAnalyzer::Check(ir::ETSNonNullishTypeNode *node) const return node->TsType(); } ETSChecker *checker = GetETSChecker(); - checker::Type *originalType = node->GetTypeNode()->Check(checker); - if (!originalType->IsETSTypeParameter()) { - checker->LogError(diagnostic::ILLEGAL_NON_NULLISH_TYPE, {}, node->GetTypeNode()->Start()); - } - return node->SetTsType(checker->GetNonNullishType(originalType)); + return node->SetTsType(checker->GetNonNullishType(node->GetTypeNode()->Check(checker))); } checker::Type *ETSAnalyzer::Check([[maybe_unused]] ir::ETSNullType *node) const @@ -665,11 +745,6 @@ checker::Type *ETSAnalyzer::Check(ir::ETSKeyofType *node) const // compile methods for EXPRESSIONS in alphabetical order -checker::Type *ETSAnalyzer::GetPreferredType(ir::ArrayExpression *expr) const -{ - return expr->preferredType_; -} - static void AddSpreadElementTypes(ETSChecker *checker, ir::SpreadElement *const element, ArenaVector> &elementTypes) { @@ -680,7 +755,7 @@ static void AddSpreadElementTypes(ETSChecker *checker, ir::SpreadElement *const return; } - Type *const spreadArgumentType = element->Argument()->TsType(); + Type *const spreadArgumentType = element->Argument()->TsType()->MaybeBaseTypeOfGradualType(); if (spreadArgumentType->IsETSTupleType()) { for (Type *type : spreadArgumentType->AsETSTupleType()->GetTupleTypesList()) { @@ -709,31 +784,30 @@ static ArenaVector> GetElementTypes(ETSCheck { ArenaVector> elementTypes(checker->ProgramAllocator()->Adapter()); - for (std::size_t idx = 0; idx < expr->Elements().size(); ++idx) { + auto *const exprPreferredType = expr->PreferredType(); + auto *const exprTupleType = exprPreferredType->IsETSTupleType() ? exprPreferredType->AsETSTupleType() : nullptr; + checker::Type *elemPreferredType = + exprPreferredType->IsETSTupleType() ? nullptr : checker->GetElementTypeOfArray(exprPreferredType); + + for (std::size_t idx = 0U; idx < expr->Elements().size(); ++idx) { ir::Expression *const element = expr->Elements()[idx]; if (element->IsSpreadElement()) { + element->SetPreferredType(exprPreferredType); AddSpreadElementTypes(checker, element->AsSpreadElement(), elementTypes); continue; } - auto *const exprPreferredType = expr->GetPreferredType(); - - if (expr->GetPreferredType()->IsETSTupleType() && - idx < expr->GetPreferredType()->AsETSTupleType()->GetTupleSize() && - !ValidArrayExprSizeForTupleSize(checker, exprPreferredType->AsETSTupleType()->GetTypeAtIndex(idx), - element)) { - elementTypes.emplace_back(checker->GlobalTypeError(), element); - continue; - } - - if (element->IsArrayExpression() || element->IsObjectExpression()) { - auto *const targetPreferredType = exprPreferredType->IsETSTupleType() - ? exprPreferredType->AsETSTupleType()->GetTypeAtIndex(idx) - : checker->GetElementTypeOfArray(exprPreferredType); - ETSChecker::SetPreferredTypeIfPossible(element, targetPreferredType); + if (exprTupleType != nullptr && exprPreferredType->IsETSTupleType()) { + if (idx >= exprTupleType->GetTupleSize() || + !ValidArrayExprSizeForTupleSize(checker, exprTupleType->GetTypeAtIndex(idx), element)) { + elementTypes.emplace_back(element->SetTsType(checker->GlobalTypeError()), element); + continue; + } + elemPreferredType = exprTupleType->GetTypeAtIndex(idx); } + element->SetPreferredType(elemPreferredType); elementTypes.emplace_back(element->Check(checker), element); } @@ -843,36 +917,43 @@ static bool CheckArrayExpressionElements(ETSChecker *checker, ir::ArrayExpressio [](auto &pair) { return pair.first->IsTypeError(); }); for (std::size_t idx = 0; idx < arrayExprElementTypes.size(); ++idx) { - allElementsAssignable &= CheckElement(checker, arrayExpr->GetPreferredType(), arrayExprElementTypes, idx); + allElementsAssignable &= CheckElement(checker, arrayExpr->PreferredType(), arrayExprElementTypes, idx); } return allElementsAssignable; } -void ETSAnalyzer::GetUnionPreferredType(ir::Expression *expr, Type *originalType) const +static Type *GetAppropriatePreferredType(Type *originalType, std::function const &predicate) { - if (originalType == nullptr || !originalType->IsETSUnionType()) { - return; + if (originalType == nullptr) { + return nullptr; + } + + while (originalType->IsETSTypeAliasType()) { + if (predicate(originalType)) { + return originalType; + } + originalType = originalType->AsETSTypeAliasType()->GetTargetType(); + } + + if (predicate(originalType)) { + return originalType; + } + + if (!originalType->IsETSUnionType()) { + return nullptr; } - checker::Type *preferredType = nullptr; + + Type *preferredType = nullptr; for (auto &type : originalType->AsETSUnionType()->ConstituentTypes()) { - if (type->IsETSArrayType() || type->IsETSTupleType() || type->IsETSResizableArrayType()) { + if (predicate(type)) { if (preferredType != nullptr) { - preferredType = nullptr; - break; + return nullptr; // ambiguity } preferredType = type; } } - if (expr->IsArrayExpression()) { - expr->AsArrayExpression()->SetPreferredType(preferredType); - } else if (expr->IsETSNewArrayInstanceExpression()) { - expr->AsETSNewArrayInstanceExpression()->SetPreferredType(preferredType); - } else if (expr->IsETSNewMultiDimArrayInstanceExpression()) { - expr->AsETSNewMultiDimArrayInstanceExpression()->SetPreferredType(preferredType); - } else { - ES2PANDA_UNREACHABLE(); - } + return preferredType; } checker::Type *ETSAnalyzer::Check(ir::ArrayExpression *expr) const @@ -882,39 +963,36 @@ checker::Type *ETSAnalyzer::Check(ir::ArrayExpression *expr) const return expr->TsType(); } - if (expr->GetPreferredType() != nullptr) { - if (expr->GetPreferredType()->IsETSTypeAliasType()) { - expr->SetPreferredType(expr->GetPreferredType()->AsETSTypeAliasType()->GetTargetType()); - } - - if (expr->GetPreferredType()->IsETSUnionType()) { - GetUnionPreferredType(expr, expr->GetPreferredType()); - } - } + auto *preferredType = GetAppropriatePreferredType(expr->PreferredType(), [](Type *tp) -> bool { + return tp->IsETSArrayType() || tp->IsETSResizableArrayType() || tp->IsETSTupleType(); + }); - if (!IsArrayExpressionValidInitializerForType(checker, expr->GetPreferredType())) { - checker->LogError(diagnostic::UNEXPECTED_ARRAY, {expr->GetPreferredType()}, expr->Start()); + if (!IsArrayExpressionValidInitializerForType(checker, preferredType)) { + checker->LogError(diagnostic::UNEXPECTED_ARRAY, {expr->PreferredType()}, expr->Start()); return checker->InvalidateType(expr); } if (!expr->Elements().empty()) { - if (expr->GetPreferredType() == nullptr || expr->GetPreferredType() == checker->GlobalETSObjectType()) { - expr->SetPreferredType(InferPreferredTypeFromElements(checker, expr)); + if (preferredType == nullptr || preferredType == checker->GlobalETSObjectType()) { + preferredType = InferPreferredTypeFromElements(checker, expr); } - if (!CheckArrayExpressionElements(checker, expr)) { + expr->SetPreferredType(preferredType); + + if (!ValidArrayExprSizeForTupleSize(checker, preferredType, expr) || + !CheckArrayExpressionElements(checker, expr)) { return checker->InvalidateType(expr); } } - if (expr->GetPreferredType() == nullptr) { + if (preferredType == nullptr) { return checker->TypeError(expr, diagnostic::UNRESOLVABLE_ARRAY, expr->Start()); } - expr->SetTsType(expr->GetPreferredType()); - if (!expr->GetPreferredType()->IsETSResizableArrayType() && !expr->TsType()->IsETSTupleType()) { - ES2PANDA_ASSERT(expr->TsType()->IsETSArrayType()); - const auto *const arrayType = expr->TsType()->AsETSArrayType(); + expr->SetTsType(preferredType); + if (!preferredType->IsETSResizableArrayType() && !preferredType->IsETSTupleType()) { + ES2PANDA_ASSERT(preferredType->IsETSArrayType()); + const auto *const arrayType = preferredType->AsETSArrayType(); checker->CreateBuiltinArraySignature(arrayType, arrayType->Rank()); } return expr->TsType(); @@ -1051,7 +1129,10 @@ checker::Type *ETSAnalyzer::GetSmartType(ir::AssignmentExpression *expr, checker if (expr->Left()->IsIdentifier() && expr->Target() != nullptr) { // Now try to define the actual type of Identifier so that smart cast can be used in further checker // processing - smartType = checker->ResolveSmartType(rightType, leftType); + auto const value = expr->Right()->IsNumberLiteral() + ? std::make_optional(expr->Right()->AsNumberLiteral()->Number().GetDouble()) + : std::nullopt; + smartType = checker->ResolveSmartType(rightType, leftType, value); auto const *const variable = expr->Target(); // Add/Remove/Modify smart cast for identifier @@ -1072,6 +1153,33 @@ checker::Type *ETSAnalyzer::GetSmartType(ir::AssignmentExpression *expr, checker return smartType; } +static bool IsMethodDefinition(const ir::Expression *const expression) +{ + return expression->IsMemberExpression() && expression->AsMemberExpression()->Property() != nullptr && + expression->AsMemberExpression()->Property()->Variable() != nullptr && + expression->AsMemberExpression()->Property()->Variable()->Declaration() != nullptr && + expression->AsMemberExpression()->Property()->Variable()->Declaration()->Node()->IsMethodDefinition(); +} + +static bool IsInvalidMethodAssignment(const ir::AssignmentExpression *const expr, ETSChecker *checker) +{ + auto left = expr->Left(); + if (IsMethodDefinition(left)) { + { + auto methodDefinition = + left->AsMemberExpression()->Property()->Variable()->Declaration()->Node()->AsMethodDefinition(); + if (!methodDefinition->IsSetter() && + std::none_of(methodDefinition->Overloads().cbegin(), methodDefinition->Overloads().cend(), + [](const auto *overload) { return overload->IsSetter(); })) { + checker->LogError(diagnostic::METHOD_ASSIGNMENT, expr->Left()->Start()); + return true; + } + } + } + + return false; +} + checker::Type *ETSAnalyzer::Check(ir::AssignmentExpression *const expr) const { if (expr->TsType() != nullptr) { @@ -1086,7 +1194,7 @@ checker::Type *ETSAnalyzer::Check(ir::AssignmentExpression *const expr) const const auto leftType = expr->Left()->Check(checker); - if (IsInvalidArrayMemberAssignment(expr, checker)) { + if (IsInvalidArrayMemberAssignment(expr, checker) || IsInvalidMethodAssignment(expr, checker)) { expr->SetTsType(checker->GlobalTypeError()); return expr->TsType(); } @@ -1117,7 +1225,10 @@ checker::Type *ETSAnalyzer::Check(ir::AssignmentExpression *const expr) const CastPossibleTupleOnRHS(checker, expr); checker::Type *smartType = rightType; - if (!leftType->IsTypeError()) { + auto isLazyImportObject = + leftType->MaybeBaseTypeOfGradualType()->IsETSObjectType() && + leftType->MaybeBaseTypeOfGradualType()->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::LAZY_IMPORT_OBJECT); + if (!leftType->IsTypeError() && !isLazyImportObject) { if (const auto ctx = checker::AssignmentContext(checker->Relation(), relationNode, rightType, leftType, expr->Right()->Start(), {{diagnostic::INVALID_ASSIGNMNENT, {rightType, leftType}}}); @@ -1135,22 +1246,22 @@ static checker::Type *HandleSubstitution(ETSChecker *checker, ir::AssignmentExpr leftType->IsETSTupleType() || leftType->IsETSUnionType(); if (expr->Right()->IsArrayExpression() && possibleInferredTypeOfArray) { checker->ModifyPreferredType(expr->Right()->AsArrayExpression(), leftType); - } - - if (expr->Right()->IsETSNewArrayInstanceExpression()) { - expr->Right()->AsETSNewArrayInstanceExpression()->SetPreferredType(leftType); - } - - if (expr->Right()->IsETSNewMultiDimArrayInstanceExpression()) { - expr->Right()->AsETSNewMultiDimArrayInstanceExpression()->SetPreferredType(leftType); - } - - if (expr->Right()->IsObjectExpression()) { + } else if (expr->Right()->IsArrowFunctionExpression() && + (leftType->IsETSArrowType() || leftType->IsETSUnionType())) { + if (auto *preferredType = GetAppropriatePreferredType(leftType, [](Type *tp) { return tp->IsETSArrowType(); }); + preferredType != nullptr) { + checker->TryInferTypeForLambdaTypeAlias(expr->Right()->AsArrowFunctionExpression(), + preferredType->AsETSFunctionType()); + } + } else if (expr->Right()->IsObjectExpression()) { + if (leftType->IsETSObjectType() && leftType->IsGradualType() && + (leftType->HasTypeFlag(TypeFlag::READONLY) || + leftType->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::REQUIRED))) { + checker->LogError(diagnostic::DYMANIC_INIT_WITH_OBJEXPR, {leftType}, expr->Right()->Start()); + } expr->Right()->AsObjectExpression()->SetPreferredType(leftType); - } - - if (expr->Right()->IsArrowFunctionExpression() && (leftType->IsETSArrowType() || leftType->IsETSUnionType())) { - expr->Right()->AsArrowFunctionExpression()->SetPreferredType(leftType); + } else { + expr->Right()->SetPreferredType(leftType); } return expr->Right()->Check(checker); @@ -1177,10 +1288,7 @@ std::tuple ETSAnalyzer::CheckAssignmentExprOperatorTyp case lexer::TokenType::PUNCTUATOR_PLUS_EQUAL: { std::tie(std::ignore, expr->operationType_) = checker->CheckBinaryOperator( expr->Left(), expr->Right(), expr, expr->OperatorType(), expr->Start(), true); - - auto unboxedLeft = checker->MaybeUnboxInRelation(leftType); - sourceType = unboxedLeft == nullptr ? leftType : unboxedLeft; - + sourceType = leftType; relationNode = expr; break; } @@ -1291,10 +1399,10 @@ checker::Type *ETSAnalyzer::Check(ir::BinaryExpression *expr) const } } - checker::Type *newTsType {nullptr}; - std::tie(newTsType, expr->operationType_) = + auto [newTsType, operationType] = checker->CheckBinaryOperator(expr->Left(), expr->Right(), expr, expr->OperatorType(), expr->Start()); - expr->SetTsType(newTsType); + expr->SetTsType(checker->MaybeBoxType(newTsType)); + expr->SetOperationType(checker->MaybeBoxType(operationType)); checker->Context().CheckBinarySmartCastCondition(expr); @@ -1334,6 +1442,18 @@ static bool LambdaIsField(ir::CallExpression *expr) return me->PropVar() != nullptr; } +static bool OverloadDeclaration(ir::Expression *expr) +{ + while (expr->IsMemberExpression()) { + expr = expr->AsMemberExpression()->Property(); + } + + if (expr->IsIdentifier() && expr->AsIdentifier()->Variable() != nullptr) { + return expr->AsIdentifier()->Variable()->HasFlag(varbinder::VariableFlags::OVERLOAD); + } + return false; +} + checker::Signature *ETSAnalyzer::ResolveSignature(ETSChecker *checker, ir::CallExpression *expr, checker::Type *calleeType) const { @@ -1347,6 +1467,10 @@ checker::Signature *ETSAnalyzer::ResolveSignature(ETSChecker *checker, ir::CallE return checker->ResolveCallExpressionAndTrailingLambda(checker->GetOverloadSigContainer(), expr, expr->Start()); } + if (calleeType->IsETSFunctionType() && OverloadDeclaration(expr->Callee())) { + return checker->FirstMatchSignatures(expr, calleeType); + } + if (calleeType->IsETSExtensionFuncHelperType()) { auto *signature = ResolveCallForETSExtensionFuncHelperType(calleeType->AsETSExtensionFuncHelperType(), checker, expr); @@ -1374,7 +1498,7 @@ checker::Signature *ETSAnalyzer::ResolveSignature(ETSChecker *checker, ir::CallE static ETSObjectType *GetCallExpressionCalleeObject(ETSChecker *checker, ir::CallExpression *expr, Type *calleeType) { if (expr->IsETSConstructorCall()) { - return calleeType->AsETSObjectType(); + return calleeType->MaybeBaseTypeOfGradualType()->AsETSObjectType(); } auto callee = expr->Callee(); if (callee->IsMemberExpression()) { @@ -1399,6 +1523,7 @@ Type *ETSAnalyzer::GetReturnType(ir::CallExpression *expr, Type *calleeType) con } Signature *const signature = ResolveSignature(checker, expr, calleeType); + if (signature == nullptr) { return checker->GlobalTypeError(); } @@ -1410,13 +1535,7 @@ Type *ETSAnalyzer::GetReturnType(ir::CallExpression *expr, Type *calleeType) con checker->ValidateSignatureAccessibility(calleeObj, signature, expr->Start()); } - if (calleeType->IsETSMethodType() && signature->Function()->IsDynamic()) { - ES2PANDA_ASSERT(signature->Function()->IsDynamic()); - auto lang = signature->Function()->Language(); - expr->SetSignature(checker->ResolveDynamicCallExpression(expr->Callee(), signature->Params(), lang, false)); - } else { - expr->SetSignature(signature); - } + expr->SetSignature(signature); // #22951: this type should not be encoded as a signature flag if (signature->HasSignatureFlag(SignatureFlags::THIS_RETURN_TYPE)) { @@ -1443,10 +1562,15 @@ static void CheckAbstractCall(ETSChecker *checker, ir::CallExpression *expr) static void CheckCallee(ETSChecker *checker, ir::CallExpression *expr) { checker->CheckNonNullish(expr->Callee()); - if (expr->Callee()->IsMemberExpression() && expr->Callee()->AsMemberExpression()->Object() != nullptr && - expr->Callee()->AsMemberExpression()->Object()->TsType()->IsETSObjectType() && - expr->Callee()->AsMemberExpression()->Object()->TsType()->AsETSObjectType()->HasObjectFlag( - ETSObjectFlags::READONLY)) { + if (!expr->Callee()->IsMemberExpression()) { + return; + } + auto memberExpr = expr->Callee()->AsMemberExpression(); + if (memberExpr->Object() == nullptr) { + return; + } + auto baseType = memberExpr->Object()->TsType()->MaybeBaseTypeOfGradualType(); + if (baseType->IsETSObjectType() && baseType->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::READONLY)) { checker->LogError(diagnostic::READONLY_CALL, {}, expr->Start()); expr->SetTsType(checker->GlobalTypeError()); } @@ -1473,16 +1597,7 @@ static checker::SavedCheckerContext ReconstructOwnerClassContext(ETSChecker *che checker::Type *ETSAnalyzer::GetCallExpressionReturnType(ir::CallExpression *expr, checker::Type *calleeType) const { ETSChecker *checker = GetETSChecker(); - checker::Type *returnType = nullptr; - if (UNLIKELY(calleeType->IsETSDynamicType() && !calleeType->AsETSDynamicType()->HasDecl())) { - // Trailing lambda for js function call is not supported, check the correctness of `foo() {}` - checker->EnsureValidCurlyBrace(expr); - auto lang = calleeType->AsETSDynamicType()->Language(); - expr->SetSignature(checker->ResolveDynamicCallExpression(expr->Callee(), expr->Arguments(), lang, false)); - returnType = expr->Signature()->ReturnType(); - } else { - returnType = GetReturnType(expr, calleeType); - } + checker::Type *returnType = GetReturnType(expr, calleeType); if (returnType->IsTypeError()) { return checker->GlobalTypeError(); @@ -1500,6 +1615,10 @@ checker::Type *ETSAnalyzer::GetCallExpressionReturnType(ir::CallExpression *expr return returnType; } + if (!signature->HasFunction()) { + return checker->GlobalTypeError(); + } + auto owner = const_cast(util::Helpers::GetContainingObjectType(signature->Function())); SavedCheckerContext savedCtx(ReconstructOwnerClassContext(checker, owner)); @@ -1547,6 +1666,12 @@ checker::Type *ETSAnalyzer::Check(ir::CallExpression *expr) const CheckCallee(checker, expr); + checker::TypeStackElement tse(checker, expr, {{diagnostic::CYCLIC_CALLEE, {}}}, expr->Start()); + if (tse.HasTypeError()) { + expr->SetTsType(checker->GlobalTypeError()); + return checker->GlobalTypeError(); + } + checker::Type *const returnType = GetCallExpressionReturnType(expr, calleeType); expr->SetTsType(returnType); if (returnType->IsTypeError()) { @@ -1554,7 +1679,7 @@ checker::Type *ETSAnalyzer::Check(ir::CallExpression *expr) const } if (calleeType->IsETSArrowType()) { expr->SetUncheckedType(checker->GuaranteedTypeForUncheckedCast( - checker->GlobalETSNullishObjectType(), checker->MaybeBoxType(expr->Signature()->ReturnType()))); + checker->GlobalETSAnyType(), checker->MaybeBoxType(expr->Signature()->ReturnType()))); } else { expr->SetUncheckedType(checker->GuaranteedTypeForUncheckedCallReturn(expr->Signature())); } @@ -1574,6 +1699,45 @@ checker::Type *ETSAnalyzer::Check(ir::CallExpression *expr) const return expr->TsType(); } +static bool IsNumericType(ETSChecker *checker, Type *type) +{ + return checker->Relation()->IsSupertypeOf(checker->GetGlobalTypesHolder()->GlobalNumericBuiltinType(), type); +} + +static Type *BiggerNumericType(ETSChecker *checker, Type *t1, Type *t2) +{ + ES2PANDA_ASSERT(IsNumericType(checker, t1)); + ES2PANDA_ASSERT(IsNumericType(checker, t2)); + + auto *rel = checker->Relation(); + + if (rel->IsSupertypeOf(checker->GlobalDoubleBuiltinType(), t1) || + rel->IsSupertypeOf(checker->GlobalDoubleBuiltinType(), t2)) { + return checker->GlobalDoubleBuiltinType(); + } + if (rel->IsSupertypeOf(checker->GlobalFloatBuiltinType(), t1) || + rel->IsSupertypeOf(checker->GlobalFloatBuiltinType(), t2)) { + return checker->GlobalFloatBuiltinType(); + } + if (rel->IsSupertypeOf(checker->GlobalLongBuiltinType(), t1) || + rel->IsSupertypeOf(checker->GlobalLongBuiltinType(), t2)) { + return checker->GlobalLongBuiltinType(); + } + if (rel->IsSupertypeOf(checker->GlobalIntBuiltinType(), t1) || + rel->IsSupertypeOf(checker->GlobalIntBuiltinType(), t2)) { + return checker->GlobalIntBuiltinType(); + } + if (rel->IsSupertypeOf(checker->GlobalShortBuiltinType(), t1) || + rel->IsSupertypeOf(checker->GlobalShortBuiltinType(), t2)) { + return checker->GlobalShortBuiltinType(); + } + if (rel->IsSupertypeOf(checker->GlobalByteBuiltinType(), t1) || + rel->IsSupertypeOf(checker->GlobalByteBuiltinType(), t2)) { + return checker->GlobalByteBuiltinType(); + } + ES2PANDA_UNREACHABLE(); +} + checker::Type *ETSAnalyzer::Check(ir::ConditionalExpression *expr) const { if (expr->TsType() != nullptr) { @@ -1610,22 +1774,11 @@ checker::Type *ETSAnalyzer::Check(ir::ConditionalExpression *expr) const checker->Context().CombineSmartCasts(consequentSmartCasts); if (checker->IsTypeIdenticalTo(consequentType, alternateType)) { - expr->SetTsType(checker->GetNonConstantType(consequentType)); + expr->SetTsType(consequentType); + } else if (IsNumericType(GetETSChecker(), consequentType) && IsNumericType(GetETSChecker(), alternateType)) { + expr->SetTsType(BiggerNumericType(GetETSChecker(), consequentType, alternateType)); } else { - // If possible and required update number literal type to the proper value (identical to left-side type) - if (alternate->IsNumberLiteral() && - checker->AdjustNumberLiteralType(alternate->AsNumberLiteral(), alternateType, consequentType)) { - expr->SetTsType(consequentType); - } else if (consequent->IsNumberLiteral() && - checker->AdjustNumberLiteralType(consequent->AsNumberLiteral(), consequentType, alternateType)) { - expr->SetTsType(alternateType); - } else { - expr->SetTsType(checker->CreateETSUnionType({consequentType, alternateType})); - if (expr->TsType()->IsETSReferenceType()) { - checker->MaybeBoxExpression(expr->Consequent()); - checker->MaybeBoxExpression(expr->Alternate()); - } - } + expr->SetTsType(checker->CreateETSUnionType({consequentType, alternateType})); } // Restore smart casts to initial state. @@ -1638,7 +1791,12 @@ checker::Type *ETSAnalyzer::Check(ir::ConditionalExpression *expr) const static Type *TransformTypeForMethodReference(ETSChecker *checker, ir::Expression *const use, Type *type) { ES2PANDA_ASSERT(use->IsIdentifier() || use->IsMemberExpression()); - if (!type->IsETSMethodType()) { + if (!type->IsETSMethodType() || + (use->IsMemberExpression() && use->AsMemberExpression()->PropVar() != nullptr && + use->AsMemberExpression()->PropVar()->HasFlag(varbinder::VariableFlags::DYNAMIC))) { + if (use->Parent()->IsCallExpression() && type->IsETSObjectType() && use->IsMemberExpression()) { + checker->ValidateCallExpressionIdentifier(use->AsMemberExpression()->Property()->AsIdentifier(), type); + } return type; } auto const getUseSite = [use]() { @@ -1652,17 +1810,33 @@ static Type *TransformTypeForMethodReference(ETSChecker *checker, ir::Expression if (expr->Parent()->IsCallExpression() && expr->Parent()->AsCallExpression()->Callee() == expr) { return type; // type is actually used as method } + if (expr->Parent()->IsOverloadDeclaration()) { + return type; // Don't trans overloaded name to arrow type. + } - if (type->AsETSFunctionType()->CallSignatures().at(0)->HasSignatureFlag(SignatureFlags::PRIVATE)) { + auto *const functionType = type->AsETSFunctionType(); + auto &signatures = functionType->CallSignatures(); + + if (signatures.at(0)->HasSignatureFlag(SignatureFlags::PRIVATE)) { checker->LogError(diagnostic::PRIVATE_METHOD_AS_VALUE, getUseSite()); return checker->GlobalTypeError(); } - if (type->AsETSFunctionType()->CallSignatures().size() > 1) { + auto it = signatures.begin(); + while (it != signatures.end()) { + if ((*it)->HasSignatureFlag(SignatureFlags::ABSTRACT) && + !(*it)->Owner()->GetDeclNode()->IsTSInterfaceDeclaration()) { + it = signatures.erase(it); + } else { + ++it; + } + } + + if (signatures.size() > 1U) { checker->LogError(diagnostic::OVERLOADED_METHOD_AS_VALUE, getUseSite()); return checker->GlobalTypeError(); } - return type->AsETSFunctionType()->MethodToArrow(checker); + return functionType->MethodToArrow(checker); } checker::Type *ETSAnalyzer::Check(ir::Identifier *expr) const @@ -1675,6 +1849,9 @@ checker::Type *ETSAnalyzer::Check(ir::Identifier *expr) const auto *identType = TransformTypeForMethodReference(checker, expr, checker->ResolveIdentifier(expr)); + if (expr->TsType() != nullptr && expr->TsType()->IsTypeError()) { + return expr->TsType(); + } ES2PANDA_ASSERT(expr->Variable() != nullptr); if (expr->Parent() == nullptr || !expr->Parent()->IsAssignmentExpression() || expr != expr->Parent()->AsAssignmentExpression()->Left()) { @@ -1685,6 +1862,7 @@ checker::Type *ETSAnalyzer::Check(ir::Identifier *expr) const } expr->SetTsType(identType); + ES2PANDA_ASSERT(identType != nullptr); if (!identType->IsTypeError()) { checker->Context().CheckIdentifierSmartCastCondition(expr); } @@ -1692,7 +1870,7 @@ checker::Type *ETSAnalyzer::Check(ir::Identifier *expr) const } std::pair SearchReExportsType(ETSObjectType *baseType, ir::MemberExpression *expr, - util::StringView &aliasName, ETSChecker *checker) + util::StringView const &aliasName, ETSChecker *checker) { std::pair ret {}; @@ -1733,9 +1911,13 @@ checker::Type *ETSAnalyzer::ResolveMemberExpressionByBaseType(ETSChecker *checke return checker->InvalidateType(expr); } + if (baseType->IsGradualType()) { + return ResolveMemberExpressionByBaseType(checker, baseType->AsGradualType()->GetBaseType(), expr); + } + if (baseType->IsETSArrayType()) { if (expr->Property()->AsIdentifier()->Name().Is("length")) { - return expr->AdjustType(checker, checker->GlobalIntType()); + return expr->AdjustType(checker, checker->GlobalIntBuiltinType()); } return expr->SetAndAdjustType(checker, checker->GlobalETSObjectType()); @@ -1771,8 +1953,7 @@ checker::Type *ETSAnalyzer::ResolveMemberExpressionByBaseType(ETSChecker *checke "toFloat", "toDouble", }}; - auto method = expr->Property()->AsIdentifier()->Name().Utf8(); - auto res = std::find(castMethods.begin(), castMethods.end(), method); + auto res = std::find(castMethods.begin(), castMethods.end(), expr->Property()->AsIdentifier()->Name().Utf8()); if (res != castMethods.end()) { auto type = checker->MaybeBoxType(baseType); expr->SetAstNodeFlags(ir::AstNodeFlags::TMP_CONVERT_PRIMITIVE_CAST_METHOD_CALL); @@ -1796,6 +1977,7 @@ checker::Type *ETSAnalyzer::Check(ir::MemberExpression *expr) const auto *baseType = checker->GetNonConstantType(checker->GetApparentType(expr->Object()->Check(checker))); // Note: don't use possible smart cast to null-like types. // Such situation should be correctly resolved in the subsequent lowering. + ES2PANDA_ASSERT(baseType != nullptr); if (baseType->DefinitelyETSNullish() && expr->Object()->IsIdentifier()) { baseType = expr->Object()->AsIdentifier()->Variable()->TsType(); } @@ -1813,7 +1995,7 @@ checker::Type *ETSAnalyzer::Check(ir::MemberExpression *expr) const } if (!checker->CheckNonNullish(expr->Object())) { auto *invalidType = checker->HasStatus(checker::CheckerStatus::IN_EXTENSION_ACCESSOR_CHECK) - ? checker->GlobalETSNullishType() + ? checker->GlobalETSUnionUndefinedNull() : checker->InvalidateType(expr); return invalidType; } @@ -1825,11 +2007,6 @@ checker::Type *ETSAnalyzer::Check(ir::MemberExpression *expr) const return ResolveMemberExpressionByBaseType(checker, baseType, expr); } -checker::Type *ETSAnalyzer::PreferredType(ir::ObjectExpression *expr) const -{ - return expr->preferredType_; -} - checker::Type *ETSAnalyzer::CheckDynamic(ir::ObjectExpression *expr) const { ETSChecker *checker = GetETSChecker(); @@ -1847,7 +2024,7 @@ checker::Type *ETSAnalyzer::CheckDynamic(ir::ObjectExpression *expr) const static bool ValidatePreferredType(ETSChecker *checker, ir::ObjectExpression *expr) { - auto preferredType = expr->PreferredType(); + auto preferredType = expr->PreferredType()->MaybeBaseTypeOfGradualType(); if (preferredType == nullptr) { checker->LogError(diagnostic::CLASS_COMPOSITE_UNKNOWN_TYPE, {}, expr->Start()); return false; @@ -1874,8 +2051,16 @@ static void SetTypeforRecordProperties(const ir::ObjectExpression *expr, checker auto *const valueType = typeArguments[1]; // Record type arguments for (auto *const recordProperty : recordProperties) { - auto *const recordPropertyExpr = recordProperty->AsProperty()->Value(); - ETSChecker::SetPreferredTypeIfPossible(recordPropertyExpr, valueType); + ir::Expression *recordPropertyExpr = nullptr; + if (recordProperty->IsProperty()) { + recordPropertyExpr = recordProperty->AsProperty()->Value(); + } else if (recordProperty->IsSpreadElement()) { + recordPropertyExpr = recordProperty->AsSpreadElement()->Argument(); + } else { + ES2PANDA_UNREACHABLE(); + } + + recordPropertyExpr->SetPreferredType(valueType); recordPropertyExpr->Check(checker); } } @@ -2060,12 +2245,12 @@ static bool AreAllRequiredInterfacePropertiesSatisfied(ir::ObjectExpression *exp auto allProperties = interfaceType->GetAllProperties(); // Create a set of property names provided in the object literal - std::unordered_set literalProperties; + std::unordered_set literalProperties; for (ir::Expression *propExpr : expr->Properties()) { if (propExpr->IsProperty()) { ir::Expression *key = propExpr->AsProperty()->Key(); if (auto optPname = GetPropertyNameFromKey(key); optPname.has_value()) { - literalProperties.insert(std::string(optPname.value().Utf8())); + literalProperties.insert(optPname.value().Utf8()); } } } @@ -2086,7 +2271,6 @@ static bool AreAllRequiredInterfacePropertiesSatisfied(ir::ObjectExpression *exp // Check that all required interface properties are satisfied for (auto *property : allProperties) { - std::string propName(property->Name().Utf8()); auto *propertyType = checker->GetTypeOfVariable(property); // Skip method types that aren't getters/setters (they make interface incompatible anyway) @@ -2097,7 +2281,7 @@ static bool AreAllRequiredInterfacePropertiesSatisfied(ir::ObjectExpression *exp } } // Check if this property is provided in the literal - bool isInLiteral = literalProperties.find(propName) != literalProperties.end(); + bool isInLiteral = literalProperties.find(property->Name().Utf8()) != literalProperties.end(); if (!isInLiteral) { // Property not in literal - check if it's optional or has default value bool isOptional = IsPropertyOptional(property, propertyType); @@ -2162,8 +2346,9 @@ checker::ETSObjectType *ResolveUnionObjectTypeForObjectLiteral(ETSChecker *check std::vector candidateObjectTypes; // Phase 1: Gather all ETSObjectTypes from the union for (auto *constituentType : unionType->ConstituentTypes()) { - if (constituentType->IsETSObjectType()) { - candidateObjectTypes.push_back(constituentType->AsETSObjectType()); + auto type = constituentType->MaybeBaseTypeOfGradualType(); + if (type->IsETSObjectType()) { + candidateObjectTypes.push_back(type->AsETSObjectType()); } } @@ -2198,7 +2383,11 @@ checker::ETSObjectType *ResolveUnionObjectTypeForObjectLiteral(ETSChecker *check static checker::ETSObjectType *ResolveObjectTypeFromPreferredType(ETSChecker *checker, ir::ObjectExpression *expr) { // Assume not null, checked by caller in Check() - checker::Type *preferredType = expr->PreferredType(); + checker::Type *preferredType = expr->PreferredType()->MaybeBaseTypeOfGradualType(); + + if (preferredType->IsETSAsyncFuncReturnType()) { + preferredType = preferredType->AsETSAsyncFuncReturnType()->GetPromiseTypeArg(); + } if (preferredType->IsETSUnionType()) { return ResolveUnionObjectTypeForObjectLiteral(checker, expr, preferredType->AsETSUnionType()); @@ -2246,16 +2435,11 @@ checker::Type *ETSAnalyzer::Check(ir::ObjectExpression *expr) const return expr->TsType(); } - if (!expr->PreferredType()->IsETSUnionType() && !expr->PreferredType()->IsETSDynamicType() && - !ValidatePreferredType(checker, expr)) { + if (!expr->PreferredType()->IsETSUnionType() && !ValidatePreferredType(checker, expr)) { expr->SetTsType(checker->GlobalTypeError()); return expr->TsType(); } - if (expr->PreferredType()->IsETSDynamicType() && !expr->PreferredType()->AsETSDynamicType()->HasDecl()) { - return CheckDynamic(expr); - } - checker::ETSObjectType *objType = ResolveObjectTypeFromPreferredType(checker, expr); if (objType == nullptr) { @@ -2333,7 +2517,8 @@ void ETSAnalyzer::CheckObjectExprProps(const ir::ObjectExpression *expr, return; } - ETSChecker::SetPreferredTypeIfPossible(value, propType); + value->SetPreferredType(propType); + propExpr->SetTsType(propType); key->SetTsType(propType); value->SetTsType(value->Check(checker)); @@ -2385,6 +2570,11 @@ checker::Type *ETSAnalyzer::Check(ir::SuperExpression *expr) const checker::Type *ETSAnalyzer::Check(ir::TemplateLiteral *expr) const { ETSChecker *checker = GetETSChecker(); + + for (auto *it : expr->Expressions()) { + it->Check(checker); + } + if (expr->TsType() != nullptr) { return expr->TsType(); } @@ -2395,10 +2585,6 @@ checker::Type *ETSAnalyzer::Check(ir::TemplateLiteral *expr) const return expr->TsType(); } - for (auto *it : expr->Expressions()) { - it->Check(checker); - } - for (auto *it : expr->Quasis()) { it->Check(checker); } @@ -2493,6 +2679,7 @@ static checker::Type *ComputeTypeOfType(ETSChecker *checker, checker::Type *argT { checker::Type *ret = nullptr; ArenaVector types(checker->ProgramAllocator()->Adapter()); + ES2PANDA_ASSERT(argType != nullptr); if (argType->IsETSUnionType()) { for (auto *it : argType->AsETSUnionType()->ConstituentTypes()) { checker::Type *elType = ComputeTypeOfType(checker, it); @@ -2527,16 +2714,14 @@ checker::Type *ETSAnalyzer::Check(ir::UnaryExpression *expr) const auto argType = expr->argument_->Check(checker); const auto isCondExpr = expr->OperatorType() == lexer::TokenType::PUNCTUATOR_EXCLAMATION_MARK; - checker::Type *operandType = checker->ApplyUnaryOperatorPromotion(argType, true, true, isCondExpr); - auto unboxedOperandType = - isCondExpr ? checker->MaybeUnboxConditionalInRelation(argType) : checker->MaybeUnboxInRelation(argType); - + checker::Type *operandType = checker->ApplyUnaryOperatorPromotion(expr->argument_, argType, isCondExpr); if (argType != nullptr && argType->IsETSBigIntType() && argType->HasTypeFlag(checker::TypeFlag::BIGINT_LITERAL)) { switch (expr->OperatorType()) { case lexer::TokenType::PUNCTUATOR_MINUS: { checker::Type *type = checker->CreateETSBigIntLiteralType(argType->AsETSBigIntType()->GetValue()); // We do not need this const anymore as we are negating the bigint object in runtime + ES2PANDA_ASSERT(type != nullptr); type->RemoveTypeFlag(checker::TypeFlag::CONSTANT); expr->argument_->SetTsType(type); expr->SetTsType(type); @@ -2562,11 +2747,6 @@ checker::Type *ETSAnalyzer::Check(ir::UnaryExpression *expr) const } } - if ((argType != nullptr) && argType->IsETSObjectType() && (unboxedOperandType != nullptr) && - unboxedOperandType->IsETSPrimitiveType()) { - expr->Argument()->AddBoxingUnboxingFlags(checker->GetUnboxingFlag(unboxedOperandType)); - } - SetTsTypeForUnaryExpression(checker, expr, operandType); checker->Context().CheckUnarySmartCastCondition(expr); @@ -2618,11 +2798,6 @@ checker::Type *ETSAnalyzer::Check(ir::UpdateExpression *expr) const return expr->SetTsType(checker->GlobalTypeError()); } - if (operandType->IsETSObjectType()) { - expr->Argument()->AddBoxingUnboxingFlags(checker->GetUnboxingFlag(unboxedType) | - checker->GetBoxingFlag(unboxedType)); - } - return expr->SetTsType(operandType); } @@ -2638,7 +2813,9 @@ checker::Type *ETSAnalyzer::Check(ir::BooleanLiteral *expr) const { ETSChecker *checker = GetETSChecker(); if (expr->TsType() == nullptr) { - expr->SetTsType(checker->CreateETSBooleanType(expr->Value())); + auto type = checker->GlobalETSBooleanBuiltinType()->Clone(GetChecker()); + type->AddTypeFlag(TypeFlag::CONSTANT); + expr->SetTsType(type); } return expr->TsType(); } @@ -2647,7 +2824,9 @@ checker::Type *ETSAnalyzer::Check(ir::CharLiteral *expr) const { ETSChecker *checker = GetETSChecker(); if (expr->TsType() == nullptr) { - expr->SetTsType(checker->ProgramAllocator()->New(expr->Char())); + auto type = checker->GlobalCharBuiltinType()->Clone(GetChecker()); + type->AddTypeFlag(TypeFlag::CONSTANT); + expr->SetTsType(type); } return expr->TsType(); } @@ -2661,26 +2840,66 @@ checker::Type *ETSAnalyzer::Check(ir::NullLiteral *expr) const return expr->TsType(); } -checker::Type *ETSAnalyzer::Check(ir::NumberLiteral *expr) const +static bool CheckIfLiteralValueIsAppropriate(ETSChecker *checker, Type *type, ir::NumberLiteral *expr) { - ETSChecker *checker = GetETSChecker(); - if (expr->Number().IsInt()) { - expr->SetTsType(checker->CreateIntType(expr->Number().GetInt())); - return expr->TsType(); + auto number = expr->Number(); + auto relation = checker->Relation(); + if (relation->IsSupertypeOf(checker->GetGlobalTypesHolder()->GlobalIntegralBuiltinType(), type)) { + if (number.IsReal()) { + return false; + } + auto val = number.GetValueAndCastTo(); + if (relation->IsIdenticalTo(type, checker->GlobalByteBuiltinType())) { + return val >= std::numeric_limits::min() && val <= std::numeric_limits::max(); + } + if (relation->IsIdenticalTo(type, checker->GlobalShortBuiltinType())) { + return val >= std::numeric_limits::min() && val <= std::numeric_limits::max(); + } + if (relation->IsIdenticalTo(type, checker->GlobalIntBuiltinType())) { + return val >= std::numeric_limits::min() && val <= std::numeric_limits::max(); + } + } else if (relation->IsIdenticalTo(type, checker->GlobalCharBuiltinType())) { + auto val = number.GetValueAndCastTo(); + return !number.IsReal() && val >= std::numeric_limits::min() && + val <= std::numeric_limits::max(); + } else if (number.IsDouble()) { + return relation->IsIdenticalTo(checker->GlobalDoubleBuiltinType(), type); } + return true; +} - if (expr->Number().IsLong()) { - expr->SetTsType(checker->CreateLongType(expr->Number().GetLong())); +checker::Type *ETSAnalyzer::Check(ir::NumberLiteral *expr) const +{ + if (expr->TsType() != nullptr) { return expr->TsType(); } - if (expr->Number().IsFloat()) { - expr->SetTsType(checker->CreateFloatType(expr->Number().GetFloat())); - return expr->TsType(); + ETSChecker *checker = GetETSChecker(); + Type *type; + + if (auto *preferredType = + GetAppropriatePreferredType(expr->PreferredType(), [&](Type *tp) { return checker->CheckIfNumeric(tp); }); + preferredType != nullptr && !expr->IsFolded() && + CheckIfLiteralValueIsAppropriate(checker, preferredType, expr)) { + type = preferredType->Clone(checker); + } else if (expr->Number().IsInt()) { + type = checker->GlobalIntBuiltinType()->Clone(checker); + } else if (expr->Number().IsLong()) { + type = checker->GlobalLongBuiltinType()->Clone(checker); + } else if (expr->Number().IsFloat()) { + type = checker->GlobalFloatBuiltinType()->Clone(checker); + } else if (expr->Number().IsDouble()) { + type = checker->GlobalDoubleBuiltinType()->Clone(checker); + } else if (expr->Number().IsShort()) { + type = checker->GlobalShortBuiltinType()->Clone(checker); + } else if (expr->Number().IsByte()) { + type = checker->GlobalByteBuiltinType()->Clone(checker); + } else { + return checker->GlobalTypeError(); } - expr->SetTsType(checker->CreateDoubleType(expr->Number().GetDouble())); - return expr->TsType(); + type->AddTypeFlag(TypeFlag::CONSTANT); + return expr->SetTsType(type); } checker::Type *ETSAnalyzer::Check(ir::StringLiteral *expr) const @@ -2692,6 +2911,25 @@ checker::Type *ETSAnalyzer::Check(ir::StringLiteral *expr) const return expr->TsType(); } +checker::Type *ETSAnalyzer::Check(ir::ETSIntrinsicNode *node) const +{ + ETSChecker *checker = GetETSChecker(); + for (auto *arg : node->Arguments()) { + arg->Check(checker); + } + // Note (daizihan): #27074, make it more scalable when IntrinsicNodeType is extended. + if (node->Type() == ir::IntrinsicNodeType::TYPE_REFERENCE) { + auto type = checker->GlobalBuiltinClassType()->Clone(checker); + // Since std.core.Class initialize() is instance method, need to remove the variable flag. + auto newVar = type->Variable()->AsLocalVariable()->Copy(checker->Allocator(), type->Variable()->Declaration()); + newVar->RemoveFlag(varbinder::VariableFlags::CLASS_OR_INTERFACE); + type->SetVariable(newVar); + return node->SetTsType(type); + } + ES2PANDA_UNREACHABLE(); + return checker->GlobalTypeError(); +} + checker::Type *ETSAnalyzer::Check(ir::ImportDeclaration *st) const { ETSChecker *checker = GetETSChecker(); @@ -2753,10 +2991,9 @@ checker::Type *ETSAnalyzer::Check(ir::BlockStatement *st) const stmt->Check(checker); // NOTE! Processing of trailing blocks was moved here so that smart casts could be applied correctly - if (auto const tb = st->trailingBlocks_.find(stmt); tb != st->trailingBlocks_.end()) { - auto *const trailingBlock = tb->second; + if (auto *const trailingBlock = st->SearchStatementInTrailingBlock(stmt); trailingBlock != nullptr) { trailingBlock->Check(checker); - st->Statements().emplace(std::next(st->Statements().begin() + idx), trailingBlock); + st->AddStatement(idx, trailingBlock); ++idx; } } @@ -2845,6 +3082,21 @@ checker::Type *ETSAnalyzer::Check(ir::AnnotationDeclaration *st) const return ReturnTypeForStatement(st); } +static void ProcessRequiredFields(ArenaUnorderedMap &fieldMap, + ir::AnnotationUsage *st, ETSChecker *checker) +{ + for (const auto &entry : fieldMap) { + if (entry.second->Value() == nullptr) { + checker->LogError(diagnostic::ANNOT_FIELD_NO_VAL, {entry.first}, st->Start()); + continue; + } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + auto *clone = entry.second->Clone(checker->Allocator(), st); + st->AddProperty(clone); + clone->Check(checker); + } +} + checker::Type *ETSAnalyzer::Check(ir::AnnotationUsage *st) const { if (st->Expr()->TsType() != nullptr) { @@ -2865,6 +3117,7 @@ checker::Type *ETSAnalyzer::Check(ir::AnnotationUsage *st) const ArenaUnorderedMap fieldMap {checker->ProgramAllocator()->Adapter()}; for (auto *it : annoDecl->Properties()) { auto *field = it->AsClassProperty(); + ES2PANDA_ASSERT(field->Id() != nullptr); fieldMap.insert(std::make_pair(field->Id()->Name(), field)); } @@ -2873,7 +3126,7 @@ checker::Type *ETSAnalyzer::Check(ir::AnnotationUsage *st) const return ReturnTypeForStatement(st); } - if (st->Properties().size() == 1 && + if (st->Properties().size() == 1 && st->Properties().at(0)->AsClassProperty()->Id() != nullptr && st->Properties().at(0)->AsClassProperty()->Id()->Name() == compiler::Signatures::ANNOTATION_KEY_VALUE) { checker->CheckSinglePropertyAnnotation(st, annoDecl); fieldMap.clear(); @@ -2881,7 +3134,7 @@ checker::Type *ETSAnalyzer::Check(ir::AnnotationUsage *st) const checker->CheckMultiplePropertiesAnnotation(st, st->GetBaseName()->Name(), fieldMap); } - checker->ProcessRequiredFields(fieldMap, st, checker); + ProcessRequiredFields(fieldMap, st, checker); return ReturnTypeForStatement(st); } @@ -2943,7 +3196,7 @@ static bool ValidateAndProcessIteratorType(ETSChecker *checker, Type *elemType, relation->SetNode(ident); if (auto ctx = checker::AssignmentContext(checker->Relation(), ident, elemType, iterType, ident->Start(), std::nullopt, TypeRelationFlag::NO_THROW); - !ctx.IsAssignable()) { + !ctx.IsAssignable() && !relation->IsLegalBoxedPrimitiveConversion(iterType, elemType)) { checker->LogError(diagnostic::ITERATOR_ELEMENT_TYPE_MISMATCH, {elemType, iterType}, st->Start()); return false; } @@ -2969,23 +3222,23 @@ checker::Type *ETSAnalyzer::Check(ir::ForOfStatement *const st) const // NOTE: Smart casts are not processed correctly within the loops now, thus clear them at this point. auto [smartCasts, clearFlag] = checker->Context().EnterLoop(*st, std::nullopt); - checker::Type *const exprType = st->Right()->Check(checker); + checker::Type *const exprType = st->Right()->Check(checker)->MaybeBaseTypeOfGradualType(); if (exprType == nullptr) { checker->LogError(diagnostic::FOROF_CANT_INFER_SOURCE, {}, st->Right()->Start()); return checker->GlobalTypeError(); } - checker::Type *elemType = nullptr; + checker::Type *elemType = checker->GlobalTypeError(); if (exprType->IsETSStringType()) { - elemType = checker->GetGlobalTypesHolder()->GlobalCharType(); + elemType = checker->GlobalBuiltinETSStringType(); } else if (exprType->IsETSArrayType() || exprType->IsETSResizableArrayType()) { elemType = checker->GetElementTypeOfArray(exprType); } else if (exprType->IsETSObjectType() || exprType->IsETSUnionType() || exprType->IsETSTypeParameter()) { elemType = st->CheckIteratorMethod(checker); } - if (elemType == nullptr) { + if (elemType == checker->GlobalTypeError()) { checker->LogError(diagnostic::FOROF_SOURCE_NONITERABLE, {}, st->Right()->Start()); return checker->GlobalTypeError(); } @@ -3092,7 +3345,8 @@ static bool CheckIsValidReturnTypeAnnotation(ir::ReturnStatement *st, ir::Script ir::TypeNode *returnTypeAnnotation, ETSChecker *checker) { // check valid `this` type as return type - if (containingFunc->GetPreferredReturnType() != nullptr || !returnTypeAnnotation->IsTSThisType()) { + if (containingFunc->GetPreferredReturnType() != nullptr || + (returnTypeAnnotation != nullptr && !returnTypeAnnotation->IsTSThisType())) { return true; } @@ -3134,40 +3388,30 @@ bool ETSAnalyzer::CheckInferredFunctionReturnType(ir::ReturnStatement *st, ir::S // Case when function's return type is defined explicitly: if (st->argument_ == nullptr) { - if (!funcReturnType->IsETSVoidType() && funcReturnType != checker->GlobalVoidType() && - !funcReturnType->IsETSAsyncFuncReturnType()) { + ES2PANDA_ASSERT(funcReturnType != nullptr); + if (!funcReturnType->MaybeBaseTypeOfGradualType()->IsETSVoidType() && + funcReturnType != checker->GlobalVoidType() && + !funcReturnType->MaybeBaseTypeOfGradualType()->IsETSAsyncFuncReturnType()) { checker->LogError(diagnostic::RETURN_WITHOUT_VALUE, {}, st->Start()); return false; } funcReturnType = checker->GlobalVoidType(); } else { const auto name = containingFunc->Scope()->InternalName().Mutf8(); - if (!CheckArgumentVoidType(funcReturnType, checker, name, st)) { + if (!CheckArgumentVoidType(funcReturnType->MaybeBaseTypeOfGradualType(), checker, name, st)) { return false; } - if (st->argument_->IsObjectExpression()) { - st->argument_->AsObjectExpression()->SetPreferredType(funcReturnType); - } if (st->argument_->IsMemberExpression()) { checker->SetArrayPreferredTypeForNestedMemberExpressions(st->argument_->AsMemberExpression(), funcReturnType); - } - - if (st->argument_->IsArrayExpression()) { - st->argument_->AsArrayExpression()->SetPreferredType(funcReturnType); - } - - if (st->argument_->IsETSNewArrayInstanceExpression()) { - st->argument_->AsETSNewArrayInstanceExpression()->SetPreferredType(funcReturnType); - } - - if (st->argument_->IsETSNewMultiDimArrayInstanceExpression()) { - st->argument_->AsETSNewMultiDimArrayInstanceExpression()->SetPreferredType(funcReturnType); + } else { + st->argument_->SetPreferredType(funcReturnType); } checker::Type *argumentType = st->argument_->Check(checker); - return CheckReturnType(checker, funcReturnType, argumentType, st->argument_, containingFunc); + return CheckReturnType(checker, funcReturnType->MaybeBaseTypeOfGradualType(), argumentType, st->argument_, + containingFunc); } return true; } @@ -3189,13 +3433,14 @@ checker::Type *ETSAnalyzer::GetFunctionReturnType(ir::ReturnStatement *st, ir::S } else { // Case when function's return type should be inferred from return statement(s): if (containingFunc->Signature()->HasSignatureFlag(checker::SignatureFlags::NEED_RETURN_TYPE)) { - InferReturnType(checker, containingFunc, funcReturnType, - st->argument_); // This removes the NEED_RETURN_TYPE flag, so only the first return - // statement going to land here... + funcReturnType = InferReturnType(checker, containingFunc, + st->argument_); // This removes the NEED_RETURN_TYPE flag, so only the + // first return statement going to land here... } else { // All subsequent return statements: - ProcessReturnStatements(checker, containingFunc, funcReturnType, st, - st->argument_); // and the remaining return statements will get processed here. + funcReturnType = + ProcessReturnStatements(checker, containingFunc, st, + st->argument_); // and the remaining return statements will get processed here. } } @@ -3249,9 +3494,8 @@ checker::Type *ETSAnalyzer::Check(ir::SwitchStatement *st) const checker::TypeRelationFlag::NONE); auto *comparedExprType = checker->CheckSwitchDiscriminant(st->Discriminant()); - auto unboxedDiscType = (st->Discriminant()->GetBoxingUnboxingFlags() & ir::BoxingUnboxingFlags::UNBOXING_FLAG) != 0U - ? checker->MaybeUnboxInRelation(comparedExprType) - : comparedExprType; + // may have no meaning to unbox comparedExprType + auto unboxedDiscType = checker->MaybeUnboxType(comparedExprType); SmartCastArray smartCasts = checker->Context().CloneSmartCasts(); bool hasDefaultCase = false; @@ -3384,7 +3628,11 @@ checker::Type *ETSAnalyzer::Check(ir::VariableDeclarator *st) const // NOTE: T_S and K_o_t_l_i_n don't act in such way, but we can try - why not? :) auto *smartType = variableType; if (auto *const initType = st->Init() != nullptr ? st->Init()->TsType() : nullptr; initType != nullptr) { - smartType = checker->ResolveSmartType(initType, variableType); + auto const value = st->Init()->IsNumberLiteral() + ? std::make_optional(st->Init()->AsNumberLiteral()->Number().GetDouble()) + : std::nullopt; + + smartType = checker->ResolveSmartType(initType, variableType, value); // Set smart type for identifier if it differs from annotated type // Top-level and captured variables are not processed here! if (!checker->Relation()->IsIdenticalTo(variableType, smartType)) { @@ -3457,39 +3705,30 @@ checker::Type *ETSAnalyzer::Check(ir::TSAsExpression *expr) const checker->CheckAnnotations(expr->TypeAnnotation()->Annotations()); auto *const targetType = expr->TypeAnnotation()->AsTypeNode()->GetType(checker); + ES2PANDA_ASSERT(targetType != nullptr); if (targetType->IsTypeError()) { return checker->InvalidateType(expr); } - ETSChecker::SetPreferredTypeIfPossible(expr->Expr(), targetType); + expr->Expr()->SetPreferredType(targetType); auto const sourceType = expr->Expr()->Check(checker); if (sourceType->IsTypeError()) { return checker->InvalidateType(expr); } - // NOTE(vpukhov): #20510 lowering - if (targetType->IsETSPrimitiveType() && sourceType->IsETSReferenceType()) { - auto *const boxedTargetType = checker->MaybeBoxInRelation(targetType); - if (!checker->Relation()->IsIdenticalTo(sourceType, boxedTargetType)) { - expr->Expr()->AddAstNodeFlags(ir::AstNodeFlags::CHECKCAST); - } - } - if (sourceType->DefinitelyETSNullish() && !targetType->PossiblyETSNullish()) { - return checker->TypeError(expr, diagnostic::NULLISH_CAST_TO_NONNULLISH, expr->Start()); + return expr->SetTsType(checker->TypeError(expr, diagnostic::NULLISH_CAST_TO_NONNULLISH, expr->Start())); } const checker::CastingContext ctx( - checker->Relation(), diagnostic::INVALID_CAST, {sourceType, targetType}, + checker->Relation(), + sourceType->IsBuiltinNumeric() && targetType->IsBuiltinNumeric() ? diagnostic::IMPROPER_NUMERIC_CAST + : diagnostic::INVALID_CAST, + // CC-OFFNXT(G.FMT.03-CPP) project code style + {sourceType, targetType}, checker::CastingContext::ConstructorData {expr->Expr(), sourceType, targetType, expr->Expr()->Start()}); - if (sourceType->IsETSDynamicType() && targetType->IsLambdaObject()) { - // NOTE: itrubachev. change targetType to created lambdaobject type. - // Now targetType is not changed, only construct signature is added to it - checker->BuildLambdaObjectClass(targetType->AsETSObjectType(), - expr->TypeAnnotation()->AsETSFunctionType()->ReturnType()); - } expr->isUncheckedCast_ = ctx.UncheckedCast(); // Make sure the array type symbol gets created for the assembler to be able to emit checkcast. @@ -3500,12 +3739,10 @@ checker::Type *ETSAnalyzer::Check(ir::TSAsExpression *expr) const } if (targetType == checker->GetGlobalTypesHolder()->GlobalETSNeverType()) { - return checker->TypeError(expr, diagnostic::CAST_TO_NEVER, expr->Start()); + return expr->SetTsType(checker->TypeError(expr, diagnostic::CAST_TO_NEVER, expr->Start())); } - checker->ComputeApparentType(targetType); - expr->SetTsType(targetType); - return expr->TsType(); + return expr->SetTsType(targetType); } checker::Type *ETSAnalyzer::Check(ir::TSEnumDeclaration *st) const @@ -3528,13 +3765,14 @@ checker::Type *ETSAnalyzer::Check(ir::TSInterfaceDeclaration *st) const return st->SetTsType(stmtType); } - auto *interfaceType = stmtType->AsETSObjectType(); + auto *interfaceType = stmtType->IsGradualType() ? stmtType->AsGradualType()->GetBaseType()->AsETSObjectType() + : stmtType->AsETSObjectType(); checker->CheckInterfaceAnnotations(st); interfaceType->SetSuperType(checker->GlobalETSObjectType()); checker->CheckInvokeMethodsLegitimacy(interfaceType); - st->SetTsType(interfaceType); + st->SetTsType(stmtType); checker::ScopeContext scopeCtx(checker, st->Scope()); auto savedContext = checker::SavedCheckerContext(checker, checker::CheckerStatus::IN_INTERFACE, interfaceType); @@ -3573,10 +3811,62 @@ checker::Type *ETSAnalyzer::Check(ir::TSNonNullExpression *expr) const return expr->TsType(); } +static varbinder::Variable *FindNameForImportNamespace(ETSChecker *checker, util::StringView &searchName, + ETSObjectType *baseType) +{ + /* This function try to find name1.name2, name1.A in file file1.ets, + * ./file1.ets: + * import * as name1 from "./file2" + * + * ./file2.ets: + * import * as name2 from "./file3" + * import {A} from "./file3" + * export {name2} + * export {A} + * + * ./file3.ets + * export class A{} + * + * 1. Find in file2->program->ast->scope first + * 2. Find in varbinder->selectiveExportAliasMultimap second + * if both found, return variable + */ + auto declNode = baseType->GetDeclNode(); + if (!declNode->IsIdentifier()) { + return nullptr; + } + if (declNode->Parent() == nullptr || declNode->Parent()->Parent() == nullptr) { + return nullptr; + } + auto importDeclNode = declNode->Parent()->Parent(); + if (!importDeclNode->IsETSImportDeclaration()) { + return nullptr; + } + + auto importDecl = importDeclNode->AsETSImportDeclaration(); + + parser::Program *program = checker->SelectEntryOrExternalProgram( + static_cast(checker->VarBinder()), importDecl->ImportMetadata().resolvedSource); + + auto &bindings = program->Ast()->Scope()->Bindings(); + + if (auto result = bindings.find(searchName); result != bindings.end()) { + auto &sMap = checker->VarBinder() + ->AsETSBinder() + ->GetSelectiveExportAliasMultimap() + .find(importDecl->ImportMetadata().resolvedSource) + ->second; + if (auto it = sMap.find(searchName); it != sMap.end()) { + return result->second; + } + } + return nullptr; +} + checker::Type *ETSAnalyzer::Check(ir::TSQualifiedName *expr) const { ETSChecker *checker = GetETSChecker(); - checker::Type *baseType = expr->Left()->Check(checker); + checker::Type *baseType = expr->Left()->Check(checker)->MaybeBaseTypeOfGradualType(); if (baseType->IsETSObjectType()) { // clang-format off auto searchName = expr->Right()->Name(); @@ -3586,7 +3876,11 @@ checker::Type *ETSAnalyzer::Check(ir::TSQualifiedName *expr) const searchName = expr->Right()->Name(); } varbinder::Variable *prop = - baseType->AsETSObjectType()->GetProperty(searchName, checker::PropertySearchFlags::SEARCH_DECL); + baseType->AsETSObjectType()->GetProperty(searchName, PropertySearchFlags::SEARCH_DECL); + + if (prop == nullptr) { + prop = FindNameForImportNamespace(GetETSChecker(), searchName, baseType->AsETSObjectType()); + } // NOTE(dslynko): in debugger evaluation mode must lazily generate module's properties here. if (prop == nullptr) { checker->LogError(diagnostic::NONEXISTENT_TYPE, {expr->Right()->Name()}, expr->Right()->Start()); @@ -3605,6 +3899,7 @@ checker::Type *ETSAnalyzer::Check(ir::TSQualifiedName *expr) const checker::Type *ETSAnalyzer::Check(ir::TSTypeAliasDeclaration *st) const { ETSChecker *checker = GetETSChecker(); + auto checkerContext = SavedCheckerContext(checker, CheckerStatus::NO_OPTS, checker->Context().ContainingClass()); checker->CheckAnnotations(st->Annotations()); diff --git a/ets2panda/checker/ETSAnalyzer.h b/ets2panda/checker/ETSAnalyzer.h index c9a398b319b807b28c697498308e787f9103af69..c4a0d46ba6757eddae4f3d5212c7247c3a787942 100644 --- a/ets2panda/checker/ETSAnalyzer.h +++ b/ets2panda/checker/ETSAnalyzer.h @@ -36,7 +36,6 @@ public: virtual checker::Type *Check(ir::nodeType *node) const override; // CC-OFF(G.PRE.02,G.PRE.09) name part AST_NODE_REINTERPRET_MAPPING(DECLARE_ETSANALYZER_CHECK_METHOD) #undef DECLARE_ETSANALYZER_CHECK_METHOD - checker::Type *PreferredType(ir::ObjectExpression *expr) const; checker::Type *CheckDynamic(ir::ObjectExpression *expr) const; checker::Type *GetPreferredType(ir::ArrayExpression *expr) const; void GetUnionPreferredType(ir::Expression *expr, Type *originalType) const; diff --git a/ets2panda/checker/ETSAnalyzerHelpers.cpp b/ets2panda/checker/ETSAnalyzerHelpers.cpp index f652f68e788bf04c99f3cf5025e85efc5da534f2..6579897c613af33f1f9ed73e0e43c45279219514 100644 --- a/ets2panda/checker/ETSAnalyzerHelpers.cpp +++ b/ets2panda/checker/ETSAnalyzerHelpers.cpp @@ -57,6 +57,7 @@ void CheckExtensionIsShadowedInCurrentClassOrInterface(checker::ETSChecker *chec const auto *const funcType = methodVariable->TsType()->AsETSFunctionType(); for (auto *funcSignature : funcType->CallSignatures()) { + ES2PANDA_ASSERT(signature != nullptr); signature->SetReturnType(funcSignature->ReturnType()); if (!checker->Relation()->SignatureIsSupertypeOf(signature, funcSignature) && !checker->HasSameAssemblySignature(signature, funcSignature)) { @@ -149,6 +150,7 @@ void CheckExtensionMethod(checker::ETSChecker *checker, ir::ScriptFunction *exte checker::SignatureInfo *originalExtensionSigInfo = checker->ProgramAllocator()->New( extensionFunc->Signature()->GetSignatureInfo(), checker->ProgramAllocator()); + ES2PANDA_ASSERT(originalExtensionSigInfo != nullptr); originalExtensionSigInfo->minArgCount -= 1U; originalExtensionSigInfo->params.erase(originalExtensionSigInfo->params.begin()); checker::Signature *originalExtensionSignature = @@ -220,6 +222,7 @@ void DoBodyTypeChecking(ETSChecker *checker, ir::MethodDefinition *node, ir::Scr if (scriptFunc->ReturnTypeAnnotation() == nullptr) { if (scriptFunc->IsAsyncFunc()) { auto returnType = checker->CreateETSAsyncFuncReturnTypeFromBaseType(scriptFunc->Signature()->ReturnType()); + ES2PANDA_ASSERT(returnType != nullptr); scriptFunc->Signature()->SetReturnType(returnType->PromiseType()); for (auto &returnStatement : scriptFunc->ReturnStatements()) { returnStatement->SetReturnType(checker, returnType); @@ -244,10 +247,11 @@ void ComposeAsyncImplFuncReturnType(ETSChecker *checker, ir::ScriptFunction *scr auto *objectId = checker->ProgramAllocNode(compiler::Signatures::BUILTIN_OBJECT_CLASS, checker->ProgramAllocator()); - checker->VarBinder()->AsETSBinder()->LookupTypeReference(objectId, false); + checker->VarBinder()->AsETSBinder()->LookupTypeReference(objectId); auto *returnType = checker->ProgramAllocNode( checker->ProgramAllocNode(objectId, nullptr, nullptr, checker->ProgramAllocator()), checker->ProgramAllocator()); + ES2PANDA_ASSERT(returnType != nullptr); objectId->SetParent(returnType->Part()); returnType->Part()->SetParent(returnType); returnType->SetTsType(checker->ProgramAllocator()->New(checker->ProgramAllocator(), @@ -306,7 +310,7 @@ static bool HasIteratorInterface(ETSObjectType const *const objectType) void CheckIteratorMethodReturnType(ETSChecker *checker, ir::ScriptFunction *scriptFunc, const lexer::SourcePosition &position, const std::string &methodName) { - const auto *returnType = scriptFunc->Signature()->ReturnType(); + const auto *returnType = scriptFunc->Signature()->ReturnType()->MaybeBaseTypeOfGradualType(); if (returnType == nullptr) { checker->LogError(diagnostic::MISSING_RETURN_TYPE_2, {util::StringView(methodName)}, position); @@ -317,6 +321,7 @@ void CheckIteratorMethodReturnType(ETSChecker *checker, ir::ScriptFunction *scri returnType = checker->GetApparentType(returnType->AsETSTypeParameter()->GetConstraintType()); } + ES2PANDA_ASSERT(returnType != nullptr); if (returnType->IsETSObjectType() && HasIteratorInterface(returnType->AsETSObjectType())) { return; } @@ -420,7 +425,7 @@ checker::Signature *GetMostSpecificSigFromExtensionFuncAndClassMethod(checker::E methodCallSig->GetSignatureInfo()->minArgCount++; auto ¶msVar = methodCallSig->Params(); paramsVar.insert(paramsVar.begin(), dummyReceiverVar); - auto ¶ms = methodCallSig->Function()->Params(); + auto ¶ms = methodCallSig->Function()->ParamsForUpdate(); params.insert(params.begin(), dummyReceiver); if (typeParamsNeeded) { auto &typeParams = methodCallSig->TypeParams(); @@ -436,7 +441,7 @@ checker::Signature *GetMostSpecificSigFromExtensionFuncAndClassMethod(checker::E methodCallSig->GetSignatureInfo()->minArgCount--; auto ¶msVar = methodCallSig->Params(); paramsVar.erase(paramsVar.begin()); - auto ¶ms = methodCallSig->Function()->Params(); + auto ¶ms = methodCallSig->Function()->ParamsForUpdate(); params.erase(params.begin()); if (typeParamsNeeded) { auto &typeParams = methodCallSig->TypeParams(); @@ -509,27 +514,12 @@ ArenaVector GetUnionTypeSignatures(ETSChecker *checker, ch void ProcessExclamationMark(ETSChecker *checker, ir::UnaryExpression *expr, checker::Type *operandType) { - if (checker->IsNullLikeOrVoidExpression(expr->Argument())) { - auto tsType = checker->CreateETSBooleanType(true); - tsType->AddTypeFlag(checker::TypeFlag::CONSTANT); - expr->SetTsType(tsType); - return; - } - - if (operandType == nullptr || !operandType->IsConditionalExprType()) { - checker->LogError(diagnostic::ASSERT_NOT_LOGICAL, {}, expr->Argument()->Start()); + if (operandType == nullptr || operandType->IsTypeError()) { expr->SetTsType(checker->GlobalTypeError()); return; } - auto exprRes = operandType->ResolveConditionExpr(); - if (std::get<0>(exprRes)) { - auto tsType = checker->CreateETSBooleanType(!std::get<1>(exprRes)); - tsType->AddTypeFlag(checker::TypeFlag::CONSTANT); - expr->SetTsType(tsType); - return; - } - expr->SetTsType(checker->GlobalETSBooleanType()); + expr->SetTsType(checker->GlobalETSBooleanBuiltinType()); } void SetTsTypeForUnaryExpression(ETSChecker *checker, ir::UnaryExpression *expr, checker::Type *operandType) @@ -537,29 +527,27 @@ void SetTsTypeForUnaryExpression(ETSChecker *checker, ir::UnaryExpression *expr, switch (expr->OperatorType()) { case lexer::TokenType::PUNCTUATOR_MINUS: case lexer::TokenType::PUNCTUATOR_PLUS: { - if (operandType == nullptr || !operandType->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { + if (operandType == nullptr || !operandType->IsETSObjectType() || + !operandType->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::CONVERTIBLE_TO_NUMERIC)) { checker->LogError(diagnostic::OPERAND_NOT_NUMERIC, {}, expr->Argument()->Start()); expr->SetTsType(checker->GlobalTypeError()); break; } - if (operandType->HasTypeFlag(checker::TypeFlag::CONSTANT) && - expr->OperatorType() == lexer::TokenType::PUNCTUATOR_MINUS) { - expr->SetTsType(checker->NegateNumericType(operandType, expr)); - break; - } - expr->SetTsType(operandType); break; } case lexer::TokenType::PUNCTUATOR_TILDE: { - if (operandType == nullptr || !operandType->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { + if (operandType == nullptr || !operandType->IsETSObjectType() || + !operandType->AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::CONVERTIBLE_TO_NUMERIC)) { checker->LogError(diagnostic::OPERAND_NOT_NUMERIC, {}, expr->Argument()->Start()); expr->SetTsType(checker->GlobalTypeError()); break; } - - expr->Argument()->SetTsType(expr->SetTsType(checker->SelectGlobalIntegerTypeForNumeric(operandType))); + auto exprType = expr->SetTsType(checker->SelectGlobalIntegerTypeForNumeric(operandType)); + if (!expr->Argument()->TsType()->IsETSIntEnumType()) { + expr->Argument()->SetTsType(exprType); + } break; } case lexer::TokenType::PUNCTUATOR_EXCLAMATION_MARK: { @@ -611,14 +599,15 @@ checker::Type *GetIteratorType(ETSChecker *checker, checker::Type *elemType, ir: checker->LogError(diagnostic::ITERATOR_TYPE_ABSENT, {}, left->Start()); return checker->GlobalTypeError(); } - return iterType; + return checker->GetNonConstantType(iterType); } -bool CheckArgumentVoidType(checker::Type *&funcReturnType, ETSChecker *checker, const std::string &name, +bool CheckArgumentVoidType(checker::Type *funcReturnType, ETSChecker *checker, const std::string &name, ir::ReturnStatement *st) { if (name.find(compiler::Signatures::ETS_MAIN_WITH_MANGLE_BEGIN) != std::string::npos) { - if (!funcReturnType->IsETSVoidType() && !funcReturnType->IsIntType()) { + if (!funcReturnType->IsETSVoidType() && + !checker->Relation()->IsSupertypeOf(checker->GlobalIntBuiltinType(), funcReturnType)) { checker->LogError(diagnostic::MAIN_BAD_RETURN, {}, st->Start()); } } @@ -666,15 +655,15 @@ bool CheckReturnType(ETSChecker *checker, checker::Type *funcReturnType, checker return true; } -void InferReturnType(ETSChecker *checker, ir::ScriptFunction *containingFunc, checker::Type *&funcReturnType, - ir::Expression *stArgument) +checker::Type *InferReturnType(ETSChecker *checker, ir::ScriptFunction *containingFunc, ir::Expression *stArgument) { // First (or single) return statement in the function: - funcReturnType = + auto *funcReturnType = stArgument == nullptr ? checker->GlobalVoidType() : checker->GetNonConstantType(stArgument->Check(checker)); + ES2PANDA_ASSERT(funcReturnType != nullptr); if (funcReturnType->IsTypeError()) { containingFunc->Signature()->RemoveSignatureFlag(checker::SignatureFlags::NEED_RETURN_TYPE); - return; + return funcReturnType; } /* @@ -689,6 +678,7 @@ void InferReturnType(ETSChecker *checker, ir::ScriptFunction *containingFunc, ch auto typeAnnotation = arrowFunc->CreateTypeAnnotation(checker); auto *argumentType = arrowFunc->TsType(); + ES2PANDA_ASSERT(typeAnnotation != nullptr); funcReturnType = typeAnnotation->GetType(checker); if (!checker::AssignmentContext(checker->Relation(), arrowFunc, argumentType, funcReturnType, stArgument->Start(), std::nullopt, @@ -696,8 +686,7 @@ void InferReturnType(ETSChecker *checker, ir::ScriptFunction *containingFunc, ch // CC-OFFNXT(G.FMT.02) project code style .IsAssignable()) { checker->LogError(diagnostic::ARROW_TYPE_MISMATCH, {argumentType, funcReturnType}, stArgument->Start()); - funcReturnType = checker->GlobalTypeError(); - return; + return checker->GlobalTypeError(); } } @@ -706,9 +695,11 @@ void InferReturnType(ETSChecker *checker, ir::ScriptFunction *containingFunc, ch containingFunc->Signature()->AddSignatureFlag(checker::SignatureFlags::INFERRED_RETURN_TYPE); checker->VarBinder()->AsETSBinder()->BuildFunctionName(containingFunc); - if (stArgument != nullptr && stArgument->IsObjectExpression()) { - stArgument->AsObjectExpression()->SetPreferredType(funcReturnType); + if (stArgument != nullptr) { + stArgument->SetPreferredType(funcReturnType); } + + return funcReturnType; } bool IsArrayExpressionValidInitializerForType(ETSChecker *checker, const Type *const arrayExprPreferredType) @@ -737,16 +728,16 @@ void CastPossibleTupleOnRHS(ETSChecker *checker, ir::AssignmentExpression *expr) } } -void ProcessReturnStatements(ETSChecker *checker, ir::ScriptFunction *containingFunc, checker::Type *&funcReturnType, - ir::ReturnStatement *st, ir::Expression *stArgument) +checker::Type *ProcessReturnStatements(ETSChecker *checker, ir::ScriptFunction *containingFunc, ir::ReturnStatement *st, + ir::Expression *stArgument) { - funcReturnType = containingFunc->Signature()->ReturnType(); + auto *funcReturnType = containingFunc->Signature()->ReturnType(); if (stArgument == nullptr) { // previous return statement(s) have value if (!funcReturnType->IsETSVoidType() && funcReturnType != checker->GlobalVoidType()) { checker->LogError(diagnostic::MIXED_VOID_NONVOID, {}, st->Start()); - return; + return funcReturnType; } } else { if (stArgument->IsObjectExpression()) { @@ -760,14 +751,15 @@ void ProcessReturnStatements(ETSChecker *checker, ir::ScriptFunction *containing checker::Type *argumentType = checker->GetNonConstantType(stArgument->Check(checker)); // previous return statement(s) don't have any value + ES2PANDA_ASSERT(argumentType != nullptr); if (funcReturnType->IsETSVoidType() && !argumentType->IsETSVoidType()) { checker->LogError(diagnostic::MIXED_VOID_NONVOID, {}, stArgument->Start()); - return; + return funcReturnType; } const auto name = containingFunc->Scope()->InternalName().Mutf8(); if (!CheckArgumentVoidType(funcReturnType, checker, name, st)) { - return; + return funcReturnType; } auto *const relation = checker->Relation(); @@ -780,6 +772,7 @@ void ProcessReturnStatements(ETSChecker *checker, ir::ScriptFunction *containing relation->SetNode(nullptr); relation->SetFlags(checker::TypeRelationFlag::NONE); } + return funcReturnType; } bool CheckReturnTypeNecessity(ir::MethodDefinition *node) @@ -788,6 +781,7 @@ bool CheckReturnTypeNecessity(ir::MethodDefinition *node) auto *scriptFunc = node->Function(); needReturnType &= (node->IsNative() || node->IsDeclare()); needReturnType &= !node->IsConstructor(); + ES2PANDA_ASSERT(scriptFunc != nullptr); needReturnType &= !scriptFunc->IsSetter(); return needReturnType; } @@ -807,11 +801,40 @@ void CheckAllConstPropertyInitialized(checker::ETSChecker *checker, ir::ETSModul continue; } - if (prop->AsClassProperty()->Key()->Variable()->HasFlag(varbinder::VariableFlags::INIT_IN_STATIC_BLOCK) && - !prop->AsClassProperty()->Key()->Variable()->HasFlag(varbinder::VariableFlags::INITIALIZED)) { + auto *classProp = prop->AsClassProperty(); + if (classProp->Key()->Variable() == nullptr) { + continue; + } + + if (classProp->Key()->Variable()->HasFlag(varbinder::VariableFlags::INIT_IN_STATIC_BLOCK) && + !classProp->Key()->Variable()->HasFlag(varbinder::VariableFlags::INITIALIZED)) { checker->LogError(diagnostic::MISSING_INIT_FOR_CONST_PACKAGE_PROP, {}, prop->Start()); } } } +// NOLINTBEGIN(readability-else-after-return) +std::tuple IsConstantTestValue(ir::Expression const *expr) +{ + if (expr->IsNullLiteral() || expr->IsUndefinedLiteral()) { + return {true, false}; + } else if (expr->IsBooleanLiteral()) { + return {true, expr->AsBooleanLiteral()->Value()}; + } else if (expr->IsStringLiteral()) { + return {true, expr->AsStringLiteral()->Str().Length() != 0}; + } else if (expr->IsCharLiteral()) { + return {true, expr->AsCharLiteral()->Char() != 0}; + } else if (expr->IsBigIntLiteral()) { + return {true, expr->AsBigIntLiteral()->Str() != "0"}; + } else if (expr->IsNumberLiteral()) { + auto num = expr->AsNumberLiteral()->Number(); + return {true, !num.IsZero()}; + } else if (expr->TsType()->IsETSEnumType() && expr->TsType()->IsConstantType()) { + // NOTE(gogabr): Should handle enum constants + return {false, false}; + } + return {false, false}; +} +// NOLINTEND(readability-else-after-return) + } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/ETSAnalyzerHelpers.h b/ets2panda/checker/ETSAnalyzerHelpers.h index 979d6413ac63d58a4c73e16aabef6a38c793068f..37ac4ce4f2c8fa2188c44b75e7a5ad116a72b27a 100644 --- a/ets2panda/checker/ETSAnalyzerHelpers.h +++ b/ets2panda/checker/ETSAnalyzerHelpers.h @@ -52,18 +52,20 @@ ArenaVector GetUnionTypeSignatures(ETSChecker *checker, ch void ProcessExclamationMark(ETSChecker *checker, ir::UnaryExpression *expr, checker::Type *operandType); void SetTsTypeForUnaryExpression(ETSChecker *checker, ir::UnaryExpression *expr, checker::Type *operandType); checker::Type *GetIteratorType(ETSChecker *checker, checker::Type *elemType, ir::AstNode *left); -bool CheckArgumentVoidType(checker::Type *&funcReturnType, ETSChecker *checker, const std::string &name, +bool CheckArgumentVoidType(checker::Type *funcReturnType, ETSChecker *checker, const std::string &name, ir::ReturnStatement *st); bool CheckReturnType(ETSChecker *checker, checker::Type *funcReturnType, checker::Type *argumentType, ir::Expression *stArgument, ir::ScriptFunction *containingFunc); -void InferReturnType(ETSChecker *checker, ir::ScriptFunction *containingFunc, checker::Type *&funcReturnType, - ir::Expression *stArgument); +checker::Type *InferReturnType(ETSChecker *checker, ir::ScriptFunction *containingFunc, ir::Expression *stArgument); bool IsArrayExpressionValidInitializerForType(ETSChecker *checker, const Type *arrayExprPreferredType); void CastPossibleTupleOnRHS(ETSChecker *checker, ir::AssignmentExpression *expr); -void ProcessReturnStatements(ETSChecker *checker, ir::ScriptFunction *containingFunc, checker::Type *&funcReturnType, - ir::ReturnStatement *st, ir::Expression *stArgument); +checker::Type *ProcessReturnStatements(ETSChecker *checker, ir::ScriptFunction *containingFunc, ir::ReturnStatement *st, + ir::Expression *stArgument); bool CheckReturnTypeNecessity(ir::MethodDefinition *node); + void CheckAllConstPropertyInitialized(checker::ETSChecker *checker, ir::ETSModule *pkg); + +std::tuple IsConstantTestValue(ir::Expression const *expr); } // namespace ark::es2panda::checker #endif // ES2PANDA_CHECKER_ETSANALYZERHELPERS_H diff --git a/ets2panda/checker/ETSchecker.cpp b/ets2panda/checker/ETSchecker.cpp index 452cf67b950b0b7caf454c600c134c4b527a0d8e..7ca0134c5285ececb8f59e06208b8850731d4fe7 100644 --- a/ets2panda/checker/ETSchecker.cpp +++ b/ets2panda/checker/ETSchecker.cpp @@ -13,6 +13,10 @@ * limitations under the License. */ +#include +#include +#include + #include "ETSchecker.h" #include "es2panda.h" @@ -21,6 +25,8 @@ #include "ir/expressions/callExpression.h" #include "ir/ts/tsInterfaceDeclaration.h" #include "ir/statements/blockStatement.h" +#include "types/type.h" +#include "utils/arena_containers.h" #include "varbinder/ETSBinder.h" #include "parser/program/program.h" #include "checker/ets/aliveAnalyzer.h" @@ -30,43 +36,61 @@ #include "ir/base/scriptFunction.h" #include "util/helpers.h" #include "evaluate/scopedDebugInfoPlugin.h" +#include "checker/types/ets/etsTupleType.h" namespace ark::es2panda::checker { -ETSChecker::ETSChecker(util::DiagnosticEngine &diagnosticEngine) - // NOLINTNEXTLINE(readability-redundant-member-init) - : Checker(diagnosticEngine), - arrayTypes_(Allocator()->Adapter()), - pendingConstraintCheckRecords_(Allocator()->Adapter()), - globalArraySignatures_(Allocator()->Adapter()), - dynamicIntrinsics_ {DynamicCallIntrinsicsMap {Allocator()->Adapter()}, - DynamicCallIntrinsicsMap {Allocator()->Adapter()}}, - dynamicClasses_ {DynamicClassIntrinsicsMap(Allocator()->Adapter()), - DynamicClassIntrinsicsMap(Allocator()->Adapter())}, - dynamicLambdaSignatureCache_(Allocator()->Adapter()), - functionalInterfaceCache_(Allocator()->Adapter()), - apparentTypes_(Allocator()->Adapter()), - dynamicCallNames_ {{DynamicCallNamesMap(Allocator()->Adapter()), DynamicCallNamesMap(Allocator()->Adapter())}}, - overloadSigContainer_(Allocator()->Adapter()) -{ -} - -ETSChecker::ETSChecker(util::DiagnosticEngine &diagnosticEngine, ArenaAllocator *programAllocator) - // NOLINTNEXTLINE(readability-redundant-member-init) - : Checker(diagnosticEngine, programAllocator), - arrayTypes_(Allocator()->Adapter()), - pendingConstraintCheckRecords_(Allocator()->Adapter()), - globalArraySignatures_(Allocator()->Adapter()), - dynamicIntrinsics_ {DynamicCallIntrinsicsMap {Allocator()->Adapter()}, - DynamicCallIntrinsicsMap {Allocator()->Adapter()}}, - dynamicClasses_ {DynamicClassIntrinsicsMap(Allocator()->Adapter()), - DynamicClassIntrinsicsMap(Allocator()->Adapter())}, - dynamicLambdaSignatureCache_(Allocator()->Adapter()), - functionalInterfaceCache_(Allocator()->Adapter()), - apparentTypes_(Allocator()->Adapter()), - dynamicCallNames_ {{DynamicCallNamesMap(Allocator()->Adapter()), DynamicCallNamesMap(Allocator()->Adapter())}}, - overloadSigContainer_(Allocator()->Adapter()) +void ETSChecker::ReputCheckerData() { + readdedChecker_.insert(this); + for (auto &[_, extPrograms] : Program()->ExternalSources()) { + (void)_; + auto *extProg = extPrograms.front(); + if (!extProg->IsASTLowered()) { + continue; + } + auto eChecker = extProg->Checker()->AsETSChecker(); + + if (!HasStatus(CheckerStatus::BUILTINS_INITIALIZED)) { + SetGlobalTypesHolder(eChecker->GetGlobalTypesHolder()); + AddStatus(CheckerStatus::BUILTINS_INITIALIZED); + } + + if (auto it = readdedChecker_.find(eChecker); it != readdedChecker_.end()) { + continue; + } + readdedChecker_.insert(eChecker->readdedChecker_.begin(), eChecker->readdedChecker_.end()); + auto computedAbstractMapToCopy = eChecker->GetCachedComputedAbstracts(); + for (auto &[key, value] : *computedAbstractMapToCopy) { + if (GetCachedComputedAbstracts()->find(key) != GetCachedComputedAbstracts()->end()) { + continue; + } + auto &[v1, v2] = value; + ArenaVector newV1(Allocator()->Adapter()); + ArenaUnorderedSet newV2(Allocator()->Adapter()); + newV1.assign(v1.cbegin(), v1.cend()); + newV2.insert(v2.cbegin(), v2.cend()); + GetCachedComputedAbstracts()->try_emplace(key, newV1, newV2); + } + + auto &globalArraySigs = eChecker->globalArraySignatures_; + globalArraySignatures_.insert(globalArraySigs.cbegin(), globalArraySigs.cend()); + + auto &apparentTypes = eChecker->apparentTypes_; + apparentTypes_.insert(apparentTypes.cbegin(), apparentTypes.cend()); + + auto &objectInstantiationMap = eChecker->objectInstantiationMap_; + for (auto &[key, value] : objectInstantiationMap) { + if (objectInstantiationMap_.find(key) == objectInstantiationMap_.end()) { + objectInstantiationMap_.insert(objectInstantiationMap.cbegin(), objectInstantiationMap.cend()); + } + } + + auto &invokeToArrowSignatures = eChecker->invokeToArrowSignatures_; + invokeToArrowSignatures_.insert(invokeToArrowSignatures.cbegin(), invokeToArrowSignatures.cend()); + auto &arrowToFuncInterfaces = eChecker->arrowToFuncInterfaces_; + arrowToFuncInterfaces_.insert(arrowToFuncInterfaces.cbegin(), arrowToFuncInterfaces.cend()); + } } static util::StringView InitBuiltin(ETSChecker *checker, std::string_view signature) @@ -76,20 +100,21 @@ static util::StringView InitBuiltin(ETSChecker *checker, std::string_view signat ES2PANDA_ASSERT(iterator != varMap.end()); auto *var = iterator->second; Type *type {nullptr}; - if (var->Declaration()->Node()->IsClassDefinition()) { - type = checker->BuildBasicClassProperties(var->Declaration()->Node()->AsClassDefinition()); - } else { - ES2PANDA_ASSERT(var->Declaration()->Node()->IsTSInterfaceDeclaration()); - type = checker->BuildBasicInterfaceProperties(var->Declaration()->Node()->AsTSInterfaceDeclaration()); + if (var->HasFlag(varbinder::VariableFlags::BUILTIN_TYPE)) { + if (var->Declaration()->Node()->IsClassDefinition()) { + type = checker->BuildBasicClassProperties(var->Declaration()->Node()->AsClassDefinition()); + } else { + ES2PANDA_ASSERT(var->Declaration()->Node()->IsTSInterfaceDeclaration()); + type = checker->BuildBasicInterfaceProperties(var->Declaration()->Node()->AsTSInterfaceDeclaration()); + } + checker->GetGlobalTypesHolder()->InitializeBuiltin(iterator->first, type); } - checker->GetGlobalTypesHolder()->InitializeBuiltin(iterator->first, type); return iterator->first; } void ETSChecker::CheckObjectLiteralKeys(const ArenaVector &properties) { - static std::set names; - names.clear(); + std::set names; for (auto property : properties) { if (!property->IsProperty()) { @@ -233,7 +258,7 @@ static void IntializeFunctionInterfaces(GlobalTypesHolder *typeHolder) return typeHolder->GlobalFunctionBuiltinType(arity, hasRest)->AsETSObjectType(); }; - for (size_t arity = 0; arity < typeHolder->VariadicFunctionTypeThreshold(); arity++) { + for (size_t arity = 0; arity <= typeHolder->VariadicFunctionTypeThreshold(); arity++) { getItf(arity, false)->AddObjectFlag(ETSObjectFlags::FUNCTIONAL); getItf(arity, true)->AddObjectFlag(ETSObjectFlags::FUNCTIONAL); } @@ -291,8 +316,6 @@ void ETSChecker::InitializeBuiltin(varbinder::Variable *var, const util::StringV bool ETSChecker::StartChecker(varbinder::VarBinder *varbinder, const util::Options &options) { - Initialize(varbinder); - if (options.IsParseOnly()) { return false; } @@ -300,13 +323,6 @@ bool ETSChecker::StartChecker(varbinder::VarBinder *varbinder, const util::Optio auto *etsBinder = varbinder->AsETSBinder(); InitializeBuiltins(etsBinder); - for (auto &entry : etsBinder->DynamicImportVars()) { - auto &data = entry.second; - if (data.import->IsPureDynamic()) { - data.variable->SetTsType(GlobalBuiltinDynamicType(data.import->Language())); - } - } - bool isEvalMode = (debugInfoPlugin_ != nullptr); if (UNLIKELY(isEvalMode)) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -352,23 +368,24 @@ void ETSChecker::SetDebugInfoPlugin(evaluate::ScopedDebugInfoPlugin *debugInfo) void ETSChecker::CheckProgram(parser::Program *program, bool runAnalysis) { - if (program->IsASTChecked()) { - return; - } - auto *savedProgram = Program(); SetProgram(program); for (auto &[_, extPrograms] : program->ExternalSources()) { (void)_; for (auto *extProg : extPrograms) { - if (extProg->IsASTChecked()) { - continue; + if (!extProg->IsASTLowered()) { + extProg->PushChecker(this); + auto *savedProgram2 = VarBinder()->AsETSBinder()->Program(); + varbinder::RecordTableContext recordTableCtx(VarBinder()->AsETSBinder(), extProg); + VarBinder()->AsETSBinder()->SetProgram(extProg); + VarBinder()->AsETSBinder()->ResetTopScope(extProg->GlobalScope()); + checker::SavedCheckerContext savedContext(this, Context().Status(), Context().ContainingClass()); + AddStatus(checker::CheckerStatus::IN_EXTERNAL); + CheckProgram(extProg, VarBinder()->IsGenStdLib() || extProg->IsGenAbcForExternal()); + VarBinder()->AsETSBinder()->SetProgram(savedProgram2); + VarBinder()->AsETSBinder()->ResetTopScope(savedProgram2->GlobalScope()); } - checker::SavedCheckerContext savedContext(this, Context().Status(), Context().ContainingClass()); - AddStatus(checker::CheckerStatus::IN_EXTERNAL); - CheckProgram(extProg, VarBinder()->IsGenStdLib()); - extProg->SetFlag(parser::ProgramFlags::AST_CHECK_PROCESSED); } } @@ -409,6 +426,20 @@ bool ETSChecker::IsClassStaticMethod(checker::ETSObjectType *objType, checker::S signature->HasSignatureFlag(checker::SignatureFlags::STATIC); } +[[nodiscard]] TypeFlag ETSChecker::TypeKind(const Type *const type) noexcept +{ + // These types were not present in the ETS_TYPE list. Some of them are omitted intentionally, other are just bugs + static constexpr auto TO_CLEAR = TypeFlag::CONSTANT | TypeFlag::GENERIC | TypeFlag::ETS_INT_ENUM | + TypeFlag::ETS_STRING_ENUM | TypeFlag::READONLY | TypeFlag::BIGINT_LITERAL | + TypeFlag::ETS_TYPE_ALIAS | TypeFlag::TYPE_ERROR; + + CHECK_NOT_NULL(type); + auto res = static_cast(type->TypeFlags() & ~(TO_CLEAR)); + ES2PANDA_ASSERT_POS(res == TypeFlag::NONE || helpers::math::IsPowerOfTwo(res & ~(TypeFlag::NONE)), + ark::es2panda::GetPositionForDiagnostic()); + return res; +} + template ETSObjectType *ETSChecker::AsETSObjectType(Type *(GlobalTypesHolder::*typeFunctor)(Args...), Args... args) const { @@ -510,6 +541,16 @@ Type *ETSChecker::GlobalETSUndefinedType() const return GetGlobalTypesHolder()->GlobalETSUndefinedType(); } +Type *ETSChecker::GlobalETSAnyType() const +{ + return GetGlobalTypesHolder()->GlobalETSAnyType(); +} + +Type *ETSChecker::GlobalETSRelaxedAnyType() const +{ + return GetGlobalTypesHolder()->GlobalETSRelaxedAnyType(); +} + Type *ETSChecker::GlobalETSNeverType() const { return GetGlobalTypesHolder()->GlobalETSNeverType(); @@ -535,18 +576,23 @@ ETSObjectType *ETSChecker::GlobalETSObjectType() const return AsETSObjectType(&GlobalTypesHolder::GlobalETSObjectType); } -ETSUnionType *ETSChecker::GlobalETSNullishType() const +ETSUnionType *ETSChecker::GlobalETSUnionUndefinedNull() const { - auto *ret = (GetGlobalTypesHolder()->*&GlobalTypesHolder::GlobalETSNullishType)(); + auto *ret = (GetGlobalTypesHolder()->*&GlobalTypesHolder::GlobalETSUnionUndefinedNull)(); return ret != nullptr ? ret->AsETSUnionType() : nullptr; } -ETSUnionType *ETSChecker::GlobalETSNullishObjectType() const +ETSUnionType *ETSChecker::GlobalETSUnionUndefinedNullObject() const { - auto *ret = (GetGlobalTypesHolder()->*&GlobalTypesHolder::GlobalETSNullishObjectType)(); + auto *ret = (GetGlobalTypesHolder()->*&GlobalTypesHolder::GlobalETSUnionUndefinedNullObject)(); return ret != nullptr ? ret->AsETSUnionType() : nullptr; } +ETSObjectType *ETSChecker::GlobalBuiltinClassType() const +{ + return AsETSObjectType(&GlobalTypesHolder::GlobalClassBuiltinType); +} + ETSObjectType *ETSChecker::GlobalBuiltinETSResizableArrayType() const { return AsETSObjectType(&GlobalTypesHolder::GlobalArrayBuiltinType); @@ -651,9 +697,10 @@ ETSObjectType *ETSChecker::GlobalBuiltinBoxType(Type *contents) return AsETSObjectType(&GlobalTypesHolder::GlobalDoubleBoxBuiltinType); default: { auto *base = AsETSObjectType(&GlobalTypesHolder::GlobalBoxBuiltinType); - auto *substitution = NewSubstitution(); - substitution->emplace(base->TypeArguments()[0]->AsETSTypeParameter(), contents); - return base->Substitute(Relation(), substitution); + auto substitution = Substitution {}; + ES2PANDA_ASSERT(base != nullptr); + substitution.emplace(base->TypeArguments()[0]->AsETSTypeParameter(), contents); + return base->Substitute(Relation(), &substitution); } } } @@ -668,6 +715,16 @@ const GlobalArraySignatureMap &ETSChecker::GlobalArrayTypes() const return globalArraySignatures_; } +const ArenaSet &ETSChecker::UnionAssemblerTypes() const +{ + return unionAssemblerTypes_; +} + +ArenaSet &ETSChecker::UnionAssemblerTypes() +{ + return unionAssemblerTypes_; +} + Type *ETSChecker::GlobalTypeError() const { return GetGlobalTypesHolder()->GlobalTypeError(); @@ -711,19 +768,20 @@ void ETSChecker::HandleUpdatedCallExpressionNode(ir::CallExpression *callExpr) VarBinder()->AsETSBinder()->HandleCustomNodes(callExpr); } -Type *ETSChecker::SelectGlobalIntegerTypeForNumeric(Type *type) +Type *ETSChecker::SelectGlobalIntegerTypeForNumeric(Type *type) const noexcept { - switch (ETSType(type)) { - case checker::TypeFlag::FLOAT: { - return GlobalIntType(); - } - case checker::TypeFlag::DOUBLE: { - return GlobalLongType(); + if (type->IsETSObjectType()) { + auto const *objectType = type->AsETSObjectType(); + + if (objectType->HasObjectFlag(ETSObjectFlags::BUILTIN_FLOAT)) { + return GlobalIntBuiltinType(); } - default: { - return type; + + if (objectType->HasObjectFlag(ETSObjectFlags::BUILTIN_DOUBLE)) { + return GlobalLongBuiltinType(); } } + return type; } Signature *ETSChecker::FindExtensionSetterInMap(util::StringView name, ETSObjectType *type) @@ -745,4 +803,20 @@ void ETSChecker::InsertExtensionGetterToMap(util::StringView name, ETSObjectType { GetGlobalTypesHolder()->InsertExtensionGetterToMap(name, type, sig); } + +bool ETSChecker::TypeHasDefaultValue(Type *tp) const +{ + return tp->IsBuiltinNumeric() || tp->IsETSBooleanType() || tp->IsETSCharType() || + Relation()->IsSupertypeOf(GlobalETSUndefinedType(), tp); +} + +/* Invoke method name in functional interfaces */ +std::string ETSChecker::FunctionalInterfaceInvokeName(size_t arity, bool hasRest) +{ + if (arity < GlobalBuiltinFunctionTypeVariadicThreshold()) { + return (hasRest ? "invokeR" : "invoke") + std::to_string(arity); + } + return "unsafeCall"; +} + } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/ETSchecker.h b/ets2panda/checker/ETSchecker.h index 06de9f47df7fc3cd76ba9417daf3c146cc31b52d..8e7db4fb3ccc3aa5041cca4dcb9f7e5533bad6e9 100644 --- a/ets2panda/checker/ETSchecker.h +++ b/ets2panda/checker/ETSchecker.h @@ -25,8 +25,8 @@ #include "checker/types/ets/etsResizableArrayType.h" #include "checker/types/ets/types.h" #include "checker/resolveResult.h" -#include "ir/ts/tsInterfaceDeclaration.h" #include "ir/visitor/AstVisitor.h" +#include "types/type.h" #include "util/helpers.h" namespace ark::es2panda::varbinder { @@ -65,38 +65,60 @@ struct PairHash { using ComputedAbstracts = ArenaUnorderedMap, ArenaUnorderedSet>>; using ArrayMap = ArenaUnorderedMap, ETSArrayType *, PairHash>; +using ObjectInstantiationMap = ArenaUnorderedMap>; using GlobalArraySignatureMap = ArenaUnorderedMap; using DynamicCallIntrinsicsMap = ArenaUnorderedMap>; +using FunctionSignatureMap = ArenaUnorderedMap; +using FunctionInterfaceMap = ArenaUnorderedMap; using DynamicClassIntrinsicsMap = ArenaUnorderedMap; using DynamicLambdaObjectSignatureMap = ArenaUnorderedMap; using FunctionalInterfaceMap = ArenaUnorderedMap; using TypeMapping = ArenaUnorderedMap; using DynamicCallNamesMap = ArenaMap, uint32_t>; -using ConstraintCheckRecord = std::tuple *, const Substitution *, lexer::SourcePosition>; +using ConstraintCheckRecord = std::tuple *, const Substitution, lexer::SourcePosition>; // can't use util::DiagnosticWithParams because std::optional can't contain references using MaybeDiagnosticInfo = std::optional>; using AstNodePtr = ir::AstNode *; +using TypePtr = Type *; class ETSChecker final : public Checker { public: - explicit ETSChecker(util::DiagnosticEngine &diagnosticEngine); - explicit ETSChecker(util::DiagnosticEngine &diagnosticEngine, ArenaAllocator *programAllocator); + explicit ETSChecker(ThreadSafeArenaAllocator *allocator, util::DiagnosticEngine &diagnosticEngine, + ThreadSafeArenaAllocator *programAllocator = nullptr) + // NOLINTNEXTLINE(readability-redundant-member-init) + : Checker(allocator, diagnosticEngine, programAllocator), + arrayTypes_(Allocator()->Adapter()), + objectInstantiationMap_(Allocator()->Adapter()), + invokeToArrowSignatures_(Allocator()->Adapter()), + arrowToFuncInterfaces_(Allocator()->Adapter()), + globalArraySignatures_(Allocator()->Adapter()), + unionAssemblerTypes_(Allocator()->Adapter()), + dynamicIntrinsics_ {DynamicCallIntrinsicsMap {Allocator()->Adapter()}, + DynamicCallIntrinsicsMap {Allocator()->Adapter()}}, + dynamicClasses_ {DynamicClassIntrinsicsMap(Allocator()->Adapter()), + DynamicClassIntrinsicsMap(Allocator()->Adapter())}, + dynamicLambdaSignatureCache_(Allocator()->Adapter()), + functionalInterfaceCache_(Allocator()->Adapter()), + apparentTypes_(Allocator()->Adapter()), + dynamicCallNames_ { + {DynamicCallNamesMap(Allocator()->Adapter()), DynamicCallNamesMap(Allocator()->Adapter())}}, + overloadSigContainer_(Allocator()->Adapter()), + readdedChecker_(Allocator()->Adapter()) + { + } ~ETSChecker() override = default; NO_COPY_SEMANTIC(ETSChecker); NO_MOVE_SEMANTIC(ETSChecker); - [[nodiscard]] static inline TypeFlag ETSType(const Type *const type) noexcept + [[nodiscard]] static TypeFlag ETSType(const Type *const type) noexcept { - return static_cast(type->TypeFlags() & TypeFlag::ETS_TYPE); + return ETSChecker::TypeKind(type); } - [[nodiscard]] static inline TypeFlag TypeKind(const Type *const type) noexcept - { - return static_cast(type->TypeFlags() & checker::TypeFlag::ETS_TYPE); - } + [[nodiscard]] static TypeFlag TypeKind(const Type *const type) noexcept; Type *GlobalByteType() const; Type *GlobalShortType() const; @@ -109,6 +131,8 @@ public: Type *GlobalVoidType() const; Type *GlobalETSNullType() const; Type *GlobalETSUndefinedType() const; + Type *GlobalETSAnyType() const; + Type *GlobalETSRelaxedAnyType() const; Type *GlobalETSNeverType() const; Type *GlobalETSStringLiteralType() const; Type *GlobalETSBigIntType() const; @@ -124,8 +148,9 @@ public: Type *GlobalETSBooleanBuiltinType() const; ETSObjectType *GlobalETSObjectType() const; - ETSUnionType *GlobalETSNullishType() const; - ETSUnionType *GlobalETSNullishObjectType() const; + ETSUnionType *GlobalETSUnionUndefinedNull() const; + ETSUnionType *GlobalETSUnionUndefinedNullObject() const; + ETSObjectType *GlobalBuiltinClassType() const; ETSObjectType *GlobalBuiltinETSResizableArrayType() const; ETSObjectType *GlobalBuiltinETSStringType() const; ETSObjectType *GlobalBuiltinETSBigIntType() const; @@ -150,6 +175,9 @@ public: GlobalArraySignatureMap &GlobalArrayTypes(); const GlobalArraySignatureMap &GlobalArrayTypes() const; + const ArenaSet &UnionAssemblerTypes() const; + ArenaSet &UnionAssemblerTypes(); + Type *GlobalTypeError() const; [[nodiscard]] Type *InvalidateType(ir::Typed *node); [[nodiscard]] Type *TypeError(ir::Typed *node, const diagnostic::DiagnosticKind &diagKind, @@ -172,6 +200,7 @@ public: Type *GuaranteedTypeForUncheckedCallReturn(Signature *sig); Type *GuaranteedTypeForUncheckedPropertyAccess(varbinder::Variable *prop); Type *GuaranteedTypeForUnionFieldAccess(ir::MemberExpression *memberExpression, ETSUnionType *etsUnionType); + void ReputCheckerData(); [[nodiscard]] bool IsETSChecker() const noexcept override { @@ -182,6 +211,7 @@ public: void CheckObjectLiteralKeys(const ArenaVector &properties); Type *BuildBasicClassProperties(ir::ClassDefinition *classDef); ETSObjectType *BuildAnonymousClassProperties(ir::ClassDefinition *classDef, ETSObjectType *superType); + Type *MaybeGradualType(ir::AstNode *node, ETSObjectType *type); Type *BuildBasicInterfaceProperties(ir::TSInterfaceDeclaration *interfaceDecl); ETSObjectType *GetSuperType(ETSObjectType *type); ArenaVector GetInterfaces(ETSObjectType *type); @@ -190,8 +220,7 @@ public: void ValidateImplementedInterface(ETSObjectType *type, Type *interface, std::unordered_set *extendsSet, const lexer::SourcePosition &pos); void ResolveDeclaredMembersOfObject(const Type *type); - lexer::Number ExtractNumericValue(Type const *const indexType); - std::optional GetTupleElementAccessValue(const Type *type); + std::optional GetTupleElementAccessValue(const ir::Expression *expr); bool ValidateArrayIndex(ir::Expression *expr, bool relaxed = false); bool ValidateTupleIndex(const ETSTupleType *tuple, ir::MemberExpression *expr, bool reportError = true); bool ValidateTupleIndexFromEtsObject(const ETSTupleType *const tuple, ir::MemberExpression *expr); @@ -244,8 +273,11 @@ public: void CreateFunctionTypesFromAbstracts(const std::vector &abstracts, ArenaVector *target); void CheckCyclicConstructorCall(Signature *signature); + void CheckAnnotationReference(const ir::MemberExpression *memberExpr, const varbinder::LocalVariable *prop); std::vector ResolveMemberReference(const ir::MemberExpression *memberExpr, const ETSObjectType *target); + varbinder::LocalVariable *ResolveOverloadReference(const ir::Identifier *ident, ETSObjectType *objType, + PropertySearchFlags searchFlags); void WarnForEndlessLoopInGetterSetter(const ir::MemberExpression *const memberExpr); varbinder::Variable *GetExtensionFuncVarInGlobalFunction(const ir::MemberExpression *const memberExpr); varbinder::Variable *GetExtensionFuncVarInGlobalField(const ir::MemberExpression *const memberExpr); @@ -274,6 +306,8 @@ public: void VariableTypeFromInitializer(varbinder::Variable *variable, Type *annotationType, Type *initType); + bool TypeHasDefaultValue(Type *tp) const; + // Type creation ByteType *CreateByteType(int8_t value); ETSBooleanType *CreateETSBooleanType(bool value); @@ -288,6 +322,7 @@ public: ETSResizableArrayType *CreateETSMultiDimResizableArrayType(Type *element, size_t dimSize); ETSResizableArrayType *CreateETSResizableArrayType(Type *element); ETSArrayType *CreateETSArrayType(Type *elementType, bool isCachePolluting = false); + Type *CreateGradualType(Type *baseType, Language lang = Language(Language::Id::JS)); Type *CreateETSUnionType(Span constituentTypes); template Type *CreateETSUnionType(Type *const (&arr)[N]) // NOLINT(modernize-avoid-c-arrays) @@ -306,9 +341,6 @@ public: bool isRecursive = false); ETSFunctionType *CreateETSArrowType(Signature *signature); ETSFunctionType *CreateETSMethodType(util::StringView name, ArenaVector &&signatures); - ETSFunctionType *CreateETSDynamicArrowType(Signature *signature, Language lang); - ETSFunctionType *CreateETSDynamicMethodType(util::StringView name, ArenaVector &&signatures, - Language lang); ETSExtensionFuncHelperType *CreateETSExtensionFuncHelperType(ETSFunctionType *classMethodType, ETSFunctionType *extensionFunctionType); void AddThisReturnTypeFlagForInterfaceInvoke(ETSObjectType *interface); @@ -318,8 +350,6 @@ public: std::tuple CreateBuiltinArraySignatureInfo(const ETSArrayType *arrayType, size_t dim); Signature *CreateBuiltinArraySignature(const ETSArrayType *arrayType, size_t dim); - IntType *CreateIntTypeFromType(Type *type); - std::tuple CheckForDynamicLang(ir::AstNode *declNode, util::StringView assemblerName); ETSObjectType *CreatePromiseOf(Type *type); Signature *CreateSignature(SignatureInfo *info, Type *returnType, ir::ScriptFunction *func); @@ -327,7 +357,6 @@ public: SignatureInfo *CreateSignatureInfo(); // Arithmetic - Type *NegateNumericType(Type *type, ir::Expression *node); bool CheckBinaryOperatorForBigInt(Type *left, Type *right, lexer::TokenType op); [[nodiscard]] bool CheckBinaryPlusMultDivOperandsForUnionType(const Type *leftType, const Type *rightType, const ir::Expression *left, @@ -343,12 +372,9 @@ public: checker::Type *CheckBinaryOperatorMulDivMod( std::tuple op, bool isEqualOp, std::tuple types); - checker::Type *CheckBinaryOperatorForIntEnums(const checker::Type *const leftType, - const checker::Type *const rightType); + checker::Type *CheckBinaryBitwiseOperatorForIntEnums(const checker::Type *const leftType, const checker::Type *const rightType); - checker::Type *CheckBinaryOperatorPlusForEnums(const checker::Type *const leftType, - const checker::Type *const rightType); checker::Type *CheckBinaryOperatorPlus( std::tuple op, bool isEqualOp, std::tuple types); @@ -359,9 +385,8 @@ public: std::tuple op, bool isEqualOp, std::tuple types); // CC-OFFNXT(G.FUN.01-CPP) solid logic - checker::Type *CheckBinaryOperatorLogical(ir::Expression *left, ir::Expression *right, ir::BinaryExpression *expr, - checker::Type *leftType, checker::Type *rightType, Type *unboxedL, - Type *unboxedR); + checker::Type *CheckBinaryOperatorLogical(ir::Expression *left, ir::Expression *right, checker::Type *leftType, + checker::Type *rightType, Type *unboxedL, Type *unboxedR); std::tuple CheckBinaryOperatorStrictEqual(ir::Expression *left, lexer::TokenType operationType, lexer::SourcePosition pos, checker::Type *leftType, checker::Type *rightType); @@ -374,15 +399,13 @@ public: checker::Type *rightType); checker::Type *CheckBinaryOperatorNullishCoalescing(ir::Expression *left, ir::Expression *right, lexer::SourcePosition pos); + bool CheckIfNumeric(Type *type); + bool CheckIfFloatingPoint(Type *type); bool AdjustNumberLiteralType(ir::NumberLiteral *literal, Type *literalType, Type *otherType); Type *HandleArithmeticOperationOnTypes(Type *left, Type *right, lexer::TokenType operationType); - Type *HandleBitwiseOperationOnTypes(Type *left, Type *right, lexer::TokenType operationType); - void FlagExpressionWithUnboxing(Type *type, Type *unboxedType, ir::Expression *typeExpression); - template - Type *PerformArithmeticOperationOnTypes(Type *left, Type *right, lexer::TokenType operationType); - - Type *HandleRelationOperationOnTypes(Type *left, Type *right, lexer::TokenType operationType); + void SetGenerateValueOfFlags(std::tuple types, + std::tuple nodes); template Type *PerformRelationOperationOnTypes(Type *left, Type *right, lexer::TokenType operationType); @@ -398,7 +421,7 @@ public: bool TrailingLambdaTypeInference(Signature *signature, const ArenaVector &arguments); bool TypeInference(Signature *signature, const ArenaVector &arguments, TypeRelationFlag flags = TypeRelationFlag::NONE); - bool CheckLambdaTypeAnnotation(ir::AstNode *typeAnnotation, ir::ArrowFunctionExpression *arrowFuncExpr, + bool CheckLambdaTypeAnnotation(ir::ETSParameterExpression *param, ir::ArrowFunctionExpression *arrowFuncExpr, Type *parameterType, TypeRelationFlag flags); bool CheckLambdaInfer(ir::AstNode *typeAnnotation, ir::ArrowFunctionExpression *arrowFuncExpr, Type *const subParameterType); @@ -406,21 +429,20 @@ public: bool CheckLambdaAssignableUnion(ir::AstNode *typeAnn, ir::ScriptFunction *lambda); bool IsCompatibleTypeArgument(ETSTypeParameter *typeParam, Type *typeArgument, const Substitution *substitution); - Substitution *NewSubstitution() + ArenaSubstitution *NewArenaSubstitution() { - return ProgramAllocator()->New(ProgramAllocator()->Adapter()); + return ProgramAllocator()->New(ProgramAllocator()->Adapter()); } - Substitution *CopySubstitution(const Substitution *src) - { - return ProgramAllocator()->New(*src); - } bool ValidateTypeSubstitution(const ArenaVector &typeParams, Type *ctype, Type *argumentType, Substitution *substitution); bool ProcessUntypedParameter(ir::AstNode *declNode, size_t paramIndex, Signature *paramSig, Signature *argSig, Substitution *substitution); + static Substitution ArenaSubstitutionToSubstitution(const ArenaSubstitution *orig); void EmplaceSubstituted(Substitution *substitution, ETSTypeParameter *tparam, Type *typeArg); + void EmplaceSubstituted(ArenaSubstitution *substitution, ETSTypeParameter *tparam, Type *typeArg); + [[nodiscard]] bool EnhanceSubstitutionForType(const ArenaVector &typeParams, Type *paramType, Type *argumentType, Substitution *substitution); [[nodiscard]] bool EnhanceSubstitutionForReadonly(const ArenaVector &typeParams, ETSReadonlyType *paramType, @@ -452,13 +474,38 @@ public: bool ValidateSignatureInvocationContext(Signature *substitutedSig, ir::Expression *argument, std::size_t index, TypeRelationFlag flags); bool CheckOptionalLambdaFunction(ir::Expression *argument, Signature *substitutedSig, std::size_t index); - bool ValidateArgumentAsIdentifier(const ir::Identifier *identifier); bool IsValidRestArgument(ir::Expression *argument, Signature *substitutedSig, TypeRelationFlag flags, std::size_t index); + bool SetPreferredTypeForArrayArgument(ir::ArrayExpression *arrayExpr, Signature *substitutedSig); bool ValidateSignatureRestParams(Signature *substitutedSig, const ArenaVector &arguments, TypeRelationFlag flags, bool reportError, bool unique); void ThrowSignatureMismatch(ArenaVector &signatures, const ArenaVector &arguments, const lexer::SourcePosition &pos, std::string_view signatureKind); + Signature *FirstMatchSignatures(ir::CallExpression *expr, checker::Type *calleeType); + Signature *MatchOrderSignatures(ArenaVector &signatures, + const ir::TSTypeParameterInstantiation *typeArguments, + const ArenaVector &arguments, const lexer::SourcePosition &pos, + TypeRelationFlag resolveFlags); + void CleanArgumentsInformation(const ArenaVector &arguments); + Signature *ValidateOrderSignature( + std::tuple info, + const ArenaVector &arguments, const lexer::SourcePosition &pos, + const std::vector &argTypeInferenceRequired, const bool unique); + bool ValidateOrderSignatureRequiredParams(Signature *substitutedSig, const ArenaVector &arguments, + TypeRelationFlag flags, + const std::vector &argTypeInferenceRequired); + bool ValidateOrderSignatureInvocationContext(Signature *substitutedSig, ir::Expression *argument, std::size_t index, + TypeRelationFlag flags); + void ThrowOverloadMismatch(util::StringView callName, const ArenaVector &arguments, + const lexer::SourcePosition &pos, std::string_view signatureKind); + Signature *ResolveTrailingLambda(ArenaVector &signatures, ir::CallExpression *callExpr, + const lexer::SourcePosition &pos, + TypeRelationFlag reportFlag = TypeRelationFlag::NONE); + Signature *ResolvePotentialTrailingLambda(ir::CallExpression *callExpr, ArenaVector const &signatures, + ArenaVector &arguments); + bool SetPreferredTypeBeforeValidate(Signature *substitutedSig, ir::Expression *argument, size_t index, + TypeRelationFlag flags, const std::vector &argTypeInferenceRequired); + // CC-OFFNXT(G.FUN.01-CPP) solid logic Signature *ValidateSignatures(ArenaVector &signatures, const ir::TSTypeParameterInstantiation *typeArguments, @@ -471,6 +518,8 @@ public: void SearchAmongMostSpecificTypes(Type *&mostSpecificType, Signature *&prevSig, std::tuple info, bool lookForClassType); + void CheckAmbiguousCall(Type *&mostSpecificType, Type *sigType, Signature *prevSig, Signature *sig, + const lexer::SourcePosition &pos); void CollectSuitableSignaturesForTypeInference(size_t paramIdx, ArenaVector &signatures, ArenaMultiMap &bestSignaturesForParameter, const ArenaVector &arguments); @@ -484,6 +533,7 @@ public: Signature *ResolvePotentialTrailingLambdaWithReceiver(ir::CallExpression *callExpr, ArenaVector const &signatures, ArenaVector &arguments); + Signature *MakeSignatureInvocable(Signature *sig, ir::CallExpression *callExpr); Signature *ResolveCallExpressionAndTrailingLambda(ArenaVector &signatures, ir::CallExpression *callExpr, const lexer::SourcePosition &pos, TypeRelationFlag reportFlag = TypeRelationFlag::NONE); @@ -504,8 +554,8 @@ public: Signature *CheckEveryAbstractSignatureIsOverridden(ETSFunctionType *target, ETSFunctionType *source); static Signature *GetSignatureFromMethodDefinition(const ir::MethodDefinition *methodDef); bool CheckIdenticalOverloads(ETSFunctionType *func, ETSFunctionType *overload, - const ir::MethodDefinition *currentFunc, bool omitSameAsm = false); - static bool CmpAssemblerTypesWithRank(Signature const *const sig1, Signature const *const sig2) noexcept; + const ir::MethodDefinition *currentFunc, bool omitSameAsm = false, + TypeRelationFlag relationFlags = TypeRelationFlag::NO_RETURN_TYPE_CHECK); static bool HasSameAssemblySignature(Signature const *const sig1, Signature const *const sig2) noexcept; static bool HasSameAssemblySignatures(ETSFunctionType const *const func1, ETSFunctionType const *const func2) noexcept; @@ -537,6 +587,7 @@ public: void ReplaceScope(ir::AstNode *root, ir::AstNode *oldNode, varbinder::Scope *newScope); // Helpers + std::string FunctionalInterfaceInvokeName(size_t arity, bool hasRest); static std::string GetAsyncImplName(const util::StringView &name); static std::string GetAsyncImplName(ir::MethodDefinition *asyncMethod); static bool IsAsyncImplMethod(ir::MethodDefinition const *method); @@ -549,6 +600,7 @@ public: const util::StringView &importPath); void SetPropertiesForModuleObject(checker::ETSObjectType *moduleObjType, const util::StringView &importPath, ir::ETSImportDeclaration *importDecl = nullptr); + parser::Program *SelectEntryOrExternalProgram(varbinder::ETSBinder *etsBinder, const util::StringView &importPath); void SetrModuleObjectTsType(ir::Identifier *local, checker::ETSObjectType *moduleObjType); Type *GetReferencedTypeFromBase(Type *baseType, ir::Expression *name); Type *GetReferencedTypeBase(ir::Expression *name); @@ -571,9 +623,6 @@ public: bool IsNullLikeOrVoidExpression(const ir::Expression *expr) const; bool IsConstantExpression(ir::Expression *expr, Type *type); void ValidateUnaryOperatorOperand(varbinder::Variable *variable); - bool ValidateAnnotationPropertyType(checker::Type *tsType); - void ProcessRequiredFields(ArenaUnorderedMap &fieldMap, - ir::AnnotationUsage *st, ETSChecker *checker) const; void CheckFunctionSignatureAnnotations(const ArenaVector ¶ms, ir::TSTypeParameterDeclaration *typeParams, ir::TypeNode *returnTypeAnnotation); @@ -594,15 +643,11 @@ public: void InferAliasLambdaType(ir::TypeNode *localTypeAnnotation, ir::ArrowFunctionExpression *init); checker::Type *ApplyConditionalOperatorPromotion(checker::ETSChecker *checker, checker::Type *unboxedL, checker::Type *unboxedR); - Type *ApplyUnaryOperatorPromotion(Type *type, bool createConst = true, bool doPromotion = true, - bool isCondExpr = false); + Type *ApplyUnaryOperatorPromotion(ir::Expression *expr, Type *type, bool isCondExpr = false); + Type *GetUnaryOperatorPromotedType(Type *type, const bool doPromotion = true); Type *HandleBooleanLogicalOperators(Type *leftType, Type *rightType, lexer::TokenType tokenType); - bool HandleLogicalPotentialResult(ir::Expression *left, ir::Expression *right, ir::BinaryExpression *expr, - checker::Type *leftType); - - checker::Type *FixOptionalVariableType(varbinder::Variable *const bindingVar, ir::ModifierFlags flags, - ir::Expression *init); + checker::Type *FixOptionalVariableType(varbinder::Variable *const bindingVar, ir::ModifierFlags flags); void CheckEnumType(ir::Expression *init, checker::Type *initType, const util::StringView &varName); checker::Type *CheckVariableDeclaration(ir::Identifier *ident, ir::TypeNode *typeAnnotation, ir::Expression *init, ir::ModifierFlags flags); @@ -634,11 +679,7 @@ public: Type *MaybeUnboxInRelation(Type *objectType); Type *MaybeUnboxConditionalInRelation(Type *objectType); Type *MaybeBoxInRelation(Type *objectType); - void AddBoxingUnboxingFlagsToNode(ir::AstNode *node, Type *boxingUnboxingType); - ir::BoxingUnboxingFlags GetBoxingFlag(Type *boxingType); - ir::BoxingUnboxingFlags GetUnboxingFlag(Type const *unboxingType) const; Type *MaybeBoxExpression(ir::Expression *expr); - Type *MaybeUnboxExpression(ir::Expression *expr); Type *MaybeBoxType(Type *type) const; Type *MaybeUnboxType(Type *type) const; Type const *MaybeBoxType(Type const *type) const; @@ -648,7 +689,6 @@ public: bool CompareIdentifiersValuesAreDifferent(ir::Expression *compareValue, const std::string &caseValue); void CheckIdentifierSwitchCase(ir::Expression *currentCase, ir::Expression *compareCase, const lexer::SourcePosition &pos); - std::string GetStringFromLiteral(ir::Expression *caseTest) const; varbinder::Variable *FindVariableInFunctionScope(util::StringView name); std::pair FindVariableInClassOrEnclosing( util::StringView name, const ETSObjectType *classType); @@ -658,11 +698,10 @@ public: static bool IsVariableStatic(const varbinder::Variable *var); static bool IsVariableGetterSetter(const varbinder::Variable *var); static bool IsVariableExtensionAccessor(const varbinder::Variable *var); + static bool IsVariableOverloadDeclaration(const varbinder::Variable *var); bool IsSameDeclarationType(varbinder::LocalVariable *target, varbinder::LocalVariable *compare); void SaveCapturedVariable(varbinder::Variable *var, ir::Identifier *ident); bool SaveCapturedVariableInLocalClass(varbinder::Variable *var, ir::Identifier *ident); - void MaybeAddBoxingFlagInRelation(TypeRelation *relation, Type *target); - void MaybeAddUnboxingFlagInRelation(TypeRelation *relation, Type *source, Type *self); void CheckUnboxedTypeWidenable(TypeRelation *relation, Type *target, Type *self); void CheckUnboxedTypesAssignable(TypeRelation *relation, Type *source, Type *target); void CheckBoxedSourceTypeAssignable(TypeRelation *relation, Type *source, Type *target); @@ -677,6 +716,12 @@ public: ir::BlockStatement *FindFinalizerOfTryStatement(ir::AstNode *startFrom, const ir::AstNode *p); void CheckExceptionClauseType(const std::vector &exceptions, ir::CatchClause *catchClause, checker::Type *clauseType); + + void CheckConstructorOverloadDeclaration(ETSChecker *checker, ir::OverloadDeclaration *node) const; + void CheckFunctionOverloadDeclaration(ETSChecker *checker, ir::OverloadDeclaration *node) const; + void CheckClassMethodOverloadDeclaration(ETSChecker *checker, ir::OverloadDeclaration *node) const; + void CheckInterfaceMethodOverloadDeclaration(ETSChecker *checker, ir::OverloadDeclaration *node) const; + ETSObjectType *GetRelevantArgumentedTypeFromChild(ETSObjectType *child, ETSObjectType *target); util::StringView GetHashFromTypeArguments(const ArenaVector &typeArgTypes); util::StringView GetHashFromSubstitution(const Substitution *substitution, const bool isExtensionFuncFlag); @@ -687,7 +732,7 @@ public: bool IsExtensionAccessorFunctionType(const checker::Type *type); bool IsArrayExprSizeValidForTuple(const ir::ArrayExpression *arrayExpr, const ETSTupleType *tuple); void ModifyPreferredType(ir::ArrayExpression *arrayExpr, Type *newPreferredType); - Type *SelectGlobalIntegerTypeForNumeric(Type *type); + Type *SelectGlobalIntegerTypeForNumeric(Type *type) const noexcept; ir::ClassProperty *ClassPropToImplementationProp(ir::ClassProperty *classProp, varbinder::ClassScope *scope); ir::Expression *GenerateImplicitInstantiateArg(const std::string &className); @@ -707,7 +752,6 @@ public: void ETSObjectTypeDeclNode(ETSChecker *checker, ETSObjectType *const objectType); ir::CallExpression *CreateExtensionAccessorCall(ETSChecker *checker, ir::MemberExpression *expr, ArenaVector &&args); - static void SetPreferredTypeIfPossible(ir::Expression *expr, Type *targetType); Signature *FindRelativeExtensionGetter(ir::MemberExpression *const expr, ETSFunctionType *funcType); Signature *FindRelativeExtensionSetter(ir::MemberExpression *const expr, ETSFunctionType *funcType); Type *GetExtensionAccessorReturnType(ir::MemberExpression *expr); @@ -761,12 +805,15 @@ public: void MakePropertyNonNullish(ETSObjectType *classType, varbinder::LocalVariable *prop); void ValidateObjectLiteralForRequiredType(const ETSObjectType *requiredType, const ir::ObjectExpression *initObjExpr); + bool IsStaticInvoke(ir::MemberExpression *const expr); + void ValidateCallExpressionIdentifier(ir::Identifier *const ident, Type *const type); using NamedAccessMeta = std::tuple; static NamedAccessMeta FormNamedAccessMetadata(varbinder::Variable const *prop); // Smart cast support - [[nodiscard]] checker::Type *ResolveSmartType(checker::Type *sourceType, checker::Type *targetType); + [[nodiscard]] checker::Type *ResolveSmartType(checker::Type *sourceType, checker::Type *targetType, + std::optional value = std::nullopt); [[nodiscard]] std::pair CheckTestNullishCondition(Type *testedType, Type *actualType, bool strict); [[nodiscard]] std::pair CheckTestObjectCondition(ETSObjectType *testedType, Type *actualType, bool strict); @@ -781,15 +828,6 @@ public: static Type *TryToInstantiate(Type *type, ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes); - // Dynamic interop - template - Signature *ResolveDynamicCallExpression(ir::Expression *callee, const ArenaVector &arguments, Language lang, - bool isConstruct); - ir::ClassProperty *CreateStaticReadonlyField(const char *name); - void BuildClassBodyFromDynamicImports(const ArenaVector &dynamicImports, - ArenaVector *classBody); - void BuildDynamicImportClass(); - void BuildLambdaObjectClass(ETSObjectType *functionalInterface, ir::TypeNode *retTypeAnnotation); // Trailing lambda void EnsureValidCurlyBrace(ir::CallExpression *callExpr); @@ -840,7 +878,7 @@ public: return util::NodeAllocator::ForceSetParent(ProgramAllocator(), std::forward(args)...); } - ArenaVector &PendingConstraintCheckRecords(); + std::vector &PendingConstraintCheckRecords(); size_t &ConstraintCheckScopesCount(); ETSObjectType *GetCachedFunctionalInterface(ir::ETSFunctionType *type); @@ -865,6 +903,7 @@ public: ir::MethodDefinition *CreateClassMethod(std::string_view name, ir::ScriptFunctionFlags funcFlags, ir::ModifierFlags modifierFlags, const MethodBuilder &builder); ir::ClassDeclaration *BuildClass(util::StringView name, const ClassBuilder &builder); + const varbinder::Variable *GetTargetRef(const ir::MemberExpression *memberExpr); void LogUnresolvedReferenceError(ir::Identifier *ident); void WrongContextErrorClassifyByType(ir::Identifier *ident); @@ -884,6 +923,26 @@ public: return overloadSigContainer_; } + ObjectInstantiationMap &GetObjectInstantiationMap() + { + return objectInstantiationMap_; + } + + FunctionSignatureMap &GetInvokeToArrowSignatures() + { + return invokeToArrowSignatures_; + } + + FunctionInterfaceMap &GetArrowToFuncInterfaces() + { + return arrowToFuncInterfaces_; + } + + void ClearApparentTypes() noexcept + { + apparentTypes_.clear(); + } + void CleanUp() override { Checker::CleanUp(); @@ -891,6 +950,7 @@ public: pendingConstraintCheckRecords_.clear(); constraintCheckScopesCount_ = 0; globalArraySignatures_.clear(); + unionAssemblerTypes_.clear(); GetCachedComputedAbstracts()->clear(); for (auto &dynamicCallIntrinsicsMap : dynamicIntrinsics_) { dynamicCallIntrinsicsMap.clear(); @@ -940,7 +1000,6 @@ private: std::pair GetTargetIdentifierAndType(ir::Identifier *ident); void NotResolvedError(ir::Identifier *const ident, const varbinder::Variable *classVar, const ETSObjectType *classType); - void ValidateCallExpressionIdentifier(ir::Identifier *const ident, Type *const type); void ValidateNewClassInstanceIdentifier(ir::Identifier *const ident); void ValidateMemberIdentifier(ir::Identifier *const ident); void ValidateAssignmentIdentifier(ir::Identifier *const ident, Type *const type); @@ -958,8 +1017,8 @@ private: std::tuple IsResolvedAndValue(const ir::Expression *expr, Type *type) const; PropertySearchFlags GetSearchFlags(const ir::MemberExpression *memberExpr, const varbinder::Variable *targetRef); PropertySearchFlags GetInitialSearchFlags(const ir::MemberExpression *memberExpr); - const varbinder::Variable *GetTargetRef(const ir::MemberExpression *memberExpr); Type *GetTypeOfSetterGetter([[maybe_unused]] varbinder::Variable *var); + ETSFunctionType *CreateSyntheticTypeFromOverload(varbinder::Variable *const var); void IterateInVariableContext([[maybe_unused]] varbinder::Variable *const var); bool CheckInit(ir::Identifier *ident, ir::TypeNode *typeAnnotation, ir::Expression *init, checker::Type *annotationType, varbinder::Variable *const bindingVar); @@ -985,7 +1044,6 @@ private: ir::MethodDefinition *CreateLambdaObjectClassInvokeMethod(Signature *invokeSignature, ir::TypeNode *retTypeAnnotation); - void ClassInitializerFromImport(ir::ETSImportDeclaration *import, ArenaVector *statements); void EmitDynamicModuleClassInitCall(); DynamicCallIntrinsicsMap *DynamicCallIntrinsics(bool isConstruct) { @@ -1001,6 +1059,7 @@ private: void SetUpTypeParameterConstraint(ir::TSTypeParameter *param); ETSObjectType *UpdateGlobalType(ETSObjectType *objType, util::StringView name); + void WrapTypeNode(ir::AstNode *node); void CheckProgram(parser::Program *program, bool runAnalysis = false); void CheckWarnings(parser::Program *program, const util::Options &options); @@ -1008,15 +1067,6 @@ private: bool ComputeSuperType(ETSObjectType *type); - template - UType HandleModulo(UType leftValue, UType rightValue); - - template - Type *HandleBitWiseArithmetic(Type *leftValue, Type *rightValue, lexer::TokenType operationType); - - template - typename TargetType::UType GetOperand(Type *type); - template ETSObjectType *AsETSObjectType(Type *(GlobalTypesHolder::*typeFunctor)(Args...), Args... args) const; Signature *GetMostSpecificSignature(ArenaVector &compatibleSignatures, @@ -1028,14 +1078,15 @@ private: const lexer::SourcePosition &pos, TypeRelationFlag resolveFlags); // Trailing lambda void MoveTrailingBlockToEnclosingBlockStatement(ir::CallExpression *callExpr); + ir::ScriptFunction *CreateLambdaFunction(ir::BlockStatement *trailingBlock, Signature *sig); void TransformTraillingLambda(ir::CallExpression *callExpr, Signature *sig); ArenaVector ExtendArgumentsWithFakeLamda(ir::CallExpression *callExpr); // Static invoke bool SetStaticInvokeValues(ir::Identifier *const ident, ir::Identifier *classId, ir::Identifier *methodId, varbinder::LocalVariable *instantiateMethod); - void CreateTransformedCallee(ir::Identifier *classId, ir::Identifier *methodId, ir::Identifier *const ident, - varbinder::LocalVariable *instantiateMethod); + void CreateTransformedCallee(ir::Identifier *ident, ir::Identifier *classId, ir::Identifier *methodId, + ir::CallExpression *callExpr); bool TryTransformingToStaticInvoke(ir::Identifier *ident, const Type *resolvedType); // Partial @@ -1052,9 +1103,13 @@ private: std::unordered_set &typeAliases); ArrayMap arrayTypes_; - ArenaVector pendingConstraintCheckRecords_; + std::vector pendingConstraintCheckRecords_ {}; + ObjectInstantiationMap objectInstantiationMap_; + FunctionSignatureMap invokeToArrowSignatures_; + FunctionInterfaceMap arrowToFuncInterfaces_; size_t constraintCheckScopesCount_ {0}; GlobalArraySignatureMap globalArraySignatures_; + ArenaSet unionAssemblerTypes_; ComputedAbstracts *cachedComputedAbstracts_ {nullptr}; // NOTE(aleksisch): Extract dynamic from checker to separate class std::array dynamicIntrinsics_; @@ -1067,6 +1122,7 @@ private: evaluate::ScopedDebugInfoPlugin *debugInfoPlugin_ {nullptr}; std::unordered_set elementStack_; ArenaVector overloadSigContainer_; + ArenaSet readdedChecker_; }; } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/JSchecker.cpp b/ets2panda/checker/JSchecker.cpp index 3efe6f5b8d7bbc0d6d74297acdd42fcab796c441..62c02cc2064b2540fbdcc5551816e2681d53fa0f 100644 --- a/ets2panda/checker/JSchecker.cpp +++ b/ets2panda/checker/JSchecker.cpp @@ -23,7 +23,6 @@ namespace ark::es2panda::checker { bool JSChecker::StartChecker([[maybe_unused]] varbinder::VarBinder *varbinder, const util::Options &options) { - Initialize(varbinder); varbinder->IdentifierAnalysis(); if (options.IsDumpAst()) { diff --git a/ets2panda/checker/JSchecker.h b/ets2panda/checker/JSchecker.h index 0d0a6052089ea1bd959d2a88ca3b4774b31a2d69..3e261069aa8196ca0803ad84e0d67a53e8d9112d 100644 --- a/ets2panda/checker/JSchecker.h +++ b/ets2panda/checker/JSchecker.h @@ -23,9 +23,9 @@ namespace ark::es2panda::checker { class JSChecker : public Checker { public: // NOLINTNEXTLINE(readability-redundant-member-init) - explicit JSChecker(util::DiagnosticEngine &diagnosticEngine, - [[maybe_unused]] ArenaAllocator *programAllocator = nullptr) - : Checker(diagnosticEngine) + explicit JSChecker([[maybe_unused]] ThreadSafeArenaAllocator *allocator, util::DiagnosticEngine &diagnosticEngine, + [[maybe_unused]] ThreadSafeArenaAllocator *programAllocator = nullptr) + : Checker(allocator, diagnosticEngine, programAllocator) { } diff --git a/ets2panda/checker/SemanticAnalyzer.h b/ets2panda/checker/SemanticAnalyzer.h index b0db804c0861695bd2c965bb20e8f232feabd08c..1126ba93c03b19140c9f8c2a5b66671fcfd2a0d1 100644 --- a/ets2panda/checker/SemanticAnalyzer.h +++ b/ets2panda/checker/SemanticAnalyzer.h @@ -27,6 +27,7 @@ #include "ir/base/decorator.h" #include "ir/base/metaProperty.h" #include "ir/base/methodDefinition.h" +#include "ir/base/overloadDeclaration.h" #include "ir/base/property.h" #include "ir/base/scriptFunction.h" #include "ir/base/spreadElement.h" @@ -37,6 +38,7 @@ #include "ir/base/tsSignatureDeclaration.h" #include "ir/ets/etsClassLiteral.h" #include "ir/ets/etsFunctionType.h" +#include "ir/ets/etsIntrinsicNode.h" #include "ir/ets/etsImportDeclaration.h" #include "ir/ets/etsKeyofType.h" #include "ir/ets/etsNewArrayInstanceExpression.h" diff --git a/ets2panda/checker/TSAnalyzer.cpp b/ets2panda/checker/TSAnalyzer.cpp index cfaad3f534778bcc113cfa6f35b12ba77bdffdfb..655c154d5f62250d0c9fb34c1864a88a80a7bb09 100644 --- a/ets2panda/checker/TSAnalyzer.cpp +++ b/ets2panda/checker/TSAnalyzer.cpp @@ -74,6 +74,7 @@ checker::Type *TSAnalyzer::Check(ir::TSIndexSignature *node) const checker::ObjectDescriptor *desc = checker->Allocator()->New(checker->Allocator()); checker::ObjectType *placeholder = checker->Allocator()->New(desc); + ES2PANDA_ASSERT(placeholder != nullptr); if (node->Kind() == ir::TSIndexSignature::TSIndexSignatureKind::NUMBER) { placeholder->Desc()->numberIndexInfo = info; } else { @@ -107,6 +108,7 @@ checker::Type *TSAnalyzer::Check(ir::TSMethodSignature *node) const } returnType->Check(checker); + ES2PANDA_ASSERT(callSignature != nullptr); callSignature->SetReturnType(returnType->GetType(checker)); return nullptr; @@ -280,12 +282,13 @@ checker::Type *TSAnalyzer::Check(ir::ArrayExpression *expr) const util::StringView memberIndex = util::Helpers::ToStringView(checker->Allocator(), index); varbinder::LocalVariable *tupleMember = varbinder::Scope::CreateVar( checker->Allocator(), memberIndex, varbinder::VariableFlags::PROPERTY, nullptr); - + ES2PANDA_ASSERT(tupleMember != nullptr); if (inConstContext) { tupleMember->AddFlag(varbinder::VariableFlags::READONLY); } tupleMember->SetTsType(*it); + ES2PANDA_ASSERT(desc != nullptr); desc->properties.push_back(tupleMember); } @@ -326,7 +329,7 @@ checker::Type *TSAnalyzer::Check(ir::ArrowFunctionExpression *expr) const if (funcVar != nullptr && funcVar->TsType() == nullptr) { funcVar->SetTsType(funcType); } - + ES2PANDA_ASSERT(signature != nullptr); signature->SetReturnType(checker->HandleFunctionReturn(expr->Function())); if (!expr->Function()->Body()->IsExpression()) { @@ -569,7 +572,7 @@ checker::Type *TSAnalyzer::Check(ir::FunctionExpression *expr) const if (funcVar != nullptr && funcVar->TsType() == nullptr) { funcVar->SetTsType(funcType); } - + ES2PANDA_ASSERT(signature != nullptr); signature->SetReturnType(checker->HandleFunctionReturn(expr->Function())); expr->Function()->Body()->Check(checker); @@ -787,6 +790,7 @@ void TSAnalyzer::CheckNonComputed(checker::ObjectDescriptor *desc, ir::Expressio auto *memberVar = varbinder::Scope::CreateVar(checker->Allocator(), propName, flags, it); + ES2PANDA_ASSERT(memberVar != nullptr); if (inConstContext) { memberVar->AddFlag(varbinder::VariableFlags::READONLY); } else { @@ -798,7 +802,7 @@ void TSAnalyzer::CheckNonComputed(checker::ObjectDescriptor *desc, ir::Expressio if (prop->Key()->IsNumberLiteral()) { memberVar->AddFlag(varbinder::VariableFlags::NUMERIC_NAME); } - + ES2PANDA_ASSERT(desc != nullptr); varbinder::LocalVariable *foundMember = desc->FindProperty(propName); allPropertiesMap.insert({propName, it->Start()}); @@ -876,6 +880,7 @@ checker::Type *TSAnalyzer::Check(ir::ObjectExpression *expr) const } checker::Type *returnType = checker->Allocator()->New(desc); + ES2PANDA_ASSERT(returnType != nullptr); returnType->AsObjectType()->AddObjectFlag(checker::ObjectFlags::RESOLVED_MEMBERS | checker::ObjectFlags::CHECK_EXCESS_PROPS); return returnType; @@ -1342,6 +1347,7 @@ static void CheckSimpleVariableDeclaration(checker::TSChecker *checker, ir::Vari initializerType = checker->GetBaseTypeOfLiteralType(initializerType); } + ES2PANDA_ASSERT(initializerType != nullptr); if (initializerType->IsNullType()) { checker->ThrowTypeError( {"Cannot infer type for variable '", declarator->Id()->AsIdentifier()->Name(), "'."}, @@ -1729,10 +1735,12 @@ static void AddEnumValueDeclaration(checker::TSChecker *checker, double number, if (res == nullptr) { auto *decl = checker->Allocator()->New(memberStr); + ES2PANDA_ASSERT(decl != nullptr); decl->BindNode(variable->Declaration()->Node()); enumScope->AddDecl(checker->Allocator(), decl, ScriptExtension::TS); res = enumScope->FindLocal(memberStr, varbinder::ResolveBindingOptions::BINDINGS); ES2PANDA_ASSERT(res && res->IsEnumVariable()); + ES2PANDA_ASSERT(enumVar != nullptr); enumVar = res->AsEnumVariable(); enumVar->AsEnumVariable()->SetBackReference(); enumVar->SetTsType(checker->GlobalStringType()); @@ -1740,6 +1748,7 @@ static void AddEnumValueDeclaration(checker::TSChecker *checker, double number, ES2PANDA_ASSERT(res->IsEnumVariable()); enumVar = res->AsEnumVariable(); auto *decl = checker->Allocator()->New(memberStr); + ES2PANDA_ASSERT(decl != nullptr); decl->BindNode(variable->Declaration()->Node()); enumVar->ResetDecl(decl); } @@ -1846,6 +1855,7 @@ checker::Type *TSAnalyzer::Check(ir::TSEnumDeclaration *st) const if (enumVar->TsType() == nullptr) { checker::ScopeContext scopeCtx(checker, st->Scope()); checker::Type *enumType = InferType(checker, st->IsConst(), st); + ES2PANDA_ASSERT(enumType != nullptr); enumType->SetVariable(enumVar); enumVar->SetTsType(enumType); } @@ -1953,6 +1963,7 @@ checker::Type *TSAnalyzer::Check(ir::TSInterfaceDeclaration *st) const checker->Allocator()->New(checker->Allocator()); resolvedType = checker->Allocator()->New(checker->Allocator(), st->Id()->Name(), desc); + ES2PANDA_ASSERT(resolvedType != nullptr); resolvedType->SetVariable(var); var->SetTsType(resolvedType); } diff --git a/ets2panda/checker/TSAnalyzerUnreachable.cpp b/ets2panda/checker/TSAnalyzerUnreachable.cpp index e5c22b6907deb5347cbd8553504c68ee31ae8b77..43a987d1cbef1363bed34d02767b82d326bec5b8 100644 --- a/ets2panda/checker/TSAnalyzerUnreachable.cpp +++ b/ets2panda/checker/TSAnalyzerUnreachable.cpp @@ -48,6 +48,11 @@ checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::MethodDefinition *node) co ES2PANDA_UNREACHABLE(); } +checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::OverloadDeclaration *node) const +{ + ES2PANDA_UNREACHABLE(); +} + checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::Property *expr) const { ES2PANDA_UNREACHABLE(); @@ -84,6 +89,11 @@ checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSFunctionType *node) con ES2PANDA_UNREACHABLE(); } +checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSIntrinsicNode *node) const +{ + ES2PANDA_UNREACHABLE(); +} + checker::Type *TSAnalyzer::Check([[maybe_unused]] ir::ETSImportDeclaration *node) const { ES2PANDA_UNREACHABLE(); diff --git a/ets2panda/checker/TSchecker.cpp b/ets2panda/checker/TSchecker.cpp index 9e820dfc4d067f98c1dfe1c36f675edcd0e9ed44..4fe4acde5426a0b21f5bd43b23d7fb79f17e0d44 100644 --- a/ets2panda/checker/TSchecker.cpp +++ b/ets2panda/checker/TSchecker.cpp @@ -23,7 +23,6 @@ namespace ark::es2panda::checker { bool TSChecker::StartChecker([[maybe_unused]] varbinder::VarBinder *varbinder, const util::Options &options) { - Initialize(varbinder); varbinder->IdentifierAnalysis(); if (options.IsDumpAst()) { diff --git a/ets2panda/checker/TSchecker.h b/ets2panda/checker/TSchecker.h index 83ecaa50ca0e3d5ecf6df95e1d76e898c693a1cb..77756cb4891aa666dcdf36041f559260a12ff917 100644 --- a/ets2panda/checker/TSchecker.h +++ b/ets2panda/checker/TSchecker.h @@ -101,7 +101,7 @@ class TSMethodSignature; class ChainExpression; class VariableDeclarator; -enum class AstNodeType; +enum class AstNodeType : uint8_t; } // namespace ark::es2panda::ir namespace ark::es2panda::checker { @@ -121,8 +121,9 @@ struct TupleTypeInfo { class TSChecker : public Checker { public: // NOLINTNEXTLINE(readability-redundant-member-init) - explicit TSChecker(util::DiagnosticEngine &diagnosticEngine, [[maybe_unused]] ArenaAllocator *programAllocator) - : Checker(diagnosticEngine) + explicit TSChecker([[maybe_unused]] ThreadSafeArenaAllocator *allocator, util::DiagnosticEngine &diagnosticEngine, + [[maybe_unused]] ThreadSafeArenaAllocator *programAllocator) + : Checker(allocator, diagnosticEngine, programAllocator) { } diff --git a/ets2panda/checker/checker.cpp b/ets2panda/checker/checker.cpp index d4adeb07cc20d29c1f6cd650981628aeb2c0df7f..ab4e17a2e079d1182cf78b6a0e32ecc6eedbaa1d 100644 --- a/ets2panda/checker/checker.cpp +++ b/ets2panda/checker/checker.cpp @@ -20,8 +20,9 @@ #include "checker/types/ts/unionType.h" namespace ark::es2panda::checker { -Checker::Checker(util::DiagnosticEngine &diagnosticEngine, ArenaAllocator *programAllocator) - : allocator_(SpaceType::SPACE_TYPE_COMPILER, nullptr, true), +Checker::Checker(ThreadSafeArenaAllocator *allocator, util::DiagnosticEngine &diagnosticEngine, + ThreadSafeArenaAllocator *programAllocator) + : allocator_(allocator), programAllocator_(programAllocator), context_(this, CheckerStatus::NO_OPTS), diagnosticEngine_(diagnosticEngine) @@ -163,6 +164,11 @@ bool Checker::IsAnyError() return DiagnosticEngine().IsAnyError(); } +bool Checker::IsDeclForDynamicStaticInterop() const +{ + return Program()->IsDeclForDynamicStaticInterop(); +} + ScopeContext::ScopeContext(Checker *checker, varbinder::Scope *newScope) : checker_(checker), prevScope_(checker_->scope_), prevProgram_(checker_->Program()) { @@ -177,14 +183,16 @@ ScopeContext::ScopeContext(Checker *checker, varbinder::Scope *newScope) void Checker::CleanUp() { + if (!program_->IsASTLowered()) { + globalTypes_ = allocator_->New(allocator_); + } context_ = CheckerContext(this, CheckerStatus::NO_OPTS); - globalTypes_ = allocator_.New(&allocator_); - relation_ = allocator_.New(this); - identicalResults_.cached.clear(); - assignableResults_.cached.clear(); - comparableResults_.cached.clear(); - uncheckedCastableResults_.cached.clear(); - supertypeResults_.cached.clear(); + relation_ = allocator_->New(this); + identicalResults_.Clear(); + assignableResults_.Clear(); + comparableResults_.Clear(); + uncheckedCastableResults_.Clear(); + supertypeResults_.Clear(); typeStack_.clear(); namedTypeStack_.clear(); } diff --git a/ets2panda/checker/checker.h b/ets2panda/checker/checker.h index 8c0e0dc583d66fc04ca0e3b7c8175699eead9846..04d1c376926c01e27f3afc0cb2bc3e37180a3439 100644 --- a/ets2panda/checker/checker.h +++ b/ets2panda/checker/checker.h @@ -33,7 +33,7 @@ namespace ark::es2panda::ir { class AstNode; class Expression; class BlockStatement; -enum class AstNodeType; +enum class AstNodeType : uint8_t; } // namespace ark::es2panda::ir namespace ark::es2panda::varbinder { @@ -50,6 +50,7 @@ namespace ark::es2panda::checker { class ETSChecker; class InterfaceType; class GlobalTypesHolder; +class SemanticAnalyzer; using StringLiteralPool = std::unordered_map; using NumberLiteralPool = std::unordered_map; @@ -63,15 +64,16 @@ using ArgRange = std::pair; class Checker { public: - explicit Checker(util::DiagnosticEngine &diagnosticEngine, ArenaAllocator *programAllocator = nullptr); + explicit Checker(ThreadSafeArenaAllocator *allocator, util::DiagnosticEngine &diagnosticEngine, + ThreadSafeArenaAllocator *programAllocator = nullptr); virtual ~Checker() = default; NO_COPY_SEMANTIC(Checker); NO_MOVE_SEMANTIC(Checker); - [[nodiscard]] ArenaAllocator *Allocator() noexcept + [[nodiscard]] ThreadSafeArenaAllocator *Allocator() noexcept { - return &allocator_; + return allocator_; } [[nodiscard]] varbinder::Scope *Scope() const noexcept @@ -114,7 +116,7 @@ public: return globalTypes_; } - void SetGlobalTypes(GlobalTypesHolder *globalTypes) noexcept + void SetGlobalTypesHolder(GlobalTypesHolder *globalTypes) { globalTypes_ = globalTypes; } @@ -232,18 +234,20 @@ public: virtual void CleanUp(); - [[nodiscard]] ArenaAllocator *ProgramAllocator() + [[nodiscard]] ThreadSafeArenaAllocator *ProgramAllocator() { - return programAllocator_ == nullptr ? &allocator_ : programAllocator_; + return programAllocator_ == nullptr ? allocator_ : programAllocator_; } + bool IsDeclForDynamicStaticInterop() const; + protected: parser::Program *Program() const; void SetProgram(parser::Program *program); private: - ArenaAllocator allocator_; - ArenaAllocator *programAllocator_ {nullptr}; + ThreadSafeArenaAllocator *allocator_; + ThreadSafeArenaAllocator *programAllocator_ {nullptr}; CheckerContext context_; GlobalTypesHolder *globalTypes_ {nullptr}; TypeRelation *relation_; @@ -253,11 +257,11 @@ private: varbinder::Scope *scope_ {}; util::DiagnosticEngine &diagnosticEngine_; - RelationHolder identicalResults_ {{}, RelationType::IDENTICAL}; - RelationHolder assignableResults_ {{}, RelationType::ASSIGNABLE}; - RelationHolder comparableResults_ {{}, RelationType::COMPARABLE}; - RelationHolder uncheckedCastableResults_ {{}, RelationType::UNCHECKED_CASTABLE}; - RelationHolder supertypeResults_ {{}, RelationType::SUPERTYPE}; + RelationHolder identicalResults_ {Allocator()}; + RelationHolder assignableResults_ {Allocator()}; + RelationHolder comparableResults_ {Allocator()}; + RelationHolder uncheckedCastableResults_ {Allocator()}; + RelationHolder supertypeResults_ {Allocator()}; std::unordered_map typeStack_; std::unordered_set namedTypeStack_; @@ -479,6 +483,42 @@ private: Type *type_ {}; }; +class SignatureMatchContext { +public: + explicit SignatureMatchContext(Checker *checker, util::DiagnosticType diagnosticKind, bool isLogError = true) + : diagnosticEngine_(checker->DiagnosticEngine()), + diagnosticCheckpoint_(), + diagnosticKind_(diagnosticKind), + isLogError_(isLogError) + { + diagnosticCheckpoint_ = diagnosticEngine_.Save(); + } + + bool ValidSignatureMatchStatus() + { + std::array diagnosticCheckpoint = diagnosticEngine_.Save(); + return diagnosticCheckpoint_[diagnosticKind_] == diagnosticCheckpoint[diagnosticKind_]; + } + + ~SignatureMatchContext() + { + if (isLogError_) { + return; + } + + diagnosticEngine_.Rollback(diagnosticCheckpoint_); + } + + NO_COPY_SEMANTIC(SignatureMatchContext); + NO_MOVE_SEMANTIC(SignatureMatchContext); + +private: + util::DiagnosticEngine &diagnosticEngine_; + std::array diagnosticCheckpoint_; + util::DiagnosticType diagnosticKind_; + bool isLogError_; +}; + } // namespace ark::es2panda::checker #endif /* CHECKER_H */ diff --git a/ets2panda/checker/ets/aliveAnalyzer.cpp b/ets2panda/checker/ets/aliveAnalyzer.cpp index ff2ba27302437785434c2801d9608996fdfe6f70..e4edb04a7a1eadcccc752a94d25838480119604d 100644 --- a/ets2panda/checker/ets/aliveAnalyzer.cpp +++ b/ets2panda/checker/ets/aliveAnalyzer.cpp @@ -44,6 +44,7 @@ #include "ir/ets/etsNewClassInstanceExpression.h" #include "ir/ets/etsStructDeclaration.h" #include "ir/ts/tsInterfaceDeclaration.h" +#include "checker/ETSAnalyzerHelpers.h" #include "checker/types/globalTypesHolder.h" #include "varbinder/variable.h" #include "varbinder/declaration.h" @@ -234,6 +235,7 @@ void AliveAnalyzer::AnalyzeMethodDef(const ir::MethodDefinition *methodDef) auto *func = methodDef->Function(); + ES2PANDA_ASSERT(func != nullptr); if (func->Body() == nullptr || func->IsProxy()) { return; } @@ -241,20 +243,27 @@ void AliveAnalyzer::AnalyzeMethodDef(const ir::MethodDefinition *methodDef) status_ = LivenessStatus::ALIVE; AnalyzeStat(func->Body()); ES2PANDA_ASSERT(methodDef->TsType() && methodDef->TsType()->IsETSFunctionType()); - const auto *returnType = methodDef->TsType()->AsETSFunctionType()->FindSignature(func)->ReturnType(); + const auto *signature = methodDef->TsType()->AsETSFunctionType()->FindSignature(func); + ES2PANDA_ASSERT(signature != nullptr); + const auto *returnType = signature->ReturnType(); const auto isVoid = returnType->IsETSVoidType() || returnType == checker_->GlobalVoidType(); auto isPromiseVoid = false; - if (returnType->IsETSAsyncFuncReturnType()) { - const auto *asAsync = returnType->AsETSAsyncFuncReturnType(); - isPromiseVoid = asAsync->GetPromiseTypeArg() == checker_->GlobalETSUndefinedType(); + if (returnType->IsETSObjectType() && + returnType->AsETSObjectType()->AssemblerName() == compiler::Signatures::BUILTIN_PROMISE) { + const auto *asAsync = returnType->AsETSObjectType(); + isPromiseVoid = asAsync->TypeArguments().front() == checker_->GlobalETSUndefinedType() || + asAsync->TypeArguments().front() == checker_->GlobalVoidType(); } - if (status_ == LivenessStatus::ALIVE && !isVoid && !isPromiseVoid && !util::Helpers::IsAsyncMethod(methodDef)) { + if (status_ == LivenessStatus::ALIVE && !isVoid && !isPromiseVoid) { + ES2PANDA_ASSERT(methodDef->Function() != nullptr); if (!methodDef->Function()->HasReturnStatement()) { - checker_->LogError(diagnostic::MISSING_RETURN_STMT, {}, func->Start()); - ClearPendingExits(); + if (!util::Helpers::IsAsyncMethod(methodDef)) { + checker_->LogError(diagnostic::MISSING_RETURN_STMT, {}, func->Start()); + ClearPendingExits(); + } return; } @@ -281,8 +290,8 @@ void AliveAnalyzer::AnalyzeDoLoop(const ir::DoWhileStatement *doWhile) AnalyzeStat(doWhile->Body()); status_ = Or(status_, ResolveContinues(doWhile)); AnalyzeNode(doWhile->Test()); - ES2PANDA_ASSERT(doWhile->Test()->TsType() && doWhile->Test()->TsType()->IsConditionalExprType()); - const auto exprRes = doWhile->Test()->TsType()->ResolveConditionExpr(); + ES2PANDA_ASSERT(doWhile->Test()->TsType()); + const auto exprRes = IsConstantTestValue(doWhile->Test()); status_ = And(status_, static_cast(!std::get<0>(exprRes) || !std::get<1>(exprRes))); status_ = Or(status_, ResolveBreaks(doWhile)); } @@ -291,8 +300,8 @@ void AliveAnalyzer::AnalyzeWhileLoop(const ir::WhileStatement *whileStmt) { SetOldPendingExits(PendingExits()); AnalyzeNode(whileStmt->Test()); - ES2PANDA_ASSERT(whileStmt->Test()->TsType() && whileStmt->Test()->TsType()->IsConditionalExprType()); - const auto exprRes = whileStmt->Test()->TsType()->ResolveConditionExpr(); + ES2PANDA_ASSERT(whileStmt->Test()->TsType()); + const auto exprRes = IsConstantTestValue(whileStmt->Test()); status_ = And(status_, static_cast(!std::get<0>(exprRes) || std::get<1>(exprRes))); AnalyzeStat(whileStmt->Body()); status_ = Or(status_, ResolveContinues(whileStmt)); @@ -309,9 +318,9 @@ void AliveAnalyzer::AnalyzeForLoop(const ir::ForUpdateStatement *forStmt) if (forStmt->Test() != nullptr) { AnalyzeNode(forStmt->Test()); - ES2PANDA_ASSERT(forStmt->Test()->TsType() && forStmt->Test()->TsType()->IsConditionalExprType()); + ES2PANDA_ASSERT(forStmt->Test()->TsType()); condType = forStmt->Test()->TsType(); - std::tie(resolveType, res) = forStmt->Test()->TsType()->ResolveConditionExpr(); + std::tie(resolveType, res) = IsConstantTestValue(forStmt->Test()); status_ = From(!resolveType || res); } else { status_ = LivenessStatus::ALIVE; diff --git a/ets2panda/checker/ets/arithmetic.cpp b/ets2panda/checker/ets/arithmetic.cpp index b0b3e32efd5af3ce71e4525bf4e8fca6e88a970f..b76c779b5ae596684a2d710a8dac3be1938a5747 100644 --- a/ets2panda/checker/ets/arithmetic.cpp +++ b/ets2panda/checker/ets/arithmetic.cpp @@ -15,7 +15,7 @@ #include "arithmetic.h" -#include "checker/types/ts/nullType.h" +#include "checker/types/globalTypesHolder.h" #include "lexer/token/token.h" namespace ark::es2panda::checker { @@ -28,7 +28,7 @@ struct BinaryArithmOperands { checker::Type *reducedR; }; -static inline BinaryArithmOperands GetBinaryOperands(ETSChecker *checker, ir::BinaryExpression *expr) +static BinaryArithmOperands GetBinaryOperands(ETSChecker *checker, ir::BinaryExpression *expr) { auto typeL = expr->Left()->Check(checker); auto typeR = expr->Right()->Check(checker); @@ -48,20 +48,6 @@ static void LogOperatorCannotBeApplied(ETSChecker *checker, BinaryArithmOperands LogOperatorCannotBeApplied(checker, ops.expr->OperatorType(), ops.typeL, ops.typeR, ops.expr->Start()); } -static inline void UnboxOperands(ETSChecker *checker, BinaryArithmOperands const &ops) -{ - auto const unbox = [checker](ir::Expression *expr, Type *type, Type *reducedType) { - if (type != reducedType) { - expr->AddBoxingUnboxingFlags(checker->GetUnboxingFlag(reducedType)); - } - if (reducedType->IsETSEnumType()) { - expr->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); - } - }; - unbox(ops.expr->Left(), ops.typeL, ops.reducedL); - unbox(ops.expr->Right(), ops.typeR, ops.reducedR); -} - static inline void RepairTypeErrorsInOperands(Type **left, Type **right) { if (IsTypeError(*left)) { @@ -87,11 +73,40 @@ static inline void RepairTypeErrorWithDefault(Type **type, Type *dflt) } } -static Type *EffectiveTypeOfNumericOp(ETSChecker *checker, Type *left, Type *right) +static bool CheckOpArgsTypeEq(ETSChecker *checker, Type *left, Type *right, Type *type) { - ES2PANDA_ASSERT(left->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) && - right->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)); + return ((left != nullptr) && (right != nullptr) && checker->IsTypeIdenticalTo(left, type) && + checker->IsTypeIdenticalTo(right, type)); +} +static bool FindOpArgsType(ETSChecker *checker, Type *left, Type *right, Type *target) +{ + return (checker->Relation()->IsSupertypeOf(target, left) || checker->Relation()->IsSupertypeOf(target, right)); +} + +bool ETSChecker::CheckIfNumeric(Type *type) +{ + if (type == nullptr) { + return false; + } + if (type->IsETSPrimitiveType()) { + return type->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC); + } + auto *unboxed = MaybeUnboxInRelation(type); + return (unboxed != nullptr) && unboxed->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC); +} + +bool ETSChecker::CheckIfFloatingPoint(Type *type) +{ + if (type == nullptr) { + return false; + } + auto *unboxed = MaybeUnboxInRelation(type); + return (unboxed != nullptr) && (unboxed->IsFloatType() || unboxed->IsDoubleType()); +} + +static Type *EffectivePrimitiveTypeOfNumericOp(ETSChecker *checker, Type *left, Type *right) +{ if (left->IsDoubleType() || right->IsDoubleType()) { return checker->GlobalDoubleType(); } @@ -101,7 +116,10 @@ static Type *EffectiveTypeOfNumericOp(ETSChecker *checker, Type *left, Type *rig if (left->IsLongType() || right->IsLongType()) { return checker->GlobalLongType(); } - return checker->GlobalIntType(); + if (left->IsCharType() && right->IsCharType()) { + return checker->GlobalCharType(); + } + return checker->GlobalIntType(); // return int in case of primitive types by default } static Type *TryConvertToPrimitiveType(ETSChecker *checker, Type *type) @@ -111,99 +129,80 @@ static Type *TryConvertToPrimitiveType(ETSChecker *checker, Type *type) } if (type->IsETSIntEnumType()) { + // Pull out the type argument to BaseEnum + if (type->AsETSObjectType()->SuperType() != nullptr && + !type->AsETSObjectType()->SuperType()->TypeArguments().empty()) { + auto *baseEnumArg = type->AsETSObjectType()->SuperType()->TypeArguments()[0]; + return checker->MaybeUnboxInRelation(baseEnumArg); + } return checker->GlobalIntType(); } + if (type->IsETSStringEnumType()) { return checker->GlobalETSStringLiteralType(); } return checker->MaybeUnboxInRelation(type); } -static std::pair BinaryCoerceToPrimitives(ETSChecker *checker, Type *left, Type *right, - bool const promote) +static Type *EffectiveTypeOfNumericOp(ETSChecker *checker, Type *left, Type *right) { - Type *const unboxedL = TryConvertToPrimitiveType(checker, left); - Type *const unboxedR = TryConvertToPrimitiveType(checker, right); - if (unboxedL == nullptr || unboxedR == nullptr) { - return {nullptr, false}; - } + ES2PANDA_ASSERT(checker->CheckIfNumeric(left) && checker->CheckIfNumeric(right)); - bool const bothConst = unboxedL->IsConstantType() && unboxedR->IsConstantType(); - - if (!promote) { - return {unboxedR, bothConst}; + auto bothBoxed = left->IsETSUnboxableObject() && right->IsETSUnboxableObject(); + if (!bothBoxed) { + return EffectivePrimitiveTypeOfNumericOp(checker, left, right); } - if (unboxedL->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) && - unboxedR->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { - return {EffectiveTypeOfNumericOp(checker, unboxedL, unboxedR), bothConst}; + auto globalTypesHolder = checker->GetGlobalTypesHolder(); + if (FindOpArgsType(checker, left, right, globalTypesHolder->GlobalDoubleBuiltinType())) { + return globalTypesHolder->GlobalDoubleBuiltinType(); + } + if (FindOpArgsType(checker, left, right, globalTypesHolder->GlobalFloatBuiltinType())) { + return globalTypesHolder->GlobalFloatBuiltinType(); + } + if (FindOpArgsType(checker, left, right, globalTypesHolder->GlobalLongBuiltinType())) { + return globalTypesHolder->GlobalLongBuiltinType(); } - return {unboxedR, bothConst}; + return globalTypesHolder->GlobalIntegerBuiltinType(); // return Int for Byte, Short, Int } -Type *ETSChecker::NegateNumericType(Type *type, ir::Expression *node) +static Type *BinaryGetPromotedType(ETSChecker *checker, Type *left, Type *right, bool const promote) { - ES2PANDA_ASSERT(type->HasTypeFlag(TypeFlag::CONSTANT | TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)); - - TypeFlag typeKind = ETSType(type); - Type *result = nullptr; - - switch (typeKind) { - case TypeFlag::BYTE: { - result = CreateByteType(-(type->AsByteType()->GetValue())); - break; - } - case TypeFlag::CHAR: { - result = CreateCharType(-(type->AsCharType()->GetValue())); - break; - } - case TypeFlag::SHORT: { - result = CreateShortType(-(type->AsShortType()->GetValue())); - break; - } - case TypeFlag::INT: { - result = CreateIntType(-(type->AsIntType()->GetValue())); - break; - } - case TypeFlag::LONG: { - result = CreateLongType(-(type->AsLongType()->GetValue())); - break; - } - case TypeFlag::FLOAT: { - result = CreateFloatType(-(type->AsFloatType()->GetValue())); - break; - } - case TypeFlag::DOUBLE: { - result = CreateDoubleType(-(type->AsDoubleType()->GetValue())); - break; - } - default: { - ES2PANDA_UNREACHABLE(); - } + Type *const unboxedL = TryConvertToPrimitiveType(checker, left); + Type *const unboxedR = TryConvertToPrimitiveType(checker, right); + if (unboxedL == nullptr || unboxedR == nullptr) { + return nullptr; } - node->SetTsType(result); - return result; -} + Type *typeL = left; + Type *typeR = right; -Type *ETSChecker::HandleRelationOperationOnTypes(Type *left, Type *right, lexer::TokenType operationType) -{ - ES2PANDA_ASSERT(left->HasTypeFlag(TypeFlag::CONSTANT | TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) && - right->HasTypeFlag(TypeFlag::CONSTANT | TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)); + bool const bothBoxed = !typeL->IsETSPrimitiveType() && !typeR->IsETSPrimitiveType(); - if (left->IsDoubleType() || right->IsDoubleType()) { - return PerformRelationOperationOnTypes(left, right, operationType); + if (!promote) { + return typeR; } - if (left->IsFloatType() || right->IsFloatType()) { - return PerformRelationOperationOnTypes(left, right, operationType); + if (!bothBoxed) { + if (unboxedL->IsETSEnumType() || unboxedR->IsETSEnumType()) { + return nullptr; + } + if (!typeL->IsETSPrimitiveType()) { + typeL = checker->MaybeUnboxType(typeL); + } + if (!typeR->IsETSPrimitiveType()) { + typeR = checker->MaybeUnboxType(typeR); + } } - if (left->IsLongType() || right->IsLongType()) { - return PerformRelationOperationOnTypes(left, right, operationType); + if (checker->CheckIfNumeric(typeL) && checker->CheckIfNumeric(typeR)) { + return EffectiveTypeOfNumericOp(checker, typeL, typeR); + } + if (checker->CheckIfNumeric(typeR)) { + return typeR; } - return PerformRelationOperationOnTypes(left, right, operationType); + return typeL; } bool ETSChecker::CheckBinaryOperatorForBigInt(Type *left, Type *right, lexer::TokenType op) @@ -212,11 +211,26 @@ bool ETSChecker::CheckBinaryOperatorForBigInt(Type *left, Type *right, lexer::To return false; } - if (!left->IsETSBigIntType()) { - return false; + // Allow operations between BigInt and numeric types - number will be converted to BigInt + bool leftIsBigInt = left->IsETSBigIntType(); + bool rightIsBigInt = right->IsETSBigIntType(); + // Allow if either operand is BigInt. + // The non-BigInt operand will be converted to BigInt during lowering. + if ((leftIsBigInt && CheckIfNumeric(right)) || (rightIsBigInt && CheckIfNumeric(left))) { + switch (op) { + case lexer::TokenType::PUNCTUATOR_GREATER_THAN: + case lexer::TokenType::PUNCTUATOR_LESS_THAN: + case lexer::TokenType::PUNCTUATOR_GREATER_THAN_EQUAL: + case lexer::TokenType::PUNCTUATOR_LESS_THAN_EQUAL: + case lexer::TokenType::PUNCTUATOR_EQUAL: + case lexer::TokenType::PUNCTUATOR_NOT_EQUAL: + return true; + default: + break; + } } - if (!right->IsETSBigIntType()) { + if (!leftIsBigInt || !rightIsBigInt) { return false; } @@ -226,6 +240,7 @@ bool ETSChecker::CheckBinaryOperatorForBigInt(Type *left, Type *right, lexer::To case lexer::TokenType::PUNCTUATOR_STRICT_EQUAL: case lexer::TokenType::PUNCTUATOR_NOT_STRICT_EQUAL: case lexer::TokenType::KEYW_INSTANCEOF: + case lexer::TokenType::PUNCTUATOR_UNSIGNED_RIGHT_SHIFT: // This is handled in the main CheckBinaryOperator function return false; default: @@ -250,6 +265,53 @@ bool ETSChecker::CheckBinaryPlusMultDivOperandsForUnionType(const Type *leftType return true; } +void ETSChecker::SetGenerateValueOfFlags(std::tuple types, + std::tuple nodes) +{ + auto [leftType, rightType, _, __] = types; + auto [left, right] = nodes; + if (leftType->IsETSEnumType()) { + left->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); + } + if (rightType->IsETSEnumType()) { + right->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); + } +} + +static bool TypeIsAppropriateForArithmetic(const checker::Type *type, ETSChecker *checker) +{ + return type->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) || + (type->IsETSObjectType() && + checker->Relation()->IsSupertypeOf(checker->GetGlobalTypesHolder()->GlobalNumericBuiltinType(), type)); +} + +static checker::Type *CheckBinaryOperatorForIntEnums(ETSChecker *checker, checker::Type *const leftType, + checker::Type *const rightType) +{ + if (!leftType->IsETSEnumType() && !rightType->IsETSEnumType()) { + return nullptr; + } + if (TypeIsAppropriateForArithmetic(leftType, checker) && TypeIsAppropriateForArithmetic(rightType, checker)) { + Type *leftNumeric; + if (leftType->IsETSIntEnumType()) { + leftNumeric = checker->MaybeBoxInRelation(TryConvertToPrimitiveType(checker, leftType)); + } else { + leftNumeric = leftType; + } + + Type *rightNumeric; + if (rightType->IsETSIntEnumType()) { + rightNumeric = checker->MaybeBoxInRelation(TryConvertToPrimitiveType(checker, rightType)); + } else { + rightNumeric = rightType; + } + + return EffectiveTypeOfNumericOp(checker, leftNumeric, rightNumeric); + } + + return nullptr; +} + checker::Type *ETSChecker::CheckBinaryOperatorMulDivMod( std::tuple op, bool isEqualOp, std::tuple types) @@ -264,18 +326,13 @@ checker::Type *ETSChecker::CheckBinaryOperatorMulDivMod( return GlobalTypeError(); } - checker::Type *tsType {}; - auto const [promotedType, bothConst] = BinaryCoerceToPrimitives(this, unboxedL, unboxedR, !isEqualOp); - FlagExpressionWithUnboxing(leftType, unboxedL, left); - FlagExpressionWithUnboxing(rightType, unboxedR, right); - + auto const promotedType = BinaryGetPromotedType(this, leftType, rightType, !isEqualOp); if (!CheckBinaryPlusMultDivOperandsForUnionType(leftType, rightType, left, right)) { return GlobalTypeError(); } - if (promotedType == nullptr || !unboxedL->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) || - !unboxedR->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { - auto type = CheckBinaryOperatorForIntEnums(leftType, rightType); + if (promotedType == nullptr || !CheckIfNumeric(leftType) || !CheckIfNumeric(rightType)) { + auto type = CheckBinaryOperatorForIntEnums(this, leftType, rightType); if (type != nullptr) { return type; } @@ -283,66 +340,42 @@ checker::Type *ETSChecker::CheckBinaryOperatorMulDivMod( return GlobalTypeError(); } - if (bothConst) { - tsType = HandleArithmeticOperationOnTypes(leftType, rightType, operationType); - } - - return (tsType != nullptr) ? tsType : promotedType; -} - -checker::Type *ETSChecker::CheckBinaryOperatorForIntEnums(const checker::Type *const leftType, - const checker::Type *const rightType) -{ - if (leftType->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) && - rightType->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { - if (leftType->IsETSIntEnumType() && rightType->IsETSIntEnumType()) { - return GlobalIntType(); - } - if (leftType->IsFloatType() || rightType->IsFloatType()) { - return GlobalFloatType(); - } - if (leftType->IsDoubleType() || rightType->IsDoubleType()) { - return GlobalDoubleType(); - } - if (leftType->IsLongType() || rightType->IsLongType()) { - return GlobalLongType(); - } - return GlobalIntType(); - } - return nullptr; + return promotedType; } checker::Type *ETSChecker::CheckBinaryBitwiseOperatorForIntEnums(const checker::Type *const leftType, const checker::Type *const rightType) { - if (leftType->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) && - rightType->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { + if (!leftType->IsETSEnumType() && !rightType->IsETSEnumType()) { + return nullptr; + } + if (TypeIsAppropriateForArithmetic(leftType, this) && TypeIsAppropriateForArithmetic(rightType, this)) { if (leftType->IsETSIntEnumType() && rightType->IsETSIntEnumType()) { - return GlobalIntType(); + return GlobalIntBuiltinType(); } if (leftType->IsFloatType() || rightType->IsFloatType()) { - return GlobalIntType(); + return GlobalIntBuiltinType(); } if (leftType->IsDoubleType() || rightType->IsDoubleType()) { - return GlobalLongType(); + return GlobalLongBuiltinType(); } if (leftType->IsLongType() || rightType->IsLongType()) { - return GlobalLongType(); + return GlobalLongBuiltinType(); } - return GlobalIntType(); + return GlobalIntBuiltinType(); } return nullptr; } -checker::Type *ETSChecker::CheckBinaryOperatorPlusForEnums(const checker::Type *const leftType, - const checker::Type *const rightType) +static checker::Type *CheckBinaryOperatorPlusForEnums(ETSChecker *checker, checker::Type *const leftType, + checker::Type *const rightType) { - if (auto numericType = CheckBinaryOperatorForIntEnums(leftType, rightType); numericType != nullptr) { + if (auto numericType = CheckBinaryOperatorForIntEnums(checker, leftType, rightType); numericType != nullptr) { return numericType; } if ((leftType->IsETSStringEnumType() && (rightType->IsETSStringType() || rightType->IsETSStringEnumType())) || (rightType->IsETSStringEnumType() && (leftType->IsETSStringType() || leftType->IsETSStringEnumType()))) { - return GlobalETSStringLiteralType(); + return checker->GlobalETSStringLiteralType(); } return nullptr; } @@ -374,29 +407,19 @@ checker::Type *ETSChecker::CheckBinaryOperatorPlus( if (!CheckBinaryPlusMultDivOperandsForUnionType(leftType, rightType, left, right)) { return GlobalTypeError(); } - - auto const [promotedType, bothConst] = BinaryCoerceToPrimitives(this, unboxedL, unboxedR, !isEqualOp); - FlagExpressionWithUnboxing(leftType, unboxedL, left); - FlagExpressionWithUnboxing(rightType, unboxedR, right); - - if (promotedType == nullptr || !unboxedL->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) || - !unboxedR->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { - auto type = CheckBinaryOperatorPlusForEnums(leftType, rightType); + auto const promotedType = BinaryGetPromotedType(this, leftType, rightType, !isEqualOp); + if (promotedType == nullptr || !CheckIfNumeric(rightType) || !CheckIfNumeric(leftType)) { + auto type = CheckBinaryOperatorPlusForEnums(this, leftType, rightType); if (type != nullptr) { return type; } LogError(diagnostic::BINOP_NONARITHMETIC_TYPE, {}, pos); - return GlobalTypeError(); - } - - if (bothConst) { - return HandleArithmeticOperationOnTypes(leftType, rightType, operationType); } return promotedType; } -static checker::Type *GetBitwiseCompatibleType(ETSChecker *checker, Type *const type) +[[maybe_unused]] static checker::Type *GetBitwiseCompatibleType(ETSChecker *checker, Type *const type) { switch (checker->ETSType(type)) { case TypeFlag::BYTE: { @@ -430,8 +453,8 @@ checker::Type *ETSChecker::CheckBinaryOperatorShift( auto [left, right, operationType, pos] = op; auto [leftType, rightType, unboxedL, unboxedR] = types; - RepairTypeErrorWithDefault(&leftType, GlobalIntType()); - RepairTypeErrorWithDefault(&rightType, GlobalIntType()); + RepairTypeErrorWithDefault(&leftType, GlobalIntBuiltinType()); + RepairTypeErrorWithDefault(&rightType, GlobalIntBuiltinType()); RepairTypeErrorWithDefault(&unboxedL, GlobalIntType()); RepairTypeErrorWithDefault(&unboxedR, GlobalIntType()); @@ -440,15 +463,10 @@ checker::Type *ETSChecker::CheckBinaryOperatorShift( return GlobalTypeError(); } - auto promotedLeftType = ApplyUnaryOperatorPromotion(unboxedL, false, !isEqualOp); - auto promotedRightType = ApplyUnaryOperatorPromotion(unboxedR, false, !isEqualOp); - - FlagExpressionWithUnboxing(leftType, unboxedL, left); - FlagExpressionWithUnboxing(rightType, unboxedR, right); - - if (promotedLeftType == nullptr || !promotedLeftType->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) || - promotedRightType == nullptr || - !promotedRightType->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { + auto promotedLeftType = GetUnaryOperatorPromotedType(leftType, !isEqualOp); + auto promotedRightType = GetUnaryOperatorPromotedType(rightType, !isEqualOp); + if (promotedLeftType == nullptr || promotedRightType == nullptr || !CheckIfNumeric(promotedLeftType) || + !CheckIfNumeric(promotedRightType)) { auto type = CheckBinaryBitwiseOperatorForIntEnums(leftType, rightType); if (type != nullptr) { return type; @@ -457,10 +475,22 @@ checker::Type *ETSChecker::CheckBinaryOperatorShift( return GlobalTypeError(); } - if (promotedLeftType->HasTypeFlag(TypeFlag::CONSTANT) && promotedRightType->HasTypeFlag(TypeFlag::CONSTANT)) { - return HandleBitwiseOperationOnTypes(promotedLeftType, promotedRightType, operationType); + auto isPrim = promotedLeftType->IsETSPrimitiveType(); + auto unboxedProm = MaybeUnboxType(promotedLeftType); + if (unboxedProm->IsFloatType() || unboxedProm->IsIntType()) { + return isPrim ? GlobalIntType() : GetGlobalTypesHolder()->GlobalIntegerBuiltinType(); + } + + if (unboxedProm->IsLongType() || unboxedProm->IsDoubleType()) { + return isPrim ? GlobalLongType() : GetGlobalTypesHolder()->GlobalLongBuiltinType(); + } + + if (unboxedProm->IsByteType() || unboxedProm->IsShortType() || unboxedProm->IsCharType()) { + return promotedLeftType; } - return GetBitwiseCompatibleType(this, promotedLeftType); + + ES2PANDA_UNREACHABLE(); + return nullptr; } checker::Type *ETSChecker::CheckBinaryOperatorBitwise( @@ -481,19 +511,12 @@ checker::Type *ETSChecker::CheckBinaryOperatorBitwise( return GlobalTypeError(); } - if (unboxedL != nullptr && unboxedL->HasTypeFlag(checker::TypeFlag::ETS_BOOLEAN) && unboxedR != nullptr && - unboxedR->HasTypeFlag(checker::TypeFlag::ETS_BOOLEAN)) { - FlagExpressionWithUnboxing(leftType, unboxedL, left); - FlagExpressionWithUnboxing(rightType, unboxedR, right); - return HandleBooleanLogicalOperators(unboxedL, unboxedR, operationType); + if (CheckOpArgsTypeEq(this, unboxedL, unboxedR, GlobalETSBooleanType())) { + return GetGlobalTypesHolder()->GlobalETSBooleanBuiltinType(); } - auto const [promotedType, bothConst] = BinaryCoerceToPrimitives(this, unboxedL, unboxedR, !isEqualOp); - FlagExpressionWithUnboxing(leftType, unboxedL, left); - FlagExpressionWithUnboxing(rightType, unboxedR, right); - - if (promotedType == nullptr || !unboxedL->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) || - !unboxedR->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { + auto const promotedType = BinaryGetPromotedType(this, leftType, rightType, !isEqualOp); + if (promotedType == nullptr || !CheckIfNumeric(rightType) || !CheckIfNumeric(leftType)) { auto type = CheckBinaryBitwiseOperatorForIntEnums(leftType, rightType); if (type != nullptr) { return type; @@ -501,17 +524,27 @@ checker::Type *ETSChecker::CheckBinaryOperatorBitwise( LogError(diagnostic::OP_NONNUMERIC, {}, pos); return GlobalTypeError(); } + SetGenerateValueOfFlags(types, {left, right}); - if (bothConst) { - return HandleBitwiseOperationOnTypes(leftType, rightType, operationType); + auto isPrim = promotedType->IsETSPrimitiveType(); + auto unboxedProm = MaybeUnboxType(promotedType); + if (unboxedProm->IsFloatType() || unboxedProm->IsIntType()) { + return isPrim ? GlobalIntType() : GetGlobalTypesHolder()->GlobalIntegerBuiltinType(); } - return SelectGlobalIntegerTypeForNumeric(promotedType); + if (unboxedProm->IsLongType() || unboxedProm->IsDoubleType()) { + return isPrim ? GlobalLongType() : GetGlobalTypesHolder()->GlobalLongBuiltinType(); + } + + if (unboxedProm->IsByteType() || unboxedProm->IsShortType() || unboxedProm->IsCharType()) { + return promotedType; + } + return nullptr; } checker::Type *ETSChecker::CheckBinaryOperatorLogical(ir::Expression *left, ir::Expression *right, - ir::BinaryExpression *expr, checker::Type *leftType, - checker::Type *rightType, Type *unboxedL, Type *unboxedR) + checker::Type *leftType, checker::Type *rightType, Type *unboxedL, + Type *unboxedR) { RepairTypeErrorsInOperands(&leftType, &rightType); RepairTypeErrorsInOperands(&unboxedL, &unboxedR); @@ -524,50 +557,66 @@ checker::Type *ETSChecker::CheckBinaryOperatorLogical(ir::Expression *left, ir:: right->RemoveAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); return CreateETSUnionType({MaybeBoxExpression(left), MaybeBoxExpression(right)}); } - if (right->IsNumberLiteral() && AdjustNumberLiteralType(right->AsNumberLiteral(), rightType, leftType)) { + + if (right->IsNumberLiteral() && !left->IsNumberLiteral() && leftType->IsBuiltinNumeric()) { return leftType; } - if (left->IsNumberLiteral() && AdjustNumberLiteralType(left->AsNumberLiteral(), leftType, rightType)) { + if (left->IsNumberLiteral() && !right->IsNumberLiteral() && rightType->IsBuiltinNumeric()) { return rightType; } - if (HandleLogicalPotentialResult(left, right, expr, leftType)) { - ES2PANDA_ASSERT(expr->Result()->TsType() != nullptr); - return expr->Result()->TsType(); - } - if (IsTypeIdenticalTo(leftType, rightType)) { return GetNonConstantType(leftType); } - if (IsTypeIdenticalTo(unboxedL, unboxedR)) { - FlagExpressionWithUnboxing(leftType, unboxedL, left); - FlagExpressionWithUnboxing(rightType, unboxedR, right); - return GetNonConstantType(unboxedL); - } + return CreateETSUnionType({MaybeBoxExpression(left), MaybeBoxExpression(right)}); +} - if (unboxedL != nullptr && unboxedL->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) && unboxedR != nullptr && - unboxedR->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)) { - FlagExpressionWithUnboxing(leftType, unboxedL, left); - FlagExpressionWithUnboxing(rightType, unboxedR, right); - return EffectiveTypeOfNumericOp(this, unboxedL, unboxedR); +static bool ContainsNumbers(ETSChecker *checker, Type *tp) +{ + auto isSubtypeOfNumeric = [checker](Type *tp2) { + return checker->Relation()->IsSupertypeOf(checker->GetGlobalTypesHolder()->GlobalNumericBuiltinType(), tp2); + }; + if (isSubtypeOfNumeric(tp)) { + return true; + } + if (tp->IsETSUnionType()) { + for (auto *constituent : tp->AsETSUnionType()->ConstituentTypes()) { + if (isSubtypeOfNumeric(constituent)) { + return true; + } + } } - return CreateETSUnionType({MaybeBoxExpression(left), MaybeBoxExpression(right)}); + return false; } +// CC-OFFNXT(huge_cyclomatic_complexity, huge_cca_cyclomatic_complexity[C++]) solid logic +// NOTE: code inside this function follows the broken logic bool ETSChecker::CheckValidEqualReferenceType(checker::Type *const leftType, checker::Type *const rightType) { - auto isGlobalObjectType {[](checker::Type *const type) -> bool { - return type->IsETSObjectType() && type->AsETSObjectType()->IsGlobalETSObjectType(); + auto isRelaxedType {[&](checker::Type *const type) -> bool { + return (type->IsETSObjectType() && type->AsETSObjectType()->IsGlobalETSObjectType()) || type->IsETSAnyType() || + type->IsETSNullType() || type->IsETSUndefinedType(); }}; - // Equality expression is always allowed for Object, undefined and null - if (isGlobalObjectType(leftType) || isGlobalObjectType(rightType) || leftType->IsETSUndefinedType() || - rightType->IsETSUndefinedType() || leftType->IsETSNullType() || rightType->IsETSNullType()) { + // Equality expression is always allowed for *magic types* + if (isRelaxedType(leftType) || isRelaxedType(rightType)) { + return true; + } + + // Any two types that can be numeric are comparable + if (ContainsNumbers(this, leftType) && ContainsNumbers(this, rightType)) { return true; } + // Boolean and any type that can be numeric or char are not comparable + if ((FindOpArgsType(this, leftType, rightType, GetGlobalTypesHolder()->GlobalNumericBuiltinType()) || + FindOpArgsType(this, leftType, rightType, GetGlobalTypesHolder()->GlobalCharBuiltinType())) && + FindOpArgsType(this, leftType, rightType, GetGlobalTypesHolder()->GlobalETSBooleanBuiltinType())) { + return false; + } + // NOTE (mxlgv): Skip for unions. Required implementation of the specification section: // 7.25.6 Reference Equality Based on Actual Type (Union Equality Operators) if (leftType->IsETSUnionType()) { @@ -594,6 +643,11 @@ bool ETSChecker::CheckValidEqualReferenceType(checker::Type *const leftType, che } } + if (FindOpArgsType(this, leftType, rightType, GetGlobalTypesHolder()->GlobalNumericBuiltinType()) && + (leftType->IsETSEnumType() || rightType->IsETSEnumType())) { + return true; + } + // 7.24.5 Enumeration Relational Operators return leftType->IsETSEnumType() == rightType->IsETSEnumType(); } @@ -627,36 +681,10 @@ std::tuple ETSChecker::CheckBinaryOperatorStrictEqual(ir::Expres } tsType = GlobalETSBooleanType(); - if (rightType->IsETSDynamicType() && leftType->IsETSDynamicType()) { - return {tsType, GlobalBuiltinJSValueType()}; - } return {tsType, GlobalETSObjectType()}; } -static Type *CheckOperatorEqualDynamic(ETSChecker *checker, BinaryArithmOperands const &ops) -{ - auto left = ops.expr->Left(); - auto right = ops.expr->Right(); - // canonicalize - auto *const dynExp = left->TsType()->IsETSDynamicType() ? left : right; - auto *const otherExp = dynExp == left ? right : left; - - if (otherExp->TsType()->IsETSDynamicType()) { - return checker->GlobalBuiltinJSValueType(); - } - if (dynExp->TsType()->AsETSDynamicType()->IsConvertible(otherExp->TsType())) { - // NOTE: vpukhov. boxing flags are not set in dynamic values - return otherExp->TsType(); - } - if (otherExp->TsType()->IsETSReferenceType()) { - // have to prevent casting dyn_exp via ApplyCast without nullish flag - return checker->GlobalETSNullishObjectType(); - } - checker->LogError(diagnostic::BINOP_DYN_UNIMPLEMENTED, {}, ops.expr->Start()); - return checker->GlobalETSNullishObjectType(); -} - static Type *HandelReferenceBinaryEquality(ETSChecker *checker, BinaryArithmOperands const &ops) { [[maybe_unused]] auto const [expr, typeL, typeR, reducedL, reducedR] = ops; @@ -665,13 +693,6 @@ static Type *HandelReferenceBinaryEquality(ETSChecker *checker, BinaryArithmOper return checker->CreateETSUnionType({typeL, typeR}); } - if (typeL->IsETSEnumType() && typeR->IsETSEnumType()) { - if (checker->Relation()->IsIdenticalTo(typeL, typeR)) { - return typeL; - } - return nullptr; - } - if (typeL->IsETSReferenceType() && typeR->IsETSReferenceType()) { checker->Relation()->SetNode(expr->Left()); if (!checker->CheckValidEqualReferenceType(typeL, typeR)) { @@ -697,24 +718,19 @@ static Type *CheckBinaryOperatorEqual(ETSChecker *checker, BinaryArithmOperands { [[maybe_unused]] auto const [expr, typeL, typeR, reducedL, reducedR] = ops; - expr->Left()->RemoveAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); - expr->Right()->RemoveAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); if (typeL->IsTypeError()) { // both are errors return checker->GlobalTypeError(); } - if (typeL->IsETSDynamicType() || typeR->IsETSDynamicType()) { - return CheckOperatorEqualDynamic(checker, ops); - } - if (reducedL->IsETSBooleanType() && reducedR->IsETSBooleanType()) { if (reducedL->IsConstantType() && reducedR->IsConstantType()) { - bool res = reducedL->AsETSBooleanType()->GetValue() == reducedR->AsETSBooleanType()->GetValue(); - res = ((expr->OperatorType() == lexer::TokenType::PUNCTUATOR_EQUAL) == res); - return checker->CreateETSBooleanType(res); + return checker->GetGlobalTypesHolder()->GlobalETSBooleanBuiltinType(); } - UnboxOperands(checker, ops); - return checker->GlobalETSBooleanType(); + if (checker->CheckIfNumeric(typeL) && checker->CheckIfNumeric(typeR) && typeL->IsETSUnboxableObject() && + typeR->IsETSUnboxableObject()) { + return typeL; + } + return reducedL; } return HandelReferenceBinaryEquality(checker, ops); @@ -751,7 +767,7 @@ std::tuple ETSChecker::CheckBinaryOperatorLessGreater(ir::Expres RepairTypeErrorsInOperands(&leftType, &rightType); RepairTypeErrorsInOperands(&unboxedL, &unboxedR); if (leftType->IsTypeError()) { // both are errors - return {GlobalETSBooleanType(), GlobalTypeError()}; + return {GlobalETSBooleanBuiltinType(), GlobalTypeError()}; } if ((leftType->IsETSUnionType() || rightType->IsETSUnionType()) && @@ -760,30 +776,30 @@ std::tuple ETSChecker::CheckBinaryOperatorLessGreater(ir::Expres operationType != lexer::TokenType::PUNCTUATOR_STRICT_EQUAL && operationType != lexer::TokenType::PUNCTUATOR_NOT_STRICT_EQUAL) { LogError(diagnostic::BINOP_UNION, {}, pos); - return {GlobalETSBooleanType(), leftType}; + return {GlobalETSBooleanBuiltinType(), leftType}; } - auto *const promotedType = std::get<0>(BinaryCoerceToPrimitives(this, unboxedL, unboxedR, !isEqualOp)); - FlagExpressionWithUnboxing(leftType, unboxedL, left); - FlagExpressionWithUnboxing(rightType, unboxedR, right); + auto const promotedType = BinaryGetPromotedType(this, leftType, rightType, !isEqualOp); if (leftType->IsETSUnionType() || rightType->IsETSUnionType()) { - return {GlobalETSBooleanType(), CreateETSUnionType({MaybeBoxExpression(left), MaybeBoxExpression(right)})}; + return {GlobalETSBooleanBuiltinType(), + CreateETSUnionType({MaybeBoxExpression(left), MaybeBoxExpression(right)})}; } - if (promotedType != nullptr && (unboxedL->IsETSBooleanType() != unboxedR->IsETSBooleanType())) { + if (promotedType != nullptr && unboxedL != nullptr && unboxedR != nullptr && + unboxedL->IsETSBooleanType() != unboxedR->IsETSBooleanType()) { LogOperatorCannotBeApplied(this, operationType, leftType, rightType, pos); - return {GlobalETSBooleanType(), leftType}; + return {GlobalETSBooleanBuiltinType(), leftType}; } if (promotedType == nullptr) { if (!NonNumericTypesAreAppropriateForComparison(this, leftType, rightType)) { LogError(diagnostic::BINOP_INCOMPARABLE, {}, pos); } - return {GlobalETSBooleanType(), GlobalETSBooleanType()}; + return {GlobalETSBooleanBuiltinType(), GlobalETSBooleanBuiltinType()}; } - return {GlobalETSBooleanType(), promotedType}; + return {GlobalETSBooleanBuiltinType(), promotedType}; } std::tuple ETSChecker::CheckBinaryOperatorInstanceOf(lexer::SourcePosition pos, checker::Type *leftType, @@ -791,59 +807,137 @@ std::tuple ETSChecker::CheckBinaryOperatorInstanceOf(lexer::Sour { RepairTypeErrorsInOperands(&leftType, &rightType); if (leftType->IsTypeError()) { // both are errors - return {GlobalETSBooleanType(), GlobalTypeError()}; + return {GlobalETSBooleanBuiltinType(), GlobalTypeError()}; } - if (!IsReferenceType(leftType) || !IsReferenceType(rightType)) { + if (leftType->IsETSPrimitiveType() || rightType->IsETSPrimitiveType()) { LogError(diagnostic::BINOP_NOT_SAME, {}, pos); - return {GlobalETSBooleanType(), leftType}; - } - - if (rightType->IsETSDynamicType() && !rightType->AsETSDynamicType()->HasDecl()) { - LogError(diagnostic::INSTANCEOF_NOT_TYPE, {}, pos); - return {GlobalETSBooleanType(), leftType}; + return {GlobalETSBooleanBuiltinType(), leftType}; } - checker::Type *opType = rightType->IsETSDynamicType() ? GlobalBuiltinJSValueType() : GlobalETSObjectType(); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ComputeApparentType(rightType); + checker::Type *opType = GlobalETSObjectType(); RemoveStatus(checker::CheckerStatus::IN_INSTANCEOF_CONTEXT); - return {GlobalETSBooleanType(), opType}; + return {GlobalETSBooleanBuiltinType(), opType}; +} + +template +static void ConvertNumberLiteralTo(ir::NumberLiteral *lit, Type *toType) +{ + auto &number = lit->Number(); + number.SetValue(number.GetValueAndCastTo()); + toType->AddTypeFlag(TypeFlag::CONSTANT); + lit->SetTsType(toType); } -bool ETSChecker::AdjustNumberLiteralType(ir::NumberLiteral *const literal, Type *literalType, Type *const otherType) +template +static bool CheckNumberLiteralValue(ETSChecker *checker, ir::NumberLiteral const *const lit) { - if (otherType->IsETSObjectType() && !otherType->IsETSEnumType()) { - auto *const objectType = otherType->AsETSObjectType(); - if (objectType->HasObjectFlag(ETSObjectFlags::BUILTIN_TYPE) && !objectType->IsETSStringType()) { - literal->RemoveBoxingUnboxingFlags(GetBoxingFlag(literalType)); - literalType = MaybeUnboxInRelation(objectType); - literal->SetTsType(literalType); - literal->AddBoxingUnboxingFlags(GetBoxingFlag(literalType)); - return true; + auto const maxTo = static_cast(std::numeric_limits::max()); + auto const minTo = static_cast(std::numeric_limits::min()); + auto const val = lit->Number().GetValue(); + if (val < minTo || val > maxTo) { + checker->LogError(diagnostic::CONSTANT_VALUE_OUT_OF_RANGE, {}, lit->Start()); + return false; + } + return true; +} + +// Just to reduce the size of 'ConvertNumberLiteral' +static void ConvertIntegerNumberLiteral(ETSChecker *checker, ir::NumberLiteral *lit, ETSObjectType *fromType, + ETSObjectType *toType) +{ + if (toType->HasObjectFlag(ETSObjectFlags::BUILTIN_LONG)) { + ConvertNumberLiteralTo(lit, checker->GlobalLongBuiltinType()->Clone(checker)); + } else if (toType->HasObjectFlag(ETSObjectFlags::BUILTIN_INT)) { + if (!fromType->HasObjectFlag(ETSObjectFlags::BUILTIN_LONG) || + CheckNumberLiteralValue(checker, lit)) { + ConvertNumberLiteralTo(lit, checker->GlobalIntBuiltinType()->Clone(checker)); + } + } else if (toType->HasObjectFlag(ETSObjectFlags::BUILTIN_SHORT)) { + if (fromType->HasObjectFlag(ETSObjectFlags::BUILTIN_LONG) && + !CheckNumberLiteralValue(checker, lit)) { + return; + } + if (fromType->HasObjectFlag(ETSObjectFlags::BUILTIN_INT) && + !CheckNumberLiteralValue(checker, lit)) { + return; + } + ConvertNumberLiteralTo(lit, checker->GlobalShortBuiltinType()->Clone(checker)); + } else if (toType->HasObjectFlag(ETSObjectFlags::BUILTIN_BYTE)) { + if (fromType->HasObjectFlag(ETSObjectFlags::BUILTIN_LONG) && + !CheckNumberLiteralValue(checker, lit)) { + return; + } + if (fromType->HasObjectFlag(ETSObjectFlags::BUILTIN_INT) && + !CheckNumberLiteralValue(checker, lit)) { + return; + } + if (fromType->HasObjectFlag(ETSObjectFlags::BUILTIN_SHORT) && + !CheckNumberLiteralValue(checker, lit)) { + return; + } + ConvertNumberLiteralTo(lit, checker->GlobalByteBuiltinType()->Clone(checker)); + } +} + +static void ConvertNumberLiteral(ETSChecker *checker, ir::NumberLiteral *lit, ETSObjectType *toType) +{ + ES2PANDA_ASSERT(toType->IsBuiltinNumeric() && lit->TsType()->IsBuiltinNumeric()); + + if (auto *fromType = lit->TsType()->AsETSObjectType(); !checker->Relation()->IsIdenticalTo(fromType, toType)) { + switch (static_cast(toType->ObjectFlags() & ETSObjectFlags::BUILTIN_NUMERIC)) { + case ETSObjectFlags::BUILTIN_DOUBLE: + ConvertNumberLiteralTo(lit, checker->GlobalDoubleBuiltinType()->Clone(checker)); + break; + + case ETSObjectFlags::BUILTIN_FLOAT: + if (fromType->HasObjectFlag(ETSObjectFlags::BUILTIN_DOUBLE)) { + checker->LogError(diagnostic::INVALID_ASSIGNMNENT, {fromType, toType}, lit->Start()); + } else { + ConvertNumberLiteralTo(lit, checker->GlobalFloatBuiltinType()->Clone(checker)); + } + break; + + case ETSObjectFlags::BUILTIN_LONG: + case ETSObjectFlags::BUILTIN_INT: + case ETSObjectFlags::BUILTIN_SHORT: + case ETSObjectFlags::BUILTIN_BYTE: + if (fromType->HasObjectFlag(ETSObjectFlags::BUILTIN_FLOATING_POINT)) { + checker->LogError(diagnostic::INVALID_ASSIGNMNENT, {fromType, toType}, lit->Start()); + } else { + ConvertIntegerNumberLiteral(checker, lit, fromType, toType); + } + break; + + default: + ES2PANDA_UNREACHABLE(); } } - return false; } Type *ETSChecker::CheckBinaryOperatorNullishCoalescing(ir::Expression *left, ir::Expression *right, lexer::SourcePosition pos) { auto *leftType = left->TsType(); - if (!IsReferenceType(leftType)) { + if (leftType->IsETSPrimitiveType()) { LogError(diagnostic::COALESCE_NOT_REF, {}, pos); - return leftType; } leftType = GetNonNullishType(leftType); + ES2PANDA_ASSERT(leftType != nullptr); + if (leftType->IsTypeError()) { + ES2PANDA_ASSERT(IsAnyError()); + return GlobalTypeError(); + } - auto *rightType = MaybeBoxExpression(right); + auto *rightType = MaybeBoxType(right->TsType()); if (IsTypeIdenticalTo(leftType, rightType)) { return leftType; } // If possible and required update number literal type to the proper value (identical to left-side type) - if (right->IsNumberLiteral() && AdjustNumberLiteralType(right->AsNumberLiteral(), rightType, leftType)) { + if (right->IsNumberLiteral() && leftType->IsBuiltinNumeric()) { + ConvertNumberLiteral(this, right->AsNumberLiteral(), leftType->AsETSObjectType()); return leftType; } @@ -903,6 +997,7 @@ struct TypeParams { Type *unboxedR; }; +// CC-OFFNXT(G.FUN.01, huge_method) solid logic static std::tuple CheckBinaryOperatorHelper(ETSChecker *checker, const BinaryOperatorParams &binaryParams, const TypeParams &typeParams) @@ -913,22 +1008,23 @@ static std::tuple CheckBinaryOperatorHelper(ETSChecker *checker, checker::Type *const leftType = typeParams.leftType; checker::Type *const rightType = typeParams.rightType; checker::Type *tsType {}; + BinaryArithmOperands ops = GetBinaryOperands(checker, binaryParams.expr->AsBinaryExpression()); BinaryArithmOperands opsRepaired = RepairTypeErrorsInOperands(ops); switch (binaryParams.operationType) { case lexer::TokenType::PUNCTUATOR_LOGICAL_AND: case lexer::TokenType::PUNCTUATOR_LOGICAL_OR: { - tsType = checker->CheckBinaryOperatorLogical(left, right, binaryParams.expr->AsBinaryExpression(), leftType, - rightType, typeParams.unboxedL, typeParams.unboxedR); + tsType = checker->CheckBinaryOperatorLogical(left, right, leftType, rightType, typeParams.unboxedL, + typeParams.unboxedR); break; } case lexer::TokenType::PUNCTUATOR_STRICT_EQUAL: case lexer::TokenType::PUNCTUATOR_NOT_STRICT_EQUAL: case lexer::TokenType::PUNCTUATOR_EQUAL: case lexer::TokenType::PUNCTUATOR_NOT_EQUAL: { - if (Type *res = CheckBinaryOperatorEqual(checker, opsRepaired); res != nullptr) { - return {checker->GlobalETSBooleanType(), res}; + if (auto res = CheckBinaryOperatorEqual(checker, opsRepaired); res != nullptr) { + return {checker->GetGlobalTypesHolder()->GlobalETSBooleanBuiltinType(), res}; } [[fallthrough]]; } @@ -956,123 +1052,70 @@ static std::tuple CheckBinaryOperatorHelper(ETSChecker *checker, return {tsType, tsType}; } -namespace { -bool IsStringEnum(const ir::Expression *expr) +static void TryAddValueOfFlagToStringEnumOperand(ir::Expression *op, const ir::Expression *otherOp) { - if (expr == nullptr) { - return false; + auto type = op->TsType(); + auto otherType = otherOp->TsType(); + if (type->IsETSStringEnumType() && (otherType->IsETSStringType() || otherType->IsETSStringEnumType())) { + op->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); } - - auto type = expr->TsType(); - if (type == nullptr) { - return false; - } - - return type->IsETSStringEnumType(); } -bool IsIntEnum(const ir::Expression *expr) +static void TryAddValueOfFlagToIntEnumOperand(ir::Expression *op, const ir::Expression *otherOp) { - if (expr == nullptr) { - return false; - } - - auto type = expr->TsType(); - if (type == nullptr) { - return false; + auto type = op->TsType(); + auto otherType = otherOp->TsType(); + if (type->IsETSIntEnumType() && + ((otherType->IsETSObjectType() && otherType->AsETSObjectType()->IsBoxedPrimitive()) || + otherType->IsETSIntEnumType())) { + op->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); } - - return type->IsETSIntEnumType(); } -bool CheckNumericOperatorContext(ir::Expression *expression, lexer::TokenType op) +static void CheckEnumInOperatorContext(ir::Expression *expression, lexer::TokenType opType, ir::Expression *left, + ir::Expression *right, ETSChecker *checker) { - const bool isMultiplicative = op == lexer::TokenType::PUNCTUATOR_MULTIPLY || - op == lexer::TokenType::PUNCTUATOR_DIVIDE || op == lexer::TokenType::PUNCTUATOR_MOD; - const bool isAdditive = op == lexer::TokenType::PUNCTUATOR_PLUS || op == lexer::TokenType::PUNCTUATOR_MINUS; - const bool isShift = op == lexer::TokenType::PUNCTUATOR_LEFT_SHIFT || - op == lexer::TokenType::PUNCTUATOR_RIGHT_SHIFT || - op == lexer::TokenType::PUNCTUATOR_UNSIGNED_RIGHT_SHIFT; - const bool isRelational = - op == lexer::TokenType::PUNCTUATOR_GREATER_THAN || op == lexer::TokenType::PUNCTUATOR_GREATER_THAN_EQUAL || - op == lexer::TokenType::PUNCTUATOR_LESS_THAN || op == lexer::TokenType::PUNCTUATOR_LESS_THAN_EQUAL; - const bool isEquality = op == lexer::TokenType::PUNCTUATOR_EQUAL || op == lexer::TokenType::PUNCTUATOR_NOT_EQUAL; - const bool isBitwise = op == lexer::TokenType::PUNCTUATOR_BITWISE_AND || - op == lexer::TokenType::PUNCTUATOR_BITWISE_OR || - op == lexer::TokenType::PUNCTUATOR_BITWISE_XOR; - const bool isConditionalAndOr = - op == lexer::TokenType::PUNCTUATOR_LOGICAL_AND || op == lexer::TokenType::PUNCTUATOR_LOGICAL_OR; - - if (IsIntEnum(expression)) { - if (isMultiplicative || isAdditive || isShift || isRelational || isEquality || isBitwise || - isConditionalAndOr) { - expression->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); - } - return true; - } - return false; -} + auto [lType, rType] = std::tuple {left->TsType(), right->TsType()}; -void CheckStringOperatorContext(ir::Expression *expression, checker::Type *otherType, lexer::TokenType op) -{ - const bool isEquality = op == lexer::TokenType::PUNCTUATOR_EQUAL || op == lexer::TokenType::PUNCTUATOR_NOT_EQUAL; - const bool isRelational = - op == lexer::TokenType::PUNCTUATOR_GREATER_THAN || op == lexer::TokenType::PUNCTUATOR_GREATER_THAN_EQUAL || - op == lexer::TokenType::PUNCTUATOR_LESS_THAN || op == lexer::TokenType::PUNCTUATOR_LESS_THAN_EQUAL; - if (IsStringEnum(expression) && (otherType->IsETSStringType() || otherType->IsETSStringEnumType())) { - if (op == lexer::TokenType::PUNCTUATOR_PLUS || isRelational || isEquality) { - expression->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); + switch (opType) { + case lexer::TokenType::PUNCTUATOR_GREATER_THAN: + case lexer::TokenType::PUNCTUATOR_GREATER_THAN_EQUAL: + case lexer::TokenType::PUNCTUATOR_LESS_THAN: + case lexer::TokenType::PUNCTUATOR_LESS_THAN_EQUAL: + case lexer::TokenType::PUNCTUATOR_EQUAL: + case lexer::TokenType::PUNCTUATOR_NOT_EQUAL: { + if (lType->IsETSEnumType() && rType->IsETSEnumType() && !checker->Relation()->IsIdenticalTo(lType, rType)) { + checker->LogError(diagnostic::BINOP_INCOMPARABLE, {}, expression->Start()); + return; + } + [[fallthrough]]; } - } -} - -bool CheckRelationalOperatorsBetweenEnums(ir::Expression *left, ir::Expression *right, lexer::TokenType op) -{ - const bool isRelational = - op == lexer::TokenType::PUNCTUATOR_GREATER_THAN || op == lexer::TokenType::PUNCTUATOR_GREATER_THAN_EQUAL || - op == lexer::TokenType::PUNCTUATOR_LESS_THAN || op == lexer::TokenType::PUNCTUATOR_LESS_THAN_EQUAL; - const bool isEquality = op == lexer::TokenType::PUNCTUATOR_EQUAL || op == lexer::TokenType::PUNCTUATOR_NOT_EQUAL; - - if (((IsStringEnum(left) && IsStringEnum(right)) || - (IsIntEnum(left) && IsIntEnum(right)))) { // NOTE(psiket) In case of int enums it has been already checked in - // the CheckNumericOperatorContext function - if (isRelational || isEquality) { - left->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); - right->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); - return true; + case lexer::TokenType::PUNCTUATOR_PLUS: { + TryAddValueOfFlagToStringEnumOperand(left, right); + TryAddValueOfFlagToStringEnumOperand(right, left); + [[fallthrough]]; } - } - return false; -} - -void CheckNeedToGenerateGetValueForBinaryExpression(ir::Expression *expression) -{ - if (!expression->IsBinaryExpression()) { - return; - } - - auto binaryExpression = expression->AsBinaryExpression(); - auto op = binaryExpression->OperatorType(); - auto leftExp = binaryExpression->Left(); - auto rightExp = binaryExpression->Right(); - - // Numeric Operator Context - auto leftIsIntEnum = CheckNumericOperatorContext(leftExp, op); - auto rightIsIntEnum = CheckNumericOperatorContext(rightExp, op); - if (leftIsIntEnum || rightIsIntEnum) { - return; - } - - // String Operator Context - CheckStringOperatorContext(leftExp, rightExp->TsType(), op); - CheckStringOperatorContext(rightExp, leftExp->TsType(), op); - - // Relational operators if both are enumeration Types - if (CheckRelationalOperatorsBetweenEnums(leftExp, rightExp, op)) { - return; + case lexer::TokenType::PUNCTUATOR_MULTIPLY: + case lexer::TokenType::PUNCTUATOR_DIVIDE: + case lexer::TokenType::PUNCTUATOR_MOD: + case lexer::TokenType::PUNCTUATOR_MINUS: + case lexer::TokenType::PUNCTUATOR_LEFT_SHIFT: + case lexer::TokenType::PUNCTUATOR_RIGHT_SHIFT: + case lexer::TokenType::PUNCTUATOR_UNSIGNED_RIGHT_SHIFT: + case lexer::TokenType::PUNCTUATOR_BITWISE_AND: + case lexer::TokenType::PUNCTUATOR_BITWISE_OR: + case lexer::TokenType::PUNCTUATOR_BITWISE_XOR: + case lexer::TokenType::PUNCTUATOR_LOGICAL_AND: + case lexer::TokenType::PUNCTUATOR_LOGICAL_OR: { + TryAddValueOfFlagToIntEnumOperand(left, right); + TryAddValueOfFlagToIntEnumOperand(right, left); + break; + } + default: + // NOTE(dkofanov): What about the '+=' operation? + break; } } -} // namespace std::tuple ETSChecker::CheckArithmeticOperations( ir::Expression *expr, std::tuple op, @@ -1088,16 +1131,28 @@ std::tuple ETSChecker::CheckArithmeticOperations( if (rightType->IsETSUnionType()) { rightType = GetNonConstantType(rightType); } + CheckEnumInOperatorContext(expr, operationType, left, right, this); auto checkMap = GetCheckMap(); if (checkMap.find(operationType) != checkMap.end()) { auto check = checkMap[operationType]; auto tsType = check(this, std::make_tuple(left, right, operationType, pos), isEqualOp, std::make_tuple(leftType, rightType, unboxedL, unboxedR)); + if (tsType == nullptr) { + return {leftType, rightType}; + } + if (tsType->IsETSPrimitiveType()) { + tsType = MaybeBoxType(tsType); + } + if (left->TsType()->IsTypeError()) { + left->SetTsType(tsType); + } + if (right->TsType()->IsTypeError()) { + right->SetTsType(tsType); + } return {tsType, tsType}; } - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return CheckBinaryOperatorHelper(this, {left, right, expr, operationType, pos, isEqualOp}, {leftType, rightType, unboxedL, unboxedR}); } @@ -1110,6 +1165,8 @@ static std::tuple ResolveCheckBinaryOperatorForBigInt(ETSChecker case lexer::TokenType::PUNCTUATOR_LESS_THAN: case lexer::TokenType::PUNCTUATOR_GREATER_THAN_EQUAL: case lexer::TokenType::PUNCTUATOR_LESS_THAN_EQUAL: + case lexer::TokenType::PUNCTUATOR_EQUAL: + case lexer::TokenType::PUNCTUATOR_NOT_EQUAL: return {checker->GlobalETSBooleanType(), checker->GlobalETSBooleanType()}; default: return {leftType, rightType}; @@ -1146,8 +1203,6 @@ std::tuple ETSChecker::CheckBinaryOperator(ir::Expression *left, return {leftType, leftType}; } - CheckNeedToGenerateGetValueForBinaryExpression(expr); - const bool isLogicalExtendedOperator = (operationType == lexer::TokenType::PUNCTUATOR_LOGICAL_AND) || (operationType == lexer::TokenType::PUNCTUATOR_LOGICAL_OR); Type *unboxedL = @@ -1167,55 +1222,4 @@ std::tuple ETSChecker::CheckBinaryOperator(ir::Expression *left, std::make_tuple(leftType, rightType, unboxedL, unboxedR)); } -Type *ETSChecker::HandleArithmeticOperationOnTypes(Type *left, Type *right, lexer::TokenType operationType) -{ - ES2PANDA_ASSERT(left->HasTypeFlag(TypeFlag::CONSTANT | TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) && - right->HasTypeFlag(TypeFlag::CONSTANT | TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)); - - if (left->IsDoubleType() || right->IsDoubleType()) { - return PerformArithmeticOperationOnTypes(left, right, operationType); - } - - if (left->IsFloatType() || right->IsFloatType()) { - return PerformArithmeticOperationOnTypes(left, right, operationType); - } - - if (left->IsLongType() || right->IsLongType()) { - return PerformArithmeticOperationOnTypes(left, right, operationType); - } - - return PerformArithmeticOperationOnTypes(left, right, operationType); -} - -Type *ETSChecker::HandleBitwiseOperationOnTypes(Type *left, Type *right, lexer::TokenType operationType) -{ - ES2PANDA_ASSERT(left->HasTypeFlag(TypeFlag::CONSTANT | TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC) && - right->HasTypeFlag(TypeFlag::CONSTANT | TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)); - - if (left->IsDoubleType() || right->IsDoubleType()) { - return HandleBitWiseArithmetic(left, right, operationType); - } - - if (left->IsFloatType() || right->IsFloatType()) { - return HandleBitWiseArithmetic(left, right, operationType); - } - - if (left->IsLongType() || right->IsLongType()) { - return HandleBitWiseArithmetic(left, right, operationType); - } - - return HandleBitWiseArithmetic(left, right, operationType); -} - -void ETSChecker::FlagExpressionWithUnboxing(Type *type, Type *unboxedType, ir::Expression *typeExpression) -{ - if (type->IsETSEnumType()) { - typeExpression->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); - return; - } - if (type->IsETSObjectType() && (unboxedType != nullptr)) { - typeExpression->AddBoxingUnboxingFlags(GetUnboxingFlag(unboxedType)); - } -} - } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/ets/arithmetic.h b/ets2panda/checker/ets/arithmetic.h index aa9d61d049f7e07c92076f83b514ad491b2b0580..6ca03978bb6127cf14ad560447bfb15a78af169d 100644 --- a/ets2panda/checker/ets/arithmetic.h +++ b/ets2panda/checker/ets/arithmetic.h @@ -18,167 +18,9 @@ #include "checker/ETSchecker.h" #include "checker/ETSAnalyzer.h" +#include "checker/types/globalTypesHolder.h" namespace ark::es2panda::checker { - -template -typename TargetType::UType ETSChecker::GetOperand(Type *type) -{ - switch (ETSType(type)) { - case TypeFlag::BYTE: { - return type->AsByteType()->GetValue(); - } - case TypeFlag::CHAR: { - return type->AsCharType()->GetValue(); - } - case TypeFlag::SHORT: { - return type->AsShortType()->GetValue(); - } - case TypeFlag::INT: { - return type->AsIntType()->GetValue(); - } - case TypeFlag::LONG: { - return type->AsLongType()->GetValue(); - } - case TypeFlag::FLOAT: { - return type->AsFloatType()->GetValue(); - } - case TypeFlag::DOUBLE: { - return type->AsDoubleType()->GetValue(); - } - case TypeFlag::ETS_BOOLEAN: { - return type->AsETSBooleanType()->GetValue(); - } - default: { - ES2PANDA_UNREACHABLE(); - } - } -} - -template -Type *ETSChecker::PerformRelationOperationOnTypes(Type *left, Type *right, lexer::TokenType operationType) -{ - using UType = typename TargetType::UType; - - UType leftValue = GetOperand(left); - UType rightValue = GetOperand(right); - - bool result {}; - switch (operationType) { - case lexer::TokenType::PUNCTUATOR_LESS_THAN: { - result = leftValue < rightValue; - break; - } - case lexer::TokenType::PUNCTUATOR_LESS_THAN_EQUAL: { - result = leftValue <= rightValue; - break; - } - case lexer::TokenType::PUNCTUATOR_GREATER_THAN: { - result = leftValue > rightValue; - break; - } - case lexer::TokenType::PUNCTUATOR_GREATER_THAN_EQUAL: { - result = leftValue >= rightValue; - break; - } - case lexer::TokenType::PUNCTUATOR_STRICT_EQUAL: - case lexer::TokenType::PUNCTUATOR_EQUAL: { - result = leftValue == rightValue; - break; - } - case lexer::TokenType::PUNCTUATOR_NOT_STRICT_EQUAL: - case lexer::TokenType::PUNCTUATOR_NOT_EQUAL: { - result = leftValue != rightValue; - break; - } - default: { - ES2PANDA_UNREACHABLE(); - } - } - - return CreateETSBooleanType(result); -} - -template -Type *ETSChecker::PerformArithmeticOperationOnTypes(Type *left, Type *right, lexer::TokenType operationType) -{ - using UType = typename TargetType::UType; - - UType leftValue = GetOperand(left); - UType rightValue = GetOperand(right); - auto result = leftValue; - auto isForbiddenZeroDivision = [&rightValue]() { return std::is_integral::value && rightValue == 0; }; - - switch (operationType) { - case lexer::TokenType::PUNCTUATOR_PLUS: - case lexer::TokenType::PUNCTUATOR_PLUS_EQUAL: { - result = leftValue + rightValue; - break; - } - case lexer::TokenType::PUNCTUATOR_MINUS: - case lexer::TokenType::PUNCTUATOR_MINUS_EQUAL: { - result = leftValue - rightValue; - break; - } - case lexer::TokenType::PUNCTUATOR_DIVIDE: - case lexer::TokenType::PUNCTUATOR_DIVIDE_EQUAL: { - if (isForbiddenZeroDivision()) { - return nullptr; - } - result = leftValue / rightValue; - break; - } - case lexer::TokenType::PUNCTUATOR_MULTIPLY: - case lexer::TokenType::PUNCTUATOR_MULTIPLY_EQUAL: { - result = leftValue * rightValue; - break; - } - case lexer::TokenType::PUNCTUATOR_MOD: - case lexer::TokenType::PUNCTUATOR_MOD_EQUAL: { - if (isForbiddenZeroDivision()) { - return nullptr; - } - result = HandleModulo(leftValue, rightValue); - break; - } - default: { - ES2PANDA_UNREACHABLE(); - } - } - - return ProgramAllocator()->New(result); -} - -template <> -inline IntType::UType ark::es2panda::checker::ETSChecker::HandleModulo(IntType::UType leftValue, - IntType::UType rightValue) -{ - ES2PANDA_ASSERT(rightValue != 0); - return leftValue % rightValue; -} - -template <> -inline LongType::UType ark::es2panda::checker::ETSChecker::HandleModulo(LongType::UType leftValue, - LongType::UType rightValue) -{ - ES2PANDA_ASSERT(rightValue != 0); - return leftValue % rightValue; -} - -template <> -inline FloatType::UType ark::es2panda::checker::ETSChecker::HandleModulo(FloatType::UType leftValue, - FloatType::UType rightValue) -{ - return std::fmod(leftValue, rightValue); -} - -template <> -inline DoubleType::UType ark::es2panda::checker::ETSChecker::HandleModulo( - DoubleType::UType leftValue, DoubleType::UType rightValue) -{ - return std::fmod(leftValue, rightValue); -} - template inline IntegerUType CastIfFloat(FloatOrIntegerUType num) { @@ -188,61 +30,6 @@ inline IntegerUType CastIfFloat(FloatOrIntegerUType num) return num; } } - -template -Type *ETSChecker::HandleBitWiseArithmetic(Type *left, Type *right, lexer::TokenType operationType) -{ - using IntegerUType = typename IntegerType::UType; - using UnsignedUType = std::make_unsigned_t; - - UnsignedUType result = 0; - UnsignedUType unsignedLeftValue = CastIfFloat(GetOperand(left)); - UnsignedUType unsignedRightValue = CastIfFloat(GetOperand(right)); - - auto mask = std::numeric_limits::digits - 1U; - auto shift = unsignedRightValue & mask; - - switch (operationType) { - case lexer::TokenType::PUNCTUATOR_BITWISE_AND: - case lexer::TokenType::PUNCTUATOR_BITWISE_AND_EQUAL: { - result = unsignedLeftValue & unsignedRightValue; - break; - } - case lexer::TokenType::PUNCTUATOR_BITWISE_OR: - case lexer::TokenType::PUNCTUATOR_BITWISE_OR_EQUAL: { - result = unsignedLeftValue | unsignedRightValue; - break; - } - case lexer::TokenType::PUNCTUATOR_BITWISE_XOR: - case lexer::TokenType::PUNCTUATOR_BITWISE_XOR_EQUAL: { - result = unsignedLeftValue ^ unsignedRightValue; - break; - } - case lexer::TokenType::PUNCTUATOR_LEFT_SHIFT: - case lexer::TokenType::PUNCTUATOR_LEFT_SHIFT_EQUAL: { - static_assert(sizeof(UnsignedUType) == 4 || sizeof(UnsignedUType) == 8); - result = unsignedLeftValue << shift; - break; - } - case lexer::TokenType::PUNCTUATOR_RIGHT_SHIFT: - case lexer::TokenType::PUNCTUATOR_RIGHT_SHIFT_EQUAL: { - static_assert(sizeof(IntegerUType) == 4 || sizeof(IntegerUType) == 8); - result = static_cast(unsignedLeftValue) >> shift; // NOLINT(hicpp-signed-bitwise) - break; - } - case lexer::TokenType::PUNCTUATOR_UNSIGNED_RIGHT_SHIFT: - case lexer::TokenType::PUNCTUATOR_UNSIGNED_RIGHT_SHIFT_EQUAL: { - static_assert(sizeof(UnsignedUType) == 4 || sizeof(UnsignedUType) == 8); - result = unsignedLeftValue >> shift; - break; - } - default: { - ES2PANDA_UNREACHABLE(); - } - } - - return ProgramAllocator()->New(result); -} } // namespace ark::es2panda::checker #endif diff --git a/ets2panda/checker/ets/assignAnalyzer.cpp b/ets2panda/checker/ets/assignAnalyzer.cpp index 9ed3378f8b6291b2736918792b1958e78018b098..8d32f667b6cfffe464c40ce49c5a59cb9511617d 100644 --- a/ets2panda/checker/ets/assignAnalyzer.cpp +++ b/ets2panda/checker/ets/assignAnalyzer.cpp @@ -14,7 +14,6 @@ */ #include "assignAnalyzer.h" -#include #include "ir/base/classDefinition.h" #include "ir/base/classProperty.h" @@ -58,6 +57,7 @@ #include "varbinder/scope.h" #include "varbinder/declaration.h" #include "checker/ETSchecker.h" +#include "checker/types/gradualType.h" #include "ir/base/catchClause.h" #include "parser/program/program.h" #include "checker/types/ts/objectType.h" @@ -532,11 +532,14 @@ static bool IsInitialConstructor(const ir::AstNode *node) } const auto methodDef = node->AsMethodDefinition(); + ES2PANDA_ASSERT(methodDef != nullptr); if (methodDef->Function()->Body() == nullptr || methodDef->Function()->IsExternal()) { return false; } - const auto funcBody = node->AsMethodDefinition()->Function()->Body()->AsBlockStatement(); + const auto *func = node->AsMethodDefinition()->Function(); + ES2PANDA_ASSERT(func != nullptr); + const auto funcBody = func->Body()->AsBlockStatement(); return !(!funcBody->Statements().empty() && funcBody->Statements()[0]->IsExpressionStatement() && funcBody->Statements()[0]->AsExpressionStatement()->GetExpression()->IsCallExpression() && @@ -551,7 +554,7 @@ static bool IsInitialConstructor(const ir::AstNode *node) void AssignAnalyzer::AnalyzeMethodDef(const ir::MethodDefinition *methodDef) { auto *func = methodDef->Function(); - + ES2PANDA_ASSERT(func != nullptr); if (func->Body() == nullptr || func->IsProxy()) { return; } @@ -1204,8 +1207,11 @@ util::StringView AssignAnalyzer::GetVariableType(const ir::AstNode *node) const util::StringView AssignAnalyzer::GetVariableName(const ir::AstNode *node) const { switch (node->Type()) { - case ir::AstNodeType::CLASS_PROPERTY: - return node->AsClassProperty()->Id()->Name(); + case ir::AstNodeType::CLASS_PROPERTY: { + const ir::Identifier *identifier = node->AsClassProperty()->Id(); + ES2PANDA_ASSERT(identifier != nullptr); + return identifier->Name(); + } case ir::AstNodeType::VARIABLE_DECLARATOR: return node->AsVariableDeclarator()->Id()->AsIdentifier()->Name(); default: @@ -1213,7 +1219,7 @@ util::StringView AssignAnalyzer::GetVariableName(const ir::AstNode *node) const } } -const lexer::SourcePosition &AssignAnalyzer::GetVariablePosition(const ir::AstNode *node) const +lexer::SourcePosition AssignAnalyzer::GetVariablePosition(const ir::AstNode *node) const { switch (node->Type()) { case ir::AstNodeType::CLASS_PROPERTY: @@ -1277,7 +1283,9 @@ varbinder::Variable *AssignAnalyzer::GetBoundVariable(const ir::AstNode *node) varbinder::Variable *ret = nullptr; if (node->IsClassProperty()) { - ret = node->AsClassProperty()->Id()->Variable(); + const ir::Identifier *identifier = node->AsClassProperty()->Id(); + ES2PANDA_ASSERT(identifier != nullptr); + ret = identifier->Variable(); } else if (node->IsVariableDeclarator()) { ret = node->AsVariableDeclarator()->Id()->AsIdentifier()->Variable(); } else { @@ -1352,8 +1360,11 @@ static bool IsDefaultValueType(const Type *type, bool isNonReadonlyField) if (type == nullptr) { return false; } - return (type->IsETSPrimitiveType() || type->IsETSNeverType() || type->IsETSUndefinedType() || - type->IsETSNullType() || + if (type->IsGradualType()) { + return IsDefaultValueType(type->AsGradualType()->GetBaseType(), isNonReadonlyField); + } + return (type->IsETSPrimitiveType() || (type->IsETSObjectType() && type->AsETSObjectType()->IsBoxedPrimitive()) || + type->IsETSNeverType() || type->IsETSUndefinedType() || type->IsETSNullType() || (type->PossiblyETSUndefined() && (!type->HasTypeFlag(checker::TypeFlag::GENERIC) || (isNonReadonlyField && !CHECK_GENERIC_NON_READONLY_PROPERTIES)))); } @@ -1395,7 +1406,7 @@ void AssignAnalyzer::LetInit(const ir::AstNode *node) // check reassignment of readonly properties util::StringView type = GetVariableType(declNode); util::StringView name = GetVariableName(declNode); - const lexer::SourcePosition &pos = GetVariablePosition(node); + const lexer::SourcePosition pos = GetVariablePosition(node); auto uninit = [this](NodeId a) { uninits_.Excl(a); @@ -1460,7 +1471,7 @@ void AssignAnalyzer::CheckInit(const ir::AstNode *node) util::StringView type = GetVariableType(declNode); util::StringView name = GetVariableName(declNode); - const lexer::SourcePosition &pos = GetVariablePosition(node); + const lexer::SourcePosition pos = GetVariablePosition(node); std::stringstream ss; if (node->IsClassProperty()) { diff --git a/ets2panda/checker/ets/assignAnalyzer.h b/ets2panda/checker/ets/assignAnalyzer.h index 621a24ba9e18239450879b044fd7fa70b0bf1823..c5004e5fae3e216dadfdda8282fd03dfb64ad9d6 100644 --- a/ets2panda/checker/ets/assignAnalyzer.h +++ b/ets2panda/checker/ets/assignAnalyzer.h @@ -150,7 +150,7 @@ private: NodeId GetNodeId(const ir::AstNode *node) const; util::StringView GetVariableType(const ir::AstNode *node) const; util::StringView GetVariableName(const ir::AstNode *node) const; - const lexer::SourcePosition &GetVariablePosition(const ir::AstNode *node) const; + lexer::SourcePosition GetVariablePosition(const ir::AstNode *node) const; const ir::AstNode *GetDeclaringNode(const ir::AstNode *node); varbinder::Variable *GetBoundVariable(const ir::AstNode *node); bool VariableHasDefaultValue(const ir::AstNode *node); diff --git a/ets2panda/checker/ets/baseAnalyzer.h b/ets2panda/checker/ets/baseAnalyzer.h index 8599c5d00a4cf3d9ed0b8b8b11b719a40f323683..93ed62e4836982c61eb7fce7ea3387956c0408d1 100644 --- a/ets2panda/checker/ets/baseAnalyzer.h +++ b/ets2panda/checker/ets/baseAnalyzer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -21,7 +21,7 @@ namespace ark::es2panda::ir { class AstNode; -enum class AstNodeType; +enum class AstNodeType : uint8_t; } // namespace ark::es2panda::ir namespace ark::es2panda::checker { diff --git a/ets2panda/checker/ets/castingContext.cpp b/ets2panda/checker/ets/castingContext.cpp index 0f1c377aaa3d61389ec083ad314ea99ca5704da2..d7a3e5f069d60d2a94c69c03debb0e95d5e3db20 100644 --- a/ets2panda/checker/ets/castingContext.cpp +++ b/ets2panda/checker/ets/castingContext.cpp @@ -26,9 +26,8 @@ CastingContext::CastingContext(TypeRelation *relation, const diagnostic::Diagnos const SavedTypeRelationFlagsContext savedTypeRelationFlags(relation, flags_); relation->SetNode(data.node); - const bool isLegalBoxedPrimitiveConversion = relation->IsLegalBoxedPrimitiveConversion(data.target, data.source); relation->Result(false); - if (!relation->IsSupertypeOf(data.target, data.source) && !isLegalBoxedPrimitiveConversion) { + if (!relation->IsSupertypeOf(data.target, data.source)) { relation->IsCastableTo(data.source, data.target); // #22954 string comparison if (!relation->IsTrue() && data.source->ToString() == data.target->ToString()) { @@ -39,13 +38,6 @@ CastingContext::CastingContext(TypeRelation *relation, const diagnostic::Diagnos } } - if (isLegalBoxedPrimitiveConversion && !relation->IsTrue()) { - auto *const checker = relation->GetChecker()->AsETSChecker(); - Type *sourceUnboxedType = checker->MaybeUnboxType(data.source); - relation->GetNode()->AddBoxingUnboxingFlags(checker->GetUnboxingFlag(sourceUnboxedType)); - relation->GetNode()->AddBoxingUnboxingFlags(checker->GetBoxingFlag(data.target)); - } - uncheckedCast_ = relation->UncheckedCast(); relation->SetNode(nullptr); } diff --git a/ets2panda/checker/ets/conversion.cpp b/ets2panda/checker/ets/conversion.cpp index 345a1a4f672ee164be2b91985212a77493fc625f..90c5d2f5be896c9e5a163c814e21236480cb8378 100644 --- a/ets2panda/checker/ets/conversion.cpp +++ b/ets2panda/checker/ets/conversion.cpp @@ -16,7 +16,6 @@ #include "conversion.h" #include "checker/ets/boxingConverter.h" -#include "checker/ets/narrowingConverter.h" #include "checker/ets/unboxingConverter.h" #include "checker/ets/wideningConverter.h" #include "checker/types/ets/etsTupleType.h" @@ -35,23 +34,6 @@ void WideningPrimitive(TypeRelation *const relation, Type *const source, Type *c WideningConverter(relation->GetChecker()->AsETSChecker(), relation, target, source); } -void NarrowingPrimitive(TypeRelation *const relation, Type *const source, Type *const target) -{ - ES2PANDA_ASSERT(source->IsETSPrimitiveType() && target->IsETSPrimitiveType()); - - NarrowingConverter(relation->GetChecker()->AsETSChecker(), relation, target, source); -} - -void WideningNarrowingPrimitive(TypeRelation *const relation, ByteType *const source, CharType *const target) -{ - auto *const tempInt = relation->GetChecker()->AsETSChecker()->GetGlobalTypesHolder()->GlobalIntType(); - WideningPrimitive(relation, source, tempInt); - if (!relation->IsTrue()) { - return; - } - NarrowingPrimitive(relation, tempInt, target); -} - void WideningReference(TypeRelation *const relation, ETSObjectType *const source, ETSObjectType *const target) { relation->IsSupertypeOf(target, source); @@ -253,13 +235,6 @@ void NarrowingReference(TypeRelation *const relation, ETSObjectType *const sourc NarrowingReferenceImpl(relation, source, target); } -static inline void RollbackBoxingIfFailed(TypeRelation *const relation) -{ - if (!relation->IsTrue()) { - relation->GetNode()->SetBoxingUnboxingFlags(ir::BoxingUnboxingFlags::NONE); - } -} - ETSObjectType *Boxing(TypeRelation *const relation, Type *const source) { auto *const etsChecker = relation->GetChecker()->AsETSChecker(); @@ -268,7 +243,6 @@ ETSObjectType *Boxing(TypeRelation *const relation, Type *const source) return nullptr; } auto *const boxedType = boxed.Result()->AsETSObjectType(); - relation->GetNode()->AddBoxingUnboxingFlags(etsChecker->GetBoxingFlag(boxedType)); return boxedType; } @@ -280,7 +254,6 @@ Type *Unboxing(TypeRelation *const relation, ETSObjectType *const source) return nullptr; } auto *const unboxedType = unboxed.Result(); - relation->GetNode()->AddBoxingUnboxingFlags(etsChecker->GetUnboxingFlag(unboxedType)); return unboxedType; } @@ -292,27 +265,6 @@ void UnboxingWideningPrimitive(TypeRelation *const relation, ETSObjectType *cons } ES2PANDA_ASSERT(unboxedSource != nullptr); WideningPrimitive(relation, target, unboxedSource); - RollbackBoxingIfFailed(relation); -} - -void UnboxingNarrowingPrimitive(TypeRelation *const relation, ETSObjectType *const source, Type *const target) -{ - auto *const unboxedSource = Unboxing(relation, source); - if (!relation->IsTrue()) { - return; - } - ES2PANDA_ASSERT(unboxedSource != nullptr); - NarrowingPrimitive(relation, target, unboxedSource); -} - -void UnboxingWideningNarrowingPrimitive(TypeRelation *const relation, ETSObjectType *const source, Type *const target) -{ - auto *const unboxedSource = Unboxing(relation, source); - if (!relation->IsTrue()) { - return; - } - ES2PANDA_ASSERT(unboxedSource != nullptr); - WideningNarrowingPrimitive(relation, unboxedSource->AsByteType(), target->AsCharType()); } void NarrowingReferenceUnboxing(TypeRelation *const relation, ETSObjectType *const source, Type *const target) @@ -337,7 +289,6 @@ void BoxingWideningReference(TypeRelation *const relation, Type *const source, E } ES2PANDA_ASSERT(boxedSource != nullptr); WideningReference(relation, boxedSource, target); - RollbackBoxingIfFailed(relation); } void String(TypeRelation *const relation, Type *const source) diff --git a/ets2panda/checker/ets/conversion.h b/ets2panda/checker/ets/conversion.h index cf75be4906f1534d32e161d4088702fb7825aebc..e78b65c087e67a85ff304efbdb430ed4e6ab4620 100644 --- a/ets2panda/checker/ets/conversion.h +++ b/ets2panda/checker/ets/conversion.h @@ -23,8 +23,6 @@ namespace ark::es2panda::checker::conversion { void Identity(TypeRelation *relation, Type *source, Type *target); void WideningPrimitive(TypeRelation *relation, Type *source, Type *target); -void NarrowingPrimitive(TypeRelation *relation, Type *source, Type *target); -void WideningNarrowingPrimitive(TypeRelation *relation, ByteType *source, CharType *target); void WideningReference(TypeRelation *relation, ETSObjectType *source, ETSObjectType *target); void WideningReference(TypeRelation *relation, ETSArrayType *source, ETSObjectType *target); @@ -38,8 +36,6 @@ void NarrowingReference(TypeRelation *relation, ETSObjectType *source, ETSTupleT ETSObjectType *Boxing(TypeRelation *relation, Type *source); Type *Unboxing(TypeRelation *relation, ETSObjectType *source); -void UnboxingWideningNarrowingPrimitive(TypeRelation *relation, ETSObjectType *source, Type *target); -void UnboxingNarrowingPrimitive(TypeRelation *relation, ETSObjectType *source, Type *target); void UnboxingWideningPrimitive(TypeRelation *relation, ETSObjectType *source, Type *target); void NarrowingReferenceUnboxing(TypeRelation *relation, ETSObjectType *source, Type *target); void BoxingWideningReference(TypeRelation *relation, Type *source, ETSObjectType *target); diff --git a/ets2panda/checker/ets/dynamic.cpp b/ets2panda/checker/ets/dynamic.cpp index 90abef0f88868f0bf982a1ca26ec3b8788c9f65e..2a67acd88d5d2d5a73df5b16812ca6e63de7b950 100644 --- a/ets2panda/checker/ets/dynamic.cpp +++ b/ets2panda/checker/ets/dynamic.cpp @@ -20,8 +20,6 @@ #include "varbinder/declaration.h" #include "varbinder/varbinder.h" #include "varbinder/ETSBinder.h" -#include "checker/types/ets/etsDynamicFunctionType.h" -#include "checker/ets/dynamic/dynamicCall.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "ir/base/classProperty.h" #include "ir/base/classStaticBlock.h" @@ -50,6 +48,7 @@ namespace ark::es2panda::checker { void ProcessCheckerNode(ETSChecker *checker, ir::AstNode *node) { auto scope = compiler::NearestScope(node); + ES2PANDA_ASSERT(scope != nullptr); if (scope->IsGlobalScope()) { // NOTE(aleksisch): All classes are contained in ETSGlobal class scope (not just Global scope), // however it's parent is ETSModule. It should be fixed @@ -64,6 +63,7 @@ void ProcessCheckerNode(ETSChecker *checker, ir::AstNode *node) // however right now checker do it when called on ClassDefinition auto method = node->AsMethodDefinition(); auto func = method->Value()->AsFunctionExpression()->Function(); + ES2PANDA_ASSERT(method->Id() != nullptr); func->Id()->SetVariable(method->Id()->Variable()); } ScopeContext checkerScope(checker, scope); @@ -73,6 +73,7 @@ void ProcessCheckerNode(ETSChecker *checker, ir::AstNode *node) void ProcessScopesNode(ETSChecker *checker, ir::AstNode *node) { auto *scope = compiler::NearestScope(node); + ES2PANDA_ASSERT(scope != nullptr); if (scope->IsGlobalScope()) { // NOTE(aleksisch): All classes are contained in ETSGlobal scope, // however it's parent is ETSModule (not ETSGlobal). It should be fixed @@ -94,147 +95,6 @@ ir::ETSParameterExpression *ETSChecker::AddParam(util::StringView name, ir::Type return ProgramAllocNode(paramIdent, false, ProgramAllocator()); } -template -ir::MethodDefinition *ETSChecker::CreateDynamicCallIntrinsic(ir::Expression *callee, const ArenaVector &arguments, - Language lang) -{ - ArenaVector params(ProgramAllocator()->Adapter()); - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto dynamicTypeNode = ProgramAllocNode(GlobalBuiltinDynamicType(lang), ProgramAllocator()); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto intTypeNode = ProgramAllocNode(ir::PrimitiveType::INT, ProgramAllocator()); - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *objParam = AddParam("obj", dynamicTypeNode); - params.push_back(objParam); - - ir::ETSParameterExpression *param2; - if (!DynamicCall::IsByValue(VarBinder()->AsETSBinder(), callee)) { - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - param2 = AddParam("qname_start", intTypeNode); - params.push_back(param2); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - param2 = AddParam("qname_len", intTypeNode->Clone(ProgramAllocator(), nullptr)); - } else { - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - param2 = AddParam("this", dynamicTypeNode->Clone(ProgramAllocator(), nullptr)); - } - - params.push_back(param2); - - for (size_t i = 0; i < arguments.size(); i++) { - util::UString paramName("p" + std::to_string(i), ProgramAllocator()); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto paramType = arguments[i]->TsType()->IsLambdaObject() - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ? dynamicTypeNode->Clone(ProgramAllocator(), nullptr) - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - : ProgramAllocNode(arguments[i]->TsType(), ProgramAllocator()); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - params.emplace_back(AddParam(paramName.View(), paramType)); - } - - auto funcSignature = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ir::FunctionSignature(nullptr, std::move(params), dynamicTypeNode->Clone(ProgramAllocator(), nullptr)); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *func = ProgramAllocNode( - ProgramAllocator(), - ir::ScriptFunction::ScriptFunctionData {nullptr, std::move(funcSignature), ir::ScriptFunctionFlags::METHOD, - ir::ModifierFlags::NONE}); - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *name = ProgramAllocNode(compiler::Signatures::STATIC_INVOKE_METHOD, ProgramAllocator()); - func->SetIdent(name); - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *funcExpr = ProgramAllocNode(func); - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *method = ProgramAllocNode( - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ir::MethodDefinitionKind::METHOD, func->Id()->Clone(ProgramAllocator(), nullptr), funcExpr, - ir::ModifierFlags::PUBLIC | ir::ModifierFlags::NATIVE | ir::ModifierFlags::STATIC, ProgramAllocator(), false); - return method; -} - -static void ToString(ETSChecker *checker, const ArenaVector &arguments, std::stringstream &ss) -{ - for (auto *arg : arguments) { - auto type = arg->Check(checker); - ss << "-"; - type->ToString(ss); - } -} - -static void ToString([[maybe_unused]] ETSChecker *checker, const ArenaVector &arguments, - std::stringstream &ss) -{ - for (auto *arg : arguments) { - auto *type = arg->TsType(); - ss << "-"; - type->ToString(ss); - } -} - -template -Signature *ETSChecker::ResolveDynamicCallExpression(ir::Expression *callee, const ArenaVector &arguments, - Language lang, bool isConstruct) -{ - auto &dynamicIntrinsics = *DynamicCallIntrinsics(isConstruct); - - auto mapIt = dynamicIntrinsics.find(lang); - if (mapIt == dynamicIntrinsics.cend()) { - std::tie(mapIt, std::ignore) = dynamicIntrinsics.emplace(lang, ProgramAllocator()->Adapter()); - } - - auto &map = mapIt->second; - - std::stringstream ss; - ss << "dyncall"; - if (DynamicCall::IsByValue(VarBinder()->AsETSBinder(), callee)) { - ss << "-byvalue"; - } else { - const auto callNames = DynamicCall::ResolveCall(VarBinder()->AsETSBinder(), callee); - DynamicCallNames(isConstruct)->try_emplace(callNames.name, 0); - } - - ToString(this, arguments, ss); - - auto key = ss.str(); - auto it = map.find(util::StringView(key)); - if (it == map.end()) { - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto klass = GetDynamicClass(lang, isConstruct); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *method = CreateDynamicCallIntrinsic(callee, arguments, lang); - auto props = ArenaVector(ProgramAllocator()->Adapter()); - props.emplace_back(method); - klass->Definition()->AddProperties(std::move(props)); - - { - auto prevClass = VarBinder()->AsETSBinder()->GetGlobalRecordTable()->ClassDefinition(); - VarBinder()->AsETSBinder()->GetGlobalRecordTable()->SetClassDefinition(klass->Definition()); - ProcessScopesNode(this, method); - ProcessCheckerNode(this, method); - VarBinder()->AsETSBinder()->GetGlobalRecordTable()->SetClassDefinition(prevClass); - } - method->Function()->Signature()->SetReturnType(GlobalBuiltinDynamicType(lang)); - - map.emplace(util::UString(key, ProgramAllocator()).View(), method->Function()); - return method->Function()->Signature(); - } - - return it->second->Signature(); -} - -template Signature *ETSChecker::ResolveDynamicCallExpression( - ir::Expression *callee, const ArenaVector &arguments, Language lang, bool isConstruct); - -template Signature *ETSChecker::ResolveDynamicCallExpression( - ir::Expression *callee, const ArenaVector &arguments, Language lang, bool isConstruct); - std::pair ETSChecker::CreateStaticScriptFunction( ClassInitializerBuilder const &builder) { @@ -260,6 +120,7 @@ std::pair ETSChecker::CreateStaticScript ir::ModifierFlags::STATIC, }); // clang-format on + ES2PANDA_ASSERT(func != nullptr); func->SetIdent(id); return std::make_pair(func, id); @@ -286,6 +147,7 @@ std::pair ETSChecker::CreateScriptFuncti ir::ScriptFunctionFlags::CONSTRUCTOR | ir::ScriptFunctionFlags::EXPRESSION, ir::ModifierFlags::PUBLIC}); + ES2PANDA_ASSERT(func != nullptr); func->SetIdent(id); return std::make_pair(func, id); @@ -302,6 +164,7 @@ ir::ClassStaticBlock *ETSChecker::CreateClassStaticInitializer(const ClassInitia // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *staticBlock = ProgramAllocNode(funcExpr, ProgramAllocator()); + ES2PANDA_ASSERT(staticBlock != nullptr); staticBlock->AddModifier(ir::ModifierFlags::STATIC); return staticBlock; @@ -325,33 +188,6 @@ ir::MethodDefinition *ETSChecker::CreateClassInstanceInitializer(const ClassInit return ctor; } -ir::ClassStaticBlock *ETSChecker::CreateDynamicCallClassInitializer(Language lang, bool isConstruct) -{ - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return CreateClassStaticInitializer( - [this, lang, isConstruct](ArenaVector *statements, - [[maybe_unused]] ArenaVector *params) { - auto [builtin_class_name, builtin_method_name] = - util::Helpers::SplitSignature(isConstruct ? compiler::Signatures::Dynamic::InitNewClassBuiltin(lang) - : compiler::Signatures::Dynamic::InitCallClassBuiltin(lang)); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *classId = ProgramAllocNode(builtin_class_name, ProgramAllocator()); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *methodId = ProgramAllocNode(builtin_method_name, ProgramAllocator()); - auto *callee = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(classId, methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, - false, false); - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *initCall = ProgramAllocNode( - callee, ArenaVector(ProgramAllocator()->Adapter()), nullptr, false); - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - statements->push_back(ProgramAllocNode(initCall)); - }); -} - ir::ClassDeclaration *ETSChecker::BuildClass(util::StringView name, const ClassBuilder &builder) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -365,7 +201,7 @@ ir::ClassDeclaration *ETSChecker::BuildClass(util::StringView name, const ClassB // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *classDecl = ProgramAllocNode(classDef, ProgramAllocator()); - VarBinder()->Program()->Ast()->Statements().push_back(classDecl); + VarBinder()->Program()->Ast()->AddStatement(classDecl); classDecl->SetParent(VarBinder()->Program()->Ast()); auto varBinder = VarBinder()->AsETSBinder(); @@ -385,94 +221,6 @@ ir::ClassDeclaration *ETSChecker::BuildClass(util::StringView name, const ClassB return classDecl; } -ir::ClassProperty *ETSChecker::CreateStaticReadonlyField(const char *name) -{ - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *fieldIdent = ProgramAllocNode(name, ProgramAllocator()); - auto flags = ir::ModifierFlags::STATIC | ir::ModifierFlags::PRIVATE | ir::ModifierFlags::READONLY; - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *field = ProgramAllocNode( - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - fieldIdent, nullptr, ProgramAllocNode(ir::PrimitiveType::INT, ProgramAllocator()), flags, - ProgramAllocator(), false); - return field; -} - -ir::ClassDeclaration *ETSChecker::GetDynamicClass(Language lang, bool isConstruct) -{ - auto &klasses = dynamicClasses_[static_cast(isConstruct)]; - if (klasses.count(lang) != 0U) { - return klasses[lang]; - } - auto className = - isConstruct ? compiler::Signatures::Dynamic::NewClass(lang) : compiler::Signatures::Dynamic::CallClass(lang); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto klass = BuildClass(className, [this, lang, isConstruct](ArenaVector *classBody) { - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - classBody->push_back(CreateStaticReadonlyField("qname_start_from")); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - classBody->push_back(CreateDynamicCallClassInitializer(lang, isConstruct)); - }); - klasses.emplace(lang, klass); - return klass; -} - -void ETSChecker::ClassInitializerFromImport(ir::ETSImportDeclaration *import, ArenaVector *statements) -{ - auto builtin = compiler::Signatures::Dynamic::LoadModuleBuiltin(import->Language()); - auto [builtin_class_name, builtin_method_name] = util::Helpers::SplitSignature(builtin); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *classId = ProgramAllocNode(builtin_class_name, ProgramAllocator()); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *methodId = ProgramAllocNode(builtin_method_name, ProgramAllocator()); - auto *callee = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(classId, methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, - false); - - // NOTE: #23698. Make 'ohmUrl' mandatory in 'dynamicPaths'. - util::StringView ohmUrl = util::UString(import->OhmUrl(), ProgramAllocator()).View(); - if (ohmUrl.Empty()) { - ohmUrl = import->ResolvedSource(); - if (ark::os::file::File::IsRegularFile(ohmUrl.Mutf8())) { - ohmUrl = util::UString(ark::os::RemoveExtension(ohmUrl.Mutf8()), ProgramAllocator()).View(); - } - } - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ArenaVector callParams({ProgramAllocNode(ohmUrl)}, - ProgramAllocator()->Adapter()); - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *loadCall = ProgramAllocNode(callee, std::move(callParams), nullptr, false); - auto *moduleClassId = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(compiler::Signatures::DYNAMIC_MODULE_CLASS, ProgramAllocator()); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *fieldId = ProgramAllocNode(import->AssemblerName(), ProgramAllocator()); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *property = ProgramAllocNode(moduleClassId, fieldId, - ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); - - auto *initializer = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(property, loadCall, lexer::TokenType::PUNCTUATOR_SUBSTITUTION); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - statements->push_back(ProgramAllocNode(initializer)); -} - -ir::ClassStaticBlock *ETSChecker::CreateDynamicModuleClassInitializer( - const std::vector &imports) -{ - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return CreateClassStaticInitializer([this, imports](ArenaVector *statements, - [[maybe_unused]] ArenaVector *params) { - for (auto *import : imports) { - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ClassInitializerFromImport(import, statements); - } - }); -} - ir::MethodDefinition *ETSChecker::CreateClassMethod(const std::string_view name, ir::ScriptFunctionFlags funcFlags, ir::ModifierFlags modifierFlags, const MethodBuilder &builder) { @@ -510,227 +258,4 @@ ir::MethodDefinition *ETSChecker::CreateClassMethod(const std::string_view name, return method; } -ir::MethodDefinition *ETSChecker::CreateDynamicModuleClassInitMethod() -{ - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return CreateClassMethod(compiler::Signatures::DYNAMIC_MODULE_CLASS_INIT, ir::ScriptFunctionFlags::METHOD, - ir::ModifierFlags::PUBLIC | ir::ModifierFlags::STATIC, - [this]([[maybe_unused]] ArenaVector *statements, - [[maybe_unused]] ArenaVector *params, - Type **returnType) { *returnType = GlobalVoidType(); }); -} - -ir::MethodDefinition *ETSChecker::CreateLambdaObjectClassInvokeMethod(Signature *invokeSignature, - ir::TypeNode *retTypeAnnotation) -{ - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return CreateClassMethod( - compiler::Signatures::LAMBDA_OBJECT_INVOKE, ir::ScriptFunctionFlags::METHOD, ir::ModifierFlags::PUBLIC, - [this, invokeSignature, retTypeAnnotation](ArenaVector *statements, - ArenaVector *params, Type **returnType) { - util::UString thisParamName(std::string("this"), ProgramAllocator()); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ir::ETSParameterExpression *thisParam = AddParam(thisParamName.View(), nullptr); - params->push_back(thisParam); - - ArenaVector callParams(ProgramAllocator()->Adapter()); - for (auto *invokeParam : invokeSignature->Params()) { - auto paramName = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - util::UString(std::string("p") + std::to_string(callParams.size()), ProgramAllocator()).View(); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *param = AddParam(paramName, - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(invokeParam->TsType(), ProgramAllocator())); - params->push_back(param); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - callParams.push_back(param->Clone(ProgramAllocator(), nullptr)); - } - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *properyId = ProgramAllocNode("jsvalue_lambda", ProgramAllocator()); - auto *callee = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(thisParam->Clone(ProgramAllocator(), nullptr), properyId, - ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *callLambda = ProgramAllocNode(callee, std::move(callParams), nullptr, false); - - auto *castToRetTypeExpr = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(callLambda, retTypeAnnotation->Clone(ProgramAllocator(), nullptr), - false); - castToRetTypeExpr->SetTsType(invokeSignature->ReturnType()); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *retStatement = ProgramAllocNode(castToRetTypeExpr); - statements->push_back(retStatement); - - *returnType = invokeSignature->ReturnType(); - }); -} - -void ETSChecker::EmitDynamicModuleClassInitCall() -{ - auto *globalClass = VarBinder()->Program()->GlobalClass(); - auto &body = globalClass->Body(); - auto it = std::find_if(body.begin(), body.end(), [](ir::AstNode *node) { return node->IsClassStaticBlock(); }); - - ES2PANDA_ASSERT(it != body.end()); - - auto *staticBlock = (*it)->AsClassStaticBlock(); - auto *cctorBody = staticBlock->Function()->Body()->AsBlockStatement(); - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *classId = ProgramAllocNode(compiler::Signatures::DYNAMIC_MODULE_CLASS, ProgramAllocator()); - auto *methodId = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(compiler::Signatures::DYNAMIC_MODULE_CLASS_INIT, ProgramAllocator()); - auto *callee = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(classId, methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, - false); - - ArenaVector callParams(ProgramAllocator()->Adapter()); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *initCall = ProgramAllocNode(callee, std::move(callParams), nullptr, false); - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *const node = ProgramAllocNode(initCall); - node->SetParent(cctorBody); - cctorBody->Statements().push_back(node); - - ProcessScopesNode(this, node); - ProcessCheckerNode(this, node); -} - -void ETSChecker::BuildClassBodyFromDynamicImports(const ArenaVector &dynamicImports, - ArenaVector *classBody) -{ - std::unordered_set fields; - std::vector imports; - - for (auto *import : dynamicImports) { - auto source = import->Source()->Str(); - if (fields.find(source) != fields.cend()) { - continue; - } - - auto assemblyName = std::string(source); - std::replace_if( - assemblyName.begin(), assemblyName.end(), [](char c) { return std::isalnum(c) == 0; }, '_'); - assemblyName.append(std::to_string(fields.size())); - - import->AssemblerName() = util::UString(assemblyName, ProgramAllocator()).View(); - fields.insert(import->AssemblerName()); - imports.push_back(import); - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *fieldIdent = ProgramAllocNode(import->AssemblerName(), ProgramAllocator()); - auto flags = ir::ModifierFlags::STATIC | ir::ModifierFlags::PUBLIC | ir::ModifierFlags::READONLY; - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *field = ProgramAllocNode( - fieldIdent, nullptr, - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(GlobalBuiltinDynamicType(import->Language()), ProgramAllocator()), - flags, ProgramAllocator(), false); - - classBody->push_back(field); - } - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - classBody->push_back(CreateDynamicModuleClassInitializer(imports)); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - classBody->push_back(CreateDynamicModuleClassInitMethod()); -} - -void ETSChecker::BuildDynamicImportClass() -{ - const auto &dynamicImports = VarBinder()->AsETSBinder()->DynamicImports(); - if (dynamicImports.empty()) { - return; - } - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - BuildClass(compiler::Signatures::DYNAMIC_MODULE_CLASS, - [this, dynamicImports](ArenaVector *classBody) { - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - BuildClassBodyFromDynamicImports(dynamicImports, classBody); - }); - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - EmitDynamicModuleClassInitCall(); -} - -ir::MethodDefinition *ETSChecker::CreateLambdaObjectClassInitializer(ETSObjectType *functionalInterface) -{ - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return CreateClassInstanceInitializer( - [this](ArenaVector *statements, ArenaVector *params) { - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ir::ETSParameterExpression *thisParam = AddParam(varbinder::VarBinder::MANDATORY_PARAM_THIS, nullptr); - params->push_back(thisParam); - - util::UString jsvalueParamName(std::string("jsvalue_param"), ProgramAllocator()); - ir::ETSParameterExpression *jsvalueParam = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - AddParam(jsvalueParamName.View(), - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(GlobalBuiltinJSValueType(), ProgramAllocator())); - params->push_back(jsvalueParam); - auto *moduleClassId = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(varbinder::VarBinder::MANDATORY_PARAM_THIS, ProgramAllocator()); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *fieldId = ProgramAllocNode("jsvalue_lambda", ProgramAllocator()); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *property = ProgramAllocNode( - moduleClassId, fieldId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *initializer = ProgramAllocNode( - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - property, jsvalueParam->Clone(ProgramAllocator(), nullptr), lexer::TokenType::PUNCTUATOR_SUBSTITUTION); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - statements->push_back(ProgramAllocNode(initializer)); - }, - functionalInterface); -} - -void ETSChecker::BuildLambdaObjectClass(ETSObjectType *functionalInterface, ir::TypeNode *retTypeAnnotation) -{ - auto *invokeMethod = functionalInterface->GetOwnProperty( - compiler::Signatures::STATIC_INVOKE_METHOD); - auto *invokeSignature = invokeMethod->TsType()->AsETSFunctionType()->CallSignatures()[0]; - - std::stringstream ss; - ss << compiler::Signatures::LAMBDA_OBJECT; - ToString(this, invokeSignature->Params(), ss); - auto syntheticLambdaObjName = ss.str(); - if (dynamicLambdaSignatureCache_.count(syntheticLambdaObjName) != 0) { - functionalInterface->AddConstructSignature(dynamicLambdaSignatureCache_[syntheticLambdaObjName]); - return; - } - - auto buildBody = [this, invokeSignature, retTypeAnnotation, - functionalInterface](ArenaVector *classBody) { - auto assemblyName = "jsvalue_lambda"; - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *fieldIdent = ProgramAllocNode(assemblyName, ProgramAllocator()); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *field = ProgramAllocNode( - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - fieldIdent, nullptr, ProgramAllocNode(GlobalBuiltinJSValueType(), ProgramAllocator()), - ir::ModifierFlags::PRIVATE, ProgramAllocator(), false); - classBody->push_back(field); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - classBody->push_back(CreateLambdaObjectClassInitializer(functionalInterface)); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - classBody->push_back(CreateLambdaObjectClassInvokeMethod(invokeSignature, retTypeAnnotation)); - }; - - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - BuildClass(util::StringView(syntheticLambdaObjName), buildBody); - - dynamicLambdaSignatureCache_[syntheticLambdaObjName] = functionalInterface->ConstructSignatures()[0]; -} - } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/ets/dynamic/dynamicCall.cpp b/ets2panda/checker/ets/dynamic/dynamicCall.cpp deleted file mode 100644 index a80dd1fd2d37652086e92691e3388feb4912ecd3..0000000000000000000000000000000000000000 --- a/ets2panda/checker/ets/dynamic/dynamicCall.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2021-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "checker/ets/dynamic/dynamicCall.h" - -#include "ir/ets/etsImportDeclaration.h" -#include "ir/ets/etsTypeReference.h" -#include "ir/ets/etsTypeReferencePart.h" -#include "ir/module/importSpecifier.h" -#include "ir/ts/tsQualifiedName.h" -#include "ir/expressions/memberExpression.h" - -namespace ark::es2panda::checker { - -DynamicCall::Result DynamicCall::ResolveCall(const varbinder::ETSBinder *varbinder, const ir::Expression *callee) -{ - auto calleeName = NameHolder(varbinder->Allocator()->Adapter()); - - if (callee->IsETSTypeReference()) { - // new A.B.C() => call js.new(A, ".B.C") - callee = callee->AsETSTypeReference()->Part()->Name(); - while (callee->IsTSQualifiedName()) { - auto *qname = callee->AsTSQualifiedName(); - callee = qname->Left(); - calleeName.emplace_back(qname->Right()->AsIdentifier()->Name()); - } - ES2PANDA_ASSERT(callee->IsIdentifier()); - } else if (callee->IsMemberExpression()) { - const auto memberExpr = callee->AsMemberExpression(); - callee = SqueezeExpr(memberExpr, calleeName); - } - if (callee->IsIdentifier()) { - // kinda optimization in case: - // `import X from Y` to use (load Y, call "X"), instead of (load Y, load X, call) - const auto var = callee->AsIdentifier()->Variable(); - const auto *data = varbinder->DynamicImportDataForVar(var); - if (data != nullptr && data->specifier != nullptr && data->specifier->IsImportSpecifier()) { - calleeName.emplace_back(data->specifier->AsImportSpecifier()->Imported()->Name()); - std::reverse(calleeName.begin(), calleeName.end()); - return {data->import, calleeName}; - } - } - std::reverse(calleeName.begin(), calleeName.end()); - return {callee, calleeName}; -} - -DynamicCall::Result DynamicCall::SqueezeExpr(ArenaAllocator *allocator, const ir::MemberExpression *expr) -{ - NameHolder name(allocator->Adapter()); - auto obj = SqueezeExpr(expr, name); - std::reverse(name.begin(), name.end()); - return {obj, name}; -} - -const ir::Expression *DynamicCall::SqueezeExpr(const ir::MemberExpression *memberExpr, NameHolder &name) -{ - if (!memberExpr->Object()->TsType()->IsETSDynamicType() || memberExpr->IsComputed()) { - return memberExpr; - } - ES2PANDA_ASSERT(memberExpr->Property()->IsIdentifier()); - name.emplace_back(memberExpr->Property()->AsIdentifier()->Name()); - if (memberExpr->Object()->IsMemberExpression()) { - return SqueezeExpr(memberExpr->Object()->AsMemberExpression(), name); - } - return memberExpr->Object(); -} - -} // namespace ark::es2panda::checker diff --git a/ets2panda/checker/ets/dynamic/dynamicCall.h b/ets2panda/checker/ets/dynamic/dynamicCall.h deleted file mode 100644 index b4de6cfd0a0b7bcab4e9cdace2a8997c5eff1db9..0000000000000000000000000000000000000000 --- a/ets2panda/checker/ets/dynamic/dynamicCall.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ARK_DYNAMICCALLINFO_H -#define ARK_DYNAMICCALLINFO_H - -#include - -#include "varbinder/ETSBinder.h" -#include "ir/expression.h" - -namespace ark::es2panda::checker { - -class DynamicCall { - using NameHolder = ArenaVector; - -public: - struct Result { - const ir::AstNode *obj; - const NameHolder name; // NOLINT(readability-identifier-naming) - }; - - /** - * Resolve callee - * @param varbinder - * @param callee expression used to call method - * @return callee and name from which should be used to produce call - */ - static Result ResolveCall(const varbinder::ETSBinder *varbinder, const ir::Expression *callee); - static bool IsByValue(const varbinder::ETSBinder *varbinder, const ir::Expression *callee) - { - return ResolveCall(varbinder, callee).name.empty(); - } - - /** - * Example: A[0].C.D => return: A[0], name: ".C.D" - * @param expr member expression - * @param name to store result - * @return object with remaining member expression - */ - static Result SqueezeExpr(ArenaAllocator *allocator, const ir::MemberExpression *expr); - -private: - static const ir::Expression *SqueezeExpr(const ir::MemberExpression *expr, NameHolder &name); -}; - -} // namespace ark::es2panda::checker -#endif // ARK_DYNAMICCALLINFO_H diff --git a/ets2panda/checker/ets/etsWarningAnalyzer.cpp b/ets2panda/checker/ets/etsWarningAnalyzer.cpp index f8709512c2c9bf0c646e968b59322d5613a6cfa0..f686ff057b060145f4a05ec2c80e36e202ad6338 100644 --- a/ets2panda/checker/ets/etsWarningAnalyzer.cpp +++ b/ets2panda/checker/ets/etsWarningAnalyzer.cpp @@ -34,8 +34,6 @@ #include "ir/base/classDefinition.h" #include "ir/statements/forOfStatement.h" #include "ir/statements/variableDeclarator.h" -#include "ir/statements/variableDeclaration.h" -#include "ir/expressions/updateExpression.h" namespace ark::es2panda::checker { @@ -103,10 +101,13 @@ void ETSWarningAnalyzer::AnalyzeClassMethodForFinalModifier(const ir::MethodDefi if (!potentialDescendant->IsDescendantOf(classAsETSObject)) { continue; } - const util::StringView bodyMethodName = - ETSChecker::GetSignatureFromMethodDefinition(bodyPart->AsMethodDefinition())->Function()->Id()->Name(); + auto signature = ETSChecker::GetSignatureFromMethodDefinition(bodyPart->AsMethodDefinition()); + ES2PANDA_ASSERT(signature != nullptr); + const util::StringView bodyMethodName = signature->Function()->Id()->Name(); + const auto *func = methodDef->Function(); + ES2PANDA_ASSERT(func != nullptr); if (bodyPart->IsOverride() && bodyMethodName != compiler::Signatures::CTOR && - bodyMethodName == methodDef->Function()->Id()->Name()) { + bodyMethodName == func->Id()->Name()) { suggestFinal = false; break; } @@ -210,13 +211,13 @@ void ETSWarningAnalyzer::ETSWarningsProhibitTopLevelStatements(const ir::AstNode } for (const auto *itBody : classDef->Body()) { - if (!itBody->IsMethodDefinition() || + if (!itBody->IsMethodDefinition() || itBody->AsMethodDefinition()->Id() == nullptr || itBody->AsMethodDefinition()->Id()->Name() != compiler::Signatures::INIT_METHOD) { continue; } - - for (const auto *statement : - itBody->AsMethodDefinition()->Function()->Body()->AsBlockStatement()->Statements()) { + const auto *func = itBody->AsMethodDefinition()->Function(); + ES2PANDA_ASSERT(func != nullptr); + for (const auto *statement : func->Body()->AsBlockStatement()->Statements()) { if (program_->NodeContainsETSNolint(statement, ETSWarnings::ETS_PROHIBIT_TOP_LEVEL_STATEMENTS)) { continue; } @@ -270,157 +271,6 @@ void ETSWarningAnalyzer::ETSWarningRemoveLambda(const ir::AstNode *node) node->Iterate([&](auto *childNode) { ETSWarningRemoveLambda(childNode); }); } -void ETSWarningAnalyzer::CheckTypeOfBoxing(const ir::AstNode *node) -{ - ES2PANDA_ASSERT(node != nullptr); - const auto flags = node->GetBoxingUnboxingFlags(); - if ((flags & ir::BoxingUnboxingFlags::BOXING_FLAG) != 0) { - std::string diagnosticParam; - switch (static_cast(flags & ir::BoxingUnboxingFlags::BOXING_FLAG)) { - case ir::BoxingUnboxingFlags::BOX_TO_INT: - diagnosticParam = "Int"; - break; - case ir::BoxingUnboxingFlags::BOX_TO_BOOLEAN: - diagnosticParam = "Boolean"; - break; - case ir::BoxingUnboxingFlags::BOX_TO_BYTE: - diagnosticParam = "Byte"; - break; - case ir::BoxingUnboxingFlags::BOX_TO_CHAR: - diagnosticParam = "Char"; - break; - case ir::BoxingUnboxingFlags::BOX_TO_DOUBLE: - diagnosticParam = "Double"; - break; - case ir::BoxingUnboxingFlags::BOX_TO_FLOAT: - diagnosticParam = "Float"; - break; - case ir::BoxingUnboxingFlags::BOX_TO_LONG: - diagnosticParam = "Long"; - break; - case ir::BoxingUnboxingFlags::BOX_TO_SHORT: - diagnosticParam = "Short"; - break; - default: - break; - } - - if (!diagnosticParam.empty()) { - util::DiagnosticMessageParams diagnosticParams = {diagnosticParam, GetBoxingUnboxingType(node)}; - LogWarning(diagnostic::IMPLICIT_BOXING_TO, diagnosticParams, node->Start()); - } - } -} - -void ETSWarningAnalyzer::CheckTypeOfUnboxing(const ir::AstNode *node) -{ - ES2PANDA_ASSERT(node != nullptr); - const auto flags = node->GetBoxingUnboxingFlags(); - if ((flags & ir::BoxingUnboxingFlags::UNBOXING_FLAG) != 0) { - std::string diagnosticParam; - switch (static_cast(flags & ir::BoxingUnboxingFlags::UNBOXING_FLAG)) { - case ir::BoxingUnboxingFlags::UNBOX_TO_INT: - diagnosticParam = "Int"; - break; - case ir::BoxingUnboxingFlags::UNBOX_TO_BOOLEAN: - diagnosticParam = "Boolean"; - break; - case ir::BoxingUnboxingFlags::UNBOX_TO_BYTE: - diagnosticParam = "Byte"; - break; - case ir::BoxingUnboxingFlags::UNBOX_TO_CHAR: - diagnosticParam = "Char"; - break; - case ir::BoxingUnboxingFlags::UNBOX_TO_DOUBLE: - diagnosticParam = "Double"; - break; - case ir::BoxingUnboxingFlags::UNBOX_TO_FLOAT: - diagnosticParam = "Float"; - break; - case ir::BoxingUnboxingFlags::UNBOX_TO_LONG: - diagnosticParam = "Long"; - break; - case ir::BoxingUnboxingFlags::UNBOX_TO_SHORT: - diagnosticParam = "Short"; - break; - default: - break; - } - - if (!diagnosticParam.empty()) { - util::DiagnosticMessageParams diagnosticParams = {diagnosticParam, GetBoxingUnboxingType(node)}; - LogWarning(diagnostic::IMPLICIT_BOXING_TO, diagnosticParams, node->Start()); - } - } -} - -void ETSWarningAnalyzer::CheckTypeOfBoxingUnboxing(const ir::AstNode *node) -{ - ES2PANDA_ASSERT(node != nullptr); - - CheckTypeOfBoxing(node); - CheckTypeOfUnboxing(node); -} - -std::string ETSWarningAnalyzer::GetBoxingUnboxingType(const ir::AstNode *node) -{ - ES2PANDA_ASSERT(node->Parent() != nullptr); - switch (node->Parent()->Type()) { - case ir::AstNodeType::VARIABLE_DECLARATOR: { - return " in Variable Declaration"; - } - case ir::AstNodeType::CALL_EXPRESSION: { - return " in Call Method/Function"; - } - case ir::AstNodeType::SWITCH_STATEMENT: { - return " in Switch-case Statement"; - } - case ir::AstNodeType::ASSIGNMENT_EXPRESSION: { - return " in Assignment Expression"; - } - case ir::AstNodeType::BINARY_EXPRESSION: { - return " in Binary Expression"; - } - case ir::AstNodeType::UNARY_EXPRESSION: { - return " in Unary Expression"; - } - case ir::AstNodeType::UPDATE_EXPRESSION: { - return " in Update Expression"; - } - case ir::AstNodeType::MEMBER_EXPRESSION: { - return " in Member Expression"; - } - default: - return ""; - } -} - -void ETSWarningAnalyzer::ETSWarningImplicitBoxingUnboxing(const ir::AstNode *node) -{ - ES2PANDA_ASSERT(node != nullptr); - - switch (node->Type()) { - case ir::AstNodeType::VARIABLE_DECLARATOR: - case ir::AstNodeType::SWITCH_STATEMENT: - case ir::AstNodeType::CALL_EXPRESSION: - case ir::AstNodeType::BINARY_EXPRESSION: - case ir::AstNodeType::ASSIGNMENT_EXPRESSION: - case ir::AstNodeType::UNARY_EXPRESSION: - case ir::AstNodeType::UPDATE_EXPRESSION: - case ir::AstNodeType::MEMBER_EXPRESSION: { - if (!program_->NodeContainsETSNolint(node, ETSWarnings::ETS_IMPLICIT_BOXING_UNBOXING)) { - node->Iterate([this](auto *childNode) { CheckTypeOfBoxingUnboxing(childNode); }); - } - break; - } - default: { - break; - } - } - - node->Iterate([&](auto *childNode) { ETSWarningImplicitBoxingUnboxing(childNode); }); -} - void ETSWarningAnalyzer::LogWarning(const diagnostic::DiagnosticKind &diagnostic, const lexer::SourcePosition &position) const { diff --git a/ets2panda/checker/ets/etsWarningAnalyzer.h b/ets2panda/checker/ets/etsWarningAnalyzer.h index 6a41550de33ac2945b21cec67b04b6e18a7fa880..8bfecef62796f19c4c764671e35cbc7b11fdb5fd 100644 --- a/ets2panda/checker/ets/etsWarningAnalyzer.h +++ b/ets2panda/checker/ets/etsWarningAnalyzer.h @@ -48,9 +48,6 @@ public: case ETSWarnings::ETS_REMOVE_LAMBDA: ETSWarningRemoveLambda(node); break; - case ETSWarnings::ETS_IMPLICIT_BOXING_UNBOXING: - ETSWarningImplicitBoxingUnboxing(node); - break; default: break; } @@ -63,12 +60,8 @@ private: void AnalyzeClassDefForFinalModifier(const ir::ClassDefinition *classDef); void AnalyzeClassMethodForFinalModifier(const ir::MethodDefinition *methodDef, const ir::ClassDefinition *classDef); - void CheckTypeOfBoxing(const ir::AstNode *node); - void CheckTypeOfUnboxing(const ir::AstNode *node); void CheckTopLevelExpressions(const ir::Expression *expression); void CheckProhibitedTopLevelStatements(const ir::Statement *statement); - std::string GetBoxingUnboxingType(const ir::AstNode *node); - void CheckTypeOfBoxingUnboxing(const ir::AstNode *node); void ETSWarningAnnotationUnusedGenericAliasWarn(const ir::AstNode *node); void ETSWarningSuggestFinal(const ir::AstNode *node); @@ -76,7 +69,6 @@ private: void ETSWarningBoostEqualityStatement(const ir::AstNode *node); void ETSWarningRemoveAsync(const ir::AstNode *node); void ETSWarningRemoveLambda(const ir::AstNode *node); - void ETSWarningImplicitBoxingUnboxing(const ir::AstNode *node); parser::Program *program_; util::DiagnosticEngine &diagnosticEngine_; diff --git a/ets2panda/checker/ets/function.cpp b/ets2panda/checker/ets/function.cpp index 167f9e40b22227915118c4492d00d434022ef228..0a27aadae20de1e95c82fc862dfb7b0999132fb3 100644 --- a/ets2panda/checker/ets/function.cpp +++ b/ets2panda/checker/ets/function.cpp @@ -16,12 +16,14 @@ #include "checker/types/ets/etsResizableArrayType.h" #include "checker/types/ets/etsTupleType.h" #include "generated/signatures.h" +#include "checker/ets/wideningConverter.h" #include "varbinder/ETSBinder.h" #include "checker/ETSchecker.h" #include "checker/ets/function_helpers.h" #include "checker/ets/typeRelationContext.h" #include "checker/types/ets/etsAsyncFuncReturnType.h" #include "checker/types/ets/etsObjectType.h" +#include "checker/types/gradualType.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "ir/base/catchClause.h" #include "ir/base/classDefinition.h" @@ -81,14 +83,15 @@ bool ETSChecker::IsCompatibleTypeArgument(ETSTypeParameter *typeParam, Type *typ bool ETSChecker::EnhanceSubstitutionForReadonly(const ArenaVector &typeParams, ETSReadonlyType *paramType, Type *argumentType, Substitution *substitution) { - return EnhanceSubstitutionForType(typeParams, paramType->GetUnderlying(), GetReadonlyType(argumentType), - substitution); + return EnhanceSubstitutionForType(typeParams, paramType->GetUnderlying()->MaybeBaseTypeOfGradualType(), + GetReadonlyType(argumentType), substitution); } /* A very rough and imprecise partial type inference */ bool ETSChecker::EnhanceSubstitutionForType(const ArenaVector &typeParams, Type *paramType, Type *argumentType, Substitution *substitution) { + ES2PANDA_ASSERT(argumentType != nullptr); if (argumentType->IsETSPrimitiveType()) { argumentType = MaybeBoxInRelation(argumentType); } @@ -114,6 +117,10 @@ bool ETSChecker::EnhanceSubstitutionForType(const ArenaVector &typeParam if (paramType->IsETSReadonlyType()) { return EnhanceSubstitutionForReadonly(typeParams, paramType->AsETSReadonlyType(), argumentType, substitution); } + if (paramType->IsGradualType()) { + return EnhanceSubstitutionForType(typeParams, paramType->AsGradualType()->GetBaseType(), argumentType, + substitution); + } if (paramType->IsETSUnionType()) { return EnhanceSubstitutionForUnion(typeParams, paramType->AsETSUnionType(), argumentType, substitution); } @@ -151,7 +158,8 @@ bool ETSChecker::EnhanceSubstitutionForUnion(const ArenaVector &typePara if (!argumentType->IsETSUnionType()) { bool foundValid = false; for (Type *ctype : paramUn->ConstituentTypes()) { - foundValid |= ValidateTypeSubstitution(typeParams, ctype, argumentType, substitution); + foundValid |= + ValidateTypeSubstitution(typeParams, ctype->MaybeBaseTypeOfGradualType(), argumentType, substitution); } return foundValid; } @@ -229,7 +237,7 @@ static void ResetInferredNode(ETSChecker *checker) auto resetFuncState = [](ir::ArrowFunctionExpression *expr) { auto *func = expr->Function(); func->SetSignature(nullptr); - func->ReturnStatements().clear(); + func->ClearReturnStatements(); expr->SetTsType(nullptr); }; @@ -378,10 +386,11 @@ bool ETSChecker::CheckOptionalLambdaFunction(ir::Expression *argument, Signature return false; } -bool ETSChecker::ValidateArgumentAsIdentifier(const ir::Identifier *identifier) +static bool IsInvalidArgumentAsIdentifier(varbinder::Scope *scope, const ir::Identifier *identifier) { - auto result = Scope()->Find(identifier->Name()); - return result.variable != nullptr && (result.variable->HasFlag(varbinder::VariableFlags::CLASS_OR_INTERFACE)); + auto result = scope->Find(identifier->Name()); + return result.variable != nullptr && (result.variable->HasFlag(varbinder::VariableFlags::CLASS_OR_INTERFACE | + varbinder::VariableFlags::TYPE_ALIAS)); } static void ClearPreferredTypeForArray(checker::ETSChecker *checker, ir::Expression *argument, Type *paramType, @@ -389,13 +398,13 @@ static void ClearPreferredTypeForArray(checker::ETSChecker *checker, ir::Express { if (argument->IsArrayExpression()) { // fixed array and resizeable array will cause problem here, so clear it. - argument->AsArrayExpression()->ClearPreferredType(); + argument->AsArrayExpression()->CleanCheckInformation(); argument->AsArrayExpression()->SetPreferredTypeBasedOnFuncParam(checker, paramType, flags); } else if (argument->IsETSNewArrayInstanceExpression()) { - argument->AsETSNewArrayInstanceExpression()->ClearPreferredType(); + argument->AsETSNewArrayInstanceExpression()->CleanCheckInformation(); argument->AsETSNewArrayInstanceExpression()->SetPreferredTypeBasedOnFuncParam(checker, paramType, flags); } else if (argument->IsETSNewMultiDimArrayInstanceExpression()) { - argument->AsETSNewMultiDimArrayInstanceExpression()->ClearPreferredType(); + argument->AsETSNewMultiDimArrayInstanceExpression()->CleanCheckInformation(); argument->AsETSNewMultiDimArrayInstanceExpression()->SetPreferredTypeBasedOnFuncParam(checker, paramType, flags); } else { @@ -406,25 +415,51 @@ static void ClearPreferredTypeForArray(checker::ETSChecker *checker, ir::Express } } +static bool CheckArrowFunctionParamIfNeeded(ETSChecker *checker, Signature *substitutedSig, + const ArenaVector &arguments, TypeRelationFlag flags) +{ + if ((flags & TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA) != 0 && arguments.back()->IsArrowFunctionExpression()) { + ir::ScriptFunction *const lambda = arguments.back()->AsArrowFunctionExpression()->Function(); + auto targetParm = substitutedSig->GetSignatureInfo()->params.back()->Declaration()->Node(); + if (!checker->CheckLambdaAssignable(targetParm->AsETSParameterExpression(), lambda)) { + return false; + } + } + return true; +} + +// Note: (Issue27688) if lambda is trailing lambda transferred, it must be in recheck. +// in signature matching, foo(()=>void) should be the same with foo() {} +static bool HasTransferredTrailingLambda(const ArenaVector &arguments) +{ + return !arguments.empty() && arguments.back()->IsArrowFunctionExpression() && + arguments.back()->AsArrowFunctionExpression()->Function()->IsTrailingLambda(); +} + +// CC-OFFNXT(huge_method[C++], G.FUN.01-CPP, G.FUD.05) solid logic bool ETSChecker::ValidateSignatureRequiredParams(Signature *substitutedSig, const ArenaVector &arguments, TypeRelationFlag flags, const std::vector &argTypeInferenceRequired, bool reportError) { auto commonArity = std::min(arguments.size(), substitutedSig->ArgCount()); - if ((flags & TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA) != 0) { + if ((flags & TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA) != 0 || HasTransferredTrailingLambda(arguments)) { commonArity = commonArity - 1; } for (size_t index = 0; index < commonArity; ++index) { auto &argument = arguments[index]; // #22952: infer optional parameter heuristics - auto const paramType = GetNonNullishType(substitutedSig->Params()[index]->TsType()); + auto const paramType = + GetNonNullishType(substitutedSig->Params()[index]->TsType())->MaybeBaseTypeOfGradualType(); if (argument->IsObjectExpression()) { - if (paramType->IsETSObjectType()) { - // No chance to check the argument at this point - continue; + ES2PANDA_ASSERT(paramType != nullptr); + if (!paramType->IsETSObjectType()) { + return false; } - return false; + if (paramType->AsETSObjectType()->IsBoxedPrimitive()) { + return false; + } + argument->SetPreferredType(paramType); } if (argument->IsMemberExpression()) { @@ -434,6 +469,9 @@ bool ETSChecker::ValidateSignatureRequiredParams(Signature *substitutedSig, LogError(diagnostic::SPREAD_ONTO_SINGLE_PARAM, {}, argument->Start()); } return false; + } else if (argument->IsNumberLiteral()) { + argument->SetTsType(nullptr); + argument->SetPreferredType(paramType); } if (argTypeInferenceRequired[index]) { @@ -449,7 +487,7 @@ bool ETSChecker::ValidateSignatureRequiredParams(Signature *substitutedSig, ClearPreferredTypeForArray(this, argument, paramType, flags, false); - if (argument->IsIdentifier() && ValidateArgumentAsIdentifier(argument->AsIdentifier())) { + if (argument->IsIdentifier() && IsInvalidArgumentAsIdentifier(Scope(), argument->AsIdentifier())) { LogError(diagnostic::ARG_IS_CLASS_ID, {}, argument->Start()); return false; } @@ -460,14 +498,7 @@ bool ETSChecker::ValidateSignatureRequiredParams(Signature *substitutedSig, } } - if ((flags & TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA) != 0 && arguments.back()->IsArrowFunctionExpression()) { - ir::ScriptFunction *const lambda = arguments.back()->AsArrowFunctionExpression()->Function(); - auto targetParm = substitutedSig->GetSignatureInfo()->params.back()->Declaration()->Node(); - if (!CheckLambdaAssignable(targetParm->AsETSParameterExpression(), lambda)) { - return false; - } - } - return true; + return CheckArrowFunctionParamIfNeeded(this, substitutedSig, arguments, flags); } bool ETSChecker::ValidateSignatureInvocationContext(Signature *substitutedSig, ir::Expression *argument, @@ -477,7 +508,7 @@ bool ETSChecker::ValidateSignatureInvocationContext(Signature *substitutedSig, i // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Type *argumentType = argument->Check(this); - flags |= TypeRelationFlag::ONLY_CHECK_WIDENING; + flags |= (TypeRelationFlag::ONLY_CHECK_WIDENING); auto const invocationCtx = checker::InvocationContext(Relation(), argument, argumentType, targetType, argument->Start(), @@ -489,20 +520,29 @@ bool ETSChecker::ValidateSignatureInvocationContext(Signature *substitutedSig, i bool ETSChecker::IsValidRestArgument(ir::Expression *const argument, Signature *const substitutedSig, const TypeRelationFlag flags, const std::size_t index) { + auto *restParamType = substitutedSig->RestVar()->TsType(); if (argument->IsObjectExpression()) { + argument->SetPreferredType(GetElementTypeOfArray(restParamType)); // Object literals should be checked separately afterwards after call resolution return true; } + + // Set preferred type for array expressions before checking, similar to spread elements + if (argument->IsArrayExpression()) { + if (!SetPreferredTypeForArrayArgument(argument->AsArrayExpression(), substitutedSig)) { + return false; + } + } + const auto argumentType = argument->Check(this); - auto *restParam = substitutedSig->RestVar()->TsType(); - if (restParam->IsETSTupleType()) { + if (restParamType->IsETSTupleType()) { return false; } if (argument->HasAstNodeFlags(ir::AstNodeFlags::RESIZABLE_REST)) { return true; } - auto targetType = GetElementTypeOfArray(restParam); + auto targetType = GetElementTypeOfArray(restParamType); if (substitutedSig->OwnerVar() == nullptr) { targetType = MaybeBoxType(targetType); } @@ -510,7 +550,35 @@ bool ETSChecker::IsValidRestArgument(ir::Expression *const argument, Signature * Relation(), argument, argumentType, targetType, argument->Start(), {{diagnostic::REST_PARAM_INCOMPAT_AT, {argumentType, targetType, index + 1}}}, flags); - return invocationCtx.IsInvocable(); + bool result = invocationCtx.IsInvocable(); + // Clear preferred type if invocation fails, similar to spread elements + if (!result && argument->IsArrayExpression()) { + ModifyPreferredType(argument->AsArrayExpression(), nullptr); + } + + return result; +} + +bool ETSChecker::SetPreferredTypeForArrayArgument(ir::ArrayExpression *arrayExpr, Signature *substitutedSig) +{ + auto *const restVarType = substitutedSig->RestVar()->TsType(); + if (!restVarType->IsETSArrayType() && !restVarType->IsETSResizableArrayType()) { + return true; + } + auto targetType = GetElementTypeOfArray(restVarType); + if (substitutedSig->OwnerVar() == nullptr) { + targetType = MaybeBoxType(targetType); + } + // Validate tuple size before setting preferred type + if (targetType->IsETSTupleType()) { + auto *tupleType = targetType->AsETSTupleType(); + if (tupleType->GetTupleSize() != arrayExpr->Elements().size()) { + // Size mismatch - don't set preferred type, this will cause a type error + return false; + } + } + arrayExpr->SetPreferredType(targetType); + return true; } bool ETSChecker::ValidateSignatureRestParams(Signature *substitutedSig, const ArenaVector &arguments, @@ -545,9 +613,7 @@ bool ETSChecker::ValidateSignatureRestParams(Signature *substitutedSig, const Ar Type *targetType = substitutedSig->RestVar()->TsType(); // backing out of check that results in a signature mismatch would be difficult // so only attempt it if there is only one candidate signature - if (restArgument->IsArrayExpression()) { - restArgument->AsArrayExpression()->SetPreferredType(targetType); - } + restArgument->SetPreferredType(targetType); auto const argumentType = restArgument->Check(this); auto const invocationCtx = checker::InvocationContext( @@ -575,7 +641,9 @@ Signature *ETSChecker::ValidateSignature( // setting the boxing/unboxing flag for the arguments if needed. // So handle substitution arguments only in the case of unique function or collecting signature phase. Signature *const signature = - MaybeSubstituteTypeParameters(this, baseSignature, typeArguments, arguments, pos, flags); + ((flags & TypeRelationFlag::NO_SUBSTITUTION_NEEDED) != 0U) + ? baseSignature + : MaybeSubstituteTypeParameters(this, baseSignature, typeArguments, arguments, pos, flags); if (signature == nullptr) { return nullptr; } @@ -672,6 +740,7 @@ std::array GetFlagVariants() }; } +// CC-OFFNXT(huge_method) solid logic ArenaVector ETSChecker::CollectSignatures(ArenaVector &signatures, const ir::TSTypeParameterInstantiation *typeArguments, const ArenaVector &arguments, @@ -681,12 +750,20 @@ ArenaVector ETSChecker::CollectSignatures(ArenaVector std::vector argTypeInferenceRequired = FindTypeInferenceArguments(arguments); Signature *notVisibleSignature = nullptr; + if (signatures.size() > 1) { + resolveFlags |= TypeRelationFlag::OVERLOADING_CONTEXT; + } + auto collectSignatures = [&](TypeRelationFlag relationFlags) { for (auto *sig : signatures) { if (notVisibleSignature != nullptr && !IsSignatureAccessible(sig, Context().ContainingClass(), Relation())) { continue; } + if (sig->HasSignatureFlag(SignatureFlags::BRIDGE)) { + // Bridges are never invoked direcly + continue; + } // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *concreteSig = ValidateSignature(std::make_tuple(sig, typeArguments, relationFlags), arguments, pos, argTypeInferenceRequired, signatures.size() == 1); @@ -724,20 +801,6 @@ ArenaVector ETSChecker::CollectSignatures(ArenaVector return compatibleSignatures; } -static void ClearUnboxingFlags(TypeRelation *relation, Signature *sig, ir::Expression *argument, size_t index) -{ - auto identical = relation->IsIdenticalTo(sig->Params()[index]->TsType(), argument->TsType()); - // NOTE(gaborarontakacs): The unboxing flag, which was added due to overloading, needs to be removed when it's - // unnecessary for the most specific signature. - // Do not remove the flag for tuples, e.g., `let a = [21 as Number] as [number]`, - // because unboxing will be executed later during the function call in this case. - // This condition may be removed after refactoring primitive types. - if (identical && argument->HasBoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOXING_FLAG) && - !(argument->IsMemberExpression() && argument->AsMemberExpression()->Object()->TsType()->IsETSTupleType())) { - argument->RemoveBoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOXING_FLAG); - } -} - static void UpdateArrayArgsAndUnboxingFlags(ETSChecker *checker, Signature *sig, const ArenaVector &arguments) { @@ -748,7 +811,6 @@ static void UpdateArrayArgsAndUnboxingFlags(ETSChecker *checker, Signature *sig, auto flags = TypeRelationFlag::NO_THROW | TypeRelationFlag::BOXING | TypeRelationFlag::UNBOXING | TypeRelationFlag::WIDENING; ClearPreferredTypeForArray(checker, argument, paramType, flags, true); - ClearUnboxingFlags(checker->Relation(), sig, argument, index); } } @@ -827,7 +889,18 @@ Signature *ETSChecker::ValidateSignatures(ArenaVector &signatures, auto compatibleSignatures = CollectSignatures(signatures, typeArguments, arguments, pos, resolveFlags); if (!compatibleSignatures.empty()) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return GetMostSpecificSignature(compatibleSignatures, arguments, pos, resolveFlags); + auto *sig = GetMostSpecificSignature(compatibleSignatures, arguments, pos, resolveFlags); + // NOTE (DZ): skip Promise constructor/then/catch check - + // temporary solution, need to be removed after fixing OHOS code! + if (sig == nullptr || !sig->HasFunction() || + !(sig->Function()->IsConstructor() || sig->Function()->Id()->Name().Is("then") || + sig->Function()->Id()->Name().Is("catch")) || + !sig->Owner()->Name().Is("Promise")) { + // May need to re-check the arguments now that we know the particular signature to call. + ValidateSignature({sig, nullptr, TypeRelationFlag::WIDENING | TypeRelationFlag::NO_SUBSTITUTION_NEEDED}, + arguments, pos, FindTypeInferenceArguments(arguments), true); + } + return sig; } if ((resolveFlags & TypeRelationFlag::NO_THROW) == 0) { @@ -851,6 +924,8 @@ Signature *ETSChecker::FindMostSpecificSignature(const ArenaVector return true; }; + auto isGeneric = [](const Signature *sig) { return sig->TypeParams().empty(); }; + Signature *result = nullptr; size_t currentMinLength = SIZE_MAX; @@ -878,8 +953,15 @@ Signature *ETSChecker::FindMostSpecificSignature(const ArenaVector } else if (candidateLength < currentLength) { result = candidate; // Shorter parameter count wins currentMinLength = result->Function()->Params().size(); - } else if (candidateLength == currentLength) { - // Ambiguous resolution for same-length params + } else if (candidateLength >= currentLength) { + continue; + // NOTE (smartin): all other cases below are unreachable code + } else if (!isGeneric(candidate) && isGeneric(result)) { + result = candidate; + } else if (isGeneric(candidate) && !isGeneric(result)) { + continue; + } else { + // Ambiguous resolution for same-length params, same genericity if (result->Owner() == candidate->Owner()) { result = nullptr; } @@ -889,45 +971,121 @@ Signature *ETSChecker::FindMostSpecificSignature(const ArenaVector return result; } -static Type *GetParatmeterTypeOrRestAtIdx(checker::ETSChecker *checker, Signature *sig, const size_t idx) +static Type *GetParameterTypeOrRestAtIdx(checker::ETSChecker *checker, Signature *sig, const size_t idx) { - return idx < sig->ArgCount() ? sig->Params().at(idx)->TsType() - : checker->GetElementTypeOfArray(sig->RestVar()->TsType()); + return idx < sig->ArgCount() + ? sig->Params().at(idx)->TsType()->MaybeBaseTypeOfGradualType() + : checker->GetElementTypeOfArray(sig->RestVar()->TsType())->MaybeBaseTypeOfGradualType(); } -static void InitMostSpecificType(checker::ETSChecker *checker, const ArenaVector &signatures, - [[maybe_unused]] Type *&mostSpecificType, [[maybe_unused]] Signature *&prevSig, - const size_t idx) +static void InitMostSpecificType(TypeRelation *relation, const ArenaVector &signatures, + Type *&mostSpecificType, Signature *&prevSig, const size_t idx) { + // Attempt to choose the widest type of available ones + SavedTypeRelationFlagsContext ctx {relation, TypeRelationFlag::WIDENING | TypeRelationFlag::ONLY_CHECK_WIDENING}; + auto checker = relation->GetChecker()->AsETSChecker(); for (auto *sig : signatures) { - if (Type *sigType = GetParatmeterTypeOrRestAtIdx(checker, sig, idx); - sigType->IsETSObjectType() && !sigType->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::INTERFACE)) { + Type *sigType = GetParameterTypeOrRestAtIdx(checker, sig, idx); + relation->Result(false); + + if (sigType->IsETSObjectType()) { + if (sigType->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::INTERFACE)) { + continue; + } + if (!sigType->AsETSObjectType()->IsBoxedPrimitive()) { + // Found "non-primitive" ref type + mostSpecificType = sigType; + prevSig = sig; + return; + } + relation->SetNode(prevSig->Function()->Params()[idx]->AsETSParameterExpression()); + if (relation->IsLegalBoxedPrimitiveConversion(sigType, mostSpecificType)) { + mostSpecificType = sigType; + prevSig = sig; + continue; + } + } + if (sigType->IsETSFunctionType() && relation->IsSupertypeOf(sigType, mostSpecificType)) { mostSpecificType = sigType; prevSig = sig; - return; + continue; + } + relation->Result(false); + WideningConverter(checker, relation, sigType, mostSpecificType); + if (relation->IsTrue()) { + mostSpecificType = sigType; + prevSig = sig; + continue; } } } +void ETSChecker::CheckAmbiguousCall(Type *&mostSpecificType, Type *sigType, Signature *prevSig, Signature *sig, + const lexer::SourcePosition &pos) +{ + if (((sigType->IsETSObjectType() && mostSpecificType->IsETSObjectType()) || + (sigType->IsETSUnionType() && mostSpecificType->IsETSUnionType() && + ((Relation()->IsSupertypeOf(sigType->AsETSUnionType(), GlobalETSNullType()) && + Relation()->IsSupertypeOf(mostSpecificType->AsETSUnionType(), GlobalETSNullType())) || + // CC-OFFNXT(G.FMT.02-CPP) project code style + (Relation()->IsSupertypeOf(sigType->AsETSUnionType(), GlobalETSUndefinedType()) && + Relation()->IsSupertypeOf(mostSpecificType->AsETSUnionType(), GlobalETSUndefinedType()))))) && + !Relation()->IsAssignableTo(mostSpecificType, sigType) && + !Relation()->IsLegalBoxedPrimitiveConversion(sigType, mostSpecificType)) { + auto funcName = sig->Function()->Id()->Name(); + LogError(diagnostic::AMBIGUOUS_CALL, {funcName, funcName, funcName, prevSig, funcName, sig}, pos); + } +} + void ETSChecker::SearchAmongMostSpecificTypes(Type *&mostSpecificType, Signature *&prevSig, std::tuple info, bool lookForClassType) { auto [pos, idx, sig] = info; - Type *sigType = GetParatmeterTypeOrRestAtIdx(this, sig, idx); + Type *sigType = GetParameterTypeOrRestAtIdx(this, sig, idx); + if (prevSig->Function()->Params()[idx]->IsETSParameterExpression()) { + Relation()->SetNode(prevSig->Function()->Params()[idx]->AsETSParameterExpression()); + } const bool isClassType = sigType->IsETSObjectType() && !sigType->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::INTERFACE); if (isClassType == lookForClassType) { if (Relation()->IsIdenticalTo(sigType, mostSpecificType)) { + Relation()->SetNode(nullptr); + return; + } + + if (idx >= prevSig->MinArgCount() && idx < sig->MinArgCount()) { + // NOTE (smartin): prefer non-optional parameters over optional ones + Relation()->Result(true); + mostSpecificType = sigType; + prevSig = sig; return; } + + if (isClassType && sigType->AsETSObjectType()->IsBoxedPrimitive() && mostSpecificType->IsETSObjectType() && + mostSpecificType->AsETSObjectType()->IsBoxedPrimitive()) { + // NOTE (smartin): when a param with type int is available, make it more specific than other primitive + // types. The making of correct rules for this is still in progress in spec, so this is a temp solution. + if (mostSpecificType->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_INT)) { + return; + } + + TypeRelationFlag flags = TypeRelationFlag::NO_THROW | TypeRelationFlag::UNBOXING | + TypeRelationFlag::BOXING | TypeRelationFlag::WIDENING; + Relation()->SetFlags(flags); + if (sigType->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_INT) || + Relation()->IsLegalBoxedPrimitiveConversion(mostSpecificType, sigType)) { + Relation()->Result(true); + mostSpecificType = sigType; + prevSig = sig; + return; + } + } if (Relation()->IsAssignableTo(sigType, mostSpecificType)) { mostSpecificType = sigType; prevSig = sig; - } else if (sigType->IsETSObjectType() && mostSpecificType->IsETSObjectType() && - !Relation()->IsAssignableTo(mostSpecificType, sigType)) { - auto funcName = sig->Function()->Id()->Name(); - LogError(diagnostic::AMBIGUOUS_CALL, {funcName, funcName, funcName, prevSig, funcName, sig}, pos); + } else { + CheckAmbiguousCall(mostSpecificType, sigType, prevSig, sig, pos); } } } @@ -944,6 +1102,7 @@ void ETSChecker::CollectSuitableSignaturesForTypeInference( for (auto *sig : signatures) { auto *sigParamType = GetNonNullishType(sig->Params().at(paramIdx)->TsType()); + ES2PANDA_ASSERT(sigParamType != nullptr); if (!sigParamType->IsETSFunctionType()) { continue; } @@ -956,6 +1115,7 @@ void ETSChecker::CollectSuitableSignaturesForTypeInference( for (auto *sig : signatures) { auto *sigParamType = GetNonNullishType(sig->Params().at(paramIdx)->TsType()); + ES2PANDA_ASSERT(sigParamType != nullptr); if (!sigParamType->IsETSFunctionType()) { continue; } @@ -970,8 +1130,9 @@ void ETSChecker::CollectSuitableSignaturesForTypeInference( } for (auto *sig : signatures) { - if (paramIdx >= sig->Params().size() || !sig->Params().at(paramIdx)->TsType()->IsETSObjectType() || - !sig->Params().at(paramIdx)->TsType()->AsETSObjectType()->IsGlobalETSObjectType()) { + auto paramType = sig->Params().at(paramIdx)->TsType()->MaybeBaseTypeOfGradualType(); + if (paramIdx >= sig->Params().size() || !paramType->IsETSObjectType() || + !paramType->AsETSObjectType()->IsGlobalETSObjectType()) { bestSignaturesForParameter.insert({paramIdx, sig}); } } @@ -1002,7 +1163,9 @@ ArenaMultiMap ETSChecker::GetSuitableSignaturesForParameter Type *mostSpecificType = signatures.front()->Params().at(i)->TsType(); Signature *prevSig = signatures.front(); - InitMostSpecificType(this, signatures, mostSpecificType, prevSig, i); + // NOTE: first we choose the some signature with possibly widest argumetns' types + // Then we search for the most specific signature + InitMostSpecificType(Relation(), signatures, mostSpecificType, prevSig, i); for (auto *sig : signatures) { SearchAmongMostSpecificTypes(mostSpecificType, prevSig, std::make_tuple(pos, i, sig), true); } @@ -1011,8 +1174,9 @@ ArenaMultiMap ETSChecker::GetSuitableSignaturesForParameter } for (auto *sig : signatures) { - Type *sigType = GetParatmeterTypeOrRestAtIdx(this, sig, i); - if (Relation()->IsIdenticalTo(sigType, mostSpecificType)) { + Type *sigType = GetParameterTypeOrRestAtIdx(this, sig, i); + if (Relation()->IsIdenticalTo(sigType, mostSpecificType) || + (sigType->IsETSFunctionType() && Relation()->IsSupertypeOf(sigType, mostSpecificType))) { bestSignaturesForParameter.insert({i, sig}); } } @@ -1090,6 +1254,10 @@ Signature *ETSChecker::ResolvePotentialTrailingLambdaWithReceiver(ir::CallExpres ArenaVector sigContainLambdaWithReceiverAsParam(ProgramAllocator()->Adapter()); Signature *signature = nullptr; for (auto sig : signatures) { + if (!sig->HasFunction()) { + continue; + } + if (!IsLastParameterLambdaWithReceiver(sig)) { normalSig.emplace_back(sig); continue; @@ -1098,7 +1266,7 @@ Signature *ETSChecker::ResolvePotentialTrailingLambdaWithReceiver(ir::CallExpres auto *candidateFunctionType = sig->Function()->Params().back()->AsETSParameterExpression()->TypeAnnotation()->AsETSFunctionType(); auto *currentReceiver = candidateFunctionType->Params()[0]; - trailingLambda->Function()->Params().emplace_back(currentReceiver); + trailingLambda->Function()->EmplaceParams(currentReceiver); sigContainLambdaWithReceiverAsParam.emplace_back(sig); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) signature = ValidateSignatures(sigContainLambdaWithReceiverAsParam, callExpr->TypeParams(), arguments, @@ -1108,7 +1276,7 @@ Signature *ETSChecker::ResolvePotentialTrailingLambdaWithReceiver(ir::CallExpres return signature; } sigContainLambdaWithReceiverAsParam.clear(); - trailingLambda->Function()->Params().clear(); + trailingLambda->Function()->ClearParams(); } // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return ValidateSignatures(normalSig, callExpr->TypeParams(), arguments, callExpr->Start(), "call", @@ -1148,9 +1316,36 @@ void ETSChecker::UpdateDeclarationFromSignature(ir::CallExpression *expr, checke auto newDecl = allocator->New(allocator, sigName, declNode); auto newVar = allocator->New(newDecl, varbinder::VariableFlags::METHOD | varbinder::VariableFlags::SYNTHETIC); + newVar->SetTsType(declNode->AsMethodDefinition()->TsType()->Clone(this)); callIdentifier->SetVariable(newVar); } +Signature *ETSChecker::MakeSignatureInvocable(Signature *sig, ir::CallExpression *callExpr) +{ + if (sig == nullptr) { + return nullptr; + } + std::size_t const argumentCount = callExpr->Arguments().size(); + std::size_t const parameterCount = sig->Params().size(); + auto count = std::min(parameterCount, argumentCount); + for (std::size_t idx = 0; idx < count; ++idx) { + // Kludge to make promise code compile + if (callExpr->Arguments().at(idx)->IsArrowFunctionExpression()) { + continue; + } + + auto ctx = checker::AssignmentContext( + Relation(), callExpr->Arguments().at(idx), callExpr->Arguments().at(idx)->TsType(), + sig->Params().at(idx)->TsType(), callExpr->Arguments().at(idx)->Start(), + {{diagnostic::INVALID_ASSIGNMNENT, + {callExpr->Arguments().at(idx)->TsType(), sig->Params().at(idx)->TsType()}}}); + if (!ctx.IsAssignable()) { + return nullptr; + } + } + return sig; +} + Signature *ETSChecker::ResolveCallExpressionAndTrailingLambda(ArenaVector &signatures, ir::CallExpression *callExpr, const lexer::SourcePosition &pos, @@ -1160,6 +1355,7 @@ Signature *ETSChecker::ResolveCallExpressionAndTrailingLambda(ArenaVectorTypeParams(), callExpr->Arguments(), pos, "call", reportFlag); + sig = MakeSignatureInvocable(sig, callExpr); UpdateDeclarationFromSignature(callExpr, sig); return sig; } @@ -1180,6 +1376,7 @@ Signature *ETSChecker::ResolveCallExpressionAndTrailingLambda(ArenaVectorTypeParams(), callExpr->Arguments(), pos, "call", reportFlag); + sig = MakeSignatureInvocable(sig, callExpr); if (sig != nullptr) { EnsureValidCurlyBrace(callExpr); } @@ -1191,6 +1388,12 @@ Signature *ETSChecker::ResolveCallExpressionAndTrailingLambda(ArenaVector &arguments, const lexer::SourcePosition &pos) { + auto *var = type->GetProperty(compiler::Signatures::CONSTRUCTOR_OVERLOAD_DEFINITION_NAME, + PropertySearchFlags::SEARCH_STATIC_METHOD); + if (var != nullptr && var->TsType()->IsETSFunctionType()) { + return MatchOrderSignatures(var->TsType()->AsETSFunctionType()->CallSignatures(), nullptr, arguments, pos, + TypeRelationFlag::NONE); + } // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return ValidateSignatures(type->ConstructSignatures(), nullptr, arguments, pos, "construct"); } @@ -1216,7 +1419,7 @@ void ETSChecker::CheckObjectLiteralArguments(Signature *signature, ArenaVectorParams()[index]->TsType()); } - arguments[index]->AsObjectExpression()->SetPreferredType(tp); + arguments[index]->SetPreferredType(tp); arguments[index]->Check(this); } } @@ -1224,23 +1427,31 @@ void ETSChecker::CheckObjectLiteralArguments(Signature *signature, ArenaVectorGetOverloadInfo(); + ir::OverloadInfo &ldInfo = method->GetOverloadInfoForUpdate(); ArenaVector overloads(checker->ProgramAllocator()->Adapter()); for (ir::MethodDefinition *const currentFunc : method->Overloads()) { ldInfo.isDeclare &= currentFunc->IsDeclare(); - + ES2PANDA_ASSERT(currentFunc->Function() != nullptr); + ES2PANDA_ASSERT(currentFunc->Id() != nullptr); currentFunc->Function()->Id()->SetVariable(currentFunc->Id()->Variable()); checker->BuildFunctionSignature(currentFunc->Function(), method->IsConstructor()); if (currentFunc->Function()->Signature() == nullptr) { - method->Id()->Variable()->SetTsType(checker->GlobalTypeError()); + auto *methodId = method->Id(); + ES2PANDA_ASSERT(methodId != nullptr); + methodId->Variable()->SetTsType(checker->GlobalTypeError()); return false; } - auto *const overloadType = checker->BuildMethodType(currentFunc->Function()); + + auto *const overloadType = currentFunc->TsType() != nullptr ? currentFunc->TsType()->AsETSFunctionType() + : checker->BuildMethodType(currentFunc->Function()); ldInfo.needHelperOverload |= checker->CheckIdenticalOverloads(funcType, overloadType, currentFunc, ldInfo.isDeclare); - currentFunc->SetTsType(overloadType); + if (currentFunc->TsType() == nullptr) { + currentFunc->SetTsType(overloadType); + } + auto overloadSig = currentFunc->Function()->Signature(); funcType->AddCallSignature(overloadSig); if (overloadSig->IsExtensionAccessor()) { @@ -1273,29 +1484,32 @@ checker::Type *ETSChecker::BuildMethodSignature(ir::MethodDefinition *method) if (method->TsType() != nullptr) { return method->TsType()->AsETSFunctionType(); } - - method->Function()->Id()->SetVariable(method->Id()->Variable()); + auto *methodId = method->Id(); + ES2PANDA_ASSERT(methodId != nullptr); + ES2PANDA_ASSERT(method->Function() != nullptr); + method->Function()->Id()->SetVariable(methodId->Variable()); BuildFunctionSignature(method->Function(), method->IsConstructor()); if (method->Function()->Signature() == nullptr) { - return method->Id()->Variable()->SetTsType(GlobalTypeError()); + return methodId->Variable()->SetTsType(GlobalTypeError()); } auto *funcType = BuildMethodType(method->Function()); method->InitializeOverloadInfo(); if (!CollectOverload(this, method, funcType)) { return GlobalTypeError(); } - ir::OverloadInfo &ldInfo = method->GetOverloadInfo(); + ir::OverloadInfo &ldInfo = method->GetOverloadInfoForUpdate(); ldInfo.needHelperOverload &= ldInfo.isDeclare; if (ldInfo.needHelperOverload) { LogDiagnostic(diagnostic::FUNCTION_ASM_SIG_COLLISION, {std::string(funcType->Name())}, method->Start()); } - return method->Id()->Variable()->SetTsType(funcType); + return methodId->Variable()->SetTsType(funcType); } bool ETSChecker::CheckIdenticalOverloads(ETSFunctionType *func, ETSFunctionType *overload, - const ir::MethodDefinition *const currentFunc, bool omitSameAsm) + const ir::MethodDefinition *const currentFunc, bool omitSameAsm, + TypeRelationFlag relationFlags) { // Don't necessary to check overload for invalid functions if (func->Name().Is(ERROR_LITERAL)) { @@ -1303,7 +1517,7 @@ bool ETSChecker::CheckIdenticalOverloads(ETSFunctionType *func, ETSFunctionType return false; } - SavedTypeRelationFlagsContext savedFlagsCtx(Relation(), TypeRelationFlag::NO_RETURN_TYPE_CHECK); + SavedTypeRelationFlagsContext savedFlagsCtx(Relation(), relationFlags); Relation()->SignatureIsIdenticalTo(func->CallSignatures()[0], overload->CallSignatures()[0]); if (Relation()->IsTrue() && func->CallSignatures()[0]->GetSignatureInfo()->restVar == @@ -1377,10 +1591,6 @@ static varbinder::LocalVariable *SetupSignatureParameter(ir::ETSParameterExpress // Should be moved to original ComposeSignatureInfo after AST fix static bool AppendSignatureInfoParam(ETSChecker *checker, SignatureInfo *sigInfo, ir::ETSParameterExpression *param) { - if (param->IsRestParameter()) { - return true; - } - auto variable = SetupSignatureParameter(param, [checker, param]() { if (param->TypeAnnotation() != nullptr) { auto type = param->TypeAnnotation()->GetType(checker); @@ -1399,12 +1609,15 @@ static bool AppendSignatureInfoParam(ETSChecker *checker, SignatureInfo *sigInfo if (variable == nullptr) { // #23134 return false; } + if (param->IsRestParameter()) { + return true; + } sigInfo->params.push_back(variable); if (!param->IsOptional()) { ++sigInfo->minArgCount; } - ES2PANDA_ASSERT(!param->IsOptional() || + ES2PANDA_ASSERT(!param->IsOptional() || param->Ident()->TsType()->IsTypeError() || checker->Relation()->IsSupertypeOf(param->Ident()->TsType(), checker->GlobalETSUndefinedType())); return true; } @@ -1416,6 +1629,7 @@ SignatureInfo *ETSChecker::ComposeSignatureInfo(ir::TSTypeParameterDeclaration * if (typeParams != nullptr) { auto [typeParamTypes, ok] = CreateUnconstrainedTypeParameters(typeParams); + ES2PANDA_ASSERT(signatureInfo != nullptr); signatureInfo->typeParams = std::move(typeParamTypes); if (ok) { AssignTypeParameterConstraints(typeParams); @@ -1432,17 +1646,22 @@ SignatureInfo *ETSChecker::ComposeSignatureInfo(ir::TSTypeParameterDeclaration * if (!params.empty()) { if (auto param = params.back()->AsETSParameterExpression(); param->IsRestParameter()) { - if (param->TypeAnnotation() == nullptr) { // #23134 - ES2PANDA_ASSERT(IsAnyError()); + checker::Type *restParamType = nullptr; + if (param->TypeAnnotation() != nullptr) { + restParamType = param->RestParameter()->TypeAnnotation()->GetType(this); + } else if (param->Ident()->TsType() != nullptr) { + restParamType = param->Ident()->TsType(); + } else { + ES2PANDA_ASSERT(IsAnyError()); // #23134 return nullptr; } - auto restParamType = param->RestParameter()->TypeAnnotation()->GetType(this); + ES2PANDA_ASSERT(restParamType != nullptr); if (!restParamType->IsETSTupleType() && !restParamType->IsETSArrayType() && !restParamType->IsETSResizableArrayType()) { LogError(diagnostic::ONLY_ARRAY_OR_TUPLE_FOR_REST, {}, param->Start()); return nullptr; } - signatureInfo->restVar = SetupSignatureParameter(param, param->TypeAnnotation()->GetType(this)); + signatureInfo->restVar = SetupSignatureParameter(param, restParamType); ES2PANDA_ASSERT(signatureInfo->restVar != nullptr); } } @@ -1473,7 +1692,12 @@ void ETSChecker::ValidateMainSignature(ir::ScriptFunction *func) void ETSChecker::BuildFunctionSignature(ir::ScriptFunction *func, bool isConstructSig) { + ES2PANDA_ASSERT(func != nullptr); bool isArrow = func->IsArrow(); + // note(Ekko): For extenal function overload, need to not change ast tree, for arrow type, need perferred type. + if (func->Signature() != nullptr && !isArrow) { + return; + } auto *nameVar = isArrow ? nullptr : func->Id()->Variable(); auto funcName = nameVar == nullptr ? util::StringView() : nameVar->Name(); @@ -1519,14 +1743,10 @@ void ETSChecker::BuildFunctionSignature(ir::ScriptFunction *func, bool isConstru checker::ETSFunctionType *ETSChecker::BuildMethodType(ir::ScriptFunction *func) { ES2PANDA_ASSERT(!func->IsArrow()); + ES2PANDA_ASSERT(func != nullptr); auto *nameVar = func->Id()->Variable(); - ETSFunctionType *funcType; - if (func->IsDynamic()) { - funcType = CreateETSDynamicMethodType(nameVar->Name(), {{func->Signature()}, ProgramAllocator()->Adapter()}, - func->Language()); - } else { - funcType = CreateETSMethodType(nameVar->Name(), {{func->Signature()}, ProgramAllocator()->Adapter()}); - } + ETSFunctionType *funcType = + CreateETSMethodType(nameVar->Name(), {{func->Signature()}, ProgramAllocator()->Adapter()}); funcType->SetVariable(nameVar); return funcType; } @@ -1542,7 +1762,7 @@ Signature *ETSChecker::CheckEveryAbstractSignatureIsOverridden(ETSFunctionType * for (auto sourceSig : source->CallSignatures()) { if ((*targetSig)->Function()->Id()->Name() == sourceSig->Function()->Id()->Name() && Relation()->SignatureIsSupertypeOf(*targetSig, sourceSig)) { - target->CallSignatures().erase(targetSig); + targetSig = target->CallSignatures().erase(targetSig); isOverridden = true; break; } @@ -1654,14 +1874,14 @@ Signature *ETSChecker::AdjustForTypeParameters(Signature *source, Signature *tar if (sourceTypeParams.empty()) { return target; } - auto *substitution = NewSubstitution(); + auto substitution = Substitution {}; for (size_t ix = 0; ix < sourceTypeParams.size(); ix++) { if (!targetTypeParams[ix]->IsETSTypeParameter()) { continue; } - EmplaceSubstituted(substitution, targetTypeParams[ix]->AsETSTypeParameter(), sourceTypeParams[ix]); + EmplaceSubstituted(&substitution, targetTypeParams[ix]->AsETSTypeParameter(), sourceTypeParams[ix]); } - return target->Substitute(Relation(), substitution); + return target->Substitute(Relation(), &substitution); } void ETSChecker::ReportOverrideError(Signature *signature, Signature *overriddenSignature, @@ -1733,7 +1953,7 @@ bool ETSChecker::CheckOverride(Signature *signature, ETSObjectType *site) auto *target = site->GetProperty(signature->Function()->Id()->Name(), flags); bool isOverridingAnySignature = false; - if (target == nullptr) { + if (target == nullptr || target->TsType() == nullptr || !target->TsType()->IsETSFunctionType()) { return isOverridingAnySignature; } @@ -1778,7 +1998,9 @@ bool ETSChecker::CheckOverride(Signature *signature, ETSObjectType *site) void ETSChecker::CheckOverride(Signature *signature) { + ES2PANDA_ASSERT(signature != nullptr); auto *owner = signature->Owner(); + ES2PANDA_ASSERT(owner != nullptr); bool isOverriding = false; if (!owner->HasObjectFlag(ETSObjectFlags::CLASS | ETSObjectFlags::INTERFACE)) { @@ -1993,7 +2215,9 @@ std::string ETSChecker::GetAsyncImplName(const util::StringView &name) std::string ETSChecker::GetAsyncImplName(ir::MethodDefinition *asyncMethod) { - ir::Identifier *asyncName = asyncMethod->Function()->Id(); + ir::ScriptFunction *scriptFunc = asyncMethod->Function(); + CHECK_NOT_NULL(scriptFunc); + ir::Identifier *asyncName = scriptFunc->Id(); ES2PANDA_ASSERT_POS(asyncName != nullptr, asyncMethod->Start()); return GetAsyncImplName(asyncName->Name()); } @@ -2024,11 +2248,13 @@ ir::MethodDefinition *ETSChecker::CreateMethod(const util::StringView &name, ir: // CC-OFFNXT(G.FMT.05-CPP) project codestyle clang format off body, ir::FunctionSignature(nullptr, std::move(params), returnType), flags, modifiers}); // clang-format on + ES2PANDA_ASSERT(func != nullptr); func->SetScope(scope); func->SetIdent(nameId); if (body != nullptr && body->IsBlockStatement()) { body->AsBlockStatement()->SetScope(scope); } + ES2PANDA_ASSERT(scope != nullptr); scope->BindNode(func); paramScope->BindNode(func); scope->BindParamScope(paramScope); @@ -2061,7 +2287,9 @@ varbinder::FunctionParamScope *ETSChecker::CopyParams( for (auto *const it : params) { auto *const paramOld = it->AsETSParameterExpression(); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *const paramNew = paramOld->Clone(ProgramAllocator(), paramOld->Parent())->AsETSParameterExpression(); + auto *typeOld = paramOld->Clone(ProgramAllocator(), paramOld->Parent()); + ES2PANDA_ASSERT(typeOld != nullptr); + auto *const paramNew = typeOld->AsETSParameterExpression(); varbinder::Variable *var = VarBinder()->AddParamDecl(paramNew); Type *paramType = paramOld->Variable()->TsType(); @@ -2127,11 +2355,8 @@ void ETSChecker::MoveTrailingBlockToEnclosingBlockStatement(ir::CallExpression * } using SFunctionData = ir::ScriptFunction::ScriptFunctionData; -void ETSChecker::TransformTraillingLambda(ir::CallExpression *callExpr, Signature *sig) +ir::ScriptFunction *ETSChecker::CreateLambdaFunction(ir::BlockStatement *trailingBlock, Signature *sig) { - auto *trailingBlock = callExpr->TrailingBlock(); - ES2PANDA_ASSERT(trailingBlock != nullptr); - auto *funcParamScope = varbinder::LexicalScope(VarBinder()).GetScope(); auto paramCtx = varbinder::LexicalScope::Enter(VarBinder(), funcParamScope, false); @@ -2178,7 +2403,19 @@ void ETSChecker::TransformTraillingLambda(ir::CallExpression *callExpr, Signatur funcParamScope->BindNode(funcNode); trailingBlock->SetScope(funcScope); - ReplaceScope(funcNode->Body(), trailingBlock, funcScope); + + return funcNode; +} + +void ETSChecker::TransformTraillingLambda(ir::CallExpression *callExpr, Signature *sig) +{ + auto *trailingBlock = callExpr->TrailingBlock(); + ES2PANDA_ASSERT(trailingBlock != nullptr); + + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + auto *funcNode = CreateLambdaFunction(trailingBlock, sig); + funcNode->AddFlag(ir::ScriptFunctionFlags::TRAILING_LAMBDA); + ReplaceScope(funcNode->Body(), trailingBlock, funcNode->Scope()); callExpr->SetTrailingBlock(nullptr); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -2197,6 +2434,7 @@ ArenaVector ETSChecker::ExtendArgumentsWithFakeLamda(ir::CallE ArenaVector statements(ProgramAllocator()->Adapter()); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *body = ProgramAllocNode(ProgramAllocator(), std::move(statements)); + ES2PANDA_ASSERT(body != nullptr); body->SetScope(funcScope); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -2204,10 +2442,12 @@ ArenaVector ETSChecker::ExtendArgumentsWithFakeLamda(ir::CallE ProgramAllocator(), ir::ScriptFunction::ScriptFunctionData {body, ir::FunctionSignature(nullptr, std::move(params), nullptr), ir::ScriptFunctionFlags::ARROW}); + ES2PANDA_ASSERT(funcNode != nullptr); funcNode->SetScope(funcScope); funcScope->BindNode(funcNode); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *arrowFuncNode = ProgramAllocNode(funcNode, ProgramAllocator()); + ES2PANDA_ASSERT(arrowFuncNode != nullptr); arrowFuncNode->SetParent(callExpr); ArenaVector fakeArguments = callExpr->Arguments(); @@ -2262,7 +2502,7 @@ void ETSChecker::CollectReturnStatements(ir::AstNode *parent) }); } -ArenaVector &ETSChecker::PendingConstraintCheckRecords() +std::vector &ETSChecker::PendingConstraintCheckRecords() { return pendingConstraintCheckRecords_; } @@ -2272,30 +2512,23 @@ size_t &ETSChecker::ConstraintCheckScopesCount() return constraintCheckScopesCount_; } -bool ETSChecker::CmpAssemblerTypesWithRank(Signature const *const sig1, Signature const *const sig2) noexcept +bool ETSChecker::HasSameAssemblySignature(Signature const *const sig1, Signature const *const sig2) noexcept { - for (size_t ix = 0U; ix < sig1->Params().size(); ++ix) { - std::stringstream s1; - std::stringstream s2; - sig1->Params()[ix]->TsType()->ToAssemblerTypeWithRank(s1); - sig2->Params()[ix]->TsType()->ToAssemblerTypeWithRank(s2); - if (s1.str() != s2.str()) { - return false; - break; - } + if (sig1->ReturnType()->ToAssemblerTypeWithRank() != sig2->ReturnType()->ToAssemblerTypeWithRank()) { + return false; } - return true; -} -bool ETSChecker::HasSameAssemblySignature(Signature const *const sig1, Signature const *const sig2) noexcept -{ if (sig1->ArgCount() != sig2->ArgCount()) { return false; } - if (!CmpAssemblerTypesWithRank(sig1, sig2)) { - return false; + for (size_t ix = 0U; ix < sig1->Params().size(); ++ix) { + if (sig1->Params()[ix]->TsType()->ToAssemblerTypeWithRank() != + sig2->Params()[ix]->TsType()->ToAssemblerTypeWithRank()) { + return false; + } } + auto *rv1 = sig1->RestVar(); auto *rv2 = sig2->RestVar(); if (rv1 == nullptr && rv2 == nullptr) { @@ -2304,11 +2537,8 @@ bool ETSChecker::HasSameAssemblySignature(Signature const *const sig1, Signature if (rv1 == nullptr || rv2 == nullptr) { // exactly one of them is null return false; } - std::stringstream s1; - std::stringstream s2; - rv1->TsType()->ToAssemblerTypeWithRank(s1); - rv2->TsType()->ToAssemblerTypeWithRank(s2); - return s1.str() == s2.str(); + + return (rv1->TsType()->ToAssemblerTypeWithRank() == rv2->TsType()->ToAssemblerTypeWithRank()); } bool ETSChecker::HasSameAssemblySignatures(ETSFunctionType const *const func1, @@ -2324,4 +2554,324 @@ bool ETSChecker::HasSameAssemblySignatures(ETSFunctionType const *const func1, return false; } +Signature *ETSChecker::FirstMatchSignatures(ir::CallExpression *expr, checker::Type *calleeType) +{ + if (expr->TrailingBlock() == nullptr) { + auto *signature = + MatchOrderSignatures(calleeType->AsETSFunctionType()->CallSignaturesOfMethodOrArrow(), expr->TypeParams(), + expr->Arguments(), expr->Start(), TypeRelationFlag::NONE); + if (signature == nullptr) { + ThrowOverloadMismatch(calleeType->AsETSFunctionType()->Name(), expr->Arguments(), expr->Start(), "call"); + return nullptr; + } + UpdateDeclarationFromSignature(expr, signature); + return signature; + } + + auto &signatures = expr->IsETSConstructorCall() ? calleeType->AsETSObjectType()->ConstructSignatures() + : calleeType->AsETSFunctionType()->CallSignaturesOfMethodOrArrow(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + return ResolveTrailingLambda(signatures, expr, expr->Start()); +} + +Signature *ETSChecker::MatchOrderSignatures(ArenaVector &signatures, + const ir::TSTypeParameterInstantiation *typeArguments, + const ArenaVector &arguments, + const lexer::SourcePosition &pos, TypeRelationFlag resolveFlags) +{ + Signature *compatibleSignatures = nullptr; + Signature *notVisibleSignature = nullptr; + std::vector argTypeInferenceRequired = FindTypeInferenceArguments(arguments); + + auto collectSignatures = [&](TypeRelationFlag relationFlags) { + for (auto *sig : signatures) { + if (notVisibleSignature != nullptr && + !IsSignatureAccessible(sig, Context().ContainingClass(), Relation())) { + continue; + } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + auto *concreteSig = ValidateOrderSignature(std::make_tuple(sig, typeArguments, relationFlags), arguments, + pos, argTypeInferenceRequired, signatures.size() == 1); + + if (concreteSig == nullptr) { + CleanArgumentsInformation(arguments); + continue; + } + if (notVisibleSignature == nullptr && + !IsSignatureAccessible(sig, Context().ContainingClass(), Relation())) { + CleanArgumentsInformation(arguments); + notVisibleSignature = concreteSig; + } else { + compatibleSignatures = concreteSig; + return; + } + } + }; + + collectSignatures(signatures.size() == 1 ? TypeRelationFlag::WIDENING | resolveFlags + : TypeRelationFlag::WIDENING | TypeRelationFlag::NO_THROW | resolveFlags); + + if (compatibleSignatures != nullptr) { + return compatibleSignatures; + } + + if (notVisibleSignature != nullptr && ((resolveFlags & TypeRelationFlag::NO_THROW) == 0)) { + LogError(diagnostic::SIG_INVISIBLE, {notVisibleSignature->Function()->Id()->Name(), notVisibleSignature}, pos); + } + + return nullptr; +} + +Signature *ETSChecker::ValidateOrderSignature( + std::tuple info, + const ArenaVector &arguments, const lexer::SourcePosition &pos, + const std::vector &argTypeInferenceRequired, const bool unique) +{ + auto [baseSignature, typeArguments, flags] = info; + // In case of overloads, it is necessary to iterate through the compatible signatures again, + // setting the boxing/unboxing flag for the arguments if needed. + // So handle substitution arguments only in the case of unique function or collecting signature phase. + Signature *const signature = + MaybeSubstituteTypeParameters(this, baseSignature, typeArguments, arguments, pos, flags); + if (signature == nullptr) { + return nullptr; + } + + // When process first match, if current signature is not matched, do not log TypeError + SignatureMatchContext signatureMatchContext(this, util::DiagnosticType::SEMANTIC, + (flags & TypeRelationFlag::NO_THROW) == 0); + + size_t const argCount = arguments.size(); + auto const hasRestParameter = signature->RestVar() != nullptr; + size_t compareCount = argCount; + if ((flags & TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA) != 0 && !signature->Params().empty() && + signature->Params().back()->Declaration()->Node()->AsETSParameterExpression()->IsOptional()) { + compareCount = compareCount - 1; + } + + if (compareCount < signature->MinArgCount() || (argCount > signature->ArgCount() && !hasRestParameter)) { + LogError(diagnostic::PARAM_COUNT_MISMATCH, {signature->MinArgCount(), argCount}, pos); + return nullptr; + } + + if (argCount > signature->ArgCount() && hasRestParameter && (flags & TypeRelationFlag::IGNORE_REST_PARAM) != 0) { + return nullptr; + } + + auto count = std::min(signature->ArgCount(), argCount); + // Check all required formal parameter(s) first + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + if (!ValidateOrderSignatureRequiredParams(signature, arguments, flags, argTypeInferenceRequired) || + !signatureMatchContext.ValidSignatureMatchStatus()) { + return nullptr; + } + + // Check rest parameter(s) if any exists + if (!hasRestParameter || (count >= argCount && !signature->RestVar()->TsType()->IsETSTupleType())) { + return signature; + } + if (!ValidateSignatureRestParams(signature, arguments, flags, true, unique)) { + return nullptr; + } + + return signature; +} + +bool ETSChecker::SetPreferredTypeBeforeValidate(Signature *substitutedSig, ir::Expression *argument, size_t index, + TypeRelationFlag flags, + const std::vector &argTypeInferenceRequired) +{ + auto const paramType = GetNonNullishType(substitutedSig->Params()[index]->TsType()); + if (argument->IsObjectExpression()) { + argument->AsObjectExpression()->SetPreferredType(paramType); + } + + if (argument->IsMemberExpression()) { + SetArrayPreferredTypeForNestedMemberExpressions(argument->AsMemberExpression(), paramType); + } + + if (argTypeInferenceRequired[index]) { + if (!paramType->IsETSFunctionType()) { + return false; + } + ES2PANDA_ASSERT(argument->IsArrowFunctionExpression()); + auto *param = substitutedSig->Params()[index]->Declaration()->Node()->AsETSParameterExpression(); + auto *lambda = argument->AsArrowFunctionExpression(); + if (lambda->Function()->Params().size() > + paramType->AsETSFunctionType()->CallSignaturesOfMethodOrArrow().front()->Params().size()) { + return false; + } + return CheckLambdaInfer(param->TypeAnnotation(), argument->AsArrowFunctionExpression(), paramType); + } + + if (argument->IsArrayExpression()) { + argument->AsArrayExpression()->SetPreferredTypeBasedOnFuncParam(this, paramType, flags); + } + + if (argument->IsETSNewArrayInstanceExpression()) { + argument->AsETSNewArrayInstanceExpression()->SetPreferredTypeBasedOnFuncParam(this, paramType, flags); + } + + if (argument->IsETSNewMultiDimArrayInstanceExpression()) { + argument->AsETSNewMultiDimArrayInstanceExpression()->SetPreferredTypeBasedOnFuncParam(this, paramType, flags); + } + + return true; +} + +bool ETSChecker::ValidateOrderSignatureRequiredParams(Signature *substitutedSig, + const ArenaVector &arguments, + TypeRelationFlag flags, + const std::vector &argTypeInferenceRequired) +{ + auto commonArity = std::min(arguments.size(), substitutedSig->ArgCount()); + if ((flags & TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA) != 0) { + commonArity = commonArity - 1; + } + for (size_t index = 0; index < commonArity; ++index) { + auto &argument = arguments[index]; + if (!SetPreferredTypeBeforeValidate(substitutedSig, argument, index, flags, argTypeInferenceRequired)) { + return false; + } + + if (argument->IsSpreadElement()) { + LogError(diagnostic::SPREAD_ONTO_SINGLE_PARAM, {}, argument->Start()); + return false; + } + + if (argument->IsIdentifier() && IsInvalidArgumentAsIdentifier(Scope(), argument->AsIdentifier())) { + LogError(diagnostic::ARG_IS_CLASS_ID, {}, argument->Start()); + return false; + } + + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + if (!ValidateOrderSignatureInvocationContext(substitutedSig, argument, index, flags)) { + return false; + } + } + + if ((flags & TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA) != 0 && arguments.back()->IsArrowFunctionExpression()) { + ir::ScriptFunction *const lambda = arguments.back()->AsArrowFunctionExpression()->Function(); + auto targetParm = substitutedSig->GetSignatureInfo()->params.back()->Declaration()->Node(); + if (!CheckLambdaAssignable(targetParm->AsETSParameterExpression(), lambda)) { + return false; + } + } + return true; +} + +void ETSChecker::CleanArgumentsInformation(const ArenaVector &arguments) +{ + if (arguments.empty()) { + return; + } + for (auto *argument : arguments) { + argument->CleanCheckInformation(); + } +} + +bool ETSChecker::ValidateOrderSignatureInvocationContext(Signature *substitutedSig, ir::Expression *argument, + std::size_t index, TypeRelationFlag flags) +{ + Type *targetType = substitutedSig->Params()[index]->TsType(); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + Type *argumentType = argument->Check(this); + + flags |= TypeRelationFlag::ONLY_CHECK_WIDENING; + + auto const invocationCtx = + checker::InvocationContext(Relation(), argument, argumentType, targetType, argument->Start(), + {{diagnostic::TYPE_MISMATCH_AT_IDX, {argumentType, targetType, index + 1}}}, flags); + + return invocationCtx.IsInvocable(); +} + +Signature *ETSChecker::ResolveTrailingLambda(ArenaVector &signatures, ir::CallExpression *callExpr, + const lexer::SourcePosition &pos, const TypeRelationFlag reportFlag) +{ + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + auto arguments = ExtendArgumentsWithFakeLamda(callExpr); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + auto sig = ResolvePotentialTrailingLambda(callExpr, signatures, arguments); + if (sig != nullptr) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + TransformTraillingLambda(callExpr, sig); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + TrailingLambdaTypeInference(sig, callExpr->Arguments()); + UpdateDeclarationFromSignature(callExpr, sig); + callExpr->SetIsTrailingCall(true); + return sig; + } + + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + sig = MatchOrderSignatures(signatures, callExpr->TypeParams(), callExpr->Arguments(), pos, reportFlag); + if (sig != nullptr) { + EnsureValidCurlyBrace(callExpr); + } + + UpdateDeclarationFromSignature(callExpr, sig); + return sig; +} + +Signature *ETSChecker::ResolvePotentialTrailingLambda(ir::CallExpression *callExpr, + ArenaVector const &signatures, + ArenaVector &arguments) +{ + auto *trailingLambda = arguments.back()->AsArrowFunctionExpression(); + ArenaVector normalSig(ProgramAllocator()->Adapter()); + ArenaVector sigContainLambdaWithReceiverAsParam(ProgramAllocator()->Adapter()); + Signature *signature = nullptr; + for (auto sig : signatures) { + if (!IsLastParameterLambdaWithReceiver(sig)) { + normalSig.emplace_back(sig); + continue; + } + + auto *candidateFunctionType = + sig->Function()->Params().back()->AsETSParameterExpression()->TypeAnnotation()->AsETSFunctionType(); + auto *currentReceiver = candidateFunctionType->Params()[0]; + trailingLambda->Function()->EmplaceParams(currentReceiver); + sigContainLambdaWithReceiverAsParam.emplace_back(sig); + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + signature = MatchOrderSignatures(sigContainLambdaWithReceiverAsParam, callExpr->TypeParams(), arguments, + callExpr->Start(), + TypeRelationFlag::NO_THROW | TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA); + if (signature != nullptr) { + return signature; + } + sigContainLambdaWithReceiverAsParam.clear(); + trailingLambda->Function()->ClearParams(); + } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + return MatchOrderSignatures(normalSig, callExpr->TypeParams(), arguments, callExpr->Start(), + TypeRelationFlag::NO_THROW | TypeRelationFlag::NO_CHECK_TRAILING_LAMBDA); +} + +void ETSChecker::ThrowOverloadMismatch(util::StringView callName, const ArenaVector &arguments, + const lexer::SourcePosition &pos, std::string_view signatureKind) +{ + std::string msg {}; + msg.append(callName.Mutf8()); + msg += "("; + + for (std::size_t index = 0U; index < arguments.size(); ++index) { + auto const &argument = arguments[index]; + Type const *const argumentType = argument->Check(this); + if (!argumentType->IsTypeError()) { + msg += argumentType->ToString(); + } else { + // NOTE (DZ): extra cases for some specific nodes can be added here (as for 'ArrowFunctionExpression') + msg += argument->ToString(); + } + + if (index == arguments.size() - 1U) { + msg += ")"; + LogError(diagnostic::NO_MATCHING_SIG, {signatureKind, msg.c_str()}, pos); + return; + } + + msg += ", "; + } +} + } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/ets/function_helpers.h b/ets2panda/checker/ets/function_helpers.h index 2ed4c6b430b254b5237d17726eaa2200711f2c37..7730c65f761e4decde9ef61df925a6af35a41b56 100644 --- a/ets2panda/checker/ets/function_helpers.h +++ b/ets2panda/checker/ets/function_helpers.h @@ -54,6 +54,7 @@ namespace ark::es2panda::checker { static Type *MaybeBoxedType(ETSChecker *checker, Type *type, ir::Expression *expr) { + ES2PANDA_ASSERT(type != nullptr); if (!type->IsETSPrimitiveType()) { return type; } @@ -77,6 +78,7 @@ static void InferUntilFail(Signature const *const signature, const ArenaVectorAddStatus(checker::CheckerStatus::IN_TYPE_INFER); // some ets lib files require type infer from arg index 0,1,... , not fit to build graph + ES2PANDA_ASSERT(substitution != nullptr); while (anyChange && substitution->size() < sigParams.size()) { anyChange = false; for (size_t ix = 0; ix < arguments.size(); ++ix) { @@ -116,81 +118,82 @@ static void InferUntilFail(Signature const *const signature, const ArenaVectorRemoveStatus(checker::CheckerStatus::IN_TYPE_INFER); } -static const Substitution *BuildImplicitSubstitutionForArguments(ETSChecker *checker, Signature *signature, - const ArenaVector &arguments) +static std::optional BuildImplicitSubstitutionForArguments(ETSChecker *checker, Signature *signature, + const ArenaVector &arguments) { - Substitution *substitution = checker->NewSubstitution(); + auto substitution = Substitution {}; auto *sigInfo = signature->GetSignatureInfo(); auto &sigParams = signature->GetSignatureInfo()->typeParams; - InferUntilFail(signature, arguments, checker, substitution); + InferUntilFail(signature, arguments, checker, &substitution); - if (substitution->size() != sigParams.size()) { + if (substitution.size() != sigParams.size()) { for (const auto typeParam : sigParams) { auto newTypeParam = typeParam->AsETSTypeParameter(); - if (auto it = substitution->find(newTypeParam); it != substitution->cend()) { + if (auto it = substitution.find(newTypeParam); it != substitution.cend()) { continue; } if (newTypeParam->GetDefaultType() == nullptr) { - checker->EmplaceSubstituted(substitution, newTypeParam, checker->GlobalETSNeverType()); + checker->EmplaceSubstituted(&substitution, newTypeParam, checker->GlobalETSNeverType()); continue; } - auto dflt = newTypeParam->GetDefaultType()->Substitute(checker->Relation(), substitution); - if (!checker->EnhanceSubstitutionForType(sigInfo->typeParams, newTypeParam, dflt, substitution)) { - return nullptr; + auto dflt = newTypeParam->GetDefaultType()->Substitute(checker->Relation(), &substitution); + if (!checker->EnhanceSubstitutionForType(sigInfo->typeParams, newTypeParam, dflt, &substitution)) { + return std::nullopt; } } } - if (substitution->size() != sigParams.size() && + if (substitution.size() != sigParams.size() && (signature->Function()->ReturnTypeAnnotation() == nullptr || !checker->EnhanceSubstitutionForType(sigInfo->typeParams, signature->Function()->ReturnTypeAnnotation()->TsType(), - signature->ReturnType(), substitution))) { - return nullptr; + signature->ReturnType(), &substitution))) { + return std::nullopt; } return substitution; } -static const Substitution *BuildExplicitSubstitutionForArguments(ETSChecker *checker, Signature *signature, - const ArenaVector ¶ms, - const lexer::SourcePosition &pos, - TypeRelationFlag flags) +static std::optional BuildExplicitSubstitutionForArguments(ETSChecker *checker, Signature *signature, + const ArenaVector ¶ms, + const lexer::SourcePosition &pos, + TypeRelationFlag flags) { auto &sigParams = signature->GetSignatureInfo()->typeParams; - auto *substitution = checker->NewSubstitution(); - auto *constraintsSubstitution = checker->NewSubstitution(); + auto substitution = Substitution {}; + auto constraintsSubstitution = Substitution {}; ArenaVector instArgs {checker->Allocator()->Adapter()}; for (size_t ix = 0; ix < params.size(); ++ix) { instArgs.push_back(MaybeBoxedType(checker, params[ix]->GetType(checker), params[ix])); if (ix < sigParams.size()) { - checker->EmplaceSubstituted(constraintsSubstitution, sigParams[ix]->AsETSTypeParameter(), instArgs[ix]); + checker->EmplaceSubstituted(&constraintsSubstitution, sigParams[ix]->AsETSTypeParameter(), instArgs[ix]); } } for (size_t ix = instArgs.size(); ix < sigParams.size(); ++ix) { - auto *dflt = sigParams[ix]->AsETSTypeParameter()->GetDefaultType(); + auto typeParam = sigParams[ix]->AsETSTypeParameter(); + auto *dflt = typeParam->GetDefaultType(); if (dflt == nullptr) { break; } - dflt = dflt->Substitute(checker->Relation(), constraintsSubstitution); + dflt = dflt->Substitute(checker->Relation(), &constraintsSubstitution); instArgs.push_back(dflt); - checker->EmplaceSubstituted(constraintsSubstitution, sigParams[ix]->AsETSTypeParameter(), instArgs[ix]); + checker->EmplaceSubstituted(&constraintsSubstitution, typeParam, instArgs[ix]); } if (sigParams.size() != instArgs.size()) { if ((flags & TypeRelationFlag::NO_THROW) == static_cast>(0U)) { checker->LogError(diagnostic::RTYPE_PARAM_COUNT_MISMATCH, {sigParams.size(), instArgs.size()}, pos); } - return nullptr; + return std::nullopt; } for (size_t ix = 0; ix < sigParams.size(); ix++) { if (!checker->IsCompatibleTypeArgument(sigParams[ix]->AsETSTypeParameter(), instArgs[ix], - constraintsSubstitution)) { - return nullptr; + &constraintsSubstitution)) { + return std::nullopt; } - checker->EmplaceSubstituted(substitution, sigParams[ix]->AsETSTypeParameter(), instArgs[ix]); + checker->EmplaceSubstituted(&substitution, sigParams[ix]->AsETSTypeParameter(), instArgs[ix]); } return substitution; } @@ -204,12 +207,12 @@ static Signature *MaybeSubstituteTypeParameters(ETSChecker *checker, Signature * return signature; } - const Substitution *substitution = + const std::optional substitution = (typeArguments != nullptr) ? BuildExplicitSubstitutionForArguments(checker, signature, typeArguments->Params(), pos, flags) : BuildImplicitSubstitutionForArguments(checker, signature, arguments); - return (substitution == nullptr) ? nullptr : signature->Substitute(checker->Relation(), substitution); + return (!substitution.has_value()) ? nullptr : signature->Substitute(checker->Relation(), &substitution.value()); } static bool CheckInterfaceOverride(ETSChecker *const checker, ETSObjectType *const interface, diff --git a/ets2panda/checker/ets/helpers.cpp b/ets2panda/checker/ets/helpers.cpp index c79994490201528c5a6ea780ce6461e168ff88bc..66b876183569d8533df241ea89e09c9b3215bacb 100644 --- a/ets2panda/checker/ets/helpers.cpp +++ b/ets2panda/checker/ets/helpers.cpp @@ -13,15 +13,20 @@ * limitations under the License. */ +#include #include "checker/ETSchecker.h" #include "checker/types/globalTypesHolder.h" +#include "checker/checkerContext.h" +#include "checker/ETSAnalyzerHelpers.h" +#include "checker/types/ets/etsEnumType.h" #include "checker/types/ets/etsTupleType.h" #include "checker/ets/typeRelationContext.h" #include "checker/ets/typeConverter.h" #include "evaluate/scopedDebugInfoPlugin.h" #include "compiler/lowering/scopesInit/scopesInitPhase.h" #include "compiler/lowering/util.h" +#include "util/helpers.h" namespace ark::es2panda::checker { @@ -39,7 +44,8 @@ std::pair ETSChecker::FindVariable return {nullptr, nullptr}; } const auto searchFlags = PropertySearchFlags::SEARCH_ALL | PropertySearchFlags::SEARCH_IN_BASE | - PropertySearchFlags::SEARCH_IN_INTERFACES; + PropertySearchFlags::SEARCH_IN_INTERFACES | + PropertySearchFlags::DISALLOW_SYNTHETIC_METHOD_CREATION; auto *resolved = classType->GetProperty(name, searchFlags); while (classType->EnclosingType() != nullptr && resolved == nullptr) { classType = classType->EnclosingType(); @@ -58,8 +64,10 @@ varbinder::Variable *ETSChecker::FindVariableInGlobal(const ir::Identifier *cons bool ETSChecker::IsVariableStatic(const varbinder::Variable *var) { + CHECK_NOT_NULL(var); if (var->HasFlag(varbinder::VariableFlags::METHOD)) { - return var->TsType()->AsETSFunctionType()->CallSignatures()[0]->HasSignatureFlag(SignatureFlags::STATIC); + return var->TsType()->IsETSFunctionType() && + var->TsType()->AsETSFunctionType()->CallSignatures()[0]->HasSignatureFlag(SignatureFlags::STATIC); } return var->HasFlag(varbinder::VariableFlags::STATIC); } @@ -69,6 +77,12 @@ bool ETSChecker::IsVariableGetterSetter(const varbinder::Variable *var) return var != nullptr && var->TsType() != nullptr && var->TsType()->HasTypeFlag(TypeFlag::GETTER_SETTER); } +bool ETSChecker::IsVariableOverloadDeclaration(const varbinder::Variable *var) +{ + return var != nullptr && var->Declaration() != nullptr && var->Declaration()->Node() != nullptr && + var->Declaration()->Node()->IsOverloadDeclaration(); +} + bool ETSChecker::IsVariableExtensionAccessor(const varbinder::Variable *var) { return var != nullptr && var->TsType() != nullptr && var->TsType()->IsETSFunctionType() && @@ -97,11 +111,13 @@ void ETSChecker::WrongContextErrorClassifyByType(ir::Identifier *ident) varbinder::VariableFlags::TYPE))) { case varbinder::VariableFlags::CLASS: identCategoryName = "Class"; - break; + LogError(diagnostic::NOT_AS_OBJECT, {identCategoryName}, ident->Start()); + return; case varbinder::VariableFlags::NAMESPACE: identCategoryName = "Namespace"; - break; + LogError(diagnostic::NOT_AS_OBJECT, {identCategoryName}, ident->Start()); + return; case varbinder::VariableFlags::METHOD: identCategoryName = "Function"; @@ -287,6 +303,9 @@ Type *ETSChecker::ResolveIdentifier(ir::Identifier *ident) if (resolved == nullptr) { resolved = ExtraCheckForResolvedError(ident); if (resolved == nullptr) { + if (VarBinder()->GetScope()->IsClassScope() && this->IsAnyError()) { + return ident->SetTsType(GlobalTypeError()); + } auto [decl, var] = VarBinder()->NewVarDecl( ident->Start(), !ident->IsErrorPlaceHolder() ? ident->Name() : compiler::GenName(ProgramAllocator()).View()); @@ -306,6 +325,10 @@ Type *ETSChecker::ResolveIdentifier(ir::Identifier *ident) ValidatePropertyAccess(resolved, Context().ContainingClass(), ident->Start()); SaveCapturedVariable(resolved, ident); + if (IsVariableOverloadDeclaration(resolved)) { + return CreateSyntheticTypeFromOverload(resolved); + } + return GetTypeOfVariable(resolved); } @@ -369,31 +392,53 @@ checker::Type *ETSChecker::ApplyConditionalOperatorPromotion(checker::ETSChecker ES2PANDA_UNREACHABLE(); } -Type *ETSChecker::ApplyUnaryOperatorPromotion(Type *type, const bool createConst, const bool doPromotion, - const bool isCondExpr) +Type *ETSChecker::GetUnaryOperatorPromotedType(Type *type, const bool doPromotion) +{ + auto globalTypesHolder = GetGlobalTypesHolder(); + + if (doPromotion) { + if (type == globalTypesHolder->GlobalByteBuiltinType() || type == globalTypesHolder->GlobalShortBuiltinType() || + type == globalTypesHolder->GlobalCharBuiltinType() || + type == globalTypesHolder->GlobalIntegerBuiltinType()) { + return GlobalIntBuiltinType(); + } + + if (type->IsIntType() || type->IsByteType() || type->IsShortType() || type->IsCharType()) { + return GlobalIntBuiltinType(); + } + } + + return type; +} + +Type *ETSChecker::ApplyUnaryOperatorPromotion(ir::Expression *expr, Type *type, const bool isCondExpr) { Type *unboxedType = isCondExpr ? MaybeUnboxConditionalInRelation(type) : MaybeUnboxInRelation(type); + if (type != nullptr && type->IsETSIntEnumType()) { + expr->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); + unboxedType = type->AsETSEnumType()->GetBaseEnumElementType(this); + } + if (unboxedType == nullptr) { return nullptr; } - if (doPromotion) { - switch (ETSType(unboxedType)) { - case TypeFlag::BYTE: - case TypeFlag::SHORT: - case TypeFlag::CHAR: { - if (!createConst) { - return GlobalIntType(); - } - return CreateIntTypeFromType(unboxedType); - } - default: { - break; - } - } + switch (ETSType(unboxedType)) { + case TypeFlag::BYTE: + [[fallthrough]]; + case TypeFlag::SHORT: + [[fallthrough]]; + case TypeFlag::CHAR: + [[fallthrough]]; + case TypeFlag::INT: + return GlobalIntBuiltinType(); + + default: + break; } - return unboxedType; + + return type; } bool ETSChecker::IsNullLikeOrVoidExpression(const ir::Expression *expr) const @@ -405,7 +450,7 @@ bool ETSChecker::IsNullLikeOrVoidExpression(const ir::Expression *expr) const std::tuple ETSChecker::IsResolvedAndValue(const ir::Expression *expr, Type *type) const { auto [isResolve, isValue] = - IsNullLikeOrVoidExpression(expr) ? std::make_tuple(true, false) : type->ResolveConditionExpr(); + IsNullLikeOrVoidExpression(expr) ? std::make_tuple(true, false) : IsConstantTestValue(expr); const Type *tsType = expr->TsType(); if (tsType->DefinitelyNotETSNullish() && !type->IsETSPrimitiveOrEnumType()) { @@ -452,30 +497,6 @@ Type *ETSChecker::HandleBooleanLogicalOperators(Type *leftType, Type *rightType, return nullptr; } -bool ETSChecker::HandleLogicalPotentialResult(ir::Expression *left, ir::Expression *right, ir::BinaryExpression *expr, - checker::Type *leftType) -{ - if (leftType->IsConstantType() && leftType->IsETSBooleanType()) { - if (expr->OperatorType() == lexer::TokenType::PUNCTUATOR_LOGICAL_AND) { - expr->SetResult(leftType->AsETSBooleanType()->GetValue() ? right : left); - return true; - } - expr->SetResult(leftType->AsETSBooleanType()->GetValue() ? left : right); - return true; - } - - if (!leftType->IsETSPrimitiveType() && !leftType->PossiblyETSValueTyped()) { - expr->SetResult(expr->OperatorType() == lexer::TokenType::PUNCTUATOR_LOGICAL_AND ? right : left); - return true; - } - if (leftType->IsETSNullType() || leftType->IsETSUndefinedType()) { - expr->SetResult(expr->OperatorType() == lexer::TokenType::PUNCTUATOR_LOGICAL_AND ? left : right); - return true; - } - - return false; -} - void ETSChecker::ResolveReturnStatement(checker::Type *funcReturnType, checker::Type *argumentType, ir::ScriptFunction *containingFunc, ir::ReturnStatement *st) { @@ -500,8 +521,6 @@ void ETSChecker::ResolveReturnStatement(checker::Type *funcReturnType, checker:: argumentType = MaybeBoxInRelation(argumentType); if (argumentType == nullptr) { LogError(diagnostic::INVALID_EXPR_IN_RETURN, {}, st->Argument()->Start()); - } else { - st->Argument()->AddBoxingUnboxingFlags(GetBoxingFlag(argumentType)); } } @@ -536,7 +555,6 @@ checker::Type *ETSChecker::CheckArrayElements(ir::ArrayExpression *init) for (auto *typeFromTuple : elementType->AsETSTupleType()->GetTupleTypesList()) { elementTypes.emplace_back(typeFromTuple); } - continue; } @@ -544,22 +562,33 @@ checker::Type *ETSChecker::CheckArrayElements(ir::ArrayExpression *init) elementType = elementType->AsETSArrayType()->ElementType(); } - elementTypes.push_back(GetNonConstantType(elementType)); + elementTypes.emplace_back(elementType); } if (elementTypes.empty()) { - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return ProgramAllocator()->New(GlobalETSObjectType()); + if (init->PreferredType() != nullptr) { + return init->PreferredType(); + } + LogError(diagnostic::UNRESOLVABLE_ARRAY, {}, init->Start()); + return GetGlobalTypesHolder()->GlobalTypeError(); } - auto const isNumeric = [](checker::Type *ct) { return ct->HasTypeFlag(TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC); }; - auto const isChar = [](checker::Type *ct) { return ct->HasTypeFlag(TypeFlag::CHAR); }; - auto *const arrayElementType = - std::all_of(elementTypes.begin(), elementTypes.end(), isNumeric) - ? std::all_of(elementTypes.begin(), elementTypes.end(), isChar) ? GlobalCharType() : GlobalDoubleType() - : CreateETSUnionType(std::move(elementTypes)); + auto const isNumericLiteral = [this](checker::Type *&ct) { + auto const rc = + ct->IsConstantType() && Relation()->IsSupertypeOf(GetGlobalTypesHolder()->GlobalNumericBuiltinType(), ct); + ct = GetNonConstantType(ct); + return rc; + }; + auto const isChar = [this](checker::Type *ct) { + return Relation()->IsSupertypeOf(GetGlobalTypesHolder()->GlobalCharBuiltinType(), ct); + }; + auto const elementType = std::all_of(elementTypes.begin(), elementTypes.end(), isNumericLiteral) + ? std::all_of(elementTypes.begin(), elementTypes.end(), isChar) + ? GlobalCharBuiltinType() + : GlobalDoubleBuiltinType() + : CreateETSUnionType(std::move(elementTypes)); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return CreateETSResizableArrayType(arrayElementType); + return CreateETSResizableArrayType(elementType); } void ETSChecker::InferAliasLambdaType(ir::TypeNode *localTypeAnnotation, ir::ArrowFunctionExpression *init) @@ -594,15 +623,13 @@ void ETSChecker::InferAliasLambdaType(ir::TypeNode *localTypeAnnotation, ir::Arr } } -checker::Type *ETSChecker::FixOptionalVariableType(varbinder::Variable *const bindingVar, ir::ModifierFlags flags, - ir::Expression *init) +checker::Type *ETSChecker::FixOptionalVariableType(varbinder::Variable *const bindingVar, ir::ModifierFlags flags) { if ((flags & ir::ModifierFlags::OPTIONAL) != 0) { - if (init != nullptr && bindingVar->TsType()->IsETSPrimitiveType()) { - init->SetBoxingUnboxingFlags(GetBoxingFlag(bindingVar->TsType())); - } + ES2PANDA_ASSERT(bindingVar != nullptr); auto *variableType = bindingVar->TsType() != nullptr ? bindingVar->TsType() : GlobalTypeError(); - bindingVar->SetTsType(CreateETSUnionType({GlobalETSUndefinedType(), variableType})); + bindingVar->SetTsType( + !variableType->IsTypeError() ? CreateETSUnionType({GlobalETSUndefinedType(), variableType}) : variableType); } return bindingVar->TsType(); } @@ -639,8 +666,9 @@ checker::Type *PreferredObjectTypeFromAnnotation(checker::Type *annotationType) return nullptr; } -bool SetPreferredTypeForExpression(ETSChecker *checker, ir::Identifier *ident, ir::TypeNode *typeAnnotation, - ir::Expression *init, checker::Type *annotationType) +// CC-OFFNXT(huge_cyclomatic_complexity, huge_cca_cyclomatic_complexity[C++]) solid logic +static bool SetPreferredTypeForExpression(ETSChecker *checker, ir::Identifier *ident, ir::TypeNode *typeAnnotation, + ir::Expression *init, checker::Type *annotationType) { if (init->IsMemberExpression() && init->AsMemberExpression()->Object()->IsObjectExpression()) { checker->LogError(diagnostic::MEMBER_OF_OBJECT_LIT, {}, ident->Start()); @@ -654,7 +682,7 @@ bool SetPreferredTypeForExpression(ETSChecker *checker, ir::Identifier *ident, i checker->SetArrayPreferredTypeForNestedMemberExpressions(init->AsMemberExpression(), annotationType); } - if (init->IsArrayExpression() && (annotationType != nullptr) && !annotationType->IsETSDynamicType()) { + if (init->IsArrayExpression() && (annotationType != nullptr)) { if (annotationType->IsETSTupleType() && !checker->IsArrayExprSizeValidForTuple(init->AsArrayExpression(), annotationType->AsETSTupleType())) { return false; @@ -664,14 +692,17 @@ bool SetPreferredTypeForExpression(ETSChecker *checker, ir::Identifier *ident, i } if (init->IsObjectExpression() && annotationType != nullptr) { - init->AsObjectExpression()->SetPreferredType(PreferredObjectTypeFromAnnotation(annotationType)); + init->SetPreferredType(PreferredObjectTypeFromAnnotation(annotationType)); } if (init->IsETSNewArrayInstanceExpression() && annotationType != nullptr) { - init->AsETSNewArrayInstanceExpression()->SetPreferredType(annotationType); + init->SetPreferredType(annotationType); } if (init->IsETSNewMultiDimArrayInstanceExpression() && annotationType != nullptr) { - init->AsETSNewMultiDimArrayInstanceExpression()->SetPreferredType(annotationType); + init->SetPreferredType(annotationType); + } + if (init->IsNumberLiteral() && annotationType != nullptr) { + init->SetPreferredType(annotationType); } if (typeAnnotation != nullptr && init->IsArrowFunctionExpression()) { @@ -755,6 +786,7 @@ static void CheckAssignForDeclare(ir::Identifier *ident, ir::TypeNode *typeAnnot return; } const bool isConst = (flags & ir::ModifierFlags::CONST) != 0; + ES2PANDA_ASSERT(init != nullptr); bool numberLiteralButNotBigInt = init->IsNumberLiteral() && !init->IsBigIntLiteral(); bool multilineLiteralWithNoEmbedding = init->IsTemplateLiteral() && init->AsTemplateLiteral()->Expressions().empty(); @@ -763,38 +795,87 @@ static void CheckAssignForDeclare(ir::Identifier *ident, ir::TypeNode *typeAnnot } } +static void CheckRecordSpreadElement(ir::SpreadElement *spreadElement, ArenaVector &typeArguments, + ETSChecker *checker, const lexer::SourcePosition &start) +{ + auto spreadArg = spreadElement->Argument(); + auto spreadType = spreadArg->Check(checker); + // Verify spread source is also a Record type + if (!spreadType->IsETSObjectType()) { + checker->LogError(diagnostic::INVALID_RECORD_PROPERTY, start); + return; + } + // Check if spread type is Record or Map using proper type identity checking + auto *spreadObjType = spreadType->AsETSObjectType(); + auto *spreadOriginalBaseType = spreadObjType->GetOriginalBaseType(); + auto *globalTypes = checker->GetGlobalTypesHolder(); + if (!checker->IsTypeIdenticalTo(spreadOriginalBaseType, globalTypes->GlobalMapBuiltinType()) && + !checker->IsTypeIdenticalTo(spreadOriginalBaseType, globalTypes->GlobalRecordBuiltinType())) { + checker->LogError(diagnostic::INVALID_RECORD_PROPERTY, start); + return; + } + // Verify type parameters match + auto spreadTypeArgs = spreadType->AsETSObjectType()->TypeArguments(); + constexpr size_t EXPECTED_TYPE_ARGUMENTS_SIZE = 2; + if (spreadTypeArgs.size() != EXPECTED_TYPE_ARGUMENTS_SIZE) { + checker->LogError(diagnostic::INVALID_RECORD_PROPERTY, start); + return; + } + // Checking if the key type is a subtype of the type argument + if (!checker->Relation()->IsSupertypeOf(typeArguments[0], spreadTypeArgs[0])) { + checker->LogError(diagnostic::TYPE_MISMATCH_AT_IDX, {spreadTypeArgs[0], typeArguments[0], size_t(1)}, start); + } + checker::AssignmentContext(checker->Relation(), spreadArg, spreadTypeArgs[1], typeArguments[1], start, + util::DiagnosticWithParams {diagnostic::TYPE_MISMATCH_AT_IDX, + {spreadTypeArgs[1], typeArguments[1], size_t(2)}}); +} + +static void CheckRecordProperty(ir::Property *p, ArenaVector &typeArguments, ETSChecker *checker) +{ + p->Key()->SetPreferredType(typeArguments[0]); + p->Value()->SetPreferredType(typeArguments[1]); + + checker::Type *keyType = p->Key()->Check(checker); + checker::Type *valueType = p->Value()->Check(checker); + + // Checking if the key type is a subtype of the type argument + if (!checker->Relation()->IsSupertypeOf(typeArguments[0], keyType)) { + checker->LogError(diagnostic::TYPE_MISMATCH_AT_IDX, {keyType, typeArguments[0], size_t(1)}, p->Key()->Start()); + } + checker::AssignmentContext( + checker->Relation(), p->Value(), valueType, typeArguments[1], p->Value()->Start(), + util::DiagnosticWithParams {diagnostic::TYPE_MISMATCH_AT_IDX, {valueType, typeArguments[1], size_t(2)}}); +} + static void CheckRecordType(ir::Expression *init, checker::Type *annotationType, ETSChecker *checker) { if (!annotationType->IsETSObjectType() || !init->IsObjectExpression()) { return; } + // Check if this is actually a Record or Map type using proper type identity checking + auto *objType = annotationType->AsETSObjectType(); + auto *originalBaseType = objType->GetOriginalBaseType(); + auto *globalTypes = checker->GetGlobalTypesHolder(); - std::stringstream ss; - init->TsType()->ToAssemblerType(ss); - if (ss.str() != "escompat.Record" && ss.str() != "escompat.Map") { + if (!checker->IsTypeIdenticalTo(originalBaseType, globalTypes->GlobalMapBuiltinType()) && + !checker->IsTypeIdenticalTo(originalBaseType, globalTypes->GlobalRecordBuiltinType())) { return; } auto objectExpr = init->AsObjectExpression(); auto typeArguments = annotationType->AsETSObjectType()->TypeArguments(); auto properties = objectExpr->Properties(); - for (const auto &property : properties) { - ES2PANDA_ASSERT(property->IsProperty()); - auto p = property->AsProperty(); - - ETSChecker::SetPreferredTypeIfPossible(p->Key(), typeArguments[0]); - ETSChecker::SetPreferredTypeIfPossible(p->Value(), typeArguments[1]); - - Type *keyType = p->Key()->Check(checker); - Type *valueType = p->Value()->Check(checker); + if (property->IsSpreadElement()) { + CheckRecordSpreadElement(property->AsSpreadElement(), typeArguments, checker, property->Start()); + continue; + } + if (!property->IsProperty()) { + checker->LogError(diagnostic::INVALID_RECORD_PROPERTY, property->Start()); + continue; + } - checker::AssignmentContext( - checker->Relation(), p->Key(), keyType, typeArguments[0], p->Key()->Start(), - util::DiagnosticWithParams {diagnostic::TYPE_MISMATCH_AT_IDX, {keyType, typeArguments[0], size_t(1)}}); - checker::AssignmentContext( - checker->Relation(), p->Value(), valueType, typeArguments[1], p->Value()->Start(), - util::DiagnosticWithParams {diagnostic::TYPE_MISMATCH_AT_IDX, {valueType, typeArguments[1], size_t(2)}}); + CheckRecordProperty(property->AsProperty(), typeArguments, checker); } } @@ -802,6 +883,7 @@ static void CheckRecordType(ir::Expression *init, checker::Type *annotationType, checker::Type *ETSChecker::CheckVariableDeclaration(ir::Identifier *ident, ir::TypeNode *typeAnnotation, ir::Expression *init, ir::ModifierFlags const flags) { + ES2PANDA_ASSERT(ident != nullptr); varbinder::Variable *const bindingVar = ident->Variable(); checker::Type *annotationType = nullptr; @@ -813,7 +895,7 @@ checker::Type *ETSChecker::CheckVariableDeclaration(ir::Identifier *ident, ir::T } if (init == nullptr) { - return FixOptionalVariableType(bindingVar, flags, init); + return FixOptionalVariableType(bindingVar, flags); } CheckAssignForDeclare(ident, typeAnnotation, init, flags, this); } else { @@ -832,11 +914,15 @@ checker::Type *ETSChecker::CheckVariableDeclaration(ir::Identifier *ident, ir::T ES2PANDA_ASSERT(IsAnyError()); } - // initType should not be nullptr. If an error occurs during check, set it to GlobalTypeError(). - if (bindingVar == nullptr || initType == nullptr || initType->IsTypeError()) { + if (bindingVar == nullptr) { return annotationType != nullptr ? annotationType : GlobalTypeError(); } + // initType should not be nullptr. If an error occurs during check, set it to GlobalTypeError(). + if (initType == nullptr || initType->IsTypeError()) { + return bindingVar->SetTsType(annotationType != nullptr ? annotationType : GlobalTypeError()); + } + if (typeAnnotation == nullptr && initType->IsETSFunctionType()) { annotationType = initType->AsETSFunctionType(); bindingVar->SetTsType(annotationType); @@ -863,7 +949,7 @@ checker::Type *ETSChecker::CheckVariableDeclaration(ir::Identifier *ident, ir::T bindingVar->SetTsType(needWidening ? GetNonConstantType(initType) : initType); } - return FixOptionalVariableType(bindingVar, flags, init); + return FixOptionalVariableType(bindingVar, flags); } void ETSChecker::VariableTypeFromInitializer(varbinder::Variable *variable, Type *annotationType, Type *initType) @@ -1010,64 +1096,50 @@ checker::Type *ETSChecker::GetExtensionAccessorReturnType(ir::MemberExpression * // Smart cast support //==============================================================================// -checker::Type *ETSChecker::ResolveSmartType(checker::Type *sourceType, checker::Type *targetType) +static checker::Type *MaybeReadonlyType(ETSChecker *checker, checker::Type *sourceType, checker::Type *targetType) { - // For left-hand variable of primitive type leave it as is. - if (targetType->IsETSPrimitiveType()) { + // For left-hand variable of builtin type leave it as is. + if (targetType->IsBuiltinNumeric()) { return targetType; } - // For left-hand variable of tuple type leave it as is. - if (targetType->IsETSTupleType()) { - return targetType; + // Preserve 'Readonly' type flag in smart type if it exists in declared type + if (targetType->HasTypeFlag(TypeFlag::READONLY) && !sourceType->HasTypeFlag(TypeFlag::READONLY)) { + sourceType = sourceType->Clone(checker); + sourceType->AddTypeFlag(TypeFlag::READONLY); } + return sourceType; +} + +checker::Type *ETSChecker::ResolveSmartType(checker::Type *sourceType, checker::Type *targetType, + std::optional value) +{ + // For left-hand variable of primitive type leave it as is. + ES2PANDA_ASSERT(!targetType->IsETSPrimitiveType() && !sourceType->IsETSPrimitiveType()); // For left-hand invalid variable set smart type to right-hand type. if (targetType->IsTypeError()) { return sourceType; } - // For left-hand variable of builtin type leave it as is. - if (targetType->IsETSObjectType() && targetType->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_TYPE)) { - return targetType; - } - - // Nothing to do with identical types: - auto *nonConstSourceType = GetNonConstantType(sourceType); - auto *nonConstTargetType = GetNonConstantType(targetType); - - if (Relation()->IsIdenticalTo(nonConstSourceType, nonConstTargetType) || - Relation()->IsIdenticalTo(GlobalBuiltinJSValueType(), nonConstTargetType)) { - return targetType; - } - // For type parameter, null or undefined source type return it as is. if (sourceType->IsETSTypeParameter() || sourceType->DefinitelyETSNullish()) { return sourceType; } - // In case of Union left-hand type we have to select the proper type from the Union - // Because now we have logging of errors we have to continue analyze incorrect program, for - // this case we change typeError to source type. - if (targetType->IsETSUnionType()) { - auto component = targetType->AsETSUnionType()->GetAssignableType(this, sourceType); - return component->IsTypeError() ? MaybeBoxType(sourceType) : component; - } - - // If source is reference type, set it as the current and use it for identifier smart cast - if (sourceType->IsETSReferenceType()) { - return sourceType; + // In case of Union left-hand type we try to select the proper type from the Union + if (targetType->IsETSUnionType() && !sourceType->IsUnionType()) { + auto *constituentType = targetType->AsETSUnionType()->GetAssignableType(this, sourceType, value); + if (constituentType != nullptr) { + return MaybeReadonlyType(this, sourceType, constituentType); + } } - // For right-hand variable of primitive type apply boxing conversion (case: 'let x: Object = 5', then x => Int). - if (sourceType->IsETSPrimitiveType() && !sourceType->IsETSVoidType() && targetType->IsETSObjectType()) { - return MaybeBoxInRelation(sourceType); + // General case - return more specific subtype + if (Relation()->IsSupertypeOf(targetType, sourceType)) { + return MaybeReadonlyType(this, sourceType, targetType); } - // NOTE - it seems that all the other possible cases are assignments like: - // 'Object = ObjectLiteral' or smth similar ??? - // thus for such cases also leave the target type as is. - // Possible errors in tests should clarify this hypothesis sooner or later :) return targetType; } @@ -1086,7 +1158,7 @@ std::pair ETSChecker::CheckTestNullishCondition(Type *testedType return {GlobalETSUndefinedType(), RemoveUndefinedType(actualType)}; } - return {GlobalETSNullishType(), GetNonNullishType(actualType)}; + return {GlobalETSUnionUndefinedNull(), GetNonNullishType(actualType)}; } // Auxiliary method to reduce the size of common 'CheckTestSmartCastConditions' function. @@ -1505,8 +1577,8 @@ static void CollectAliasParametersForBoxing(Type *expandedAliasType, std::setIsETSObjectType()) { auto objectType = expandedAliasType->AsETSObjectType(); - needToBeBoxed = - objectType->GetDeclNode()->IsClassDefinition() || objectType->GetDeclNode()->IsTSInterfaceDeclaration(); + needToBeBoxed = objectType->GetDeclNode() != nullptr && (objectType->GetDeclNode()->IsClassDefinition() || + objectType->GetDeclNode()->IsTSInterfaceDeclaration()); for (const auto typeArgument : objectType->TypeArguments()) { CollectAliasParametersForBoxing(typeArgument, parametersNeedToBeBoxed, needToBeBoxed); } @@ -1557,7 +1629,7 @@ bool ETSChecker::CheckMinimumTypeArgsPresent(const ir::TSTypeAliasDeclaration *t ir::TypeNode *ETSChecker::ResolveTypeNodeForTypeArg(const ir::TSTypeAliasDeclaration *typeAliasNode, const ir::TSTypeParameterInstantiation *typeParams, size_t idx) { - if (typeParams->Params().size() > idx) { + if (typeParams != nullptr && typeParams->Params().size() > idx) { return typeParams->Params().at(idx); } @@ -1567,41 +1639,48 @@ ir::TypeNode *ETSChecker::ResolveTypeNodeForTypeArg(const ir::TSTypeAliasDeclara Type *ETSChecker::HandleTypeAlias(ir::Expression *const name, const ir::TSTypeParameterInstantiation *const typeParams, ir::TSTypeAliasDeclaration *const typeAliasNode) { - // NOTE (mmartin): modify for default params - if ((typeParams == nullptr) != (typeAliasNode->TypeParams() == nullptr)) { - if (typeParams == nullptr) { + if (typeParams == nullptr && typeAliasNode->TypeParams() != nullptr) { + auto declTypeParams = typeAliasNode->TypeParams()->Params(); + auto isAllTypeParamsHasDefaultType = + std::find_if(declTypeParams.begin(), declTypeParams.end(), [](ir::TSTypeParameter *param) { + return param->DefaultType() == nullptr; + }) == declTypeParams.end(); + if (!isAllTypeParamsHasDefaultType) { LogError(diagnostic::GENERIC_ALIAS_WITHOUT_PARAMS, {}, name->Start()); return GlobalTypeError(); } + } + if (typeParams != nullptr && typeAliasNode->TypeParams() == nullptr) { LogError(diagnostic::NON_GENERIC_ALIAS_WITH_PARAMS, {}, typeParams->Start()); return GlobalTypeError(); } - if (typeParams == nullptr) { + if (typeParams == nullptr && typeAliasNode->TypeParams() == nullptr) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return GetReferencedTypeBase(name); } - for (auto *const origTypeParam : typeParams->Params()) { - origTypeParam->Check(this); + if (typeParams != nullptr) { + for (auto *const origTypeParam : typeParams->Params()) { + origTypeParam->Check(this); + } + if (CheckMinimumTypeArgsPresent(typeAliasNode, typeParams)) { + return GlobalTypeError(); + } } // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Type *const aliasType = GetReferencedTypeBase(name); - auto *substitution = NewSubstitution(); - - if (CheckMinimumTypeArgsPresent(typeAliasNode, typeParams)) { - return GlobalTypeError(); - } + auto substitution = Substitution {}; std::set parametersNeedToBeBoxed; - auto expandedAliasType = aliasType->Substitute(Relation(), substitution); + auto expandedAliasType = aliasType->Substitute(Relation(), &substitution); CollectAliasParametersForBoxing(expandedAliasType, parametersNeedToBeBoxed, false); for (std::size_t idx = 0; idx < typeAliasNode->TypeParams()->Params().size(); ++idx) { auto *typeAliasTypeName = typeAliasNode->TypeParams()->Params().at(idx)->Name(); - auto *typeAliasType = typeAliasTypeName->Variable()->TsType(); + auto *typeAliasType = typeAliasTypeName->Variable()->TsType()->MaybeBaseTypeOfGradualType(); if (!typeAliasType->IsETSTypeParameter()) { continue; } @@ -1614,13 +1693,13 @@ Type *ETSChecker::HandleTypeAlias(ir::Expression *const name, const ir::TSTypePa paramType = boxedType; } } - substitution->insert({typeAliasType->AsETSTypeParameter(), paramType}); // #21835: type argument is not boxed + substitution.insert({typeAliasType->AsETSTypeParameter(), paramType}); // #21835: type argument is not boxed } // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ValidateGenericTypeAliasForClonedNode(typeAliasNode->AsTSTypeAliasDeclaration(), typeParams); - return aliasType->Substitute(Relation(), substitution); + return aliasType->Substitute(Relation(), &substitution); } std::vector ETSChecker::GetNameForSynteticObjectType(const util::StringView &source) @@ -1669,6 +1748,9 @@ void ETSChecker::BindingsModuleObjectAddProperty(checker::ETSObjectType *moduleO for (auto [_, var] : bindings) { (void)_; auto [found, aliasedName] = FindSpecifierForModuleObject(importDecl, var->AsLocalVariable()->Name()); + if (!var->AsLocalVariable()->Declaration()->Node()->IsValidInCurrentPhase()) { + continue; + } if ((var->AsLocalVariable()->Declaration()->Node()->IsExported()) && found) { if (!aliasedName.Empty()) { moduleObjType->AddReExportAlias(var->Declaration()->Name(), aliasedName); @@ -1696,8 +1778,8 @@ util::StringView ETSChecker::FindPropNameForNamespaceImport(const util::StringVi } // Helps to prevent searching for the imported file among external sources if it is the entry program -static parser::Program *SelectEntryOrExternalProgram(varbinder::ETSBinder *etsBinder, - const util::StringView &importPath) +parser::Program *ETSChecker::SelectEntryOrExternalProgram(varbinder::ETSBinder *etsBinder, + const util::StringView &importPath) { if (importPath.Is(etsBinder->GetGlobalRecordTable()->Program()->AbsoluteName().Mutf8())) { return etsBinder->GetGlobalRecordTable()->Program(); @@ -1713,26 +1795,43 @@ void ETSChecker::SetPropertiesForModuleObject(checker::ETSObjectType *moduleObjT parser::Program *program = SelectEntryOrExternalProgram(static_cast(VarBinder()), importPath); // Check imported properties before assigning them to module object + ES2PANDA_ASSERT(program != nullptr); if (!program->IsASTChecked()) { // NOTE: helps to avoid endless loop in case of recursive imports that uses all bindings program->SetASTChecked(); program->Ast()->Check(this); } + if (program->IsDeclForDynamicStaticInterop()) { + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->StaticFieldScope()->Bindings(), importPath); + + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->StaticMethodScope()->Bindings(), importPath); + + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->StaticDeclScope()->Bindings(), importPath); - BindingsModuleObjectAddProperty( - moduleObjType, importDecl, program->GlobalClassScope()->StaticFieldScope()->Bindings(), importPath); + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->InstanceDeclScope()->Bindings(), importPath); - BindingsModuleObjectAddProperty( - moduleObjType, importDecl, program->GlobalClassScope()->StaticMethodScope()->Bindings(), importPath); + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->TypeAliasScope()->Bindings(), importPath); + } else { + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->StaticFieldScope()->Bindings(), importPath); + + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->StaticMethodScope()->Bindings(), importPath); - BindingsModuleObjectAddProperty( - moduleObjType, importDecl, program->GlobalClassScope()->StaticDeclScope()->Bindings(), importPath); + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->StaticDeclScope()->Bindings(), importPath); - BindingsModuleObjectAddProperty( - moduleObjType, importDecl, program->GlobalClassScope()->InstanceDeclScope()->Bindings(), importPath); + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->InstanceDeclScope()->Bindings(), importPath); - BindingsModuleObjectAddProperty( - moduleObjType, importDecl, program->GlobalClassScope()->TypeAliasScope()->Bindings(), importPath); + BindingsModuleObjectAddProperty( + moduleObjType, importDecl, program->GlobalClassScope()->TypeAliasScope()->Bindings(), importPath); + } } void ETSChecker::SetrModuleObjectTsType(ir::Identifier *local, checker::ETSObjectType *moduleObjType) @@ -1757,7 +1856,15 @@ Type *ETSChecker::GetReferencedTypeBase(ir::Expression *name) return name->Check(this); } + if (name->IsMemberExpression()) { + return name->Check(this); + } + ES2PANDA_ASSERT(name->IsIdentifier()); + if (name->AsIdentifier()->Variable() == nullptr) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + VarBinder()->AsETSBinder()->LookupTypeReference(name->AsIdentifier()); + } auto *const var = name->AsIdentifier()->Variable(); ES2PANDA_ASSERT(var != nullptr); @@ -1766,11 +1873,6 @@ Type *ETSChecker::GetReferencedTypeBase(ir::Expression *name) return name->SetTsType(GlobalTypeError()); } - auto *importData = VarBinder()->AsETSBinder()->DynamicImportDataForVar(var); - if (importData != nullptr && importData->import->IsPureDynamic()) { - return name->SetTsType(GlobalBuiltinDynamicType(importData->import->Language())); - } - return name->SetTsType(ResolveReferencedType(var->AsLocalVariable(), name)); } @@ -1807,6 +1909,7 @@ checker::Type *ETSChecker::GetElementTypeOfArray(checker::Type *type) if (type->IsTypeError()) { return GlobalTypeError(); } + if (type->IsETSArrayType()) { return type->AsETSArrayType()->ElementType(); } @@ -1829,7 +1932,9 @@ void ETSChecker::ConcatConstantString(util::UString &target, Type *type) { switch (ETSType(type)) { case TypeFlag::ETS_OBJECT: { - ES2PANDA_ASSERT(type->IsETSStringType()); + if (!type->IsETSStringType()) { + break; + } target.Append(type->AsETSStringType()->GetValue()); break; } @@ -2014,8 +2119,9 @@ varbinder::VariableFlags ETSChecker::GetAccessFlagFromNode(const ir::AstNode *no Type *ETSChecker::CheckSwitchDiscriminant(ir::Expression *discriminant) { - discriminant->Check(this); - auto *discriminantType = GetNonConstantType(MaybeUnboxExpression(discriminant)); + Type *discriminantType = discriminant->Check(this); + discriminantType = GetNonConstantType(MaybeUnboxType(discriminantType)); + ES2PANDA_ASSERT(discriminantType != nullptr); if (!discriminantType->HasTypeFlag(TypeFlag::VALID_SWITCH_TYPE)) { if (!(discriminantType->IsETSObjectType() && discriminantType->AsETSObjectType()->HasObjectFlag( @@ -2027,33 +2133,12 @@ Type *ETSChecker::CheckSwitchDiscriminant(ir::Expression *discriminant) return discriminantType; } -void ETSChecker::AddBoxingUnboxingFlagsToNode(ir::AstNode *node, Type *boxingUnboxingType) -{ - if (boxingUnboxingType->IsETSObjectType()) { - node->AddBoxingUnboxingFlags(GetBoxingFlag(boxingUnboxingType)); - } else if (!boxingUnboxingType->IsETSUnionType()) { - node->AddBoxingUnboxingFlags(GetUnboxingFlag(boxingUnboxingType)); - } -} - Type *ETSChecker::MaybeBoxExpression(ir::Expression *expr) { auto *promoted = MaybeBoxType(expr->TsType()); - if (promoted != expr->TsType()) { - expr->AddBoxingUnboxingFlags(GetBoxingFlag(promoted)); - } return promoted; } -Type *ETSChecker::MaybeUnboxExpression(ir::Expression *expr) -{ - auto *primitive = MaybeUnboxType(expr->TsType()); - if (primitive != expr->TsType()) { - expr->AddBoxingUnboxingFlags(GetUnboxingFlag(primitive)); - } - return primitive; -} - void ETSChecker::CheckForSameSwitchCases(ArenaVector const &cases) { CheckItemCasesConstant(cases); @@ -2148,7 +2233,7 @@ void ETSChecker::CheckItemCasesConstant(ArenaVector c if (caseTest == nullptr) { continue; } - auto *caseType = caseTest->TsType(); + auto *caseType = MaybeUnboxType(caseTest->TsType()); if (caseType->HasTypeFlag(TypeFlag::TYPE_ERROR)) { continue; } @@ -2226,7 +2311,7 @@ void ETSChecker::CheckItemCasesDuplicate(ArenaVector } if (caseTest->IsLiteral() && compareCaseTest->IsLiteral() && - GetStringFromLiteral(caseTest) != GetStringFromLiteral(compareCaseTest)) { + caseTest->AsLiteral()->ToString() != compareCaseTest->AsLiteral()->ToString()) { continue; } @@ -2256,7 +2341,7 @@ bool ETSChecker::CompareIdentifiersValuesAreDifferent(ir::Expression *compareVal return caseValue != compareCaseValue; } - return caseValue != GetStringFromLiteral(compareValue); + return caseValue != compareValue->ToString(); } void ETSChecker::CheckIdentifierSwitchCase(ir::Expression *currentCase, ir::Expression *compareCase, @@ -2280,23 +2365,6 @@ void ETSChecker::CheckIdentifierSwitchCase(ir::Expression *currentCase, ir::Expr } } -std::string ETSChecker::GetStringFromLiteral(ir::Expression *caseTest) const -{ - switch (caseTest->Type()) { - case ir::AstNodeType::CHAR_LITERAL: { - return std::to_string(caseTest->AsCharLiteral()->Char()); - } - case ir::AstNodeType::STRING_LITERAL: - case ir::AstNodeType::NULL_LITERAL: - case ir::AstNodeType::UNDEFINED_LITERAL: - case ir::AstNodeType::NUMBER_LITERAL: { - return util::Helpers::LiteralToPropName(caseTest).Mutf8(); - } - default: - ES2PANDA_UNREACHABLE(); - } -} - bool ETSChecker::IsSameDeclarationType(varbinder::LocalVariable *target, varbinder::LocalVariable *compare) { return target->Declaration()->Type() == compare->Declaration()->Type(); @@ -2327,7 +2395,7 @@ ETSObjectType *ETSChecker::GetRelevantArgumentedTypeFromChild(ETSObjectType *con auto *relevantType = CreateETSObjectType(child->GetDeclNode(), child->ObjectFlags()); ArenaVector params = child->TypeArguments(); - + ES2PANDA_ASSERT(relevantType != nullptr); relevantType->SetTypeArguments(std::move(params)); relevantType->SetEnclosingType(child->EnclosingType()); relevantType->SetSuperType(child->SuperType()); @@ -2340,7 +2408,22 @@ ETSObjectType *ETSChecker::GetRelevantArgumentedTypeFromChild(ETSObjectType *con return GetRelevantArgumentedTypeFromChild(child->SuperType(), target); } +Substitution ETSChecker::ArenaSubstitutionToSubstitution(const ArenaSubstitution *orig) +{ + Substitution copied {}; + std::copy(orig->begin(), orig->end(), std::inserter(copied, copied.end())); + return copied; +} + void ETSChecker::EmplaceSubstituted(Substitution *substitution, ETSTypeParameter *tparam, Type *typeArg) +{ + // *only* reference type may be substituted, no exceptions + ES2PANDA_ASSERT(typeArg->IsETSReferenceType()); + ES2PANDA_ASSERT(substitution != nullptr); + substitution->emplace(tparam, typeArg); +} + +void ETSChecker::EmplaceSubstituted(ArenaSubstitution *substitution, ETSTypeParameter *tparam, Type *typeArg) { // *only* reference type may be substituted, no exceptions ES2PANDA_ASSERT(typeArg->IsETSReferenceType()); @@ -2397,7 +2480,9 @@ util::StringView ETSChecker::GetHashFromFunctionType(ir::ETSFunctionType *type) std::stringstream ss; for (auto *p : type->Params()) { auto *const param = p->AsETSParameterExpression(); - param->TypeAnnotation()->GetType(this)->ToString(ss, true); + auto *paramType = param->TypeAnnotation()->GetType(this); + ES2PANDA_ASSERT(paramType != nullptr); + paramType->ToString(ss, true); ss << ";"; } @@ -2405,23 +2490,19 @@ util::StringView ETSChecker::GetHashFromFunctionType(ir::ETSFunctionType *type) if (type->ReturnType()->IsTSThisType()) { type->Params()[0]->AsETSParameterExpression()->TypeAnnotation()->TsType()->ToString(ss, true); } else { - type->ReturnType()->GetType(this)->ToString(ss, true); + auto *returnType = type->ReturnType()->GetType(this); + ES2PANDA_ASSERT(returnType != nullptr); + returnType->ToString(ss, true); } ss << "extensionFunction;"; } else { - type->ReturnType()->GetType(this)->ToString(ss, true); + auto *returnType = type->ReturnType()->GetType(this); + ES2PANDA_ASSERT(returnType != nullptr); + returnType->ToString(ss, true); } ss << ";"; - if (type->IsThrowing()) { - ss << "throws;"; - } - - if (type->IsRethrowing()) { - ss << "rethrows;"; - } - return util::UString(ss.str(), ProgramAllocator()).View(); } @@ -2502,19 +2583,31 @@ std::vector ETSChecker::FindTypeInferenceArguments(const ArenaVectorAsETSUnionType()->Types()) { if (type->IsETSFunctionType()) { - return lambda->Params().size() == type->AsETSFunctionType()->Params().size(); + assignable |= lambda->Params().size() == type->AsETSFunctionType()->Params().size(); + continue; + } + + if (type->IsETSTypeReference()) { + auto aliasType = util::Helpers::DerefETSTypeReference(type); + assignable |= aliasType->IsETSFunctionType() && + lambda->Params().size() == aliasType->AsETSFunctionType()->Params().size(); } } - return false; + return assignable; } void ETSChecker::InferTypesForLambda(ir::ScriptFunction *lambda, ir::ETSFunctionType *calleeType, Signature *maybeSubstitutedFunctionSig) { for (size_t i = 0; i < lambda->Params().size(); ++i) { + if (!lambda->Params().at(i)->IsETSParameterExpression()) { + LogError(diagnostic::INVALID_LAMBDA_PARAMETER, lambda->Params().at(i)->Start()); + continue; + } auto *const lambdaParam = lambda->Params().at(i)->AsETSParameterExpression()->Ident(); if (lambdaParam->TypeAnnotation() == nullptr) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -2530,7 +2623,6 @@ void ETSChecker::InferTypesForLambda(ir::ScriptFunction *lambda, ir::ETSFunction } if (lambda->ReturnTypeAnnotation() == nullptr) { - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) Type *inferredReturnType = calleeType->ReturnType()->GetType(this); bool isPrimitive = inferredReturnType != nullptr && inferredReturnType->IsETSPrimitiveType(); if (!isPrimitive && maybeSubstitutedFunctionSig != nullptr) { @@ -2544,16 +2636,18 @@ void ETSChecker::InferTypesForLambda(ir::ScriptFunction *lambda, Signature *sign { ES2PANDA_ASSERT(signature->Params().size() >= lambda->Params().size()); for (size_t i = 0; i < lambda->Params().size(); ++i) { + if (!lambda->Params().at(i)->IsETSParameterExpression()) { + LogError(diagnostic::INVALID_LAMBDA_PARAMETER, lambda->Params().at(i)->Start()); + continue; + } auto *const lambdaParam = lambda->Params().at(i)->AsETSParameterExpression()->Ident(); if (lambdaParam->TypeAnnotation() == nullptr) { - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) lambdaParam->Variable()->SetTsType(signature->Params().at(i)->TsType()); lambdaParam->SetTsType(signature->Params().at(i)->TsType()); } } if (lambda->ReturnTypeAnnotation() == nullptr) { - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) lambda->SetPreferredReturnType(signature->ReturnType()); } } @@ -2633,6 +2727,7 @@ ir::ClassProperty *ETSChecker::ClassPropToImplementationProp(ir::ClassProperty * classProp->AddModifier(ir::ModifierFlags::PRIVATE); auto *fieldDecl = ProgramAllocator()->New(classProp->Key()->AsIdentifier()->Name()); + ES2PANDA_ASSERT(fieldDecl != nullptr); fieldDecl->BindNode(classProp); auto fieldVar = scope->InstanceFieldScope()->AddDecl(ProgramAllocator(), fieldDecl, ScriptExtension::ETS); @@ -2713,6 +2808,7 @@ void ETSChecker::GenerateGetterSetterBody(ArenaVector &stmts, A // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto ident = ProgramAllocNode(paramExpression->Ident()->Name(), ProgramAllocator()); ident->SetVariable(paramExpression->Variable()); + ident->SetTsTypeAnnotation(nullptr); auto *assignmentExpression = // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ProgramAllocNode(memberExpression, ident, lexer::TokenType::PUNCTUATOR_SUBSTITUTION); @@ -2734,6 +2830,7 @@ static ir::BlockStatement *GenGetterSetterBodyHelper(ETSChecker *checker, ArenaV return nullptr; } auto *body = checker->ProgramAllocNode(checker->ProgramAllocator(), std::move(stmts)); + ES2PANDA_ASSERT(body != nullptr); body->SetScope(functionScope); return body; } @@ -2750,6 +2847,7 @@ static std::tupleBindParamScope(paramScope); paramScope->BindFunctionScope(functionScope); + auto classCtx = varbinder::LexicalScope::Enter(checker->VarBinder(), classScope); ArenaVector params(checker->ProgramAllocator()->Adapter()); ArenaVector stmts(checker->ProgramAllocator()->Adapter()); @@ -2793,6 +2891,7 @@ ir::MethodDefinition *ETSChecker::GenerateDefaultGetterSetter(ir::ClassProperty auto *methodIdent = property->Key()->AsIdentifier()->Clone(checker->ProgramAllocator(), nullptr); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *funcExpr = checker->ProgramAllocNode(func); + CHECK_NOT_NULL(funcExpr); funcExpr->SetRange(func->Range()); func->AddFlag(ir::ScriptFunctionFlags::METHOD); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -2802,22 +2901,27 @@ ir::MethodDefinition *ETSChecker::GenerateDefaultGetterSetter(ir::ClassProperty auto *decl = checker->ProgramAllocator()->New( checker->ProgramAllocator(), property->Key()->AsIdentifier()->Name(), method); auto *var = checker->ProgramAllocator()->New(decl, varbinder::VariableFlags::VAR); + CHECK_NOT_NULL(var); var->AddFlag(varbinder::VariableFlags::METHOD); methodIdent->SetVariable(var); - method->Id()->SetMutator(); + auto *methodId = method->Id(); + CHECK_NOT_NULL(methodId); + methodId->SetMutator(); method->SetRange(field->Range()); + auto *methodFunc = method->Function(); + CHECK_NOT_NULL(methodFunc); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - method->Function()->SetIdent(method->Id()->Clone(checker->ProgramAllocator(), nullptr)); - method->Function()->AddModifier(method->Modifiers()); + methodFunc->SetIdent(methodId->Clone(checker->ProgramAllocator(), nullptr)); + methodFunc->AddModifier(method->Modifiers()); method->SetVariable(var); method->SetParent(field->Parent()); functionScope->BindNode(func); - auto classCtx = varbinder::LexicalScope::Enter(checker->VarBinder(), classScope); checker->VarBinder()->AsETSBinder()->ResolveMethodDefinition(method); + method->Function()->ClearFlag(ir::ScriptFunctionFlags::EXTERNAL); functionScope->BindName(classScope->Node()->AsClassDefinition()->InternalName()); method->Check(checker); @@ -2836,7 +2940,7 @@ ir::ClassProperty *GetImplementationClassProp(ETSChecker *checker, ir::ClassProp auto *const classProp = checker->ClassPropToImplementationProp( interfaceProp->Clone(checker->ProgramAllocator(), originalProp->Parent()), scope); classType->AddProperty(classProp->Key()->Variable()->AsLocalVariable()); - classDef->Body().push_back(classProp); + classDef->EmplaceBody(classProp); return classProp; } @@ -2854,6 +2958,8 @@ void ETSChecker::SetupGetterSetterFlags(ir::ClassProperty *originalProp, ETSObje ir::MethodDefinition *getter, ir::MethodDefinition *setter, const bool inExternal) { + auto getProgram = [](ir::AstNode *node) { return node->Range().start.Program(); }; + auto *const classDef = classType->GetDeclNode()->AsClassDefinition(); for (auto &method : {getter, setter}) { if (method == nullptr) { @@ -2865,19 +2971,21 @@ void ETSChecker::SetupGetterSetterFlags(ir::ClassProperty *originalProp, ETSObje method->TsType()->AddTypeFlag(tflag); method->Variable()->SetTsType(method->TsType()); + auto *func = method->Function(); + ES2PANDA_ASSERT(func != nullptr); if (((originalProp->Modifiers() & mflag) != 0U)) { - method->Function()->AddModifier(ir::ModifierFlags::OVERRIDE); + func->AddModifier(ir::ModifierFlags::OVERRIDE); } - if (inExternal) { - method->Function()->AddFlag(ir::ScriptFunctionFlags::EXTERNAL); + if (inExternal && !getProgram(originalProp)->IsGenAbcForExternal()) { + func->AddFlag(ir::ScriptFunctionFlags::EXTERNAL); } if (originalProp->IsDeclare()) { method->AddModifier(ir::ModifierFlags::DECLARE); - method->Function()->AddModifier(ir::ModifierFlags::DECLARE); + func->AddModifier(ir::ModifierFlags::DECLARE); } - this->CheckOverride(method->Function()->Signature()); + this->CheckOverride(func->Signature()); method->SetParent(classDef); classType->AddProperty(method->Variable()->AsLocalVariable()); } @@ -2903,7 +3011,7 @@ void ETSChecker::GenerateGetterSetterPropertyAndMethod(ir::ClassProperty *origin // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ir::MethodDefinition *getter = GenerateDefaultGetterSetter(interfaceProp, classProp, scope, false, this); - classDef->Body().push_back(getter); + classDef->EmplaceBody(getter); const auto &name = getter->Key()->AsIdentifier()->Name(); @@ -2936,14 +3044,45 @@ void ETSChecker::GenerateGetterSetterPropertyAndMethod(ir::ClassProperty *origin getter->Variable()->TsType()->AsETSFunctionType()->AddCallSignature( setter->TsType()->AsETSFunctionType()->CallSignatures()[0]); getter->AddOverload(setter); + setter->SetParent(getter); + } +} + +void ETSChecker::CreateTransformedCallee(ir::Identifier *ident, ir::Identifier *classId, ir::Identifier *methodId, + ir::CallExpression *callExpr) +{ + ir::MemberExpression *transformedCallee = nullptr; + classId->SetRange(ident->Range()); + if (ident->Parent()->IsMemberExpression()) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + transformedCallee = ProgramAllocNode( + ident->Parent()->AsMemberExpression(), methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + ident->Parent()->AsMemberExpression()->SetParent(transformedCallee); + } else { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + transformedCallee = ProgramAllocNode( + classId, methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, false); + transformedCallee->SetParent(callExpr); } + + methodId->SetRange(ident->Range()); + transformedCallee->SetRange(ident->Range()); + // Note: Should not modify the AST + // Related issue: #issue27122 + callExpr->SetCallee(transformedCallee); } // CC-OFFNXT(huge_method[C++], G.FUN.01-CPP) solid logic bool ETSChecker::TryTransformingToStaticInvoke(ir::Identifier *const ident, const Type *resolvedType) { - ES2PANDA_ASSERT(ident->Parent()->IsCallExpression()); - ES2PANDA_ASSERT(ident->Parent()->AsCallExpression()->Callee() == ident); + ir::CallExpression *callExpr = nullptr; + if (ident->Parent()->IsMemberExpression()) { + callExpr = ident->Parent()->Parent()->AsCallExpression(); + } else { + ES2PANDA_ASSERT(ident->Parent()->IsCallExpression()); + ES2PANDA_ASSERT(ident->Parent()->AsCallExpression()->Callee() == ident); + callExpr = ident->Parent()->AsCallExpression(); + } if (!resolvedType->IsETSObjectType()) { return false; @@ -2978,21 +3117,10 @@ bool ETSChecker::TryTransformingToStaticInvoke(ir::Identifier *const ident, cons } else if (propertyName == compiler::Signatures::STATIC_INVOKE_METHOD) { methodId->SetVariable(invokeMethod); } - - auto *transformedCallee = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(classId, methodId, ir::MemberExpressionKind::PROPERTY_ACCESS, false, - false); - - classId->SetRange(ident->Range()); - methodId->SetRange(ident->Range()); - transformedCallee->SetRange(ident->Range()); - - auto *callExpr = ident->Parent()->AsCallExpression(); - transformedCallee->SetParent(callExpr); - callExpr->SetCallee(transformedCallee); - + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + CreateTransformedCallee(ident, classId, methodId, callExpr); if (instantiateMethod != nullptr) { + auto lexScope {varbinder::LexicalScope::Enter(VarBinder(), compiler::NearestScope(callExpr))}; // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *argExpr = GenerateImplicitInstantiateArg(std::string(className)); @@ -3020,6 +3148,7 @@ void ETSChecker::ImportNamespaceObjectTypeAddReExportType(ir::ETSImportDeclarati if (reExportType->IsTypeError()) { continue; } + ES2PANDA_ASSERT(lastObjectType != nullptr); lastObjectType->AddReExports(reExportType->AsETSObjectType()); for (auto node : importDecl->Specifiers()) { if (node->IsImportSpecifier()) { @@ -3053,6 +3182,7 @@ Type *ETSChecker::GetImportSpecifierObjectType(ir::ETSImportDeclaration *importD auto *rootDecl = ProgramAllocator()->New(moduleName); varbinder::LocalVariable *rootVar = ProgramAllocator()->New(rootDecl, varbinder::VariableFlags::NONE); + ES2PANDA_ASSERT(rootVar != nullptr); rootVar->SetTsType(moduleObjectType); ImportNamespaceObjectTypeAddReExportType(importDecl, moduleObjectType, ident); @@ -3065,9 +3195,12 @@ Type *ETSChecker::GetImportSpecifierObjectType(ir::ETSImportDeclaration *importD ETSChecker::NamedAccessMeta ETSChecker::FormNamedAccessMetadata(varbinder::Variable const *prop) { + CHECK_NOT_NULL(prop); const auto *field = prop->Declaration()->Node()->AsClassProperty(); const auto *owner = field->Parent()->AsClassDefinition(); - return {owner->TsType()->AsETSObjectType(), field->TsType(), field->Id()->Name()}; + auto *fieldId = field->Id(); + CHECK_NOT_NULL(fieldId); + return {owner->TsType()->AsETSObjectType(), field->TsType(), fieldId->Name()}; } void ETSChecker::ETSObjectTypeDeclNode(ETSChecker *checker, ETSObjectType *const objectType) @@ -3096,6 +3229,7 @@ ir::CallExpression *ETSChecker::CreateExtensionAccessorCall(ETSChecker *checker, // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) callExpr = checker->ProgramAllocNode(expr, std::move(args), nullptr, false, false); } + ES2PANDA_ASSERT(callExpr != nullptr); callExpr->SetRange(expr->Range()); return callExpr->AsCallExpression(); } @@ -3106,7 +3240,7 @@ void ETSChecker::CheckTypeParameterVariance(ir::ClassDefinition *classDef) return; } - Context().SetContainingClass(classDef->TsType()->AsETSObjectType()); + Context().SetContainingClass(classDef->TsType()->MaybeBaseTypeOfGradualType()->AsETSObjectType()); auto checkVariance = [this](VarianceFlag varianceFlag, ir::Expression *expression, Type *type) { Relation()->Result(RelationResult::TRUE); Relation()->SetNode(expression); @@ -3140,19 +3274,6 @@ void ETSChecker::CheckTypeParameterVariance(ir::ClassDefinition *classDef) } } -void ETSChecker::SetPreferredTypeIfPossible(ir::Expression *const expr, Type *const targetType) -{ - // Object expression requires that its type be set by the context before checking. in this case, the target type - // provides that context. - if (expr->IsObjectExpression()) { - expr->AsObjectExpression()->SetPreferredType(targetType); - } - - if (expr->IsArrayExpression()) { - expr->AsArrayExpression()->SetPreferredType(targetType); - } -} - checker::ETSFunctionType *ETSChecker::IntersectSignatureSets(const checker::ETSFunctionType *left, const checker::ETSFunctionType *right) { diff --git a/ets2panda/checker/ets/narrowingConverter.cpp b/ets2panda/checker/ets/narrowingConverter.cpp deleted file mode 100644 index 3b2d1cf9e0b4134083188b7a9ede2a7c6df0e92e..0000000000000000000000000000000000000000 --- a/ets2panda/checker/ets/narrowingConverter.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2021 - 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "narrowingConverter.h" - -namespace ark::es2panda::checker { -} // namespace ark::es2panda::checker diff --git a/ets2panda/checker/ets/narrowingConverter.h b/ets2panda/checker/ets/narrowingConverter.h deleted file mode 100644 index f42051d88b9042d717680e29e899a2d0f472c87b..0000000000000000000000000000000000000000 --- a/ets2panda/checker/ets/narrowingConverter.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2021-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ES2PANDA_COMPILER_CHECKER_ETS_NARROWING_CONVERTER_H -#define ES2PANDA_COMPILER_CHECKER_ETS_NARROWING_CONVERTER_H - -#include "checker/ETSchecker.h" -#include "checker/ets/typeConverter.h" -#include "util/helpers.h" - -namespace ark::es2panda::checker { -class NarrowingConverter : public TypeConverter { -public: - static constexpr TypeFlag NARROWABLE_TO_FLOAT = TypeFlag::DOUBLE; - static constexpr TypeFlag NARROWABLE_TO_LONG = TypeFlag::FLOAT | NARROWABLE_TO_FLOAT; - static constexpr TypeFlag NARROWABLE_TO_INT = TypeFlag::LONG | NARROWABLE_TO_LONG; - static constexpr TypeFlag NARROWABLE_TO_CHAR = TypeFlag::SHORT | TypeFlag::INT | NARROWABLE_TO_INT; - static constexpr TypeFlag NARROWABLE_TO_SHORT = TypeFlag::CHAR | TypeFlag::INT | NARROWABLE_TO_INT; - static constexpr TypeFlag NARROWABLE_TO_BYTE = TypeFlag::CHAR | NARROWABLE_TO_CHAR; - - explicit NarrowingConverter(ETSChecker *checker, TypeRelation *relation, Type *target, Type *source) - : TypeConverter(checker, relation, target, source) - { - if (!relation->ApplyNarrowing()) { - return; - } - - ES2PANDA_ASSERT(relation->GetNode()); - - switch (ETSChecker::ETSChecker::ETSType(target)) { - case TypeFlag::BYTE: { - ApplyNarrowing(NARROWABLE_TO_BYTE); - break; - } - case TypeFlag::CHAR: { - ApplyNarrowing(NARROWABLE_TO_CHAR); - break; - } - case TypeFlag::SHORT: { - ApplyNarrowing(NARROWABLE_TO_SHORT); - break; - } - case TypeFlag::INT: { - ApplyNarrowing(NARROWABLE_TO_INT); - break; - } - case TypeFlag::LONG: { - ApplyNarrowing(NARROWABLE_TO_LONG); - break; - } - case TypeFlag::FLOAT: { - ApplyNarrowing(NARROWABLE_TO_FLOAT); - break; - } - - default: { - break; - } - } - } - -private: - template - void ApplyNarrowing(TypeFlag flag) - { - if (!Source()->HasTypeFlag(flag)) { - return; - } - - switch (ETSChecker::ETSChecker::ETSType(Source())) { - case TypeFlag::CHAR: { - ApplyNarrowing(); - break; - } - case TypeFlag::SHORT: { - ApplyNarrowing(); - break; - } - case TypeFlag::INT: { - ApplyNarrowing(); - break; - } - case TypeFlag::LONG: { - ApplyNarrowing(); - break; - } - case TypeFlag::FLOAT: { - ApplyNarrowing(); - break; - } - case TypeFlag::DOUBLE: { - ApplyNarrowing(); - break; - } - default: { - break; - } - } - } - - template - To CastFloatingPointToIntOrLong(From value) - { - if (std::isinf(value)) { - if (std::signbit(value)) { - return std::numeric_limits::min(); - } - return std::numeric_limits::max(); - } - ES2PANDA_ASSERT(std::is_floating_point_v); - ES2PANDA_ASSERT(std::is_integral_v); - To minInt = std::numeric_limits::min(); - To maxInt = std::numeric_limits::max(); - auto floatMinInt = static_cast(minInt); - auto floatMaxInt = static_cast(maxInt); - - if (value > floatMinInt) { - if (value < floatMaxInt) { - return static_cast(value); - } - return maxInt; - } - if (std::isnan(value)) { - return 0; - } - return minInt; - } - - template - TType CalculateNarrowedValue(Type *target, Type *source, SType value) - { - switch (ETSChecker::ETSChecker::ETSType(target)) { - case TypeFlag::BYTE: - case TypeFlag::CHAR: - case TypeFlag::SHORT: { - if (source->HasTypeFlag(checker::TypeFlag::DOUBLE) || source->HasTypeFlag(checker::TypeFlag::FLOAT)) { - return static_cast(CastFloatingPointToIntOrLong(value)); - } - return static_cast(value); - } - case TypeFlag::INT: - case TypeFlag::LONG: { - if (source->HasTypeFlag(checker::TypeFlag::DOUBLE) || source->HasTypeFlag(checker::TypeFlag::FLOAT)) { - return CastFloatingPointToIntOrLong(value); - } - return static_cast(value); - } - case TypeFlag::FLOAT: - case TypeFlag::DOUBLE: { - return static_cast(value); - } - default: { - ES2PANDA_UNREACHABLE(); - } - } - } - - template - void ApplyNarrowing() - { - using SType = typename SourceType::UType; - using TType = typename TargetType::UType; - - if (Source()->HasTypeFlag(TypeFlag::CONSTANT)) { - SType value = reinterpret_cast(Source())->GetValue(); - if (!Relation()->InCastingContext() && Source()->HasTypeFlag(TypeFlag::ETS_FLOATING_POINT) && - Target()->HasTypeFlag(TypeFlag::ETS_INTEGRAL)) { - auto narrowedValue = CalculateNarrowedValue(Target(), Source(), value); - if (narrowedValue != value) { - Relation()->Result(RelationResult::ERROR); - return; - } - } - - if (Relation()->InCastingContext() || util::Helpers::IsTargetFitInSourceRange(value)) { - Relation()->Result(true); - return; - } - - Relation()->Result(RelationResult::ERROR); - return; - } - - Relation()->Result(true); - } -}; -} // namespace ark::es2panda::checker - -#endif diff --git a/ets2panda/checker/ets/narrowingWideningConverter.cpp b/ets2panda/checker/ets/narrowingWideningConverter.cpp deleted file mode 100644 index 41ed3aeb8cf47902ad35907f636e97f771c1ffd2..0000000000000000000000000000000000000000 --- a/ets2panda/checker/ets/narrowingWideningConverter.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2021 - 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "narrowingWideningConverter.h" - -namespace ark::es2panda::checker { -} // namespace ark::es2panda::checker diff --git a/ets2panda/checker/ets/narrowingWideningConverter.h b/ets2panda/checker/ets/narrowingWideningConverter.h deleted file mode 100644 index 8aa21fea56ca759e8d6d5d6940406dd6d6c0212e..0000000000000000000000000000000000000000 --- a/ets2panda/checker/ets/narrowingWideningConverter.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2021 - 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ES2PANDA_COMPILER_CHECKER_ETS_NARROWING_WIDENING_CONVERTER_H -#define ES2PANDA_COMPILER_CHECKER_ETS_NARROWING_WIDENING_CONVERTER_H - -#include "checker/ets/narrowingConverter.h" -#include "checker/ets/wideningConverter.h" - -namespace ark::es2panda::checker { -class NarrowingWideningConverter : public NarrowingConverter { -public: - explicit NarrowingWideningConverter(ETSChecker *checker, TypeRelation *relation, Type *target, Type *source) - : NarrowingConverter(checker, relation, target, source) - { - if (Relation()->IsTrue() || Relation()->IsError()) { - return; - } - - WideningConverter(checker, relation, target, source); - } -}; -} // namespace ark::es2panda::checker - -#endif diff --git a/ets2panda/checker/ets/object.cpp b/ets2panda/checker/ets/object.cpp index c5724a9d7e175efa7d20ad4fda5cfce5b6e2c599..82f486c79ec36b88168d8a7e19e117f1e46cefbd 100644 --- a/ets2panda/checker/ets/object.cpp +++ b/ets2panda/checker/ets/object.cpp @@ -13,12 +13,14 @@ * limitations under the License. */ +#include #include "checker/ETSchecker.h" #include "checker/ets/typeRelationContext.h" -#include "checker/types/ets/etsDynamicType.h" #include "checker/types/ets/etsObjectType.h" #include "checker/types/ets/etsTupleType.h" #include "checker/types/ets/etsPartialTypeParameter.h" +#include "checker/types/gradualType.h" +#include "compiler/lowering/phase.h" #include "ir/base/classDefinition.h" #include "ir/base/classElement.h" #include "ir/base/classProperty.h" @@ -80,10 +82,37 @@ static bool CheckGetterSetterDecl(varbinder::LocalVariable const *child, varbind return checkChild && checkParent && (child->TsType()->IsETSFunctionType() || parent->TsType()->IsETSFunctionType()); } +static bool CheckOverloadDecl(varbinder::LocalVariable *child, varbinder::LocalVariable *parent) +{ + if (!child->Declaration()->Node()->IsOverloadDeclaration() || + !parent->Declaration()->Node()->IsOverloadDeclaration()) { + return false; + } + + auto *childOverload = child->Declaration()->Node()->AsOverloadDeclaration(); + auto *parentOverload = parent->Declaration()->Node()->AsOverloadDeclaration(); + for (auto *baseMethodName : parentOverload->OverloadedList()) { + ES2PANDA_ASSERT(baseMethodName->IsIdentifier()); + auto res = std::find_if(childOverload->OverloadedList().begin(), childOverload->OverloadedList().end(), + [baseMethodName](ir::Expression *subMethodName) { + return subMethodName->IsIdentifier() && subMethodName->AsIdentifier()->Name() == + baseMethodName->AsIdentifier()->Name(); + }); + if (res == childOverload->OverloadedList().end()) { + return false; + } + } + return true; +} + static bool CheckFunctionDecl(varbinder::LocalVariable *child, varbinder::LocalVariable *parent) { + if (child->Declaration()->Node()->IsOverloadDeclaration() || + parent->Declaration()->Node()->IsOverloadDeclaration()) { + return false; + } ES2PANDA_ASSERT(child->Declaration()->Type() == parent->Declaration()->Type()); - if (!child->TsType()->IsETSMethodType()) { + if (!child->TsType()->IsETSMethodType() || !parent->TsType()->IsETSMethodType()) { return true; } @@ -154,7 +183,7 @@ bool ETSChecker::ComputeSuperType(ETSObjectType *type) return false; } - Type *superType = classDef->Super()->AsTypeNode()->GetType(this); + auto *superType = classDef->Super()->AsTypeNode()->GetType(this)->MaybeBaseTypeOfGradualType(); if (superType == nullptr) { return true; } @@ -164,7 +193,7 @@ bool ETSChecker::ComputeSuperType(ETSObjectType *type) return true; } - ETSObjectType *superObj = superType->AsETSObjectType(); + ETSObjectType *superObj = superType->MaybeBaseTypeOfGradualType()->AsETSObjectType(); // struct node has class definition, too if (superObj->GetDeclNode()->Parent()->IsETSStructDeclaration()) { @@ -186,6 +215,12 @@ bool ETSChecker::ComputeSuperType(ETSObjectType *type) void ETSChecker::ValidateImplementedInterface(ETSObjectType *type, Type *interface, std::unordered_set *extendsSet, const lexer::SourcePosition &pos) { + ES2PANDA_ASSERT(interface != nullptr); + interface = interface->MaybeBaseTypeOfGradualType(); + if (interface->IsETSObjectType() && interface->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::CLASS)) { + LogError(diagnostic::INTERFACE_EXTENDS_CLASS, {}, pos); + return; + } if (!interface->IsETSObjectType() || !interface->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::INTERFACE)) { LogError(diagnostic::NOT_INTERFACE, {}, pos); return; @@ -374,7 +409,7 @@ void ETSChecker::SetUpTypeParameterConstraint(ir::TSTypeParameter *const param) traverseReferenced(param->Constraint()); paramType->SetConstraintType(param->Constraint()->GetType(this)); } else { - paramType->SetConstraintType(GlobalETSNullishObjectType()); + paramType->SetConstraintType(GlobalETSAnyType()); } if (param->DefaultType() != nullptr) { @@ -394,13 +429,12 @@ ETSTypeParameter *ETSChecker::SetUpParameterType(ir::TSTypeParameter *const para } auto *const paramType = CreateTypeParameter(); - + ES2PANDA_ASSERT(paramType != nullptr); paramType->AddTypeFlag(TypeFlag::GENERIC); paramType->SetDeclNode(param); paramType->SetVariable(param->Variable()); // NOTE: #15026 recursive type parameter workaround - paramType->SetConstraintType(GlobalETSNullishObjectType()); - + paramType->SetConstraintType(GlobalETSAnyType()); var->SetTsType(paramType); return paramType; } @@ -423,6 +457,15 @@ void ETSChecker::CreateTypeForClassOrInterfaceTypeParameters(ETSObjectType *type type->AddObjectFlag(ETSObjectFlags::INCOMPLETE_INSTANTIATION); } +Type *ETSChecker::MaybeGradualType(ir::AstNode *node, ETSObjectType *type) +{ + ES2PANDA_ASSERT(node->IsClassDefinition() || node->IsTSInterfaceDeclaration()); + auto isDynamic = node->IsClassDefinition() ? node->AsClassDefinition()->Language().IsDynamic() + : node->AsTSInterfaceDeclaration()->Language().IsDynamic(); + // Temporary solution, the struct loses 'language' while being converted to a class through the plugin API. + return isDynamic || Program()->IsDeclForDynamicStaticInterop() ? CreateGradualType(type) : type; +} + Type *ETSChecker::BuildBasicInterfaceProperties(ir::TSInterfaceDeclaration *interfaceDecl) { auto *var = interfaceDecl->Id()->Variable(); @@ -432,14 +475,27 @@ Type *ETSChecker::BuildBasicInterfaceProperties(ir::TSInterfaceDeclaration *inte } checker::ETSObjectType *interfaceType {}; + checker::Type *type {}; if (var->TsType() == nullptr) { interfaceType = CreateETSObjectTypeOrBuiltin(interfaceDecl, checker::ETSObjectFlags::INTERFACE); interfaceType->SetVariable(var); - var->SetTsType(interfaceType); + type = MaybeGradualType(interfaceDecl, interfaceType); + var->SetTsType(type); + } else if (var->TsType()->MaybeBaseTypeOfGradualType()->IsETSObjectType()) { + interfaceType = var->TsType()->MaybeBaseTypeOfGradualType()->AsETSObjectType(); + type = MaybeGradualType(interfaceDecl, interfaceType); } else { - interfaceType = var->TsType()->AsETSObjectType(); + ES2PANDA_ASSERT(IsAnyError()); + return GlobalTypeError(); } + // Save before we mess with savedContext. + bool builtinsInitialized = HasStatus(CheckerStatus::BUILTINS_INITIALIZED); + + auto *enclosingClass = Context().ContainingClass(); + interfaceType->SetEnclosingType(enclosingClass); + CheckerStatus newStatus = CheckerStatus::IN_INTERFACE; + auto savedContext = checker::SavedCheckerContext(this, newStatus, interfaceType); ConstraintCheckScope ctScope(this); if (interfaceDecl->TypeParams() != nullptr) { interfaceType->AddTypeFlag(TypeFlag::GENERIC); @@ -453,11 +509,11 @@ Type *ETSChecker::BuildBasicInterfaceProperties(ir::TSInterfaceDeclaration *inte // Skip this check if the builtins are not initialized. // They will be initialized in different order, // and it is possible that the FunctionType interface is not yet created. - if (HasStatus(CheckerStatus::BUILTINS_INITIALIZED)) { + if (builtinsInitialized) { CheckInterfaceFunctions(interfaceType); } - return interfaceType; + return type; } Type *ETSChecker::BuildBasicClassProperties(ir::ClassDefinition *classDef) @@ -473,21 +529,24 @@ Type *ETSChecker::BuildBasicClassProperties(ir::ClassDefinition *classDef) } checker::ETSObjectType *classType {}; + checker::Type *type {}; if (var->TsType() == nullptr) { classType = CreateETSObjectTypeOrBuiltin(classDef, checker::ETSObjectFlags::CLASS); + type = MaybeGradualType(classDef, classType); classType->SetVariable(var); - var->SetTsType(classType); + var->SetTsType(type); if (classDef->IsAbstract()) { classType->AddObjectFlag(checker::ETSObjectFlags::ABSTRACT); } - } else if (var->TsType()->IsETSObjectType()) { - classType = var->TsType()->AsETSObjectType(); + } else if (var->TsType()->MaybeBaseTypeOfGradualType()->IsETSObjectType()) { + classType = var->TsType()->MaybeBaseTypeOfGradualType()->AsETSObjectType(); + type = MaybeGradualType(classDef, classType); } else { ES2PANDA_ASSERT(IsAnyError()); return GlobalTypeError(); } - classDef->SetTsType(classType); + classDef->SetTsType(type); ConstraintCheckScope ctScope(this); if (classDef->TypeParams() != nullptr) { @@ -511,13 +570,14 @@ Type *ETSChecker::BuildBasicClassProperties(ir::ClassDefinition *classDef) GetInterfaces(classType); } ctScope.TryCheckConstraints(); - return classType; + return type; } ETSObjectType *ETSChecker::BuildAnonymousClassProperties(ir::ClassDefinition *classDef, ETSObjectType *superType) { auto classType = CreateETSObjectType(classDef, checker::ETSObjectFlags::CLASS); classDef->SetTsType(classType); + ES2PANDA_ASSERT(classType != nullptr); classType->SetSuperType(superType); classType->AddObjectFlag(checker::ETSObjectFlags::RESOLVED_SUPER); @@ -543,53 +603,63 @@ static void ResolveDeclaredFieldsOfObject(ETSChecker *checker, const ETSObjectTy } } +// CC-OFFNXT(huge_method[C++], G.FUN.01-CPP) solid logic static void ResolveDeclaredMethodsOfObject(ETSChecker *checker, const ETSObjectType *type, varbinder::ClassScope *scope) { for (auto &[_, it] : scope->InstanceMethodScope()->Bindings()) { (void)_; - auto *method = it->Declaration()->Node()->AsMethodDefinition(); - auto *function = method->Function(); - if (function->IsProxy()) { - continue; - } + if (it->Declaration()->Node()->IsMethodDefinition()) { + auto *method = it->Declaration()->Node()->AsMethodDefinition(); + auto *function = method->Function(); + ES2PANDA_ASSERT(function != nullptr); + if (function->IsProxy()) { + continue; + } - it->AddFlag(checker->GetAccessFlagFromNode(method)); - auto *funcType = checker->BuildMethodSignature(method); - if (!funcType->IsTypeError()) { - funcType->SetVariable(it); + it->AddFlag(checker->GetAccessFlagFromNode(method)); + auto *funcType = checker->BuildMethodSignature(method); + if (!funcType->IsTypeError()) { + funcType->SetVariable(it); + } + it->SetTsType(funcType); + method->SetTsType(funcType); + type->AddProperty(it->AsLocalVariable()); + } else if (it->Declaration()->Node()->IsOverloadDeclaration()) { + type->AddProperty(it->AsLocalVariable()); + } else { + ES2PANDA_UNREACHABLE(); } - it->SetTsType(funcType); - method->SetTsType(funcType); - type->AddProperty(it->AsLocalVariable()); } for (auto &[_, it] : scope->StaticMethodScope()->Bindings()) { (void)_; - if (!it->Declaration()->Node()->IsMethodDefinition()) { - continue; - } - - auto *method = it->Declaration()->Node()->AsMethodDefinition(); - auto *function = method->Function(); + if (it->Declaration()->Node()->IsMethodDefinition()) { + auto *method = it->Declaration()->Node()->AsMethodDefinition(); + auto *function = method->Function(); + ES2PANDA_ASSERT(function != nullptr); + if (function->IsProxy()) { + continue; + } - if (function->IsProxy()) { - continue; - } + it->AddFlag(checker->GetAccessFlagFromNode(method)); + auto *funcType = checker->BuildMethodSignature(method); + if (!funcType->IsTypeError()) { + funcType->SetVariable(it); + } + it->SetTsType(funcType); + method->SetTsType(funcType); - it->AddFlag(checker->GetAccessFlagFromNode(method)); - auto *funcType = checker->BuildMethodSignature(method); - if (!funcType->IsTypeError()) { - funcType->SetVariable(it); - } - it->SetTsType(funcType); - method->SetTsType(funcType); + if (method->IsConstructor() && funcType->IsETSFunctionType()) { + type->AddConstructSignature(funcType->AsETSFunctionType()->CallSignatures()); + continue; + } - if (method->IsConstructor() && funcType->IsETSFunctionType()) { - type->AddConstructSignature(funcType->AsETSFunctionType()->CallSignatures()); + type->AddProperty(it->AsLocalVariable()); + } else if (it->Declaration()->Node()->IsOverloadDeclaration()) { + type->AddProperty(it->AsLocalVariable()); + } else { continue; } - - type->AddProperty(it->AsLocalVariable()); } } @@ -615,6 +685,10 @@ static void ResolveDeclaredDeclsOfObject(ETSChecker *checker, const ETSObjectTyp void ETSChecker::ResolveDeclaredMembersOfObject(const Type *type) { + if (type->IsGradualType()) { + return ResolveDeclaredMembersOfObject(type->AsGradualType()->GetBaseType()); + } + if (!type->IsETSObjectType() || type->AsETSObjectType()->IsPropertiesInstantiated()) { return; } @@ -693,6 +767,10 @@ std::vector ETSChecker::CollectAbstractSignaturesFromObject(const E { std::vector abstracts; for (const auto &prop : objType->Methods()) { + if (prop->Declaration()->Node()->IsOverloadDeclaration()) { + continue; + } + GetTypeOfVariable(prop); if (!prop->TsType()->IsETSFunctionType()) { @@ -725,8 +803,10 @@ void ETSChecker::CreateFunctionTypesFromAbstracts(const std::vector void ETSChecker::ComputeAbstractsFromInterface(ETSObjectType *interfaceType) { - auto cached = GetCachedComputedAbstracts()->find(interfaceType); - if (cached != GetCachedComputedAbstracts()->end()) { + auto cachedComputedAbstracts = GetCachedComputedAbstracts(); + ES2PANDA_ASSERT(cachedComputedAbstracts != nullptr); + auto cached = cachedComputedAbstracts->find(interfaceType); + if (cached != cachedComputedAbstracts->end()) { return; } @@ -739,8 +819,8 @@ void ETSChecker::ComputeAbstractsFromInterface(ETSObjectType *interfaceType) ArenaUnorderedSet abstractInheritanceTarget(ProgramAllocator()->Adapter()); for (auto *interface : interfaceType->Interfaces()) { - auto found = GetCachedComputedAbstracts()->find(interface); - ES2PANDA_ASSERT(found != GetCachedComputedAbstracts()->end()); + auto found = cachedComputedAbstracts->find(interface); + ES2PANDA_ASSERT(found != cachedComputedAbstracts->end()); if (!abstractInheritanceTarget.insert(found->first).second) { continue; @@ -753,7 +833,7 @@ void ETSChecker::ComputeAbstractsFromInterface(ETSObjectType *interfaceType) } } - GetCachedComputedAbstracts()->insert({interfaceType, {merged, abstractInheritanceTarget}}); + cachedComputedAbstracts->insert({interfaceType, {merged, abstractInheritanceTarget}}); } ArenaVector &ETSChecker::GetAbstractsForClass(ETSObjectType *classType) @@ -857,6 +937,7 @@ void ETSChecker::CheckFunctionRedeclarationInInterface(ETSObjectType *classType, if (sig == sigFunc) { return; } + ES2PANDA_ASSERT(sigFunc != nullptr); if (sigFunc->Function()->Id()->Name() == sig->Function()->Id()->Name()) { if (classType->IsSameBasedGeneric(Relation(), sig->Owner())) { return; @@ -876,6 +957,7 @@ static void CallRedeclarationCheckForCorrectSignature(ir::MethodDefinition *meth ETSObjectType *classType, ETSChecker *checker) { ir::ScriptFunction *func = method->Function(); + ES2PANDA_ASSERT(func != nullptr); if (!func->IsAbstract()) { auto *sigFunc = funcType->FindSignature(func); checker->CheckFunctionRedeclarationInInterface(classType, similarSignatures, sigFunc); @@ -891,6 +973,10 @@ void ETSChecker::CheckInterfaceFunctions(ETSObjectType *classType) for (auto *const &interface : interfaces) { for (auto *const &prop : interface->Methods()) { + if (prop->Declaration()->Node()->IsOverloadDeclaration()) { + continue; + } + ir::MethodDefinition *node = prop->Declaration()->Node()->AsMethodDefinition(); if (prop->TsType()->IsTypeError()) { continue; @@ -1080,6 +1166,9 @@ void ETSChecker::MaybeReportErrorsForOverridingValidation(ArenaVectorCallSignatures().front(); auto containingObjectName = GetContainingObjectNameFromSignature(unimplementedSignature); + if (unimplementedSignature->HasSignatureFlag(SignatureFlags::DEFAULT)) { + return; + } if (unimplementedSignature->HasSignatureFlag(SignatureFlags::GETTER)) { LogError(diagnostic::GETTER_MISSING_IMPL, {classType->Name(), unimplementedSignature->Function()->Id()->Name(), containingObjectName}, pos); @@ -1099,7 +1188,7 @@ void ETSChecker::MaybeReportErrorsForOverridingValidation(ArenaVectorHasObjectFlag(ETSObjectFlags::CHECKED_COMPATIBLE_ABSTRACTS)) { + if (GetCachedComputedAbstracts()->find(classType) != GetCachedComputedAbstracts()->end()) { return; } @@ -1131,8 +1220,6 @@ void ETSChecker::ValidateOverriding(ETSObjectType *classType, const lexer::Sourc } while (superIter != nullptr); ValidateAbstractMethodsToBeImplemented(abstractsToBeImplemented, classType, implementedSignatures); MaybeReportErrorsForOverridingValidation(abstractsToBeImplemented, classType, pos, throwError); - - classType->AddObjectFlag(ETSObjectFlags::CHECKED_COMPATIBLE_ABSTRACTS); } void ETSChecker::AddImplementedSignature(std::vector *implementedSignatures, @@ -1185,11 +1272,17 @@ void ETSChecker::CheckClassDefinition(ir::ClassDefinition *classDef) return; } - auto *classType = classDef->TsType()->AsETSObjectType(); + auto *classType = classDef->TsType()->MaybeBaseTypeOfGradualType()->AsETSObjectType(); if (classType->SuperType() != nullptr) { classType->SuperType()->GetDeclNode()->Check(this); } + if (classType->GetDeclNode() != classDef) { + ES2PANDA_ASSERT(IsAnyError()); + classDef->SetTsType(GlobalTypeError()); + return; + } + auto newStatus = checker::CheckerStatus::IN_CLASS; if (Context().ContainingClass() != classType) { classType->SetEnclosingType(Context().ContainingClass()); @@ -1516,85 +1609,65 @@ void ETSChecker::CheckInnerClassMembers(const ETSObjectType *classType) } } -lexer::Number ETSChecker::ExtractNumericValue(Type const *const indexType) -{ - TypeFlag typeKind = ETSType(indexType); - lexer::Number resNum; - switch (typeKind) { - case TypeFlag::BYTE: { - resNum = lexer::Number(indexType->AsByteType()->GetValue()); - break; - } - case TypeFlag::SHORT: { - resNum = lexer::Number(indexType->AsShortType()->GetValue()); - break; - } - case TypeFlag::INT: { - resNum = lexer::Number(indexType->AsIntType()->GetValue()); - break; - } - case TypeFlag::FLOAT: { - resNum = lexer::Number(indexType->AsFloatType()->GetValue()); - break; - } - case TypeFlag::DOUBLE: { - resNum = lexer::Number(indexType->AsDoubleType()->GetValue()); - break; - } - default: - break; - } - return resNum; -} - bool ETSChecker::ValidateArrayIndex(ir::Expression *const expr, bool relaxed) { - auto const expressionType = expr->Check(this); + auto const expressionType = expr->Check(this)->MaybeBaseTypeOfGradualType(); if (expressionType->IsTypeError()) { return false; } - Type const *const unboxedExpressionType = MaybeUnboxInRelation(expressionType); - if (expressionType->IsETSObjectType() && (unboxedExpressionType != nullptr)) { - expr->AddBoxingUnboxingFlags(GetUnboxingFlag(unboxedExpressionType)); + if (!expressionType->IsETSObjectType() || + (!expressionType->AsETSObjectType()->HasObjectFlag(relaxed ? ETSObjectFlags::BUILTIN_ARRAY_NUMERIC + : ETSObjectFlags::BUILTIN_ARRAY_INDEX))) { + LogError(diagnostic::INVALID_INDEX_TYPE, {expressionType->ToString()}, expr->Start()); + return false; } - Type const *const indexType = ApplyUnaryOperatorPromotion(expressionType); - - if (relaxed && indexType != nullptr) { - lexer::Number resNum = ExtractNumericValue(indexType); - double value = resNum.GetDouble(); - double intpart; - if (std::modf(value, &intpart) != 0.0) { - LogError(diagnostic::INDEX_NONINTEGRAL_FLOAT, {}, expr->Start()); - return false; - } - bool tildeFlag = false; - if (expr->IsUnaryExpression() && - expr->AsUnaryExpression()->OperatorType() == lexer::TokenType::PUNCTUATOR_TILDE) { - tildeFlag = true; - } - if ((tildeFlag && value > 0) || (!tildeFlag && value < 0)) { - LogError(diagnostic::NEGATIVE_INDEX, {}, expr->Start()); - return false; - } + if (!relaxed || !expressionType->IsConstantType()) { + return true; } - if (indexType == nullptr || - (!indexType->HasTypeFlag(relaxed ? (TypeFlag::ETS_ARRAY_INDEX | TypeFlag::ETS_FLOATING_POINT) - : TypeFlag::ETS_ARRAY_INDEX))) { - std::stringstream message(""); - expressionType->ToString(message); + ES2PANDA_ASSERT(expr->IsNumberLiteral()); + double value = expr->AsNumberLiteral()->Number().GetDouble(); - LogError(diagnostic::INVALID_INDEX_TYPE, {message.str()}, expr->Start()); + double intPart; + if (std::modf(value, &intPart) != 0.0) { + LogError(diagnostic::INDEX_NONINTEGRAL_FLOAT, {}, expr->Start()); + return false; + } + + if (intPart < 0.0) { + LogError(diagnostic::NEGATIVE_INDEX, {}, expr->Start()); return false; } return true; } -std::optional ETSChecker::GetTupleElementAccessValue(const Type *const type) +std::optional ETSChecker::GetTupleElementAccessValue(const ir::Expression *expr) { + auto checkLongValBounds = [this](int64_t val, const lexer::SourcePosition &p) -> std::optional { + if (val < 0) { + LogError(diagnostic::TUPLE_INDEX_OOB, {}, p); + return std::nullopt; + } + return static_cast(val); + }; + + if (expr->IsNumberLiteral()) { + auto num = expr->AsNumberLiteral()->Number(); + if (num.IsInt()) { + return checkLongValBounds(num.GetInt(), expr->Start()); + } + if (num.IsLong()) { + return checkLongValBounds(num.GetLong(), expr->Start()); + } + ES2PANDA_UNREACHABLE(); + } + + // Below code should be unreachable after removing primitives + auto type = expr->TsType(); + ES2PANDA_ASSERT(type->HasTypeFlag(TypeFlag::CONSTANT | TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC)); switch (ETSType(type)) { @@ -1623,14 +1696,9 @@ std::optional ETSChecker::GetTupleElementAccessValue(const Type *co bool ETSChecker::ValidateTupleIndex(const ETSTupleType *const tuple, ir::MemberExpression *const expr, const bool reportError) { - auto const expressionType = expr->Property()->Check(this); - auto const *const unboxedExpressionType = MaybeUnboxInRelation(expressionType); - - if (expressionType->IsETSObjectType() && (unboxedExpressionType != nullptr)) { - expr->Property()->AddBoxingUnboxingFlags(GetUnboxingFlag(unboxedExpressionType)); - } + auto const exprType = expr->Property()->Check(this); + auto const *const unboxedExpressionType = MaybeUnboxInRelation(exprType); - const auto *const exprType = expr->Property()->TsType(); ES2PANDA_ASSERT(exprType != nullptr); if (!exprType->HasTypeFlag(TypeFlag::CONSTANT)) { @@ -1643,14 +1711,13 @@ bool ETSChecker::ValidateTupleIndex(const ETSTupleType *const tuple, ir::MemberE return false; } - if (!exprType->HasTypeFlag(TypeFlag::ETS_ARRAY_INDEX | TypeFlag::LONG)) { - if (reportError) { - LogError(diagnostic::TUPLE_INDEX_NOT_INT, {}, expr->Property()->Start()); - } + if (!Relation()->IsSupertypeOf(GlobalIntBuiltinType(), exprType) && + !Relation()->IsSupertypeOf(GlobalLongBuiltinType(), exprType)) { + LogError(diagnostic::TUPLE_INDEX_NOT_INT, {}, expr->Property()->Start()); return false; } - auto exprValue = GetTupleElementAccessValue(exprType); + auto exprValue = GetTupleElementAccessValue(expr->Property()); if (!exprValue.has_value() || (*exprValue >= tuple->GetTupleSize())) { if (reportError) { LogError(diagnostic::TUPLE_INDEX_OOB, {}, expr->Property()->Start()); @@ -1663,6 +1730,16 @@ bool ETSChecker::ValidateTupleIndex(const ETSTupleType *const tuple, ir::MemberE bool ETSChecker::ValidateTupleIndexFromEtsObject(const ETSTupleType *const tuple, ir::MemberExpression *const expr) { + if (expr->Property() == nullptr || expr->Property()->Variable() == nullptr || + expr->Property()->Variable()->Declaration() == nullptr || + expr->Property()->Variable()->Declaration()->Node() == nullptr || + !(expr->Property()->Variable()->Declaration()->Node()->IsMethodDefinition() || + expr->Property()->Variable()->Declaration()->Node()->IsClassProperty() || + expr->Property()->Variable()->Declaration()->Node()->IsClassStaticBlock() || + expr->Property()->Variable()->Declaration()->Node()->IsOverloadDeclaration())) { + LogError(diagnostic::TUPLE_INDEX_NONCONST, {}, expr->Start()); + return false; + } auto *value = expr->Property()->Variable()->Declaration()->Node()->AsClassElement()->Value(); if (value == nullptr) { LogError(diagnostic::TUPLE_INDEX_NONCONST, {}, expr->Property()->Start()); @@ -1680,7 +1757,7 @@ bool ETSChecker::ValidateTupleIndexFromEtsObject(const ETSTupleType *const tuple return false; } - auto exprValue = GetTupleElementAccessValue(exprType); + auto exprValue = GetTupleElementAccessValue(expr); if (!exprValue.has_value() || (*exprValue >= tuple->GetTupleSize())) { LogError(diagnostic::TUPLE_INDEX_OOB, {}, expr->Property()->Start()); return false; @@ -1764,6 +1841,7 @@ void ETSChecker::CheckCyclicConstructorCall(Signature *signature) ETSObjectType *ETSChecker::CheckExceptionOrErrorType(checker::Type *type, const lexer::SourcePosition pos) { + ES2PANDA_ASSERT(type != nullptr); if (!type->IsETSObjectType() || (!Relation()->IsAssignableTo(type, GlobalBuiltinExceptionType()) && !Relation()->IsAssignableTo(type, GlobalBuiltinErrorType()))) { LogError(diagnostic::CATCH_OR_THROW_OF_INVALID_TYPE, @@ -1873,7 +1951,11 @@ varbinder::Variable *ETSChecker::GetExtensionFuncVarInGlobalFunction(const ir::M { auto propertyName = memberExpr->Property()->AsIdentifier()->Name(); auto *globalFunctionVar = Scope()->FindInGlobal(propertyName, VO::STATIC_METHODS).variable; - if (globalFunctionVar == nullptr || !IsExtensionETSFunctionType(globalFunctionVar->TsType())) { + if (globalFunctionVar == nullptr) { + return nullptr; + } + + if (!IsExtensionETSFunctionType(GetTypeOfVariable(globalFunctionVar))) { return nullptr; } @@ -1926,10 +2008,14 @@ PropertySearchFlags ETSChecker::GetInitialSearchFlags(const ir::MemberExpression switch (memberExpr->Parent()->Type()) { case ir::AstNodeType::CALL_EXPRESSION: { if (memberExpr->Parent()->AsCallExpression()->Callee() == memberExpr) { - return FUNCTIONAL_FLAGS; + return PropertySearchFlags::SEARCH_ALL; } break; } + case ir::AstNodeType::OVERLOAD_DECLARATION: { + return FUNCTIONAL_FLAGS | GETTER_FLAGS; + break; + } case ir::AstNodeType::ETS_NEW_CLASS_INSTANCE_EXPRESSION: { if (memberExpr->Parent()->AsETSNewClassInstanceExpression()->GetTypeRef() == memberExpr) { return PropertySearchFlags::SEARCH_DECL; @@ -1973,6 +2059,9 @@ static bool ShouldRemoveStaticSearchFlag(const ir::MemberExpression *const membe if (object->IsMemberExpression()) { object = object->AsMemberExpression()->Property(); } + if (object->IsTypeNode()) { + return false; + } if (!object->IsIdentifier() || (object->AsIdentifier()->Variable() == nullptr) || object->AsIdentifier()->Variable()->HasFlag(varbinder::VariableFlags::INITIALIZED)) { return true; @@ -2013,6 +2102,9 @@ const varbinder::Variable *ETSChecker::GetTargetRef(const ir::MemberExpression * if (memberExpr->Object()->IsMemberExpression()) { return memberExpr->Object()->AsMemberExpression()->PropVar(); } + if (memberExpr->Object()->IsTypeNode() && memberExpr->Object()->TsType()->IsETSObjectType()) { + return memberExpr->Object()->TsType()->Variable(); + } return nullptr; } @@ -2182,19 +2274,21 @@ static ResolvedKind DecideResolvedKind(Type *typeOfGlobalFunctionVar) return ResolvedKind::EXTENSION_FUNCTION; } +void ETSChecker::CheckAnnotationReference(const ir::MemberExpression *memberExpr, const varbinder::LocalVariable *prop) +{ + // Note: there might be a better way to handle annotations + if (prop != nullptr && prop->Declaration() != nullptr && prop->Declaration()->IsAnnotationDecl() && + memberExpr->Parent()->IsCallExpression()) { + LogError(diagnostic::ANNOTATION_INSTANTIATION, {prop->Declaration()->Name()}, memberExpr->Start()); + } +} + // NOLINTNEXTLINE(readability-function-size) std::vector ETSChecker::ResolveMemberReference(const ir::MemberExpression *const memberExpr, const ETSObjectType *const target) { std::vector resolveRes {}; - if (target->IsETSDynamicType() && !target->AsETSDynamicType()->HasDecl()) { - auto propName = memberExpr->Property()->AsIdentifier()->Name(); - varbinder::LocalVariable *propVar = target->AsETSDynamicType()->GetPropertyDynamic(propName, this); - resolveRes.emplace_back(ProgramAllocator()->New(propVar, ResolvedKind::PROPERTY)); - return resolveRes; - } - if (target->GetDeclNode() != nullptr && target->GetDeclNode()->IsClassDefinition() && !target->GetDeclNode()->AsClassDefinition()->IsClassDefinitionChecked()) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -2202,8 +2296,14 @@ std::vector ETSChecker::ResolveMemberReference(const ir::Member } const auto *const targetRef = GetTargetRef(memberExpr); auto searchFlag = GetSearchFlags(memberExpr, targetRef); + if (target->HasObjectFlag(ETSObjectFlags::LAZY_IMPORT_OBJECT)) { + searchFlag |= PropertySearchFlags::SEARCH_INSTANCE; + } auto searchName = target->GetReExportAliasValue(memberExpr->Property()->AsIdentifier()->Name()); auto *prop = target->GetProperty(searchName, searchFlag); + + CheckAnnotationReference(memberExpr, prop); + varbinder::Variable *const globalFunctionVar = ResolveInstanceExtension(memberExpr); if (targetRef != nullptr && targetRef->HasFlag(varbinder::VariableFlags::CLASS_OR_INTERFACE)) { // Note: extension function only for instance. @@ -2242,6 +2342,17 @@ std::vector ETSChecker::ResolveMemberReference(const ir::Member return resolveRes; } +varbinder::LocalVariable *ETSChecker::ResolveOverloadReference(const ir::Identifier *ident, ETSObjectType *objType, + PropertySearchFlags searchFlags) +{ + auto *var = objType->GetProperty(ident->Name(), searchFlags); + if (var == nullptr) { + return nullptr; + } + ValidatePropertyAccess(var, objType, ident->Start()); + return var; +} + void ETSChecker::WarnForEndlessLoopInGetterSetter(const ir::MemberExpression *const memberExpr) { if (!memberExpr->Object()->IsThisExpression() || memberExpr->Property() == nullptr || @@ -2250,12 +2361,13 @@ void ETSChecker::WarnForEndlessLoopInGetterSetter(const ir::MemberExpression *co } auto ident = memberExpr->Property()->AsIdentifier(); auto parent = memberExpr->Parent(); - while (parent != nullptr && - (!parent->IsMethodDefinition() || (!parent->AsMethodDefinition()->Function()->IsGetter() && - !parent->AsMethodDefinition()->Function()->IsSetter()))) { + while (parent != nullptr && (!parent->IsMethodDefinition() || parent->AsMethodDefinition()->Function() == nullptr || + (!parent->AsMethodDefinition()->Function()->IsGetter() && + !parent->AsMethodDefinition()->Function()->IsSetter()))) { parent = parent->Parent(); } - if (parent != nullptr && ident->Name() == parent->AsMethodDefinition()->Function()->Id()->Name()) { + if (parent != nullptr && parent->AsMethodDefinition()->Function() != nullptr && + ident->Name() == parent->AsMethodDefinition()->Function()->Id()->Name()) { if (parent->AsMethodDefinition()->Function()->IsGetter()) { LogDiagnostic(diagnostic::GETTER_LOOP, memberExpr->Property()->AsIdentifier()->Start()); } else { @@ -2269,13 +2381,16 @@ void ETSChecker::CheckValidInheritance(ETSObjectType *classType, ir::ClassDefini if (classType->SuperType() == nullptr) { return; } - if (classType->SuperType()->IsETSDynamicType()) { - LogError(diagnostic::EXTEND_DYNAMIC, {classDef->Ident()->Name()}, classDef->Start()); - } const auto &allProps = classType->GetAllProperties(); for (auto *it : allProps) { + auto *node = it->Declaration()->Node(); + if (node->IsClassProperty() && node->AsClassProperty()->TsType() != nullptr && + node->AsClassProperty()->TsType()->IsTypeError()) { + continue; + } + const auto searchFlag = PropertySearchFlags::SEARCH_ALL | PropertySearchFlags::SEARCH_IN_BASE | PropertySearchFlags::SEARCH_IN_INTERFACES | PropertySearchFlags::DISALLOW_SYNTHETIC_METHOD_CREATION; @@ -2325,6 +2440,8 @@ void ETSChecker::CheckProperties(ETSObjectType *classType, ir::ClassDefinition * if (CheckGetterSetterDecl(it, found)) { return; } + } else if (CheckOverloadDecl(it, found)) { + return; } else if (CheckFunctionDecl(it, found)) { return; } @@ -2343,6 +2460,8 @@ void ETSChecker::CheckProperties(ETSObjectType *classType, ir::ClassDefinition * targetType = "namespace"; } else if (it->HasFlag(varbinder::VariableFlags::ENUM_LITERAL)) { targetType = "enum"; + } else if (it->HasFlag(varbinder::VariableFlags::OVERLOAD)) { + targetType = "overload"; } else { ES2PANDA_UNREACHABLE(); } @@ -2411,10 +2530,16 @@ void ETSChecker::TransformProperties(ETSObjectType *classType) GenerateGetterSetterPropertyAndMethod(originalProp, classType); } - auto it = classDef->Body().begin(); - while (it != classDef->Body().end()) { + auto &body = classDef->Body(); + if (!std::any_of(body.cbegin(), body.cend(), [](const ir::AstNode *node) { + return node->IsClassProperty() && (node->Modifiers() & ir::ModifierFlags::GETTER_SETTER) != 0U; + })) { + return; + } + auto it = classDef->BodyForUpdate().begin(); + while (it != classDef->BodyForUpdate().end()) { if ((*it)->IsClassProperty() && ((*it)->Modifiers() & ir::ModifierFlags::GETTER_SETTER) != 0U) { - it = classDef->Body().erase(it); + it = classDef->BodyForUpdate().erase(it); } else { ++it; } @@ -2478,16 +2603,24 @@ void ETSChecker::AddElementsToModuleObject(ETSObjectType *moduleObj, const util: // This function computes effective runtime view of type Type *ETSChecker::GetApparentType(Type *type) { - if (auto it = apparentTypes_.find(type); LIKELY(it != apparentTypes_.end())) { + auto currChecker = compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker(); + auto &apparentTypes = currChecker->apparentTypes_; + + if (auto it = apparentTypes.find(type); LIKELY(it != apparentTypes.end())) { return it->second; } - auto cached = [this, type](Type *res) { + + auto cached = [&apparentTypes, type](Type *res) { if (type != res) { - apparentTypes_.insert({type, res}); + apparentTypes.insert({type, res}); } - apparentTypes_.insert({res, res}); + apparentTypes.insert({res, res}); return res; }; + ES2PANDA_ASSERT(type != nullptr); + if (type->IsGradualType()) { + return cached(type->AsGradualType()->GetBaseType()); + } if (type->IsETSTypeParameter()) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -2526,24 +2659,8 @@ Type *ETSChecker::GetApparentType(Type *type) Type const *ETSChecker::GetApparentType(Type const *type) const { - if (auto it = apparentTypes_.find(type); LIKELY(it != apparentTypes_.end())) { - return it->second; - } - // Relaxed for some types - if (type->IsETSTypeParameter()) { - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - return GetApparentType(type->AsETSTypeParameter()->GetConstraintType()); - } - if (type->IsETSArrayType()) { - return type; - } - if (type->IsETSStringType()) { - return GlobalBuiltinETSStringType(); - } - if (type->IsETSUnionType() || type->IsETSNonNullishType() || type->IsETSPartialTypeParameter()) { - ASSERT_PRINT(false, std::string("Type ") + type->ToString() + " was not found in apparent_types_"); - } - return type; + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + return const_cast(const_cast(this)->GetApparentType(const_cast(type))); } ETSObjectType *ETSChecker::GetClosestCommonAncestor(ETSObjectType *source, ETSObjectType *target) diff --git a/ets2panda/checker/ets/typeCheckingHelpers.cpp b/ets2panda/checker/ets/typeCheckingHelpers.cpp index 1fa0493279befe6b6429cb10983fd5d8b5782f9d..6496cdb8ce75eb3a25d6fc59349a8ce4840f40fc 100644 --- a/ets2panda/checker/ets/typeCheckingHelpers.cpp +++ b/ets2panda/checker/ets/typeCheckingHelpers.cpp @@ -14,8 +14,9 @@ */ #include "checker/checker.h" -#include "checker/ets/narrowingWideningConverter.h" +#include "checker/ets/wideningConverter.h" #include "checker/types/globalTypesHolder.h" +#include "checker/types/gradualType.h" #include "checker/types/ets/etsObjectType.h" #include "checker/types/ets/etsPartialTypeParameter.h" #include "ir/base/catchClause.h" @@ -55,20 +56,16 @@ void ETSChecker::CheckTruthinessOfType(ir::Expression *expr) expr->SetTsType(conditionType); - if (conditionType == nullptr || (!conditionType->IsTypeError() && !conditionType->IsConditionalExprType())) { - LogError(diagnostic::NOT_COND_TYPE, {}, expr->Start()); + if (conditionType == nullptr) { return; } + expr->SetTsType(MaybeBoxType(conditionType)); if (conditionType->IsETSVoidType()) { LogError(diagnostic::VOID_IN_LOGIC, {}, expr->Start()); return; } - if (conditionType->IsETSPrimitiveType()) { - FlagExpressionWithUnboxing(testType, conditionType, expr); - } - // For T_S compatibility if (conditionType->IsETSEnumType()) { expr->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); @@ -91,9 +88,16 @@ bool ETSChecker::CheckNonNullish(ir::Expression const *expr) Type *ETSChecker::GetNonNullishType(Type *type) { + if (type->IsGradualType()) { + return CreateGradualType(GetNonNullishType(type->AsGradualType()->GetBaseType()), + type->AsGradualType()->Language()); + } if (type->DefinitelyNotETSNullish()) { return type; } + if (type->IsETSAnyType()) { + return type; + } if (type->IsETSTypeParameter()) { return ProgramAllocator()->New(type->AsETSTypeParameter()); } @@ -116,7 +120,7 @@ Type *ETSChecker::GetNonNullishType(Type *type) Type *ETSChecker::RemoveNullType(Type *const type) { - if (type->DefinitelyNotETSNullish() || type->IsETSUndefinedType()) { + if (type->IsETSAnyType() || type->DefinitelyNotETSNullish() || type->IsETSUndefinedType()) { return type; } @@ -144,7 +148,7 @@ Type *ETSChecker::RemoveNullType(Type *const type) Type *ETSChecker::RemoveUndefinedType(Type *const type) { - if (type->DefinitelyNotETSNullish() || type->IsETSNullType()) { + if (type->IsETSAnyType() || type->DefinitelyNotETSNullish() || type->IsETSNullType()) { return type; } @@ -176,8 +180,12 @@ std::pair ETSChecker::RemoveNullishTypes(Type *type) return {GetGlobalTypesHolder()->GlobalETSNeverType(), type}; } + if (type->IsETSAnyType()) { + return {type, type}; + } + if (type->IsETSTypeParameter()) { - return {GetGlobalTypesHolder()->GlobalETSNullishType(), + return {GetGlobalTypesHolder()->GlobalETSUnionUndefinedNull(), ProgramAllocator()->New(type->AsETSTypeParameter())}; } @@ -189,7 +197,8 @@ std::pair ETSChecker::RemoveNullishTypes(Type *type) ArenaVector nullishTypes(ProgramAllocator()->Adapter()); ArenaVector notNullishTypes(ProgramAllocator()->Adapter()); - for (auto *constituentType : type->AsETSUnionType()->ConstituentTypes()) { + for (auto *ctype : type->AsETSUnionType()->ConstituentTypes()) { + auto constituentType = ctype->MaybeBaseTypeOfGradualType(); if (constituentType->IsETSUndefinedType() || constituentType->IsETSNullType()) { nullishTypes.push_back(constituentType); } else { @@ -211,6 +220,9 @@ std::pair ETSChecker::RemoveNullishTypes(Type *type) template static bool MatchConstituentOrConstraint(const Type *type, Pred const &pred, Trv const &trv) { + if (type->IsGradualType()) { + return MatchConstituentOrConstraint(type->AsGradualType()->GetBaseType(), pred, trv); + } auto const traverse = [&pred, &trv](const Type *ttype) { return MatchConstituentOrConstraint(ttype, pred, trv); }; @@ -251,21 +263,45 @@ static bool MatchConstituentOrConstraint(const Type *type, Pred const &pred) bool Type::PossiblyETSNull() const { return MatchConstituentOrConstraint( - this, [](const Type *t) { return t->IsETSNullType(); }, + this, [](const Type *t) { return t->IsETSAnyType() || t->IsETSNullType(); }, [](const Type *t) { return !t->IsETSNonNullishType(); }); } bool Type::PossiblyETSUndefined() const { return MatchConstituentOrConstraint( - this, [](const Type *t) { return t->IsETSUndefinedType(); }, + this, [](const Type *t) { return t->IsETSAnyType() || t->IsETSUndefinedType(); }, [](const Type *t) { return !t->IsETSNonNullishType(); }); } +static bool ObjectPossiblyInForeignDomain(ETSObjectType const *type) +{ + if (type->IsGlobalETSObjectType()) { + return true; + } + auto dnode = type->GetDeclNode(); + if (dnode == nullptr) { + return false; + } + auto lang = dnode->IsClassDefinition() ? dnode->AsClassDefinition()->Language() + : dnode->AsTSInterfaceDeclaration()->Language(); + return lang != Language::Id::ETS; +} + +bool Type::PossiblyInForeignDomain() const +{ + return MatchConstituentOrConstraint( + this, + [](const Type *t) { + return t->IsETSAnyType() || (t->IsETSObjectType() && ObjectPossiblyInForeignDomain(t->AsETSObjectType())); + }, + []([[maybe_unused]] const Type *t) { return true; }); +} + bool Type::PossiblyETSNullish() const { return MatchConstituentOrConstraint( - this, [](const Type *t) { return t->IsETSNullType() || t->IsETSUndefinedType(); }, + this, [](const Type *t) { return t->IsETSAnyType() || t->IsETSNullType() || t->IsETSUndefinedType(); }, [](const Type *t) { return !t->IsETSNonNullishType(); }); } @@ -287,7 +323,8 @@ bool Type::DefinitelyNotETSNullish() const bool Type::PossiblyETSString() const { return MatchConstituentOrConstraint(this, [](const Type *t) { - return t->IsETSStringType() || (t->IsETSObjectType() && t->AsETSObjectType()->IsGlobalETSObjectType()); + return t->IsETSAnyType() || t->IsETSStringType() || + (t->IsETSObjectType() && t->AsETSObjectType()->IsGlobalETSObjectType()); }); } @@ -308,7 +345,8 @@ bool Type::PossiblyETSValueTyped() const bool Type::PossiblyETSValueTypedExceptNullish() const { return MatchConstituentOrConstraint(this, [](const Type *t) { - return t->IsETSFunctionType() || (t->IsETSObjectType() && IsValueTypedObjectType(t->AsETSObjectType())); + return t->IsETSAnyType() || t->IsETSFunctionType() || + (t->IsETSObjectType() && IsValueTypedObjectType(t->AsETSObjectType())); }); } @@ -328,9 +366,9 @@ bool Type::IsETSMethodType() const static constexpr TypeFlag ETS_SANE_REFERENCE_TYPE = TypeFlag::TYPE_ERROR | TypeFlag::ETS_NULL | TypeFlag::ETS_UNDEFINED | TypeFlag::ETS_OBJECT | TypeFlag::ETS_TYPE_PARAMETER | TypeFlag::WILDCARD | TypeFlag::ETS_NONNULLISH | - TypeFlag::ETS_REQUIRED_TYPE_PARAMETER | TypeFlag::ETS_NEVER | TypeFlag::ETS_UNION | TypeFlag::ETS_ARRAY | - TypeFlag::FUNCTION | TypeFlag::ETS_PARTIAL_TYPE_PARAMETER | TypeFlag::ETS_TUPLE | TypeFlag::ETS_ENUM | - TypeFlag::ETS_READONLY; + TypeFlag::ETS_REQUIRED_TYPE_PARAMETER | TypeFlag::ETS_ANY | TypeFlag::ETS_NEVER | TypeFlag::ETS_UNION | + TypeFlag::ETS_ARRAY | TypeFlag::FUNCTION | TypeFlag::ETS_PARTIAL_TYPE_PARAMETER | TypeFlag::ETS_TUPLE | + TypeFlag::ETS_ENUM | TypeFlag::ETS_READONLY | TypeFlag::GRADUAL_TYPE; // Issues if (type->IsETSVoidType()) { // NOTE(vpukhov): #19701 void refactoring @@ -340,7 +378,7 @@ bool Type::IsETSMethodType() const return true; } if (type->IsNeverType()) { // NOTE(vpukhov): #20562 We use ets/never and ts/never simultaneously - return true; + ES2PANDA_UNREACHABLE(); } return type->HasTypeFlag(ETS_SANE_REFERENCE_TYPE); } @@ -377,6 +415,7 @@ bool ETSChecker::IsConstantExpression(ir::Expression *expr, Type *type) Type *ETSChecker::GetNonConstantType(Type *type) { + ES2PANDA_ASSERT(type != nullptr); if (type->IsETSStringType()) { return GlobalBuiltinETSStringType(); } @@ -386,10 +425,13 @@ Type *ETSChecker::GetNonConstantType(Type *type) } if (type->IsETSUnionType()) { - return CreateETSUnionType(ETSUnionType::GetNonConstantTypes(this, type->AsETSUnionType()->ConstituentTypes())); + return CreateETSUnionType(type->AsETSUnionType()->GetNonConstantTypes(this)); } if (!type->IsETSPrimitiveType()) { + if (type->IsETSObjectType() && type->AsETSObjectType()->IsBoxedPrimitive()) { + type->RemoveTypeFlag(TypeFlag::CONSTANT); + } return type; } @@ -431,12 +473,43 @@ Type *ETSChecker::GetTypeOfSetterGetter(varbinder::Variable *const var) { auto *propType = var->TsType()->AsETSFunctionType(); if (propType->HasTypeFlag(checker::TypeFlag::GETTER)) { - return propType->FindGetter()->ReturnType(); + auto *getter = propType->FindGetter(); + ES2PANDA_ASSERT(getter != nullptr); + return getter->ReturnType(); + } + + if (propType->FindSetter()->Params().empty()) { + var->SetTsType(GlobalTypeError()); + return GlobalTypeError(); } return propType->FindSetter()->Params()[0]->TsType(); } +ETSFunctionType *ETSChecker::CreateSyntheticTypeFromOverload(varbinder::Variable *const var) +{ + auto *overloadDeclaration = var->Declaration()->Node()->AsOverloadDeclaration(); + std::vector signatures; + ETSFunctionType *syntheticFunctionType = + CreateETSMethodType(overloadDeclaration->Id()->Name(), {{}, Allocator()->Adapter()}); + + for (auto *overloadFunction : overloadDeclaration->OverloadedList()) { + Type *functionType = overloadFunction->Check(this); + ES2PANDA_ASSERT(functionType->IsETSFunctionType()); + auto *signature = functionType->AsETSFunctionType()->CallSignatures().front(); + if (std::find(signatures.begin(), signatures.end(), signature) != signatures.end()) { + continue; + } + signatures.emplace_back(signature); + } + + for (auto &s : signatures) { + syntheticFunctionType->AddCallSignature(s); + } + + return syntheticFunctionType; +} + void ETSChecker::IterateInVariableContext(varbinder::Variable *const var) { // Before computing the given variables type, we have to make a new checker context frame so that the checking is @@ -447,16 +520,18 @@ void ETSChecker::IterateInVariableContext(varbinder::Variable *const var) if (iter->IsMethodDefinition()) { auto *methodDef = iter->AsMethodDefinition(); ES2PANDA_ASSERT(methodDef->TsType()); - Context().SetContainingSignature(methodDef->Function()->Signature()); + auto *func = methodDef->Function(); + ES2PANDA_ASSERT(func != nullptr); + Context().SetContainingSignature(func->Signature()); } else if (iter->IsClassDefinition()) { auto *classDef = iter->AsClassDefinition(); Type *containingClass {}; if (classDef->TsType() == nullptr) { - containingClass = BuildBasicClassProperties(classDef); - ResolveDeclaredMembersOfObject(containingClass->AsETSObjectType()); + containingClass = BuildBasicClassProperties(classDef)->MaybeBaseTypeOfGradualType(); + ResolveDeclaredMembersOfObject(containingClass); } else { - containingClass = classDef->TsType()->AsETSObjectType(); + containingClass = classDef->TsType()->MaybeBaseTypeOfGradualType()->AsETSObjectType(); } ES2PANDA_ASSERT(classDef->TsType()); @@ -555,14 +630,6 @@ Type *ETSChecker::GetTypeOfVariable(varbinder::Variable *const var) return var->TsType(); } - // NOTE: kbaladurin. forbid usage of imported entities as types without declarations - if (VarBinder()->AsETSBinder()->IsDynamicModuleVariable(var)) { - auto *importData = VarBinder()->AsETSBinder()->DynamicImportDataForVar(var); - if (importData->import->IsPureDynamic()) { - return GlobalBuiltinDynamicType(importData->import->Language()); - } - } - checker::SavedCheckerContext savedContext(this, CheckerStatus::NO_OPTS); checker::ScopeContext scopeCtx(this, var->GetScope()); IterateInVariableContext(var); @@ -610,7 +677,9 @@ Type *ETSChecker::GuaranteedTypeForUncheckedPropertyAccess(varbinder::Variable * switch (auto node = prop->Declaration()->Node(); node->Type()) { case ir::AstNodeType::CLASS_PROPERTY: { - auto baseProp = node->AsClassProperty()->Id()->Variable(); + auto *id = node->AsClassProperty()->Id(); + ES2PANDA_ASSERT(id != nullptr); + auto baseProp = id->Variable(); if (baseProp == prop) { return nullptr; } @@ -630,6 +699,7 @@ Type *ETSChecker::GuaranteedTypeForUncheckedPropertyAccess(varbinder::Variable * // Determine if substituted method cast requires cast from erased type Type *ETSChecker::GuaranteedTypeForUncheckedCallReturn(Signature *sig) { + ES2PANDA_ASSERT(sig != nullptr); ES2PANDA_ASSERT(sig->HasFunction()); if (sig->HasSignatureFlag(SignatureFlags::THIS_RETURN_TYPE)) { return sig->ReturnType(); @@ -648,9 +718,9 @@ Type *ETSChecker::ResolveUnionUncheckedType(ArenaVector &&appar return nullptr; } auto *unionType = CreateETSUnionType(std::move(apparentTypes)); + ES2PANDA_ASSERT(unionType != nullptr); if (unionType->IsETSUnionType()) { - checker::Type *typeLUB = unionType->AsETSUnionType()->GetAssemblerLUB(); - return typeLUB; + return unionType->AsETSUnionType(); } // Is case of single apparent type, just return itself return unionType; @@ -660,7 +730,8 @@ Type *ETSChecker::GuaranteedTypeForUnionFieldAccess(ir::MemberExpression *member { const auto &types = etsUnionType->ConstituentTypes(); ArenaVector apparentTypes {ProgramAllocator()->Adapter()}; - const auto &propertyName = memberExpression->Property()->AsIdentifier()->Name(); + const auto *prop = memberExpression->Property(); + const auto &propertyName = prop->IsIdentifier() ? prop->AsIdentifier()->Name() : prop->AsStringLiteral()->Str(); for (auto *type : types) { auto searchFlags = PropertySearchFlags::SEARCH_FIELD | PropertySearchFlags::SEARCH_METHOD | PropertySearchFlags::SEARCH_IN_BASE; @@ -751,6 +822,7 @@ Type *ETSChecker::GetTypeFromTypeAliasReference(varbinder::Variable *var) typeAliasType = CreateETSTypeAliasType(aliasTypeNode->Id()->Name(), aliasTypeNode); if (aliasTypeNode->TypeParams() != nullptr) { auto [typeParamTypes, ok] = CreateUnconstrainedTypeParameters(aliasTypeNode->TypeParams()); + ES2PANDA_ASSERT(typeAliasType != nullptr); typeAliasType->AsETSTypeAliasType()->SetTypeArguments(std::move(typeParamTypes)); if (ok) { AssignTypeParameterConstraints(aliasTypeNode->TypeParams()); @@ -761,7 +833,6 @@ Type *ETSChecker::GetTypeFromTypeAliasReference(varbinder::Variable *var) aliasTypeNode->Check(this); Type *targetType = aliasTypeNode->TypeAnnotation()->GetType(this); typeAliasType->AsETSTypeAliasType()->SetTargetType(targetType); - typeAliasType->AsETSTypeAliasType()->ApplySubstitution(Relation()); var->SetTsType(targetType); return targetType; @@ -773,8 +844,14 @@ Type *ETSChecker::GetTypeFromInterfaceReference(varbinder::Variable *var) return var->TsType(); } + CheckerStatus status = CheckerStatus::IN_STATIC_CONTEXT; + status &= this->Context().Status(); + this->Context().Status() &= ~CheckerStatus::IN_STATIC_CONTEXT; + auto *interfaceType = BuildBasicInterfaceProperties(var->Declaration()->Node()->AsTSInterfaceDeclaration()); var->SetTsType(interfaceType); + + this->Context().Status() |= status; return interfaceType; } @@ -786,8 +863,13 @@ Type *ETSChecker::GetTypeFromClassReference(varbinder::Variable *var) auto classDef = var->Declaration()->Node()->AsClassDefinition(); + CheckerStatus status = CheckerStatus::IN_STATIC_CONTEXT; + status &= this->Context().Status(); + this->Context().Status() &= ~CheckerStatus::IN_STATIC_CONTEXT; + auto *classType = BuildBasicClassProperties(classDef); var->SetTsType(classType); + this->Context().Status() |= status; return classType; } @@ -890,12 +972,15 @@ void ETSChecker::CheckAmbientAnnotation(ir::AnnotationDeclaration *annoImpl, ir: for (auto *prop : annoDecl->Properties()) { auto *field = prop->AsClassProperty(); + ES2PANDA_ASSERT(field->Id() != nullptr); fieldMap[field->Id()->Name()] = field; } for (auto *prop : annoImpl->Properties()) { auto *field = prop->AsClassProperty(); - auto fieldName = field->Id()->Name(); + auto *id = field->Id(); + ES2PANDA_ASSERT(id != nullptr); + auto fieldName = id->Name(); auto fieldDeclIter = fieldMap.find(fieldName); if (fieldDeclIter == fieldMap.end()) { LogError(diagnostic::AMBIENT_ANNOT_IMPL_OF_UNDEFINED_FIELD, {fieldName, annoDecl->GetBaseName()->Name()}, @@ -930,21 +1015,22 @@ void ETSChecker::CheckFunctionSignatureAnnotations(const ArenaVectorParams()) { + std::ignore = SetUpParameterType(typeParam); + CheckAnnotations(typeParam->Annotations()); + } + } + for (auto *param : params) { if (param->IsETSParameterExpression()) { CheckAnnotations(param->AsETSParameterExpression()->Annotations()); if (param->AsETSParameterExpression()->TypeAnnotation() != nullptr) { - param->AsETSParameterExpression()->TypeAnnotation()->Check(this); + CheckAnnotations(param->AsETSParameterExpression()->TypeAnnotation()->Annotations()); } } } - if (typeParams != nullptr) { - for (auto *typeParam : typeParams->Params()) { - CheckAnnotations(typeParam->Annotations()); - } - } - if (returnTypeAnnotation != nullptr) { ValidateThisUsage(returnTypeAnnotation); CheckAnnotations(returnTypeAnnotation->Annotations()); @@ -990,11 +1076,13 @@ void ETSChecker::ValidateThisUsage(const ir::TypeNode *returnTypeAnnotation) } if (returnTypeAnnotation->IsETSTypeReference() && IsFixedArray(returnTypeAnnotation->AsETSTypeReference()->Part())) { - auto elementType = returnTypeAnnotation->AsETSTypeReference()->Part()->TypeParams()->Params()[0]; - if (CheckAndLogInvalidThisUsage(elementType, diagnostic::NOT_ALLOWED_THIS_IN_ARRAY_TYPE)) { - return; + if (returnTypeAnnotation->AsETSTypeReference()->Part()->TypeParams() != nullptr) { + auto elementType = returnTypeAnnotation->AsETSTypeReference()->Part()->TypeParams()->Params()[0]; + if (CheckAndLogInvalidThisUsage(elementType, diagnostic::NOT_ALLOWED_THIS_IN_ARRAY_TYPE)) { + return; + } + ValidateThisUsage(elementType); } - ValidateThisUsage(elementType); return; } } @@ -1072,7 +1160,7 @@ void ETSChecker::HandleAnnotationRetention(ir::AnnotationUsage *anno, ir::Annota void ETSChecker::CheckStandardAnnotation(ir::AnnotationUsage *anno) { - if (anno->GetBaseName()->Variable() == nullptr) { + if (anno->GetBaseName()->Variable() == nullptr || IsTypeError(anno->GetBaseName()->TsType())) { return; } ES2PANDA_ASSERT(anno->GetBaseName()->Variable()->Declaration()->Node()->AsAnnotationDeclaration() != nullptr); @@ -1086,21 +1174,68 @@ void ETSChecker::CheckStandardAnnotation(ir::AnnotationUsage *anno) } } +static auto IsNonArrayLiteral(ir::Expression *init) +{ + if ((init == nullptr) || init->IsLiteral()) { + return true; + } + + if (init->TsType()->IsETSEnumType() && init->TsType()->AsETSEnumType()->NodeIsEnumLiteral(init)) { + return true; + } + return false; +} + +static auto IsValidAnnotationPropInitializer(ir::Expression *init) +{ + if (IsNonArrayLiteral(init)) { + return true; + } + + if (init->IsArrayExpression()) { + for (auto elem : init->AsArrayExpression()->Elements()) { + if (!IsValidAnnotationPropInitializer(elem)) { + return false; + } + } + return true; + } + return false; +} + +static bool ValidateAnnotationPropertyType(checker::Type *type, ETSChecker *checker) +{ + if (type == nullptr || type->IsTypeError()) { + ES2PANDA_ASSERT(checker->IsAnyError()); + return false; + } + + if (type->IsETSArrayType() || type->IsETSResizableArrayType()) { + return ValidateAnnotationPropertyType(checker->GetElementTypeOfArray(type), checker); + } + auto relation = checker->Relation(); + return type->IsETSEnumType() || type->IsETSStringType() || + (type->IsETSObjectType() && (relation->IsSupertypeOf(checker->GlobalETSBooleanBuiltinType(), type) || + relation->IsSupertypeOf(checker->GlobalByteBuiltinType(), type) || + relation->IsSupertypeOf(checker->GlobalShortBuiltinType(), type) || + relation->IsSupertypeOf(checker->GlobalIntBuiltinType(), type) || + relation->IsSupertypeOf(checker->GlobalLongBuiltinType(), type) || + relation->IsSupertypeOf(checker->GlobalFloatBuiltinType(), type) || + relation->IsSupertypeOf(checker->GlobalDoubleBuiltinType(), type))); +} + void ETSChecker::CheckAnnotationPropertyType(ir::ClassProperty *property) { // typeAnnotation check - if (!ValidateAnnotationPropertyType(property->TsType())) { + if (!ValidateAnnotationPropertyType(property->TsType(), this)) { LogError(diagnostic::ANNOT_FIELD_INVALID_TYPE, {}, property->Start()); } - // The type of the Initializer has been check in the parser, - // except for the enumeration type, because it is a member expression, - // so here is an additional check to the enumeration type. - if (property->Value() != nullptr && - ((property->Value()->IsMemberExpression() && !property->TsType()->IsETSEnumType()) || - property->Value()->IsIdentifier())) { - LogError(diagnostic::ANNOTATION_FIELD_NONLITERAL, {}, property->Value()->Start()); + if (IsValidAnnotationPropInitializer(property->Value())) { + return; } + + LogError(diagnostic::ANNOTATION_FIELD_NONLITERAL, {}, property->Value()->Start()); } void ETSChecker::CheckSinglePropertyAnnotation(ir::AnnotationUsage *st, ir::AnnotationDeclaration *annoDecl) @@ -1109,43 +1244,25 @@ void ETSChecker::CheckSinglePropertyAnnotation(ir::AnnotationUsage *st, ir::Anno if (annoDecl->Properties().size() > 1) { LogError(diagnostic::ANNOT_MULTIPLE_FIELD, {st->GetBaseName()->Name()}, st->Start()); } - auto singleField = annoDecl->Properties().at(0)->AsClassProperty(); - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto clone = singleField->TypeAnnotation()->Clone(ProgramAllocator(), param); - param->SetTypeAnnotation(clone); + ScopeContext scopeCtx(this, st->Scope()); param->Check(this); CheckAnnotationPropertyType(param); } -void ETSChecker::ProcessRequiredFields(ArenaUnorderedMap &fieldMap, - ir::AnnotationUsage *st, ETSChecker *checker) const -{ - for (const auto &entry : fieldMap) { - if (entry.second->Value() == nullptr) { - checker->LogError(diagnostic::ANNOT_FIELD_NO_VAL, {entry.first}, st->Start()); - continue; - } - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *clone = entry.second->Clone(checker->ProgramAllocator(), st); - st->AddProperty(clone); - } -} - void ETSChecker::CheckMultiplePropertiesAnnotation(ir::AnnotationUsage *st, util::StringView const &baseName, ArenaUnorderedMap &fieldMap) { for (auto *it : st->Properties()) { auto *param = it->AsClassProperty(); - auto result = fieldMap.find(param->Id()->Name()); + auto *id = param->Id(); + ES2PANDA_ASSERT(id != nullptr); + auto result = fieldMap.find(id->Name()); if (result == fieldMap.end()) { - LogError(diagnostic::ANNOT_PROP_UNDEFINED, {param->Id()->Name(), baseName}, param->Start()); + LogError(diagnostic::ANNOT_PROP_UNDEFINED, {id->Name(), baseName}, param->Start()); continue; } - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto clone = result->second->TypeAnnotation()->Clone(ProgramAllocator(), param); - param->SetTypeAnnotation(clone); ScopeContext scopeCtx(this, st->Scope()); param->Check(this); CheckAnnotationPropertyType(param); @@ -1181,7 +1298,7 @@ Type *ETSChecker::MaybeUnboxConditionalInRelation(Type *const objectType) return objectType; } - if ((objectType == nullptr) || !objectType->IsConditionalExprType()) { + if (objectType == nullptr) { return nullptr; } @@ -1217,11 +1334,13 @@ Type *ETSChecker::MaybeBoxInRelation(Type *objectType) Type *ETSChecker::MaybeBoxType(Type *type) const { + ES2PANDA_ASSERT(type != nullptr); return type->IsETSPrimitiveType() ? BoxingConverter::Convert(this, type) : type; } Type *ETSChecker::MaybeUnboxType(Type *type) const { + ES2PANDA_ASSERT(type != nullptr); return type->IsETSUnboxableObject() ? UnboxingConverter::Convert(this, type->AsETSObjectType()) : type; } @@ -1235,85 +1354,15 @@ Type const *ETSChecker::MaybeUnboxType(Type const *type) const return MaybeUnboxType(const_cast(type)); } -ir::BoxingUnboxingFlags ETSChecker::GetBoxingFlag(Type *const boxingType) -{ - auto typeKind = TypeKind(MaybeUnboxInRelation(boxingType)); - switch (typeKind) { - case TypeFlag::ETS_BOOLEAN: - return ir::BoxingUnboxingFlags::BOX_TO_BOOLEAN; - case TypeFlag::BYTE: - return ir::BoxingUnboxingFlags::BOX_TO_BYTE; - case TypeFlag::CHAR: - return ir::BoxingUnboxingFlags::BOX_TO_CHAR; - case TypeFlag::SHORT: - return ir::BoxingUnboxingFlags::BOX_TO_SHORT; - case TypeFlag::INT: - return ir::BoxingUnboxingFlags::BOX_TO_INT; - case TypeFlag::LONG: - return ir::BoxingUnboxingFlags::BOX_TO_LONG; - case TypeFlag::FLOAT: - return ir::BoxingUnboxingFlags::BOX_TO_FLOAT; - case TypeFlag::DOUBLE: - return ir::BoxingUnboxingFlags::BOX_TO_DOUBLE; - default: - ES2PANDA_UNREACHABLE(); - } -} - -ir::BoxingUnboxingFlags ETSChecker::GetUnboxingFlag(Type const *const unboxingType) const -{ - auto typeKind = TypeKind(unboxingType); - switch (typeKind) { - case TypeFlag::ETS_BOOLEAN: - return ir::BoxingUnboxingFlags::UNBOX_TO_BOOLEAN; - case TypeFlag::BYTE: - return ir::BoxingUnboxingFlags::UNBOX_TO_BYTE; - case TypeFlag::CHAR: - return ir::BoxingUnboxingFlags::UNBOX_TO_CHAR; - case TypeFlag::SHORT: - return ir::BoxingUnboxingFlags::UNBOX_TO_SHORT; - case TypeFlag::INT: - return ir::BoxingUnboxingFlags::UNBOX_TO_INT; - case TypeFlag::LONG: - return ir::BoxingUnboxingFlags::UNBOX_TO_LONG; - case TypeFlag::FLOAT: - return ir::BoxingUnboxingFlags::UNBOX_TO_FLOAT; - case TypeFlag::DOUBLE: - return ir::BoxingUnboxingFlags::UNBOX_TO_DOUBLE; - default: - ES2PANDA_UNREACHABLE(); - } -} - -void ETSChecker::MaybeAddBoxingFlagInRelation(TypeRelation *relation, Type *target) -{ - auto boxingResult = MaybeBoxInRelation(target); - if ((boxingResult != nullptr) && !relation->OnlyCheckBoxingUnboxing()) { - relation->GetNode()->RemoveBoxingUnboxingFlags(ir::BoxingUnboxingFlags::BOXING_FLAG); - relation->GetNode()->AddBoxingUnboxingFlags(GetBoxingFlag(boxingResult)); - relation->Result(true); - } -} - -void ETSChecker::MaybeAddUnboxingFlagInRelation(TypeRelation *relation, Type *source, Type *self) -{ - auto unboxingResult = UnboxingConverter(this, relation, source, self).Result(); - if ((unboxingResult != nullptr) && relation->IsTrue() && !relation->OnlyCheckBoxingUnboxing()) { - relation->GetNode()->AddBoxingUnboxingFlags(GetUnboxingFlag(unboxingResult)); - } -} - void ETSChecker::CheckUnboxedTypeWidenable(TypeRelation *relation, Type *target, Type *self) { - checker::SavedTypeRelationFlagsContext savedTypeRelationFlagCtx( - relation, TypeRelationFlag::ONLY_CHECK_WIDENING | - (relation->ApplyNarrowing() ? TypeRelationFlag::NARROWING : TypeRelationFlag::NONE)); + checker::SavedTypeRelationFlagsContext savedTypeRelationFlagCtx(relation, TypeRelationFlag::ONLY_CHECK_WIDENING); // NOTE: vpukhov. handle union type auto unboxedType = MaybeUnboxInRelation(target); if (unboxedType == nullptr) { return; } - NarrowingWideningConverter(this, relation, unboxedType, self); + WideningConverter(this, relation, unboxedType, self); if (!relation->IsTrue()) { relation->Result(relation->IsAssignableTo(self, unboxedType)); } @@ -1327,10 +1376,6 @@ void ETSChecker::CheckUnboxedTypesAssignable(TypeRelation *relation, Type *sourc return; } relation->IsAssignableTo(unboxedSourceType, unboxedTargetType); - if (relation->IsTrue()) { - relation->GetNode()->AddBoxingUnboxingFlags( - relation->GetChecker()->AsETSChecker()->GetUnboxingFlag(unboxedSourceType)); - } } void ETSChecker::CheckBoxedSourceTypeAssignable(TypeRelation *relation, Type *source, Type *target) @@ -1338,7 +1383,6 @@ void ETSChecker::CheckBoxedSourceTypeAssignable(TypeRelation *relation, Type *so ES2PANDA_ASSERT(relation != nullptr); checker::SavedTypeRelationFlagsContext savedTypeRelationFlagCtx( relation, (relation->ApplyWidening() ? TypeRelationFlag::WIDENING : TypeRelationFlag::NONE) | - (relation->ApplyNarrowing() ? TypeRelationFlag::NARROWING : TypeRelationFlag::NONE) | (relation->OnlyCheckBoxingUnboxing() ? TypeRelationFlag::ONLY_CHECK_BOXING_UNBOXING : TypeRelationFlag::NONE)); @@ -1347,22 +1391,13 @@ void ETSChecker::CheckBoxedSourceTypeAssignable(TypeRelation *relation, Type *so return; } ES2PANDA_ASSERT(target != nullptr); - // Do not box primitive in case of cast to dynamic types - if (target->IsETSDynamicType()) { - return; - } relation->IsAssignableTo(boxedSourceType, target); - if (relation->IsTrue()) { - MaybeAddBoxingFlagInRelation(relation, boxedSourceType); - } else { + if (!relation->IsTrue()) { auto unboxedTargetType = MaybeUnboxInRelation(target); if (unboxedTargetType == nullptr) { return; } - NarrowingWideningConverter(this, relation, unboxedTargetType, source); - if (relation->IsTrue()) { - MaybeAddBoxingFlagInRelation(relation, target); - } + WideningConverter(this, relation, unboxedTargetType, source); } } @@ -1376,28 +1411,6 @@ void ETSChecker::CheckUnboxedSourceTypeWithWideningAssignable(TypeRelation *rela if (!relation->IsTrue() && relation->ApplyWidening()) { relation->GetChecker()->AsETSChecker()->CheckUnboxedTypeWidenable(relation, target, unboxedSourceType); } - if (!relation->OnlyCheckBoxingUnboxing()) { - relation->GetNode()->AddBoxingUnboxingFlags( - relation->GetChecker()->AsETSChecker()->GetUnboxingFlag(unboxedSourceType)); - } -} - -static ir::AstNode *DerefETSTypeReference(ir::AstNode *node) -{ - ES2PANDA_ASSERT(node->IsETSTypeReference()); - do { - auto *name = node->AsETSTypeReference()->Part()->GetIdent(); - - ES2PANDA_ASSERT(name->IsIdentifier()); - auto *var = name->AsIdentifier()->Variable(); - ES2PANDA_ASSERT(var != nullptr); - auto *declNode = var->Declaration()->Node(); - if (!declNode->IsTSTypeAliasDeclaration()) { - return declNode; - } - node = declNode->AsTSTypeAliasDeclaration()->TypeAnnotation(); - } while (node->IsETSTypeReference()); - return node; } // #22952: optional arrow leftovers @@ -1409,14 +1422,13 @@ bool ETSChecker::CheckLambdaAssignable(ir::Expression *param, ir::ScriptFunction return false; } if (typeAnn->IsETSTypeReference() && !typeAnn->AsETSTypeReference()->TsType()->IsETSArrayType()) { - typeAnn = DerefETSTypeReference(typeAnn); + typeAnn = util::Helpers::DerefETSTypeReference(typeAnn); } if (!typeAnn->IsETSFunctionType()) { // the surrounding function is made so we can *bypass* the typecheck in the "inference" context, // however the body of the function has to be checked in any case if (typeAnn->IsETSUnionType()) { - lambda->Parent()->Check(this); return CheckLambdaAssignableUnion(typeAnn, lambda); } @@ -1436,7 +1448,7 @@ bool ETSChecker::CheckLambdaInfer(ir::AstNode *typeAnnotation, ir::ArrowFunction Type *const subParameterType) { if (typeAnnotation->IsETSTypeReference()) { - typeAnnotation = DerefETSTypeReference(typeAnnotation); + typeAnnotation = util::Helpers::DerefETSTypeReference(typeAnnotation); } if (!typeAnnotation->IsETSFunctionType()) { @@ -1451,10 +1463,14 @@ bool ETSChecker::CheckLambdaInfer(ir::AstNode *typeAnnotation, ir::ArrowFunction return true; } -bool ETSChecker::CheckLambdaTypeAnnotation(ir::AstNode *typeAnnotation, +bool ETSChecker::CheckLambdaTypeAnnotation(ir::ETSParameterExpression *param, ir::ArrowFunctionExpression *const arrowFuncExpr, Type *const parameterType, TypeRelationFlag flags) { + ir::AstNode *typeAnnotation = param->Ident()->TypeAnnotation(); + if (typeAnnotation->IsETSTypeReference()) { + typeAnnotation = util::Helpers::DerefETSTypeReference(typeAnnotation); + } auto checkInvocable = [&arrowFuncExpr, ¶meterType, this](TypeRelationFlag functionFlags) { Type *const argumentType = arrowFuncExpr->Check(this); functionFlags |= TypeRelationFlag::NO_THROW; @@ -1466,10 +1482,11 @@ bool ETSChecker::CheckLambdaTypeAnnotation(ir::AstNode *typeAnnotation, // process `single` type as usual. if (!typeAnnotation->IsETSUnionType()) { - auto param = typeAnnotation->Parent()->Parent()->AsETSParameterExpression(); // #22952: infer optional parameter heuristics auto nonNullishParam = param->IsOptional() ? GetNonNullishType(parameterType) : parameterType; + ES2PANDA_ASSERT(nonNullishParam != nullptr); if (!nonNullishParam->IsETSFunctionType()) { + arrowFuncExpr->Check(this); return true; } // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -1484,13 +1501,12 @@ bool ETSChecker::CheckLambdaTypeAnnotation(ir::AstNode *typeAnnotation, } auto *const lambdaReturnTypeAnnotation = lambda->ReturnTypeAnnotation(); - Type *const argumentType = arrowFuncExpr->Check(this); - if (Relation()->IsSupertypeOf(parameterType, argumentType)) { - return true; + if (!parameterType->IsETSUnionType() || parameterType->AsETSUnionType()->ConstituentTypes().size() != + typeAnnotation->AsETSUnionType()->Types().size()) { + Type *const argumentType = arrowFuncExpr->Check(this); + return Relation()->IsSupertypeOf(parameterType, argumentType); } - ES2PANDA_ASSERT(parameterType->AsETSUnionType()->ConstituentTypes().size() == - typeAnnotation->AsETSUnionType()->Types().size()); const auto typeAnnsOfUnion = typeAnnotation->AsETSUnionType()->Types(); const auto typeParamOfUnion = parameterType->AsETSUnionType()->ConstituentTypes(); for (size_t ix = 0; ix < typeAnnsOfUnion.size(); ++ix) { @@ -1525,18 +1541,19 @@ bool ETSChecker::ResolveLambdaArgumentType(Signature *signature, ir::Expression auto arrowFuncExpr = argument->AsArrowFunctionExpression(); bool typeValid = true; ir::ScriptFunction *const lambda = arrowFuncExpr->Function(); - if (!NeedTypeInference(lambda)) { + // Note: (Issue27688) if lambda is trailing lambda transferred, it must be in recheck. + // its type was cleared before the check, so here we need recheck it. + if (!NeedTypeInference(lambda) && !lambda->IsTrailingLambda()) { return typeValid; } arrowFuncExpr->SetTsType(nullptr); - auto const *const param = + auto *const param = signature->GetSignatureInfo()->params[paramPosition]->Declaration()->Node()->AsETSParameterExpression(); - ir::AstNode *typeAnn = param->Ident()->TypeAnnotation(); Type *const parameterType = signature->Params()[paramPosition]->TsType(); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - bool rc = CheckLambdaTypeAnnotation(typeAnn, arrowFuncExpr, parameterType, resolutionFlags); + bool rc = CheckLambdaTypeAnnotation(param, arrowFuncExpr, parameterType, resolutionFlags); if (!rc) { if ((resolutionFlags & TypeRelationFlag::NO_THROW) == 0) { Type *const argumentType = arrowFuncExpr->Check(this); @@ -1635,4 +1652,180 @@ void ETSChecker::CheckExceptionClauseType(const std::vectorLogError(diagnostic::OVERLOAD_MODIFIERS_ABSTRACT, {}, pos); + return false; + } + + if (((overLoadAliasFlags ^ overloadedMethodFlags) & (ir::ModifierFlags::STATIC | ir::ModifierFlags::ASYNC)) != 0) { + checker->LogError(diagnostic::OVERLOAD_SAME_ACCESS_MODIFIERS_STATIC_ASYNC, {}, pos); + return false; + } + + if (((overLoadAliasFlags ^ overloadedMethodFlags) & (ir::ModifierFlags::CONSTRUCTOR)) != 0) { + checker->LogError(diagnostic::OVERLOAD_MUST_BOTH_CONSTRUCT, {}, pos); + return false; + } + + if ((overLoadAliasFlags & ir::ModifierFlags::EXPORT) != 0 && + (overloadedMethodFlags & ir::ModifierFlags::EXPORT) == 0) { + checker->LogError(diagnostic::OVERLOADED_NAME_MUST_ALSO_EXPORTED, {}, pos); + return false; + } + return true; +} + +static bool CheckOverloadedName(ETSChecker *checker, ir::OverloadDeclaration *node, ir::Expression *overloadedName) +{ + if (overloadedName->Variable()->Declaration() == nullptr) { + checker->LogError(diagnostic::OVERLOADED_NAME_MUST_FUNCTION, {}, overloadedName->Start()); + overloadedName->SetTsType(checker->GlobalTypeError()); + return false; + } + + auto *identDeclNode = overloadedName->Variable()->Declaration()->Node(); + if (!identDeclNode->IsMethodDefinition()) { + checker->LogError(diagnostic::OVERLOADED_NAME_MUST_FUNCTION, {}, overloadedName->Start()); + overloadedName->SetTsType(checker->GlobalTypeError()); + return false; + } + // Constructor will lowering to multiple Constructor if have rest parameters or optional parameters. + // Need to modify RestTupleConstructionPhase. + if (!identDeclNode->AsMethodDefinition()->Overloads().empty() && !identDeclNode->IsConstructor()) { + checker->LogError(diagnostic::OVERLOADED_NAME_REFER_TO_OVERLOAD_FUNCTION, {overloadedName->Variable()->Name()}, + overloadedName->Start()); + overloadedName->SetTsType(checker->GlobalTypeError()); + return false; + } + + return CheckAccessModifierForOverloadDeclaration(checker, node->Modifiers(), identDeclNode->Modifiers(), + overloadedName->Start()); +} + +void ETSChecker::CheckFunctionOverloadDeclaration(ETSChecker *checker, ir::OverloadDeclaration *node) const +{ + for (auto *overloadedName : node->OverloadedList()) { + if (overloadedName->IsMemberExpression()) { + overloadedName->Check(checker); + overloadedName->SetVariable(overloadedName->AsMemberExpression()->Property()->Variable()); + } else if (overloadedName->IsIdentifier()) { + ir::Identifier *ident = overloadedName->AsIdentifier(); + + Type *classType = node->Parent()->AsClassDefinition()->TsType(); + ES2PANDA_ASSERT(classType->IsETSObjectType()); + + PropertySearchFlags searchFlags = PropertySearchFlags::SEARCH_METHOD | PropertySearchFlags::SEARCH_IN_BASE | + PropertySearchFlags::SEARCH_IN_INTERFACES | + PropertySearchFlags::IS_GETTER; + auto *variable = + checker->ResolveOverloadReference(ident->AsIdentifier(), classType->AsETSObjectType(), searchFlags); + if (variable == nullptr) { + checker->LogError(diagnostic::OVERLOADED_NAME_MUST_FUNCTION, {}, ident->Start()); + ident->SetTsType(checker->GlobalTypeError()); + continue; + } + + ident->SetTsType(variable->TsType()); + ident->SetVariable(variable); + + if (!CheckOverloadedName(checker, node, overloadedName)) { + continue; + } + } else { + overloadedName->SetTsType(checker->GlobalTypeError()); + continue; + } + } +} + +void ETSChecker::CheckClassMethodOverloadDeclaration(ETSChecker *checker, ir::OverloadDeclaration *node) const +{ + for (auto *overloadedName : node->OverloadedList()) { + if (!overloadedName->IsIdentifier()) { + overloadedName->SetTsType(checker->GlobalTypeError()); + continue; + } + ir::Identifier *ident = overloadedName->AsIdentifier(); + + Type *classType = node->Parent()->AsClassDefinition()->TsType(); + ES2PANDA_ASSERT(classType->IsETSObjectType()); + + PropertySearchFlags searchFlags = PropertySearchFlags::SEARCH_METHOD | PropertySearchFlags::SEARCH_IN_BASE | + PropertySearchFlags::SEARCH_IN_INTERFACES | PropertySearchFlags::IS_GETTER; + auto *variable = + checker->ResolveOverloadReference(ident->AsIdentifier(), classType->AsETSObjectType(), searchFlags); + if (variable == nullptr) { + checker->LogError(diagnostic::OVERLOADED_NAME_MUST_FUNCTION, {}, ident->Start()); + ident->SetTsType(checker->GlobalTypeError()); + continue; + } + + ident->SetTsType(variable->TsType()); + ident->SetVariable(variable); + + if (!CheckOverloadedName(checker, node, overloadedName)) { + continue; + } + } +} + +void ETSChecker::CheckInterfaceMethodOverloadDeclaration(ETSChecker *checker, ir::OverloadDeclaration *node) const +{ + for (auto *overloadedName : node->OverloadedList()) { + if (!overloadedName->IsIdentifier()) { + overloadedName->SetTsType(checker->GlobalTypeError()); + continue; + } + ir::Identifier *ident = overloadedName->AsIdentifier(); + + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + Type *identType = checker->ResolveIdentifier(ident); + ident->SetTsType(identType); + if (!CheckOverloadedName(checker, node, overloadedName)) { + continue; + } + } +} + +void ETSChecker::CheckConstructorOverloadDeclaration(ETSChecker *checker, ir::OverloadDeclaration *node) const +{ + for (auto *overloadedName : node->OverloadedList()) { + if (!overloadedName->IsIdentifier()) { + overloadedName->SetTsType(checker->GlobalTypeError()); + continue; + } + ir::Identifier *ident = overloadedName->AsIdentifier(); + + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + Type *identType = checker->ResolveIdentifier(ident->AsIdentifier()); + ident->SetTsType(identType); + if (identType->IsTypeError()) { + continue; + } + + ES2PANDA_ASSERT(identType->IsETSFunctionType()); + const size_t singleSignatureSize = 1; + if (identType->AsETSFunctionType()->CallSignatures().size() > singleSignatureSize) { + size_t userDefinedConstructorSize = + std::count_if(identType->AsETSFunctionType()->CallSignatures().begin(), + identType->AsETSFunctionType()->CallSignatures().end(), + [](Signature *sig) { return !sig->Function()->IsSynthetic(); }); + if (userDefinedConstructorSize > singleSignatureSize) { + checker->LogError(diagnostic::OVERLOADED_NAME_REFER_TO_OVERLOAD_FUNCTION, {ident->Name()}, + node->Start()); + continue; + } + } + + if (!CheckOverloadedName(checker, node, overloadedName)) { + continue; + } + } +} + } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/ets/typeConverter.h b/ets2panda/checker/ets/typeConverter.h index 2d0bd3db6ce4eecd8838166e27c22b1fb93d0ca7..46635fdc5d66f58cfaa086f6b093a378a749bac2 100644 --- a/ets2panda/checker/ets/typeConverter.h +++ b/ets2panda/checker/ets/typeConverter.h @@ -62,7 +62,7 @@ public: template static Type *ConvertConstantType(Type *source, ArenaAllocator *allocator) { - switch (static_cast(source->TypeFlags() & TypeFlag::ETS_TYPE)) { + switch (static_cast(source->TypeFlags() & (TypeFlag::ETS_NUMERIC | TypeFlag::CHAR))) { case TypeFlag::INT: return ConvertConstant(source->AsIntType(), allocator); @@ -95,7 +95,7 @@ public: { ES2PANDA_ASSERT(source->IsETSPrimitiveType() && target->IsETSPrimitiveType() && source->IsConstantType()); - switch (static_cast(target->TypeFlags() & TypeFlag::ETS_TYPE)) { + switch (static_cast(target->TypeFlags() & (TypeFlag::ETS_NUMERIC | TypeFlag::CHAR))) { case TypeFlag::INT: return ConvertConstantType(source, allocator); diff --git a/ets2panda/checker/ets/typeCreation.cpp b/ets2panda/checker/ets/typeCreation.cpp index 4c35d829af3a26b73da9834501dd945f6dccaad4..959fcad7731532ffdfb72a35ebfbf334621adbbd 100644 --- a/ets2panda/checker/ets/typeCreation.cpp +++ b/ets2panda/checker/ets/typeCreation.cpp @@ -17,12 +17,14 @@ #include "checker/types/ets/etsAsyncFuncReturnType.h" #include "checker/types/ets/etsEnumType.h" -#include "checker/types/ets/etsDynamicFunctionType.h" #include "checker/types/ets/etsResizableArrayType.h" #include "checker/types/globalTypesHolder.h" +#include "checker/types/gradualType.h" #include "checker/types/type.h" #include "ir/statements/annotationDeclaration.h" +#include + namespace ark::es2panda::checker { ByteType *ETSChecker::CreateByteType(int8_t value) @@ -50,32 +52,6 @@ IntType *ETSChecker::CreateIntType(int32_t value) return ProgramAllocator()->New(value); } -IntType *ETSChecker::CreateIntTypeFromType(Type *type) -{ - if (!type->HasTypeFlag(TypeFlag::CONSTANT)) { - return GlobalIntType()->AsIntType(); - } - - if (type->IsIntType()) { - return type->AsIntType(); - } - - switch (ETSType(type)) { - case TypeFlag::CHAR: { - return CreateIntType(static_cast(type->AsCharType()->GetValue())); - } - case TypeFlag::BYTE: { - return CreateIntType(static_cast(type->AsByteType()->GetValue())); - } - case TypeFlag::SHORT: { - return CreateIntType(static_cast(type->AsShortType()->GetValue())); - } - default: { - return nullptr; - } - } -} - LongType *ETSChecker::CreateLongType(int64_t value) { return ProgramAllocator()->New(value); @@ -103,29 +79,33 @@ ETSStringType *ETSChecker::CreateETSStringLiteralType(util::StringView value) ETSResizableArrayType *ETSChecker::CreateETSMultiDimResizableArrayType(Type *element, size_t dimSize) { - ETSResizableArrayType *const arrayType = GlobalBuiltinETSResizableArrayType()->AsETSResizableArrayType(); + ETSObjectType *type = GlobalBuiltinETSResizableArrayType(); + ES2PANDA_ASSERT(type != nullptr); + ETSResizableArrayType *const arrayType = type->AsETSResizableArrayType(); ES2PANDA_ASSERT(arrayType->TypeArguments().size() == 1U); Type *baseArrayType = element; for (size_t dim = 0; dim < dimSize; ++dim) { - Substitution *tmpSubstitution = NewSubstitution(); - EmplaceSubstituted(tmpSubstitution, arrayType->TypeArguments()[0]->AsETSTypeParameter()->GetOriginal(), + auto tmpSubstitution = Substitution {}; + EmplaceSubstituted(&tmpSubstitution, arrayType->TypeArguments()[0]->AsETSTypeParameter()->GetOriginal(), MaybeBoxType(baseArrayType)); - baseArrayType = arrayType->Substitute(Relation(), tmpSubstitution); + baseArrayType = arrayType->Substitute(Relation(), &tmpSubstitution); } return baseArrayType->AsETSResizableArrayType(); } ETSResizableArrayType *ETSChecker::CreateETSResizableArrayType(Type *element) { - ETSResizableArrayType *arrayType = GlobalBuiltinETSResizableArrayType()->AsETSResizableArrayType(); + ETSObjectType *type = GlobalBuiltinETSResizableArrayType(); + ES2PANDA_ASSERT(type != nullptr); + ETSResizableArrayType *arrayType = type->AsETSResizableArrayType(); ES2PANDA_ASSERT(arrayType->TypeArguments().size() == 1U); - Substitution *substitution = NewSubstitution(); - EmplaceSubstituted(substitution, arrayType->TypeArguments()[0]->AsETSTypeParameter()->GetOriginal(), + auto substitution = Substitution {}; + EmplaceSubstituted(&substitution, arrayType->TypeArguments()[0]->AsETSTypeParameter()->GetOriginal(), MaybeBoxType(element)); - return arrayType->Substitute(Relation(), substitution); + return arrayType->Substitute(Relation(), &substitution); } ETSArrayType *ETSChecker::CreateETSArrayType(Type *elementType, bool isCachePolluting) @@ -137,6 +117,7 @@ ETSArrayType *ETSChecker::CreateETSArrayType(Type *elementType, bool isCachePoll auto *arrayType = ProgramAllocator()->New(elementType); + ES2PANDA_ASSERT(arrayType != nullptr); std::stringstream ss; arrayType->ToAssemblerTypeWithRank(ss); // arrayType->SetAssemblerName(util::UString(ss.str(), ProgramAllocator()).View()); @@ -149,6 +130,27 @@ ETSArrayType *ETSChecker::CreateETSArrayType(Type *elementType, bool isCachePoll return arrayType; } +Type *ETSChecker::CreateGradualType(Type *type, Language const lang) +{ + if (type == nullptr) { + return type; + } + if (type->IsGradualType()) { + return type; + } + if (type->IsETSAnyType()) { + return type; + } + if (type->IsETSUnionType()) { + ArenaVector copied(ProgramAllocator()->Adapter()); + for (auto const &t : type->AsETSUnionType()->ConstituentTypes()) { + copied.push_back(CreateGradualType(t, lang)); + } + return CreateETSUnionType(std::move(copied)); + } + return ProgramAllocator()->New(type); +} + Type *ETSChecker::CreateETSUnionType(Span constituentTypes) { if (constituentTypes.empty()) { @@ -162,8 +164,12 @@ Type *ETSChecker::CreateETSUnionType(Span constituentTypes) if (newConstituentTypes.size() == 1) { return newConstituentTypes[0]; } - - return ProgramAllocator()->New(this, std::move(newConstituentTypes)); + auto *un = ProgramAllocator()->New(this, std::move(newConstituentTypes)); + auto ut = un->GetAssemblerType().Mutf8(); + if (std::count_if(ut.begin(), ut.end(), [](char c) { return c == ','; }) > 0) { + unionAssemblerTypes_.insert(un->GetAssemblerType()); + } + return un; } ETSTypeAliasType *ETSChecker::CreateETSTypeAliasType(util::StringView name, const ir::AstNode *declNode, @@ -182,17 +188,6 @@ ETSFunctionType *ETSChecker::CreateETSMethodType(util::StringView name, ArenaVec return ProgramAllocator()->New(this, name, std::move(signatures)); } -ETSFunctionType *ETSChecker::CreateETSDynamicArrowType(Signature *signature, Language lang) -{ - return ProgramAllocator()->New(this, signature, lang); -} - -ETSFunctionType *ETSChecker::CreateETSDynamicMethodType(util::StringView name, ArenaVector &&signatures, - Language lang) -{ - return ProgramAllocator()->New(this, name, std::move(signatures), lang); -} - static SignatureFlags ConvertToSignatureFlags(ir::ModifierFlags inModifiers, ir::ScriptFunctionFlags inFunctionFlags) { SignatureFlags outFlags = SignatureFlags::NO_OPTS; @@ -208,9 +203,6 @@ static SignatureFlags ConvertToSignatureFlags(ir::ModifierFlags inModifiers, ir: } }; - convertFlag(ir::ScriptFunctionFlags::THROWS, SignatureFlags::THROWS); - convertFlag(ir::ScriptFunctionFlags::RETHROWS, SignatureFlags::RETHROWS); - convertFlag(ir::ScriptFunctionFlags::CONSTRUCTOR, SignatureFlags::CONSTRUCTOR); convertFlag(ir::ScriptFunctionFlags::SETTER, SignatureFlags::SETTER); convertFlag(ir::ScriptFunctionFlags::GETTER, SignatureFlags::GETTER); @@ -222,6 +214,7 @@ static SignatureFlags ConvertToSignatureFlags(ir::ModifierFlags inModifiers, ir: convertModifier(ir::ModifierFlags::PUBLIC, SignatureFlags::PUBLIC); convertModifier(ir::ModifierFlags::PRIVATE, SignatureFlags::PRIVATE); convertModifier(ir::ModifierFlags::INTERNAL, SignatureFlags::INTERNAL); + convertModifier(ir::ModifierFlags::DEFAULT, SignatureFlags::DEFAULT); return outFlags; } @@ -234,6 +227,7 @@ Signature *ETSChecker::CreateSignature(SignatureInfo *info, Type *returnType, ir } auto signature = ProgramAllocator()->New(info, returnType, func); auto convertedFlag = ConvertToSignatureFlags(func->Modifiers(), func->Flags()); + ES2PANDA_ASSERT(signature != nullptr); func->HasReceiver() ? signature->AddSignatureFlag(SignatureFlags::EXTENSION_FUNCTION | convertedFlag) : signature->AddSignatureFlag(convertedFlag); return signature; @@ -247,6 +241,7 @@ Signature *ETSChecker::CreateSignature(SignatureInfo *info, Type *returnType, ir return nullptr; } auto signature = ProgramAllocator()->New(info, returnType, nullptr); + ES2PANDA_ASSERT(signature != nullptr); signature->AddSignatureFlag(ConvertToSignatureFlags(ir::ModifierFlags::NONE, sff)); // synthetic arrow type signature flags auto extraFlags = SignatureFlags::ABSTRACT | SignatureFlags::CALL | SignatureFlags::PUBLIC; @@ -305,8 +300,8 @@ static ETSObjectType *InitializeGlobalBuiltinObjectType(ETSChecker *checker, Glo auto *objType = setType(GlobalTypeId::ETS_OBJECT_BUILTIN, create())->AsETSObjectType(); auto null = checker->GlobalETSNullType(); auto undef = checker->GlobalETSUndefinedType(); - setType(GlobalTypeId::ETS_NULLISH_OBJECT, checker->CreateETSUnionType({objType, null, undef})); - setType(GlobalTypeId::ETS_NULLISH_TYPE, checker->CreateETSUnionType({null, undef})); + setType(GlobalTypeId::ETS_UNION_UNDEFINED_NULL_OBJECT, checker->CreateETSUnionType({objType, null, undef})); + setType(GlobalTypeId::ETS_UNION_UNDEFINED_NULL, checker->CreateETSUnionType({null, undef})); return objType; } case GlobalTypeId::ETS_STRING_BUILTIN: { @@ -365,56 +360,27 @@ ETSObjectType *ETSChecker::CreateETSObjectTypeOrBuiltin(ir::AstNode *declNode, E return InitializeGlobalBuiltinObjectType(this, globalId.value(), declNode, flags); } -std::tuple ETSChecker::CheckForDynamicLang(ir::AstNode *declNode, util::StringView assemblerName) -{ - Language lang(Language::Id::ETS); - bool hasDecl = false; - - if (declNode->IsClassDefinition()) { - auto *clsDef = declNode->AsClassDefinition(); - lang = clsDef->Language(); - hasDecl = clsDef->IsDeclare(); - } - - if (declNode->IsTSInterfaceDeclaration()) { - auto *ifaceDecl = declNode->AsTSInterfaceDeclaration(); - lang = ifaceDecl->Language(); - hasDecl = ifaceDecl->IsDeclare(); - } - - auto res = compiler::Signatures::Dynamic::LanguageFromType(assemblerName.Utf8()); - if (res) { - lang = *res; - } - - return std::make_tuple(lang, hasDecl); -} - ETSObjectType *ETSChecker::CreateETSObjectType(ir::AstNode *declNode, ETSObjectFlags flags) { auto const [name, internalName] = GetObjectTypeDeclNames(declNode); - + ETSObjectType *objectType = nullptr; if (declNode->IsClassDefinition() && (declNode->AsClassDefinition()->IsEnumTransformed())) { if (declNode->AsClassDefinition()->IsIntEnumTransformed()) { - return ProgramAllocator()->New(ProgramAllocator(), name, internalName, declNode, - Relation()); + objectType = + ProgramAllocator()->New(ProgramAllocator(), name, internalName, declNode, Relation()); + } else { + ES2PANDA_ASSERT(declNode->AsClassDefinition()->IsStringEnumTransformed()); + objectType = ProgramAllocator()->New(ProgramAllocator(), name, internalName, declNode, + Relation()); } - ES2PANDA_ASSERT(declNode->AsClassDefinition()->IsStringEnumTransformed()); - return ProgramAllocator()->New(ProgramAllocator(), name, internalName, declNode, Relation()); + } else if (internalName == compiler::Signatures::BUILTIN_ARRAY) { + objectType = ProgramAllocator()->New(ProgramAllocator(), name, + std::make_tuple(declNode, flags, Relation())); + } else { + objectType = ProgramAllocator()->New(ProgramAllocator(), name, internalName, + std::make_tuple(declNode, flags, Relation())); } - - if (internalName == compiler::Signatures::BUILTIN_ARRAY) { - return ProgramAllocator()->New(ProgramAllocator(), name, - std::make_tuple(declNode, flags, Relation())); - } - - if (auto [lang, hasDecl] = CheckForDynamicLang(declNode, internalName); lang.IsDynamic()) { - return ProgramAllocator()->New(ProgramAllocator(), std::make_tuple(name, internalName, lang), - std::make_tuple(declNode, flags, Relation()), hasDecl); - } - - return ProgramAllocator()->New(ProgramAllocator(), name, internalName, - std::make_tuple(declNode, flags, Relation())); + return objectType; } std::tuple ETSChecker::CreateBuiltinArraySignatureInfo(const ETSArrayType *arrayType, @@ -426,12 +392,14 @@ std::tuple ETSChecker::CreateBuiltinArraySign arrayType->ToAssemblerTypeWithRank(ss); auto *info = CreateSignatureInfo(); + ES2PANDA_ASSERT(info != nullptr); info->minArgCount = dim; for (size_t i = 0; i < dim; i++) { util::UString param(std::to_string(i), ProgramAllocator()); auto *paramVar = varbinder::Scope::CreateVar(ProgramAllocator(), param.View(), varbinder::VariableFlags::NONE, nullptr); + ES2PANDA_ASSERT(paramVar != nullptr); paramVar->SetTsType(GlobalIntType()); info->params.push_back(paramVar); @@ -448,15 +416,19 @@ std::tuple ETSChecker::CreateBuiltinArraySign Signature *ETSChecker::CreateBuiltinArraySignature(const ETSArrayType *arrayType, size_t dim) { - auto res = globalArraySignatures_.find(arrayType); - if (res != globalArraySignatures_.end()) { + auto currentChecker = + compiler::GetPhaseManager()->Context() != nullptr ? compiler::GetPhaseManager()->Context()->GetChecker() : this; + auto &globalArraySignatures = currentChecker->AsETSChecker()->globalArraySignatures_; + auto res = globalArraySignatures.find(arrayType); + if (res != globalArraySignatures.end()) { return res->second; } auto [internalName, info] = CreateBuiltinArraySignatureInfo(arrayType, dim); auto *signature = CreateSignature(info, GlobalVoidType(), ir::ScriptFunctionFlags::NONE, false); + ES2PANDA_ASSERT(signature != nullptr); signature->SetInternalName(internalName); - globalArraySignatures_.insert({arrayType, signature}); + globalArraySignatures.insert({arrayType, signature}); return signature; } @@ -466,10 +438,11 @@ ETSObjectType *ETSChecker::CreatePromiseOf(Type *type) ETSObjectType *const promiseType = GlobalBuiltinPromiseType(); ES2PANDA_ASSERT(promiseType->TypeArguments().size() == 1U); - Substitution *substitution = NewSubstitution(); - EmplaceSubstituted(substitution, promiseType->TypeArguments()[0]->AsETSTypeParameter()->GetOriginal(), type); + auto substitution = Substitution {}; + ES2PANDA_ASSERT(promiseType != nullptr); + EmplaceSubstituted(&substitution, promiseType->TypeArguments()[0]->AsETSTypeParameter()->GetOriginal(), type); - return promiseType->Substitute(Relation(), substitution); + return promiseType->Substitute(Relation(), &substitution); } static bool IsInValidKeyofTypeNode(ir::AstNode *node) diff --git a/ets2panda/checker/ets/typeRelationContext.cpp b/ets2panda/checker/ets/typeRelationContext.cpp index 00dcde0ae4f6226f2eee1d2649cfaf76282d2fd1..855ea818309eec24bf01bb68432e35ebd88e9010 100644 --- a/ets2panda/checker/ets/typeRelationContext.cpp +++ b/ets2panda/checker/ets/typeRelationContext.cpp @@ -73,30 +73,18 @@ void InstantiationContext::InstantiateType(ETSObjectType *type, ir::TSTypeParame if (typeArgs != nullptr) { for (auto *const it : typeArgs->Params()) { auto *paramType = it->GetType(checker_); + ES2PANDA_ASSERT(paramType != nullptr); if (paramType->IsTypeError()) { result_ = paramType; return; } - - if (paramType->IsETSPrimitiveType()) { - checker_->Relation()->SetNode(it); - - auto *const boxedTypeArg = checker_->MaybeBoxInRelation(paramType); - if (boxedTypeArg != nullptr) { - paramType = boxedTypeArg->Instantiate(checker_->Allocator(), checker_->Relation(), - checker_->GetGlobalTypesHolder()); - } else { - ES2PANDA_UNREACHABLE(); - } - } - + ES2PANDA_ASSERT(!paramType->IsETSPrimitiveType()); typeArgTypes.push_back(paramType); } } while (typeArgTypes.size() < type->TypeArguments().size()) { Type *defaultType = nullptr; - if (type->TypeArguments().at(typeArgTypes.size())->IsETSTypeParameter()) { defaultType = type->TypeArguments().at(typeArgTypes.size())->AsETSTypeParameter()->GetDefaultType(); } else { @@ -123,6 +111,7 @@ static void CheckInstantiationConstraints(ETSChecker *checker, ArenaVectorRelation(); for (auto type : typeParams) { + type = type->MaybeBaseTypeOfGradualType(); if (!type->IsETSTypeParameter()) { continue; } @@ -136,10 +125,10 @@ static void CheckInstantiationConstraints(ETSChecker *checker, ArenaVectorIsETSReferenceType() || typeArg->IsETSVoidType()); + auto maybeIrrelevantTypeArg = typeArg->IsETSVoidType() ? checker->GlobalETSUndefinedType() : typeArg; auto constraint = typeParam->GetConstraintType()->Substitute(relation, substitution); - if (!relation->IsAssignableTo(typeArg, constraint)) { - // NOTE(vpukhov): refine message - checker->LogError(diagnostic::INIT_NOT_ASSIGNABLE, {typeArg, constraint}, pos); + if (!relation->IsSupertypeOf(constraint, maybeIrrelevantTypeArg)) { + checker->LogError(diagnostic::TYPEARG_TYPEPARAM_SUBTYPING, {typeArg, constraint}, pos); } } } @@ -149,7 +138,7 @@ void ConstraintCheckScope::TryCheckConstraints() if (Unlock()) { auto &records = checker_->PendingConstraintCheckRecords(); for (auto const &[typeParams, substitution, pos] : records) { - CheckInstantiationConstraints(checker_, *typeParams, substitution, pos); + CheckInstantiationConstraints(checker_, *typeParams, &substitution, pos); } records.clear(); } @@ -165,21 +154,21 @@ void InstantiationContext::InstantiateType(ETSObjectType *type, ArenaVectorNewSubstitution(); + auto substitution = Substitution {}; for (size_t idx = 0; idx < typeParams.size(); idx++) { if (!typeParams[idx]->IsETSTypeParameter()) { continue; } - checker_->EmplaceSubstituted(substitution, typeParams[idx]->AsETSTypeParameter(), typeArgTypes[idx]); + checker_->EmplaceSubstituted(&substitution, typeParams[idx]->AsETSTypeParameter(), typeArgTypes[idx]); } ConstraintCheckScope ctScope(checker_); + result_ = type->Substitute(checker_->Relation(), &substitution)->AsETSObjectType(); if (!checker_->Relation()->NoThrowGenericTypeAlias()) { - checker_->PendingConstraintCheckRecords().push_back({&typeParams, substitution, pos}); + checker_->PendingConstraintCheckRecords().emplace_back(&typeParams, std::move(substitution), pos); } - result_ = type->Substitute(checker_->Relation(), substitution)->AsETSObjectType(); - type->GetInstantiationMap().try_emplace(hash, result_->AsETSObjectType()); + type->InsertInstantiationMap(hash, result_->AsETSObjectType()); result_->AddTypeFlag(TypeFlag::GENERIC); ctScope.TryCheckConstraints(); diff --git a/ets2panda/checker/ets/typeRelationContext.h b/ets2panda/checker/ets/typeRelationContext.h index ef6c5017f9cb026520b83ba5f7166d0b5855baeb..7ba41f94c85585a2607a67f9da63bea20b07c3ff 100644 --- a/ets2panda/checker/ets/typeRelationContext.h +++ b/ets2panda/checker/ets/typeRelationContext.h @@ -34,6 +34,9 @@ public: auto *const etsChecker = relation->GetChecker()->AsETSChecker(); + ES2PANDA_ASSERT(target != nullptr); + ES2PANDA_ASSERT(node != nullptr); + ES2PANDA_ASSERT(source != nullptr); if (target->IsETSArrayType() && node->IsArrayExpression()) { assignable_ = ValidateArrayTypeInitializerByElement(relation, node->AsArrayExpression(), target->AsETSArrayType()); @@ -45,19 +48,11 @@ public: flags_ |= flags; relation->SetNode(node); - // NOTE (oeotvos) The narrowing flag will be applied here. It means, that the result of "let tmp: int = 1.5" - // will be 1, which could cause problems. - if (source->HasTypeFlag(TypeFlag::CONSTANT)) { - flags_ |= TypeRelationFlag::NARROWING; - } - relation->SetFlags(flags_); if (!relation->IsAssignableTo(source, target)) { if (relation->IsLegalBoxedPrimitiveConversion(target, source)) { - Type *sourceUnboxedType = etsChecker->MaybeUnboxType(source); - relation->GetNode()->AddBoxingUnboxingFlags(etsChecker->GetUnboxingFlag(sourceUnboxedType)); - relation->GetNode()->AddBoxingUnboxingFlags(etsChecker->GetBoxingFlag(target)); + relation->Result(true); } if (((flags_ & TypeRelationFlag::UNBOXING) != 0) && !relation->IsTrue() && source->IsETSObjectType() && !target->IsETSObjectType()) { @@ -107,6 +102,9 @@ public: relation->SetFlags(flags_ | initialFlags); if (!relation->IsAssignableTo(source, target)) { + if (relation->IsLegalBoxedPrimitiveConversion(target, source)) { + relation->Result(true); + } if (((flags_ & TypeRelationFlag::UNBOXING) != 0U) && !relation->IsTrue() && source->IsETSObjectType() && !target->IsETSObjectType()) { etsChecker->CheckUnboxedSourceTypeWithWideningAssignable(relation, source, target); diff --git a/ets2panda/checker/ets/utilityTypeHandlers.cpp b/ets2panda/checker/ets/utilityTypeHandlers.cpp index b2d95bd91d730743bac2ae4a6aa46895dfa27d90..3bc326155822b3d444b65c31076f1d1d42cf44ae 100644 --- a/ets2panda/checker/ets/utilityTypeHandlers.cpp +++ b/ets2panda/checker/ets/utilityTypeHandlers.cpp @@ -23,6 +23,8 @@ #include "varbinder/ETSBinder.h" #include "checker/types/ets/etsPartialTypeParameter.h" +#include + namespace ark::es2panda::checker { std::optional ETSChecker::GetUtilityTypeTypeParamNode( @@ -59,6 +61,10 @@ Type *ETSChecker::HandleUtilityTypeParameterNode(const ir::TSTypeParameterInstan return GlobalTypeError(); } + if (baseType->IsETSAnyType()) { + return baseType; + } + if (utilityType == compiler::Signatures::PARTIAL_TYPE_NAME) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) return CreatePartialType(baseType); @@ -98,7 +104,7 @@ static std::pair GetPartialClassPro ir::AstNode *typeNode) { auto classDefProgram = typeNode->GetTopStatement()->AsETSModule()->Program(); - if (classDefProgram == checker->VarBinder()->Program()) { + if (classDefProgram == checker->VarBinder()->AsETSBinder()->GetGlobalRecordTable()->Program()) { return {classDefProgram, checker->VarBinder()->AsETSBinder()->GetGlobalRecordTable()}; } return {classDefProgram, checker->VarBinder()->AsETSBinder()->GetExternalRecordTable().at(classDefProgram)}; @@ -114,6 +120,18 @@ static T *CloneNodeIfNotNullptr(T *node, ArenaAllocator *allocator) Type *ETSChecker::CreatePartialType(Type *const typeToBePartial) { ES2PANDA_ASSERT(typeToBePartial->IsETSReferenceType()); + if (typeToBePartial->IsTypeError()) { + return typeToBePartial; + } + + if (typeToBePartial->IsETSAnyType()) { + return typeToBePartial; + } + + if (typeToBePartial->IsGradualType()) { + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + return CreatePartialType(typeToBePartial->AsGradualType()->GetBaseType()); + } if (typeToBePartial->IsETSTypeParameter()) { return CreatePartialTypeParameter(typeToBePartial->AsETSTypeParameter()); @@ -141,7 +159,9 @@ Type *ETSChecker::CreatePartialTypeClass(ETSObjectType *typeToBePartial, ir::Ast // Check if we've already generated the partial class, then don't do it again const auto classNameToFind = - partialProgram == VarBinder()->Program() || VarBinder()->IsGenStdLib() ? partialName : partialQualifiedName; + partialProgram == VarBinder()->Program() || VarBinder()->IsGenStdLib() || partialProgram->IsGenAbcForExternal() + ? partialName + : partialQualifiedName; if (auto *var = SearchNamesInMultiplePrograms({partialProgram, VarBinder()->Program()}, {classNameToFind, partialName}); var != nullptr) { @@ -204,8 +224,11 @@ Type *ETSChecker::HandlePartialInterface(ir::TSInterfaceDeclaration *interfaceDe partialInterDecl->Variable()); } + auto savedScope = VarBinder()->TopScope(); + VarBinder()->ResetTopScope(partialProgram->GlobalScope()); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *partialType = CreatePartialTypeInterfaceDecl(interfaceDecl, typeToBePartial, partialInterDecl); + VarBinder()->ResetTopScope(savedScope); ES2PANDA_ASSERT(partialType != nullptr); NamedTypeStackElement ntse(this, partialType); @@ -215,18 +238,22 @@ Type *ETSChecker::HandlePartialInterface(ir::TSInterfaceDeclaration *interfaceDe ir::ClassProperty *ETSChecker::CreateNullishPropertyFromAccessor(ir::MethodDefinition *const accessor, ir::ClassDefinition *const newClassDefinition) { + auto *id = accessor->Id(); + ES2PANDA_ASSERT(id != nullptr); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - auto *ident = accessor->Id()->Clone(ProgramAllocator(), nullptr); + auto *ident = id->Clone(ProgramAllocator(), nullptr); + ES2PANDA_ASSERT(accessor->Function() != nullptr); auto modifierFlag = accessor->Function()->IsGetter() && accessor->Overloads().empty() ? ir::ModifierFlags::READONLY : ir::ModifierFlags::NONE; auto *prop = // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ProgramAllocator()->New(ident, nullptr, nullptr, modifierFlag, ProgramAllocator(), false); - + ES2PANDA_ASSERT(prop != nullptr); prop->SetParent(newClassDefinition); ident->SetParent(prop); + ES2PANDA_ASSERT(accessor->Function() != nullptr); prop->SetTypeAnnotation(accessor->Function()->IsGetter() ? accessor->Function()->ReturnTypeAnnotation() : accessor->Function()->Params()[0]->AsETSParameterExpression()->TypeAnnotation()); @@ -242,6 +269,7 @@ ir::ClassProperty *ETSChecker::CreateNullishPropertyFromAccessor(ir::MethodDefin auto callSign = accessor->TsType()->AsETSFunctionType()->CallSignatures()[0]; + ES2PANDA_ASSERT(accessor->Function() != nullptr); auto tsType = accessor->Function()->IsGetter() ? callSign->ReturnType() : callSign->Params()[0]->TsType(); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -350,8 +378,10 @@ ir::TSTypeParameterDeclaration *ETSChecker::ProcessTypeParamAndGenSubstitution( CloneNodeIfNotNullptr(classOrInterfaceDefTypeParam->Constraint(), ProgramAllocator()), // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) CloneNodeIfNotNullptr(classOrInterfaceDefTypeParam->DefaultType(), ProgramAllocator()), ProgramAllocator()); + ES2PANDA_ASSERT(newTypeParam != nullptr); newTypeParams->AddParam(newTypeParam); newTypeParam->SetParent(newTypeParams); + ES2PANDA_ASSERT(likeSubstitution != nullptr); (*likeSubstitution)[classOrInterfaceDefTypeParam] = newTypeParam; } return newTypeParams; @@ -377,16 +407,18 @@ ir::TSTypeParameterInstantiation *ETSChecker::CreateNewSuperPartialRefTypeParams !originRefParams[ix]->AsETSTypeReference()->Part()->TsType()->IsETSTypeParameter()) { continue; } - auto it = likeSubstitution->find( - originRefParams[ix]->AsETSTypeReference()->Part()->TsType()->AsETSTypeParameter()->GetDeclNode()); + auto type = originRefParams[ix]->AsETSTypeReference()->Part()->TsType(); + auto it = likeSubstitution->find(type->AsETSTypeParameter()->GetDeclNode()); if (it != likeSubstitution->end()) { auto *typeParamRefPart = // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ProgramAllocNode(it->second->Name()->Clone(ProgramAllocator(), nullptr), ProgramAllocator()); + ES2PANDA_ASSERT(typeParamRefPart != nullptr); typeParamRefPart->Name()->SetParent(typeParamRefPart); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *typeParamRef = ProgramAllocNode(typeParamRefPart, ProgramAllocator()); + ES2PANDA_ASSERT(typeParamRef != nullptr); typeParamRefPart->SetParent(typeParamRef); typeParamRef->SetParent(superPartialRefTypeParams); @@ -412,6 +444,7 @@ ir::ETSTypeReference *ETSChecker::BuildSuperPartialTypeReference( // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ProgramAllocNode(clonedId, superPartialRefTypeParams, nullptr, ProgramAllocator()); + ES2PANDA_ASSERT(superPartialRefPart != nullptr); superPartialRefPart->Name()->SetParent(superPartialRefPart); if (superPartialRefTypeParams != nullptr) { superPartialRefTypeParams->SetParent(superPartialRefPart); @@ -445,7 +478,7 @@ void ETSChecker::CreatePartialClassDeclaration(ir::ClassDefinition *const newCla // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ProgramAllocNode(std::move(typeParams), classDef->TypeParams()->RequiredParams()); - + ES2PANDA_ASSERT(newTypeParams != nullptr); newClassDefinition->SetTypeParams(newTypeParams); newTypeParams->SetParent(newClassDefinition); } @@ -457,7 +490,8 @@ void ETSChecker::CreatePartialClassDeclaration(ir::ClassDefinition *const newCla // Only handle class properties (members) // Method calls on partial classes will make the class not type safe, so we don't copy any methods if (prop->IsClassProperty()) { - if (prop->AsClassProperty()->Id()->Name().Mutf8().find(compiler::Signatures::PROPERTY, 0) == 0) { + if (prop->AsClassProperty()->Id() == nullptr || + prop->AsClassProperty()->Id()->Name().Mutf8().find(compiler::Signatures::PROPERTY, 0) == 0) { continue; } @@ -465,18 +499,19 @@ void ETSChecker::CreatePartialClassDeclaration(ir::ClassDefinition *const newCla auto *const newProp = CreateNullishProperty(prop->AsClassProperty(), newClassDefinition); // Put the new property into the class declaration - newClassDefinition->Body().emplace_back(newProp); + newClassDefinition->EmplaceBody(newProp); } - - if (prop->IsMethodDefinition() && (prop->AsMethodDefinition()->Function()->IsGetter() || - prop->AsMethodDefinition()->Function()->IsSetter())) { + if (prop->IsMethodDefinition() && prop->AsMethodDefinition()->Function() != nullptr && + (prop->AsMethodDefinition()->Function()->IsGetter() || + prop->AsMethodDefinition()->Function()->IsSetter())) { auto *method = prop->AsMethodDefinition(); + ES2PANDA_ASSERT(method->Id() != nullptr); if (newClassDefinition->Scope()->FindLocal(method->Id()->Name(), varbinder::ResolveBindingOptions::VARIABLES) != nullptr) { continue; } // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - newClassDefinition->Body().emplace_back(CreateNullishPropertyFromAccessor(method, newClassDefinition)); + newClassDefinition->EmplaceBody(CreateNullishPropertyFromAccessor(method, newClassDefinition)); } } if (classDef->IsDeclare()) { @@ -490,6 +525,35 @@ void ETSChecker::CreatePartialClassDeclaration(ir::ClassDefinition *const newCla newClassDefinition->Variable()->SetTsType(nullptr); } +static void SetupFunctionParams(ir::ScriptFunction *function, varbinder::FunctionParamScope *paramScope, + checker::ETSChecker *checker) +{ + for (auto *params : function->Params()) { + auto *paramExpr = params->AsETSParameterExpression(); + if (paramExpr->Ident()->TypeAnnotation() == nullptr) { + paramExpr->Ident()->SetTsTypeAnnotation(nullptr); + } else { + auto *unionType = + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + checker->ProgramAllocNode( + ArenaVector( + {paramExpr->Ident()->TypeAnnotation(), + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + checker->ProgramAllocNode(checker->ProgramAllocator())}, + checker->ProgramAllocator()->Adapter()), + checker->ProgramAllocator()); + paramExpr->Ident()->SetTsTypeAnnotation(unionType); + unionType->SetParent(paramExpr->Ident()); + } + auto [paramVar, node] = paramScope->AddParamDecl(checker->ProgramAllocator(), checker->VarBinder(), paramExpr); + if (node != nullptr) { + checker->VarBinder()->ThrowRedeclaration(node->Start(), paramVar->Name(), paramVar->Declaration()->Type()); + } + + paramExpr->SetVariable(paramVar); + } +} + // CC-OFFNXT(huge_method[C++], G.FUN.01-CPP) solid logic ir::MethodDefinition *ETSChecker::CreateNullishAccessor(ir::MethodDefinition *const accessor, ir::TSInterfaceDeclaration *interface) @@ -497,6 +561,7 @@ ir::MethodDefinition *ETSChecker::CreateNullishAccessor(ir::MethodDefinition *co const auto interfaceCtx = varbinder::LexicalScope::Enter(VarBinder(), interface->Scope()); auto *paramScope = ProgramAllocator()->New(ProgramAllocator(), interface->Scope()); auto *functionScope = ProgramAllocator()->New(ProgramAllocator(), paramScope); + ES2PANDA_ASSERT(functionScope != nullptr); functionScope->BindParamScope(paramScope); paramScope->BindFunctionScope(functionScope); @@ -536,27 +601,8 @@ ir::MethodDefinition *ETSChecker::CreateNullishAccessor(ir::MethodDefinition *co ProgramAllocator()->Adapter()), ProgramAllocator())); } else { - for (auto *params : function->Params()) { - auto *paramExpr = params->AsETSParameterExpression(); - - auto *unionType = - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode( - ArenaVector({paramExpr->Ident()->TypeAnnotation(), - // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - ProgramAllocNode(ProgramAllocator())}, - ProgramAllocator()->Adapter()), - ProgramAllocator()); - paramExpr->Ident()->SetTsTypeAnnotation(unionType); - unionType->SetParent(paramExpr->Ident()); - - auto [paramVar, node] = paramScope->AddParamDecl(ProgramAllocator(), VarBinder(), paramExpr); - if (node != nullptr) { - VarBinder()->ThrowRedeclaration(node->Start(), paramVar->Name(), paramVar->Declaration()->Type()); - } - - paramExpr->SetVariable(paramVar); - } + // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) + SetupFunctionParams(function, paramScope, this); } nullishAccessor->SetOverloads(ArenaVector(ProgramAllocator()->Adapter())); @@ -575,6 +621,7 @@ ir::TSInterfaceDeclaration *ETSChecker::CreateInterfaceProto(util::StringView na auto *const interfaceId = ProgramAllocNode(name, ProgramAllocator()); const auto [decl, var] = VarBinder()->NewVarDecl(interfaceId->Start(), ProgramAllocator(), interfaceId->Name()); + ES2PANDA_ASSERT(interfaceId != nullptr); interfaceId->SetVariable(var); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -592,6 +639,7 @@ ir::TSInterfaceDeclaration *ETSChecker::CreateInterfaceProto(util::StringView na Language(Language::Id::ETS)}); const auto classCtx = varbinder::LexicalScope(VarBinder()); + ES2PANDA_ASSERT(partialInterface != nullptr); partialInterface->TypeParams()->SetParent(partialInterface); partialInterface->SetScope(classCtx.GetScope()); partialInterface->SetVariable(var); @@ -599,10 +647,12 @@ ir::TSInterfaceDeclaration *ETSChecker::CreateInterfaceProto(util::StringView na // Put class declaration in global scope, and in program AST partialInterface->SetParent(interfaceDeclProgram->Ast()); - interfaceDeclProgram->Ast()->Statements().push_back(partialInterface); + interfaceDeclProgram->Ast()->AddStatement(partialInterface); interfaceDeclProgram->GlobalScope()->InsertBinding(name, var); partialInterface->AddModifier(flags); + partialInterface->ClearModifier(ir::ModifierFlags::EXPORTED); + partialInterface->ClearModifier(ir::ModifierFlags::DEFAULT_EXPORT); return partialInterface; } @@ -642,14 +692,17 @@ void ETSChecker::CreatePartialTypeInterfaceMethods(ir::TSInterfaceDeclaration *c } auto *const method = prop->AsMethodDefinition(); - ES2PANDA_ASSERT((method->Function()->Flags() & ir::ScriptFunctionFlags::OVERLOAD) == 0U); + auto *func = method->Function(); + ES2PANDA_ASSERT(func != nullptr); + ES2PANDA_ASSERT((func->Flags() & ir::ScriptFunctionFlags::OVERLOAD) == 0U); - if (method->Function()->IsGetter() || method->Function()->IsSetter()) { + if (func->IsGetter() || func->IsSetter()) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) addNullishAccessor(CreateNullishAccessor(method, partialInterface)); } for (auto *overload : method->Overloads()) { + ES2PANDA_ASSERT(overload->Function() != nullptr); if (overload->Function()->IsGetter() || overload->Function()->IsSetter()) { // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) addNullishAccessor(CreateNullishAccessor(overload, partialInterface)); @@ -680,7 +733,9 @@ Type *ETSChecker::CreatePartialTypeInterfaceDecl(ir::TSInterfaceDeclaration *con auto methodscope = partialInterface->Scope()->AsClassScope()->InstanceMethodScope(); // Add getter methods to instancemethodscope. for (auto *const prop : partialInterface->Body()->Body()) { - if (prop->IsMethodDefinition() && prop->AsMethodDefinition()->Function()->IsGetter()) { + auto *func = prop->AsMethodDefinition()->Function(); + ES2PANDA_ASSERT(func != nullptr); + if (prop->IsMethodDefinition() && func->IsGetter()) { auto *decl = ProgramAllocator()->New( ProgramAllocator(), prop->AsMethodDefinition()->Key()->AsIdentifier()->Name(), prop); methodscope->AddDecl(ProgramAllocator(), decl, ScriptExtension::ETS); @@ -701,7 +756,7 @@ Type *ETSChecker::CreatePartialTypeInterfaceDecl(ir::TSInterfaceDeclaration *con // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) BuildSuperPartialTypeReference(superPartialType, superPartialRefTypeParams); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) - partialInterface->Extends().push_back(ProgramAllocNode(superPartialRef)); + partialInterface->EmplaceExtends(ProgramAllocNode(superPartialRef)); partialInterface->Extends().back()->SetParent(partialInterface); } } @@ -739,7 +794,7 @@ void ETSChecker::CreateConstructorForPartialType(ir::ClassDefinition *const part ctor->Id()->SetVariable(ctorId->Variable()); // Put ctor in partial class body - partialClassDef->Body().emplace_back(ctor); + partialClassDef->EmplaceBody(ctor); } ir::ClassDefinition *ETSChecker::CreateClassPrototype(util::StringView name, parser::Program *const classDeclProgram) @@ -750,6 +805,7 @@ ir::ClassDefinition *ETSChecker::CreateClassPrototype(util::StringView name, par // Create class name, and declaration variable // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const classId = ProgramAllocNode(name, ProgramAllocator()); + ES2PANDA_ASSERT(classId != nullptr); const auto [decl, var] = VarBinder()->NewVarDecl(classId->Start(), classId->Name()); classId->SetVariable(var); @@ -759,12 +815,14 @@ ir::ClassDefinition *ETSChecker::CreateClassPrototype(util::StringView name, par // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) ProgramAllocNode(ProgramAllocator(), classId, ir::ClassDefinitionModifiers::DECLARATION, ir::ModifierFlags::NONE, Language(Language::Id::ETS)); + ES2PANDA_ASSERT(classDef != nullptr); classDef->SetScope(classCtx.GetScope()); classDef->SetVariable(var); // Create class declaration node // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const classDecl = ProgramAllocNode(classDef, ProgramAllocator()); + ES2PANDA_ASSERT(classDecl != nullptr); classDecl->SetParent(classDeclProgram->Ast()); // Class definition is scope bearer, not class declaration @@ -772,7 +830,7 @@ ir::ClassDefinition *ETSChecker::CreateClassPrototype(util::StringView name, par decl->BindNode(classDef); // Put class declaration in global scope, and in program AST - classDeclProgram->Ast()->Statements().push_back(classDecl); + classDeclProgram->Ast()->AddStatement(classDecl); classDeclProgram->GlobalScope()->InsertBinding(name, var); return classDef; @@ -845,6 +903,13 @@ Type *ETSChecker::CreatePartialTypeClassDef(ir::ClassDefinition *const partialCl ? GlobalETSObjectType() : classDef->Super()->TsType()); + if (partialSuper == partialType) { + LogError(diagnostic::CYCLIC_CLASS_SUPER_TYPE, {}, classDef->Start()); + return partialType; + } + if (partialSuper->IsTypeError()) { + return partialType; + } partialType->SetSuperType(partialSuper->AsETSObjectType()); } @@ -862,6 +927,7 @@ std::pair ETSChecker::CreateScriptFuncti // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) auto *const body = ProgramAllocNode(ProgramAllocator(), std::move(statements)); + ES2PANDA_ASSERT(body != nullptr); body->SetScope(scope); // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) id = ProgramAllocNode(util::UString(std::string("constructor"), ProgramAllocator()).View(), @@ -873,7 +939,7 @@ std::pair ETSChecker::CreateScriptFuncti ir::ScriptFunctionFlags::CONSTRUCTOR | ir::ScriptFunctionFlags::EXPRESSION, ir::ModifierFlags::PUBLIC}); - + ES2PANDA_ASSERT(func != nullptr); func->SetScope(scope); scope->BindNode(func); func->SetIdent(id); @@ -930,10 +996,11 @@ Type *ETSChecker::GetReadonlyType(Type *type) } NamedTypeStackElement ntse(this, type); - + ES2PANDA_ASSERT(type != nullptr); if (type->IsETSArrayType()) { ETSArrayType *const clonedArrayType = ProgramAllocator()->New(type->AsETSArrayType()->ElementType()); + ES2PANDA_ASSERT(clonedArrayType != nullptr); clonedArrayType->AddTypeFlag(TypeFlag::READONLY); return clonedArrayType; } @@ -964,7 +1031,7 @@ Type *ETSChecker::GetReadonlyType(Type *type) void ETSChecker::MakePropertiesReadonly(ETSObjectType *const classType) { - classType->UpdateTypeProperties(this, [this](auto *property, auto *propType) { + classType->UpdateTypeProperties([this](auto *property, auto *propType) { auto *newDecl = ProgramAllocator()->New(property->Name(), property->Declaration()->Node()); auto *const propCopy = property->Copy(ProgramAllocator(), newDecl); @@ -996,6 +1063,7 @@ Type *ETSChecker::HandleRequiredType(Type *typeToBeRequired) for (auto *type : typeToBeRequired->AsETSUnionType()->ConstituentTypes()) { if (type->IsETSObjectType()) { type = type->Clone(this); + ES2PANDA_ASSERT(type != nullptr); MakePropertiesNonNullish(type->AsETSObjectType()); } @@ -1015,7 +1083,7 @@ Type *ETSChecker::HandleRequiredType(Type *typeToBeRequired) typeToBeRequired = typeToBeRequired->Clone(this); - MakePropertiesNonNullish(typeToBeRequired->AsETSObjectType()); + MakePropertiesNonNullish(typeToBeRequired->MaybeBaseTypeOfGradualType()->AsETSObjectType()); return typeToBeRequired; } @@ -1047,7 +1115,7 @@ void ETSChecker::MakePropertyNonNullish(ETSObjectType *const classType, varbinde auto *const nonNullishPropType = GetNonNullishType(propType); auto *const propCopy = prop->Copy(ProgramAllocator(), prop->Declaration()); - + ES2PANDA_ASSERT(propCopy != nullptr); propCopy->SetTsType(nonNullishPropType); classType->RemoveProperty(prop); classType->AddProperty(propCopy); @@ -1077,7 +1145,12 @@ void ETSChecker::ValidateObjectLiteralForRequiredType(const ETSObjectType *const if (requiredType->HasObjectFlag(ETSObjectFlags::INTERFACE)) { for (const auto *method : requiredType->GetDeclNode()->AsTSInterfaceDeclaration()->Body()->Body()) { - if (!method->IsMethodDefinition() || !method->AsMethodDefinition()->Function()->IsGetter()) { + if (!method->IsMethodDefinition()) { + continue; + } + auto *func = method->AsMethodDefinition()->Function(); + ES2PANDA_ASSERT(func != nullptr); + if (!func->IsGetter()) { continue; } diff --git a/ets2panda/checker/ets/validateHelpers.cpp b/ets2panda/checker/ets/validateHelpers.cpp index f3ad9a385b9c4e0619ab024c454748e9602ecc35..c81ecc05fd1ebe428cb9a27cdc61c6b735662fe1 100644 --- a/ets2panda/checker/ets/validateHelpers.cpp +++ b/ets2panda/checker/ets/validateHelpers.cpp @@ -51,24 +51,57 @@ void ETSChecker::ValidatePropertyAccess(varbinder::Variable *var, ETSObjectType } } +bool ETSChecker::IsStaticInvoke(ir::MemberExpression *const expr) +{ + ir::Identifier *ident = nullptr; + if (expr->Object()->IsIdentifier()) { + ident = expr->Object()->AsIdentifier(); + } else if (expr->Object()->IsMemberExpression()) { + auto object = expr->Object(); + + while (object->IsMemberExpression()) { + object = object->AsMemberExpression()->Object(); + } + if (object->IsIdentifier()) { + ident = object->AsIdentifier(); + } + } + + return (ident != nullptr && + (ident->Variable()->Declaration()->IsClassDecl() || ident->Variable()->Declaration()->IsImportDecl())); +} + void ETSChecker::ValidateCallExpressionIdentifier(ir::Identifier *const ident, Type *const type) { - if (ident->Variable()->HasFlag(varbinder::VariableFlags::CLASS_OR_INTERFACE) && - ident->Parent()->AsCallExpression()->Callee() != ident) { + ir::CallExpression *callExpr = nullptr; + if (ident->Parent()->IsMemberExpression() && IsStaticInvoke(ident->Parent()->AsMemberExpression())) { + callExpr = ident->Parent()->Parent()->AsCallExpression(); + } else if (ident->Parent()->IsCallExpression()) { + callExpr = ident->Parent()->AsCallExpression(); + } else { + return; + } + + if (ident->Variable()->HasFlag(varbinder::VariableFlags::CLASS_OR_INTERFACE) && callExpr->Callee() != ident && + callExpr->Callee() != ident->Parent()) { std::ignore = TypeError(ident->Variable(), diagnostic::CLASS_OR_IFACE_AS_OBJ, {ident->ToString()}, ident->Start()); } - if (ident->Parent()->AsCallExpression()->Callee() != ident) { + if (callExpr->Callee() != ident && callExpr->Callee() != ident->Parent()) { return; } ES2PANDA_ASSERT(ident->Variable() != nullptr); + if (ident->Variable()->Declaration()->Node() != nullptr && + ident->Variable()->Declaration()->Node()->IsOverloadDeclaration()) { + return; + } if (ident->Variable()->Declaration()->Node() != nullptr && ident->Variable()->Declaration()->Node()->IsImportNamespaceSpecifier()) { std::ignore = TypeError(ident->Variable(), diagnostic::NAMESPACE_CALL, {ident->ToString()}, ident->Start()); } - if (type->IsETSFunctionType() || type->IsETSDynamicType()) { + if (type->IsETSFunctionType()) { return; } // SUPPRESS_CSA_NEXTLINE(alpha.core.AllocatorETSCheckerHint) @@ -129,7 +162,8 @@ bool ETSChecker::ValidateBinaryExpressionIdentifier(ir::Identifier *const ident, const auto *const binaryExpr = ident->Parent()->AsBinaryExpression(); bool isFinished = false; - if (binaryExpr->OperatorType() == lexer::TokenType::KEYW_INSTANCEOF && binaryExpr->Left() == ident) { + bool isInstanceOfKeyword = binaryExpr->OperatorType() == lexer::TokenType::KEYW_INSTANCEOF; + if (isInstanceOfKeyword && binaryExpr->Left() == ident) { if (!IsReferenceType(type)) { std::ignore = TypeError(ident->Variable(), diagnostic::INSTANCEOF_NONOBJECT, {ident->Name()}, ident->Start()); @@ -145,6 +179,10 @@ bool ETSChecker::ValidateBinaryExpressionIdentifier(ir::Identifier *const ident, } isFinished = true; } + if (isInstanceOfKeyword && ident->Variable()->HasFlag(varbinder::VariableFlags::CLASS_OR_INTERFACE | + varbinder::VariableFlags::TYPE_ALIAS)) { + LogError(diagnostic::WRONG_LEFT_OF_INSTANCEOF, {}, ident->Start()); + } return isFinished; } @@ -174,7 +212,10 @@ void ETSChecker::ValidateResolvedIdentifier(ir::Identifier *const ident) if (ValidateBinaryExpressionIdentifier(ident, resolvedType)) { return; } - [[fallthrough]]; + if (resolved != nullptr && !resolved->Declaration()->PossibleTDZ() && !resolvedType->IsETSFunctionType()) { + WrongContextErrorClassifyByType(ident); + } + break; case ir::AstNodeType::UPDATE_EXPRESSION: case ir::AstNodeType::UNARY_EXPRESSION: if (resolved != nullptr && !resolved->Declaration()->PossibleTDZ()) { @@ -191,21 +232,6 @@ void ETSChecker::ValidateResolvedIdentifier(ir::Identifier *const ident) } } -bool ETSChecker::ValidateAnnotationPropertyType(checker::Type *type) -{ - if (type == nullptr || type->IsTypeError()) { - ES2PANDA_ASSERT(IsAnyError()); - return false; - } - - if (type->IsETSArrayType() || type->IsETSResizableArrayType()) { - return ValidateAnnotationPropertyType(MaybeUnboxType(GetElementTypeOfArray(type))); - } - - return type->HasTypeFlag(TypeFlag::ETS_NUMERIC | TypeFlag::ETS_ENUM | TypeFlag::ETS_BOOLEAN) || - type->IsETSStringType(); -} - void ETSChecker::ValidateUnaryOperatorOperand(varbinder::Variable *variable) { if (IsVariableGetterSetter(variable)) { @@ -279,7 +305,7 @@ void ETSChecker::ValidateGenericTypeAliasForClonedNode(ir::TSTypeAliasDeclaratio ir::TypeNode *typeParamType = nullptr; - if (exactTypeParams->Params().size() > typeParamIdx) { + if (exactTypeParams != nullptr && exactTypeParams->Params().size() > typeParamIdx) { typeParamType = exactTypeParams->Params().at(typeParamIdx); } else { typeParamType = typeAliasNode->TypeParams()->Params().at(typeParamIdx)->DefaultType(); diff --git a/ets2panda/checker/ets/wideningConverter.h b/ets2panda/checker/ets/wideningConverter.h index 00f65deda0daa1f03557f22fa6fc7a7228c6ca0a..163f5545e05457cd3404244e9303f1613015cedc 100644 --- a/ets2panda/checker/ets/wideningConverter.h +++ b/ets2panda/checker/ets/wideningConverter.h @@ -30,11 +30,7 @@ public: return; } - if (!Source()->HasTypeFlag(TypeFlag::CONSTANT)) { - ApplyGlobalWidening(); - } else { - ApplyConstWidening(); - } + ApplyGlobalWidening(); } private: @@ -45,39 +41,6 @@ private: static constexpr TypeFlag WIDENABLE_TO_FLOAT = TypeFlag::LONG | WIDENABLE_TO_LONG; static constexpr TypeFlag WIDENABLE_TO_DOUBLE = TypeFlag::FLOAT | WIDENABLE_TO_FLOAT; - void ApplyConstWidening() - { - switch (ETSChecker::ETSChecker::ETSType(Target())) { - case TypeFlag::SHORT: { - ApplyWidening(WIDENABLE_TO_SHORT); - break; - } - case TypeFlag::CHAR: { - ApplyWidening(WIDENABLE_TO_CHAR); - break; - } - case TypeFlag::INT: { - ApplyWidening(WIDENABLE_TO_INT); - break; - } - case TypeFlag::LONG: { - ApplyWidening(WIDENABLE_TO_LONG); - break; - } - case TypeFlag::FLOAT: { - ApplyWidening(WIDENABLE_TO_FLOAT); - break; - } - case TypeFlag::DOUBLE: { - ApplyWidening(WIDENABLE_TO_DOUBLE); - break; - } - default: { - break; - } - } - } - void ApplyGlobalWidening() { switch (ETSChecker::ETSChecker::ETSType(Target())) { @@ -121,31 +84,31 @@ private: ES2PANDA_ASSERT(Relation()->GetNode()); switch (ETSChecker::ETSChecker::ETSType(Source())) { case TypeFlag::BYTE: { - Relation()->GetNode()->SetTsType(Checker()->GlobalByteType()); + Relation()->GetNode()->SetTsType(Checker()->GlobalByteBuiltinType()); break; } case TypeFlag::SHORT: { - Relation()->GetNode()->SetTsType(Checker()->GlobalShortType()); + Relation()->GetNode()->SetTsType(Checker()->GlobalShortBuiltinType()); break; } case TypeFlag::CHAR: { - Relation()->GetNode()->SetTsType(Checker()->GlobalCharType()); + Relation()->GetNode()->SetTsType(Checker()->GlobalCharBuiltinType()); break; } case TypeFlag::INT: { - Relation()->GetNode()->SetTsType(Checker()->GlobalIntType()); + Relation()->GetNode()->SetTsType(Checker()->GlobalIntBuiltinType()); break; } case TypeFlag::LONG: { - Relation()->GetNode()->SetTsType(Checker()->GlobalLongType()); + Relation()->GetNode()->SetTsType(Checker()->GlobalLongBuiltinType()); break; } case TypeFlag::FLOAT: { - Relation()->GetNode()->SetTsType(Checker()->GlobalFloatType()); + Relation()->GetNode()->SetTsType(Checker()->GlobalFloatBuiltinType()); break; } case TypeFlag::DOUBLE: { - Relation()->GetNode()->SetTsType(Checker()->GlobalDoubleType()); + Relation()->GetNode()->SetTsType(Checker()->GlobalDoubleBuiltinType()); break; } default: { @@ -156,62 +119,6 @@ private: Relation()->Result(true); } - - template - void ApplyWidening(TypeFlag flag) - { - if (!Source()->HasTypeFlag(flag)) { - return; - } - - switch (ETSChecker::ETSChecker::ETSType(Source())) { - case TypeFlag::BYTE: { - ApplyWidening(); - break; - } - case TypeFlag::CHAR: { - ApplyWidening(); - break; - } - case TypeFlag::SHORT: { - ApplyWidening(); - break; - } - case TypeFlag::INT: { - ApplyWidening(); - break; - } - case TypeFlag::LONG: { - ApplyWidening(); - break; - } - case TypeFlag::FLOAT: { - ApplyWidening(); - break; - } - case TypeFlag::DOUBLE: { - ApplyWidening(); - break; - } - default: { - return; - } - } - Relation()->Result(true); - } - - template - void ApplyWidening() - { - using SType = typename SourceType::UType; - using TType = typename TargetType::UType; - SType value = reinterpret_cast(Source())->GetValue(); - - if (!Relation()->OnlyCheckWidening()) { - ES2PANDA_ASSERT(Relation()->GetNode()); - Relation()->GetNode()->SetTsType(Checker()->ProgramAllocator()->New(static_cast(value))); - } - } }; } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/ts/destructuringContext.cpp b/ets2panda/checker/ts/destructuringContext.cpp index 95f65a54bb3774b404092e6be1cefd35534e21c7..7fcbc2e9d905ac4dee37558f8e74a2cdf537f4a7 100644 --- a/ets2panda/checker/ts/destructuringContext.cpp +++ b/ets2panda/checker/ts/destructuringContext.cpp @@ -154,9 +154,10 @@ void DestructuringContext::HandleAssignmentPattern(ir::AssignmentExpression *ass if (!checker_->HasStatus(CheckerStatus::IN_CONST_CONTEXT)) { defaultType = checker_->GetBaseTypeOfLiteralType(defaultType); } - + ES2PANDA_ASSERT(defaultType != nullptr); if (validateDefault && assignmentPattern->Right()->IsObjectExpression() && assignmentPattern->Left()->IsObjectPattern()) { + ES2PANDA_ASSERT(defaultType != nullptr); ValidateObjectLiteralType(defaultType->AsObjectType(), assignmentPattern->Left()->AsObjectPattern()); } @@ -201,6 +202,7 @@ void DestructuringContext::HandleAssignmentPattern(ir::AssignmentExpression *ass void ArrayDestructuringContext::ValidateInferredType() { + ES2PANDA_ASSERT(inferredType_ != nullptr); if (!inferredType_->IsArrayType() && !inferredType_->IsUnionType() && (!inferredType_->IsObjectType() || !inferredType_->AsObjectType()->IsTupleType())) { checker_->ThrowTypeError( @@ -328,8 +330,10 @@ Type *ArrayDestructuringContext::CreateTupleTypeForRest(TupleType *tuple) util::StringView memberIndex = util::Helpers::ToStringView(checker_->Allocator(), iterIndex); auto *memberVar = varbinder::Scope::CreateVar(checker_->Allocator(), memberIndex, varbinder::VariableFlags::PROPERTY, nullptr); + ES2PANDA_ASSERT(memberVar != nullptr); memberVar->SetTsType(tupleElementType); elementFlags.push_back(memberFlag); + ES2PANDA_ASSERT(desc != nullptr); desc->properties.push_back(memberVar); index_++; @@ -528,6 +532,7 @@ void ArrayDestructuringContext::Start() void ObjectDestructuringContext::ValidateInferredType() { + ES2PANDA_ASSERT(inferredType_ != nullptr); // NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) if (!inferredType_->IsObjectType()) { return; @@ -557,13 +562,16 @@ Type *ObjectDestructuringContext::CreateObjectTypeForRest(ObjectType *objType) if (!it->HasFlag(varbinder::VariableFlags::INFERRED_IN_PATTERN)) { auto *memberVar = varbinder::Scope::CreateVar(checker_->Allocator(), it->Name(), varbinder::VariableFlags::NONE, nullptr); + ES2PANDA_ASSERT(memberVar != nullptr); memberVar->SetTsType(it->TsType()); memberVar->AddFlag(it->Flags()); + ES2PANDA_ASSERT(desc != nullptr); desc->properties.push_back(memberVar); } } Type *returnType = checker_->Allocator()->New(desc); + ES2PANDA_ASSERT(returnType != nullptr); returnType->AsObjectType()->AddObjectFlag(ObjectFlags::RESOLVED_MEMBERS); return returnType; } diff --git a/ets2panda/checker/ts/function.cpp b/ets2panda/checker/ts/function.cpp index e4419c3f8c3e31d2890a36cf00d8249525e94ec9..7b0634260ae6807f7d3a0a5ed3871690ee83a8db 100644 --- a/ets2panda/checker/ts/function.cpp +++ b/ets2panda/checker/ts/function.cpp @@ -54,7 +54,7 @@ Type *TSChecker::HandleFunctionReturn(ir::ScriptFunction *func) if (func->IsArrow() && func->Body()->IsExpression()) { ElaborateElementwise(returnType, func->Body()->AsExpression(), func->Body()->Start()); } - + ES2PANDA_ASSERT(returnType != nullptr); if (returnType->IsNeverType()) { ThrowTypeError("A function returning 'never' cannot have a reachable end point.", func->ReturnTypeAnnotation()->Start()); @@ -149,13 +149,15 @@ Type *TSChecker::CreateParameterTypeForArrayAssignmentPattern(ir::ArrayExpressio return inferredType; } - TupleType *newTuple = - inferredTuple->Instantiate(Allocator(), Relation(), GetGlobalTypesHolder())->AsObjectType()->AsTupleType(); + auto initTuple = inferredTuple->Instantiate(Allocator(), Relation(), GetGlobalTypesHolder()); + ES2PANDA_ASSERT(initTuple != nullptr); + TupleType *newTuple = initTuple->AsObjectType()->AsTupleType(); for (uint32_t index = inferredTuple->FixedLength(); index < arrayPattern->Elements().size(); index++) { util::StringView memberIndex = util::Helpers::ToStringView(Allocator(), index); varbinder::LocalVariable *newMember = varbinder::Scope::CreateVar( Allocator(), memberIndex, varbinder::VariableFlags::PROPERTY | varbinder::VariableFlags::OPTIONAL, nullptr); + ES2PANDA_ASSERT(newMember != nullptr); newMember->SetTsType(GlobalAnyType()); newTuple->AddProperty(newMember); } @@ -193,6 +195,7 @@ Type *TSChecker::CreateParameterTypeForObjectAssignmentPattern(ir::ObjectExpress varbinder::LocalVariable *newProp = varbinder::Scope::CreateVar( Allocator(), prop->Key()->AsIdentifier()->Name(), varbinder::VariableFlags::PROPERTY | varbinder::VariableFlags::OPTIONAL, nullptr); + ES2PANDA_ASSERT(newProp != nullptr); newProp->SetTsType(GetBaseTypeOfLiteralType(CheckTypeCached(assignmentPattern->Right()))); newObject->AddProperty(newProp); } @@ -246,6 +249,7 @@ ReturnedVariable TSChecker::CheckFunctionAssignmentPatternParameter(ir::Assignme util::UString pn(ss.str(), Allocator()); varbinder::LocalVariable *patternVar = varbinder::Scope::CreateVar(Allocator(), pn.View(), varbinder::VariableFlags::NONE, param); + ES2PANDA_ASSERT(patternVar != nullptr); patternVar->SetTsType(paramType); patternVar->AddFlag(varbinder::VariableFlags::OPTIONAL); return {patternVar->AsLocalVariable(), nullptr, true}; @@ -264,6 +268,7 @@ std::tuple TSCheck if (typeAnnotation != nullptr) { typeAnnotation->Check(this); restType = typeAnnotation->GetType(this); + ES2PANDA_ASSERT(restType != nullptr); if (!restType->IsArrayType()) { ThrowTypeError("A rest parameter must be of an array type", param->Start()); } @@ -315,6 +320,7 @@ std::tuple TSCheck auto destructuringContext = ArrayDestructuringContext({this, param->AsArrayPattern(), false, false, param->TypeAnnotation(), nullptr}); destructuringContext.Start(); + ES2PANDA_ASSERT(patternVar != nullptr); patternVar->SetTsType(destructuringContext.InferredType()); return {patternVar->AsLocalVariable(), nullptr, false}; } @@ -337,6 +343,7 @@ std::tuple TSCheck auto destructuringContext = ObjectDestructuringContext( {this, param->AsObjectPattern(), false, false, param->TypeAnnotation(), nullptr}); destructuringContext.Start(); + ES2PANDA_ASSERT(patternVar != nullptr); patternVar->SetTsType(destructuringContext.InferredType()); return {patternVar->AsLocalVariable(), nullptr, false}; } @@ -386,6 +393,7 @@ std::tuple TSCheck if (cache) { Type *placeholder = Allocator()->New(GlobalAnyType()); + ES2PANDA_ASSERT(placeholder != nullptr); placeholder->SetVariable(std::get<0>(result)); param->SetTsType(placeholder); } @@ -396,6 +404,7 @@ std::tuple TSCheck void TSChecker::CheckFunctionParameterDeclarations(const ArenaVector ¶ms, SignatureInfo *signatureInfo) { + ES2PANDA_ASSERT(signatureInfo != nullptr); signatureInfo->restVar = nullptr; signatureInfo->minArgCount = 0; @@ -590,6 +599,7 @@ void TSChecker::InferFunctionDeclarationType(const varbinder::FunctionDecl *decl } Signature *overloadSignature = Allocator()->New(overloadSignatureInfo, returnType, func); + ES2PANDA_ASSERT(descWithOverload != nullptr); descWithOverload->callSignatures.push_back(overloadSignature); } @@ -601,14 +611,16 @@ void TSChecker::InferFunctionDeclarationType(const varbinder::FunctionDecl *decl if (descWithOverload->callSignatures.empty()) { Type *funcType = CreateFunctionTypeWithSignature(bodyCallSignature); + ES2PANDA_ASSERT(funcType != nullptr); funcType->SetVariable(funcVar); funcVar->SetTsType(funcType); } - + ES2PANDA_ASSERT(bodyCallSignature != nullptr); bodyCallSignature->SetReturnType(HandleFunctionReturn(bodyDeclaration)); if (!descWithOverload->callSignatures.empty()) { Type *funcType = Allocator()->New(descWithOverload); + ES2PANDA_ASSERT(funcType != nullptr); funcType->SetVariable(funcVar); funcVar->SetTsType(funcType); diff --git a/ets2panda/checker/ts/helpers.cpp b/ets2panda/checker/ts/helpers.cpp index 9c2455f558c2cf064c93663fee5cd0ffa05bf9b4..9b5abf6d2902b1da9ca71b0877115008f6afa0ac 100644 --- a/ets2panda/checker/ts/helpers.cpp +++ b/ets2panda/checker/ts/helpers.cpp @@ -59,7 +59,7 @@ Type *TSChecker::GetBaseTypeOfLiteralType(Type *type) if (HasStatus(CheckerStatus::KEEP_LITERAL_TYPE)) { return type; } - + ES2PANDA_ASSERT(type != nullptr); if (type->IsStringLiteralType()) { return GlobalStringType(); } @@ -382,6 +382,7 @@ void TSChecker::GetTypeParam(varbinder::Variable *var, varbinder::Decl *decl) { ir::AstNode *declaration = FindAncestorUntilGivenType(decl->Node(), ir::AstNodeType::SCRIPT_FUNCTION); + ES2PANDA_ASSERT(declaration != nullptr); if (declaration->IsIdentifier()) { auto *ident = declaration->AsIdentifier(); if (ident->TypeAnnotation() != nullptr) { @@ -499,6 +500,7 @@ Type *TSChecker::GetTypeFromClassOrInterfaceReference([[maybe_unused]] ir::TSTyp if (resolvedType == nullptr) { ObjectDescriptor *desc = Allocator()->New(Allocator()); resolvedType = Allocator()->New(Allocator(), var->Name(), desc); + ES2PANDA_ASSERT(resolvedType != nullptr); resolvedType->SetVariable(var); var->SetTsType(resolvedType); } diff --git a/ets2panda/checker/ts/object.cpp b/ets2panda/checker/ts/object.cpp index d0b36c61dc21745bb7fb0994b1f9c0f222731dd9..0c9e3c25c32a4186ee55c6746a6e212a05cedbc7 100644 --- a/ets2panda/checker/ts/object.cpp +++ b/ets2panda/checker/ts/object.cpp @@ -139,6 +139,7 @@ void TSChecker::ResolveUnionTypeMembers(UnionType *type) } } + ES2PANDA_ASSERT(desc != nullptr); desc->callSignatures = callSignatures; desc->constructSignatures = constructSignatures; @@ -151,6 +152,7 @@ void TSChecker::ResolveUnionTypeMembers(UnionType *type) } ObjectType *mergedType = Allocator()->New(desc); + ES2PANDA_ASSERT(mergedType != nullptr); mergedType->AddObjectFlag(ObjectFlags::RESOLVED_MEMBERS); type->SetMergedObjectType(mergedType); } @@ -333,6 +335,7 @@ varbinder::Variable *TSChecker::GetPropertyOfUnionType(UnionType *type, const ut } varbinder::Variable *syntheticProp = varbinder::Scope::CreateVar(Allocator(), name, flags, nullptr); + ES2PANDA_ASSERT(syntheticProp != nullptr); syntheticProp->SetTsType(CreateUnionType(std::move(collectedTypes))); type->CachedSyntheticProperties().insert({name, syntheticProp}); return syntheticProp; @@ -386,10 +389,12 @@ IndexInfo *TSChecker::GetApplicableIndexInfo(Type *type, Type *indexType) Type *TSChecker::GetPropertyTypeForIndexType(Type *type, Type *indexType) { + ES2PANDA_ASSERT(type != nullptr); if (type->IsArrayType()) { return type->AsArrayType()->ElementType(); } + ES2PANDA_ASSERT(indexType != nullptr); if (indexType->HasTypeFlag(TypeFlag::STRING_LITERAL | TypeFlag::NUMBER_LITERAL)) { varbinder::Variable *prop = nullptr; @@ -453,6 +458,7 @@ ArenaVector TSChecker::GetBaseTypes(InterfaceType *type) for (auto *extends : declaration->Extends()) { Type *baseType = extends->Expr()->GetType(this); + ES2PANDA_ASSERT(baseType != nullptr); if (!baseType->HasTypeFlag(TypeFlag::OBJECT | TypeFlag::NON_PRIMITIVE | TypeFlag::ANY)) { ThrowTypeError( "An interface can only extend an object type or intersection of object types with statically " diff --git a/ets2panda/checker/ts/typeCreation.cpp b/ets2panda/checker/ts/typeCreation.cpp index c40b8b1ed750ee4e21a47d61006ca2b9620b0bc2..08b9a7ae9bcba3a14be96f43d24ed6c717601b50 100644 --- a/ets2panda/checker/ts/typeCreation.cpp +++ b/ets2panda/checker/ts/typeCreation.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -125,6 +125,7 @@ Type *TSChecker::CreateUnionType(ArenaVector &&constituentTypes) Type *TSChecker::CreateObjectTypeWithCallSignature(Signature *callSignature) { auto *objType = Allocator()->New(Allocator()->New(Allocator())); + ES2PANDA_ASSERT(objType != nullptr); objType->AddCallSignature(callSignature); return objType; } @@ -132,6 +133,7 @@ Type *TSChecker::CreateObjectTypeWithCallSignature(Signature *callSignature) Type *TSChecker::CreateObjectTypeWithConstructSignature(Signature *constructSignature) { auto *objType = Allocator()->New(Allocator()->New(Allocator())); + ES2PANDA_ASSERT(objType != nullptr); objType->AddConstructSignature(constructSignature); return objType; } @@ -139,6 +141,7 @@ Type *TSChecker::CreateObjectTypeWithConstructSignature(Signature *constructSign Type *TSChecker::CreateFunctionTypeWithSignature(Signature *callSignature) { auto *funcObjType = Allocator()->New(Allocator()->New(Allocator())); + ES2PANDA_ASSERT(funcObjType != nullptr); funcObjType->AddCallSignature(callSignature); return funcObjType; } @@ -146,6 +149,7 @@ Type *TSChecker::CreateFunctionTypeWithSignature(Signature *callSignature) Type *TSChecker::CreateConstructorTypeWithSignature(Signature *constructSignature) { auto *constructObjType = Allocator()->New(Allocator()->New(Allocator())); + ES2PANDA_ASSERT(constructObjType != nullptr); constructObjType->AddConstructSignature(constructSignature); return constructObjType; } diff --git a/ets2panda/checker/types/ets/byteType.cpp b/ets2panda/checker/types/ets/byteType.cpp index 44537a4f5469bd9f109de7b02dc32816a05cf909..e69f7aff80e99cd986e89b4a4b5dc09b98f17023 100644 --- a/ets2panda/checker/types/ets/byteType.cpp +++ b/ets2panda/checker/types/ets/byteType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,8 +15,9 @@ #include "byteType.h" +#include "checker/ETSchecker.h" #include "checker/ets/conversion.h" -#include "checker/ets/narrowingConverter.h" +#include "checker/types/ets/etsObjectType.h" namespace ark::es2panda::checker { void ByteType::Identical(TypeRelation *relation, Type *other) @@ -26,13 +27,7 @@ void ByteType::Identical(TypeRelation *relation, Type *other) } } -void ByteType::AssignmentTarget(TypeRelation *relation, [[maybe_unused]] Type *source) -{ - if (relation->ApplyUnboxing()) { - relation->GetChecker()->AsETSChecker()->MaybeAddUnboxingFlagInRelation(relation, source, this); - } - NarrowingConverter(relation->GetChecker()->AsETSChecker(), relation, this, source); -} +void ByteType::AssignmentTarget([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *source) {} bool ByteType::AssignmentSource([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *target) { @@ -57,38 +52,9 @@ void ByteType::Cast(TypeRelation *const relation, Type *const target) return; } - if (target->HasTypeFlag(TypeFlag::SHORT | TypeFlag::INT | TypeFlag::LONG | TypeFlag::FLOAT | TypeFlag::DOUBLE)) { - conversion::WideningPrimitive(relation, this, target); - return; - } - - if (target->HasTypeFlag(TypeFlag::CHAR)) { - conversion::WideningNarrowingPrimitive(relation, this, target->AsCharType()); - return; - } - - if (target->HasTypeFlag(TypeFlag::ETS_OBJECT)) { - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_BYTE)) { - conversion::Boxing(relation, this); - return; - } - - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_TYPE)) { - auto unboxedTarget = relation->GetChecker()->AsETSChecker()->MaybeUnboxInRelation(target); - if (unboxedTarget == nullptr) { - conversion::Forbidden(relation); - return; - } - Cast(relation, unboxedTarget); - if (relation->IsTrue()) { - conversion::Boxing(relation, unboxedTarget); - return; - } - conversion::Forbidden(relation); - return; - } - - conversion::BoxingWideningReference(relation, this, target->AsETSObjectType()); + if (target->HasTypeFlag(TypeFlag::ETS_OBJECT) && + target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_BYTE)) { + conversion::Boxing(relation, this); return; } diff --git a/ets2panda/checker/types/ets/byteType.h b/ets2panda/checker/types/ets/byteType.h index a92f1f637d46d3611ba579ca23e7acc4cd63d9ca..a622ebc4e27e1b8bf50171ba47e1b301816d9c7e 100644 --- a/ets2panda/checker/types/ets/byteType.h +++ b/ets2panda/checker/types/ets/byteType.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -52,11 +52,6 @@ public: ss << compiler::Signatures::TYPE_DESCRIPTOR_BYTE; } - std::tuple ResolveConditionExpr() const override - { - return {IsConstantType(), value_ != 0}; - } - private: UType value_ {0}; }; diff --git a/ets2panda/checker/types/ets/charType.cpp b/ets2panda/checker/types/ets/charType.cpp index 62fad52d6eb2f8e635e2943810a817976103d996..43bbec66cd258fa3b35bd307b86ec6a804ea5725 100644 --- a/ets2panda/checker/types/ets/charType.cpp +++ b/ets2panda/checker/types/ets/charType.cpp @@ -16,7 +16,7 @@ #include "charType.h" #include "checker/ets/conversion.h" -#include "checker/ets/narrowingWideningConverter.h" +#include "checker/ets/wideningConverter.h" namespace ark::es2panda::checker { void CharType::Identical(TypeRelation *relation, Type *other) @@ -28,10 +28,7 @@ void CharType::Identical(TypeRelation *relation, Type *other) void CharType::AssignmentTarget(TypeRelation *relation, [[maybe_unused]] Type *source) { - if (relation->ApplyUnboxing()) { - relation->GetChecker()->AsETSChecker()->MaybeAddUnboxingFlagInRelation(relation, source, this); - } - NarrowingWideningConverter(relation->GetChecker()->AsETSChecker(), relation, this, source); + WideningConverter(relation->GetChecker()->AsETSChecker(), relation, this, source); } bool CharType::AssignmentSource([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *target) @@ -57,38 +54,9 @@ void CharType::Cast(TypeRelation *const relation, Type *const target) return; } - if (target->HasTypeFlag(TypeFlag::BYTE | TypeFlag::SHORT)) { - conversion::NarrowingPrimitive(relation, this, target); - return; - } - - if (target->HasTypeFlag(TypeFlag::INT | TypeFlag::LONG | TypeFlag::FLOAT | TypeFlag::DOUBLE)) { - conversion::WideningPrimitive(relation, this, target); - return; - } - - if (target->HasTypeFlag(TypeFlag::ETS_OBJECT)) { - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_CHAR)) { - conversion::Boxing(relation, this); - return; - } - - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_TYPE)) { - auto unboxedTarget = relation->GetChecker()->AsETSChecker()->MaybeUnboxInRelation(target); - if (unboxedTarget == nullptr) { - conversion::Forbidden(relation); - return; - } - Cast(relation, unboxedTarget); - if (relation->IsTrue()) { - conversion::Boxing(relation, unboxedTarget); - return; - } - conversion::Forbidden(relation); - return; - } - - conversion::BoxingWideningReference(relation, this, target->AsETSObjectType()); + if (target->HasTypeFlag(TypeFlag::ETS_OBJECT) && + target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_CHAR)) { + conversion::Boxing(relation, this); return; } diff --git a/ets2panda/checker/types/ets/charType.h b/ets2panda/checker/types/ets/charType.h index 9ddb9054ff1173910324d71e2ccdb1a65e3854e6..793a64ea4ed52a5ed44f86b1a6439623f9e55375 100644 --- a/ets2panda/checker/types/ets/charType.h +++ b/ets2panda/checker/types/ets/charType.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -52,11 +52,6 @@ public: ss << compiler::Signatures::TYPE_DESCRIPTOR_CHAR; } - std::tuple ResolveConditionExpr() const override - { - return {IsConstantType(), value_ != '\0'}; - } - private: UType value_ {'\0'}; }; diff --git a/ets2panda/checker/types/ets/doubleType.cpp b/ets2panda/checker/types/ets/doubleType.cpp index 91477c19e4e6d3e13e3bd32caa00fe15102b22c2..ad58d7bc8c9a5470fb94e12a8b57660b0dd10813 100644 --- a/ets2panda/checker/types/ets/doubleType.cpp +++ b/ets2panda/checker/types/ets/doubleType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -28,9 +28,6 @@ void DoubleType::Identical(TypeRelation *relation, Type *other) void DoubleType::AssignmentTarget(TypeRelation *relation, [[maybe_unused]] Type *source) { - if (relation->ApplyUnboxing() && !relation->IsTrue()) { - relation->GetChecker()->AsETSChecker()->MaybeAddUnboxingFlagInRelation(relation, source, this); - } WideningConverter(relation->GetChecker()->AsETSChecker(), relation, this, source); } @@ -56,34 +53,9 @@ void DoubleType::Cast(TypeRelation *const relation, Type *const target) return; } - if (target->HasTypeFlag(TypeFlag::BYTE | TypeFlag::SHORT | TypeFlag::CHAR | TypeFlag::INT | TypeFlag::LONG | - TypeFlag::FLOAT)) { - conversion::NarrowingPrimitive(relation, this, target); - return; - } - - if (target->HasTypeFlag(TypeFlag::ETS_OBJECT)) { - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_DOUBLE)) { - conversion::Boxing(relation, this); - return; - } - - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_TYPE)) { - auto unboxedTarget = relation->GetChecker()->AsETSChecker()->MaybeUnboxInRelation(target); - if (unboxedTarget == nullptr) { - conversion::Forbidden(relation); - return; - } - Cast(relation, unboxedTarget); - if (relation->IsTrue()) { - conversion::Boxing(relation, unboxedTarget); - return; - } - conversion::Forbidden(relation); - return; - } - - conversion::BoxingWideningReference(relation, this, target->AsETSObjectType()); + if (target->HasTypeFlag(TypeFlag::ETS_OBJECT) && + target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_DOUBLE)) { + conversion::Boxing(relation, this); return; } diff --git a/ets2panda/checker/types/ets/doubleType.h b/ets2panda/checker/types/ets/doubleType.h index e7e7dde792299f53ba775bea89d0a674dab337d2..fa3d5de326b61b66c9a6eaa2f745f8d82e7044a4 100644 --- a/ets2panda/checker/types/ets/doubleType.h +++ b/ets2panda/checker/types/ets/doubleType.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -52,12 +52,6 @@ public: ss << compiler::Signatures::TYPE_DESCRIPTOR_DOUBLE; } - std::tuple ResolveConditionExpr() const override - { - // isNan = !(value_ == value_) - return {IsConstantType(), (value_ != 0) && (value_ == value_)}; - } - private: UType value_ {0.0}; }; diff --git a/ets2panda/checker/types/ets/etsAnyType.cpp b/ets2panda/checker/types/ets/etsAnyType.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ea399276063cd735fb696ab45e416260bd38d9f9 --- /dev/null +++ b/ets2panda/checker/types/ets/etsAnyType.cpp @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "etsAnyType.h" +#include + +#include "checker/ETSchecker.h" +#include "checker/ets/conversion.h" +#include "etsTypeParameter.h" + +namespace ark::es2panda::checker { +void ETSAnyType::Identical(TypeRelation *relation, Type *other) +{ + relation->Result(other->IsETSAnyType()); +} + +void ETSAnyType::AssignmentTarget(TypeRelation *relation, Type *source) +{ + if (!source->IsETSPrimitiveType()) { + relation->Result(true); + return; + } + + if (relation->ApplyBoxing()) { + relation->Result(true); + } +} + +bool ETSAnyType::AssignmentSource(TypeRelation *relation, Type *target) +{ + Identical(relation, target); + return relation->IsTrue(); +} + +void ETSAnyType::Compare([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *other) +{ + ES2PANDA_UNREACHABLE(); +} + +void ETSAnyType::Cast(TypeRelation *relation, Type *target) +{ + if (!relation->InCastingContext()) { + Identical(relation, target); + return; + } + + if (!target->IsETSPrimitiveType()) { + relation->Result(true); + return; + } + + if (relation->ApplyUnboxing()) { + auto *const boxedTarget = relation->GetChecker()->AsETSChecker()->MaybeBoxInRelation(target); + ES2PANDA_ASSERT(boxedTarget != nullptr); + conversion::Unboxing(relation, boxedTarget->AsETSObjectType()); + relation->Result(true); + } +} + +void ETSAnyType::CastTarget(TypeRelation *relation, [[maybe_unused]] Type *source) +{ + AssignmentTarget(relation, source); +} + +void ETSAnyType::IsSubtypeOf(TypeRelation *relation, Type *target) +{ + Identical(relation, target); +} + +void ETSAnyType::IsSupertypeOf(TypeRelation *relation, Type *source) +{ + relation->Result(!source->IsETSPrimitiveType()); +} + +void ETSAnyType::ToString(std::stringstream &ss, [[maybe_unused]] bool precise) const +{ + ss << compiler::Signatures::ANY_TYPE_NAME; +} + +void ETSAnyType::ToAssemblerType(std::stringstream &ss) const +{ + ss << compiler::Signatures::BUILTIN_OBJECT; +} + +TypeFacts ETSAnyType::GetTypeFacts() const +{ + return TypeFacts::NONE; +} + +void ETSAnyType::ToDebugInfoType(std::stringstream &ss) const +{ + ss << ETSObjectType::NameToDescriptor(compiler::Signatures::BUILTIN_OBJECT); +} + +Type *ETSAnyType::Instantiate(ArenaAllocator *allocator, [[maybe_unused]] TypeRelation *relation, + [[maybe_unused]] GlobalTypesHolder *globalTypes) +{ + return isRelaxedAny_ ? allocator->New(true) : allocator->New(); +} +} // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/ets/etsDynamicType.h b/ets2panda/checker/types/ets/etsAnyType.h similarity index 38% rename from ets2panda/checker/types/ets/etsDynamicType.h rename to ets2panda/checker/types/ets/etsAnyType.h index eea79b4fb92a6ea1b1275bdfc17aa8c1a845ad9c..7d12b6a004e77c58e9e50f6f0b2b2a2691dd5668 100644 --- a/ets2panda/checker/types/ets/etsDynamicType.h +++ b/ets2panda/checker/types/ets/etsAnyType.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2025 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -12,60 +12,41 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef ES2PANDA_COMPILER_CHECKER_TYPES_ETS_ANY_TYPE_H +#define ES2PANDA_COMPILER_CHECKER_TYPES_ETS_ANY_TYPE_H -#ifndef ES2PANDA_COMPILER_CHECKER_TYPES_ETS_DYNAMIC_TYPE_H -#define ES2PANDA_COMPILER_CHECKER_TYPES_ETS_DYNAMIC_TYPE_H - -#include "checker/types/ets/etsObjectType.h" +#include "checker/types/type.h" +#include "ir/astNode.h" namespace ark::es2panda::checker { -class ETSDynamicType : public ETSObjectType { - static constexpr auto NAME = 0; - static constexpr auto ASSEMBLER_NAME = 1; - static constexpr auto LANGUAGE = 2; - static constexpr auto DECL_NODE = 0; - static constexpr auto FLAGS = 1; - static constexpr auto RELATION = 2; - +class ETSAnyType : public Type { public: - explicit ETSDynamicType(ArenaAllocator *allocator, std::tuple label, - std::tuple info, bool hasDecl) - : ETSObjectType(allocator, std::get(label), std::get(label), - std::make_tuple(std::get(info), std::get(info) | ETSObjectFlags::DYNAMIC, - std::get(info))), - propertiesCache_ {allocator->Adapter()}, - lang_(std::get(label)), - hasDecl_(hasDecl) - { - AddTypeFlag(TypeFlag::ETS_DYNAMIC_TYPE); - } + ETSAnyType() : Type(TypeFlag::ETS_ANY) {} + explicit ETSAnyType(bool isRelaxedAny) : Type(TypeFlag::ETS_ANY), isRelaxedAny_(isRelaxedAny) {} - varbinder::LocalVariable *GetPropertyDynamic(const util::StringView &name, const ETSChecker *checker) const; + void Identical(TypeRelation *relation, Type *other) override; void AssignmentTarget(TypeRelation *relation, Type *source) override; bool AssignmentSource(TypeRelation *relation, Type *target) override; + void Compare(TypeRelation *relation, Type *other) override; void Cast(TypeRelation *relation, Type *target) override; void CastTarget(TypeRelation *relation, Type *source) override; + void IsSubtypeOf(TypeRelation *relation, Type *target) override; + void IsSupertypeOf(TypeRelation *relation, Type *source) override; + void ToString(std::stringstream &ss, bool precise) const override; + void ToAssemblerType(std::stringstream &ss) const override; + void ToDebugInfoType([[maybe_unused]] std::stringstream &ss) const override; - es2panda::Language Language() const - { - return lang_; - } + TypeFacts GetTypeFacts() const override; + + Type *Instantiate(ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes) override; - bool HasDecl() const + bool IsRelaxedAny() const { - return hasDecl_; + return isRelaxedAny_; } - ETSFunctionType *CreateMethodTypeForProp(const util::StringView &name) const override; - - void ToAssemblerType(std::stringstream &ss) const override; - - static bool IsConvertible(Type const *target); - private: - mutable PropertyMap propertiesCache_; - es2panda::Language lang_; - bool hasDecl_; + bool isRelaxedAny_ = false; }; } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/ets/etsArrayType.cpp b/ets2panda/checker/types/ets/etsArrayType.cpp index 2f0573d664103a80b83e96d590b62ca7d01da44c..79d9cc398389767328cfa2ccc2d9a51868e91f81 100644 --- a/ets2panda/checker/types/ets/etsArrayType.cpp +++ b/ets2panda/checker/types/ets/etsArrayType.cpp @@ -111,7 +111,7 @@ void ETSArrayType::AssignmentTarget(TypeRelation *relation, Type *source) source->AsETSArrayType()->ElementType()->IsETSPrimitiveOrEnumType()) { return; } - relation->IsAssignableTo(source->AsETSArrayType()->ElementType(), element_); + relation->IsSupertypeOf(element_, source->AsETSArrayType()->ElementType()); } } diff --git a/ets2panda/checker/types/ets/etsArrayType.h b/ets2panda/checker/types/ets/etsArrayType.h index 9794adb54f0f11e1a5cc0dfb2a2ffc7b528fdde4..c9dd00904fffa7d09046075fde8e94a49ff87db8 100644 --- a/ets2panda/checker/types/ets/etsArrayType.h +++ b/ets2panda/checker/types/ets/etsArrayType.h @@ -38,11 +38,6 @@ public: element_ = element; } - std::tuple ResolveConditionExpr() const override - { - return {false, false}; - } - void ToString(std::stringstream &ss, bool precise) const override; void ToAssemblerType(std::stringstream &ss) const override; diff --git a/ets2panda/checker/types/ets/etsAsyncFuncReturnType.cpp b/ets2panda/checker/types/ets/etsAsyncFuncReturnType.cpp index 46308e495d546fec72639801ef3c8588619a8f9a..bc2a83fca736a1b978110d1655b64d2fa954bab3 100644 --- a/ets2panda/checker/types/ets/etsAsyncFuncReturnType.cpp +++ b/ets2panda/checker/types/ets/etsAsyncFuncReturnType.cpp @@ -39,6 +39,15 @@ void ETSAsyncFuncReturnType::Identical(TypeRelation *relation, Type *other) relation->Result(false); } +void ETSAsyncFuncReturnType::IsSupertypeOf(TypeRelation *relation, Type *source) +{ + GetPromiseTypeArg()->IsSupertypeOf(relation, source); + if (relation->IsTrue()) { + return; + } + promiseType_->IsSupertypeOf(relation, source); +} + bool ETSAsyncFuncReturnType::AssignmentSource([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *target) { return false; @@ -47,9 +56,6 @@ bool ETSAsyncFuncReturnType::AssignmentSource([[maybe_unused]] TypeRelation *rel void ETSAsyncFuncReturnType::AssignmentTarget(TypeRelation *relation, Type *source) { relation->IsAssignableTo(source, promiseType_) || relation->IsAssignableTo(source, GetPromiseTypeArg()); - if (relation->IsTrue() && !source->IsETSObjectType() && relation->ApplyBoxing()) { - relation->GetChecker()->AsETSChecker()->MaybeAddBoxingFlagInRelation(relation, source); - } } void ETSAsyncFuncReturnType::CheckVarianceRecursively(TypeRelation *relation, VarianceFlag varianceFlag) diff --git a/ets2panda/checker/types/ets/etsAsyncFuncReturnType.h b/ets2panda/checker/types/ets/etsAsyncFuncReturnType.h index e1ede4842b6fe35b3dc6ac4d712bf8e26ed064f2..d6b4d58b22b090e2bb0e2202a5d51510d5ead510 100644 --- a/ets2panda/checker/types/ets/etsAsyncFuncReturnType.h +++ b/ets2panda/checker/types/ets/etsAsyncFuncReturnType.h @@ -23,7 +23,7 @@ class GlobalTypesHolder; class ETSAsyncFuncReturnType : public ETSObjectType { public: - ETSAsyncFuncReturnType(ArenaAllocator *allocator, TypeRelation *relation, ETSObjectType *promiseType) + ETSAsyncFuncReturnType(ThreadSafeArenaAllocator *allocator, TypeRelation *relation, ETSObjectType *promiseType) : ETSObjectType(allocator, "", compiler::Signatures::BUILTIN_OBJECT, std::make_tuple(nullptr, ETSObjectFlags::ASYNC_FUNC_RETURN_TYPE, relation)), promiseType_(promiseType) @@ -33,6 +33,7 @@ public: void ToString(std::stringstream &ss, bool precise) const override; void Identical(TypeRelation *relation, Type *other) override; + void IsSupertypeOf(TypeRelation *relation, Type *source) override; void AssignmentTarget(TypeRelation *relation, Type *source) override; bool AssignmentSource(TypeRelation *relation, Type *target) override; void CheckVarianceRecursively(TypeRelation *relation, VarianceFlag varianceFlag) override; diff --git a/ets2panda/checker/types/ets/etsBigIntType.h b/ets2panda/checker/types/ets/etsBigIntType.h index 279c5d08170a65b67037458472b7d959bcc61005..8ed5f40ccb1f3ecdda34f88f5fdc60eee0483297 100644 --- a/ets2panda/checker/types/ets/etsBigIntType.h +++ b/ets2panda/checker/types/ets/etsBigIntType.h @@ -21,14 +21,14 @@ namespace ark::es2panda::checker { class ETSBigIntType : public ETSObjectType { public: - explicit ETSBigIntType(ArenaAllocator *allocator, [[maybe_unused]] ETSObjectType *super) + explicit ETSBigIntType(ThreadSafeArenaAllocator *allocator, [[maybe_unused]] ETSObjectType *super) : ETSObjectType(allocator, "", compiler::Signatures::BUILTIN_BIGINT, nullptr, ETSObjectFlags::CLASS | ETSObjectFlags::BUILTIN_BIGINT | ETSObjectFlags::RESOLVED_SUPER) { SetSuperType(super); } - explicit ETSBigIntType(ArenaAllocator *allocator, ETSObjectType *super, TypeRelation *relation, + explicit ETSBigIntType(ThreadSafeArenaAllocator *allocator, ETSObjectType *super, TypeRelation *relation, util::StringView value) : ETSObjectType( allocator, "", compiler::Signatures::BUILTIN_BIGINT, diff --git a/ets2panda/checker/types/ets/etsBooleanType.cpp b/ets2panda/checker/types/ets/etsBooleanType.cpp index e3d661ea8d4435fc18891f6373dceb2ebff8bdcd..f19823daa2f3ab0f1dc703ee184a7708609884c5 100644 --- a/ets2panda/checker/types/ets/etsBooleanType.cpp +++ b/ets2panda/checker/types/ets/etsBooleanType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -26,14 +26,9 @@ void ETSBooleanType::Identical(TypeRelation *relation, Type *other) } } -void ETSBooleanType::AssignmentTarget([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *source) -{ - if (relation->ApplyUnboxing() && !relation->IsTrue()) { - relation->GetChecker()->AsETSChecker()->MaybeAddUnboxingFlagInRelation(relation, source, this); - } -} +void ETSBooleanType::AssignmentTarget([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *source) {} -bool ETSBooleanType::AssignmentSource([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *target) +bool ETSBooleanType::AssignmentSource(TypeRelation *relation, Type *target) { if (relation->ApplyBoxing() && target->IsETSObjectType()) { relation->GetChecker()->AsETSChecker()->CheckBoxedSourceTypeAssignable(relation, this, target); diff --git a/ets2panda/checker/types/ets/etsBooleanType.h b/ets2panda/checker/types/ets/etsBooleanType.h index 421ae63e3b29b5ff3b070f1b25c482a73f8343ef..2bc7ccaddca17d8268de62ba33e7fbaa7a3aa371 100644 --- a/ets2panda/checker/types/ets/etsBooleanType.h +++ b/ets2panda/checker/types/ets/etsBooleanType.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -51,11 +51,6 @@ public: ss << compiler::Signatures::TYPE_DESCRIPTOR_BOOLEAN; } - std::tuple ResolveConditionExpr() const override - { - return {IsConstantType(), value_}; - } - private: UType value_ {false}; }; diff --git a/ets2panda/checker/types/ets/etsDynamicFunctionType.h b/ets2panda/checker/types/ets/etsDynamicFunctionType.h deleted file mode 100644 index 77a3c5731b2a49305766413eb1db370c0a9635e2..0000000000000000000000000000000000000000 --- a/ets2panda/checker/types/ets/etsDynamicFunctionType.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2024-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ES2PANDA_COMPILER_CHECKER_TYPES_ETS_DYNAMIC_FUNCTION_TYPE_H -#define ES2PANDA_COMPILER_CHECKER_TYPES_ETS_DYNAMIC_FUNCTION_TYPE_H - -#include "checker/types/ets/etsFunctionType.h" -#include "checker/ETSchecker.h" - -namespace ark::es2panda::checker { - -class ETSDynamicFunctionType : public ETSFunctionType { -public: - explicit ETSDynamicFunctionType(ETSChecker *checker, util::StringView name, ArenaVector &&signatures, - Language lang) - : ETSFunctionType(checker, name, std::move(signatures)), lang_(lang) - { - AddTypeFlag(TypeFlag::ETS_DYNAMIC_FUNCTION_TYPE); - } - - explicit ETSDynamicFunctionType(ETSChecker *checker, Signature *signature, Language lang) - : ETSFunctionType(checker, signature), lang_(lang) - { - AddTypeFlag(TypeFlag::ETS_DYNAMIC_FUNCTION_TYPE); - } - - ETSDynamicFunctionType() = delete; - ~ETSDynamicFunctionType() override = default; - NO_COPY_SEMANTIC(ETSDynamicFunctionType); - NO_MOVE_SEMANTIC(ETSDynamicFunctionType); - - es2panda::Language Language() const - { - return lang_; - } - -private: - es2panda::Language lang_; -}; -} // namespace ark::es2panda::checker - -#endif /* ES2PANDA_COMPILER_CHECKER_TYPES_ETS_DYNAMIC_FUNCTION_TYPE_H */ diff --git a/ets2panda/checker/types/ets/etsDynamicType.cpp b/ets2panda/checker/types/ets/etsDynamicType.cpp deleted file mode 100644 index 3fb4c1392d36f4ec568982963c0b2cc247d00960..0000000000000000000000000000000000000000 --- a/ets2panda/checker/types/ets/etsDynamicType.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2021-2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "etsDynamicType.h" -#include "checker/ETSchecker.h" -#include "checker/ets/conversion.h" -#include "checker/types/ets/etsDynamicFunctionType.h" - -namespace ark::es2panda::checker { - -varbinder::LocalVariable *ETSDynamicType::GetPropertyDynamic(const util::StringView &name, - const ETSChecker *checker) const -{ - auto it = propertiesCache_.find(name); - if (it != propertiesCache_.end()) { - return it->second; - } - - varbinder::LocalVariable *var = varbinder::Scope::CreateVar( - Allocator(), name, varbinder::VariableFlags::BUILTIN_TYPE, nullptr); - var->SetTsType(checker->GlobalBuiltinDynamicType(lang_)); - propertiesCache_.emplace(name, var); - - return var; -} - -void ETSDynamicType::AssignmentTarget(TypeRelation *relation, Type *source) -{ - if (hasDecl_) { - return ETSObjectType::AssignmentTarget(relation, source); - } - - if (relation->ApplyBoxing() && !relation->IsTrue() && IsConvertible(source)) { - relation->Result(true); - return; - } - - if (source->IsETSDynamicType()) { - relation->Result(true); - } -} - -bool ETSDynamicType::AssignmentSource(TypeRelation *relation, Type *target) -{ - if (hasDecl_) { - return ETSObjectType::AssignmentSource(relation, target); - } - - if (relation->ApplyUnboxing() && IsConvertible(target)) { - relation->Result(true); - return true; - } - - if (target->IsETSDynamicType()) { - relation->Result(true); - } - return relation->IsTrue(); -} - -void ETSDynamicType::Cast(TypeRelation *relation, Type *target) -{ - if (hasDecl_) { - return ETSObjectType::Cast(relation, target); - } - - if (relation->InCastingContext() || IsConvertible(target)) { - relation->Result(true); - return; - } - - conversion::Forbidden(relation); -} - -void ETSDynamicType::CastTarget(TypeRelation *relation, Type *source) -{ - if (hasDecl_) { - ETSObjectType::CastTarget(relation, source); - return; - } - - if (relation->InCastingContext() || IsConvertible(source)) { - relation->Result(true); - return; - } - - conversion::Forbidden(relation); -} - -bool ETSDynamicType::IsConvertible(Type const *target) -{ - return target->IsETSDynamicType() || target->IsETSObjectType() || target->IsETSArrayType() || - target->IsETSTupleType() || target->IsETSFunctionType() || - target->HasTypeFlag(checker::TypeFlag::ETS_CONVERTIBLE_TO_NUMERIC | checker::TypeFlag::ETS_BOOLEAN); -} - -ETSFunctionType *ETSDynamicType::CreateMethodTypeForProp(const util::StringView &name) const -{ - auto checker = GetRelation()->GetChecker()->AsETSChecker(); - return checker->CreateETSDynamicMethodType(name, {{}, Allocator()->Adapter()}, lang_); -} - -void ETSDynamicType::ToAssemblerType(std::stringstream &ss) const -{ - ss << compiler::Signatures::Dynamic::Type(lang_); -} - -} // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/ets/etsEnumType.cpp b/ets2panda/checker/types/ets/etsEnumType.cpp index 61d23b7cbf94ef87d12a88cce69cb24207f4cb97..233a403e0501e8a662fba2b7bd2ad9c056b0df62 100644 --- a/ets2panda/checker/types/ets/etsEnumType.cpp +++ b/ets2panda/checker/types/ets/etsEnumType.cpp @@ -15,11 +15,17 @@ #include "etsEnumType.h" +#include "checker/ETSchecker.h" #include "checker/ets/conversion.h" #include "checker/types/ets/etsUnionType.h" namespace ark::es2panda::checker { +Type *ETSEnumType::GetBaseEnumElementType(ETSChecker *checker) +{ + return checker->MaybeUnboxType(SuperType()->TypeArguments()[0]); +} + bool ETSStringEnumType::AssignmentSource(TypeRelation *relation, Type *target) { bool result = false; @@ -55,6 +61,7 @@ void ETSStringEnumType::Cast(TypeRelation *const relation, Type *const target) return; } if (target->IsETSStringType()) { + relation->RaiseError(diagnostic::ENUM_DEPRECATED_CAST, {this, target}, relation->GetNode()->Start()); relation->Result(true); return; } @@ -64,6 +71,7 @@ void ETSStringEnumType::Cast(TypeRelation *const relation, Type *const target) void ETSStringEnumType::CastTarget(TypeRelation *relation, Type *source) { if (source->IsETSStringType()) { + relation->RaiseError(diagnostic::ENUM_DEPRECATED_CAST, {source, this}, relation->GetNode()->Start()); relation->Result(true); return; } @@ -77,7 +85,7 @@ bool ETSIntEnumType::AssignmentSource(TypeRelation *relation, Type *target) if (target->AsETSObjectType()->IsGlobalETSObjectType() || target->AsETSObjectType()->Name() == compiler::Signatures::NUMERIC) { result = true; - } else if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_NUMERIC)) { + } else if (target->IsBuiltinNumeric()) { result = true; relation->GetNode()->AddAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF); } @@ -108,8 +116,8 @@ void ETSIntEnumType::Cast(TypeRelation *const relation, Type *const target) relation->Result(true); return; } - if (target->HasTypeFlag(TypeFlag::ETS_NUMERIC) || - (target->IsETSObjectType() && target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_NUMERIC))) { + if (target->HasTypeFlag(TypeFlag::ETS_NUMERIC) || target->IsBuiltinNumeric()) { + relation->RaiseError(diagnostic::ENUM_DEPRECATED_CAST, {this, target}, relation->GetNode()->Start()); relation->Result(true); return; } @@ -118,15 +126,12 @@ void ETSIntEnumType::Cast(TypeRelation *const relation, Type *const target) void ETSIntEnumType::CastTarget(TypeRelation *relation, Type *source) { - if (source->IsIntType()) { - relation->Result(true); - return; - } - if (source->IsETSObjectType() && source->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_NUMERIC)) { + if (source->IsIntType() || source->IsBuiltinNumeric()) { + relation->RaiseError(diagnostic::ENUM_DEPRECATED_CAST, {source, this}, relation->GetNode()->Start()); relation->Result(true); return; } conversion::Forbidden(relation); } -} // namespace ark::es2panda::checker \ No newline at end of file +} // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/ets/etsEnumType.h b/ets2panda/checker/types/ets/etsEnumType.h index a5c6bdf33d7a3e767413365b6105f75f9114285b..3005b78053a406f8ef707e2410d7d7cc090593a4 100644 --- a/ets2panda/checker/types/ets/etsEnumType.h +++ b/ets2panda/checker/types/ets/etsEnumType.h @@ -19,16 +19,24 @@ #include "checker/types/ets/etsObjectType.h" #include "checker/types/ets/etsObjectTypeConstants.h" #include "checker/types/typeFlag.h" +#include "ir/base/classProperty.h" +#include "ir/expressions/arrayExpression.h" +#include "ir/expressions/literals/stringLiteral.h" +#include "ir/expressions/memberExpression.h" namespace ark::es2panda::checker { class ETSEnumType : public ETSObjectType { public: - explicit ETSEnumType(ArenaAllocator *allocator, util::StringView name, util::StringView internalName, - ir::AstNode *declNode, TypeRelation *relation) + // CC-OFFNXT(G.FUN.01-CPP) solid logic + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) + explicit ETSEnumType(ThreadSafeArenaAllocator *allocator, util::StringView name, util::StringView internalName, + ir::AstNode *declNode, TypeRelation *relation, ETSObjectFlags const flag) : ETSObjectType(allocator, name, internalName, - std::make_tuple(declNode, ETSObjectFlags::CLASS | ETSObjectFlags::ENUM_OBJECT, relation)) + std::make_tuple(declNode, ETSObjectFlags::CLASS | flag, relation)), + memberNameToOrdinal_(allocator->Adapter()) { + InitElementsShortcuts(declNode->AsClassDefinition()); } NO_COPY_SEMANTIC(ETSEnumType); @@ -37,21 +45,86 @@ public: ETSEnumType() = delete; ~ETSEnumType() override = default; - static constexpr std::string_view const TO_STRING_METHOD_NAME {"toString"}; - static constexpr std::string_view const VALUE_OF_METHOD_NAME {"valueOf"}; - static constexpr std::string_view const GET_NAME_METHOD_NAME {"getName"}; - static constexpr std::string_view const GET_VALUE_OF_METHOD_NAME {"getValueOf"}; - static constexpr std::string_view const FROM_VALUE_METHOD_NAME {"fromValue"}; - static constexpr std::string_view const VALUES_METHOD_NAME {"values"}; - static constexpr std::string_view const GET_ORDINAL_METHOD_NAME {"getOrdinal"}; - static constexpr std::string_view const DOLLAR_GET_METHOD_NAME {"$_get"}; + static constexpr std::string_view TO_STRING_METHOD_NAME {"toString"}; + static constexpr std::string_view VALUE_OF_METHOD_NAME {"valueOf"}; + static constexpr std::string_view GET_NAME_METHOD_NAME {"getName"}; + static constexpr std::string_view GET_VALUE_OF_METHOD_NAME {"getValueOf"}; + static constexpr std::string_view FROM_VALUE_METHOD_NAME {"fromValue"}; + static constexpr std::string_view VALUES_METHOD_NAME {"values"}; + static constexpr std::string_view GET_ORDINAL_METHOD_NAME {"getOrdinal"}; + static constexpr std::string_view DOLLAR_GET_METHOD_NAME {"$_get"}; + + static constexpr std::string_view STRING_VALUES_ARRAY_NAME {"#StringValuesArray"}; + static constexpr std::string_view VALUES_ARRAY_NAME {"#ValuesArray"}; + static constexpr std::string_view NAMES_ARRAY_NAME {"#NamesArray"}; + + auto *Underlying() + { + ES2PANDA_ASSERT(membersValues_->TsType() != nullptr); + return membersValues_->TsType()->AsETSArrayType()->ElementType(); + } + + auto GetOrdinalFromMemberName(std::string_view name) const + { + return memberNameToOrdinal_.at(name); + } + + auto GetValueLiteralFromOrdinal(size_t ord) const + { + ES2PANDA_ASSERT(ord < membersValues_->Elements().size()); + return membersValues_->Elements()[ord]; + } + + bool NodeIsEnumLiteral(ir::Expression *node) const + { + ES2PANDA_ASSERT(node->TsType() == this); + if (!node->IsMemberExpression()) { + return false; + } + + auto mobj = node->AsMemberExpression()->Object(); + if (mobj->TsType() == this) { + // No need to search properties since enum-literals are the only enum-type properties + // NOTE(dkofanov): For some reason, 'enumLowering' changes 'CLASS' to 'ENUM_LITERAL', instead of 'ENUM'. + ES2PANDA_ASSERT(GetDeclNode()->AsClassDefinition()->IsEnumTransformed()); + return true; + } + return false; + } + Type *GetBaseEnumElementType(ETSChecker *checker); + +private: + void InitElementsShortcuts(ir::ClassDefinition *declNode) + { + Span membersNames {}; + for (auto elem : declNode->Body()) { + auto elemName = elem->AsClassElement()->Key()->AsIdentifier()->Name(); + if (elemName == NAMES_ARRAY_NAME) { + membersNames = Span(elem->AsClassProperty()->Value()->AsArrayExpression()->Elements()); + } else if (elemName == VALUES_ARRAY_NAME) { + membersValues_ = elem->AsClassProperty()->Value()->AsArrayExpression(); // int-enum + } else if ((elemName == STRING_VALUES_ARRAY_NAME) && (membersValues_ == nullptr)) { + membersValues_ = elem->AsClassProperty()->Value()->AsArrayExpression(); // string-enum + } + } + auto membersValues = Span {membersValues_->Elements()}; + ES2PANDA_ASSERT(membersValues.size() == membersNames.size()); + for (size_t i = 0; i < membersNames.size(); i++) { + memberNameToOrdinal_.insert({membersNames[i]->AsStringLiteral()->Str(), i}); + ES2PANDA_ASSERT(membersValues[i]->IsStringLiteral() || membersValues[i]->IsNumberLiteral()); + } + } + +private: + ArenaMap memberNameToOrdinal_; + ir::ArrayExpression *membersValues_; }; class ETSIntEnumType : public ETSEnumType { public: - explicit ETSIntEnumType(ArenaAllocator *allocator, util::StringView name, util::StringView internalName, + explicit ETSIntEnumType(ThreadSafeArenaAllocator *allocator, util::StringView name, util::StringView internalName, ir::AstNode *declNode, TypeRelation *relation) - : ETSEnumType(allocator, name, internalName, declNode, relation) + : ETSEnumType(allocator, name, internalName, declNode, relation, ETSObjectFlags::INT_ENUM_OBJECT) { AddTypeFlag(checker::TypeFlag::ETS_INT_ENUM); } @@ -70,9 +143,9 @@ public: class ETSStringEnumType : public ETSEnumType { public: - explicit ETSStringEnumType(ArenaAllocator *allocator, util::StringView name, util::StringView internalName, - ir::AstNode *declNode, TypeRelation *relation) - : ETSEnumType(allocator, name, internalName, declNode, relation) + explicit ETSStringEnumType(ThreadSafeArenaAllocator *allocator, util::StringView name, + util::StringView internalName, ir::AstNode *declNode, TypeRelation *relation) + : ETSEnumType(allocator, name, internalName, declNode, relation, ETSObjectFlags::STRING_ENUM_OBJECT) { AddTypeFlag(checker::TypeFlag::ETS_STRING_ENUM); } @@ -91,4 +164,4 @@ public: } // namespace ark::es2panda::checker -#endif \ No newline at end of file +#endif diff --git a/ets2panda/checker/types/ets/etsFunctionType.cpp b/ets2panda/checker/types/ets/etsFunctionType.cpp index 1df9fd28eac9bc6271cff13c4bf63277ce2ae0d8..b3d97f28b776d6388b8bb59496739312d18ee137 100644 --- a/ets2panda/checker/types/ets/etsFunctionType.cpp +++ b/ets2panda/checker/types/ets/etsFunctionType.cpp @@ -15,6 +15,7 @@ #include "checker/ETSchecker.h" #include "checker/types/globalTypesHolder.h" +#include "compiler/lowering/phase.h" namespace ark::es2panda::checker { @@ -45,21 +46,24 @@ ETSFunctionType::ETSFunctionType(ETSChecker *checker, Signature *signature) extensionFunctionSigs_(ArenaVector(checker->ProgramAllocator()->Adapter())), extensionAccessorSigs_(ArenaVector(checker->ProgramAllocator()->Adapter())), name_(""), - assemblerName_(checker->GlobalBuiltinFunctionType(signature->MinArgCount(), signature->HasRestParameter()) - ->AsETSObjectType() - ->AssemblerName()) + assemblerName_(checker->GlobalBuiltinFunctionType(signature->MinArgCount(), signature->HasRestParameter()) != + nullptr + ? checker->GlobalBuiltinFunctionType(signature->MinArgCount(), signature->HasRestParameter()) + ->AsETSObjectType() + ->AssemblerName() + : "") { } // #22951: proper this type implementation -static void HackThisParameterInExtensionFunctionInvoke(ETSObjectType *interface, size_t arity) +static void HackThisParameterInExtensionFunctionInvoke(ETSObjectType *interface, std::string &invokeName) { - auto invokeName = FunctionalInterfaceInvokeName(arity, false); - auto &callSigsOfInvoke0 = interface->AsETSObjectType() - ->GetOwnProperty(util::StringView(invokeName)) - ->TsType() - ->AsETSFunctionType() - ->CallSignatures(); + auto *property = interface->AsETSObjectType()->GetOwnProperty( + util::StringView(invokeName)); + ES2PANDA_ASSERT(property != nullptr); + auto *tsType = property->TsType(); + ES2PANDA_ASSERT(tsType != nullptr); + auto &callSigsOfInvoke0 = tsType->AsETSFunctionType()->CallSignatures(); for (auto sig : callSigsOfInvoke0) { sig->AddSignatureFlag(SignatureFlags::THIS_RETURN_TYPE); } @@ -71,44 +75,69 @@ static ETSObjectType *FunctionTypeToFunctionalInterfaceType(ETSChecker *checker, bool isExtensionHack = signature->HasSignatureFlag(SignatureFlags::EXTENSION_FUNCTION); if (signature->RestVar() != nullptr) { - auto *functionN = checker->GlobalBuiltinFunctionType(arity, true)->AsETSObjectType(); - auto *substitution = checker->NewSubstitution(); - auto *elementType = checker->GetElementTypeOfArray(signature->RestVar()->TsType()); - substitution->emplace(functionN->TypeArguments()[0]->AsETSTypeParameter(), checker->MaybeBoxType(elementType)); - return functionN->Substitute(checker->Relation(), substitution, true, isExtensionHack); + auto sigParamsSize = signature->Params().size(); + auto nPosParams = arity < sigParamsSize ? arity : sigParamsSize; + auto *functionN = checker->GlobalBuiltinFunctionType(nPosParams, true); + + if (nPosParams >= checker->GetGlobalTypesHolder()->VariadicFunctionTypeThreshold()) { + return functionN; + } + + auto substitution = Substitution {}; + ES2PANDA_ASSERT(functionN != nullptr); + for (size_t i = 0; i < nPosParams; i++) { + substitution.emplace(functionN->TypeArguments()[i]->AsETSTypeParameter(), + checker->MaybeBoxType(signature->Params()[i]->TsType())); + } + auto *elementType = !signature->RestVar()->TsType()->IsETSTupleType() + ? checker->GetElementTypeOfArray(signature->RestVar()->TsType()) + : checker->GlobalETSAnyType(); + substitution.emplace(functionN->TypeArguments()[nPosParams]->AsETSTypeParameter(), + checker->MaybeBoxType(elementType)); + substitution.emplace(functionN->TypeArguments()[nPosParams + 1]->AsETSTypeParameter(), + checker->MaybeBoxType(signature->ReturnType())); + auto result = functionN->Substitute(checker->Relation(), &substitution, true, isExtensionHack); + result->AddObjectFlag(checker::ETSObjectFlags::FUNCTIONAL); + return result; } ES2PANDA_ASSERT(arity >= signature->MinArgCount() && arity <= signature->ArgCount()); - // Note: FunctionN is not supported yet + auto *funcIface = checker->GlobalBuiltinFunctionType(arity, false); if (arity >= checker->GetGlobalTypesHolder()->VariadicFunctionTypeThreshold()) { - return nullptr; + return funcIface; } - auto *funcIface = checker->GlobalBuiltinFunctionType(arity, false)->AsETSObjectType(); - auto *substitution = checker->NewSubstitution(); - + auto substitution = Substitution {}; for (size_t i = 0; i < arity; i++) { - substitution->emplace(funcIface->TypeArguments()[i]->AsETSTypeParameter(), - checker->MaybeBoxType(signature->Params()[i]->TsType())); + substitution.emplace(funcIface->TypeArguments()[i]->AsETSTypeParameter(), + checker->MaybeBoxType(signature->Params()[i]->TsType())); } - substitution->emplace(funcIface->TypeArguments()[arity]->AsETSTypeParameter(), - checker->MaybeBoxType(signature->ReturnType())); - auto result = funcIface->Substitute(checker->Relation(), substitution, true, isExtensionHack); + substitution.emplace(funcIface->TypeArguments()[arity]->AsETSTypeParameter(), + checker->MaybeBoxType(signature->ReturnType())); + auto result = funcIface->Substitute(checker->Relation(), &substitution, true, isExtensionHack); if (signature->HasSignatureFlag(SignatureFlags::THIS_RETURN_TYPE)) { - HackThisParameterInExtensionFunctionInvoke(result, arity); + auto invokeName = checker->FunctionalInterfaceInvokeName(arity, false); + HackThisParameterInExtensionFunctionInvoke(result, invokeName); } + + result->AddObjectFlag(checker::ETSObjectFlags::FUNCTIONAL); return result; } ETSObjectType *ETSFunctionType::ArrowToFunctionalInterface(ETSChecker *checker) { - auto &cached = arrowToFuncInterface_; - if (LIKELY(cached != nullptr)) { - return cached; + auto &cached = compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker()->GetArrowToFuncInterfaces(); + + auto found = cached.find(this); + if (LIKELY(found != cached.end())) { + return found->second; } - return cached = FunctionTypeToFunctionalInterfaceType(checker, ArrowSignature(), ArrowSignature()->MinArgCount()); + return cached + .emplace(this, + FunctionTypeToFunctionalInterfaceType(checker, ArrowSignature(), ArrowSignature()->MinArgCount())) + .first->second; } ETSObjectType *ETSFunctionType::ArrowToFunctionalInterfaceDesiredArity(ETSChecker *checker, size_t arity) @@ -121,13 +150,15 @@ ETSObjectType *ETSFunctionType::ArrowToFunctionalInterfaceDesiredArity(ETSChecke ETSFunctionType *ETSFunctionType::MethodToArrow(ETSChecker *checker) { - auto &cached = invokeToArrowSignature_; - if (LIKELY(cached != nullptr)) { - return cached; + auto &cached = compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker()->GetInvokeToArrowSignatures(); + + auto found = cached.find(this); + if (LIKELY(found != cached.end())) { + return found->second; } ES2PANDA_ASSERT(!IsETSArrowType() && CallSignatures().size() == 1); - return cached = checker->CreateETSArrowType(CallSignatures()[0]); + return cached.emplace(this, checker->CreateETSArrowType(CallSignatures()[0])).first->second; } void ETSFunctionType::AddCallSignature(Signature *signature) @@ -157,12 +188,12 @@ static inline void AssertNoMethodsInFunctionRelation([[maybe_unused]] Type *left static Signature *EnhanceSignatureSubstitution(TypeRelation *relation, Signature *super, Signature *sub) { auto checker = relation->GetChecker()->AsETSChecker(); - auto *substitution = checker->NewSubstitution(); + auto substitution = Substitution {}; - auto const enhance = [checker, sub, substitution](Type *param, Type *arg) { - return checker->EnhanceSubstitutionForType(sub->GetSignatureInfo()->typeParams, param, arg, substitution); + auto const enhance = [checker, sub, &substitution](Type *param, Type *arg) { + return checker->EnhanceSubstitutionForType(sub->GetSignatureInfo()->typeParams, param, arg, &substitution); }; - for (size_t ix = 0; ix < super->MinArgCount(); ix++) { + for (size_t ix = 0; ix < sub->ArgCount(); ix++) { if (!enhance(sub->GetSignatureInfo()->params[ix]->TsType(), super->GetSignatureInfo()->params[ix]->TsType())) { return nullptr; } @@ -172,14 +203,7 @@ static Signature *EnhanceSignatureSubstitution(TypeRelation *relation, Signature return nullptr; } } - return sub->Substitute(relation, substitution); -} - -static uint8_t SignatureThrowKindToOrder(Signature *sig) -{ - return sig->HasSignatureFlag(SignatureFlags::THROWS) ? 0U - : sig->HasSignatureFlag(SignatureFlags::RETHROWS) ? 1U - : 2U; + return sub->Substitute(relation, &substitution); } static bool SignatureIsSupertypeOf(TypeRelation *relation, Signature *super, Signature *sub) @@ -208,7 +232,7 @@ static bool SignatureIsSupertypeOf(TypeRelation *relation, Signature *super, Sig if (!relation->IsSupertypeOf(super->ReturnType(), sub->ReturnType())) { return false; } - return SignatureThrowKindToOrder(super) <= SignatureThrowKindToOrder(sub); + return true; } static ETSFunctionType *CoerceToArrowType(TypeRelation *relation, Type *type) @@ -241,16 +265,6 @@ bool ETSFunctionType::AssignmentSource(TypeRelation *relation, Type *target) { AssertNoMethodsInFunctionRelation(this, target); - // this should be defined by the dynamic type itself - if (target->IsETSDynamicType()) { - ES2PANDA_ASSERT(relation->GetNode() != nullptr); - if (relation->GetNode()->IsArrowFunctionExpression()) { - ES2PANDA_ASSERT(callSignatures_.size() == 1 && ArrowSignature()->HasSignatureFlag(SignatureFlags::CALL)); - return relation->Result(true); - } - return relation->Result(false); - } - return relation->IsSupertypeOf(target, this); } diff --git a/ets2panda/checker/types/ets/etsFunctionType.h b/ets2panda/checker/types/ets/etsFunctionType.h index f59b65c709b186655a85fb231952f2884b628baa..ffc9e8ea5987fe634c900543de8f21a8e019eb4c 100644 --- a/ets2panda/checker/types/ets/etsFunctionType.h +++ b/ets2panda/checker/types/ets/etsFunctionType.h @@ -134,11 +134,6 @@ public: void Cast(TypeRelation *relation, Type *target) override; void CastTarget(TypeRelation *relation, Type *source) override; - std::tuple ResolveConditionExpr() const override - { - return {false, false}; - } - void SetHelperSignature(Signature *signature) noexcept { helperSignature_ = signature; @@ -165,8 +160,6 @@ private: ArenaVector extensionAccessorSigs_; util::StringView const name_; util::StringView const assemblerName_; - ETSFunctionType *invokeToArrowSignature_ {}; - ETSObjectType *arrowToFuncInterface_ {}; Signature *helperSignature_ {}; }; } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/ets/etsNeverType.h b/ets2panda/checker/types/ets/etsNeverType.h index 06904ce0581c2dcf74cc495f1c17e960a04cbbf0..7e998eb6b619f7962aea4e1d931ca1b2edff1889 100644 --- a/ets2panda/checker/types/ets/etsNeverType.h +++ b/ets2panda/checker/types/ets/etsNeverType.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -38,11 +38,6 @@ public: TypeFacts GetTypeFacts() const override; Type *Instantiate(ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes) override; - - std::tuple ResolveConditionExpr() const override - { - return {IsConstantType(), false}; - } }; } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/ets/etsNullishTypes.h b/ets2panda/checker/types/ets/etsNullishTypes.h index 195332ffd27cb4541ca6d7ee6bdd31beb21f0027..ff11033e5d4d7c2a2af967e67bd0cc3fea8ce87a 100644 --- a/ets2panda/checker/types/ets/etsNullishTypes.h +++ b/ets2panda/checker/types/ets/etsNullishTypes.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -37,11 +37,6 @@ public: void ToDebugInfoType([[maybe_unused]] std::stringstream &ss) const override; Type *Instantiate(ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes) override; - - std::tuple ResolveConditionExpr() const override - { - return {IsConstantType(), false}; - } }; class ETSUndefinedType : public Type { @@ -60,11 +55,6 @@ public: void ToDebugInfoType([[maybe_unused]] std::stringstream &ss) const override; Type *Instantiate(ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes) override; - - std::tuple ResolveConditionExpr() const override - { - return {IsConstantType(), false}; - } }; } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/ets/etsObjectType.cpp b/ets2panda/checker/types/ets/etsObjectType.cpp index 733f658a5321354fffcb92de928c42ad72af4540..177a0c679a909e84d1e36a2aff4228362d92df78 100644 --- a/ets2panda/checker/types/ets/etsObjectType.cpp +++ b/ets2panda/checker/types/ets/etsObjectType.cpp @@ -18,26 +18,49 @@ #include "checker/ETSchecker.h" #include "checker/ets/conversion.h" #include "checker/types/globalTypesHolder.h" +#include "checker/types/ets/etsAsyncFuncReturnType.h" +#include "checker/types/ets/etsEnumType.h" +#include "compiler/lowering/phase.h" +#include "ir/statements/annotationDeclaration.h" namespace ark::es2panda::checker { void ETSObjectType::Iterate(const PropertyTraverser &cb) const { - for (const auto *prop : GetAllProperties()) { - cb(prop); + ForEachAllOwnProperties(cb); + ForEachAllNonOwnProperties(cb); +} + +void ETSObjectType::AddInterface(ETSObjectType *interfaceType) +{ + if (std::find(interfaces_.begin(), interfaces_.end(), interfaceType) == interfaces_.end()) { + interfaces_.push_back(interfaceType); + CacheSupertypeTransitive(interfaceType); } +} - if (superType_ != nullptr) { - superType_->Iterate(cb); +void ETSObjectType::SetSuperType(ETSObjectType *super) +{ + superType_ = super; + if (super == nullptr) { + return; } + CacheSupertypeTransitive(super); +} - for (const auto *interface : interfaces_) { - interface->Iterate(cb); +void ETSObjectType::CacheSupertypeTransitive(ETSObjectType *type) +{ + auto const insertType = [this](ETSObjectType *t) { + return transitiveSupertypes_.insert(t->GetOriginalBaseType()).second; + }; + if (insertType(type)) { + for (auto &t : type->transitiveSupertypes_) { + insertType(t); + } } } -varbinder::LocalVariable *ETSObjectType::SearchFieldsDecls(const util::StringView &name, - PropertySearchFlags flags) const +varbinder::LocalVariable *ETSObjectType::SearchFieldsDecls(util::StringView name, PropertySearchFlags flags) const { varbinder::LocalVariable *res {}; if ((flags & PropertySearchFlags::SEARCH_INSTANCE_FIELD) != 0) { @@ -58,37 +81,53 @@ varbinder::LocalVariable *ETSObjectType::SearchFieldsDecls(const util::StringVie return res; } -varbinder::LocalVariable *ETSObjectType::GetProperty(const util::StringView &name, PropertySearchFlags flags) const +varbinder::LocalVariable *ETSObjectType::GetProperty(util::StringView name, PropertySearchFlags flags) const { - varbinder::LocalVariable *res = SearchFieldsDecls(name, flags); - if (res == nullptr && (flags & PropertySearchFlags::SEARCH_METHOD) != 0) { - if ((flags & PropertySearchFlags::DISALLOW_SYNTHETIC_METHOD_CREATION) != 0) { - if ((flags & PropertySearchFlags::SEARCH_INSTANCE_METHOD) != 0) { - res = GetOwnProperty(name); + // CC-OFFNXT(G.FMT.14-CPP) project code style + auto const searchOwnMethod = [this, flags, name]() -> varbinder::LocalVariable * { + if ((flags & PropertySearchFlags::SEARCH_INSTANCE_METHOD) != 0) { + if (auto res = GetOwnProperty(name); res != nullptr) { + return res; + } + } + if ((flags & PropertySearchFlags::SEARCH_STATIC_METHOD) != 0) { + if (auto res = GetOwnProperty(name); res != nullptr) { + return res; } + } + return nullptr; + }; - if (res == nullptr && ((flags & PropertySearchFlags::SEARCH_STATIC_METHOD) != 0)) { - res = GetOwnProperty(name); + if (auto res = SearchFieldsDecls(name, flags); res != nullptr) { + return res; + } + + if ((flags & PropertySearchFlags::SEARCH_METHOD) != 0) { + if ((flags & PropertySearchFlags::DISALLOW_SYNTHETIC_METHOD_CREATION) != 0) { + if (auto res = searchOwnMethod(); res != nullptr) { + return res; } } else { - res = CreateSyntheticVarFromEverySignature(name, flags); + if (auto res = CreateSyntheticVarFromEverySignature(name, flags)) { + return res; + } } } - if (res == nullptr && (flags & PropertySearchFlags::SEARCH_IN_INTERFACES) != 0) { + if (((flags & PropertySearchFlags::SEARCH_INSTANCE) != 0 || (flags & PropertySearchFlags::SEARCH_STATIC) == 0) && + (flags & PropertySearchFlags::SEARCH_IN_INTERFACES) != 0) { for (auto *interface : interfaces_) { - res = interface->GetProperty(name, flags); - if (res != nullptr) { + if (auto res = interface->GetProperty(name, flags); res != nullptr) { return res; } } } - if (res == nullptr && superType_ != nullptr && ((flags & PropertySearchFlags::SEARCH_IN_BASE) != 0)) { - res = superType_->GetProperty(name, flags); + if ((flags & PropertySearchFlags::SEARCH_IN_BASE) != 0 && superType_ != nullptr) { + return superType_->GetProperty(name, flags); } - return res; + return nullptr; } bool ETSObjectType::IsPropertyInherited(const varbinder::Variable *var) @@ -160,7 +199,11 @@ static void UpdateDeclarationForGetterSetter(varbinder::LocalVariable *res, cons if (!HasAccessor(flags, funcType) || res->Declaration() != nullptr) { return; } - auto var = funcType->CallSignatures().front()->OwnerVar(); + + auto frontGetter = std::find_if(funcType->CallSignatures().begin(), funcType->CallSignatures().end(), + [](Signature *sig) { return sig->Function()->IsGetter(); }); + auto var = frontGetter == funcType->CallSignatures().end() ? funcType->CallSignatures().front()->OwnerVar() + : (*frontGetter)->OwnerVar(); auto decl = var->Declaration(); if (decl == nullptr || decl->Node() == nullptr) { return; @@ -172,7 +215,11 @@ varbinder::LocalVariable *ETSObjectType::CreateSyntheticVarFromEverySignature(co PropertySearchFlags flags) const { std::vector signatures; - varbinder::LocalVariable *functionalInterface = CollectSignaturesForSyntheticType(signatures, name, flags); + // Since both "first match" and "best match" exist at present, overloadDeclarationCall is temporarily used. After + // "best match" removed, this marking needs to be removed. + bool overloadDeclarationCall = false; + varbinder::LocalVariable *functionalInterface = + CollectSignaturesForSyntheticType(signatures, name, flags, overloadDeclarationCall); // #22952: the called function *always* returns nullptr ES2PANDA_ASSERT(functionalInterface == nullptr); (void)functionalInterface; @@ -181,14 +228,18 @@ varbinder::LocalVariable *ETSObjectType::CreateSyntheticVarFromEverySignature(co return nullptr; } - varbinder::LocalVariable *res = allocator_->New(varbinder::VariableFlags::SYNTHETIC | - varbinder::VariableFlags::METHOD); + varbinder::VariableFlags varianceFlag = + overloadDeclarationCall ? varbinder::VariableFlags::SYNTHETIC | varbinder::VariableFlags::METHOD | + varbinder::VariableFlags::OVERLOAD + : varbinder::VariableFlags::SYNTHETIC | varbinder::VariableFlags::METHOD; + varbinder::LocalVariable *res = allocator_->New(varianceFlag); ETSFunctionType *funcType = CreateMethodTypeForProp(name); + ES2PANDA_ASSERT(funcType != nullptr); for (auto &s : signatures) { funcType->AddCallSignature(s); } - + ES2PANDA_ASSERT(res != nullptr); res->SetTsType(funcType); funcType->SetVariable(res); @@ -197,15 +248,36 @@ varbinder::LocalVariable *ETSObjectType::CreateSyntheticVarFromEverySignature(co return res; } -ETSFunctionType *ETSObjectType::CreateMethodTypeForProp(const util::StringView &name) const +ETSFunctionType *ETSObjectType::CreateMethodTypeForProp(util::StringView name) const { - ES2PANDA_ASSERT(GetRelation() != nullptr && GetRelation()->GetChecker() != nullptr); - auto *checker = GetRelation()->GetChecker()->AsETSChecker(); - return checker->CreateETSMethodType(name, {{}, Allocator()->Adapter()}); + ES2PANDA_ASSERT(GetRelation() != nullptr); + return GetRelation()->GetChecker()->AsETSChecker()->CreateETSMethodType(name, {{}, Allocator()->Adapter()}); } -static void AddSignature(std::vector &signatures, PropertySearchFlags flags, ETSChecker *checker, - varbinder::LocalVariable *found) +bool ETSObjectType::ReplaceArgumentInSignature(std::vector &signatures, Signature *sigToInsert, + TypeRelation *relation) const +{ + for (auto *&sigToReplace : signatures) { + if (sigToReplace->ArgCount() != sigToInsert->ArgCount()) { + continue; + } + if (relation->IsSupertypeOf(sigToInsert->Owner(), sigToReplace->Owner()) && + relation->SignatureIsSupertypeOf(sigToInsert, sigToReplace)) { + // Already overridden by a subtype's signature + return true; + } + if (relation->IsSupertypeOf(sigToReplace->Owner(), sigToInsert->Owner()) && + relation->SignatureIsSupertypeOf(sigToReplace, sigToInsert)) { + sigToReplace = sigToInsert; + return true; + } + } + + return false; +} + +void ETSObjectType::AddSignatureFromFunction(std::vector &signatures, PropertySearchFlags flags, + ETSChecker *checker, varbinder::LocalVariable *found) const { for (auto *it : found->TsType()->AsETSFunctionType()->CallSignatures()) { if (std::find(signatures.begin(), signatures.end(), it) != signatures.end()) { @@ -214,63 +286,130 @@ static void AddSignature(std::vector &signatures, PropertySearchFla if (((flags & PropertySearchFlags::IGNORE_ABSTRACT) != 0) && it->HasSignatureFlag(SignatureFlags::ABSTRACT)) { continue; } - if (std::any_of(signatures.begin(), signatures.end(), [&it, &checker](auto sig) { - return checker->AreOverrideCompatible(sig, it) && - it->Owner()->HasObjectFlag(ETSObjectFlags::INTERFACE) && - (checker->Relation()->IsSupertypeOf(it->Owner(), sig->Owner()) || - !sig->Owner()->HasObjectFlag(ETSObjectFlags::INTERFACE)); - })) { + if (ReplaceArgumentInSignature(signatures, it, checker->Relation())) { continue; } - // Issue: #18720 - // NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) signatures.emplace_back(it); } } +void ETSObjectType::AddSignatureFromOverload(std::vector &signatures, PropertySearchFlags flags, + varbinder::LocalVariable *found, bool &overloadDeclarationCall) const +{ + auto *overloadDeclaration = found->Declaration()->Node()->AsOverloadDeclaration(); + std::vector methodSignature; + if (overloadDeclaration->Id()->IsErrorPlaceHolder()) { + return; + } + + overloadDeclarationCall |= true; + if (overloadDeclaration->IsConstructorOverloadDeclaration()) { + return AddSignatureFromConstructor(signatures, found); + } + + for (auto *method : overloadDeclaration->OverloadedList()) { + // Identical type cannot be obtained directly, because typeparamter has not been substitute. + methodSignature.clear(); + util::StringView methodName = + method->IsIdentifier() ? method->AsIdentifier()->Name() : method->AsTSQualifiedName()->Right()->Name(); + CollectSignaturesForSyntheticType(methodSignature, methodName, flags, overloadDeclarationCall); + if (!methodSignature.empty()) { + signatures.emplace_back(methodSignature.front()); + } + } +} + +void ETSObjectType::AddSignatureFromConstructor(std::vector &signatures, + varbinder::LocalVariable *found) const +{ + auto *overloadDeclaration = found->Declaration()->Node()->AsOverloadDeclaration(); + for (auto *method : overloadDeclaration->OverloadedList()) { + util::StringView orderConstructorName = method->AsIdentifier()->Name(); + + // Constructor will lowering to multiple Constructor if have rest parameters or optional parameters. + // Need to modify RestTupleConstructionPhase. + std::vector matches; + std::copy_if( + constructSignatures_.begin(), constructSignatures_.end(), std::back_inserter(matches), + [orderConstructorName](Signature *sig) { return sig->Function()->Id()->Name() == orderConstructorName; }); + + if (!matches.empty()) { + std::copy(matches.begin(), matches.end(), std::back_inserter(signatures)); + } + } +} + +void ETSObjectType::AddSignature(std::vector &signatures, PropertySearchFlags flags, ETSChecker *checker, + varbinder::LocalVariable *found, bool &overloadDeclarationCall) const +{ + if (found != nullptr && found->HasFlag(varbinder::VariableFlags::OVERLOAD)) { + if (!found->Declaration()->Node()->IsOverloadDeclaration()) { + return; + } + AddSignatureFromOverload(signatures, flags, found, overloadDeclarationCall); + } else if (found != nullptr && !found->TsType()->IsTypeError()) { + ES2PANDA_ASSERT(found->TsType()->IsETSFunctionType()); + AddSignatureFromFunction(signatures, flags, checker, found); + } +} + varbinder::LocalVariable *ETSObjectType::CollectSignaturesForSyntheticType(std::vector &signatures, const util::StringView &name, - PropertySearchFlags flags) const + PropertySearchFlags flags, + bool &overloadDeclarationCall) const { auto *checker = GetRelation()->GetChecker()->AsETSChecker(); if ((flags & PropertySearchFlags::SEARCH_STATIC_METHOD) != 0) { - if (auto *found = GetOwnProperty(name); - found != nullptr && !found->TsType()->IsTypeError()) { - ES2PANDA_ASSERT(found->TsType()->IsETSFunctionType()); - AddSignature(signatures, flags, checker, found); - } + auto *found = GetOwnProperty(name); + AddSignature(signatures, flags, checker, found, overloadDeclarationCall); } if ((flags & PropertySearchFlags::SEARCH_INSTANCE_METHOD) != 0) { - if (auto *found = GetOwnProperty(name); - found != nullptr && !found->TsType()->IsTypeError()) { - ES2PANDA_ASSERT(found->TsType()->IsETSFunctionType()); - AddSignature(signatures, flags, checker, found); - } + auto *found = GetOwnProperty(name); + AddSignature(signatures, flags, checker, found, overloadDeclarationCall); } - if (superType_ != nullptr && ((flags & PropertySearchFlags::SEARCH_IN_BASE) != 0)) { - superType_->CollectSignaturesForSyntheticType(signatures, name, flags); + if ((flags & PropertySearchFlags::SEARCH_INSTANCE_METHOD) == 0) { + return nullptr; } - ArenaVector interfaces(Allocator()->Adapter()); - checker->GetInterfacesOfClass(const_cast(this), interfaces); + if (superType_ != nullptr && ((flags & PropertySearchFlags::SEARCH_IN_BASE) != 0)) { + superType_->CollectSignaturesForSyntheticType(signatures, name, flags, overloadDeclarationCall); + } - for (auto *const &interface : interfaces) { - if (interface != nullptr && ((flags & PropertySearchFlags::SEARCH_IN_INTERFACES) != 0) && - !this->IsPartial()) { // NOTE: issue 24548 - if (auto *found = - interface->GetProperty(name, flags | PropertySearchFlags::DISALLOW_SYNTHETIC_METHOD_CREATION); - found != nullptr && !found->TsType()->IsTypeError()) { - ES2PANDA_ASSERT(found->TsType()->IsETSFunctionType()); - AddSignature(signatures, flags, checker, found); - } + if ((flags & PropertySearchFlags::SEARCH_IN_INTERFACES) != 0) { + for (auto *interface : Interfaces()) { + interface->CollectSignaturesForSyntheticType(signatures, name, flags, overloadDeclarationCall); } } + return nullptr; } +void ETSObjectType::ForEachAllOwnProperties(const PropertyTraverser &cb) const +{ + EnsurePropertiesInstantiated(); + for (size_t i = 0; i < static_cast(PropertyType::COUNT); ++i) { + PropertyMap &map = properties_[i]; + for (const auto &[_, prop] : map) { + (void)_; + cb(prop); + } + } +} + +void ETSObjectType::ForEachAllNonOwnProperties(const PropertyTraverser &cb) const +{ + if (superType_ != nullptr) { + superType_->Iterate(cb); + } + + for (const auto *interface : interfaces_) { + interface->Iterate(cb); + } +} + std::vector ETSObjectType::GetAllProperties() const { std::vector allProperties; @@ -307,16 +446,42 @@ std::vector ETSObjectType::GetAllProperties() const return allProperties; } +std::vector ETSObjectType::Overloads() const +{ + std::vector methods; + for (const auto &[_, prop] : InstanceMethods()) { + (void)_; + if (prop->HasFlag(varbinder::VariableFlags::OVERLOAD)) { + methods.push_back(prop); + } + } + + for (const auto &[_, prop] : StaticMethods()) { + (void)_; + if (prop->HasFlag(varbinder::VariableFlags::OVERLOAD)) { + methods.push_back(prop); + } + } + + return methods; +} + std::vector ETSObjectType::Methods() const { std::vector methods; for (const auto &[_, prop] : InstanceMethods()) { (void)_; + if (prop->HasFlag(varbinder::VariableFlags::OVERLOAD)) { + continue; + } methods.push_back(prop); } for (const auto &[_, prop] : StaticMethods()) { (void)_; + if (prop->HasFlag(varbinder::VariableFlags::OVERLOAD)) { + continue; + } methods.push_back(prop); } @@ -351,35 +516,25 @@ std::vector ETSObjectType::ForeignProperties() ownInstanceProps.reserve(properties_.size()); ownStaticProps.reserve(properties_.size()); - for (const auto *prop : GetAllProperties()) { + ForEachAllOwnProperties([&](const varbinder::LocalVariable *prop) { if (prop->HasFlag(varbinder::VariableFlags::STATIC)) { ownStaticProps.insert(prop->Name()); } else { ownInstanceProps.insert(prop->Name()); } - } - - std::map allInstanceProps {}; - std::map allStaticProps {}; - Iterate([&allInstanceProps, &allStaticProps](const varbinder::LocalVariable *var) { + }); + ForEachAllNonOwnProperties([&](const varbinder::LocalVariable *var) { if (var->HasFlag(varbinder::VariableFlags::STATIC)) { - allStaticProps.emplace(var->Name(), var); + if (ownStaticProps.find(var->Name()) == ownStaticProps.end()) { + foreignProps.push_back(var); + } } else { - allInstanceProps.emplace(var->Name(), var); + if (ownInstanceProps.find(var->Name()) == ownInstanceProps.end()) { + foreignProps.push_back(var); + } } }); - for (const auto &[name, var] : allInstanceProps) { - if (ownInstanceProps.find(name) == ownInstanceProps.end()) { - foreignProps.push_back(var); - } - } - for (const auto &[name, var] : allStaticProps) { - if (ownStaticProps.find(name) == ownStaticProps.end()) { - foreignProps.push_back(var); - } - } - return foreignProps; } @@ -426,7 +581,8 @@ void ETSObjectType::SubstitutePartialTypes(TypeRelation *relation, Type *other) ES2PANDA_ASSERT(IsPartial()); if ((baseType_->IsGeneric() || baseType_->IsETSTypeParameter()) && effectiveSubstitution_ != nullptr) { - if (auto *newBaseType = baseType_->Substitute(relation, effectiveSubstitution_); + auto subst = ETSChecker::ArenaSubstitutionToSubstitution(effectiveSubstitution_); + if (auto *newBaseType = baseType_->Substitute(relation, &subst); newBaseType->IsETSObjectType() && !relation->IsIdenticalTo(newBaseType, baseType_)) { baseType_ = newBaseType->AsETSObjectType(); } @@ -436,7 +592,8 @@ void ETSObjectType::SubstitutePartialTypes(TypeRelation *relation, Type *other) auto *otherPartial = other->AsETSObjectType(); if ((otherPartial->baseType_->IsGeneric() || otherPartial->baseType_->IsETSTypeParameter()) && otherPartial->effectiveSubstitution_ != nullptr) { - if (auto *newBaseType = otherPartial->baseType_->Substitute(relation, otherPartial->effectiveSubstitution_); + auto subst = ETSChecker::ArenaSubstitutionToSubstitution(otherPartial->effectiveSubstitution_); + if (auto *newBaseType = otherPartial->baseType_->Substitute(relation, &subst); newBaseType->IsETSObjectType() && !relation->IsIdenticalTo(newBaseType, otherPartial->baseType_)) { otherPartial->baseType_ = newBaseType->AsETSObjectType(); } @@ -518,7 +675,6 @@ void ETSObjectType::Identical(TypeRelation *relation, Type *other) bool ETSObjectType::CheckIdenticalFlags(ETSObjectType *other) const { constexpr auto FLAGS_TO_REMOVE = ETSObjectFlags::INCOMPLETE_INSTANTIATION | - ETSObjectFlags::CHECKED_COMPATIBLE_ABSTRACTS | ETSObjectFlags::CHECKED_INVOKE_LEGITIMACY | ETSObjectFlags::EXTENSION_FUNCTION; auto cleanedTargetFlags = other->ObjectFlags(); @@ -538,7 +694,7 @@ bool ETSObjectType::AssignmentSource(TypeRelation *const relation, [[maybe_unuse bool ETSObjectType::IsBoxedPrimitive() const { - if (this->IsETSDynamicType()) { + if (this->IsETSEnumType()) { return false; } @@ -554,12 +710,12 @@ void ETSObjectType::AssignmentTarget(TypeRelation *const relation, Type *source) ETSFunctionType *ETSObjectType::GetFunctionalInterfaceInvokeType() const { ES2PANDA_ASSERT(HasObjectFlag(ETSObjectFlags::FUNCTIONAL)); + auto checker = GetRelation()->GetChecker()->AsETSChecker(); // NOTE(vpukhov): this is still better than to retain any "functional" state in ETSObjectType - auto [foundArity, hasRest] = [this]() { - auto checker = GetRelation()->GetChecker()->AsETSChecker(); + auto [foundArity, hasRest] = [this, checker]() { auto baseType = GetConstOriginalBaseType(); - for (size_t arity = 0; arity < checker->GetGlobalTypesHolder()->VariadicFunctionTypeThreshold(); ++arity) { + for (size_t arity = 0; arity <= checker->GlobalBuiltinFunctionTypeVariadicThreshold(); ++arity) { if (auto itf = checker->GlobalBuiltinFunctionType(arity, false); itf == baseType) { return std::make_pair(arity, false); } @@ -570,14 +726,15 @@ ETSFunctionType *ETSObjectType::GetFunctionalInterfaceInvokeType() const ES2PANDA_UNREACHABLE(); }(); - std::string invokeName = FunctionalInterfaceInvokeName(foundArity, hasRest); - auto *invoke = GetOwnProperty(util::StringView(invokeName)); + std::string invokeName = checker->FunctionalInterfaceInvokeName(foundArity, hasRest); + auto *invoke = GetProperty(util::StringView(invokeName), + PropertySearchFlags::SEARCH_INSTANCE_METHOD | PropertySearchFlags::SEARCH_IN_INTERFACES); ES2PANDA_ASSERT(invoke != nullptr && invoke->TsType() != nullptr && invoke->TsType()->IsETSFunctionType()); return invoke->TsType()->AsETSFunctionType(); } -bool ETSObjectType::CastWideningNarrowing(TypeRelation *const relation, Type *const target, TypeFlag unboxFlags, - TypeFlag wideningFlags, TypeFlag narrowingFlags) +bool ETSObjectType::CastWidening(TypeRelation *const relation, Type *const target, TypeFlag unboxFlags, + TypeFlag wideningFlags) { if (target->HasTypeFlag(unboxFlags)) { conversion::Unboxing(relation, this); @@ -587,10 +744,6 @@ bool ETSObjectType::CastWideningNarrowing(TypeRelation *const relation, Type *co conversion::UnboxingWideningPrimitive(relation, this, target); return true; } - if (target->HasTypeFlag(narrowingFlags)) { - conversion::UnboxingNarrowingPrimitive(relation, this, target); - return true; - } return false; } @@ -605,7 +758,7 @@ bool ETSObjectType::TryCastByte(TypeRelation *const relation, Type *const target return true; } if (target->HasTypeFlag(TypeFlag::CHAR)) { - conversion::UnboxingWideningNarrowingPrimitive(relation, this, target); + conversion::UnboxingWideningPrimitive(relation, this, target); return true; } return false; @@ -617,25 +770,21 @@ bool ETSObjectType::TryCastIntegral(TypeRelation *const relation, Type *const ta return true; } if (this->HasObjectFlag(ETSObjectFlags::BUILTIN_SHORT) && - CastWideningNarrowing(relation, target, TypeFlag::SHORT, - TypeFlag::INT | TypeFlag::LONG | TypeFlag::FLOAT | TypeFlag::DOUBLE, - TypeFlag::BYTE | TypeFlag::CHAR)) { + CastWidening(relation, target, TypeFlag::SHORT, + TypeFlag::INT | TypeFlag::LONG | TypeFlag::FLOAT | TypeFlag::DOUBLE)) { return true; } if (this->HasObjectFlag(ETSObjectFlags::BUILTIN_CHAR) && - CastWideningNarrowing(relation, target, TypeFlag::CHAR, - TypeFlag::INT | TypeFlag::LONG | TypeFlag::FLOAT | TypeFlag::DOUBLE, - TypeFlag::BYTE | TypeFlag::SHORT)) { + CastWidening(relation, target, TypeFlag::CHAR, + TypeFlag::SHORT | TypeFlag::INT | TypeFlag::LONG | TypeFlag::FLOAT | TypeFlag::DOUBLE)) { return true; } if (this->HasObjectFlag(ETSObjectFlags::BUILTIN_INT) && - CastWideningNarrowing(relation, target, TypeFlag::INT, TypeFlag::LONG | TypeFlag::FLOAT | TypeFlag::DOUBLE, - TypeFlag::BYTE | TypeFlag::SHORT | TypeFlag::CHAR)) { + CastWidening(relation, target, TypeFlag::INT, TypeFlag::LONG | TypeFlag::FLOAT | TypeFlag::DOUBLE)) { return true; } if (this->HasObjectFlag(ETSObjectFlags::BUILTIN_LONG) && - CastWideningNarrowing(relation, target, TypeFlag::LONG, TypeFlag::FLOAT | TypeFlag::DOUBLE, - TypeFlag::BYTE | TypeFlag::SHORT | TypeFlag::CHAR | TypeFlag::INT)) { + CastWidening(relation, target, TypeFlag::LONG, TypeFlag::FLOAT | TypeFlag::DOUBLE)) { return true; } return false; @@ -644,14 +793,11 @@ bool ETSObjectType::TryCastIntegral(TypeRelation *const relation, Type *const ta bool ETSObjectType::TryCastFloating(TypeRelation *const relation, Type *const target) { if (this->HasObjectFlag(ETSObjectFlags::BUILTIN_FLOAT) && - CastWideningNarrowing(relation, target, TypeFlag::FLOAT, TypeFlag::DOUBLE, - TypeFlag::BYTE | TypeFlag::SHORT | TypeFlag::CHAR | TypeFlag::INT | TypeFlag::LONG)) { + CastWidening(relation, target, TypeFlag::FLOAT, TypeFlag::DOUBLE)) { return true; } - if (auto narrowingFlags = - TypeFlag::BYTE | TypeFlag::SHORT | TypeFlag::CHAR | TypeFlag::INT | TypeFlag::LONG | TypeFlag::FLOAT; - this->HasObjectFlag(ETSObjectFlags::BUILTIN_DOUBLE) && - CastWideningNarrowing(relation, target, TypeFlag::DOUBLE, TypeFlag::NONE, narrowingFlags)) { + if (this->HasObjectFlag(ETSObjectFlags::BUILTIN_DOUBLE) && + CastWidening(relation, target, TypeFlag::DOUBLE, TypeFlag::NONE)) { return true; } return false; @@ -673,6 +819,12 @@ bool ETSObjectType::TryCastUnboxable(TypeRelation *const relation, Type *const t conversion::WideningReference(relation, this, target->AsETSObjectType()); return true; } + + if (target->IsETSEnumType()) { + auto unboxedThis = relation->GetChecker()->AsETSChecker()->MaybeUnboxInRelation(this); + return relation->IsCastableTo(unboxedThis, target); + } + conversion::Forbidden(relation); return true; } @@ -698,10 +850,6 @@ bool ETSObjectType::CastNumericObject(TypeRelation *const relation, Type *const if (this->IsETSUnboxableObject()) { return TryCastUnboxable(relation, target); } - if (target->IsETSPrimitiveType()) { - conversion::NarrowingReferenceUnboxing(relation, this, target); - return true; - } return false; } @@ -794,6 +942,14 @@ void ETSObjectType::IsSupertypeOf(TypeRelation *relation, Type *source) void ETSObjectType::IsSubtypeOf(TypeRelation *relation, Type *target) { + if (target->IsETSObjectType()) { + auto &transitives = transitiveSupertypes_; + if (transitives.find(target->AsETSObjectType()->GetOriginalBaseType()) == transitives.end()) { + relation->Result(false); + return; + } + } + if (auto super = SuperType(); super != nullptr) { if (relation->IsSupertypeOf(target, super)) { return; @@ -856,6 +1012,7 @@ void ETSObjectType::IsGenericSupertypeOf(TypeRelation *relation, ETSObjectType * Type *ETSObjectType::AsSuper(Checker *checker, varbinder::Variable *sourceVar) { + checker = GetETSChecker(); if (sourceVar == nullptr) { return nullptr; } @@ -915,13 +1072,15 @@ varbinder::LocalVariable *ETSObjectType::CopyProperty(varbinder::LocalVariable * if (copiedPropType->Variable() == prop) { copiedPropType->SetVariable(copiedProp); } + ES2PANDA_ASSERT(copiedProp != nullptr); copiedProp->SetTsType(copiedPropType); return copiedProp; } -Type *ETSObjectType::Instantiate(ArenaAllocator *const allocator, TypeRelation *const relation, +Type *ETSObjectType::Instantiate(ArenaAllocator *const allocator, TypeRelation *relation, GlobalTypesHolder *const globalTypes) { + relation = relation_; auto *const checker = relation->GetChecker()->AsETSChecker(); std::lock_guard guard {*checker->Mutex()}; auto *const base = GetOriginalBaseType(); @@ -934,9 +1093,9 @@ Type *ETSObjectType::Instantiate(ArenaAllocator *const allocator, TypeRelation * auto *const copiedType = checker->CreateETSObjectType(declNode_, flags_); ES2PANDA_ASSERT(copiedType->internalName_ == internalName_); ES2PANDA_ASSERT(copiedType->name_ == name_); + ES2PANDA_ASSERT(copiedType != nullptr); copiedType->typeFlags_ = typeFlags_; - copiedType->RemoveObjectFlag(ETSObjectFlags::CHECKED_COMPATIBLE_ABSTRACTS | - ETSObjectFlags::INCOMPLETE_INSTANTIATION | ETSObjectFlags::CHECKED_INVOKE_LEGITIMACY); + copiedType->RemoveObjectFlag(ETSObjectFlags::INCOMPLETE_INSTANTIATION | ETSObjectFlags::CHECKED_INVOKE_LEGITIMACY); copiedType->SetVariable(variable_); copiedType->SetSuperType(superType_); @@ -976,12 +1135,13 @@ static varbinder::LocalVariable *CopyPropertyWithTypeArguments(varbinder::LocalV auto *const checker = relation->GetChecker()->AsETSChecker(); auto *const varType = ETSChecker::IsVariableGetterSetter(prop) ? prop->TsType() : checker->GetTypeOfVariable(prop); auto *const copiedPropType = SubstituteVariableType(relation, substitution, varType); - auto *const copiedProp = prop->Copy(checker->ProgramAllocator(), prop->Declaration()); + auto *const copiedProp = prop->Copy(checker->Allocator(), prop->Declaration()); // NOTE: some situation copiedPropType we get here are types cached in Checker, // uncontrolled SetVariable will pollute the cache. if (copiedPropType->Variable() == prop || copiedPropType->Variable() == nullptr) { copiedPropType->SetVariable(copiedProp); } + ES2PANDA_ASSERT(copiedProp != nullptr); copiedProp->SetTsType(copiedPropType); return copiedProp; } @@ -1014,13 +1174,13 @@ bool ETSObjectType::SubstituteTypeArgs(TypeRelation *const relation, ArenaVector return anyChange; } -static Substitution *ComputeEffectiveSubstitution(TypeRelation *const relation, - const ArenaVector &baseTypeParams, - ArenaVector &newTypeArgs) +static ArenaSubstitution *ComputeEffectiveSubstitution(TypeRelation *const relation, + const ArenaVector &baseTypeParams, + ArenaVector &newTypeArgs) { ES2PANDA_ASSERT(baseTypeParams.size() == newTypeArgs.size()); auto *const checker = relation->GetChecker()->AsETSChecker(); - auto *effectiveSubstitution = checker->NewSubstitution(); + auto *effectiveSubstitution = checker->NewArenaSubstitution(); for (size_t ix = 0; ix < baseTypeParams.size(); ix++) { checker->EmplaceSubstituted(effectiveSubstitution, baseTypeParams[ix]->AsETSTypeParameter(), newTypeArgs[ix]); @@ -1032,23 +1192,30 @@ static Substitution *ComputeEffectiveSubstitution(TypeRelation *const relation, void ETSObjectType::SetCopiedTypeProperties(TypeRelation *const relation, ETSObjectType *const copiedType, ArenaVector &&newTypeArgs, ETSObjectType *base) { + ES2PANDA_ASSERT(copiedType != nullptr); copiedType->typeFlags_ = typeFlags_; - copiedType->RemoveObjectFlag(ETSObjectFlags::CHECKED_COMPATIBLE_ABSTRACTS | - ETSObjectFlags::INCOMPLETE_INSTANTIATION | ETSObjectFlags::CHECKED_INVOKE_LEGITIMACY); + copiedType->RemoveObjectFlag(ETSObjectFlags::INCOMPLETE_INSTANTIATION | ETSObjectFlags::CHECKED_INVOKE_LEGITIMACY); copiedType->SetVariable(variable_); - copiedType->SetBaseType(base); + + // #25295 Need to do some refactor on baseType for partial + if (IsPartial() && HasObjectFlag(ETSObjectFlags::INTERFACE)) { + copiedType->SetBaseType(this); + } else { + copiedType->SetBaseType(base); + } auto const &baseTypeParams = base->TypeArguments(); copiedType->effectiveSubstitution_ = ComputeEffectiveSubstitution(relation, baseTypeParams, newTypeArgs); copiedType->SetTypeArguments(std::move(newTypeArgs)); + ES2PANDA_ASSERT(relation); copiedType->relation_ = relation; } -void ETSObjectType::UpdateTypeProperty(checker::ETSChecker *checker, varbinder::LocalVariable *const prop, - PropertyType fieldType, PropertyProcesser const &func) +void ETSObjectType::UpdateTypeProperty(varbinder::LocalVariable *const prop, PropertyType fieldType, + PropertyProcesser const &func) { - auto const propType = prop->Declaration()->Node()->Check(checker); + auto const propType = prop->Declaration()->Node()->Check(GetETSChecker()); auto *const propCopy = func(prop, propType); if (fieldType == PropertyType::INSTANCE_FIELD) { @@ -1060,36 +1227,97 @@ void ETSObjectType::UpdateTypeProperty(checker::ETSChecker *checker, varbinder:: } } -void ETSObjectType::UpdateTypeProperties(checker::ETSChecker *checker, PropertyProcesser const &func) +void ETSObjectType::UpdateTypeProperties(PropertyProcesser const &func) { AddTypeFlag(TypeFlag::READONLY); for (auto const &prop : InstanceFields()) { - UpdateTypeProperty(checker, prop.second, PropertyType::INSTANCE_FIELD, func); + UpdateTypeProperty(prop.second, PropertyType::INSTANCE_FIELD, func); } for (auto const &prop : StaticFields()) { - UpdateTypeProperty(checker, prop.second, PropertyType::STATIC_FIELD, func); + UpdateTypeProperty(prop.second, PropertyType::STATIC_FIELD, func); } if (SuperType() != nullptr) { - auto *const superProp = SuperType()->Clone(checker)->AsETSObjectType(); - superProp->UpdateTypeProperties(checker, func); + auto *const superProp = + SuperType() + ->Instantiate(allocator_, relation_, relation_->GetChecker()->GetGlobalTypesHolder()) + ->AsETSObjectType(); + superProp->UpdateTypeProperties(func); SetSuperType(superProp); } } +static util::StringView GetHashFromSubstitution(const Substitution *substitution, const bool extensionFuncFlag, + ArenaAllocator *allocator) +{ + std::vector fields; + for (auto [k, v] : *substitution) { + std::stringstream ss; + k->ToString(ss, true); + ss << ":"; + v->ToString(ss, true); + // NOTE (mmartin): change bare address to something more appropriate unique representation + ss << ":" << k << ":" << v; + fields.push_back(ss.str()); + } + std::sort(fields.begin(), fields.end()); + + std::stringstream ss; + for (auto &fstr : fields) { + ss << fstr; + ss << ";"; + } + + if (extensionFuncFlag) { + ss << "extensionFunctionType;"; + } + return util::UString(ss.str(), allocator).View(); +} + +static std::pair GetObjectTypeDeclNames(ir::AstNode *node) +{ + if (node->IsClassDefinition()) { + return {node->AsClassDefinition()->Ident()->Name(), node->AsClassDefinition()->InternalName()}; + } + if (node->IsTSInterfaceDeclaration()) { + return {node->AsTSInterfaceDeclaration()->Id()->Name(), node->AsTSInterfaceDeclaration()->InternalName()}; + } + return {node->AsAnnotationDeclaration()->GetBaseName()->Name(), node->AsAnnotationDeclaration()->InternalName()}; +} + +ETSObjectType *ETSObjectType::CreateETSObjectType(ir::AstNode *declNode, ETSObjectFlags flags) +{ + auto const [name, internalName] = GetObjectTypeDeclNames(declNode); + + if (declNode->IsClassDefinition() && (declNode->AsClassDefinition()->IsEnumTransformed())) { + if (declNode->AsClassDefinition()->IsIntEnumTransformed()) { + return Allocator()->New(Allocator(), name, internalName, declNode, GetRelation()); + } + ES2PANDA_ASSERT(declNode->AsClassDefinition()->IsStringEnumTransformed()); + return Allocator()->New(Allocator(), name, internalName, declNode, GetRelation()); + } + if (internalName == compiler::Signatures::BUILTIN_ARRAY) { + return Allocator()->New(Allocator(), name, + std::make_tuple(declNode, flags, GetRelation())); + } + + return Allocator()->New(Allocator(), name, internalName, + std::make_tuple(declNode, flags, GetRelation())); +} + // #22951: remove isExtensionFunctionType flag ETSObjectType *ETSObjectType::Substitute(TypeRelation *relation, const Substitution *substitution, bool cache, bool isExtensionFunctionType) { + relation = relation_; if (substitution == nullptr || substitution->empty()) { return this; } - auto *const checker = relation->GetChecker()->AsETSChecker(); auto *base = GetOriginalBaseType(); - ArenaVector newTypeArgs {Allocator()->Adapter()}; + ArenaVector newTypeArgs {allocator_->Adapter()}; const bool anyChange = SubstituteTypeArgs(relation, newTypeArgs, substitution); // Lambda types can capture type params in their bodies, normal classes cannot. // NOTE: gogabr. determine precise conditions where we do not need to copy. @@ -1098,7 +1326,7 @@ ETSObjectType *ETSObjectType::Substitute(TypeRelation *relation, const Substitut return this; } - const util::StringView hash = checker->GetHashFromSubstitution(substitution, isExtensionFunctionType); + const util::StringView hash = GetHashFromSubstitution(substitution, isExtensionFunctionType, allocator_); if (cache) { if (auto *inst = GetInstantiatedType(hash); inst != nullptr) { return inst; @@ -1110,14 +1338,15 @@ ETSObjectType *ETSObjectType::Substitute(TypeRelation *relation, const Substitut } relation->IncreaseTypeRecursionCount(base); - auto *const copiedType = checker->CreateETSObjectType(declNode_, flags_); + auto *const copiedType = CreateETSObjectType(declNode_, flags_); SetCopiedTypeProperties(relation, copiedType, std::move(newTypeArgs), base); if (isExtensionFunctionType) { copiedType->AddObjectFlag(checker::ETSObjectFlags::EXTENSION_FUNCTION); } if (cache) { - GetInstantiationMap().try_emplace(hash, copiedType); + ES2PANDA_ASSERT(copiedType->GetRelation()); + InsertInstantiationMap(hash, copiedType); } if (superType_ != nullptr) { @@ -1145,16 +1374,22 @@ ETSObjectType *ETSObjectType::SubstituteArguments(TypeRelation *relation, ArenaV } auto *checker = relation->GetChecker()->AsETSChecker(); - auto *substitution = checker->NewSubstitution(); + auto substitution = Substitution {}; ES2PANDA_ASSERT(baseType_ == nullptr); ES2PANDA_ASSERT(typeArguments_.size() == arguments.size()); for (size_t ix = 0; ix < typeArguments_.size(); ix++) { - substitution->emplace(typeArguments_[ix]->AsETSTypeParameter(), checker->MaybeBoxType(arguments[ix])); + substitution.emplace(typeArguments_[ix]->AsETSTypeParameter(), + checker->MaybeBoxType(arguments[ix]->MaybeBaseTypeOfGradualType())); } - return Substitute(relation, substitution); + return Substitute(relation, &substitution); +} + +ETSChecker *ETSObjectType::GetETSChecker() +{ + return relation_->GetChecker()->AsETSChecker(); } void ETSObjectType::InstantiateProperties() const @@ -1170,44 +1405,48 @@ void ETSObjectType::InstantiateProperties() const ES2PANDA_ASSERT(!propertiesInstantiated_); declNode_->Check(checker); + auto subst = effectiveSubstitution_ == nullptr + ? Substitution {} + : ETSChecker::ArenaSubstitutionToSubstitution(effectiveSubstitution_); + for (auto *const it : baseType_->ConstructSignatures()) { - auto *newSig = it->Substitute(relation_, effectiveSubstitution_); + auto *newSig = it->Substitute(relation_, &subst); constructSignatures_.push_back(newSig); } for (auto const &[_, prop] : baseType_->InstanceFields()) { (void)_; - auto *copiedProp = CopyPropertyWithTypeArguments(prop, relation_, effectiveSubstitution_); + auto *copiedProp = CopyPropertyWithTypeArguments(prop, relation_, &subst); properties_[static_cast(PropertyType::INSTANCE_FIELD)].emplace(prop->Name(), copiedProp); } for (auto const &[_, prop] : baseType_->StaticFields()) { (void)_; - auto *copiedProp = CopyPropertyWithTypeArguments(prop, relation_, effectiveSubstitution_); + auto *copiedProp = CopyPropertyWithTypeArguments(prop, relation_, &subst); properties_[static_cast(PropertyType::STATIC_FIELD)].emplace(prop->Name(), copiedProp); } for (auto const &[_, prop] : baseType_->InstanceMethods()) { (void)_; - auto *copiedProp = CopyPropertyWithTypeArguments(prop, relation_, effectiveSubstitution_); + auto *copiedProp = CopyPropertyWithTypeArguments(prop, relation_, &subst); properties_[static_cast(PropertyType::INSTANCE_METHOD)].emplace(prop->Name(), copiedProp); } for (auto const &[_, prop] : baseType_->StaticMethods()) { (void)_; - auto *copiedProp = CopyPropertyWithTypeArguments(prop, relation_, effectiveSubstitution_); + auto *copiedProp = CopyPropertyWithTypeArguments(prop, relation_, &subst); properties_[static_cast(PropertyType::STATIC_METHOD)].emplace(prop->Name(), copiedProp); } for (auto const &[_, prop] : baseType_->InstanceDecls()) { (void)_; - auto *copiedProp = CopyPropertyWithTypeArguments(prop, relation_, effectiveSubstitution_); + auto *copiedProp = CopyPropertyWithTypeArguments(prop, relation_, &subst); properties_[static_cast(PropertyType::INSTANCE_DECL)].emplace(prop->Name(), copiedProp); } for (auto const &[_, prop] : baseType_->StaticDecls()) { (void)_; - auto *copiedProp = CopyPropertyWithTypeArguments(prop, relation_, effectiveSubstitution_); + auto *copiedProp = CopyPropertyWithTypeArguments(prop, relation_, &subst); properties_[static_cast(PropertyType::STATIC_DECL)].emplace(prop->Name(), copiedProp); } } @@ -1336,8 +1575,29 @@ void ETSObjectType::CheckVarianceRecursively(TypeRelation *relation, VarianceFla return; } - auto *params = GetDeclNode()->IsClassDefinition() ? GetDeclNode()->AsClassDefinition()->TypeParams() - : GetDeclNode()->AsTSInterfaceDeclaration()->TypeParams(); + // according to the spec(GENERICS chapter), only class/interface/function/ + // method/lambda and type alias can have type parameters. since + // 1. the type of function and method is ETSFunctionType + // 2. lambda has been checked above + // here we just need check + // 1. class + // 2. interface + // 3. type alias(which will be redirected to its real type) + // And all of them should have declarations + if (declNode_ == nullptr) { + // If the type is not declared, then we do not need to check variance. + return; + } + ir::TSTypeParameterDeclaration *params; + if (GetDeclNode()->IsClassDefinition()) { + params = GetDeclNode()->AsClassDefinition()->TypeParams(); + } else if (GetDeclNode()->IsTSInterfaceDeclaration()) { + params = GetDeclNode()->AsTSInterfaceDeclaration()->TypeParams(); + } else { + // If the type is not a class or interface or type alias, then we do not need to check variance. + return; + } + if (params == nullptr) { return; } @@ -1355,4 +1615,40 @@ void ETSObjectType::CheckVarianceRecursively(TypeRelation *relation, VarianceFla } } +ETSObjectType *ETSObjectType::GetInstantiatedType(util::StringView hash) +{ + auto &instantiationMap = + compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker()->GetObjectInstantiationMap(); + auto found = instantiationMap.find(this); + if (found == instantiationMap.end()) { + return nullptr; + } + + auto found2 = instantiationMap.at(this).find(hash); + if (found2 == instantiationMap.at(this).end()) { + return nullptr; + } + + return found2->second; +} + +void ETSObjectType::InsertInstantiationMap(util::StringView key, ETSObjectType *value) +{ + auto &instantiationMap = + compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker()->GetObjectInstantiationMap(); + if (instantiationMap.find(this) == instantiationMap.end()) { + ArenaUnorderedMap instantiation( + compiler::GetPhaseManager()->Context()->GetChecker()->AsETSChecker()->Allocator()->Adapter()); + instantiation.emplace(key, value); + instantiationMap.emplace(this, std::move(instantiation)); + } + compiler::GetPhaseManager() + ->Context() + ->GetChecker() + ->AsETSChecker() + ->GetObjectInstantiationMap() + .at(this) + .try_emplace(key, value); +} + } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/ets/etsObjectType.h b/ets2panda/checker/types/ets/etsObjectType.h index 9a174689dd7925c03ca8557b5caf2c2a044d2338..2f81c4be7c98481b663be75eb3c0a94a6bb28383 100644 --- a/ets2panda/checker/types/ets/etsObjectType.h +++ b/ets2panda/checker/types/ets/etsObjectType.h @@ -16,6 +16,10 @@ #ifndef ES2PANDA_COMPILER_CHECKER_TYPES_ETS_OBJECT_TYPE_H #define ES2PANDA_COMPILER_CHECKER_TYPES_ETS_OBJECT_TYPE_H +#include +#include + +#include "checker/checker.h" #include "checker/types/type.h" #include "checker/types/ets/etsObjectTypeConstants.h" #include "checker/types/signature.h" @@ -37,14 +41,14 @@ public: using PropertyTraverser = std::function; using PropertyHolder = std::array(PropertyType::COUNT)>; - explicit ETSObjectType(ArenaAllocator *allocator, util::StringView name, util::StringView internalName, + explicit ETSObjectType(ThreadSafeArenaAllocator *allocator, util::StringView name, util::StringView internalName, ir::AstNode *declNode, ETSObjectFlags flags) : ETSObjectType(allocator, name, internalName, std::make_tuple(declNode, flags, nullptr), std::make_index_sequence(PropertyType::COUNT)> {}) { } - explicit ETSObjectType(ArenaAllocator *allocator, util::StringView name, util::StringView internalName, + explicit ETSObjectType(ThreadSafeArenaAllocator *allocator, util::StringView name, util::StringView internalName, std::tuple info) : ETSObjectType(allocator, name, internalName, info, std::make_index_sequence(PropertyType::COUNT)> {}) @@ -63,17 +67,10 @@ public: propertiesInstantiated_ = true; } - void AddInterface(ETSObjectType *interfaceType) - { - if (std::find(interfaces_.begin(), interfaces_.end(), interfaceType) == interfaces_.end()) { - interfaces_.push_back(interfaceType); - } - } + void AddInterface(ETSObjectType *interfaceType); + void SetSuperType(ETSObjectType *super); - void SetSuperType(ETSObjectType *super) - { - superType_ = super; - } + ETSChecker *GetETSChecker(); void SetTypeArguments(ArenaVector &&typeArgs) { @@ -92,6 +89,7 @@ public: void SetRelation(TypeRelation *relation) { + ES2PANDA_ASSERT(relation); relation_ = relation; } @@ -158,7 +156,7 @@ public: return interfaces_; } - ArenaVector &Interfaces() + const ArenaVector &Interfaces() { return interfaces_; } @@ -234,12 +232,12 @@ public: bool IsDescendantOf(const ETSObjectType *ascendant) const; - const util::StringView &Name() const + util::StringView Name() const { return name_; } - const util::StringView &AssemblerName() const + util::StringView AssemblerName() const { return internalName_; } @@ -276,15 +274,7 @@ public: return static_cast(flags_ & ETSObjectFlags::UNBOXABLE_TYPE); } - ETSObjectType *GetInstantiatedType(util::StringView hash) - { - auto found = instantiationMap_.find(hash); - if (found != instantiationMap_.end()) { - return found->second; - } - - return nullptr; - } + ETSObjectType *GetInstantiatedType(util::StringView hash); varbinder::Scope *GetTypeArgumentScope() const { @@ -295,13 +285,10 @@ public: return typeParams->Scope(); } - InstantiationMap &GetInstantiationMap() - { - return instantiationMap_; - } + void InsertInstantiationMap(const util::StringView key, ETSObjectType *value); template - varbinder::LocalVariable *GetOwnProperty(const util::StringView &name) const + varbinder::LocalVariable *GetOwnProperty(const util::StringView name) const { EnsurePropertiesInstantiated(); auto found = properties_[static_cast(TYPE)].find(name); @@ -349,19 +336,31 @@ public: } std::vector ForeignProperties() const; - varbinder::LocalVariable *GetProperty(const util::StringView &name, PropertySearchFlags flags) const; + varbinder::LocalVariable *GetProperty(util::StringView name, PropertySearchFlags flags) const; std::vector GetAllProperties() const; + void ForEachAllOwnProperties(const PropertyTraverser &cb) const; + void ForEachAllNonOwnProperties(const PropertyTraverser &cb) const; varbinder::LocalVariable *CopyProperty(varbinder::LocalVariable *prop, ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes); std::vector Methods() const; std::vector Fields() const; + std::vector Overloads() const; varbinder::LocalVariable *CreateSyntheticVarFromEverySignature(const util::StringView &name, PropertySearchFlags flags) const; varbinder::LocalVariable *CollectSignaturesForSyntheticType(std::vector &signatures, - const util::StringView &name, - PropertySearchFlags flags) const; + const util::StringView &name, PropertySearchFlags flags, + bool &overloadDeclarationCall) const; + void AddSignature(std::vector &signatures, PropertySearchFlags flags, ETSChecker *checker, + varbinder::LocalVariable *found, bool &overloadDeclarationCall) const; + void AddSignatureFromFunction(std::vector &signatures, PropertySearchFlags flags, ETSChecker *checker, + varbinder::LocalVariable *found) const; + void AddSignatureFromOverload(std::vector &signatures, PropertySearchFlags flags, + varbinder::LocalVariable *found, bool &overloadDeclarationCall) const; + void AddSignatureFromConstructor(std::vector &signatures, varbinder::LocalVariable *found) const; + bool ReplaceArgumentInSignature(std::vector &signatures, Signature *sigToInsert, + TypeRelation *relation) const; bool CheckIdenticalFlags(ETSObjectType *other) const; - + ETSObjectType *CreateETSObjectType(ir::AstNode *declNode, ETSObjectFlags flags); void Iterate(const PropertyTraverser &cb) const; void ToString(std::stringstream &ss, bool precise) const override; void Identical(TypeRelation *relation, Type *other) override; @@ -369,7 +368,7 @@ public: void AssignmentTarget(TypeRelation *relation, Type *source) override; bool IsBoxedPrimitive() const; Type *Instantiate(ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes) override; - void UpdateTypeProperties(checker::ETSChecker *checker, PropertyProcesser const &func); + void UpdateTypeProperties(PropertyProcesser const &func); ETSObjectType *Substitute(TypeRelation *relation, const Substitution *substitution) override; ETSObjectType *Substitute(TypeRelation *relation, const Substitution *substitution, bool cache, bool isExtensionFunctionType = false); @@ -392,16 +391,11 @@ public: const ArenaVector &ReExports() const; bool IsSameBasedGeneric(TypeRelation *relation, Type const *other) const; - ArenaAllocator *Allocator() const + ThreadSafeArenaAllocator *Allocator() const { return allocator_; } - std::tuple ResolveConditionExpr() const override - { - return {false, false}; - } - [[nodiscard]] static std::uint32_t GetPrecedence(checker::ETSChecker *checker, ETSObjectType const *type) noexcept; bool IsPropertiesInstantiated() const @@ -410,11 +404,11 @@ public: } protected: - virtual ETSFunctionType *CreateMethodTypeForProp(const util::StringView &name) const; + virtual ETSFunctionType *CreateMethodTypeForProp(util::StringView name) const; private: template - explicit ETSObjectType(ArenaAllocator *allocator, util::StringView name, util::StringView assemblerName, + explicit ETSObjectType(ThreadSafeArenaAllocator *allocator, util::StringView name, util::StringView assemblerName, std::tuple info, [[maybe_unused]] std::index_sequence s) : Type(TypeFlag::ETS_OBJECT), @@ -426,8 +420,8 @@ private: reExports_(allocator->Adapter()), reExportAlias_(allocator->Adapter()), flags_(std::get(info)), - instantiationMap_(allocator->Adapter()), typeArguments_(allocator->Adapter()), + transitiveSupertypes_(allocator->Adapter()), relation_(std::get(info)), constructSignatures_(allocator->Adapter()), properties_ {(void(IS), PropertyMap {allocator->Adapter()})...} @@ -443,15 +437,14 @@ private: propertiesInstantiated_ = true; } } - bool CastWideningNarrowing(TypeRelation *relation, Type *target, TypeFlag unboxFlags, TypeFlag wideningFlags, - TypeFlag narrowingFlags); + bool CastWidening(TypeRelation *relation, Type *target, TypeFlag unboxFlags, TypeFlag wideningFlags); void IdenticalUptoTypeArguments(TypeRelation *relation, Type *other); void SubstitutePartialTypes(TypeRelation *relation, Type *other); void IsGenericSupertypeOf(TypeRelation *relation, ETSObjectType *source); - void UpdateTypeProperty(checker::ETSChecker *checker, varbinder::LocalVariable *const prop, PropertyType fieldType, + void UpdateTypeProperty(varbinder::LocalVariable *const prop, PropertyType fieldType, PropertyProcesser const &func); - varbinder::LocalVariable *SearchFieldsDecls(const util::StringView &name, PropertySearchFlags flags) const; + varbinder::LocalVariable *SearchFieldsDecls(util::StringView name, PropertySearchFlags flags) const; void SetCopiedTypeProperties(TypeRelation *relation, ETSObjectType *copiedType, ArenaVector &&newTypeArgs, ETSObjectType *base); @@ -462,9 +455,11 @@ private: bool TryCastFloating(TypeRelation *const relation, Type *const target); bool TryCastUnboxable(TypeRelation *const relation, Type *const target); + void CacheSupertypeTransitive(ETSObjectType *type); + ir::TSTypeParameterDeclaration *GetTypeParams() const; - ArenaAllocator *const allocator_; + ThreadSafeArenaAllocator *const allocator_; util::StringView const name_; util::StringView const internalName_; ir::AstNode *const declNode_; @@ -472,15 +467,17 @@ private: ArenaVector reExports_; ArenaMap reExportAlias_; ETSObjectFlags flags_; - InstantiationMap instantiationMap_; ArenaVector typeArguments_; ETSObjectType *superType_ {}; ETSObjectType *enclosingType_ {}; ETSObjectType *baseType_ {}; + // optimized subtyping + ArenaSet transitiveSupertypes_; + // for lazy properties instantiation TypeRelation *relation_ = nullptr; - const Substitution *effectiveSubstitution_ = nullptr; + const ArenaSubstitution *effectiveSubstitution_ = nullptr; mutable bool propertiesInstantiated_ = false; mutable ArenaVector constructSignatures_; mutable PropertyHolder properties_; diff --git a/ets2panda/checker/types/ets/etsObjectTypeConstants.h b/ets2panda/checker/types/ets/etsObjectTypeConstants.h index 0a51f2f1d6a1393d49d722194d834fdc8992eb7e..007a89a06d9b3bb70caddc99126922e721d91a30 100644 --- a/ets2panda/checker/types/ets/etsObjectTypeConstants.h +++ b/ets2panda/checker/types/ets/etsObjectTypeConstants.h @@ -34,15 +34,14 @@ enum class ETSObjectFlags : std::uint64_t { RESOLVED_INTERFACES = 1U << 7U, RESOLVED_SUPER = 1U << 8U, RESOLVED_TYPE_PARAMS = 1U << 9U, - CHECKED_COMPATIBLE_ABSTRACTS = 1U << 10U, - STRING = 1U << 11U, - INCOMPLETE_INSTANTIATION = 1U << 12U, - INNER = 1U << 13U, - DYNAMIC = 1U << 14U, - ASYNC_FUNC_RETURN_TYPE = 1U << 15U, - CHECKED_INVOKE_LEGITIMACY = 1U << 16U, - REQUIRED = 1U << 17U, - READONLY = 1U << 18U, + STRING = 1U << 10U, + INCOMPLETE_INSTANTIATION = 1U << 11U, + INNER = 1U << 12U, + DYNAMIC = 1U << 13U, + ASYNC_FUNC_RETURN_TYPE = 1U << 14U, + CHECKED_INVOKE_LEGITIMACY = 1U << 15U, + REQUIRED = 1U << 16U, + READONLY = 1U << 17U, BUILTIN_BIGINT = 1U << 22U, BUILTIN_STRING = 1U << 23U, @@ -56,16 +55,27 @@ enum class ETSObjectFlags : std::uint64_t { BUILTIN_DOUBLE = 1U << 31U, BUILTIN_ARRAY = 1ULL << 32U, - ENUM_OBJECT = 1ULL << 33U, - EXTENSION_FUNCTION = 1ULL << 34U, + INT_ENUM_OBJECT = 1ULL << 33U, + STRING_ENUM_OBJECT = 1ULL << 34U, - FUNCTIONAL_REFERENCE = 1ULL << 35U, + EXTENSION_FUNCTION = 1ULL << 35U, + FUNCTIONAL_REFERENCE = 1ULL << 36U, + LAZY_IMPORT_OBJECT = 1ULL << 37U, - BUILTIN_NUMERIC = BUILTIN_BYTE | BUILTIN_SHORT | BUILTIN_INT | BUILTIN_LONG | BUILTIN_FLOAT | BUILTIN_DOUBLE, + ENUM_OBJECT = INT_ENUM_OBJECT | STRING_ENUM_OBJECT, + + BUILTIN_FLOATING_POINT = BUILTIN_DOUBLE | BUILTIN_FLOAT, + BUILTIN_INTEGRAL = BUILTIN_BYTE | BUILTIN_SHORT | BUILTIN_INT | BUILTIN_LONG, + + BUILTIN_ARRAY_INDEX = BUILTIN_BYTE | BUILTIN_SHORT | BUILTIN_INT, + BUILTIN_ARRAY_NUMERIC = BUILTIN_ARRAY_INDEX | BUILTIN_FLOATING_POINT, + + BUILTIN_NUMERIC = BUILTIN_INTEGRAL | BUILTIN_FLOATING_POINT, // Complete set includes null|undefined|Object VALUE_TYPED = BUILTIN_BOOLEAN | BUILTIN_CHAR | BUILTIN_NUMERIC | BUILTIN_BIGINT | STRING, UNBOXABLE_TYPE = BUILTIN_BOOLEAN | BUILTIN_CHAR | BUILTIN_NUMERIC, BUILTIN_TYPE = BUILTIN_STRING | BUILTIN_BIGINT | UNBOXABLE_TYPE, + CONVERTIBLE_TO_NUMERIC = BUILTIN_NUMERIC | BUILTIN_CHAR | INT_ENUM_OBJECT, GLOBAL_CLASS = CLASS | GLOBAL, FUNCTIONAL_INTERFACE = INTERFACE | ABSTRACT | FUNCTIONAL, @@ -110,12 +120,6 @@ enum class PropertyType { COUNT, }; -/* Invoke method name in functional interfaces */ -inline std::string FunctionalInterfaceInvokeName(size_t arity, bool hasRest) -{ - return (hasRest ? "invokeR" : "invoke") + std::to_string(arity); -} - } // namespace ark::es2panda::checker namespace enumbitops { diff --git a/ets2panda/checker/types/ets/etsPartialTypeParameter.cpp b/ets2panda/checker/types/ets/etsPartialTypeParameter.cpp index 14b55779761ae1d6d2230315da9696e72eaf0d35..fc451fd0707596091c2f81d0c8fb6beb8ce54b6b 100644 --- a/ets2panda/checker/types/ets/etsPartialTypeParameter.cpp +++ b/ets2panda/checker/types/ets/etsPartialTypeParameter.cpp @@ -82,8 +82,13 @@ void ETSPartialTypeParameter::IsSubtypeOf(TypeRelation *relation, Type *target) ETSPartialTypeParameter *ETSPartialTypeParameter::Instantiate(ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes) { - return allocator->New( - GetUnderlying()->Instantiate(allocator, relation, globalTypes)->AsETSTypeParameter(), checker_); + auto *underlying = GetUnderlying(); + ES2PANDA_ASSERT(underlying != nullptr); + auto *instantiated = underlying->Instantiate(allocator, relation, globalTypes); + ES2PANDA_ASSERT(instantiated != nullptr); + auto *typeParam = instantiated->AsETSTypeParameter(); + ES2PANDA_ASSERT(typeParam != nullptr); + return allocator->New(typeParam, checker_); } Type *ETSPartialTypeParameter::Substitute(TypeRelation *relation, const Substitution *substitution) diff --git a/ets2panda/checker/types/ets/etsResizableArrayType.cpp b/ets2panda/checker/types/ets/etsResizableArrayType.cpp index 25fcd72aba950af51699942f1241bbfff595af9a..464207ceda8e4d8f2c71f898a8cdeb89990fdbe4 100644 --- a/ets2panda/checker/types/ets/etsResizableArrayType.cpp +++ b/ets2panda/checker/types/ets/etsResizableArrayType.cpp @@ -14,6 +14,7 @@ */ #include "etsResizableArrayType.h" +#include "etsUnionType.h" namespace ark::es2panda::checker { @@ -24,4 +25,16 @@ ETSResizableArrayType *ETSResizableArrayType::Substitute(TypeRelation *relation, return copiedType; } -} // namespace ark::es2panda::checker \ No newline at end of file +void ETSResizableArrayType::ToString(std::stringstream &ss, [[maybe_unused]] bool precise) const +{ + if (ElementType() != nullptr) { + if (HasTypeFlag(TypeFlag::READONLY)) { + ss << "readonly "; + } + ss << "Array<"; + ElementType()->ToString(ss, precise); + ss << ">"; + } +} + +} // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/ets/etsResizableArrayType.h b/ets2panda/checker/types/ets/etsResizableArrayType.h index 43babf404a36dcfdbce983333683b9a94a0666bd..90936ceadfbcb45ac54ccc707dc04d294f067d07 100644 --- a/ets2panda/checker/types/ets/etsResizableArrayType.h +++ b/ets2panda/checker/types/ets/etsResizableArrayType.h @@ -23,7 +23,7 @@ namespace ark::es2panda::checker { class ETSResizableArrayType : public ETSObjectType { public: - explicit ETSResizableArrayType(ArenaAllocator *allocator, ETSObjectType *super) + explicit ETSResizableArrayType(ThreadSafeArenaAllocator *allocator, ETSObjectType *super) : ETSObjectType(allocator, "", compiler::Signatures::BUILTIN_ARRAY, nullptr, ETSObjectFlags::CLASS | ETSObjectFlags::BUILTIN_ARRAY | ETSObjectFlags::RESOLVED_SUPER), element_(nullptr) @@ -31,13 +31,13 @@ public: SetSuperType(super); } - explicit ETSResizableArrayType(ArenaAllocator *allocator, util::StringView name, + explicit ETSResizableArrayType(ThreadSafeArenaAllocator *allocator, util::StringView name, std::tuple info) : ETSObjectType(allocator, name, compiler::Signatures::BUILTIN_ARRAY, info), element_(nullptr) { } - explicit ETSResizableArrayType(ArenaAllocator *allocator, ETSObjectType *super, TypeRelation *relation, + explicit ETSResizableArrayType(ThreadSafeArenaAllocator *allocator, ETSObjectType *super, TypeRelation *relation, Type *element) : ETSObjectType( allocator, "", compiler::Signatures::BUILTIN_ARRAY, @@ -76,10 +76,12 @@ public: ETSResizableArrayType *Substitute(TypeRelation *relation, const Substitution *substitution) override; + void ToString(std::stringstream &ss, [[maybe_unused]] bool precise) const override; + private: Type *element_; }; } // namespace ark::es2panda::checker -#endif \ No newline at end of file +#endif diff --git a/ets2panda/checker/types/ets/etsStringType.cpp b/ets2panda/checker/types/ets/etsStringType.cpp index 1a3c8ba2cc94ec1fc7ea2c58a07b1c419137e8dc..ef98c512f8887eff0ba6f19d14f95fa89d0d081b 100644 --- a/ets2panda/checker/types/ets/etsStringType.cpp +++ b/ets2panda/checker/types/ets/etsStringType.cpp @@ -74,5 +74,4 @@ void ETSStringType::IsSubtypeOf(TypeRelation *relation, Type *source) auto *const checker = relation->GetChecker()->AsETSChecker(); relation->IsSupertypeOf(source, checker->GlobalBuiltinETSStringType()); } - } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/ets/etsStringType.h b/ets2panda/checker/types/ets/etsStringType.h index 09d15090cc73771505b92585b1e5d7c9953cfcf3..ab6b6e07608388106a8f0b8b2fc043fbffb6f6c5 100644 --- a/ets2panda/checker/types/ets/etsStringType.h +++ b/ets2panda/checker/types/ets/etsStringType.h @@ -21,14 +21,14 @@ namespace ark::es2panda::checker { class ETSStringType : public ETSObjectType { public: - explicit ETSStringType(ArenaAllocator *allocator, ETSObjectType *super) + explicit ETSStringType(ThreadSafeArenaAllocator *allocator, ETSObjectType *super) : ETSObjectType(allocator, "", compiler::Signatures::BUILTIN_STRING, nullptr, ETSObjectFlags::CLASS | ETSObjectFlags::STRING | ETSObjectFlags::RESOLVED_SUPER) { SetSuperType(super); } - explicit ETSStringType(ArenaAllocator *allocator, ETSObjectType *super, TypeRelation *relation) + explicit ETSStringType(ThreadSafeArenaAllocator *allocator, ETSObjectType *super, TypeRelation *relation) : ETSObjectType(allocator, "", compiler::Signatures::BUILTIN_STRING, std::make_tuple(nullptr, ETSObjectFlags::CLASS | ETSObjectFlags::STRING | ETSObjectFlags::RESOLVED_SUPER, @@ -37,7 +37,7 @@ public: SetSuperType(super); } - explicit ETSStringType(ArenaAllocator *allocator, ETSObjectType *super, TypeRelation *relation, + explicit ETSStringType(ThreadSafeArenaAllocator *allocator, ETSObjectType *super, TypeRelation *relation, util::StringView value) : ETSObjectType(allocator, "", compiler::Signatures::BUILTIN_STRING, std::make_tuple(nullptr, @@ -76,11 +76,6 @@ public: return value_; } - std::tuple ResolveConditionExpr() const override - { - return {IsConstantType(), IsConstantType() ? (GetValue().Length() != 0) : false}; - } - private: util::StringView value_ {}; }; diff --git a/ets2panda/checker/types/ets/etsTupleType.cpp b/ets2panda/checker/types/ets/etsTupleType.cpp index cd7ffe68c14f04c04178eefcbc94aa10f0534a01..38930b20a3a519e024ff6bba7b36b785e0619191 100644 --- a/ets2panda/checker/types/ets/etsTupleType.cpp +++ b/ets2panda/checker/types/ets/etsTupleType.cpp @@ -65,7 +65,9 @@ void ETSTupleType::ToDebugInfoType(std::stringstream &ss) const Type *ETSTupleType::GetTypeAtIndex(const TupleSizeType index) const { - ES2PANDA_ASSERT(index < GetTupleSize()); + if (index >= GetTupleSize()) { // happens when dealing with type errors + return nullptr; + } return GetTupleTypesList().at(index); } @@ -196,6 +198,7 @@ Type *ETSTupleType::Instantiate([[maybe_unused]] ArenaAllocator *allocator, [[ma { auto *const checker = relation->GetChecker()->AsETSChecker(); auto *const tupleType = allocator->New(checker, GetTupleTypesList()); + ES2PANDA_ASSERT(tupleType != nullptr); tupleType->typeFlags_ = typeFlags_; return tupleType; } diff --git a/ets2panda/checker/types/ets/etsTupleType.h b/ets2panda/checker/types/ets/etsTupleType.h index 53418a226c933ef7bd6fe24e38d68bfc3ba130f4..f6a76125a9f8d2032f1526238b5be2e100543fef 100644 --- a/ets2panda/checker/types/ets/etsTupleType.h +++ b/ets2panda/checker/types/ets/etsTupleType.h @@ -28,7 +28,10 @@ public: explicit ETSTupleType(ETSChecker *checker, const ArenaVector &typeList) : Type(checker::TypeFlag::ETS_TUPLE), typeList_(typeList), - wrapperType_(checker->GlobalBuiltinTupleType(typeList_.size())->AsETSObjectType()) + // NOLINTNEXTLINE(readability-implicit-bool-conversion) + wrapperType_(checker->GlobalBuiltinTupleType(typeList_.size()) != nullptr + ? checker->GlobalBuiltinTupleType(typeList_.size())->AsETSObjectType() + : nullptr) { typeFlags_ |= TypeFlag::ETS_TUPLE; } @@ -43,11 +46,6 @@ public: return typeList_; } - std::tuple ResolveConditionExpr() const override - { - return {false, false}; - } - [[nodiscard]] ETSObjectType *GetWrapperType() const { return wrapperType_; diff --git a/ets2panda/checker/types/ets/etsTypeAliasType.cpp b/ets2panda/checker/types/ets/etsTypeAliasType.cpp index 411b0bbe09f49f9b0f6b77f5f48c6c045bd031c6..e1e05bdb25bd611438881d21390abebceeb530df 100644 --- a/ets2panda/checker/types/ets/etsTypeAliasType.cpp +++ b/ets2panda/checker/types/ets/etsTypeAliasType.cpp @@ -257,34 +257,6 @@ bool ETSTypeAliasType::SubstituteTypeArgs(TypeRelation *const relation, ArenaVec return anyChange; } -void ETSTypeAliasType::ApplySubstitution(TypeRelation *relation) -{ - ES2PANDA_ASSERT(base_ == nullptr); - - const util::StringView hash = relation->GetChecker()->AsETSChecker()->GetHashFromTypeArguments(typeArguments_); - EmplaceInstantiatedType(hash, this); - - auto getTypes = [this]() { - std::vector types; - - for (auto [name, type] : instantiationMap_) { - if (type->targetType_ == nullptr) { - types.push_back(type); - } - } - - return types; - }; - - std::vector types; - - while (!(types = getTypes(), types.empty())) { - for (auto type : types) { - type->SetTargetType(type->parent_->targetType_->Substitute(relation, type->substitution_)); - } - } -} - void ETSTypeAliasType::SetTypeArguments(ArenaVector typeArguments) { typeArguments_ = std::move(typeArguments); @@ -311,10 +283,13 @@ Type *ETSTypeAliasType::Substitute(TypeRelation *relation, const Substitution *s return copiedType; } + auto arenaSubst = checker->NewArenaSubstitution(); + std::copy(substitution->begin(), substitution->end(), std::inserter(*arenaSubst, arenaSubst->end())); + copiedType = checker->CreateETSTypeAliasType(name_, declNode_, isRecursive_); copiedType->base_ = base_ == nullptr ? this : base_; copiedType->parent_ = this; - copiedType->substitution_ = substitution; + copiedType->substitution_ = arenaSubst; copiedType->typeArguments_ = newTypeArgs; EmplaceInstantiatedType(hash, copiedType); diff --git a/ets2panda/checker/types/ets/etsTypeAliasType.h b/ets2panda/checker/types/ets/etsTypeAliasType.h index a0811891f9a32250542360191c57ad77fe7961e2..3146b63f51500953d1a669ee47eb22d94419eaf1 100644 --- a/ets2panda/checker/types/ets/etsTypeAliasType.h +++ b/ets2panda/checker/types/ets/etsTypeAliasType.h @@ -53,11 +53,6 @@ public: targetType_ = targetType; } - std::tuple ResolveConditionExpr() const override - { - return {false, false}; - } - void SetRecursive(bool value = true) { isRecursive_ = value; @@ -87,8 +82,6 @@ public: Type *Substitute(TypeRelation *relation, const Substitution *substitution) override; - void ApplySubstitution(TypeRelation *relation); - void SetTypeArguments(ArenaVector typeArguments); private: @@ -112,7 +105,7 @@ private: Type *targetType_ = nullptr; InstantiationMap instantiationMap_; ArenaVector typeArguments_; - const Substitution *substitution_ = nullptr; + const ArenaSubstitution *substitution_ = nullptr; mutable bool recursionCount_ = false; }; } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/ets/etsTypeParameter.cpp b/ets2panda/checker/types/ets/etsTypeParameter.cpp index 518a42441bc1d0493b3a90a4a549052fdf48b3b9..ebb370321da70c44aa3855509d3387f22c3d2244 100644 --- a/ets2panda/checker/types/ets/etsTypeParameter.cpp +++ b/ets2panda/checker/types/ets/etsTypeParameter.cpp @@ -127,6 +127,7 @@ Type *ETSTypeParameter::Instantiate([[maybe_unused]] ArenaAllocator *allocator, auto *const checker = relation->GetChecker()->AsETSChecker(); auto *const copiedType = checker->CreateTypeParameter(); + ES2PANDA_ASSERT(copiedType != nullptr); copiedType->AddTypeFlag(TypeFlag::GENERIC); copiedType->SetDeclNode(GetDeclNode()); copiedType->SetDefaultType(GetDefaultType()); diff --git a/ets2panda/checker/types/ets/etsUnionType.cpp b/ets2panda/checker/types/ets/etsUnionType.cpp index 2bbdf54442f4f6e4e746f7b52b6a3795a33aedc4..3bfeecc8cc9282d8c9d2cd9a936db99701553574 100644 --- a/ets2panda/checker/types/ets/etsUnionType.cpp +++ b/ets2panda/checker/types/ets/etsUnionType.cpp @@ -34,74 +34,125 @@ void ETSUnionType::ToString(std::stringstream &ss, bool precise) const void ETSUnionType::ToAssemblerType(std::stringstream &ss) const { - assemblerLub_->ToAssemblerTypeWithRank(ss); + ss << GetAssemblerType(); } void ETSUnionType::ToDebugInfoType(std::stringstream &ss) const { - assemblerLub_->ToDebugInfoType(ss); -} - -ETSUnionType::ETSUnionType(ETSChecker *checker, ArenaVector &&constituentTypes) - : Type(TypeFlag::ETS_UNION), constituentTypes_(std::move(constituentTypes)) -{ - ES2PANDA_ASSERT(constituentTypes_.size() > 1); - assemblerLub_ = ComputeAssemblerLUB(checker, this); + if (assemblerConstituentTypes_.size() == 1) { + assemblerConstituentTypes_[0]->ToDebugInfoType(ss); + return; + } + ss << "{U"; + // NOLINTNEXTLINE(modernize-loop-convert) + for (size_t idx = 0; idx < assemblerConstituentTypes_.size(); idx++) { + assemblerConstituentTypes_[idx]->ToDebugInfoType(ss); + if (idx != assemblerConstituentTypes_.size() - 1) { + ss << ","; + } + } + ss << "}"; } -bool ETSUnionType::EachTypeRelatedToSomeType(TypeRelation *relation, ETSUnionType *source, ETSUnionType *target) +static std::string GetAssemblerTypeString(Type *type) { - return std::all_of(source->constituentTypes_.begin(), source->constituentTypes_.end(), - [relation, target](auto *s) { return TypeRelatedToSomeType(relation, s, target); }); + std::stringstream ss; + type->ToAssemblerTypeWithRank(ss); + return ss.str(); } -bool ETSUnionType::TypeRelatedToSomeType(TypeRelation *relation, Type *source, ETSUnionType *target) +void ETSUnionType::InitAssemblerTypeCache(ETSChecker *checker) { - return std::any_of(target->constituentTypes_.begin(), target->constituentTypes_.end(), - [relation, source](auto *t) { return relation->IsIdenticalTo(source, t); }); + ES2PANDA_ASSERT(!assemblerConstituentTypes_.empty()); + std::stringstream ss; + if (assemblerConstituentTypes_.size() == 1) { + assemblerConstituentTypes_[0]->ToAssemblerTypeWithRank(ss); + } else { + ss << "{U"; + for (size_t idx = 0; idx < assemblerConstituentTypes_.size(); idx++) { + if (idx != 0) { + ss << ","; + } + if (assemblerConstituentTypes_[idx]->IsETSNullType()) { + ss << compiler::Signatures::NULL_ASSEMBLY_TYPE; + continue; + } + assemblerConstituentTypes_[idx]->ToAssemblerTypeWithRank(ss); + } + ss << "}"; + } + assemblerTypeCache_ = util::UString(ss.str(), checker->ProgramAllocator()).View(); } -// This function computes effective runtime representation of union type -Type *ETSUnionType::ComputeAssemblerLUB(ETSChecker *checker, ETSUnionType *un) +void ETSUnionType::CanonicalizedAssemblerType(ETSChecker *checker) { - auto *const apparent = checker->GetApparentType(un); + auto *const apparent = checker->GetApparentType(this); if (!apparent->IsETSUnionType()) { - return apparent; + assemblerConstituentTypes_.push_back(apparent); + return; } - if (apparent != un) { - return apparent->AsETSUnionType()->assemblerLub_; + if (apparent != this) { + const auto &types = apparent->AsETSUnionType()->GetAssemblerTypes(); + assemblerConstituentTypes_.insert(assemblerConstituentTypes_.begin(), types.begin(), types.end()); + return; } - un = apparent->AsETSUnionType(); - - Type *lub = nullptr; - for (auto *t : un->ConstituentTypes()) { - if (t->IsTypeError()) { - return checker->GlobalTypeError(); - } - // NOTE(vpukhov): #19701 void refactoring - ES2PANDA_ASSERT(t->IsETSReferenceType() || t->IsETSVoidType()); - t = t->IsETSVoidType() ? checker->GlobalETSUndefinedType() : t; - if (lub == nullptr || lub->IsETSUndefinedType()) { - lub = t; + ES2PANDA_ASSERT(constituentTypes_.size() > 1); + bool hasNull = false; + for (auto *type : constituentTypes_) { + ES2PANDA_ASSERT(!type->IsETSUnionType()); + if (type->IsETSUndefinedType() || type->IsETSVoidType()) { continue; } - if (lub == t || t->IsETSUndefinedType()) { + if (type->IsETSNullType() && !hasNull) { + hasNull = true; + assemblerConstituentTypes_.push_back(type); continue; } - if (t->IsETSNullType()) { - return checker->GetGlobalTypesHolder()->GlobalETSObjectType(); + if (type->IsTypeError()) { + assemblerConstituentTypes_.clear(); + assemblerConstituentTypes_.push_back(checker->GlobalTypeError()); + return; } - if (t->IsETSObjectType() && lub->IsETSObjectType()) { - lub = checker->GetClosestCommonAncestor(lub->AsETSObjectType(), t->AsETSObjectType()); - } else if (t->IsETSArrayType() && lub->IsETSArrayType()) { - // NOTE: can compute "common(lub, t)[]" - return checker->GetGlobalTypesHolder()->GlobalETSObjectType(); - } else { - return checker->GetGlobalTypesHolder()->GlobalETSObjectType(); + auto found = + std::find_if(assemblerConstituentTypes_.begin(), assemblerConstituentTypes_.end(), + [&type](Type *t) { return GetAssemblerTypeString(type) == GetAssemblerTypeString(t); }); + if (found == assemblerConstituentTypes_.end()) { + assemblerConstituentTypes_.push_back(type); } } - return checker->GetNonConstantType(lub); + if (assemblerConstituentTypes_.empty()) { + assemblerConstituentTypes_.push_back(checker->GlobalETSObjectType()); + return; + } + if (assemblerConstituentTypes_.size() == 1) { + return; + } + + std::sort(assemblerConstituentTypes_.begin(), assemblerConstituentTypes_.end(), + [](Type *a, Type *b) { return GetAssemblerTypeString(a) < GetAssemblerTypeString(b); }); +} + +ETSUnionType::ETSUnionType(ETSChecker *checker, ArenaVector &&constituentTypes) + : Type(TypeFlag::ETS_UNION), + constituentTypes_(std::move(constituentTypes)), + assemblerConstituentTypes_(checker->ProgramAllocator()->Adapter()) +{ + ES2PANDA_ASSERT(constituentTypes_.size() > 1); + CanonicalizedAssemblerType(checker); + InitAssemblerTypeCache(checker); +} + +bool ETSUnionType::EachTypeRelatedToSomeType(TypeRelation *relation, ETSUnionType *source, ETSUnionType *target) +{ + return std::all_of(source->constituentTypes_.begin(), source->constituentTypes_.end(), + [relation, target](auto *s) { return TypeRelatedToSomeType(relation, s, target); }); +} + +bool ETSUnionType::TypeRelatedToSomeType(TypeRelation *relation, Type *source, ETSUnionType *target) +{ + return std::any_of(target->constituentTypes_.begin(), target->constituentTypes_.end(), + [relation, source](auto *t) { return relation->IsIdenticalTo(source, t); }); } void ETSUnionType::Identical(TypeRelation *relation, Type *other) @@ -138,16 +189,7 @@ void ETSUnionType::RelationTarget(TypeRelation *relation, Type *source, RelFN co return; } - if (std::any_of(constituentTypes_.begin(), constituentTypes_.end(), - [relation, refsource, relFn](auto *t) { return relFn(relation, refsource, t); })) { - if (refsource != source) { - // Some nodes can have both boxing and unboxing flags set. When applying them, first the unboxing happens - // (then a possible primitive conversion), and boxing at last. - // NOTE (smartin): when boxing/unboxing is moved to a lowering, review this part of the code - const auto mergedBoxingFlags = - relation->GetNode()->GetBoxingUnboxingFlags() | checker->GetBoxingFlag(refsource); - relation->GetNode()->SetBoxingUnboxingFlags(mergedBoxingFlags); - } + if (AnyOfConstituentTypes([relation, refsource, relFn](auto *t) { return relFn(relation, refsource, t); })) { relation->Result(true); return; } @@ -162,8 +204,8 @@ void ETSUnionType::RelationTarget(TypeRelation *relation, Type *source, RelFN co if (relFn(relation, source, checker->MaybeUnboxType(ct))) { if (related) { AmbiguousUnionOperation(relation); + return; } - relation->GetNode()->SetBoxingUnboxingFlags(checker->GetBoxingFlag(ct)); related = true; } } @@ -173,98 +215,57 @@ void ETSUnionType::RelationTarget(TypeRelation *relation, Type *source, RelFN co bool ETSUnionType::AssignmentSource(TypeRelation *relation, Type *target) { - auto *const checker = relation->GetChecker()->AsETSChecker(); - if (target->HasTypeFlag(TypeFlag::PRIMITIVE)) { - if (!relation->ApplyUnboxing()) { - return relation->Result(false); - } - relation->GetNode()->SetBoxingUnboxingFlags( - relation->GetChecker()->AsETSChecker()->GetUnboxingFlag(checker->MaybeUnboxType(target))); - } - - return relation->Result(std::all_of(constituentTypes_.begin(), constituentTypes_.end(), - [relation, target](auto *t) { return relation->IsAssignableTo(t, target); })); + ES2PANDA_ASSERT(!target->IsETSPrimitiveType()); + return relation->Result( + AllOfConstituentTypes([relation, target](auto *t) { return relation->IsAssignableTo(t, target); })); } void ETSUnionType::AssignmentTarget(TypeRelation *relation, Type *source) { - auto const relFn = []([[maybe_unused]] TypeRelation *rel, [[maybe_unused]] Type *src, [[maybe_unused]] Type *tgt) { - return rel->IsAssignableTo(src, tgt); - }; + auto const relFn = [](TypeRelation *rel, Type *src, Type *tgt) { return rel->IsAssignableTo(src, tgt); }; RelationTarget(relation, source, relFn); } void ETSUnionType::Cast(TypeRelation *relation, Type *target) { - auto *const checker = relation->GetChecker()->AsETSChecker(); - - if (target->HasTypeFlag(TypeFlag::PRIMITIVE)) { - if (!relation->ApplyUnboxing()) { - relation->Result(false); - return; - } - - relation->GetNode()->SetBoxingUnboxingFlags( - relation->GetChecker()->AsETSChecker()->GetUnboxingFlag(checker->MaybeUnboxType(target))); - } + ES2PANDA_ASSERT(!target->IsETSPrimitiveType()); if (relation->InCastingContext()) { - relation->Result(std::any_of(constituentTypes_.begin(), constituentTypes_.end(), - [relation, target](auto *t) { return relation->IsCastableTo(t, target); })); + relation->Result( + AnyOfConstituentTypes([relation, target](auto *t) { return relation->IsCastableTo(t, target); })); return; } - relation->Result(std::all_of(constituentTypes_.begin(), constituentTypes_.end(), - [relation, target](auto *t) { return relation->IsCastableTo(t, target); })); + relation->Result(AllOfConstituentTypes([relation, target](auto *t) { return relation->IsCastableTo(t, target); })); } void ETSUnionType::CastTarget(TypeRelation *relation, Type *source) { - auto const relFn = []([[maybe_unused]] TypeRelation *rel, [[maybe_unused]] Type *src, [[maybe_unused]] Type *tgt) { - return rel->IsCastableTo(src, tgt); - }; + auto const relFn = [](TypeRelation *rel, Type *src, Type *tgt) -> bool { return rel->IsCastableTo(src, tgt); }; RelationTarget(relation, source, relFn); } -static auto constexpr ETS_NORMALIZABLE_NUMERIC = TypeFlag(TypeFlag::ETS_NUMERIC); - -static Type *LargestNumeric(Type *t1, Type *t2) -{ - static_assert(TypeFlag::DOUBLE > TypeFlag::FLOAT); - static_assert(TypeFlag::FLOAT > TypeFlag::LONG); - static_assert(TypeFlag::LONG > TypeFlag::INT); - static_assert(TypeFlag::INT > TypeFlag::SHORT); - static_assert(TypeFlag::SHORT > TypeFlag::BYTE); - - auto v1 = t1->TypeFlags() & ETS_NORMALIZABLE_NUMERIC; - auto v2 = t2->TypeFlags() & ETS_NORMALIZABLE_NUMERIC; - ES2PANDA_ASSERT(helpers::math::IsPowerOfTwo(v1)); - ES2PANDA_ASSERT(helpers::math::IsPowerOfTwo(v2)); - return v1 > v2 ? t1 : t2; -} - static std::optional TryMergeTypes(TypeRelation *relation, Type *const t1, Type *const t2) { - auto checker = relation->GetChecker()->AsETSChecker(); - auto never = checker->GetGlobalTypesHolder()->GlobalETSNeverType(); + auto *const checker = relation->GetChecker()->AsETSChecker(); + auto *const never = checker->GetGlobalTypesHolder()->GlobalETSNeverType(); + if (relation->IsSupertypeOf(t1, t2) || t2 == never) { return t1; } if (relation->IsSupertypeOf(t2, t1) || t1 == never) { return t2; } - // NOTE(vpukhov): numerics - clarification required return std::nullopt; } void ETSUnionType::LinearizeAndEraseIdentical(TypeRelation *relation, ArenaVector &types) { - auto *const checker = relation->GetChecker()->AsETSChecker(); - // Linearize - size_t const initialSz = types.size(); - for (size_t i = 0; i < initialSz; ++i) { + std::size_t const initialSz = types.size(); + for (std::size_t i = 0U; i < initialSz; ++i) { auto ct = types[i]; + ES2PANDA_ASSERT(ct != nullptr); if (ct->IsETSUnionType()) { auto const &otherTypes = ct->AsETSUnionType()->ConstituentTypes(); types.insert(types.end(), otherTypes.begin(), otherTypes.end()); @@ -273,50 +274,32 @@ void ETSUnionType::LinearizeAndEraseIdentical(TypeRelation *relation, ArenaVecto types[i] = nullptr; } } - size_t insPos = 0; - for (size_t i = 0; i < types.size(); ++i) { - auto *const ct = types[i]; - if (ct != nullptr) { - types[insPos++] = ct; - } - } - types.resize(insPos); - // Promote primitives - for (auto &ct : types) { - ct = checker->MaybeBoxType(ct); - } + // Remove nullptrs + types.erase(std::remove_if(types.begin(), types.end(), [](Type *ct) { return ct == nullptr; }), types.end()); + // Reduce subtypes for (auto cmpIt = types.begin(); cmpIt != types.end(); ++cmpIt) { - for (auto it = std::next(cmpIt); it != types.end();) { - auto merged = TryMergeTypes(relation, *cmpIt, *it); - if (!merged) { + auto it = std::next(cmpIt); + while (it != types.end()) { + if (auto merged = TryMergeTypes(relation, *cmpIt, *it); !merged) { ++it; - continue; - } - - if (merged == *cmpIt) { + } else if (*merged == *cmpIt) { it = types.erase(it); - continue; + } else { + cmpIt = types.erase(cmpIt); + it = cmpIt != types.end() ? std::next(cmpIt) : cmpIt; } - - cmpIt = types.erase(cmpIt); - it = std::next(cmpIt); } } } void ETSUnionType::NormalizeTypes(TypeRelation *relation, ArenaVector &types) { - if (types.size() == 1) { - return; - } - auto const isNumeric = [](auto *ct) { return ct->HasTypeFlag(ETS_NORMALIZABLE_NUMERIC); }; - if (std::all_of(types.begin(), types.end(), isNumeric)) { - types[0] = std::accumulate(std::next(types.begin()), types.end(), types[0], LargestNumeric); - types.resize(1); + if (types.size() == 1U) { return; } + LinearizeAndEraseIdentical(relation, types); } @@ -325,7 +308,7 @@ Type *ETSUnionType::Instantiate(ArenaAllocator *allocator, TypeRelation *relatio auto *const checker = relation->GetChecker()->AsETSChecker(); ArenaVector copiedConstituents(allocator->Adapter()); for (auto *it : constituentTypes_) { - copiedConstituents.push_back(it->Instantiate(allocator, relation, globalTypes)); + copiedConstituents.emplace_back(it->Instantiate(allocator, relation, globalTypes)); } return checker->CreateETSUnionType(std::move(copiedConstituents)); } @@ -335,14 +318,14 @@ Type *ETSUnionType::Substitute(TypeRelation *relation, const Substitution *subst auto *const checker = relation->GetChecker()->AsETSChecker(); ArenaVector substitutedConstituents(checker->Allocator()->Adapter()); for (auto *ctype : constituentTypes_) { - substitutedConstituents.push_back(ctype->Substitute(relation, substitution)); + substitutedConstituents.emplace_back(ctype->Substitute(relation, substitution)); } return checker->CreateETSUnionType(std::move(substitutedConstituents)); } void ETSUnionType::IsSupertypeOf(TypeRelation *relation, Type *source) { - for (auto const &ctype : ConstituentTypes()) { + for (auto const *ctype : ConstituentTypes()) { if (relation->IsSupertypeOf(ctype, source)) { return; } @@ -351,7 +334,7 @@ void ETSUnionType::IsSupertypeOf(TypeRelation *relation, Type *source) void ETSUnionType::IsSubtypeOf(TypeRelation *relation, Type *target) { - for (auto const &ctype : ConstituentTypes()) { + for (auto const *ctype : ConstituentTypes()) { if (!relation->IsSupertypeOf(target, ctype)) { return; } @@ -360,138 +343,75 @@ void ETSUnionType::IsSubtypeOf(TypeRelation *relation, Type *target) void ETSUnionType::CheckVarianceRecursively(TypeRelation *relation, VarianceFlag varianceFlag) { - for (auto const &ctype : ConstituentTypes()) { + for (auto *ctype : ConstituentTypes()) { relation->CheckVarianceRecursively(ctype, relation->TransferVariant(varianceFlag, VarianceFlag::COVARIANT)); } } -bool ETSUnionType::IsAssignableType(checker::Type *sourceType) const noexcept -{ - if (sourceType->IsETSTypeParameter() || sourceType->IsTypeError()) { - return true; - } - - if (sourceType->IsETSUnionType() || sourceType->IsETSArrayType() || sourceType->IsETSFunctionType()) { - return true; - } - - return false; -} - -checker::Type *ETSUnionType::HandleNumericPrecedence( - checker::ETSChecker *checker, checker::ETSObjectType *objectType, checker::Type *sourceType, - std::map &numericTypes) const noexcept -{ - auto const sourceId = - (objectType != nullptr) ? ETSObjectType::GetPrecedence(checker, objectType) : Type::GetPrecedence(sourceType); - if (sourceId > 0U) { - for (auto const [id, type] : numericTypes) { - if (id >= sourceId) { - return type; - } - } - if (sourceType->IsConstantType() && !numericTypes.empty()) { - return numericTypes.begin()->second; - } - } - return nullptr; -} - -// NOTE! When calling this method we assume that 'AssignmentTarget(...)' check was passes successfully, -// thus the required assignable type always exists. -checker::Type *ETSUnionType::GetAssignableType(checker::ETSChecker *checker, checker::Type *sourceType) const noexcept +// ATTENTION! When calling this method we assume that 'AssignmentTarget(...)' check was passes successfully, +// thus the required assignable type (or corresponding supertype) always exists. +checker::Type *ETSUnionType::GetAssignableType(checker::ETSChecker *checker, checker::Type *sourceType, + [[maybe_unused]] std::optional value) const noexcept { - if (IsAssignableType(sourceType)) { - return sourceType; - } - - auto *objectType = sourceType->IsETSObjectType() ? sourceType->AsETSObjectType() - : sourceType->IsETSTupleType() ? sourceType->AsETSTupleType()->GetWrapperType() - : nullptr; - std::map numericTypes {}; - bool const isBool = objectType != nullptr ? objectType->HasObjectFlag(ETSObjectFlags::BUILTIN_BOOLEAN) - : sourceType->HasTypeFlag(TypeFlag::ETS_BOOLEAN); - bool const isChar = objectType != nullptr ? objectType->HasObjectFlag(ETSObjectFlags::BUILTIN_CHAR) - : sourceType->HasTypeFlag(TypeFlag::CHAR); - - if (objectType != nullptr) { - if (objectType->IsETSResizableArrayType() || sourceType->IsETSTupleType()) { - checker::Type *assignableType = GetAssignableBuiltinType(checker, objectType, isBool, isChar, numericTypes); - // NOTE: For array and tuple types, they may be readonly, so we cannot simply use the it - if (assignableType != nullptr && assignableType->HasTypeFlag(TypeFlag::READONLY)) { - return assignableType; - } - } - if ((!objectType->HasObjectFlag(ETSObjectFlags::BUILTIN_TYPE) || - objectType->HasObjectFlag(ETSObjectFlags::BUILTIN_STRING))) { - // NOTE: here wo don't cast the actual type to possible base type using in the union, but use it as is! - return sourceType; + for (auto *ctype : ConstituentTypes()) { + if (checker->Relation()->IsSupertypeOf(ctype, sourceType)) { + return ctype; } } - if (checker::Type *assignableType = GetAssignableBuiltinType(checker, objectType, isBool, isChar, numericTypes); - assignableType != nullptr) { - return assignableType; + if (!sourceType->IsBuiltinNumeric()) { + return nullptr; } - if (auto *assignableType = HandleNumericPrecedence(checker, objectType, sourceType, numericTypes)) { + // NOTE (DZ): we still keep 'numericTypes` collection for possible processing cases like 'let x: short|double = 1` + // Waiting for complete clearness in spec - now return the highest type in such a case or type itself. + // Maybe 'value' will be used for this purpose + std::map numericTypes {}; + auto *objectType = sourceType->AsETSObjectType(); + if (auto *assignableType = GetAssignableBuiltinType(checker, objectType, numericTypes); assignableType != nullptr) { return assignableType; } - for (auto *constituentType : constituentTypes_) { - if (constituentType->IsETSObjectType() && constituentType->AsETSObjectType()->IsGlobalETSObjectType()) { - return constituentType; - } + if (!numericTypes.empty()) { + return (*std::prev(numericTypes.end())).second; } - - return checker->GlobalTypeError(); + return nullptr; } checker::Type *ETSUnionType::GetAssignableBuiltinType( - checker::ETSChecker *checker, checker::ETSObjectType *sourceType, bool const isBool, bool const isChar, - std::map &numericTypes) const noexcept + checker::ETSChecker *checker, checker::ETSObjectType *sourceType, + std::map &numericTypes) const noexcept { - checker::Type *assignableType = nullptr; - for (auto *constituentType : constituentTypes_) { if (!constituentType->IsETSObjectType() && !constituentType->IsETSTupleType()) { continue; } - auto *const type = constituentType->IsETSTupleType() ? constituentType->AsETSTupleType()->GetWrapperType() - : constituentType->AsETSObjectType(); - if (type->HasObjectFlag(ETSObjectFlags::BUILTIN_BOOLEAN)) { - if (isBool) { - assignableType = constituentType; - break; - } - } else if (type->HasObjectFlag(ETSObjectFlags::BUILTIN_CHAR)) { - if (isChar) { - assignableType = constituentType; - break; - } - } else if (auto const id = ETSObjectType::GetPrecedence(checker, type); id > 0U) { - numericTypes.emplace(id, constituentType); - } else if (assignableType == nullptr && sourceType != nullptr && - checker->Relation()->IsSupertypeOf(type, sourceType)) { - assignableType = constituentType; + ETSObjectType *objectType = constituentType->AsETSObjectType(); + if (!objectType->IsBuiltinNumeric()) { + continue; } + + if (checker->Relation()->IsIdenticalTo(objectType, sourceType)) { + return sourceType; + } + + numericTypes.emplace(ETSObjectType::GetPrecedence(checker, objectType), objectType); } - return assignableType; + return nullptr; } -bool ETSUnionType::ExtractType(checker::ETSChecker *checker, checker::ETSObjectType *sourceType, +bool ETSUnionType::ExtractType(checker::ETSChecker *checker, checker::Type *source, ArenaVector &unionTypes) noexcept { std::map::const_iterator> numericTypes {}; - bool const isBool = sourceType->HasObjectFlag(ETSObjectFlags::BUILTIN_BOOLEAN); - bool const isChar = sourceType->HasObjectFlag(ETSObjectFlags::BUILTIN_CHAR); + source = checker->GetNonConstantType(source); bool rc = false; auto it = unionTypes.cbegin(); while (it != unionTypes.cend()) { - auto *constituentType = *it; + auto *constituentType = (*it)->MaybeBaseTypeOfGradualType(); // Because 'instanceof' expression does not check for type parameters, then for generic types we should // consider that expressions like 'SomeType' and 'SomeType' are identical for smart casting. // We also have to pass through all the union to process cases like 'C|A|B|C|undefined` @@ -499,30 +419,22 @@ bool ETSUnionType::ExtractType(checker::ETSChecker *checker, checker::ETSObjectT constituentType = constituentType->AsETSTypeParameter()->GetConstraintType(); } else if (constituentType->HasTypeFlag(checker::TypeFlag::GENERIC)) { constituentType = constituentType->Clone(checker); + ES2PANDA_ASSERT(constituentType != nullptr); constituentType->RemoveTypeFlag(checker::TypeFlag::GENERIC); } - if (checker->Relation()->IsIdenticalTo(constituentType, sourceType)) { + if (checker->Relation()->IsIdenticalTo(constituentType, source)) { rc = true; - it = unionTypes.erase(it); + if (!(*it)->IsETSTypeParameter()) { + it = unionTypes.erase(it); + } continue; } - if (checker->Relation()->IsSupertypeOf(constituentType, sourceType)) { + if (checker->Relation()->IsSupertypeOf(constituentType, source)) { rc = true; - } else if (!rc && constituentType->IsETSObjectType()) { - auto *const objectType = (*it)->AsETSObjectType(); - if (isBool && objectType->HasObjectFlag(ETSObjectFlags::BUILTIN_BOOLEAN)) { - unionTypes.erase(it); - return true; - } - - if (isChar && objectType->HasObjectFlag(ETSObjectFlags::BUILTIN_CHAR)) { - unionTypes.erase(it); - return true; - } - - if (auto const id = ETSObjectType::GetPrecedence(checker, objectType); id > 0U) { + } else if (!rc && constituentType->IsBuiltinNumeric()) { + if (auto const id = ETSObjectType::GetPrecedence(checker, constituentType->AsETSObjectType()); id > 0U) { numericTypes.emplace(id, it); } } @@ -534,76 +446,46 @@ bool ETSUnionType::ExtractType(checker::ETSChecker *checker, checker::ETSObjectT return true; } - if (auto const sourceId = ETSObjectType::GetPrecedence(checker, sourceType); sourceId > 0U) { - for (auto const [id, it1] : numericTypes) { - if (id >= sourceId) { - unionTypes.erase(it1); - return true; - } - } + if (source->IsBuiltinNumeric() && !numericTypes.empty()) { + unionTypes.erase((*std::prev(numericTypes.end())).second); + return true; } return false; } -bool ETSUnionType::ExtractType(checker::ETSChecker *checker, checker::ETSArrayType *sourceType, - ArenaVector &unionTypes) noexcept -{ - auto it = unionTypes.cbegin(); - - bool rc = false; - while (it != unionTypes.cend()) { - auto *constituentType = *it; - - if (constituentType->IsETSTypeParameter()) { - constituentType = constituentType->AsETSTypeParameter()->GetConstraintType(); - } - - if (checker->Relation()->IsIdenticalTo(constituentType, sourceType)) { - rc = true; - unionTypes.erase(it); - continue; - } - if (checker->Relation()->IsSupertypeOf(constituentType, sourceType)) { - rc = true; - } - ++it; - } - - return rc; -} - std::pair ETSUnionType::GetComplimentaryType(ETSChecker *const checker, checker::Type *sourceType) { ArenaVector unionTypes(checker->Allocator()->Adapter()); - for (auto *it : constituentTypes_) { - unionTypes.emplace_back(it); + for (auto *ct : constituentTypes_) { + unionTypes.emplace_back(ct->Clone(checker)); } - bool ok = true; - if (sourceType->IsETSUnionType()) { - for (auto *const constituentType : sourceType->AsETSUnionType()->ConstituentTypes()) { - if (ok = ExtractType(checker, constituentType->AsETSObjectType(), unionTypes); !ok) { - break; - } + auto const extractType = [checker, &unionTypes](Type *&type) -> bool { + ES2PANDA_ASSERT(!type->IsETSPrimitiveType()); + if (type->IsETSEnumType()) { + return true; } - } else if (sourceType->IsETSArrayType()) { - ok = ExtractType(checker, sourceType->AsETSArrayType(), unionTypes); - } else { - // NOTE(vpukhov): #19701 void refactoring - if (sourceType->IsETSPrimitiveType() && !sourceType->IsETSVoidType()) { - sourceType = checker->MaybeBoxInRelation(sourceType); - } else if (sourceType->HasTypeFlag(checker::TypeFlag::GENERIC)) { + if (type->HasTypeFlag(checker::TypeFlag::GENERIC)) { // Because 'instanceof' expression does not check for type parameters, then for generic types we should // consider that expressions like 'SomeType' and 'SomeType' are identical for smart casting. - sourceType = sourceType->Clone(checker); - sourceType->RemoveTypeFlag(checker::TypeFlag::GENERIC); + type = type->Clone(checker); + type->RemoveTypeFlag(checker::TypeFlag::GENERIC); } + return ExtractType(checker, type, unionTypes); + }; + + bool ok = true; - if (sourceType->IsETSObjectType()) { - ok = ExtractType(checker, sourceType->AsETSObjectType(), unionTypes); + if (sourceType->IsETSUnionType()) { + for (auto *constituentType : sourceType->AsETSUnionType()->ConstituentTypes()) { + if (ok = extractType(constituentType); !ok) { + break; + } } + } else { + ok = extractType(sourceType); } if (!ok) { @@ -611,7 +493,9 @@ std::pair ETSUnionType::GetComplimentaryType(E } checker::Type *complimentaryType; - if (unionTypes.size() == 1U) { + if (auto const size = unionTypes.size(); size == 0U) { + complimentaryType = checker->GetGlobalTypesHolder()->GlobalETSNeverType(); + } else if (size == 1U) { complimentaryType = unionTypes.front(); } else { complimentaryType = checker->CreateETSUnionType(std::move(unionTypes)); @@ -620,145 +504,24 @@ std::pair ETSUnionType::GetComplimentaryType(E return std::make_pair(sourceType, complimentaryType); } -Type *ETSUnionType::FindTypeIsCastableToThis(ir::Expression *node, TypeRelation *relation, Type *source) const -{ - ES2PANDA_ASSERT(node); - bool nodeWasSet = false; - if (relation->GetNode() == nullptr) { - nodeWasSet = true; - relation->SetNode(node); - } - // Prioritize object to object conversion - auto it = std::find_if(constituentTypes_.begin(), constituentTypes_.end(), [relation, source](Type *target) { - relation->IsCastableTo(source, target); - return relation->IsTrue() && source->IsETSReferenceType() && target->IsETSReferenceType(); - }); - if (it != constituentTypes_.end()) { - if (nodeWasSet) { - relation->SetNode(nullptr); - } - return *it; - } - it = std::find_if(constituentTypes_.begin(), constituentTypes_.end(), [relation, source](Type *target) { - relation->IsCastableTo(source, target); - return relation->IsTrue(); - }); - if (nodeWasSet) { - relation->SetNode(nullptr); - } - if (it != constituentTypes_.end()) { - return *it; - } - return nullptr; -} - -Type *ETSUnionType::FindTypeIsCastableToSomeType(ir::Expression *node, TypeRelation *relation, Type *target) const -{ - ES2PANDA_ASSERT(node); - bool nodeWasSet = false; - if (relation->GetNode() == nullptr) { - nodeWasSet = true; - relation->SetNode(node); - relation->SetFlags(TypeRelationFlag::CASTING_CONTEXT); - } - auto isCastablePred = [](TypeRelation *r, Type *sourceType, Type *targetType) { - if (targetType->IsETSUnionType()) { - auto *foundTargetType = targetType->AsETSUnionType()->FindTypeIsCastableToThis(r->GetNode(), r, sourceType); - r->Result(foundTargetType != nullptr); - } else { - r->IsCastableTo(sourceType, targetType); - } - return r->IsTrue(); - }; - // Prioritize object to object conversion - auto it = std::find_if(constituentTypes_.begin(), constituentTypes_.end(), - [relation, target, &isCastablePred](Type *source) { - return isCastablePred(relation, source, target) && source->IsETSReferenceType() && - target->IsETSReferenceType(); - }); // CC-OFF(G.FMT.02) project code style - if (it != constituentTypes_.end()) { - if (nodeWasSet) { - relation->SetNode(nullptr); - relation->RemoveFlags(TypeRelationFlag::CASTING_CONTEXT); - } - return *it; - } - it = std::find_if( - constituentTypes_.begin(), constituentTypes_.end(), - [relation, target, &isCastablePred](Type *source) { return isCastablePred(relation, source, target); }); - if (nodeWasSet) { - relation->SetNode(nullptr); - relation->RemoveFlags(TypeRelationFlag::CASTING_CONTEXT); - } - if (it != constituentTypes_.end()) { - return *it; - } - return nullptr; -} - -Type *ETSUnionType::FindUnboxableType() const +Type *ETSUnionType::FindUnboxableType() const noexcept { - auto it = std::find_if(constituentTypes_.begin(), constituentTypes_.end(), - [](Type *t) { return t->IsETSUnboxableObject(); }); - if (it != constituentTypes_.end()) { - return *it; - } - return nullptr; -} - -bool ETSUnionType::HasObjectType(ETSObjectFlags flag) const -{ - auto it = std::find_if(constituentTypes_.begin(), constituentTypes_.end(), [flag](Type *t) { - return t->IsETSObjectType() && t->AsETSObjectType()->HasObjectFlag(flag); - }); - return it != constituentTypes_.end(); -} - -Type *ETSUnionType::FindExactOrBoxedType(ETSChecker *checker, Type *const type) const -{ - auto it = std::find_if(constituentTypes_.begin(), constituentTypes_.end(), [checker, type](Type *ct) { - if (ct->IsETSUnboxableObject()) { - auto *const unboxedCt = checker->MaybeUnboxInRelation(ct); - return unboxedCt == type; - } - return ct == type; - }); - if (it != constituentTypes_.end()) { - return *it; - } - return nullptr; -} - -std::tuple ETSUnionType::ResolveConditionExpr() const -{ - if (PossiblyETSString()) { - return {false, false}; - } - if (std::all_of(ConstituentTypes().begin(), ConstituentTypes().end(), - [](checker::Type const *ct) { return ct->DefinitelyETSNullish(); })) { - return {true, false}; - } - // We have to test if union can contain builtin numerics or string types to infer "true" - return {false, false}; + return FindSpecificType([](Type *t) { return t->IsETSUnboxableObject(); }); } -bool ETSUnionType::HasType(Type *type) const -{ - for (const auto &cType : constituentTypes_) { - if (cType == type) { - return true; - } - } - return false; -} - -bool ETSUnionType::IsOverlapWith(TypeRelation *relation, Type *type) +bool ETSUnionType::IsOverlapWith(TypeRelation *relation, Type const *type) const noexcept { // NOTE(aakmaev): replace this func with intersection type when it will be implemented - for (auto const &ct : ConstituentTypes()) { + for (auto *ct : constituentTypes_) { if (type->IsETSUnionType() && type->AsETSUnionType()->IsOverlapWith(relation, ct)) { return true; } + if (type->IsETSObjectType() && ct->IsETSObjectType()) { + if (type->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_NUMERIC) && + ct->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_NUMERIC)) { + return true; + } + } if (relation->IsSupertypeOf(ct, type) || relation->IsSupertypeOf(type, ct)) { return true; } @@ -766,11 +529,11 @@ bool ETSUnionType::IsOverlapWith(TypeRelation *relation, Type *type) return false; } -ArenaVector ETSUnionType::GetNonConstantTypes(ETSChecker *checker, const ArenaVector &types) +ArenaVector ETSUnionType::GetNonConstantTypes(ETSChecker *checker) const noexcept { ArenaVector nonConstTypes(checker->Allocator()->Adapter()); - for (const auto &ct : types) { - nonConstTypes.push_back(checker->GetNonConstantType(ct)); + for (auto *ct : constituentTypes_) { + nonConstTypes.emplace_back(checker->GetNonConstantType(ct)); } return nonConstTypes; } diff --git a/ets2panda/checker/types/ets/etsUnionType.h b/ets2panda/checker/types/ets/etsUnionType.h index 12ae980aec9d686f2561d43f4309aec0d3710229..71c9ac8601f4de50b818fac6c149ee28950068cb 100644 --- a/ets2panda/checker/types/ets/etsUnionType.h +++ b/ets2panda/checker/types/ets/etsUnionType.h @@ -45,39 +45,47 @@ public: void IsSupertypeOf(TypeRelation *relation, Type *source) override; void IsSubtypeOf(TypeRelation *relation, Type *target) override; void CheckVarianceRecursively(TypeRelation *relation, VarianceFlag varianceFlag) override; - Type *FindTypeIsCastableToThis(ir::Expression *node, TypeRelation *relation, Type *source) const; - Type *FindTypeIsCastableToSomeType(ir::Expression *node, TypeRelation *relation, Type *target) const; - Type *FindUnboxableType() const; - bool HasObjectType(ETSObjectFlags flag) const; - bool HasType(Type *type) const; + [[nodiscard]] Type *FindUnboxableType() const noexcept; - bool IsOverlapWith(TypeRelation *relation, Type *type); - - Type *FindExactOrBoxedType(ETSChecker *checker, Type *type) const; + [[nodiscard]] bool IsOverlapWith(TypeRelation *relation, Type const *type) const noexcept; static void NormalizeTypes(TypeRelation *relation, ArenaVector &types); - static ArenaVector GetNonConstantTypes(ETSChecker *checker, const ArenaVector &types); - - std::tuple ResolveConditionExpr() const override; + [[nodiscard]] ArenaVector GetNonConstantTypes(ETSChecker *checker) const noexcept; - // Do not use it anywhere except codegen - Type *GetAssemblerLUB() const + const util::StringView &GetAssemblerType() const { - return assemblerLub_; + return assemblerTypeCache_; } template - bool AllOfConstituentTypes(UnaryPredicate p) const + [[nodiscard]] bool AllOfConstituentTypes(UnaryPredicate p) const noexcept { return std::all_of(constituentTypes_.cbegin(), constituentTypes_.cend(), p); } - checker::Type *HandleNumericPrecedence(checker::ETSChecker *checker, checker::ETSObjectType *objectType, - checker::Type *sourceType, - std::map &numericTypes) const noexcept; - [[nodiscard]] checker::Type *GetAssignableType(ETSChecker *checker, checker::Type *sourceType) const noexcept; + template + [[nodiscard]] bool AnyOfConstituentTypes(UnaryPredicate p) const noexcept + { + return std::any_of(constituentTypes_.cbegin(), constituentTypes_.cend(), p); + } + + template + [[nodiscard]] Type *FindSpecificType(UnaryPredicate p) const noexcept + { + auto const it = std::find_if(constituentTypes_.cbegin(), constituentTypes_.cend(), p); + return it != constituentTypes_.cend() ? *it : nullptr; + } + + template + [[nodiscard]] bool HasSpecificType(UnaryPredicate p) const noexcept + { + return FindSpecificType(p) != nullptr; + } + + [[nodiscard]] checker::Type *GetAssignableType(ETSChecker *checker, checker::Type *sourceType, + std::optional value) const noexcept; [[nodiscard]] std::pair GetComplimentaryType(ETSChecker *checker, checker::Type *sourceType); @@ -89,21 +97,24 @@ private: void RelationTarget(TypeRelation *relation, Type *source, RelFN const &relFn); static void LinearizeAndEraseIdentical(TypeRelation *relation, ArenaVector &types); - [[nodiscard]] static bool ExtractType(ETSChecker *checker, checker::ETSObjectType *sourceType, - ArenaVector &unionTypes) noexcept; - [[nodiscard]] static bool ExtractType(ETSChecker *checker, checker::ETSArrayType *sourceType, + [[nodiscard]] static bool ExtractType(ETSChecker *checker, checker::Type *source, ArenaVector &unionTypes) noexcept; [[nodiscard]] checker::Type *GetAssignableBuiltinType( - checker::ETSChecker *checker, checker::ETSObjectType *sourceType, bool isBool, bool isChar, - std::map &numericTypes) const noexcept; + checker::ETSChecker *checker, checker::ETSObjectType *sourceType, + std::map &numericTypes) const noexcept; - bool IsAssignableType(checker::Type *sourceType) const noexcept; + void CanonicalizedAssemblerType(ETSChecker *checker); + void InitAssemblerTypeCache(ETSChecker *checker); - static Type *ComputeAssemblerLUB(ETSChecker *checker, ETSUnionType *un); + const ArenaVector &GetAssemblerTypes() const + { + return assemblerConstituentTypes_; + } ArenaVector const constituentTypes_; - Type *assemblerLub_ {nullptr}; + ArenaVector assemblerConstituentTypes_; + util::StringView assemblerTypeCache_; }; } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/ets/etsVoidType.cpp b/ets2panda/checker/types/ets/etsVoidType.cpp index bb3e90fb257d0bc0fb0a69f895d449c6e7b0192f..0fe7ede62002e0d284a5238d309d5957cef10b3d 100644 --- a/ets2panda/checker/types/ets/etsVoidType.cpp +++ b/ets2panda/checker/types/ets/etsVoidType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -23,6 +23,11 @@ void ETSVoidType::Identical(TypeRelation *relation, Type *other) } } +void ETSVoidType::IsSupertypeOf(TypeRelation *const relation, Type *source) +{ + relation->Result(source->IsETSUndefinedType()); +} + bool ETSVoidType::AssignmentSource(TypeRelation *relation, Type *target) { // NOTE(vpukhov): #19701 void refactoring diff --git a/ets2panda/checker/types/ets/etsVoidType.h b/ets2panda/checker/types/ets/etsVoidType.h index bf6f9fcf7ff8261ae4ffdec8213aa4f790a524e2..845d638d89b8a49fd592686f29dcbba5ea15f5ba 100644 --- a/ets2panda/checker/types/ets/etsVoidType.h +++ b/ets2panda/checker/types/ets/etsVoidType.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -26,6 +26,7 @@ public: void Identical(TypeRelation *relation, Type *other) override; void AssignmentTarget(TypeRelation *relation, Type *source) override; bool AssignmentSource(TypeRelation *relation, Type *target) override; + void IsSupertypeOf(TypeRelation *relation, Type *source) override; Type *Instantiate(ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes) override; void ToString(std::stringstream &ss, [[maybe_unused]] bool precise) const override diff --git a/ets2panda/checker/types/ets/floatType.cpp b/ets2panda/checker/types/ets/floatType.cpp index 7f69458b1896ea368a70785d9f2cf810d9c0f092..958f338480b0afa1b7787edfc1f443222202edb5 100644 --- a/ets2panda/checker/types/ets/floatType.cpp +++ b/ets2panda/checker/types/ets/floatType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,7 @@ #include "floatType.h" #include "checker/ets/conversion.h" -#include "checker/ets/narrowingWideningConverter.h" +#include "checker/ets/wideningConverter.h" namespace ark::es2panda::checker { void FloatType::Identical(TypeRelation *relation, Type *other) @@ -28,10 +28,7 @@ void FloatType::Identical(TypeRelation *relation, Type *other) void FloatType::AssignmentTarget(TypeRelation *relation, [[maybe_unused]] Type *source) { - if (relation->ApplyUnboxing()) { - relation->GetChecker()->AsETSChecker()->MaybeAddUnboxingFlagInRelation(relation, source, this); - } - NarrowingWideningConverter(relation->GetChecker()->AsETSChecker(), relation, this, source); + WideningConverter(relation->GetChecker()->AsETSChecker(), relation, this, source); } bool FloatType::AssignmentSource([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *target) @@ -57,38 +54,9 @@ void FloatType::Cast(TypeRelation *const relation, Type *const target) return; } - if (target->HasTypeFlag(TypeFlag::BYTE | TypeFlag::SHORT | TypeFlag::CHAR | TypeFlag::INT | TypeFlag::LONG)) { - conversion::NarrowingPrimitive(relation, this, target); - return; - } - - if (target->HasTypeFlag(TypeFlag::DOUBLE)) { - conversion::WideningPrimitive(relation, this, target); - return; - } - - if (target->HasTypeFlag(TypeFlag::ETS_OBJECT)) { - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_FLOAT)) { - conversion::Boxing(relation, this); - return; - } - - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_TYPE)) { - auto unboxedTarget = relation->GetChecker()->AsETSChecker()->MaybeUnboxInRelation(target); - if (unboxedTarget == nullptr) { - conversion::Forbidden(relation); - return; - } - Cast(relation, unboxedTarget); - if (relation->IsTrue()) { - conversion::Boxing(relation, unboxedTarget); - return; - } - conversion::Forbidden(relation); - return; - } - - conversion::BoxingWideningReference(relation, this, target->AsETSObjectType()); + if (target->HasTypeFlag(TypeFlag::ETS_OBJECT) && + target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_FLOAT)) { + conversion::Boxing(relation, this); return; } diff --git a/ets2panda/checker/types/ets/floatType.h b/ets2panda/checker/types/ets/floatType.h index 61f04f8e0b5b37eb34d2b1da22ac6f064d282b11..936effb4b0f1f59e8d5ccc5824f7e1653aab4277 100644 --- a/ets2panda/checker/types/ets/floatType.h +++ b/ets2panda/checker/types/ets/floatType.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -52,12 +52,6 @@ public: ss << compiler::Signatures::TYPE_DESCRIPTOR_FLOAT; } - std::tuple ResolveConditionExpr() const override - { - // isNan = !(value_ == value_) - return {IsConstantType(), (value_ != 0) && (value_ == value_)}; - } - private: UType value_ {0.0}; }; diff --git a/ets2panda/checker/types/ets/intType.cpp b/ets2panda/checker/types/ets/intType.cpp index c21e904b086e871881b70036dd39fd804a7eae0c..3587ee1bc0b071c21700acadf8ecc3315412f5a6 100644 --- a/ets2panda/checker/types/ets/intType.cpp +++ b/ets2panda/checker/types/ets/intType.cpp @@ -16,7 +16,7 @@ #include "intType.h" #include "checker/ets/conversion.h" -#include "checker/ets/narrowingWideningConverter.h" +#include "checker/ets/wideningConverter.h" namespace ark::es2panda::checker { void IntType::Identical(TypeRelation *relation, Type *other) @@ -28,10 +28,7 @@ void IntType::Identical(TypeRelation *relation, Type *other) void IntType::AssignmentTarget(TypeRelation *relation, [[maybe_unused]] Type *source) { - if (relation->ApplyUnboxing() && !relation->IsTrue()) { - relation->GetChecker()->AsETSChecker()->MaybeAddUnboxingFlagInRelation(relation, source, this); - } - NarrowingWideningConverter(relation->GetChecker()->AsETSChecker(), relation, this, source); + WideningConverter(relation->GetChecker()->AsETSChecker(), relation, this, source); } bool IntType::AssignmentSource(TypeRelation *relation, Type *target) @@ -57,38 +54,9 @@ void IntType::Cast(TypeRelation *const relation, Type *const target) return; } - if (target->HasTypeFlag(TypeFlag::BYTE | TypeFlag::SHORT | TypeFlag::CHAR)) { - conversion::NarrowingPrimitive(relation, this, target); - return; - } - - if (target->HasTypeFlag(TypeFlag::LONG | TypeFlag::FLOAT | TypeFlag::DOUBLE)) { - conversion::WideningPrimitive(relation, this, target); - return; - } - - if (target->HasTypeFlag(TypeFlag::ETS_OBJECT)) { - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_INT)) { - conversion::Boxing(relation, this); - return; - } - - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_TYPE)) { - auto unboxedTarget = relation->GetChecker()->AsETSChecker()->MaybeUnboxInRelation(target); - if (unboxedTarget == nullptr) { - conversion::Forbidden(relation); - return; - } - Cast(relation, unboxedTarget); - if (relation->IsTrue()) { - conversion::Boxing(relation, unboxedTarget); - return; - } - conversion::Forbidden(relation); - return; - } - - conversion::BoxingWideningReference(relation, this, target->AsETSObjectType()); + if (target->HasTypeFlag(TypeFlag::ETS_OBJECT) && + target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_INT)) { + conversion::Boxing(relation, this); return; } diff --git a/ets2panda/checker/types/ets/intType.h b/ets2panda/checker/types/ets/intType.h index b1583a869578ff5243ca051353b4a963b54698aa..835cc47d612c7010193530b2196075b5350085c6 100644 --- a/ets2panda/checker/types/ets/intType.h +++ b/ets2panda/checker/types/ets/intType.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -52,11 +52,6 @@ public: ss << compiler::Signatures::TYPE_DESCRIPTOR_INT; } - std::tuple ResolveConditionExpr() const override - { - return {IsConstantType(), value_ != 0}; - } - private: UType value_ {0}; }; diff --git a/ets2panda/checker/types/ets/longType.cpp b/ets2panda/checker/types/ets/longType.cpp index 7f4d080115b80bcfc8306baef6c79224046bd87c..7b8c5b34fae0af6e8144ecc4412a82528e8c93ba 100644 --- a/ets2panda/checker/types/ets/longType.cpp +++ b/ets2panda/checker/types/ets/longType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,7 @@ #include "longType.h" #include "checker/ets/conversion.h" -#include "checker/ets/narrowingWideningConverter.h" +#include "checker/ets/wideningConverter.h" namespace ark::es2panda::checker { void LongType::Identical(TypeRelation *relation, Type *other) @@ -28,10 +28,7 @@ void LongType::Identical(TypeRelation *relation, Type *other) void LongType::AssignmentTarget(TypeRelation *relation, [[maybe_unused]] Type *source) { - if (relation->ApplyUnboxing() && !relation->IsTrue()) { - relation->GetChecker()->AsETSChecker()->MaybeAddUnboxingFlagInRelation(relation, source, this); - } - NarrowingWideningConverter(relation->GetChecker()->AsETSChecker(), relation, this, source); + WideningConverter(relation->GetChecker()->AsETSChecker(), relation, this, source); } bool LongType::AssignmentSource([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *target) @@ -57,38 +54,9 @@ void LongType::Cast(TypeRelation *const relation, Type *const target) return; } - if (target->HasTypeFlag(TypeFlag::BYTE | TypeFlag::SHORT | TypeFlag::CHAR | TypeFlag::INT)) { - conversion::NarrowingPrimitive(relation, this, target); - return; - } - - if (target->HasTypeFlag(TypeFlag::FLOAT | TypeFlag::DOUBLE)) { - conversion::WideningPrimitive(relation, this, target); - return; - } - - if (target->HasTypeFlag(TypeFlag::ETS_OBJECT)) { - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_LONG)) { - conversion::Boxing(relation, this); - return; - } - - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_TYPE)) { - auto unboxedTarget = relation->GetChecker()->AsETSChecker()->MaybeUnboxInRelation(target); - if (unboxedTarget == nullptr) { - conversion::Forbidden(relation); - return; - } - Cast(relation, unboxedTarget); - if (relation->IsTrue()) { - conversion::Boxing(relation, unboxedTarget); - return; - } - conversion::Forbidden(relation); - return; - } - - conversion::BoxingWideningReference(relation, this, target->AsETSObjectType()); + if (target->HasTypeFlag(TypeFlag::ETS_OBJECT) && + target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_LONG)) { + conversion::Boxing(relation, this); return; } diff --git a/ets2panda/checker/types/ets/longType.h b/ets2panda/checker/types/ets/longType.h index 898b692072905d627d0f84b0138d0faf46161e87..0823bc7608f4840b9e2db740f130590ba8ee6cec 100644 --- a/ets2panda/checker/types/ets/longType.h +++ b/ets2panda/checker/types/ets/longType.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -52,11 +52,6 @@ public: ss << compiler::Signatures::TYPE_DESCRIPTOR_LONG; } - std::tuple ResolveConditionExpr() const override - { - return {IsConstantType(), value_ != 0}; - } - private: UType value_ {0}; }; diff --git a/ets2panda/checker/types/ets/shortType.cpp b/ets2panda/checker/types/ets/shortType.cpp index bc2011294ba2ee8c3f735743c3f027abcbdacdc7..c7f79a229ea6be5b256578cf30154725121f5e93 100644 --- a/ets2panda/checker/types/ets/shortType.cpp +++ b/ets2panda/checker/types/ets/shortType.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 - 2024 Huawei Device Co., Ltd. + * Copyright (c) 2021 - 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -16,7 +16,7 @@ #include "shortType.h" #include "checker/ets/conversion.h" -#include "checker/ets/narrowingWideningConverter.h" +#include "checker/ets/wideningConverter.h" namespace ark::es2panda::checker { void ShortType::Identical(TypeRelation *relation, Type *other) @@ -28,10 +28,7 @@ void ShortType::Identical(TypeRelation *relation, Type *other) void ShortType::AssignmentTarget(TypeRelation *relation, [[maybe_unused]] Type *source) { - if (relation->ApplyUnboxing() && !relation->IsTrue()) { - relation->GetChecker()->AsETSChecker()->MaybeAddUnboxingFlagInRelation(relation, source, this); - } - NarrowingWideningConverter(relation->GetChecker()->AsETSChecker(), relation, this, source); + WideningConverter(relation->GetChecker()->AsETSChecker(), relation, this, source); } bool ShortType::AssignmentSource([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] Type *target) @@ -57,38 +54,9 @@ void ShortType::Cast(TypeRelation *const relation, Type *const target) return; } - if (target->HasTypeFlag(TypeFlag::BYTE | TypeFlag::CHAR)) { - conversion::NarrowingPrimitive(relation, this, target); - return; - } - - if (target->HasTypeFlag(TypeFlag::INT | TypeFlag::LONG | TypeFlag::FLOAT | TypeFlag::DOUBLE)) { - conversion::WideningPrimitive(relation, this, target); - return; - } - - if (target->HasTypeFlag(TypeFlag::ETS_OBJECT)) { - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_SHORT)) { - conversion::Boxing(relation, this); - return; - } - - if (target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_TYPE)) { - auto unboxedTarget = relation->GetChecker()->AsETSChecker()->MaybeUnboxInRelation(target); - if (unboxedTarget == nullptr) { - conversion::Forbidden(relation); - return; - } - Cast(relation, unboxedTarget); - if (relation->IsTrue()) { - conversion::Boxing(relation, unboxedTarget); - return; - } - conversion::Forbidden(relation); - return; - } - - conversion::BoxingWideningReference(relation, this, target->AsETSObjectType()); + if (target->HasTypeFlag(TypeFlag::ETS_OBJECT) && + target->AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_SHORT)) { + conversion::Boxing(relation, this); return; } diff --git a/ets2panda/checker/types/ets/shortType.h b/ets2panda/checker/types/ets/shortType.h index 0cbd73ab16e223a284fa41bd1692c33588f48c6b..4b226806a322536a8c10bb03e5169d534fa8f2b1 100644 --- a/ets2panda/checker/types/ets/shortType.h +++ b/ets2panda/checker/types/ets/shortType.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -52,11 +52,6 @@ public: ss << compiler::Signatures::TYPE_DESCRIPTOR_SHORT; } - std::tuple ResolveConditionExpr() const override - { - return {IsConstantType(), value_ != 0}; - } - private: UType value_ {0}; }; diff --git a/ets2panda/checker/types/ets/types.h b/ets2panda/checker/types/ets/types.h index 89d59b801ed6bc0f632dd6dd7f7adf08473c41f8..e82a8fa0a503b690ae1cd7a15531ebfa873e4fd8 100644 --- a/ets2panda/checker/types/ets/types.h +++ b/ets2panda/checker/types/ets/types.h @@ -32,7 +32,6 @@ #include "etsBigIntType.h" #include "etsObjectType.h" #include "etsTypeAliasType.h" -#include "etsDynamicType.h" #include "etsArrayType.h" #include "wildcardType.h" #include "etsTypeParameter.h" @@ -40,6 +39,8 @@ #include "etsNullishTypes.h" #include "checker/types/signature.h" #include "etsReadonlyType.h" +#include "etsAnyType.h" #include "etsNeverType.h" +#include "etsEnumType.h" #endif /* TYPES_H */ diff --git a/ets2panda/checker/types/globalTypesHolder.cpp b/ets2panda/checker/types/globalTypesHolder.cpp index 784aa977a409c2561d3418a1ec74d7eb7821fb44..e6f337aa26e883f1852ab8174b55610d3041d306 100644 --- a/ets2panda/checker/types/globalTypesHolder.cpp +++ b/ets2panda/checker/types/globalTypesHolder.cpp @@ -48,6 +48,7 @@ #include "checker/types/ets/etsNullishTypes.h" #include "checker/types/ets/etsObjectType.h" #include "checker/types/ets/wildcardType.h" +#include "checker/types/ets/etsAnyType.h" #include "checker/types/ets/etsNeverType.h" #include "util/helpers.h" @@ -84,7 +85,7 @@ void GlobalTypesHolder::AddFunctionTypes(ArenaAllocator *allocator) addTypes("LambdaR", GlobalTypeId::ETS_LAMBDAR0_CLASS, GlobalTypeId::ETS_LAMBDAR16_CLASS); builtinNameMappings_.emplace("FunctionN", GlobalTypeId::ETS_FUNCTIONN_CLASS); - builtinNameMappings_.emplace("LambdaN", GlobalTypeId::ETS_FUNCTIONN_CLASS); + builtinNameMappings_.emplace("LambdaN", GlobalTypeId::ETS_LAMBDAN_CLASS); } void GlobalTypesHolder::AddTupleTypes(ArenaAllocator *allocator) @@ -148,14 +149,18 @@ void GlobalTypesHolder::AddEtsSpecificTypes(ArenaAllocator *allocator) globalTypes_[static_cast(GlobalTypeId::ETS_UNDEFINED)] = allocator->New(); globalTypes_[static_cast(GlobalTypeId::ETS_WILDCARD)] = allocator->New(); globalTypes_[static_cast(GlobalTypeId::TYPE_ERROR)] = allocator->New(); + globalTypes_[static_cast(GlobalTypeId::ETS_ANY)] = allocator->New(); + globalTypes_[static_cast(GlobalTypeId::ETS_RELAXED_ANY)] = allocator->New(true); globalTypes_[static_cast(GlobalTypeId::ETS_NEVER)] = allocator->New(); } void GlobalTypesHolder::AddEtsSpecificBuiltinTypes() { + builtinNameMappings_.emplace("Any", GlobalTypeId::ETS_ANY); builtinNameMappings_.emplace("Boolean", GlobalTypeId::ETS_BOOLEAN_BUILTIN); builtinNameMappings_.emplace("Byte", GlobalTypeId::ETS_BYTE_BUILTIN); builtinNameMappings_.emplace("Char", GlobalTypeId::ETS_CHAR_BUILTIN); + builtinNameMappings_.emplace("Class", GlobalTypeId::ETS_CLASS_BUILTIN); builtinNameMappings_.emplace("Comparable", GlobalTypeId::ETS_COMPARABLE_BUILTIN); builtinNameMappings_.emplace("Console", GlobalTypeId::ETS_CONSOLE_BUILTIN); builtinNameMappings_.emplace("Double", GlobalTypeId::ETS_DOUBLE_BUILTIN); @@ -165,6 +170,7 @@ void GlobalTypesHolder::AddEtsSpecificBuiltinTypes() builtinNameMappings_.emplace("Int", GlobalTypeId::ETS_INT_BUILTIN); builtinNameMappings_.emplace("Integral", GlobalTypeId::ETS_INTEGRAL_BUILTIN); builtinNameMappings_.emplace("Long", GlobalTypeId::ETS_LONG_BUILTIN); + builtinNameMappings_.emplace("Numeric", GlobalTypeId::ETS_NUMERIC_BUILTIN); builtinNameMappings_.emplace("Object", GlobalTypeId::ETS_OBJECT_BUILTIN); builtinNameMappings_.emplace("Runtime", GlobalTypeId::ETS_RUNTIME_BUILTIN); builtinNameMappings_.emplace("RuntimeLinker", GlobalTypeId::ETS_RUNTIME_LINKER_BUILTIN); @@ -403,19 +409,29 @@ Type *GlobalTypesHolder::GlobalETSUndefinedType() return globalTypes_.at(static_cast(GlobalTypeId::ETS_UNDEFINED)); } +Type *GlobalTypesHolder::GlobalETSAnyType() +{ + return globalTypes_.at(static_cast(GlobalTypeId::ETS_ANY)); +} + +Type *GlobalTypesHolder::GlobalETSRelaxedAnyType() +{ + return globalTypes_.at(static_cast(GlobalTypeId::ETS_RELAXED_ANY)); +} + Type *GlobalTypesHolder::GlobalETSNeverType() { return globalTypes_.at(static_cast(GlobalTypeId::ETS_NEVER)); } -Type *GlobalTypesHolder::GlobalETSNullishObjectType() +Type *GlobalTypesHolder::GlobalETSUnionUndefinedNullObject() { - return globalTypes_.at(static_cast(GlobalTypeId::ETS_NULLISH_OBJECT)); + return globalTypes_.at(static_cast(GlobalTypeId::ETS_UNION_UNDEFINED_NULL_OBJECT)); } -Type *GlobalTypesHolder::GlobalETSNullishType() +Type *GlobalTypesHolder::GlobalETSUnionUndefinedNull() { - return globalTypes_.at(static_cast(GlobalTypeId::ETS_NULLISH_TYPE)); + return globalTypes_.at(static_cast(GlobalTypeId::ETS_UNION_UNDEFINED_NULL)); } Type *GlobalTypesHolder::GlobalWildcardType() @@ -433,6 +449,11 @@ Type *GlobalTypesHolder::GlobalByteBuiltinType() return globalTypes_.at(static_cast(GlobalTypeId::ETS_BYTE_BUILTIN)); } +Type *GlobalTypesHolder::GlobalClassBuiltinType() +{ + return globalTypes_.at(static_cast(GlobalTypeId::ETS_CLASS_BUILTIN)); +} + Type *GlobalTypesHolder::GlobalCharBuiltinType() { return globalTypes_.at(static_cast(GlobalTypeId::ETS_CHAR_BUILTIN)); @@ -483,6 +504,11 @@ Type *GlobalTypesHolder::GlobalLongBuiltinType() return globalTypes_.at(static_cast(GlobalTypeId::ETS_LONG_BUILTIN)); } +Type *GlobalTypesHolder::GlobalNumericBuiltinType() +{ + return globalTypes_.at(static_cast(GlobalTypeId::ETS_NUMERIC_BUILTIN)); +} + Type *GlobalTypesHolder::GlobalMapBuiltinType() { return globalTypes_.at(static_cast(GlobalTypeId::ETS_MAP_BUILTIN)); diff --git a/ets2panda/checker/types/globalTypesHolder.h b/ets2panda/checker/types/globalTypesHolder.h index 2242097f8d854483c454b3d2ab6f24672ae1840c..16d39147b08f7c7280db47bf3362ccff000bba4b 100644 --- a/ets2panda/checker/types/globalTypesHolder.h +++ b/ets2panda/checker/types/globalTypesHolder.h @@ -57,12 +57,15 @@ enum class GlobalTypeId : std::size_t { ETS_OBJECT_BUILTIN, ETS_NULL, ETS_UNDEFINED, - ETS_NULLISH_TYPE, + ETS_UNION_UNDEFINED_NULL, + ETS_ANY, + ETS_RELAXED_ANY, ETS_NEVER, - ETS_NULLISH_OBJECT, + ETS_UNION_UNDEFINED_NULL_OBJECT, ETS_WILDCARD, ETS_BOOLEAN_BUILTIN, ETS_BYTE_BUILTIN, + ETS_CLASS_BUILTIN, ETS_CHAR_BUILTIN, ETS_COMPARABLE_BUILTIN, ETS_CONSOLE_BUILTIN, @@ -74,6 +77,7 @@ enum class GlobalTypeId : std::size_t { ETS_INT_BUILTIN, ETS_INTEGRAL_BUILTIN, ETS_LONG_BUILTIN, + ETS_NUMERIC_BUILTIN, ETS_MAP_BUILTIN, ETS_RECORD_BUILTIN, ETS_ERROR_BUILTIN, @@ -98,7 +102,6 @@ enum class GlobalTypeId : std::size_t { ETS_FUNCTION_BUILTIN, ETS_REGEXP_BUILTIN, ETS_ARRAY_BUILTIN, - ETS_ARRAY, ETS_INTEROP_JSRUNTIME_BUILTIN, ETS_INTEROP_JSVALUE_BUILTIN, ETS_BOX_BUILTIN, @@ -112,6 +115,7 @@ enum class GlobalTypeId : std::size_t { ETS_DOUBLE_BOX_BUILTIN, ETS_BIG_INT_BUILTIN, ETS_BIG_INT, + ETS_ARRAY, ETS_FUNCTION0_CLASS, ETS_FUNCTION1_CLASS, @@ -267,12 +271,15 @@ public: Type *GlobalETSObjectType(); Type *GlobalETSNullType(); Type *GlobalETSUndefinedType(); + Type *GlobalETSAnyType(); + Type *GlobalETSRelaxedAnyType(); Type *GlobalETSNeverType(); - Type *GlobalETSNullishType(); - Type *GlobalETSNullishObjectType(); + Type *GlobalETSUnionUndefinedNull(); + Type *GlobalETSUnionUndefinedNullObject(); Type *GlobalWildcardType(); Type *GlobalETSBooleanBuiltinType(); Type *GlobalByteBuiltinType(); + Type *GlobalClassBuiltinType(); Type *GlobalCharBuiltinType(); Type *GlobalComparableBuiltinType(); Type *GlobalConsoleBuiltinType(); @@ -283,6 +290,7 @@ public: Type *GlobalIntegerBuiltinType(); Type *GlobalIntegralBuiltinType(); Type *GlobalLongBuiltinType(); + Type *GlobalNumericBuiltinType(); Type *GlobalErrorBuiltinType(); Type *GlobalRuntimeBuiltinType(); Type *GlobalShortBuiltinType(); diff --git a/ets2panda/checker/types/gradualType.cpp b/ets2panda/checker/types/gradualType.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ccf3f35b6c558b42ac42bcc1b1b6d1710b55c86f --- /dev/null +++ b/ets2panda/checker/types/gradualType.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gradualType.h" + +#include "checker/ETSchecker.h" +#include "checker/ets/conversion.h" + +namespace ark::es2panda::checker { +void GradualType::Identical(TypeRelation *relation, Type *other) +{ + if (other->IsGradualType()) { + baseType_->Identical(relation, other->AsGradualType()->GetBaseType()); + } else { + baseType_->Identical(relation, other); + } +} + +void GradualType::AssignmentTarget(TypeRelation *relation, Type *source) +{ + if (source->IsGradualType()) { + baseType_->AssignmentTarget(relation, source->AsGradualType()->GetBaseType()); + } else { + baseType_->AssignmentTarget(relation, source); + } +} + +bool GradualType::AssignmentSource(TypeRelation *relation, Type *target) +{ + if (target->IsGradualType()) { + return baseType_->AssignmentSource(relation, target->AsGradualType()->GetBaseType()); + } + return baseType_->AssignmentSource(relation, target); +} + +void GradualType::Compare(TypeRelation *relation, Type *other) +{ + if (other->IsGradualType()) { + baseType_->Compare(relation, other->AsGradualType()->GetBaseType()); + } else { + baseType_->Compare(relation, other); + } +} + +void GradualType::Cast(TypeRelation *relation, Type *target) +{ + if (target->IsGradualType()) { + baseType_->Cast(relation, target->AsGradualType()->GetBaseType()); + } else { + baseType_->Cast(relation, target); + } +} + +void GradualType::CastTarget(TypeRelation *relation, Type *source) +{ + if (source->IsGradualType()) { + baseType_->CastTarget(relation, source->AsGradualType()->GetBaseType()); + } else { + baseType_->CastTarget(relation, source); + } +} + +void GradualType::IsSubtypeOf(TypeRelation *relation, Type *target) +{ + if (target->IsGradualType()) { + baseType_->IsSubtypeOf(relation, target->AsGradualType()->GetBaseType()); + } else { + baseType_->IsSubtypeOf(relation, target); + } +} + +void GradualType::IsSupertypeOf(TypeRelation *relation, Type *source) +{ + if (source->IsGradualType()) { + relation->IsSupertypeOf(baseType_, source->AsGradualType()->GetBaseType()); + } else { + baseType_->IsSupertypeOf(relation, source); + } +} + +void GradualType::ToString(std::stringstream &ss, [[maybe_unused]] bool precise) const +{ + baseType_->ToString(ss); +} + +Type *GradualType::Instantiate(ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes) +{ + auto baseType = baseType_->Instantiate(allocator, relation, globalTypes); + return relation->GetChecker()->AsETSChecker()->CreateGradualType(baseType); +} + +Type *GradualType::Substitute(TypeRelation *relation, const Substitution *substitution) +{ + return baseType_->Substitute(relation, substitution); +} + +void GradualType::ToAssemblerType(std::stringstream &ss) const +{ + baseType_->ToAssemblerType(ss); +} + +void GradualType::ToDebugInfoType(std::stringstream &ss) const +{ + baseType_->ToDebugInfoType(ss); +} + +void GradualType::ToAssemblerTypeWithRank(std::stringstream &ss) const +{ + baseType_->ToAssemblerTypeWithRank(ss); +} + +void GradualType::CheckVarianceRecursively(TypeRelation *relation, VarianceFlag varianceFlag) +{ + // The type of array should be Invariant + relation->CheckVarianceRecursively(baseType_, varianceFlag); +} +} // namespace ark::es2panda::checker \ No newline at end of file diff --git a/ets2panda/checker/types/gradualType.h b/ets2panda/checker/types/gradualType.h new file mode 100644 index 0000000000000000000000000000000000000000..eb1978e8d64d03011ffa14443c8b8607c8559850 --- /dev/null +++ b/ets2panda/checker/types/gradualType.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ES2PANDA_COMPILER_CHECKER_TYPES_GRADUAL_TYPE_H +#define ES2PANDA_COMPILER_CHECKER_TYPES_GRADUAL_TYPE_H + +#include "checker/types/type.h" +#include "ir/astNode.h" + +namespace ark::es2panda::checker { +class GradualType : public Type { +public: + explicit GradualType(checker::Type *baseType) + : Type(TypeFlag::GRADUAL_TYPE), baseType_(baseType), lang_(es2panda::Language(Language::Id::ETS)) + { + } + + explicit GradualType(checker::Type *baseType, Language lang) + : Type(TypeFlag::GRADUAL_TYPE), baseType_(baseType), lang_(lang) + { + } + + void Identical(TypeRelation *relation, Type *other) override; + void AssignmentTarget(TypeRelation *relation, Type *source) override; + bool AssignmentSource(TypeRelation *relation, Type *target) override; + void Compare(TypeRelation *relation, Type *other) override; + void Cast(TypeRelation *relation, Type *target) override; + void CastTarget(TypeRelation *relation, Type *source) override; + void IsSubtypeOf(TypeRelation *relation, Type *target) override; + void IsSupertypeOf(TypeRelation *relation, Type *source) override; + void ToString(std::stringstream &ss, bool precise) const override; + void ToAssemblerType(std::stringstream &ss) const override; + void ToDebugInfoType(std::stringstream &ss) const override; + void ToAssemblerTypeWithRank(std::stringstream &ss) const override; + Type *Instantiate(ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes) override; + Type *Substitute(TypeRelation *relation, const Substitution *substitution) override; + void CheckVarianceRecursively(TypeRelation *relation, VarianceFlag varianceFlag) override; + + const Type *GetBaseType() const + { + auto baseType = baseType_; + while (baseType->IsGradualType()) { + baseType = baseType->AsGradualType()->BaseType(); + } + return baseType; + } + + Type *GetBaseType() + { + auto baseType = baseType_; + while (baseType->IsGradualType()) { + baseType = baseType->AsGradualType()->BaseType(); + } + return baseType; + } + + Type *BaseType() + { + return baseType_; + } + + Type *BaseType() const + { + return baseType_; + } + + es2panda::Language Language() const + { + return lang_; + } + +private: + Type *baseType_; + es2panda::Language lang_; +}; +} // namespace ark::es2panda::checker + +#endif \ No newline at end of file diff --git a/ets2panda/checker/types/signature.cpp b/ets2panda/checker/types/signature.cpp index 5ced79c41120e511b5f411031ffe5a045c8275b0..0aaeab306651b74f0c87a99d36bc33cd095b239f 100644 --- a/ets2panda/checker/types/signature.cpp +++ b/ets2panda/checker/types/signature.cpp @@ -35,7 +35,7 @@ Signature *Signature::Substitute(TypeRelation *relation, const Substitution *sub auto *allocator = checker->ProgramAllocator(); bool anyChange = false; SignatureInfo *newSigInfo = allocator->New(allocator); - + ES2PANDA_ASSERT(newSigInfo != nullptr); if (!signatureInfo_->typeParams.empty()) { for (auto *tparam : signatureInfo_->typeParams) { auto *newTparam = tparam->Substitute(relation, substitution); @@ -51,6 +51,10 @@ Signature *Signature::Substitute(TypeRelation *relation, const Substitution *sub if (newParamType != param->TsType()) { anyChange = true; newParam = param->Copy(allocator, param->Declaration()); + if (newParamType->IsETSVoidType()) { + // since `void` is not allowed to be used as param type + newParamType = checker->GlobalETSUndefinedType(); + } newParam->SetTsType(newParamType); } newSigInfo->params.push_back(newParam); @@ -82,6 +86,7 @@ Signature *Signature::Substitute(TypeRelation *relation, const Substitution *sub Signature *Signature::CreateSignatureForSubstitute(ArenaAllocator *allocator, SignatureInfo *sigInfo, Type *returnType) { auto *result = allocator->New(sigInfo, returnType, func_); + ES2PANDA_ASSERT(result != nullptr); result->flags_ = flags_; result->internalName_ = internalName_; result->ownerObj_ = ownerObj_; @@ -110,9 +115,9 @@ void Signature::ToAssemblerType(std::stringstream &ss) const Signature *Signature::Copy(ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes) { SignatureInfo *copiedInfo = allocator->New(signatureInfo_, allocator); - + ES2PANDA_ASSERT(copiedInfo != nullptr); for (size_t idx = 0U; idx < signatureInfo_->params.size(); ++idx) { - auto *const paramType = signatureInfo_->params[idx]->TsType(); + auto *const paramType = signatureInfo_->params[idx]->TsType()->MaybeBaseTypeOfGradualType(); if (paramType->HasTypeFlag(TypeFlag::GENERIC) && paramType->IsETSObjectType()) { copiedInfo->params[idx]->SetTsType(paramType->Instantiate(allocator, relation, globalTypes)); auto originalTypeArgs = paramType->AsETSObjectType()->GetOriginalBaseType()->TypeArguments(); @@ -124,6 +129,7 @@ Signature *Signature::Copy(ArenaAllocator *allocator, TypeRelation *relation, Gl } auto *const copiedSignature = allocator->New(copiedInfo, returnType_, func_); + ES2PANDA_ASSERT(copiedSignature != nullptr); copiedSignature->flags_ = flags_; copiedSignature->internalName_ = internalName_; copiedSignature->ownerObj_ = ownerObj_; @@ -186,12 +192,6 @@ void Signature::ToString(std::stringstream &ss, const varbinder::Variable *varia } returnType_->ToString(ss, precise); - - if (HasSignatureFlag(SignatureFlags::THROWS)) { - ss << " throws"; - } else if (HasSignatureFlag(SignatureFlags::RETHROWS)) { - ss << " rethrows"; - } } std::string Signature::ToString() const @@ -289,12 +289,14 @@ Signature *Signature::ToArrowSignature(ETSChecker *checker) { auto *allocator = checker->ProgramAllocator(); auto *sigInfo = allocator->New(signatureInfo_, allocator); + ES2PANDA_ASSERT(sigInfo != nullptr); for (auto param : sigInfo->params) { param->SetTsType(checker->MaybeBoxType(param->TsType())); } auto *retType = checker->MaybeBoxType(returnType_); auto *resultSig = allocator->New(sigInfo, retType); + ES2PANDA_ASSERT(resultSig != nullptr); resultSig->flags_ = flags_; resultSig->SetOwner(Owner()); resultSig->SetOwnerVar(OwnerVar()); diff --git a/ets2panda/checker/types/signature.h b/ets2panda/checker/types/signature.h index 2a4f8ec06d417aed65fdc416c2ac9a38ee6fd543..4051395469791c11047011856c61c70fa52f8dca 100644 --- a/ets2panda/checker/types/signature.h +++ b/ets2panda/checker/types/signature.h @@ -49,6 +49,7 @@ public: if (other->restVar != nullptr) { restVar = other->restVar->Copy(allocator, other->restVar->Declaration()); + ES2PANDA_ASSERT(restVar != nullptr); restVar->SetTsType(other->restVar->TsType()); } } @@ -90,6 +91,8 @@ enum class SignatureFlags : uint32_t { RETHROWS = 1U << 17U, EXTENSION_FUNCTION = 1U << 18U, DUPLICATE_ASM = 1U << 19U, + BRIDGE = 1U << 20U, + DEFAULT = 1U << 21U, INTERNAL_PROTECTED = INTERNAL | PROTECTED, GETTER_OR_SETTER = GETTER | SETTER, @@ -223,6 +226,11 @@ public: return signatureInfo_->restVar; } + [[nodiscard]] varbinder::LocalVariable *RestVar() noexcept + { + return signatureInfo_->restVar; + } + [[nodiscard]] uint8_t ProtectionFlag() const noexcept { if ((flags_ & SignatureFlags::PRIVATE) != 0) { diff --git a/ets2panda/checker/types/ts/interfaceType.cpp b/ets2panda/checker/types/ts/interfaceType.cpp index 724bee9caa8d13e7521140aece70a67359c3dacd..ff846e5d8ee23a37b1567938cd0789559647da71 100644 --- a/ets2panda/checker/types/ts/interfaceType.cpp +++ b/ets2panda/checker/types/ts/interfaceType.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -148,6 +148,7 @@ Type *InterfaceType::Instantiate(ArenaAllocator *allocator, TypeRelation *relati Type *newInterfaceType = allocator->New(allocator, name_, copiedDesc); + ES2PANDA_ASSERT(newInterfaceType != nullptr); for (auto *it : bases_) { newInterfaceType->AsObjectType()->AsInterfaceType()->AddBase( it->Instantiate(allocator, relation, globalTypes)->AsObjectType()); diff --git a/ets2panda/checker/types/ts/objectDescriptor.cpp b/ets2panda/checker/types/ts/objectDescriptor.cpp index a418e6815ba44d59aa5f44e684de97144d9447bd..ccd7d48a60bb566487fd5bd2f727025ea334ead7 100644 --- a/ets2panda/checker/types/ts/objectDescriptor.cpp +++ b/ets2panda/checker/types/ts/objectDescriptor.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -34,9 +34,11 @@ varbinder::LocalVariable *ObjectDescriptor::FindProperty(const util::StringView void ObjectDescriptor::Copy(ArenaAllocator *allocator, ObjectDescriptor *copiedDesc, TypeRelation *relation, GlobalTypesHolder *globalTypes) { + ES2PANDA_ASSERT(copiedDesc != nullptr); // copy by hand for (auto *it : properties) { auto *copiedProp = it->Copy(allocator, it->Declaration()); + ES2PANDA_ASSERT(copiedProp != nullptr); copiedProp->SetTsType(it->TsType()->Instantiate(allocator, relation, globalTypes)); copiedDesc->properties.push_back(copiedProp); } diff --git a/ets2panda/checker/types/ts/unionType.cpp b/ets2panda/checker/types/ts/unionType.cpp index 8ba291ba7b360e44ee5e333de3e3ae6fd3557059..fe540ce69eed998cb223d590e9c936cbe6536e8e 100644 --- a/ets2panda/checker/types/ts/unionType.cpp +++ b/ets2panda/checker/types/ts/unionType.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -111,6 +111,7 @@ void UnionType::RemoveDuplicatedTypes(TypeRelation *relation, ArenaVectorHasConstituentFlag(TypeFlag::ANY)) { return globalTypesHolder->GlobalAnyType(); } @@ -184,6 +185,7 @@ Type *UnionType::Instantiate(ArenaAllocator *allocator, TypeRelation *relation, Type *newUnionType = allocator->New(allocator, std::move(copiedConstituents)); + ES2PANDA_ASSERT(newUnionType != nullptr); return HandleUnionType(newUnionType->AsUnionType(), globalTypes); } } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/type.cpp b/ets2panda/checker/types/type.cpp index 92368135f34ab098c1a16ecead974eb3b4a03e5c..61a6b8568e82040ac0fe3ebbed737ee8846d6c40 100644 --- a/ets2panda/checker/types/type.cpp +++ b/ets2panda/checker/types/type.cpp @@ -18,10 +18,13 @@ #include "checker/types/typeFlag.h" #include "checker/types/typeRelation.h" #include "checker/types/ets/etsObjectType.h" +#include "checker/types/gradualType.h" #include "checker/checker.h" namespace ark::es2panda::checker { +std::mutex Type::idLock_ {}; + bool Type::IsETSResizableArrayType() const { return IsETSObjectType() && AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_ARRAY); @@ -47,6 +50,11 @@ bool Type::IsETSAsyncFuncReturnType() const return IsETSObjectType() && AsETSObjectType()->HasObjectFlag(ETSObjectFlags::ASYNC_FUNC_RETURN_TYPE); } +bool Type::IsBuiltinNumeric() const noexcept +{ + return IsETSObjectType() && AsETSObjectType()->HasObjectFlag(ETSObjectFlags::BUILTIN_NUMERIC); +} + bool Type::IsLambdaObject() const { if (IsETSObjectType() && (AsETSObjectType()->HasObjectFlag(checker::ETSObjectFlags::FUNCTIONAL_INTERFACE) || @@ -149,39 +157,18 @@ Type *Type::Substitute([[maybe_unused]] TypeRelation *relation, [[maybe_unused]] return this; } -std::uint32_t Type::GetPrecedence(Type const *type) noexcept +bool IsTypeError(Type const *tp) { - ES2PANDA_ASSERT(type != nullptr); - if (type->HasTypeFlag(TypeFlag::BYTE)) { - return 1U; - } - if (type->HasTypeFlag(TypeFlag::CHAR)) { - return 2U; - } - if (type->HasTypeFlag(TypeFlag::SHORT)) { - return 3U; - } - if (type->HasTypeFlag(TypeFlag::INT)) { - return 4U; - } - if (type->HasTypeFlag(TypeFlag::LONG)) { - return 5U; - } - if (type->HasTypeFlag(TypeFlag::FLOAT)) { - return 6U; - } - if (type->HasTypeFlag(TypeFlag::DOUBLE)) { - return 7U; - } - if (type->HasTypeFlag(TypeFlag::BIGINT)) { - return 8U; - } - return 0U; + return tp != nullptr && tp->IsTypeError(); } -bool IsTypeError(Type const *tp) +Type *Type::MaybeBaseTypeOfGradualType() { - return tp != nullptr && tp->IsTypeError(); + auto res = this; + while (res->IsGradualType()) { + res = res->AsGradualType()->GetBaseType(); + } + return res; } } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/type.h b/ets2panda/checker/types/type.h index 1a0895b37a62d2824bab0b9fbf52314c9f7a80e5..3840d6ab66b98a8570b957cad0c6b5cde073c655 100644 --- a/ets2panda/checker/types/type.h +++ b/ets2panda/checker/types/type.h @@ -16,6 +16,7 @@ #ifndef ES2PANDA_COMPILER_CHECKER_TYPES_TYPE_H #define ES2PANDA_COMPILER_CHECKER_TYPES_TYPE_H +#include #include "generated/signatures.h" #include "checker/types/typeMapping.h" #include "checker/types/typeRelation.h" @@ -28,12 +29,11 @@ class Variable; namespace ark::es2panda::checker { class ObjectDescriptor; class GlobalTypesHolder; -class ETSDynamicType; class ETSAsyncFuncReturnType; class ETSChecker; -class ETSDynamicFunctionType; class ETSTypeParameter; class ETSEnumType; +class GradualType; // CC-OFFNXT(G.PRE.02) name part // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) @@ -44,13 +44,16 @@ class ETSStringType; class ETSBigIntType; class ETSResizableArrayType; -using Substitution = ArenaMap; +using Substitution = std::map; +using ArenaSubstitution = ArenaMap; class Type { public: explicit Type(TypeFlag flag) : typeFlags_(flag) { - static uint64_t typeId = 0; + std::lock_guard lock(idLock_); + static uint32_t typeId = 0; + ES2PANDA_ASSERT(typeId < std::numeric_limits::max()); id_ = ++typeId; } @@ -58,6 +61,7 @@ public: NO_MOVE_SEMANTIC(Type); virtual ~Type() = default; + static std::mutex idLock_; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define TYPE_IS_CHECKS(typeFlag, typeName) \ @@ -110,6 +114,8 @@ public: bool PossiblyETSValueTyped() const; bool PossiblyETSValueTypedExceptNullish() const; + bool PossiblyInForeignDomain() const; + ETSStringType *AsETSStringType() { ES2PANDA_ASSERT(IsETSObjectType()); @@ -140,22 +146,7 @@ public: return reinterpret_cast(this); } - bool IsETSDynamicType() const - { - return IsETSObjectType() && HasTypeFlag(TypeFlag::ETS_DYNAMIC_FLAG); - } - - ETSDynamicType *AsETSDynamicType() - { - ES2PANDA_ASSERT(IsETSDynamicType()); - return reinterpret_cast(this); - } - - const ETSDynamicType *AsETSDynamicType() const - { - ES2PANDA_ASSERT(IsETSDynamicType()); - return reinterpret_cast(this); - } + [[nodiscard]] bool IsBuiltinNumeric() const noexcept; ETSAsyncFuncReturnType *AsETSAsyncFuncReturnType() { @@ -169,33 +160,13 @@ public: return reinterpret_cast(this); } - bool IsETSDynamicFunctionType() const - { - return TypeFlags() == TypeFlag::ETS_DYNAMIC_FUNCTION_TYPE; - } - - ETSDynamicFunctionType *AsETSDynamicFunctionType() - { - ES2PANDA_ASSERT(IsETSDynamicFunctionType()); - return reinterpret_cast(this); - } - - const ETSDynamicFunctionType *AsETSDynamicFunctionType() const - { - ES2PANDA_ASSERT(IsETSDynamicFunctionType()); - return reinterpret_cast(this); - } - - bool IsConditionalExprType() const - { - return HasTypeFlag(TypeFlag::CONDITION_EXPRESSION_TYPE); - } - bool IsConstantType() const { return HasTypeFlag(checker::TypeFlag::CONSTANT); } + Type *MaybeBaseTypeOfGradualType(); + TypeFlag TypeFlags() const { return typeFlags_; @@ -216,7 +187,7 @@ public: typeFlags_ &= ~typeFlag; } - uint64_t Id() const + uint32_t Id() const { return id_; } @@ -267,15 +238,24 @@ public: ToAssemblerType(ss); } - virtual uint32_t Rank() const + std::string ToAssemblerType() const { - return 0; + std::stringstream ss; + ToAssemblerType(ss); + return ss.str(); + } + + std::string ToAssemblerTypeWithRank() const + { + std::stringstream ss; + ToAssemblerTypeWithRank(ss); + return ss.str(); } - virtual std::tuple ResolveConditionExpr() const + virtual uint32_t Rank() const { - ES2PANDA_UNREACHABLE(); - }; + return 0; + } virtual void Identical(TypeRelation *relation, Type *other); virtual void AssignmentTarget(TypeRelation *relation, Type *source) = 0; @@ -290,7 +270,6 @@ public: [[maybe_unused]] VarianceFlag varianceFlag) { } - [[nodiscard]] static std::uint32_t GetPrecedence(Type const *type) noexcept; virtual Type *Instantiate(ArenaAllocator *allocator, TypeRelation *relation, GlobalTypesHolder *globalTypes); [[nodiscard]] virtual Type *Clone(Checker *checker); @@ -300,7 +279,7 @@ protected: // NOLINTBEGIN(misc-non-private-member-variables-in-classes) TypeFlag typeFlags_; varbinder::Variable *variable_ {}; // Variable associated with the type if any - uint64_t id_; + uint32_t id_; // NOLINTEND(misc-non-private-member-variables-in-classes) }; diff --git a/ets2panda/checker/types/typeFlag.h b/ets2panda/checker/types/typeFlag.h index 86e149f3a3d2ce2c4816b00280f55012f2b91548..5f01ae82252c6d2fcf311bbdfc2804c5f010a98c 100644 --- a/ets2panda/checker/types/typeFlag.h +++ b/ets2panda/checker/types/typeFlag.h @@ -48,7 +48,6 @@ enum class TypeFlag : uint64_t { INTERSECTION = 1ULL << 19ULL, // x: a & b INDEX = 1ULL << 20ULL, // keyof x INDEX_ACCESS = 1ULL << 21ULL, // x[a] - CONDITIONAL = 1ULL << 22ULL, // x extends a ? b : c TEMPLATE_LITERAL = 1ULL << 23ULL, // x: `hello ${World}` ANY = 1ULL << 24ULL, // x: any ARRAY = 1ULL << 25ULL, // x: number[] @@ -70,11 +69,10 @@ enum class TypeFlag : uint64_t { ETS_ARRAY = 1ULL << 41ULL, // ETS array type WILDCARD = 1ULL << 42ULL, // new A() ETS_TYPE_PARAMETER = 1ULL << 43ULL, // ETS type parameter - ETS_TYPE_REFERENCE = 1ULL << 44ULL, // ETS type reference GENERIC = 1ULL << 45ULL, // ETS Generic ETS_INT_ENUM = 1ULL << 46ULL, // ETS Enum ETS_STRING_ENUM = 1ULL << 47ULL, // ETS string-type Enumeration - ETS_DYNAMIC_FLAG = 1ULL << 48ULL, // ETS Dynamic flag + GRADUAL_TYPE = 1ULL << 48ULL, // gradual type GETTER = 1ULL << 49ULL, // ETS Getter SETTER = 1ULL << 50ULL, // ETS Setter ETS_EXTENSION_FUNC_HELPER = 1ULL << 51ULL, // ETS Extension Function Helper @@ -88,14 +86,9 @@ enum class TypeFlag : uint64_t { ETS_PARTIAL_TYPE_PARAMETER = 1ULL << 59ULL, // ETS Partial type parameter TYPE_ERROR = 1ULL << 60ULL, // type error ETS_TYPE_ALIAS = 1ULL << 61ULL, // ETS Type alias + ETS_ANY = 1ULL << 22ULL, // ETS any, the value was *stolen* from the CONDITIONAL type kind ETS_NEVER = 1ULL << 62ULL, // ETS never ETS_METHOD = 1ULL << 63ULL, // ETS method (or function in module) (possibly overloaded) - ETS_DYNAMIC_TYPE = ETS_OBJECT | ETS_DYNAMIC_FLAG, - ETS_DYNAMIC_FUNCTION_TYPE = FUNCTION | ETS_DYNAMIC_FLAG, - ETS_TYPE = BYTE | SHORT | INT | LONG | FLOAT | DOUBLE | CHAR | ETS_BOOLEAN | ETS_VOID | ETS_OBJECT | ETS_ARRAY | - FUNCTION | WILDCARD | ETS_TYPE_PARAMETER | ETS_DYNAMIC_TYPE | ETS_UNION | ETS_NULL | ETS_UNDEFINED | - ETS_NONNULLISH | ETS_READONLY | ETS_REQUIRED_TYPE_PARAMETER | ETS_PARTIAL_TYPE_PARAMETER | ETS_NEVER | - ETS_TUPLE, ETS_INTEGRAL_NUMERIC = BYTE | SHORT | INT | LONG, ETS_FLOATING_POINT = FLOAT | DOUBLE, ETS_NUMERIC = ETS_INTEGRAL_NUMERIC | ETS_FLOATING_POINT, @@ -123,9 +116,6 @@ enum class TypeFlag : uint64_t { VALID_ARITHMETIC_TYPE = ANY | NUMBER_LIKE | BIGINT_LIKE | ENUM, UNIT = LITERAL | UNDEFINED | NULL_TYPE, GETTER_SETTER = GETTER | SETTER, - CONDITION_EXPRESSION_TYPE = ETS_NULL | ETS_UNDEFINED | ETS_OBJECT | ETS_ARRAY | ETS_UNION | CONSTANT | BYTE | CHAR | - SHORT | INT | LONG | FLOAT | DOUBLE | ETS_BOOLEAN | ETS_INT_ENUM | ETS_STRING_ENUM | - FUNCTION | ETS_TUPLE, }; } // namespace ark::es2panda::checker diff --git a/ets2panda/checker/types/typeMapping.h b/ets2panda/checker/types/typeMapping.h index 4964190828798d93cc53c3a26e0c5e4aabd8f83e..84e3ba9cfef6fdf49983f38bf38c92e203b2e5b3 100644 --- a/ets2panda/checker/types/typeMapping.h +++ b/ets2panda/checker/types/typeMapping.h @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Copyright (c) 2021-2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -53,6 +53,7 @@ _(TypeFlag::ETS_VOID, ETSVoidType) \ _(TypeFlag::ETS_NULL, ETSNullType) \ _(TypeFlag::ETS_UNDEFINED, ETSUndefinedType) \ + _(TypeFlag::ETS_ANY, ETSAnyType) \ _(TypeFlag::ETS_NEVER, ETSNeverType) \ _(TypeFlag::FUNCTION, ETSFunctionType) \ _(TypeFlag::ETS_OBJECT, ETSObjectType) \ @@ -70,6 +71,7 @@ _(TypeFlag::ETS_TUPLE, ETSTupleType) \ _(TypeFlag::ETS_PARTIAL_TYPE_PARAMETER, ETSPartialTypeParameter) \ _(TypeFlag::TYPE_ERROR, TypeError) \ + _(TypeFlag::GRADUAL_TYPE, GradualType) \ _(TypeFlag::ETS_TYPE_ALIAS, ETSTypeAliasType) #define OBJECT_TYPE_MAPPING(_) \ diff --git a/ets2panda/checker/types/typeRelation.cpp b/ets2panda/checker/types/typeRelation.cpp index 965d2172bb0dc4ed33260bd727d8d2f127523260..c4b2fbb0869b7b727e396bd6b0eafb50eb559609 100644 --- a/ets2panda/checker/types/typeRelation.cpp +++ b/ets2panda/checker/types/typeRelation.cpp @@ -29,24 +29,20 @@ ArenaAllocator *TypeRelation::Allocator() RelationResult TypeRelation::CacheLookup(const Type *source, const Type *target, const RelationHolder &holder, RelationType type) const { - if (result_ == RelationResult::CACHE_MISS) { - return result_; - } - ES2PANDA_ASSERT(source != nullptr); ES2PANDA_ASSERT(target != nullptr); - RelationKey relationKey {source->Id(), target->Id()}; - auto res = holder.cached.find(relationKey); - if (res == holder.cached.end()) { + auto key = RelationHolder::MakeKey(source->Id(), target->Id()); + auto res = holder.Find(key); + if (res == nullptr) { return RelationResult::CACHE_MISS; } - if (res->second.type >= type && res->second.result == RelationResult::TRUE) { + if (res->type >= type && res->result == RelationResult::TRUE) { return RelationResult::TRUE; } - if (res->second.type <= type && res->second.result == RelationResult::FALSE) { + if (res->type <= type && res->result == RelationResult::FALSE) { return RelationResult::FALSE; } @@ -69,7 +65,8 @@ bool TypeRelation::IsIdenticalTo(Type *source, Type *target) checker_->ResolveStructuredTypeMembers(target); result_ = RelationResult::FALSE; target->Identical(this, source); - checker_->IdenticalResults().cached.insert({{source->Id(), target->Id()}, {result_, RelationType::IDENTICAL}}); + auto key = RelationHolder::MakeKey(source->Id(), target->Id()); + checker_->IdenticalResults().Insert(key, {result_, RelationType::IDENTICAL}); } return IsTrue(); @@ -114,7 +111,6 @@ bool TypeRelation::IsIdenticalTo(IndexInfo *source, IndexInfo *target) return result_ == RelationResult::TRUE; } -// NOTE: applyNarrowing -> flag bool TypeRelation::IsAssignableTo(Type *source, Type *target) { if (source == target) { @@ -125,11 +121,15 @@ bool TypeRelation::IsAssignableTo(Type *source, Type *target) if (result_ == RelationResult::CACHE_MISS) { // NOTE: we support assigning T to Readonly, but do not support assigning Readonly to T // more details in spec + ES2PANDA_ASSERT(source != nullptr); + ES2PANDA_ASSERT(target != nullptr); if (source->HasTypeFlag(TypeFlag::READONLY) && !target->HasTypeFlag(TypeFlag::READONLY)) { result_ = RelationResult::FALSE; } + auto key = RelationHolder::MakeKey(source->Id(), target->Id()); if (result_ != RelationResult::FALSE && IsIdenticalTo(source, target)) { + checker_->AssignableResults().Insert(key, {result_, RelationType::ASSIGNABLE}); return true; } @@ -144,8 +144,7 @@ bool TypeRelation::IsAssignableTo(Type *source, Type *target) } if (flags_ == TypeRelationFlag::NONE) { - checker_->AssignableResults().cached.insert( - {{source->Id(), target->Id()}, {result_, RelationType::ASSIGNABLE}}); + checker_->AssignableResults().Insert(key, {result_, RelationType::ASSIGNABLE}); } } @@ -155,14 +154,8 @@ bool TypeRelation::IsAssignableTo(Type *source, Type *target) bool TypeRelation::IsComparableTo(Type *source, Type *target) { result_ = CacheLookup(source, target, checker_->ComparableResults(), RelationType::COMPARABLE); - - // NOTE: vpukhov. reimplement dynamic comparison and remove this check - if (source->IsETSDynamicType() || target->IsETSDynamicType()) { - if (!(source->IsETSDynamicType() && target->IsETSDynamicType())) { - return false; - } - } - + ES2PANDA_ASSERT(source != nullptr); + ES2PANDA_ASSERT(target != nullptr); if (result_ == RelationResult::CACHE_MISS) { if (IsAssignableTo(source, target)) { return true; @@ -170,8 +163,9 @@ bool TypeRelation::IsComparableTo(Type *source, Type *target) result_ = RelationResult::FALSE; target->Compare(this, source); - checker_->ComparableResults().cached.insert( - {{source->Id(), target->Id()}, {result_, RelationType::COMPARABLE}}); + ES2PANDA_ASSERT(source != nullptr); + auto key = RelationHolder::MakeKey(source->Id(), target->Id()); + checker_->ComparableResults().Insert(key, {result_, RelationType::COMPARABLE}); } return result_ == RelationResult::TRUE; @@ -193,12 +187,9 @@ bool TypeRelation::IsCastableTo(Type *const source, Type *const target) return false; } - // NOTE: Can't cache if the node has BoxingUnboxingFlags. These flags should be stored and restored on the node - // on cache hit. - if (UncheckedCast() && node_->GetBoxingUnboxingFlags() == ir::BoxingUnboxingFlags::NONE && - !node_->HasAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF)) { - checker_->UncheckedCastableResult().cached.insert( - {{source->Id(), target->Id()}, {result_, RelationType::UNCHECKED_CASTABLE}}); + if (UncheckedCast() && !node_->HasAstNodeFlags(ir::AstNodeFlags::GENERATE_VALUE_OF)) { + auto key = RelationHolder::MakeKey(source->Id(), target->Id()); + checker_->UncheckedCastableResult().Insert(key, {result_, RelationType::UNCHECKED_CASTABLE}); } return true; @@ -209,21 +200,44 @@ bool TypeRelation::IsCastableTo(Type *const source, Type *const target) bool TypeRelation::IsLegalBoxedPrimitiveConversion(Type *target, Type *source) { - if (!target->IsETSReferenceType() || !source->IsETSReferenceType()) { + ETSChecker *checker = this->GetChecker()->AsETSChecker(); + + if (target == nullptr || source == nullptr) { return false; } + + if (target->IsETSUnionType() && source->IsETSObjectType()) { + Type *sourceUnboxedType = checker->MaybeUnboxType(source); + if (sourceUnboxedType == nullptr || !sourceUnboxedType->IsETSPrimitiveType()) { + return false; + } + Type *boxedUnionTarget = target->AsETSUnionType()->FindUnboxableType(); + if (boxedUnionTarget == nullptr) { + return false; + } + Type *targetUnboxedType = checker->MaybeUnboxType(boxedUnionTarget); + if (targetUnboxedType == nullptr || !targetUnboxedType->IsETSPrimitiveType()) { + return false; + } + bool res = this->Result(this->IsAssignableTo(sourceUnboxedType, target)); + return res; + } + if (!target->IsETSObjectType() || !source->IsETSObjectType()) { return false; } - if (!target->AsETSObjectType()->IsBoxedPrimitive() || !source->AsETSObjectType()->IsBoxedPrimitive()) { + + if (!target->AsETSObjectType()->IsBoxedPrimitive() && !source->AsETSObjectType()->IsBoxedPrimitive()) { return false; } - ETSChecker *checker = this->GetChecker()->AsETSChecker(); - Type *targetUnboxedType = checker->MaybeUnboxType(target); Type *sourceUnboxedType = checker->MaybeUnboxType(source); + if (source->IsETSIntEnumType()) { + targetUnboxedType = checker->GlobalIntType(); + } + if (targetUnboxedType == nullptr || sourceUnboxedType == nullptr) { return false; } @@ -231,33 +245,33 @@ bool TypeRelation::IsLegalBoxedPrimitiveConversion(Type *target, Type *source) return false; } - return this->Result(this->IsAssignableTo(sourceUnboxedType, targetUnboxedType)); + bool res = this->Result(this->IsAssignableTo(sourceUnboxedType, targetUnboxedType)); + return res; } bool TypeRelation::IsSupertypeOf(Type *super, Type *sub) { - if (super == sub) { + if (LIKELY(super == sub)) { return Result(true); } - if (sub == nullptr) { return false; } + if (super->IsETSPrimitiveType() != sub->IsETSPrimitiveType()) { + return false; + } result_ = CacheLookup(super, sub, checker_->SupertypeResults(), RelationType::SUPERTYPE); if (result_ == RelationResult::CACHE_MISS) { - if (IsIdenticalTo(super, sub)) { - return true; - } - - result_ = RelationResult::FALSE; - if (super->IsSupertypeOf(this, sub), !IsTrue()) { - sub->IsSubtypeOf(this, super); + if (!IsIdenticalTo(super, sub)) { + result_ = RelationResult::FALSE; + if (super->IsSupertypeOf(this, sub), !IsTrue()) { + sub->IsSubtypeOf(this, super); + } } - if (flags_ == TypeRelationFlag::NONE) { - checker_->SupertypeResults().cached.insert({{super->Id(), sub->Id()}, {result_, RelationType::SUPERTYPE}}); - } + auto key = RelationHolder::MakeKey(super->Id(), sub->Id()); + checker_->SupertypeResults().Insert(key, {result_, RelationType::SUPERTYPE}); } return result_ == RelationResult::TRUE; diff --git a/ets2panda/checker/types/typeRelation.h b/ets2panda/checker/types/typeRelation.h index a2fa218eede477c235441499bbbf8aa81a502056..33c32e789cfada5d83580cd839f5aacf80fa48e5 100644 --- a/ets2panda/checker/types/typeRelation.h +++ b/ets2panda/checker/types/typeRelation.h @@ -16,6 +16,7 @@ #ifndef ES2PANDA_COMPILER_CHECKER_TYPES_TYPE_RELATION_H #define ES2PANDA_COMPILER_CHECKER_TYPES_TYPE_RELATION_H +#include #include "lexer/token/sourceLocation.h" #include "generated/tokenType.h" #include "util/ustring.h" @@ -36,7 +37,6 @@ using ENUMBITOPS_OPERATORS; enum class TypeRelationFlag : uint32_t { NONE = 0U, - NARROWING = 1U << 0U, WIDENING = 1U << 1U, BOXING = 1U << 2U, UNBOXING = 1U << 3U, @@ -62,15 +62,18 @@ enum class TypeRelationFlag : uint32_t { NO_THROW_GENERIC_TYPEALIAS = 1U << 24U, OVERRIDING_CONTEXT = 1U << 25U, IGNORE_REST_PARAM = 1U << 26U, + STRING_TO_CHAR = 1U << 27U, + OVERLOADING_CONTEXT = 1U << 28U, + NO_SUBSTITUTION_NEEDED = 1U << 29U, ASSIGNMENT_CONTEXT = WIDENING | BOXING | UNBOXING, - BRIDGE_CHECK = OVERRIDING_CONTEXT | IGNORE_TYPE_PARAMETERS | NO_RETURN_TYPE_CHECK, - CASTING_CONTEXT = NARROWING | WIDENING | BOXING | UNBOXING | UNCHECKED_CAST, + BRIDGE_CHECK = OVERRIDING_CONTEXT | IGNORE_TYPE_PARAMETERS, + CASTING_CONTEXT = WIDENING | BOXING | UNBOXING | UNCHECKED_CAST, }; -enum class RelationResult { TRUE, FALSE, UNKNOWN, MAYBE, CACHE_MISS, ERROR }; +enum class RelationResult : uint8_t { TRUE, FALSE, UNKNOWN, MAYBE, CACHE_MISS, ERROR }; -enum class RelationType { COMPARABLE, ASSIGNABLE, IDENTICAL, UNCHECKED_CASTABLE, SUPERTYPE }; +enum class RelationType : uint8_t { COMPARABLE, ASSIGNABLE, IDENTICAL, UNCHECKED_CASTABLE, SUPERTYPE }; enum class VarianceFlag { COVARIANT, CONTRAVARIANT, INVARIANT }; @@ -82,40 +85,45 @@ struct enumbitops::IsAllowedType : std namespace ark::es2panda::checker { -class RelationKey { +class RelationHolder { public: - uint64_t sourceId; - uint64_t targetId; -}; + using RelationKey = uint64_t; -class RelationKeyHasher { -public: - size_t operator()(const RelationKey &key) const noexcept + class RelationEntry { + public: + RelationResult result; + RelationType type; + }; + + explicit RelationHolder(ThreadSafeArenaAllocator *allocator) : cached_(allocator->Adapter()) {} + + static RelationKey MakeKey(uint32_t sourceId, uint32_t targetId) { - return static_cast(key.sourceId ^ key.targetId); + constexpr size_t U32_NR_BITS = 32; // CC-OFF(G.NAM.03-CPP) project code style + return (static_cast(sourceId) << U32_NR_BITS) | targetId; } -}; -class RelationKeyComparator { -public: - bool operator()(const RelationKey &lhs, const RelationKey &rhs) const + const RelationEntry *Find(RelationKey key) const { - return lhs.sourceId == rhs.sourceId && lhs.targetId == rhs.targetId; + auto it = cached_.find(key); + if (it == cached_.cend()) { + return nullptr; + } + return &it->second; } -}; -class RelationEntry { -public: - RelationResult result; - RelationType type; -}; + void Insert(RelationKey key, RelationEntry entry) + { + cached_.insert({key, entry}); + } -using RelationMap = std::unordered_map; + void Clear() + { + cached_.clear(); + } -class RelationHolder { -public: - RelationMap cached; - RelationType type {}; +private: + ArenaUnorderedMap cached_; }; class TypeRelation { @@ -135,11 +143,6 @@ public: return result_ == RelationResult::ERROR; } - bool ApplyNarrowing() const - { - return (flags_ & TypeRelationFlag::NARROWING) != 0; - } - bool ApplyWidening() const { return (flags_ & TypeRelationFlag::WIDENING) != 0; @@ -245,6 +248,7 @@ public: void IncreaseTypeRecursionCount(Type *const type) { + std::lock_guard lock(mtx_); if (const auto foundType = instantiationRecursionMap_.find(type); foundType != instantiationRecursionMap_.end()) { foundType->second += 1; @@ -261,12 +265,14 @@ public: // possible to reference the correct types of it's members and methods. 2 is possibly enough, because if we // chain expressions, every one of them will be rechecked separately, thus allowing another 2 recursion. constexpr auto MAX_RECURSIVE_TYPE_INST = 2; + std::lock_guard lock(mtx_); const auto foundType = instantiationRecursionMap_.find(type); return foundType == instantiationRecursionMap_.end() ? true : (foundType->second < MAX_RECURSIVE_TYPE_INST); } void DecreaseTypeRecursionCount(Type *const type) { + std::lock_guard lock(mtx_); const auto foundType = instantiationRecursionMap_.find(type); if (foundType == instantiationRecursionMap_.end()) { return; @@ -306,7 +312,6 @@ public: void RaiseError(const diagnostic::DiagnosticKind &kind, const lexer::SourcePosition &loc) const; void RaiseError(const diagnostic::DiagnosticKind &kind, const util::DiagnosticMessageParams &list, const lexer::SourcePosition &loc) const; - void LogError(const util::DiagnosticMessageParams &list, const lexer::SourcePosition &loc) const; bool Result(bool res) { @@ -342,6 +347,7 @@ private: RelationResult CacheLookup(const Type *source, const Type *target, const RelationHolder &holder, RelationType type) const; + std::mutex mtx_; Checker *checker_; RelationResult result_ {}; TypeRelationFlag flags_ {}; diff --git a/ets2panda/compiler/base/condition.cpp b/ets2panda/compiler/base/condition.cpp index c8a7d0de4dbbc06d728f934d25c777bec1edc21a..e0ebfb209d394f0c6fa1371fc705cf0490346194 100644 --- a/ets2panda/compiler/base/condition.cpp +++ b/ets2panda/compiler/base/condition.cpp @@ -15,6 +15,7 @@ #include "condition.h" +#include "checker/ETSAnalyzerHelpers.h" #include "compiler/core/pandagen.h" #include "compiler/core/ETSGen.h" #include "ir/expressions/assignmentExpression.h" @@ -235,7 +236,6 @@ void Condition::Compile(ETSGen *etsg, const ir::Expression *expr, Label *falseLa etsg->BranchIfTrue(expr, falseLabel); return; } - ES2PANDA_ASSERT(expr->TsType()->IsConditionalExprType()); expr->Compile(etsg); etsg->ApplyConversion(expr, etsg->Checker()->GlobalETSBooleanType()); etsg->ResolveConditionalResultIfFalse(expr, falseLabel); diff --git a/ets2panda/compiler/base/lreference.cpp b/ets2panda/compiler/base/lreference.cpp index 240aa09bd3fbad7c3e11dc67fa5826635b15e745..1ae778a945176e180d5322d98fa8776da71b1814 100644 --- a/ets2panda/compiler/base/lreference.cpp +++ b/ets2panda/compiler/base/lreference.cpp @@ -69,6 +69,10 @@ LReference::LReferenceBase LReference::CreateBase(CodeGen *cg, const ir::AstNode case ir::AstNodeType::TS_NON_NULL_EXPRESSION: { return CreateBase(cg, node->AsTSNonNullExpression()->Expr(), isDeclaration); } + case ir::AstNodeType::ETS_NEW_CLASS_INSTANCE_EXPRESSION: { + ES2PANDA_ASSERT(node->AsETSNewClassInstanceExpression()->GetArguments().size() == 1); + return CreateBase(cg, node->AsETSNewClassInstanceExpression()->GetArguments()[0], isDeclaration); + } default: { ES2PANDA_UNREACHABLE(); } @@ -183,8 +187,8 @@ ETSLReference::ETSLReference(CodeGen *cg, const ir::AstNode *node, ReferenceKind const auto *memberExpr = Node()->AsMemberExpression(); staticObjRef_ = memberExpr->Object()->TsType(); - if (!memberExpr->IsComputed() && etsg_->Checker()->IsVariableStatic(memberExpr->PropVar()) && - !staticObjRef_->IsETSDynamicType()) { + if (!memberExpr->IsComputed() && memberExpr->PropVar() != nullptr && + etsg_->Checker()->IsVariableStatic(memberExpr->PropVar())) { return; } @@ -197,7 +201,8 @@ ETSLReference::ETSLReference(CodeGen *cg, const ir::AstNode *node, ReferenceKind TargetTypeContext pttctx(etsg_, memberExpr->Property()->TsType()); memberExpr->Property()->Compile(etsg_); etsg_->ApplyConversion(memberExpr->Property()); - ES2PANDA_ASSERT(etsg_->GetAccumulatorType()->HasTypeFlag(checker::TypeFlag::ETS_INTEGRAL)); + ES2PANDA_ASSERT(memberExpr->Object()->TsType()->IsETSAnyType() || + etsg_->GetAccumulatorType()->HasTypeFlag(checker::TypeFlag::ETS_INTEGRAL)); propReg_ = etsg_->AllocReg(); etsg_->StoreAccumulator(node, propReg_); } @@ -281,8 +286,12 @@ void ETSLReference::SetValueComputed(const ir::MemberExpression *memberExpr) con { const auto *const objectType = memberExpr->Object()->TsType(); - if (objectType->IsETSDynamicType()) { - etsg_->StoreElementDynamic(Node(), baseReg_, propReg_); + if (objectType->IsETSAnyType()) { + if (memberExpr->Property()->TsType()->HasTypeFlag(checker::TypeFlag::ETS_NUMERIC)) { + etsg_->StoreByIndexAny(memberExpr, baseReg_, propReg_); + } else { + etsg_->StoreByValueAny(memberExpr, baseReg_, propReg_); + } return; } @@ -295,20 +304,26 @@ void ETSLReference::SetValueComputed(const ir::MemberExpression *memberExpr) con return; } - ES2PANDA_ASSERT(objectType->IsETSArrayType() || objectType->IsETSResizableArrayType()); - auto vRegtype = etsg_->GetVRegType(baseReg_); - auto *elementType = vRegtype->IsETSArrayType() ? vRegtype->AsETSArrayType()->ElementType() - : vRegtype->AsETSResizableArrayType()->ElementType(); - etsg_->StoreArrayElement(Node(), baseReg_, propReg_, elementType); + if (objectType->IsETSArrayType() || objectType->IsETSResizableArrayType()) { + auto vRegtype = etsg_->GetVRegType(baseReg_); + ES2PANDA_ASSERT(vRegtype != nullptr); + auto *elementType = vRegtype->IsETSArrayType() ? vRegtype->AsETSArrayType()->ElementType() + : vRegtype->AsETSResizableArrayType()->ElementType(); + etsg_->StoreArrayElement(Node(), baseReg_, propReg_, elementType); + return; + } + + ES2PANDA_ASSERT(objectType->IsETSNeverType()); // nothing to do, we're in dead code anyway } void ETSLReference::SetValueGetterSetter(const ir::MemberExpression *memberExpr) const { + ES2PANDA_ASSERT(memberExpr->PropVar() != nullptr); const auto *sig = memberExpr->PropVar()->TsType()->AsETSFunctionType()->FindSetter(); auto argReg = etsg_->AllocReg(); etsg_->StoreAccumulator(Node(), argReg); - + ES2PANDA_ASSERT(sig->Function() != nullptr); if (sig->Function()->IsStatic()) { etsg_->CallExact(Node(), sig->InternalName(), argReg); } else if (memberExpr->Object()->IsSuperExpression()) { @@ -327,6 +342,7 @@ void ETSLReference::SetValue() const const auto *const memberExpr = Node()->AsMemberExpression(); const auto *const memberExprTsType = memberExpr->TsType(); + auto const *objectType = memberExpr->Object()->TsType(); if (!memberExpr->IsIgnoreBox()) { etsg_->ApplyConversion(Node(), memberExprTsType); @@ -337,6 +353,12 @@ void ETSLReference::SetValue() const return; } + if (objectType->IsETSAnyType()) { + etsg_->StorePropertyByNameAny(memberExpr, baseReg_, memberExpr->Property()->AsIdentifier()->Name()); + return; + } + + ES2PANDA_ASSERT(memberExpr->PropVar() != nullptr); if (memberExpr->PropVar()->TsType()->HasTypeFlag(checker::TypeFlag::GETTER_SETTER)) { SetValueGetterSetter(memberExpr); return; @@ -346,19 +368,8 @@ void ETSLReference::SetValue() const if (memberExpr->PropVar()->HasFlag(varbinder::VariableFlags::STATIC)) { const util::StringView fullName = etsg_->FormClassPropReference(staticObjRef_->AsETSObjectType(), propName); - if (staticObjRef_->IsETSDynamicType()) { - etsg_->StorePropertyDynamic(Node(), memberExprTsType, baseReg_, propName); - } else { - etsg_->StoreStaticProperty(Node(), memberExprTsType, fullName); - } - - return; - } - - auto const *objectType = memberExpr->Object()->TsType(); + etsg_->StoreStaticProperty(Node(), memberExprTsType, fullName); - if (objectType->IsETSDynamicType()) { - etsg_->StorePropertyDynamic(Node(), memberExprTsType, baseReg_, propName); return; } diff --git a/ets2panda/compiler/core/CFG.cpp b/ets2panda/compiler/core/CFG.cpp index cfafe5d7922d24e1ebdbeb0be82e26b6c0d3d52a..d1e62215e0ce57411bba4c82e0486d888ec68346 100644 --- a/ets2panda/compiler/core/CFG.cpp +++ b/ets2panda/compiler/core/CFG.cpp @@ -32,6 +32,7 @@ size_t CFG::BasicBlock::AddNode(ir::AstNode *node) std::pair CFG::BasicBlock::AddSuccessor(BasicBlock *successor) { + ES2PANDA_ASSERT(successor != nullptr); succs_.push_back(successor); successor->preds_.push_back(this); return std::make_pair(succs_.size() - 1, successor->preds_.size() - 1); @@ -208,6 +209,7 @@ CFG::BasicBlock *CFG::Build(ir::ScriptFunction *scriptFunctionNode) } ES2PANDA_ASSERT(scriptFunctionNode->Body()->IsBlockStatement()); auto exitBB = Build(scriptFunctionNode->Body()->AsBlockStatement(), entryBB); + ES2PANDA_ASSERT(exitBB != nullptr); exitBB->SetFlag(BasicBlockFlags::EXIT); return entryBB; } @@ -231,6 +233,7 @@ CFG::BasicBlock *CFG::CreateNewBB(const std::vector &&preds, const std::vector &&labels) { auto bb = allocator_->New(allocator_, basicBlockIdx_++); + ES2PANDA_ASSERT(bb != nullptr); if (inLoop_ > 0) { bb->SetFlag(BasicBlockFlags::LOOP); } @@ -840,6 +843,7 @@ size_t CFG::AddNodeToBB(ir::AstNode *node, BasicBlock *bb) if (bb == nullptr) { bb = CreateNewBB({}); } + ES2PANDA_ASSERT(bb != nullptr); size_t index = bb->AddNode(node); nodeBBMap_[node] = std::make_pair(bb, index); return index; diff --git a/ets2panda/compiler/core/ETSCompiler.cpp b/ets2panda/compiler/core/ETSCompiler.cpp index 86ee12f811a1febfbb0dbf9396155fea1018198d..75fd7d3de505e7bba5f6d34adae7e5d6b9110aeb 100644 --- a/ets2panda/compiler/core/ETSCompiler.cpp +++ b/ets2panda/compiler/core/ETSCompiler.cpp @@ -16,15 +16,18 @@ #include "ETSCompiler.h" #include "compiler/base/catchTable.h" -#include "checker/ets/dynamic/dynamicCall.h" #include "compiler/base/condition.h" -#include "compiler/core/ETSGen-inl.h" #include "compiler/base/lreference.h" #include "compiler/core/switchBuilder.h" +#include "compiler/core/targetTypeContext.h" +#include "compiler/core/vReg.h" #include "compiler/function/functionBuilder.h" #include "checker/ETSchecker.h" -#include "checker/types/ets/etsDynamicFunctionType.h" #include "checker/types/ets/etsTupleType.h" +#include "ETSGen-inl.h" +#include "generated/signatures.h" +#include "util/es2pandaMacros.h" +#include "varbinder/ETSBinder.h" namespace ark::es2panda::compiler { @@ -53,15 +56,11 @@ void ETSCompiler::Compile(const ir::ClassProperty *st) const auto ttctx = compiler::TargetTypeContext(etsg, st->TsType()); compiler::RegScope rs(etsg); - ir::BoxingUnboxingFlags flags = - (st->Value() != nullptr) ? st->Value()->GetBoxingUnboxingFlags() : ir::BoxingUnboxingFlags::NONE; - if (st->Value() == nullptr) { etsg->LoadDefaultValue(st, st->TsType()); } else { st->Value()->Compile(etsg); etsg->ApplyConversion(st->Value(), st->TsType()); - st->Value()->SetBoxingUnboxingFlags(flags); } if (st->IsStatic()) { @@ -138,8 +137,8 @@ void ETSCompiler::Compile(const ir::ETSNewArrayInstanceExpression *expr) const if (expr->Signature() != nullptr) { const compiler::TargetTypeContext ttctx2(etsg, elementType); - ArenaVector arguments(GetCodeGen()->Allocator()->Adapter()); - etsg->InitObject(expr, expr->Signature(), arguments); + static const ArenaVector ARGUMENTS(GetCodeGen()->Allocator()->Adapter()); + etsg->InitObject(expr, expr->Signature(), ARGUMENTS); } else { etsg->LoadAccumulatorPoison(expr, elementType); } @@ -156,41 +155,6 @@ void ETSCompiler::Compile(const ir::ETSNewArrayInstanceExpression *expr) const ES2PANDA_ASSERT(etsg->Checker()->Relation()->IsIdenticalTo(etsg->GetAccumulatorType(), expr->TsType())); } -static std::pair LoadDynamicName(compiler::ETSGen *etsg, const ir::AstNode *node, - const ArenaVector &dynName, bool isConstructor) -{ - auto *checker = const_cast(etsg->Checker()->AsETSChecker()); - auto *callNames = checker->DynamicCallNames(isConstructor); - - auto qnameStart = etsg->AllocReg(); - auto qnameLen = etsg->AllocReg(); - - TargetTypeContext ttctx(etsg, nullptr); // without this ints will be cast to JSValue - etsg->LoadAccumulatorInt(node, callNames->at(dynName)); - etsg->StoreAccumulator(node, qnameStart); - etsg->LoadAccumulatorInt(node, dynName.size()); - etsg->StoreAccumulator(node, qnameLen); - return {qnameStart, qnameLen}; -} - -static void CreateDynamicObject(const ir::AstNode *node, compiler::ETSGen *etsg, const ir::Expression *typeRef, - checker::Signature *signature, const ArenaVector &arguments) -{ - auto objReg = etsg->AllocReg(); - - auto callInfo = checker::DynamicCall::ResolveCall(etsg->VarBinder(), typeRef); - if (callInfo.obj->IsETSImportDeclaration()) { - etsg->LoadAccumulatorDynamicModule(node, callInfo.obj->AsETSImportDeclaration()); - } else { - callInfo.obj->Compile(etsg); - } - - etsg->StoreAccumulator(node, objReg); - - auto [qnameStart, qnameLen] = LoadDynamicName(etsg, node, callInfo.name, true); - etsg->CallDynamic(ETSGen::CallDynamicData {node, objReg, qnameStart}, qnameLen, signature, arguments); -} - static void ConvertRestArguments(checker::ETSChecker *const checker, const ir::ETSNewClassInstanceExpression *expr) { if (expr->GetSignature()->RestVar() != nullptr && (expr->GetSignature()->RestVar()->TsType()->IsETSArrayType() || @@ -210,6 +174,7 @@ static void ConvertRestArguments(checker::ETSChecker *const checker, const ir::E elements.emplace_back(expr->GetArguments()[i]); } auto *arrayExpression = checker->AllocNode(std::move(elements), checker->Allocator()); + ES2PANDA_ASSERT(arrayExpression != nullptr); arrayExpression->SetParent(const_cast(expr)); auto restType = expr->GetSignature()->RestVar()->TsType()->AsETSArrayType(); arrayExpression->SetTsType(restType); @@ -257,11 +222,7 @@ static void HandleUnionTypeInForOf(compiler::ETSGen *etsg, checker::Type const * } else if (currentType->IsETSResizableArrayType()) { etsg->LoadResizableArrayElement(st, unionReg, *countReg); } else { - etsg->LoadStringChar(st, unionReg, *countReg); - // NOTE(vpukhov): #20510 use a single unboxing convertor - etsg->ApplyCastToBoxingFlags(st, ir::BoxingUnboxingFlags::BOX_TO_CHAR); - etsg->EmitBoxingConversion(ir::BoxingUnboxingFlags::BOX_TO_CHAR, st); - etsg->CastToChar(st); + etsg->LoadStringChar(st, unionReg, *countReg, true); } } @@ -288,15 +249,17 @@ static void GetSizeInForOf(compiler::ETSGen *etsg, checker::Type const *const ex void ETSCompiler::Compile(const ir::ETSNewClassInstanceExpression *expr) const { ETSGen *etsg = GetETSGen(); - if (expr->TsType()->IsETSDynamicType()) { + + if (expr->TsType()->IsETSAnyType()) { compiler::RegScope rs(etsg); - auto *name = expr->GetTypeRef(); - CreateDynamicObject(expr, etsg, name, expr->signature_, expr->GetArguments()); + auto objReg = etsg->AllocReg(); + expr->GetTypeRef()->Compile(etsg); + etsg->StoreAccumulator(expr->GetTypeRef(), objReg); + etsg->CallAnyNew(expr, expr->GetArguments(), objReg); } else { ConvertRestArguments(const_cast(etsg->Checker()->AsETSChecker()), expr); etsg->InitObject(expr, expr->signature_, expr->GetArguments()); } - etsg->SetAccumulatorType(expr->TsType()); } @@ -334,6 +297,11 @@ void ETSCompiler::Compile(const ir::ETSTypeReferencePart *node) const ES2PANDA_ASSERT(etsg->Checker()->Relation()->IsIdenticalTo(etsg->GetAccumulatorType(), node->TsType())); } +void ETSCompiler::Compile(const ir::OpaqueTypeNode *node) const +{ + GetETSGen()->SetAccumulatorType(node->TsType()); +} + void ETSCompiler::Compile([[maybe_unused]] const ir::ETSWildcardType *node) const { ES2PANDA_UNREACHABLE(); @@ -523,6 +491,17 @@ static void CompileLogical(compiler::ETSGen *etsg, const ir::BinaryExpression *e etsg->SetAccumulatorType(expr->TsType()); } +static void CompileAnyInstanceOf(compiler::ETSGen *etsg, const VReg lhs, const ir::Expression *expr) +{ + RegScope rs(etsg); + VReg objReg = etsg->AllocReg(); + expr->Compile(etsg); + etsg->StoreAccumulator(expr, objReg); + etsg->LoadAccumulator(expr, lhs); + etsg->EmitAnyIsInstance(expr, objReg); + etsg->SetAccumulatorType(etsg->Checker()->GlobalETSBooleanType()); +} + static void CompileInstanceof(compiler::ETSGen *etsg, const ir::BinaryExpression *expr) { ES2PANDA_ASSERT(expr->OperatorType() == lexer::TokenType::KEYW_INSTANCEOF); @@ -533,13 +512,10 @@ static void CompileInstanceof(compiler::ETSGen *etsg, const ir::BinaryExpression expr->Left()->Compile(etsg); etsg->ApplyConversionAndStoreAccumulator(expr->Left(), lhs, expr->OperationType()); - if (expr->Left()->TsType()->IsETSDynamicType() || expr->Right()->TsType()->IsETSDynamicType()) { - auto rhs = etsg->AllocReg(); - expr->Right()->Compile(etsg); - etsg->StoreAccumulator(expr, rhs); - etsg->IsInstanceDynamic(expr, lhs, rhs); + auto target = expr->Right()->TsType(); + if (target->IsETSAnyType() && target->AsETSAnyType()->IsRelaxedAny()) { + CompileAnyInstanceOf(etsg, lhs, expr->Right()); } else { - auto target = expr->Right()->TsType(); etsg->IsInstance(expr, lhs, target); } ES2PANDA_ASSERT(etsg->Checker()->Relation()->IsIdenticalTo(etsg->GetAccumulatorType(), expr->TsType())); @@ -700,46 +676,56 @@ void ETSCompiler::Compile(const ir::BlockExpression *expr) const expr->Scope()->SetParent(oldParent); } -void ETSCompiler::CompileDynamic(const ir::CallExpression *expr, compiler::VReg &calleeReg) const +bool IsCastCallName(util::StringView name) { - ETSGen *etsg = GetETSGen(); - auto callInfo = checker::DynamicCall::ResolveCall(etsg->VarBinder(), expr->Callee()); - if (callInfo.obj->IsETSImportDeclaration()) { - etsg->LoadAccumulatorDynamicModule(expr, callInfo.obj->AsETSImportDeclaration()); - } else { - callInfo.obj->Compile(etsg); - } - etsg->StoreAccumulator(expr, calleeReg); - - if (!callInfo.name.empty()) { - auto [qnameStart, qnameLen] = LoadDynamicName(etsg, expr, callInfo.name, false); - etsg->CallDynamic(ETSGen::CallDynamicData {expr, calleeReg, qnameStart}, qnameLen, expr->Signature(), - expr->Arguments()); - } else { - compiler::VReg dynParam2 = etsg->AllocReg(); + return name == Signatures::BYTE_CAST || name == Signatures::SHORT_CAST || name == Signatures::INT_CAST || + name == Signatures::LONG_CAST || name == Signatures::FLOAT_CAST || name == Signatures::DOUBLE_CAST || + name == Signatures::CHAR_CAST; +} - auto lang = expr->Callee()->TsType()->IsETSDynamicFunctionType() - ? expr->Callee()->TsType()->AsETSDynamicFunctionType()->Language() - : expr->Callee()->TsType()->AsETSDynamicType()->Language(); - etsg->LoadUndefinedDynamic(expr, lang); - etsg->StoreAccumulator(expr, dynParam2); - etsg->CallDynamic(ETSGen::CallDynamicData {expr, calleeReg, dynParam2}, expr->Signature(), expr->Arguments()); - } - etsg->SetAccumulatorType(expr->Signature()->ReturnType()); +bool IsCastCall(checker::Signature *signature) +{ + ES2PANDA_ASSERT(signature->HasSignatureFlag(checker::SignatureFlags::STATIC)); + auto *func = signature->Function(); + return (func->Parent()->Parent()->IsMethodDefinition() && IsCastCallName(func->Id()->Name()) && + util::Helpers::ContainingClass(func)->AsETSObjectType()->IsBoxedPrimitive() && + (signature->Params().size() == 1) && signature->Params()[0]->TsType()->IsETSPrimitiveType()); +} - if (etsg->GetAccumulatorType() != expr->TsType()) { - etsg->ApplyConversion(expr, expr->TsType()); +void ETSCompiler::CompileAny(const ir::CallExpression *expr, const ir::Expression *callee, + compiler::VReg &calleeReg) const +{ + ETSGen *etsg = GetETSGen(); + auto memberExpr = callee->AsMemberExpression(); + memberExpr->Object()->Compile(etsg); + compiler::VReg objReg = etsg->AllocReg(); + etsg->StoreAccumulator(expr, objReg); + auto ttctx = compiler::TargetTypeContext(etsg, expr->TsType()); + if (expr->Signature()->Function() != nullptr && expr->Signature()->Function()->IsStatic()) { + etsg->LoadPropertyByNameAny(memberExpr, objReg, memberExpr->Property()->AsIdentifier()->Name()); + etsg->StoreAccumulator(expr, calleeReg); + etsg->CallAny(callee->AsMemberExpression()->Object(), expr->Arguments(), calleeReg); + } else { + etsg->CallAnyThis(expr, memberExpr->Property()->AsIdentifier(), expr->Arguments(), objReg); } + etsg->EmitAnyCheckCast(expr, expr->TsType()); } void ETSCompiler::EmitCall(const ir::CallExpression *expr, compiler::VReg &calleeReg, checker::Signature *signature) const { ETSGen *etsg = GetETSGen(); - if (expr->Callee()->GetBoxingUnboxingFlags() != ir::BoxingUnboxingFlags::NONE) { - etsg->ApplyConversionAndStoreAccumulator(expr->Callee(), calleeReg, nullptr); - } if (signature->HasSignatureFlag(checker::SignatureFlags::STATIC)) { + if (IsCastCall(signature)) { + ES2PANDA_ASSERT(expr->Arguments().size() == 1); + auto *param = expr->Arguments()[0]; + param->Compile(etsg); + + const auto *const targetType = etsg->Checker()->GetApparentType(expr->TsType()); + auto ttctx = compiler::TargetTypeContext(etsg, nullptr); + CompileCastPrimitives(param, targetType); + return; + } etsg->CallExact(expr, expr->Signature(), expr->Arguments()); } else if (expr->Callee()->IsMemberExpression()) { auto me = expr->Callee()->AsMemberExpression(); @@ -749,6 +735,7 @@ void ETSCompiler::EmitCall(const ir::CallExpression *expr, compiler::VReg &calle // NOTE: need to refactor: type of member expression object can be obtained via // me->ObjType() or me->Object()->TsType() and they may differ!!!! } else if (me->ObjType() == etsg->Checker()->GlobalETSObjectType() && + (etsg->Checker()->GetApparentType(me->Object()->TsType()) != nullptr) && (etsg->Checker()->GetApparentType(me->Object()->TsType())->IsETSUnionType())) { etsg->CallByName(expr, signature, calleeReg, expr->Arguments()); } else { @@ -776,8 +763,8 @@ void ETSCompiler::Compile(const ir::CallExpression *expr) const ConvertRestArguments(const_cast(etsg->Checker()->AsETSChecker()), expr, signature); - if (callee->TsType()->HasTypeFlag(checker::TypeFlag::ETS_DYNAMIC_FLAG)) { - CompileDynamic(expr, calleeReg); + if (expr->IsDynamicCall()) { + CompileAny(expr, callee, calleeReg); } else if (callee->IsIdentifier()) { if (!isStatic) { etsg->LoadThis(expr); @@ -798,10 +785,6 @@ void ETSCompiler::Compile(const ir::CallExpression *expr) const } else { ES2PANDA_UNREACHABLE(); } - - if (expr->HasBoxingUnboxingFlags(ir::BoxingUnboxingFlags::UNBOXING_FLAG | ir::BoxingUnboxingFlags::BOXING_FLAG)) { - etsg->ApplyConversion(expr, expr->TsType()); - } } void ETSCompiler::Compile(const ir::ConditionalExpression *expr) const @@ -833,6 +816,7 @@ void ETSCompiler::Compile(const ir::Identifier *expr) const ETSGen *etsg = GetETSGen(); auto const *smartType = expr->TsType(); + ES2PANDA_ASSERT(smartType != nullptr); if (smartType->IsETSTypeParameter() || smartType->IsETSPartialTypeParameter() || smartType->IsETSNonNullishType()) { smartType = etsg->Checker()->GetApparentType(smartType); } @@ -854,15 +838,15 @@ void ETSCompiler::Compile(const ir::Identifier *expr) const etsg->SetAccumulatorType(smartType); } -static void LoadETSDynamicTypeFromMemberExpr(compiler::ETSGen *etsg, const ir::MemberExpression *expr, - compiler::VReg objReg) +static void LoadETSAnyTypeFromMemberExpr(compiler::ETSGen *etsg, const ir::MemberExpression *expr, + compiler::VReg objReg) { - if (etsg->Checker()->AsETSChecker()->Relation()->IsSupertypeOf(etsg->Checker()->GlobalBuiltinETSStringType(), - expr->Property()->TsType())) { - etsg->LoadPropertyDynamic(expr, expr->TsType(), objReg, expr->Property()); + if (expr->Property()->TsType()->HasTypeFlag(checker::TypeFlag::ETS_NUMERIC)) { + etsg->LoadByIndexAny(expr, objReg); } else { - etsg->LoadElementDynamic(expr, objReg); + etsg->LoadByValueAny(expr, objReg); } + etsg->EmitAnyCheckCast(expr, expr->TsType()); } bool ETSCompiler::CompileComputed(compiler::ETSGen *etsg, const ir::MemberExpression *expr) @@ -890,8 +874,8 @@ bool ETSCompiler::CompileComputed(compiler::ETSGen *etsg, const ir::MemberExpres auto indexValue = *expr->GetTupleIndexValue(); auto *tupleElementType = objectType->AsETSTupleType()->GetTypeAtIndex(indexValue); etsg->LoadTupleElement(expr, objReg, tupleElementType, indexValue); - } else if (objectType->IsETSDynamicType()) { - LoadETSDynamicTypeFromMemberExpr(etsg, expr, objReg); + } else if (objectType->IsETSAnyType()) { + LoadETSAnyTypeFromMemberExpr(etsg, expr, objReg); } else { ES2PANDA_ASSERT(objectType->IsETSArrayType()); etsg->LoadArrayElement(expr, objReg); @@ -904,6 +888,23 @@ bool ETSCompiler::CompileComputed(compiler::ETSGen *etsg, const ir::MemberExpres return true; } +bool ETSCompiler::CompileAny(compiler::ETSGen *etsg, const ir::MemberExpression *expr) const +{ + if (!etsg->Checker()->GetApparentType(expr->Object()->TsType())->IsETSAnyType()) { + return false; + } + auto ottctx = compiler::TargetTypeContext(etsg, expr->Object()->TsType()); + etsg->CompileAndCheck(expr->Object()); + + compiler::VReg objReg = etsg->AllocReg(); + etsg->StoreAccumulator(expr, objReg); + + auto ttctx = compiler::TargetTypeContext(etsg, expr->TsType()); + etsg->LoadPropertyByNameAny(expr, objReg, expr->Property()->AsIdentifier()->Name()); + etsg->EmitAnyCheckCast(expr, expr->TsType()); + return true; +} + void ETSCompiler::Compile(const ir::MemberExpression *expr) const { ETSGen *etsg = GetETSGen(); @@ -914,6 +915,10 @@ void ETSCompiler::Compile(const ir::MemberExpression *expr) const return; } + if (CompileAny(etsg, expr)) { + return; + } + if (HandleArrayTypeLengthProperty(expr, etsg)) { return; } @@ -935,14 +940,13 @@ void ETSCompiler::Compile(const ir::MemberExpression *expr) const auto ttctx = compiler::TargetTypeContext(etsg, expr->TsType()); ES2PANDA_ASSERT(expr->PropVar()->TsType() != nullptr); const checker::Type *const variableType = expr->PropVar()->TsType(); + ES2PANDA_ASSERT(variableType != nullptr); if (variableType->HasTypeFlag(checker::TypeFlag::GETTER_SETTER)) { if (expr->Object()->IsSuperExpression()) { etsg->CallExact(expr, variableType->AsETSFunctionType()->FindGetter()->InternalName(), objReg); } else { etsg->CallVirtual(expr, variableType->AsETSFunctionType()->FindGetter(), objReg); } - } else if (objectType->IsETSDynamicType()) { - etsg->LoadPropertyDynamic(expr, expr->TsType(), objReg, propName); } else if (objectType->IsETSUnionType()) { etsg->LoadPropertyByName(expr, objReg, checker::ETSChecker::FormNamedAccessMetadata(expr->PropVar())); } else { @@ -957,6 +961,7 @@ void ETSCompiler::Compile(const ir::MemberExpression *expr) const bool ETSCompiler::HandleArrayTypeLengthProperty(const ir::MemberExpression *expr, ETSGen *etsg) const { auto *const objectType = etsg->Checker()->GetApparentType(expr->Object()->TsType()); + ES2PANDA_ASSERT(objectType != nullptr); auto &propName = expr->Property()->AsIdentifier()->Name(); if (objectType->IsETSArrayType() && propName.Is("length")) { auto ottctx = compiler::TargetTypeContext(etsg, objectType); @@ -980,6 +985,7 @@ bool ETSCompiler::HandleStaticProperties(const ir::MemberExpression *expr, ETSGe if (auto const *const varType = variable->TsType(); varType->HasTypeFlag(checker::TypeFlag::GETTER_SETTER)) { checker::Signature *sig = varType->AsETSFunctionType()->FindGetter(); + ES2PANDA_ASSERT(sig != nullptr); etsg->CallExact(expr, sig->InternalName()); etsg->SetAccumulatorType(expr->TsType()); } else { @@ -997,15 +1003,25 @@ bool ETSCompiler::HandleStaticProperties(const ir::MemberExpression *expr, ETSGe return false; } +void ETSCompiler::Compile(const ir::ETSIntrinsicNode *expr) const +{ + ETSGen *etsg = GetETSGen(); + // Note (daizihan): #27074, make it more scalable when IntrinsicNodeType is extended. + if (expr->Type() == ir::IntrinsicNodeType::TYPE_REFERENCE) { + // Note (daizihan): #27086, we should not use stringLiteral as argument in ETSIntrinsicNode, should be TypeNode. + etsg->EmitLdaType(expr, expr->Arguments()[0]->AsStringLiteral()->Str()); + etsg->SetAccumulatorType(expr->TsType()); + return; + } + ES2PANDA_UNREACHABLE(); +} + void ETSCompiler::Compile(const ir::ObjectExpression *expr) const { ETSGen *etsg = GetETSGen(); compiler::RegScope rs {etsg}; compiler::VReg objReg = etsg->AllocReg(); - // NOTE: object expressions of dynamic type are not handled in objectLiteralLowering phase - ES2PANDA_ASSERT(expr->TsType()->IsETSDynamicType()); - auto *signatureInfo = etsg->Allocator()->New(etsg->Allocator()); auto *createObjSig = etsg->Allocator()->New(signatureInfo, nullptr, nullptr); createObjSig->SetInternalName(compiler::Signatures::BUILTIN_JSRUNTIME_CREATE_OBJECT); @@ -1033,11 +1049,7 @@ void ETSCompiler::Compile(const ir::ObjectExpression *expr) const value->Compile(etsg); etsg->ApplyConversion(value, key->TsType()); - if (expr->TsType()->IsETSDynamicType()) { - etsg->StorePropertyDynamic(expr, value->TsType(), objReg, pname); - } else { - etsg->StoreProperty(expr, key->TsType(), objReg, pname); - } + etsg->StoreProperty(expr, key->TsType(), objReg, pname); } etsg->LoadAccumulator(expr, objReg); @@ -1414,9 +1426,9 @@ void ETSCompiler::Compile(const ir::ReturnStatement *st) const return; } - auto ttctx = compiler::TargetTypeContext(etsg, etsg->ReturnType()); + auto ttctx = compiler::TargetTypeContext(etsg, st->ReturnType()); argument->Compile(etsg); - etsg->ApplyConversion(argument, etsg->ReturnType()); + etsg->ApplyConversion(argument, st->ReturnType()); if (etsg->ExtendWithFinalizer(st->Parent(), st)) { return; @@ -1528,6 +1540,7 @@ void ETSCompiler::Compile(const ir::VariableDeclarator *st) const etsg->LoadDefaultValue(st, st->Id()->AsIdentifier()->Variable()->TsType()); } + // ????????????????????????????????????? is this meaningfull???? etsg->ApplyConversion(st, st->TsType()); lref.SetValue(); } @@ -1570,46 +1583,9 @@ void ETSCompiler::Compile(const ir::TSArrayType *node) const etsg->LoadAccumulatorPoison(node, node->TsType()); } -void ETSCompiler::CompileCastUnboxable(const ir::TSAsExpression *expr) const -{ - ETSGen *etsg = GetETSGen(); - auto *targetType = etsg->Checker()->GetApparentType(expr->TsType()); - ES2PANDA_ASSERT(targetType->IsETSObjectType()); - - switch (targetType->AsETSObjectType()->UnboxableKind()) { - case checker::ETSObjectFlags::BUILTIN_BOOLEAN: - etsg->CastToBoolean(expr); - break; - case checker::ETSObjectFlags::BUILTIN_BYTE: - etsg->CastToByte(expr); - break; - case checker::ETSObjectFlags::BUILTIN_CHAR: - etsg->CastToChar(expr); - break; - case checker::ETSObjectFlags::BUILTIN_SHORT: - etsg->CastToShort(expr); - break; - case checker::ETSObjectFlags::BUILTIN_INT: - etsg->CastToInt(expr); - break; - case checker::ETSObjectFlags::BUILTIN_LONG: - etsg->CastToLong(expr); - break; - case checker::ETSObjectFlags::BUILTIN_FLOAT: - etsg->CastToFloat(expr); - break; - case checker::ETSObjectFlags::BUILTIN_DOUBLE: - etsg->CastToDouble(expr); - break; - default: - ES2PANDA_UNREACHABLE(); - } -} - -void ETSCompiler::CompileCastPrimitives(const ir::TSAsExpression *expr) const +void ETSCompiler::CompileCastPrimitives(const ir::Expression *expr, checker::Type const *targetType) const { ETSGen *etsg = GetETSGen(); - auto *targetType = etsg->Checker()->GetApparentType(expr->TsType()); switch (checker::ETSChecker::TypeKind(targetType)) { case checker::TypeFlag::ETS_BOOLEAN: { @@ -1648,12 +1624,25 @@ void ETSCompiler::CompileCastPrimitives(const ir::TSAsExpression *expr) const ES2PANDA_UNREACHABLE(); } } + etsg->SetAccumulatorType(targetType); +} + +// NOTE(gogabr): will be needed once we forbid as conversions +/* +static void CastIfDynamic(ETSGen *etsg, ir::Expression const *expr, checker::TypeFlag typeFlag) +{ + // CC-OFFNXT(redundant_code[C++]) tmp code + if (checker::ETSChecker::TypeKind(expr->TsType()) == checker::TypeFlag::ETS_DYNAMIC_TYPE) { + etsg->CastDynamicToe(expr, typeFlag); + return; + } + ES2PANDA_UNREACHABLE(); } +*/ -void ETSCompiler::CompileCast(const ir::TSAsExpression *expr) const +void ETSCompiler::CompileCast(const ir::TSAsExpression *expr, checker::Type const *targetType) const { ETSGen *etsg = GetETSGen(); - auto *targetType = etsg->Checker()->GetApparentType(expr->TsType()); switch (checker::ETSChecker::TypeKind(targetType)) { case checker::TypeFlag::ETS_ARRAY: @@ -1664,17 +1653,35 @@ void ETSCompiler::CompileCast(const ir::TSAsExpression *expr) const case checker::TypeFlag::ETS_NONNULLISH: case checker::TypeFlag::ETS_PARTIAL_TYPE_PARAMETER: case checker::TypeFlag::ETS_UNION: + case checker::TypeFlag::ETS_ANY: case checker::TypeFlag::ETS_NULL: case checker::TypeFlag::ETS_UNDEFINED: { etsg->CastToReftype(expr, targetType, expr->isUncheckedCast_); break; } - case checker::TypeFlag::ETS_DYNAMIC_TYPE: { - etsg->CastToDynamic(expr, targetType->AsETSDynamicType()); + // NOTE(gogabr): will be needed once we forbid as conversion + /* + // CC-OFFNXT(redundant_code[C++]) tmp code + case checker::TypeFlag::DOUBLE: + case checker::TypeFlag::STRING: + case checker::TypeFlag::ETS_BOOLEAN: { + CastIfDynamic(etsg, expr->Expr(), targetType->TypeFlags()); + break; // no further conversion + } + case checker::TypeFlag::BYTE: + case checker::TypeFlag::SHORT: + case checker::TypeFlag::INT: + case checker::TypeFlag::LONG: + case checker::TypeFlag::FLOAT: + case checker::TypeFlag::CHAR: { + CastIfDynamic(etsg, expr->Expr(), targetType->TypeFlags()); + CompileCastPrimitives(expr, targetType); break; } + */ default: { - CompileCastPrimitives(expr); + CompileCastPrimitives(expr, targetType); + break; } } } @@ -1686,26 +1693,11 @@ void ETSCompiler::Compile(const ir::TSAsExpression *expr) const const auto *const targetType = etsg->Checker()->GetApparentType(expr->TsType()); - auto ttctx = compiler::TargetTypeContext(etsg, nullptr); - if ((expr->Expr()->GetBoxingUnboxingFlags() & ir::BoxingUnboxingFlags::UNBOXING_FLAG) != 0U) { - etsg->ApplyUnboxingConversion(expr->Expr()); + if (!etsg->Checker()->Relation()->IsIdenticalTo(etsg->GetAccumulatorType(), targetType)) { + auto ttctx = compiler::TargetTypeContext(etsg, nullptr); + CompileCast(expr, targetType); + ES2PANDA_ASSERT(etsg->Checker()->Relation()->IsIdenticalTo(etsg->GetAccumulatorType(), targetType)); } - - if (targetType->IsETSObjectType() && - ((expr->Expr()->GetBoxingUnboxingFlags() & ir::BoxingUnboxingFlags::UNBOXING_FLAG) != 0U || - (expr->Expr()->GetBoxingUnboxingFlags() & ir::BoxingUnboxingFlags::BOXING_FLAG) != 0U) && - checker::ETSChecker::TypeKind(etsg->GetAccumulatorType()) != checker::TypeFlag::ETS_OBJECT) { - if (targetType->IsETSUnboxableObject()) { - CompileCastUnboxable(expr); - } - } - - if ((expr->Expr()->GetBoxingUnboxingFlags() & ir::BoxingUnboxingFlags::BOXING_FLAG) != 0U) { - etsg->ApplyBoxingConversion(expr->Expr()); - } - - CompileCast(expr); - ES2PANDA_ASSERT(etsg->Checker()->Relation()->IsIdenticalTo(etsg->GetAccumulatorType(), targetType)); } void ETSCompiler::Compile([[maybe_unused]] const ir::TSInterfaceDeclaration *st) const {} @@ -1718,18 +1710,22 @@ void ETSCompiler::Compile(const ir::TSNonNullExpression *expr) const expr->Expr()->Compile(etsg); if (etsg->GetAccumulatorType()->PossiblyETSNullish()) { - auto arg = etsg->AllocReg(); - etsg->StoreAccumulator(expr, arg); - etsg->LoadAccumulator(expr, arg); + if (!etsg->GetAccumulatorType()->PossiblyETSNull()) { + etsg->EmitNullcheck(expr); + etsg->SetAccumulatorType(expr->OriginalType()); + } else { + auto arg = etsg->AllocReg(); + etsg->StoreAccumulator(expr, arg); - auto endLabel = etsg->AllocLabel(); + auto endLabel = etsg->AllocLabel(); - etsg->BranchIfNotNullish(expr, endLabel); - etsg->EmitNullishException(expr); + etsg->BranchIfNotNullish(expr, endLabel); + etsg->EmitNullishException(expr); - etsg->SetLabel(expr, endLabel); - etsg->LoadAccumulator(expr, arg); - etsg->AssumeNonNullish(expr, expr->OriginalType()); + etsg->SetLabel(expr, endLabel); + etsg->LoadAccumulator(expr, arg); + etsg->AssumeNonNullish(expr, expr->OriginalType()); + } } ES2PANDA_ASSERT(etsg->Checker()->Relation()->IsIdenticalTo(etsg->GetAccumulatorType(), expr->OriginalType())); @@ -1737,4 +1733,17 @@ void ETSCompiler::Compile(const ir::TSNonNullExpression *expr) const void ETSCompiler::Compile([[maybe_unused]] const ir::TSTypeAliasDeclaration *st) const {} +void ETSCompiler::Compile(const ir::TSQualifiedName *expr) const +{ + ES2PANDA_ASSERT(expr->Left()->IsMemberExpression()); + + ETSGen *etsg = GetETSGen(); + expr->Left()->Compile(etsg); + + compiler::VReg objReg = etsg->AllocReg(); + etsg->StoreAccumulator(expr->Left(), objReg); + etsg->LoadPropertyByNameAny(expr->Left(), objReg, expr->Right()->AsIdentifier()->Name()); + etsg->EmitAnyCheckCast(expr, expr->Right()->AsIdentifier()->Variable()->TsType()); +} + } // namespace ark::es2panda::compiler diff --git a/ets2panda/compiler/core/ETSCompiler.h b/ets2panda/compiler/core/ETSCompiler.h index 94cd1e8f35b8cdbe204d965a029984772d864185..868ce81e497e15dbcb51d9a6dd65191d2249dc58 100644 --- a/ets2panda/compiler/core/ETSCompiler.h +++ b/ets2panda/compiler/core/ETSCompiler.h @@ -35,10 +35,9 @@ public: private: void GetDynamicNameParts(const ir::CallExpression *expr, ArenaVector &parts) const; - void CompileDynamic(const ir::CallExpression *expr, compiler::VReg &calleeReg) const; - void CompileCastUnboxable(const ir::TSAsExpression *expr) const; - void CompileCastPrimitives(const ir::TSAsExpression *expr) const; - void CompileCast(const ir::TSAsExpression *expr) const; + void CompileAny(const ir::CallExpression *expr, const ir::Expression *callee, compiler::VReg &calleeReg) const; + void CompileCastPrimitives(const ir::Expression *expr, checker::Type const *targetType) const; + void CompileCast(const ir::TSAsExpression *expr, checker::Type const *targetType) const; void EmitCall(const ir::CallExpression *expr, compiler::VReg &calleeReg, checker::Signature *signature) const; bool HandleArrayTypeLengthProperty(const ir::MemberExpression *expr, ETSGen *etsg) const; bool HandleStaticProperties(const ir::MemberExpression *expr, ETSGen *etsg) const; @@ -46,6 +45,7 @@ private: void CompileTupleCreation(const ir::ArrayExpression *tupleInitializer) const; static bool CompileComputed(compiler::ETSGen *etsg, const ir::MemberExpression *expr); + bool CompileAny(compiler::ETSGen *etsg, const ir::MemberExpression *expr) const; ETSGen *GetETSGen() const; }; diff --git a/ets2panda/compiler/core/ETSCompilerUnrechable.cpp b/ets2panda/compiler/core/ETSCompilerUnrechable.cpp index edcf0a2205a199f8fffcfa611f29d53ae946bcee..77abdb301f86cd6b76c5033bbadab54716439844 100644 --- a/ets2panda/compiler/core/ETSCompilerUnrechable.cpp +++ b/ets2panda/compiler/core/ETSCompilerUnrechable.cpp @@ -52,6 +52,11 @@ void ETSCompiler::Compile([[maybe_unused]] const ir::MethodDefinition *node) con ES2PANDA_UNREACHABLE(); } +void ETSCompiler::Compile([[maybe_unused]] const ir::OverloadDeclaration *node) const +{ + ES2PANDA_UNREACHABLE(); +} + void ETSCompiler::Compile([[maybe_unused]] const ir::Property *expr) const { ES2PANDA_UNREACHABLE(); @@ -193,11 +198,6 @@ void ETSCompiler::Compile([[maybe_unused]] const ir::OmittedExpression *expr) co ES2PANDA_UNREACHABLE(); } -void ETSCompiler::Compile([[maybe_unused]] const ir::OpaqueTypeNode *node) const -{ - ES2PANDA_UNREACHABLE(); -} - void ETSCompiler::Compile([[maybe_unused]] const ir::BrokenTypeNode *node) const { ES2PANDA_UNREACHABLE(); @@ -424,11 +424,6 @@ void ETSCompiler::Compile([[maybe_unused]] const ir::TSParenthesizedType *node) ES2PANDA_UNREACHABLE(); } -void ETSCompiler::Compile([[maybe_unused]] const ir::TSQualifiedName *expr) const -{ - ES2PANDA_UNREACHABLE(); -} - void ETSCompiler::Compile([[maybe_unused]] const ir::TSStringKeyword *node) const { ES2PANDA_UNREACHABLE(); diff --git a/ets2panda/compiler/core/ETSGen.cpp b/ets2panda/compiler/core/ETSGen.cpp index e539dffc831402c382dcc99a5fcb1be9960bf545..0a724cf0d7e6f21d80a75d3dfc640b4b1a9d6e4e 100644 --- a/ets2panda/compiler/core/ETSGen.cpp +++ b/ets2panda/compiler/core/ETSGen.cpp @@ -13,9 +13,10 @@ * limitations under the License. */ -#include "ETSGen.h" #include "ETSGen-inl.h" +#include "compiler/core/regScope.h" +#include "generated/isa.h" #include "generated/signatures.h" #include "ir/base/scriptFunction.h" #include "ir/base/classDefinition.h" @@ -30,14 +31,13 @@ #include "ir/statements/continueStatement.h" #include "ir/statements/tryStatement.h" #include "ir/ts/tsInterfaceDeclaration.h" -#include "varbinder/variableFlags.h" #include "compiler/base/lreference.h" #include "compiler/base/catchTable.h" #include "compiler/core/dynamicContext.h" #include "varbinder/ETSBinder.h" #include "varbinder/variable.h" #include "checker/types/type.h" -#include "checker/types/typeFlag.h" +#include "checker/types/signature.h" #include "checker/checker.h" #include "checker/ETSchecker.h" #include "checker/types/ets/etsObjectType.h" @@ -86,6 +86,7 @@ void ETSGen::CompileAndCheck(const ir::Expression *expr) return; } + ES2PANDA_ASSERT(accType != nullptr); if (accType->IsETSPrimitiveType() && ((accType->TypeFlags() ^ exprType->TypeFlags()) & ~checker::TypeFlag::CONSTANT) == 0) { return; @@ -97,7 +98,7 @@ void ETSGen::CompileAndCheck(const ir::Expression *expr) const checker::ETSChecker *ETSGen::Checker() const noexcept { - return Context()->checker->AsETSChecker(); + return Context()->GetChecker()->AsETSChecker(); } const varbinder::ETSBinder *ETSGen::VarBinder() const noexcept @@ -216,6 +217,7 @@ checker::Type const *ETSGen::TypeForVar(varbinder::Variable const *var) const no void ETSGen::MoveVreg(const ir::AstNode *const node, const VReg vd, const VReg vs) { const auto *const sourceType = GetVRegType(vs); + ES2PANDA_ASSERT(sourceType != nullptr); if (sourceType->IsETSReferenceType()) { Ra().Emit(node, vd, vs); @@ -236,71 +238,8 @@ void ETSGen::LoadAccumulatorPoison(const ir::AstNode *node, const checker::Type SetAccumulatorType(type); } -util::StringView ETSGen::FormDynamicModulePropReference(const varbinder::Variable *var) -{ - ES2PANDA_ASSERT(VarBinder()->IsDynamicModuleVariable(var) || VarBinder()->IsDynamicNamespaceVariable(var)); - - auto *data = VarBinder()->DynamicImportDataForVar(var); - ES2PANDA_ASSERT(data != nullptr); - - auto *import = data->import; - - return FormDynamicModulePropReference(import); -} - -void ETSGen::LoadAccumulatorDynamicModule(const ir::AstNode *node, const ir::ETSImportDeclaration *import) -{ - ES2PANDA_ASSERT(import->Language().IsDynamic()); - LoadStaticProperty(node, Checker()->GlobalBuiltinDynamicType(import->Language()), - FormDynamicModulePropReference(import)); -} - -util::StringView ETSGen::FormDynamicModulePropReference(const ir::ETSImportDeclaration *import) -{ - std::stringstream ss; - ss << VarBinder()->Program()->ModulePrefix(); - ss << compiler::Signatures::DYNAMIC_MODULE_CLASS; - ss << '.'; - ss << import->AssemblerName(); - return util::UString(ss.str(), Allocator()).View(); -} - -void ETSGen::LoadDynamicModuleVariable(const ir::AstNode *node, varbinder::Variable const *const var) -{ - RegScope rs(this); - - auto *data = VarBinder()->DynamicImportDataForVar(var); - auto *import = data->import; - - LoadStaticProperty(node, var->TsType(), FormDynamicModulePropReference(var)); - - auto objReg = AllocReg(); - StoreAccumulator(node, objReg); - - auto *id = data->specifier->AsImportSpecifier()->Imported(); - auto lang = import->Language(); - LoadPropertyDynamic(node, Checker()->GlobalBuiltinDynamicType(lang), objReg, id->Name()); - - ApplyConversion(node); -} - -void ETSGen::LoadDynamicNamespaceVariable(const ir::AstNode *node, varbinder::Variable const *const var) -{ - LoadStaticProperty(node, var->TsType(), FormDynamicModulePropReference(var)); -} - void ETSGen::LoadVar(const ir::Identifier *node, varbinder::Variable const *const var) { - if (VarBinder()->IsDynamicModuleVariable(var)) { - LoadDynamicModuleVariable(node, var); - return; - } - - if (VarBinder()->IsDynamicNamespaceVariable(var)) { - LoadDynamicNamespaceVariable(node, var); - return; - } - auto *local = var->AsLocalVariable(); switch (ETSLReference::ResolveReferenceKind(var)) { @@ -310,6 +249,7 @@ void ETSGen::LoadVar(const ir::Identifier *node, varbinder::Variable const *cons break; } case ReferenceKind::FIELD: { + ES2PANDA_ASSERT(GetVRegType(GetThisReg()) != nullptr); const auto fullName = FormClassPropReference(GetVRegType(GetThisReg())->AsETSObjectType(), var->Name()); LoadProperty(node, var->TsType(), GetThisReg(), fullName); break; @@ -361,6 +301,7 @@ void ETSGen::StoreVar(const ir::Identifier *node, const varbinder::ConstScopeFin util::StringView ETSGen::FormClassPropReference(const checker::ETSObjectType *classType, const util::StringView &name) { std::stringstream ss; + ES2PANDA_ASSERT(classType != nullptr); ss << classType->AssemblerName().Mutf8() << Signatures::METHOD_SEPARATOR << name; return util::StringView(*ProgElement()->Strings().emplace(ss.str()).first); } @@ -390,11 +331,30 @@ void ETSGen::StoreStaticProperty(const ir::AstNode *const node, const checker::T } } +static bool StaticAccessRequiresReferenceSafetyCheck(const ir::AstNode *const node, const checker::Type *propType) +{ + if (propType->PossiblyETSUndefined()) { + return false; + } + auto parent = node->Parent(); + if (parent->IsMemberExpression()) { + return false; + } + if (parent->IsCallExpression() && parent->AsCallExpression()->Callee() == node) { + return false; + } + return true; +} + void ETSGen::LoadStaticProperty(const ir::AstNode *const node, const checker::Type *propType, const util::StringView &fullName) { + ES2PANDA_ASSERT(propType != nullptr); if (propType->IsETSReferenceType()) { Sa().Emit(node, fullName); + if (StaticAccessRequiresReferenceSafetyCheck(node, propType)) { + EmitNullcheck(node); + } } else if (IsWidePrimitiveType(propType)) { Sa().Emit(node, fullName); } else { @@ -407,6 +367,7 @@ void ETSGen::LoadStaticProperty(const ir::AstNode *const node, const checker::Ty void ETSGen::StoreProperty(const ir::AstNode *const node, const checker::Type *propType, const VReg objReg, const util::StringView &name) { + ES2PANDA_ASSERT(Checker()->GetApparentType(GetVRegType(objReg)) != nullptr); auto *objType = Checker()->GetApparentType(GetVRegType(objReg))->AsETSObjectType(); const auto fullName = FormClassPropReference(objType, name); @@ -419,6 +380,22 @@ void ETSGen::StoreProperty(const ir::AstNode *const node, const checker::Type *p } } +void ETSGen::StorePropertyByNameAny(const ir::AstNode *const node, const VReg objReg, const util::StringView &fullName) +{ + ES2PANDA_ASSERT(node->IsMemberExpression() && + Checker()->GetApparentType(node->AsMemberExpression()->Object()->TsType())->IsETSAnyType()); + Ra().Emit(node, objReg, fullName); + SetAccumulatorType(node->AsMemberExpression()->TsType()); +} + +void ETSGen::LoadPropertyByNameAny(const ir::AstNode *const node, const VReg objReg, const util::StringView &fullName) +{ + ES2PANDA_ASSERT(node->IsMemberExpression() && + Checker()->GetApparentType(node->AsMemberExpression()->Object()->TsType())->IsETSAnyType()); + Ra().Emit(node, objReg, fullName); + SetAccumulatorType(node->AsMemberExpression()->TsType()); +} + void ETSGen::LoadProperty(const ir::AstNode *const node, const checker::Type *propType, const VReg objReg, const util::StringView &fullName) { @@ -472,137 +449,46 @@ void ETSGen::LoadPropertyByName([[maybe_unused]] const ir::AstNode *const node, #endif // PANDA_WITH_ETS } -void ETSGen::StorePropertyDynamic(const ir::AstNode *node, const checker::Type *propType, VReg objReg, - const util::StringView &propName) -{ - auto const lang = GetVRegType(objReg)->AsETSDynamicType()->Language(); - std::string_view methodName {}; - if (propType->IsETSBooleanType()) { - methodName = Signatures::Dynamic::SetPropertyBooleanBuiltin(lang); - } else if (propType->IsByteType()) { - methodName = Signatures::Dynamic::SetPropertyByteBuiltin(lang); - } else if (propType->IsCharType()) { - methodName = Signatures::Dynamic::SetPropertyCharBuiltin(lang); - } else if (propType->IsShortType()) { - methodName = Signatures::Dynamic::SetPropertyShortBuiltin(lang); - } else if (propType->IsIntType()) { - methodName = Signatures::Dynamic::SetPropertyIntBuiltin(lang); - } else if (propType->IsLongType()) { - methodName = Signatures::Dynamic::SetPropertyLongBuiltin(lang); - } else if (propType->IsFloatType()) { - methodName = Signatures::Dynamic::SetPropertyFloatBuiltin(lang); - } else if (propType->IsDoubleType()) { - methodName = Signatures::Dynamic::SetPropertyDoubleBuiltin(lang); - } else if (propType->IsETSStringType()) { - methodName = Signatures::Dynamic::SetPropertyStringBuiltin(lang); - } else if (propType->IsETSObjectType() || propType->IsETSTypeParameter()) { - methodName = Signatures::Dynamic::SetPropertyDynamicBuiltin(lang); - // NOTE: vpukhov. add non-dynamic builtin - if (!propType->IsETSDynamicType()) { - CastToDynamic(node, Checker()->GlobalBuiltinDynamicType(lang)->AsETSDynamicType()); - } - } else { - ASSERT_PRINT(false, "Unsupported property type"); - } - - RegScope rs(this); - VReg propValueReg = AllocReg(); - VReg propNameReg = AllocReg(); - - StoreAccumulator(node, propValueReg); - - // Load property name - LoadAccumulatorString(node, propName); - StoreAccumulator(node, propNameReg); - - // Set property by name - Ra().Emit(node, methodName, objReg, propNameReg, propValueReg, dummyReg_); - SetAccumulatorType(Checker()->GlobalBuiltinJSValueType()); -} - -void ETSGen::LoadPropertyDynamic(const ir::AstNode *node, const checker::Type *propType, VReg objReg, - std::variant property) -{ - auto const lang = GetVRegType(objReg)->AsETSDynamicType()->Language(); - auto *type = propType; - std::string_view methodName {}; - if (propType->IsETSBooleanType()) { - methodName = Signatures::Dynamic::GetPropertyBooleanBuiltin(lang); - } else if (propType->IsByteType()) { - methodName = Signatures::Dynamic::GetPropertyByteBuiltin(lang); - } else if (propType->IsCharType()) { - methodName = Signatures::Dynamic::GetPropertyCharBuiltin(lang); - } else if (propType->IsShortType()) { - methodName = Signatures::Dynamic::GetPropertyShortBuiltin(lang); - } else if (propType->IsIntType()) { - methodName = Signatures::Dynamic::GetPropertyIntBuiltin(lang); - } else if (propType->IsLongType()) { - methodName = Signatures::Dynamic::GetPropertyLongBuiltin(lang); - } else if (propType->IsFloatType()) { - methodName = Signatures::Dynamic::GetPropertyFloatBuiltin(lang); - } else if (propType->IsDoubleType()) { - methodName = Signatures::Dynamic::GetPropertyDoubleBuiltin(lang); - } else if (propType->IsETSStringType()) { - methodName = Signatures::Dynamic::GetPropertyStringBuiltin(lang); - } else if (propType->IsETSObjectType() || propType->IsETSTypeParameter()) { - methodName = Signatures::Dynamic::GetPropertyDynamicBuiltin(lang); - type = Checker()->GlobalBuiltinDynamicType(lang); - } else { - ASSERT_PRINT(false, "Unsupported property type"); - } - +void ETSGen::StoreByIndexAny(const ir::MemberExpression *node, VReg objectReg, VReg index) +{ RegScope rs(this); - VReg propNameObject; - - if (node->IsMemberExpression() && node->AsMemberExpression()->IsComputed()) { - (std::get(property))->Compile(this); - } else { - // Load property name - LoadAccumulatorString(node, std::get(property)); - } - - propNameObject = AllocReg(); - StoreAccumulator(node, propNameObject); + // Store property by index + Ra().Emit(node, objectReg, index); + SetAccumulatorType(Checker()->GlobalVoidType()); +} - // Get property - Ra().Emit(node, methodName, objReg, propNameObject); +void ETSGen::LoadByIndexAny(const ir::MemberExpression *node, VReg objectReg) +{ + RegScope rs(this); - SetAccumulatorType(type); + VReg indexReg = AllocReg(); + StoreAccumulator(node, indexReg); - if (propType != type && !propType->IsETSDynamicType()) { - CastDynamicToObject(node, propType); - } + // Get property by index + Ra().Emit(node, objectReg); + SetAccumulatorType(node->TsType()); } -void ETSGen::StoreElementDynamic(const ir::AstNode *node, VReg objectReg, VReg index) +void ETSGen::StoreByValueAny(const ir::MemberExpression *node, VReg objectReg, VReg value) { - auto const lang = GetVRegType(objectReg)->AsETSDynamicType()->Language(); - std::string_view methodName = Signatures::Dynamic::SetElementDynamicBuiltin(lang); - RegScope rs(this); - VReg valueReg = AllocReg(); - StoreAccumulator(node, valueReg); - - // Set property by index - Ra().Emit(node, methodName, objectReg, index, valueReg, dummyReg_); + // Store property by value + Ra().Emit(node, objectReg, value); SetAccumulatorType(Checker()->GlobalVoidType()); } -void ETSGen::LoadElementDynamic(const ir::AstNode *node, VReg objectReg) +void ETSGen::LoadByValueAny(const ir::MemberExpression *node, VReg objectReg) { - auto const lang = GetVRegType(objectReg)->AsETSDynamicType()->Language(); - std::string_view methodName = Signatures::Dynamic::GetElementDynamicBuiltin(lang); - RegScope rs(this); - VReg indexReg = AllocReg(); - StoreAccumulator(node, indexReg); + VReg valueReg = AllocReg(); + StoreAccumulator(node, valueReg); - // Get property by index - Ra().Emit(node, methodName, objectReg, indexReg); - SetAccumulatorType(Checker()->GlobalBuiltinDynamicType(lang)); + // Get property by value + Ra().Emit(node, objectReg, valueReg); + SetAccumulatorType(node->TsType()); } void ETSGen::CallRangeFillUndefined(const ir::AstNode *const node, checker::Signature *const signature, @@ -659,6 +545,18 @@ const checker::Type *ETSGen::LoadDefaultValue(const ir::AstNode *node, const che if (type->IsETSReferenceType()) { if (checker->Relation()->IsSupertypeOf(type, checker->GlobalETSUndefinedType())) { LoadAccumulatorUndefined(node); + } else if (type->IsETSObjectType() && type->AsETSObjectType()->IsBoxedPrimitive()) { + // Call default constructor for boxed primitive types. + static auto const DUMMY_ARGS = ArenaVector(checker->Allocator()->Adapter()); + auto const &signatures = type->AsETSObjectType()->ConstructSignatures(); + auto const it = std::find_if(signatures.cbegin(), signatures.cend(), [](checker::Signature *signature) { + return signature->ArgCount() == 0U && !signature->HasRestParameter(); + }); + if (it != signatures.cend()) { + InitObject(node, *it, DUMMY_ARGS); + } else { + LoadAccumulatorPoison(node, type); + } } else { LoadAccumulatorPoison(node, type); } @@ -682,6 +580,7 @@ void ETSGen::EmitReturnVoid(const ir::AstNode *node) void ETSGen::ReturnAcc(const ir::AstNode *node) { const auto *const accType = GetAccumulatorType(); + ES2PANDA_ASSERT(accType != nullptr); if (accType->IsETSReferenceType()) { Sa().Emit(node); @@ -692,101 +591,19 @@ void ETSGen::ReturnAcc(const ir::AstNode *node) } } -static bool IsAnyReferenceSupertype(checker::Type const *type) +bool ETSGen::IsNullUnsafeObjectType(checker::Type const *type) const { - if (!type->IsETSUnionType()) { - return false; - } - auto const &constituent = type->AsETSUnionType()->ConstituentTypes(); - return constituent.size() == 3U && std::all_of(constituent.begin(), constituent.end(), [](checker::Type *t) { - return t->IsETSUndefinedType() || t->IsETSNullType() || - (t->IsETSObjectType() && t->AsETSObjectType()->IsGlobalETSObjectType()); - }); // CC-OFF(G.FMT.02) project code style -} - -static bool IsNullUnsafeObjectType(checker::Type const *type) -{ - return type->IsETSObjectType() && type->AsETSObjectType()->IsGlobalETSObjectType(); -} - -void ETSGen::IsInstanceDynamic(const ir::BinaryExpression *const node, const VReg srcReg, - [[maybe_unused]] const VReg tgtReg) -{ - ES2PANDA_ASSERT(node->OperatorType() == lexer::TokenType::KEYW_INSTANCEOF); - const checker::Type *lhsType = node->Left()->TsType(); - const checker::Type *rhsType = node->Right()->TsType(); - ES2PANDA_ASSERT(rhsType->IsETSDynamicType() || lhsType->IsETSDynamicType()); - - const RegScope rs(this); - if (rhsType->IsETSDynamicType()) { - ES2PANDA_ASSERT(node->Right()->TsType()->AsETSDynamicType()->HasDecl()); - if (lhsType->IsETSDynamicType()) { - VReg dynTypeReg = MoveAccToReg(node); - // Semantics: - // let dyn_val: JSValue = ... - // dyn_value instanceof DynamicDecl - // Bytecode: - // call runtime intrinsic_dynamic - CallExact(node, Signatures::BUILTIN_JSRUNTIME_INSTANCE_OF_DYNAMIC, srcReg, dynTypeReg); - } else if (lhsType == Checker()->GlobalETSObjectType()) { - // Semantics: - // let obj: Object = ... - // obj instanceof DynamicDecl - // Bytecode: - // if isinstance : - // checkcast - // return call runtime intrinsic_dynamic - // return false - Label *ifFalse = AllocLabel(); - Language lang = rhsType->AsETSDynamicType()->Language(); - VReg dynTypeReg = MoveAccToReg(node); - LoadAccumulator(node, srcReg); - Sa().Emit(node, Checker()->GlobalBuiltinDynamicType(lang)->AssemblerName()); - BranchIfFalse(node, ifFalse); - LoadAccumulator(node, srcReg); - Sa().Emit(node, Checker()->GlobalBuiltinDynamicType(lang)->AssemblerName()); - CallExact(node, Signatures::BUILTIN_JSRUNTIME_INSTANCE_OF_DYNAMIC, srcReg, dynTypeReg); - SetLabel(node, ifFalse); - } else { - // Semantics: - // let obj: EtsType = ... - // obj instanceof DynamicDecl - // Bytecode: - // False - Sa().Emit(node, 0); - } - } else { - if (lhsType->IsETSDynamicType()) { - if (rhsType == Checker()->GlobalETSObjectType()) { - // Semantics: - // let dyn_val: JSValue = ... - // dyn_val instanceof Object - // Bytecode: - // True - Sa().Emit(node, 1); - } else { - // Semantics: - // let dyn_val: JSValue = ... - // dyn_val instanceof EtsType - // Bytecode: - // lda.type + call runtime instrinsic_static - Sa().Emit(node, rhsType->AsETSObjectType()->AssemblerName()); - VReg typeReg = MoveAccToReg(node); - CallExact(node, Signatures::BUILTIN_JSRUNTIME_INSTANCE_OF_STATIC, srcReg, typeReg); - } - } else { - ES2PANDA_UNREACHABLE(); - } - } - SetAccumulatorType(Checker()->GlobalETSBooleanType()); + ES2PANDA_ASSERT(type != nullptr); + auto const checker = const_cast(Checker()); + return checker->Relation()->IsSupertypeOf(checker->GetApparentType(type), checker->GlobalETSObjectType()); } // Implemented on top of the runtime type system, do not relax checks, do not introduce new types -void ETSGen::TestIsInstanceConstituent(const ir::AstNode *const node, std::tuple