From dfb5dd808e03205cbc9244012ea47649abb6fa40 Mon Sep 17 00:00:00 2001 From: zhuoli72 Date: Tue, 28 Jun 2022 21:11:14 +0800 Subject: [PATCH] Add original es2panda compiler based on 05ddb192 of master Change-Id: I26f663c67b42f6549c7777a88c8bf00bd845fc96 Signed-off-by: zhuoli72 --- es2panda/CMakeLists.txt | 337 + es2panda/README.md | 43 + es2panda/aot/CMakeLists.txt | 47 + es2panda/aot/main.cpp | 146 + es2panda/aot/options.cpp | 163 + es2panda/aot/options.h | 134 + es2panda/binder/binder.cpp | 509 + es2panda/binder/binder.h | 210 + es2panda/binder/declaration.cpp | 20 + es2panda/binder/declaration.h | 313 + es2panda/binder/enumMemberResult.h | 30 + es2panda/binder/scope.cpp | 505 + es2panda/binder/scope.h | 742 ++ es2panda/binder/tsBinding.h | 44 + es2panda/binder/variable.cpp | 63 + es2panda/binder/variable.h | 254 + es2panda/binder/variableFlags.h | 143 + es2panda/compiler/base/catchTable.cpp | 27 + es2panda/compiler/base/catchTable.h | 94 + es2panda/compiler/base/condition.cpp | 94 + es2panda/compiler/base/condition.h | 35 + es2panda/compiler/base/destructuring.cpp | 262 + es2panda/compiler/base/destructuring.h | 34 + es2panda/compiler/base/hoisting.cpp | 81 + es2panda/compiler/base/hoisting.h | 30 + es2panda/compiler/base/iterators.cpp | 216 + es2panda/compiler/base/iterators.h | 119 + es2panda/compiler/base/lexenv.cpp | 142 + es2panda/compiler/base/lexenv.h | 41 + es2panda/compiler/base/literals.cpp | 78 + es2panda/compiler/base/literals.h | 99 + es2panda/compiler/base/lreference.cpp | 132 + es2panda/compiler/base/lreference.h | 68 + es2panda/compiler/core/compileQueue.cpp | 155 + es2panda/compiler/core/compileQueue.h | 92 + es2panda/compiler/core/compilerContext.cpp | 27 + es2panda/compiler/core/compilerContext.h | 82 + es2panda/compiler/core/compilerImpl.cpp | 64 + es2panda/compiler/core/compilerImpl.h | 52 + es2panda/compiler/core/dynamicContext.cpp | 178 + es2panda/compiler/core/dynamicContext.h | 211 + es2panda/compiler/core/emitter.cpp | 446 + es2panda/compiler/core/emitter.h | 115 + es2panda/compiler/core/envScope.cpp | 84 + es2panda/compiler/core/envScope.h | 123 + es2panda/compiler/core/function.cpp | 208 + es2panda/compiler/core/function.h | 32 + es2panda/compiler/core/inlineCache.cpp | 40 + es2panda/compiler/core/inlineCache.h | 36 + es2panda/compiler/core/labelPair.h | 43 + es2panda/compiler/core/labelTarget.cpp | 27 + es2panda/compiler/core/labelTarget.h | 88 + es2panda/compiler/core/moduleContext.cpp | 84 + es2panda/compiler/core/moduleContext.h | 39 + es2panda/compiler/core/pandagen.cpp | 1526 +++ es2panda/compiler/core/pandagen.h | 421 + es2panda/compiler/core/regAllocator.cpp | 159 + es2panda/compiler/core/regAllocator.h | 166 + es2panda/compiler/core/regScope.cpp | 135 + es2panda/compiler/core/regScope.h | 93 + es2panda/compiler/core/switchBuilder.cpp | 76 + es2panda/compiler/core/switchBuilder.h | 53 + .../compiler/debugger/debuginfoDumper.cpp | 236 + es2panda/compiler/debugger/debuginfoDumper.h | 53 + .../function/asyncFunctionBuilder.cpp | 53 + .../compiler/function/asyncFunctionBuilder.h | 48 + .../asyncGeneratorFunctionBuilder.cpp | 106 + .../function/asyncGeneratorFunctionBuilder.h | 51 + .../compiler/function/functionBuilder.cpp | 312 + es2panda/compiler/function/functionBuilder.h | 91 + .../function/generatorFunctionBuilder.cpp | 71 + .../function/generatorFunctionBuilder.h | 64 + es2panda/compiler/templates/formats.h.erb | 83 + es2panda/compiler/templates/isa.h.erb | 232 + es2panda/es2panda.cpp | 76 + es2panda/es2panda.h | 160 + es2panda/ir/astDump.cpp | 243 + es2panda/ir/astDump.h | 206 + es2panda/ir/astNode.h | 277 + es2panda/ir/astNodeMapping.h | 149 + es2panda/ir/base/catchClause.cpp | 86 + es2panda/ir/base/catchClause.h | 84 + es2panda/ir/base/classDefinition.cpp | 287 + es2panda/ir/base/classDefinition.h | 142 + es2panda/ir/base/classProperty.cpp | 68 + es2panda/ir/base/classProperty.h | 101 + es2panda/ir/base/decorator.cpp | 40 + es2panda/ir/base/decorator.h | 53 + es2panda/ir/base/metaProperty.cpp | 66 + es2panda/ir/base/metaProperty.h | 54 + es2panda/ir/base/methodDefinition.cpp | 92 + es2panda/ir/base/methodDefinition.h | 127 + es2panda/ir/base/property.cpp | 138 + es2panda/ir/base/property.h | 127 + es2panda/ir/base/scriptFunction.cpp | 83 + es2panda/ir/base/scriptFunction.h | 166 + es2panda/ir/base/spreadElement.cpp | 105 + es2panda/ir/base/spreadElement.h | 68 + es2panda/ir/base/templateElement.cpp | 42 + es2panda/ir/base/templateElement.h | 64 + es2panda/ir/expression.cpp | 20 + es2panda/ir/expression.h | 73 + es2panda/ir/expressions/arrayExpression.cpp | 359 + es2panda/ir/expressions/arrayExpression.h | 98 + .../expressions/arrowFunctionExpression.cpp | 87 + .../ir/expressions/arrowFunctionExpression.h | 62 + .../ir/expressions/assignmentExpression.cpp | 202 + .../ir/expressions/assignmentExpression.h | 87 + es2panda/ir/expressions/awaitExpression.cpp | 56 + es2panda/ir/expressions/awaitExpression.h | 52 + es2panda/ir/expressions/binaryExpression.cpp | 167 + es2panda/ir/expressions/binaryExpression.h | 91 + es2panda/ir/expressions/callExpression.cpp | 266 + es2panda/ir/expressions/callExpression.h | 88 + es2panda/ir/expressions/chainExpression.cpp | 39 + es2panda/ir/expressions/chainExpression.h | 55 + es2panda/ir/expressions/classExpression.cpp | 43 + es2panda/ir/expressions/classExpression.h | 54 + .../ir/expressions/conditionalExpression.cpp | 64 + .../ir/expressions/conditionalExpression.h | 77 + .../ir/expressions/functionExpression.cpp | 86 + es2panda/ir/expressions/functionExpression.h | 54 + es2panda/ir/expressions/identifier.cpp | 151 + es2panda/ir/expressions/identifier.h | 145 + es2panda/ir/expressions/importExpression.cpp | 43 + es2panda/ir/expressions/importExpression.h | 47 + es2panda/ir/expressions/literal.cpp | 55 + es2panda/ir/expressions/literal.h | 68 + .../ir/expressions/literals/bigIntLiteral.cpp | 49 + .../ir/expressions/literals/bigIntLiteral.h | 58 + .../expressions/literals/booleanLiteral.cpp | 41 + .../ir/expressions/literals/booleanLiteral.h | 57 + .../ir/expressions/literals/nullLiteral.cpp | 41 + .../ir/expressions/literals/nullLiteral.h | 49 + .../ir/expressions/literals/numberLiteral.cpp | 62 + .../ir/expressions/literals/numberLiteral.h | 76 + .../ir/expressions/literals/regExpLiteral.cpp | 65 + .../ir/expressions/literals/regExpLiteral.h | 67 + .../ir/expressions/literals/stringLiteral.cpp | 51 + .../ir/expressions/literals/stringLiteral.h | 63 + .../ir/expressions/literals/taggedLiteral.cpp | 39 + .../ir/expressions/literals/taggedLiteral.h | 73 + es2panda/ir/expressions/memberExpression.cpp | 83 + es2panda/ir/expressions/memberExpression.h | 92 + es2panda/ir/expressions/newExpression.cpp | 74 + es2panda/ir/expressions/newExpression.h | 61 + es2panda/ir/expressions/objectExpression.cpp | 473 + es2panda/ir/expressions/objectExpression.h | 95 + es2panda/ir/expressions/omittedExpression.cpp | 36 + es2panda/ir/expressions/omittedExpression.h | 44 + .../ir/expressions/sequenceExpression.cpp | 48 + es2panda/ir/expressions/sequenceExpression.h | 59 + es2panda/ir/expressions/superExpression.cpp | 49 + es2panda/ir/expressions/superExpression.h | 46 + .../expressions/taggedTemplateExpression.cpp | 92 + .../ir/expressions/taggedTemplateExpression.h | 71 + es2panda/ir/expressions/templateLiteral.cpp | 88 + es2panda/ir/expressions/templateLiteral.h | 62 + es2panda/ir/expressions/thisExpression.cpp | 53 + es2panda/ir/expressions/thisExpression.h | 46 + es2panda/ir/expressions/unaryExpression.cpp | 208 + es2panda/ir/expressions/unaryExpression.h | 62 + es2panda/ir/expressions/updateExpression.cpp | 73 + es2panda/ir/expressions/updateExpression.h | 71 + es2panda/ir/expressions/yieldExpression.cpp | 61 + es2panda/ir/expressions/yieldExpression.h | 62 + es2panda/ir/irnode.h | 127 + es2panda/ir/module/exportAllDeclaration.cpp | 45 + es2panda/ir/module/exportAllDeclaration.h | 64 + .../ir/module/exportDefaultDeclaration.cpp | 45 + es2panda/ir/module/exportDefaultDeclaration.h | 61 + es2panda/ir/module/exportNamedDeclaration.cpp | 62 + es2panda/ir/module/exportNamedDeclaration.h | 81 + es2panda/ir/module/exportSpecifier.cpp | 41 + es2panda/ir/module/exportSpecifier.h | 63 + es2panda/ir/module/importDeclaration.cpp | 44 + es2panda/ir/module/importDeclaration.h | 64 + es2panda/ir/module/importDefaultSpecifier.cpp | 40 + es2panda/ir/module/importDefaultSpecifier.h | 56 + .../ir/module/importNamespaceSpecifier.cpp | 40 + es2panda/ir/module/importNamespaceSpecifier.h | 57 + es2panda/ir/module/importSpecifier.cpp | 41 + es2panda/ir/module/importSpecifier.h | 63 + es2panda/ir/opcodeMap.h | 27 + es2panda/ir/statement.cpp | 20 + es2panda/ir/statement.h | 36 + es2panda/ir/statements/blockStatement.cpp | 57 + es2panda/ir/statements/blockStatement.h | 65 + es2panda/ir/statements/breakStatement.cpp | 47 + es2panda/ir/statements/breakStatement.h | 55 + es2panda/ir/statements/classDeclaration.cpp | 52 + es2panda/ir/statements/classDeclaration.h | 60 + es2panda/ir/statements/continueStatement.cpp | 46 + es2panda/ir/statements/continueStatement.h | 54 + es2panda/ir/statements/debuggerStatement.cpp | 36 + es2panda/ir/statements/debuggerStatement.h | 46 + es2panda/ir/statements/doWhileStatement.cpp | 70 + es2panda/ir/statements/doWhileStatement.h | 77 + es2panda/ir/statements/emptyStatement.cpp | 36 + es2panda/ir/statements/emptyStatement.h | 46 + .../ir/statements/expressionStatement.cpp | 43 + es2panda/ir/statements/expressionStatement.h | 54 + es2panda/ir/statements/forInStatement.cpp | 82 + es2panda/ir/statements/forInStatement.h | 88 + es2panda/ir/statements/forOfStatement.cpp | 82 + es2panda/ir/statements/forOfStatement.h | 98 + es2panda/ir/statements/forUpdateStatement.cpp | 112 + es2panda/ir/statements/forUpdateStatement.h | 104 + .../ir/statements/functionDeclaration.cpp | 60 + es2panda/ir/statements/functionDeclaration.h | 54 + es2panda/ir/statements/ifStatement.cpp | 78 + es2panda/ir/statements/ifStatement.h | 68 + es2panda/ir/statements/labelledStatement.cpp | 47 + es2panda/ir/statements/labelledStatement.h | 64 + es2panda/ir/statements/loopStatement.cpp | 21 + es2panda/ir/statements/loopStatement.h | 70 + es2panda/ir/statements/returnStatement.cpp | 98 + es2panda/ir/statements/returnStatement.h | 53 + .../ir/statements/switchCaseStatement.cpp | 46 + es2panda/ir/statements/switchCaseStatement.h | 63 + es2panda/ir/statements/switchStatement.cpp | 108 + es2panda/ir/statements/switchStatement.h | 75 + es2panda/ir/statements/throwStatement.cpp | 45 + es2panda/ir/statements/throwStatement.h | 54 + es2panda/ir/statements/tryStatement.cpp | 173 + es2panda/ir/statements/tryStatement.h | 78 + .../ir/statements/variableDeclaration.cpp | 131 + es2panda/ir/statements/variableDeclaration.h | 75 + es2panda/ir/statements/variableDeclarator.cpp | 64 + es2panda/ir/statements/variableDeclarator.h | 79 + es2panda/ir/statements/whileStatement.cpp | 69 + es2panda/ir/statements/whileStatement.h | 77 + es2panda/ir/ts/tsAnyKeyword.cpp | 36 + es2panda/ir/ts/tsAnyKeyword.h | 43 + es2panda/ir/ts/tsArrayType.cpp | 39 + es2panda/ir/ts/tsArrayType.h | 53 + es2panda/ir/ts/tsAsExpression.cpp | 111 + es2panda/ir/ts/tsAsExpression.h | 70 + es2panda/ir/ts/tsBigintKeyword.cpp | 36 + es2panda/ir/ts/tsBigintKeyword.h | 43 + es2panda/ir/ts/tsBooleanKeyword.cpp | 36 + es2panda/ir/ts/tsBooleanKeyword.h | 43 + es2panda/ir/ts/tsClassImplements.cpp | 47 + es2panda/ir/ts/tsClassImplements.h | 62 + es2panda/ir/ts/tsConditionalType.cpp | 46 + es2panda/ir/ts/tsConditionalType.h | 77 + es2panda/ir/ts/tsConstructorType.cpp | 63 + es2panda/ir/ts/tsConstructorType.h | 90 + es2panda/ir/ts/tsEnumDeclaration.cpp | 401 + es2panda/ir/ts/tsEnumDeclaration.h | 91 + es2panda/ir/ts/tsEnumMember.cpp | 44 + es2panda/ir/ts/tsEnumMember.h | 62 + es2panda/ir/ts/tsExternalModuleReference.cpp | 39 + es2panda/ir/ts/tsExternalModuleReference.h | 55 + es2panda/ir/ts/tsFunctionType.cpp | 62 + es2panda/ir/ts/tsFunctionType.h | 83 + es2panda/ir/ts/tsImportEqualsDeclaration.cpp | 45 + es2panda/ir/ts/tsImportEqualsDeclaration.h | 71 + es2panda/ir/ts/tsImportType.cpp | 53 + es2panda/ir/ts/tsImportType.h | 79 + es2panda/ir/ts/tsIndexSignature.cpp | 50 + es2panda/ir/ts/tsIndexSignature.h | 73 + es2panda/ir/ts/tsIndexedAccessType.cpp | 44 + es2panda/ir/ts/tsIndexedAccessType.h | 60 + es2panda/ir/ts/tsInferType.cpp | 40 + es2panda/ir/ts/tsInferType.h | 55 + es2panda/ir/ts/tsInterfaceBody.cpp | 41 + es2panda/ir/ts/tsInterfaceBody.h | 55 + es2panda/ir/ts/tsInterfaceDeclaration.cpp | 212 + es2panda/ir/ts/tsInterfaceDeclaration.h | 95 + es2panda/ir/ts/tsInterfaceHeritage.cpp | 50 + es2panda/ir/ts/tsInterfaceHeritage.h | 64 + es2panda/ir/ts/tsIntersectionType.cpp | 41 + es2panda/ir/ts/tsIntersectionType.h | 54 + es2panda/ir/ts/tsLiteralType.cpp | 39 + es2panda/ir/ts/tsLiteralType.h | 51 + es2panda/ir/ts/tsMappedType.cpp | 52 + es2panda/ir/ts/tsMappedType.h | 78 + es2panda/ir/ts/tsMethodSignature.cpp | 60 + es2panda/ir/ts/tsMethodSignature.h | 106 + es2panda/ir/ts/tsModuleBlock.cpp | 42 + es2panda/ir/ts/tsModuleBlock.h | 64 + es2panda/ir/ts/tsModuleDeclaration.cpp | 49 + es2panda/ir/ts/tsModuleDeclaration.h | 90 + es2panda/ir/ts/tsNamedTupleMember.cpp | 43 + es2panda/ir/ts/tsNamedTupleMember.h | 69 + es2panda/ir/ts/tsNeverKeyword.cpp | 36 + es2panda/ir/ts/tsNeverKeyword.h | 43 + es2panda/ir/ts/tsNonNullExpression.cpp | 39 + es2panda/ir/ts/tsNonNullExpression.h | 51 + es2panda/ir/ts/tsNullKeyword.cpp | 36 + es2panda/ir/ts/tsNullKeyword.h | 43 + es2panda/ir/ts/tsNumberKeyword.cpp | 36 + es2panda/ir/ts/tsNumberKeyword.h | 43 + es2panda/ir/ts/tsObjectKeyword.cpp | 36 + es2panda/ir/ts/tsObjectKeyword.h | 43 + es2panda/ir/ts/tsParameterProperty.cpp | 48 + es2panda/ir/ts/tsParameterProperty.h | 86 + es2panda/ir/ts/tsParenthesizedType.cpp | 39 + es2panda/ir/ts/tsParenthesizedType.h | 51 + es2panda/ir/ts/tsPrivateIdentifier.cpp | 50 + es2panda/ir/ts/tsPrivateIdentifier.h | 67 + es2panda/ir/ts/tsPropertySignature.cpp | 48 + es2panda/ir/ts/tsPropertySignature.h | 85 + es2panda/ir/ts/tsQualifiedName.cpp | 68 + es2panda/ir/ts/tsQualifiedName.h | 60 + es2panda/ir/ts/tsSignatureDeclaration.cpp | 57 + es2panda/ir/ts/tsSignatureDeclaration.h | 93 + es2panda/ir/ts/tsStringKeyword.cpp | 36 + es2panda/ir/ts/tsStringKeyword.h | 43 + es2panda/ir/ts/tsThisType.cpp | 36 + es2panda/ir/ts/tsThisType.h | 43 + es2panda/ir/ts/tsTupleType.cpp | 108 + es2panda/ir/ts/tsTupleType.h | 56 + es2panda/ir/ts/tsTypeAliasDeclaration.cpp | 83 + es2panda/ir/ts/tsTypeAliasDeclaration.h | 87 + es2panda/ir/ts/tsTypeAssertion.cpp | 40 + es2panda/ir/ts/tsTypeAssertion.h | 60 + es2panda/ir/ts/tsTypeLiteral.cpp | 84 + es2panda/ir/ts/tsTypeLiteral.h | 54 + es2panda/ir/ts/tsTypeOperator.cpp | 43 + es2panda/ir/ts/tsTypeOperator.h | 70 + es2panda/ir/ts/tsTypeParameter.cpp | 53 + es2panda/ir/ts/tsTypeParameter.h | 68 + es2panda/ir/ts/tsTypeParameterDeclaration.cpp | 43 + es2panda/ir/ts/tsTypeParameterDeclaration.h | 76 + .../ir/ts/tsTypeParameterInstantiation.cpp | 42 + es2panda/ir/ts/tsTypeParameterInstantiation.h | 54 + es2panda/ir/ts/tsTypePredicate.cpp | 46 + es2panda/ir/ts/tsTypePredicate.h | 69 + es2panda/ir/ts/tsTypeQuery.cpp | 40 + es2panda/ir/ts/tsTypeQuery.h | 51 + es2panda/ir/ts/tsTypeReference.cpp | 116 + es2panda/ir/ts/tsTypeReference.h | 71 + es2panda/ir/ts/tsUndefinedKeyword.cpp | 36 + es2panda/ir/ts/tsUndefinedKeyword.h | 43 + es2panda/ir/ts/tsUnionType.cpp | 48 + es2panda/ir/ts/tsUnionType.h | 54 + es2panda/ir/ts/tsUnknownKeyword.cpp | 36 + es2panda/ir/ts/tsUnknownKeyword.h | 43 + es2panda/ir/ts/tsVoidKeyword.cpp | 36 + es2panda/ir/ts/tsVoidKeyword.h | 43 + es2panda/ir/validationInfo.h | 38 + es2panda/lexer/keywordString.h | 37 + es2panda/lexer/keywordsUtil.cpp | 304 + es2panda/lexer/keywordsUtil.h | 87 + es2panda/lexer/lexer.cpp | 1602 +++ es2panda/lexer/lexer.h | 438 + es2panda/lexer/regexp/regexp.cpp | 870 ++ es2panda/lexer/regexp/regexp.h | 105 + es2panda/lexer/scripts/keywords.rb | 229 + es2panda/lexer/templates/keywords.h.erb | 89 + es2panda/lexer/templates/keywordsMap.h.erb | 50 + es2panda/lexer/token/letters.h | 158 + es2panda/lexer/token/sourceLocation.cpp | 94 + es2panda/lexer/token/sourceLocation.h | 108 + es2panda/lexer/token/token.cpp | 244 + es2panda/lexer/token/token.h | 138 + es2panda/lexer/token/tokenType.h | 186 + es2panda/parser/context/parserContext.cpp | 38 + es2panda/parser/context/parserContext.h | 137 + es2panda/parser/expressionParser.cpp | 2344 +++++ es2panda/parser/parserFlags.h | 84 + es2panda/parser/parserImpl.cpp | 3307 ++++++ es2panda/parser/parserImpl.h | 689 ++ es2panda/parser/program/program.cpp | 72 + es2panda/parser/program/program.h | 116 + es2panda/parser/statementParser.cpp | 2422 +++++ .../ts/arithmetic_operators_1-expected.txt | 186 + .../compiler/ts/arithmetic_operators_1.ts | 19 + .../ts/arithmetic_operators_10-expected.txt | 186 + .../compiler/ts/arithmetic_operators_10.ts | 19 + .../ts/arithmetic_operators_11-expected.txt | 186 + .../compiler/ts/arithmetic_operators_11.ts | 19 + .../ts/arithmetic_operators_12-expected.txt | 186 + .../compiler/ts/arithmetic_operators_12.ts | 19 + .../ts/arithmetic_operators_13-expected.txt | 186 + .../compiler/ts/arithmetic_operators_13.ts | 19 + .../ts/arithmetic_operators_14-expected.txt | 186 + .../compiler/ts/arithmetic_operators_14.ts | 19 + .../ts/arithmetic_operators_15-expected.txt | 186 + .../compiler/ts/arithmetic_operators_15.ts | 19 + .../ts/arithmetic_operators_16-expected.txt | 173 + .../compiler/ts/arithmetic_operators_16.ts | 19 + .../ts/arithmetic_operators_17-expected.txt | 173 + .../compiler/ts/arithmetic_operators_17.ts | 19 + .../ts/arithmetic_operators_18-expected.txt | 186 + .../compiler/ts/arithmetic_operators_18.ts | 19 + .../ts/arithmetic_operators_19-expected.txt | 186 + .../compiler/ts/arithmetic_operators_19.ts | 19 + .../ts/arithmetic_operators_2-expected.txt | 186 + .../compiler/ts/arithmetic_operators_2.ts | 19 + .../ts/arithmetic_operators_20-expected.txt | 186 + .../compiler/ts/arithmetic_operators_20.ts | 19 + .../ts/arithmetic_operators_21-expected.txt | 186 + .../compiler/ts/arithmetic_operators_21.ts | 19 + .../ts/arithmetic_operators_22-expected.txt | 186 + .../compiler/ts/arithmetic_operators_22.ts | 19 + .../ts/arithmetic_operators_23-expected.txt | 186 + .../compiler/ts/arithmetic_operators_23.ts | 19 + .../ts/arithmetic_operators_24-expected.txt | 186 + .../compiler/ts/arithmetic_operators_24.ts | 19 + .../ts/arithmetic_operators_25-expected.txt | 186 + .../compiler/ts/arithmetic_operators_25.ts | 19 + .../ts/arithmetic_operators_26-expected.txt | 186 + .../compiler/ts/arithmetic_operators_26.ts | 19 + .../ts/arithmetic_operators_27-expected.txt | 186 + .../compiler/ts/arithmetic_operators_27.ts | 19 + .../ts/arithmetic_operators_28-expected.txt | 186 + .../compiler/ts/arithmetic_operators_28.ts | 19 + .../ts/arithmetic_operators_29-expected.txt | 186 + .../compiler/ts/arithmetic_operators_29.ts | 19 + .../ts/arithmetic_operators_3-expected.txt | 186 + .../compiler/ts/arithmetic_operators_3.ts | 19 + .../ts/arithmetic_operators_30-expected.txt | 186 + .../compiler/ts/arithmetic_operators_30.ts | 19 + .../ts/arithmetic_operators_31-expected.txt | 186 + .../compiler/ts/arithmetic_operators_31.ts | 19 + .../ts/arithmetic_operators_32-expected.txt | 186 + .../compiler/ts/arithmetic_operators_32.ts | 19 + .../ts/arithmetic_operators_33-expected.txt | 186 + .../compiler/ts/arithmetic_operators_33.ts | 19 + .../ts/arithmetic_operators_34-expected.txt | 186 + .../compiler/ts/arithmetic_operators_34.ts | 19 + .../ts/arithmetic_operators_35-expected.txt | 186 + .../compiler/ts/arithmetic_operators_35.ts | 19 + .../ts/arithmetic_operators_36-expected.txt | 186 + .../compiler/ts/arithmetic_operators_36.ts | 19 + .../ts/arithmetic_operators_37-expected.txt | 186 + .../compiler/ts/arithmetic_operators_37.ts | 19 + .../ts/arithmetic_operators_38-expected.txt | 186 + .../compiler/ts/arithmetic_operators_38.ts | 19 + .../ts/arithmetic_operators_39-expected.txt | 186 + .../compiler/ts/arithmetic_operators_39.ts | 19 + .../ts/arithmetic_operators_4-expected.txt | 186 + .../compiler/ts/arithmetic_operators_4.ts | 19 + .../ts/arithmetic_operators_40-expected.txt | 186 + .../compiler/ts/arithmetic_operators_40.ts | 19 + .../ts/arithmetic_operators_41-expected.txt | 186 + .../compiler/ts/arithmetic_operators_41.ts | 19 + .../ts/arithmetic_operators_42-expected.txt | 186 + .../compiler/ts/arithmetic_operators_42.ts | 19 + .../ts/arithmetic_operators_43-expected.txt | 186 + .../compiler/ts/arithmetic_operators_43.ts | 19 + .../ts/arithmetic_operators_44-expected.txt | 186 + .../compiler/ts/arithmetic_operators_44.ts | 19 + .../ts/arithmetic_operators_45-expected.txt | 186 + .../compiler/ts/arithmetic_operators_45.ts | 19 + .../ts/arithmetic_operators_46-expected.txt | 173 + .../compiler/ts/arithmetic_operators_46.ts | 19 + .../ts/arithmetic_operators_47-expected.txt | 173 + .../compiler/ts/arithmetic_operators_47.ts | 19 + .../ts/arithmetic_operators_48-expected.txt | 186 + .../compiler/ts/arithmetic_operators_48.ts | 19 + .../ts/arithmetic_operators_49-expected.txt | 186 + .../compiler/ts/arithmetic_operators_49.ts | 19 + .../ts/arithmetic_operators_5-expected.txt | 186 + .../compiler/ts/arithmetic_operators_5.ts | 19 + .../ts/arithmetic_operators_50-expected.txt | 186 + .../compiler/ts/arithmetic_operators_50.ts | 19 + .../ts/arithmetic_operators_51-expected.txt | 186 + .../compiler/ts/arithmetic_operators_51.ts | 19 + .../ts/arithmetic_operators_52-expected.txt | 186 + .../compiler/ts/arithmetic_operators_52.ts | 19 + .../ts/arithmetic_operators_53-expected.txt | 186 + .../compiler/ts/arithmetic_operators_53.ts | 19 + .../ts/arithmetic_operators_54-expected.txt | 186 + .../compiler/ts/arithmetic_operators_54.ts | 19 + .../ts/arithmetic_operators_55-expected.txt | 186 + .../compiler/ts/arithmetic_operators_55.ts | 19 + .../ts/arithmetic_operators_56-expected.txt | 186 + .../compiler/ts/arithmetic_operators_56.ts | 19 + .../ts/arithmetic_operators_57-expected.txt | 186 + .../compiler/ts/arithmetic_operators_57.ts | 19 + .../ts/arithmetic_operators_58-expected.txt | 186 + .../compiler/ts/arithmetic_operators_58.ts | 19 + .../ts/arithmetic_operators_59-expected.txt | 186 + .../compiler/ts/arithmetic_operators_59.ts | 19 + .../ts/arithmetic_operators_6-expected.txt | 186 + .../compiler/ts/arithmetic_operators_6.ts | 19 + .../ts/arithmetic_operators_60-expected.txt | 186 + .../compiler/ts/arithmetic_operators_60.ts | 19 + .../ts/arithmetic_operators_61-expected.txt | 186 + .../compiler/ts/arithmetic_operators_61.ts | 19 + .../ts/arithmetic_operators_62-expected.txt | 186 + .../compiler/ts/arithmetic_operators_62.ts | 19 + .../ts/arithmetic_operators_63-expected.txt | 173 + .../compiler/ts/arithmetic_operators_63.ts | 19 + .../ts/arithmetic_operators_64-expected.txt | 173 + .../compiler/ts/arithmetic_operators_64.ts | 19 + .../ts/arithmetic_operators_7-expected.txt | 186 + .../compiler/ts/arithmetic_operators_7.ts | 19 + .../ts/arithmetic_operators_8-expected.txt | 186 + .../compiler/ts/arithmetic_operators_8.ts | 19 + .../ts/arithmetic_operators_9-expected.txt | 186 + .../compiler/ts/arithmetic_operators_9.ts | 19 + .../ts/arrayDestructuring-expected.txt | 8484 ++++++++++++++++ .../test/compiler/ts/arrayDestructuring.ts | 98 + .../ts/arrayDestructuring1-expected.txt | 89 + .../test/compiler/ts/arrayDestructuring1.ts | 17 + .../ts/arrayDestructuring10-expected.txt | 271 + .../test/compiler/ts/arrayDestructuring10.ts | 18 + .../ts/arrayDestructuring11-expected.txt | 201 + .../test/compiler/ts/arrayDestructuring11.ts | 18 + .../ts/arrayDestructuring12-expected.txt | 295 + .../test/compiler/ts/arrayDestructuring12.ts | 17 + .../ts/arrayDestructuring13-expected.txt | 260 + .../test/compiler/ts/arrayDestructuring13.ts | 19 + .../ts/arrayDestructuring14-expected.txt | 217 + .../test/compiler/ts/arrayDestructuring14.ts | 18 + .../ts/arrayDestructuring15-expected.txt | 178 + .../test/compiler/ts/arrayDestructuring15.ts | 18 + .../ts/arrayDestructuring16-expected.txt | 261 + .../test/compiler/ts/arrayDestructuring16.ts | 19 + .../ts/arrayDestructuring17-expected.txt | 378 + .../test/compiler/ts/arrayDestructuring17.ts | 21 + .../ts/arrayDestructuring18-expected.txt | 324 + .../test/compiler/ts/arrayDestructuring18.ts | 18 + .../ts/arrayDestructuring19-expected.txt | 339 + .../test/compiler/ts/arrayDestructuring19.ts | 18 + .../ts/arrayDestructuring2-expected.txt | 172 + .../test/compiler/ts/arrayDestructuring2.ts | 18 + .../ts/arrayDestructuring20-expected.txt | 163 + .../test/compiler/ts/arrayDestructuring20.ts | 17 + .../ts/arrayDestructuring21-expected.txt | 149 + .../test/compiler/ts/arrayDestructuring21.ts | 17 + .../ts/arrayDestructuring22-expected.txt | 234 + .../test/compiler/ts/arrayDestructuring22.ts | 17 + .../ts/arrayDestructuring23-expected.txt | 220 + .../test/compiler/ts/arrayDestructuring23.ts | 17 + .../ts/arrayDestructuring24-expected.txt | 398 + .../test/compiler/ts/arrayDestructuring24.ts | 18 + .../ts/arrayDestructuring25-expected.txt | 176 + .../test/compiler/ts/arrayDestructuring25.ts | 17 + .../ts/arrayDestructuring26-expected.txt | 300 + .../test/compiler/ts/arrayDestructuring26.ts | 17 + .../ts/arrayDestructuring27-expected.txt | 299 + .../test/compiler/ts/arrayDestructuring27.ts | 17 + .../ts/arrayDestructuring28-expected.txt | 502 + .../test/compiler/ts/arrayDestructuring28.ts | 18 + .../ts/arrayDestructuring29-expected.txt | 145 + .../test/compiler/ts/arrayDestructuring29.ts | 18 + .../ts/arrayDestructuring3-expected.txt | 187 + .../test/compiler/ts/arrayDestructuring3.ts | 18 + .../ts/arrayDestructuring30-expected.txt | 245 + .../test/compiler/ts/arrayDestructuring30.ts | 19 + .../ts/arrayDestructuring31-expected.txt | 172 + .../test/compiler/ts/arrayDestructuring31.ts | 18 + .../ts/arrayDestructuring32-expected.txt | 87 + .../test/compiler/ts/arrayDestructuring32.ts | 17 + .../ts/arrayDestructuring33-expected.txt | 160 + .../test/compiler/ts/arrayDestructuring33.ts | 18 + .../ts/arrayDestructuring34-expected.txt | 204 + .../test/compiler/ts/arrayDestructuring34.ts | 19 + .../ts/arrayDestructuring35-expected.txt | 215 + .../test/compiler/ts/arrayDestructuring35.ts | 19 + .../ts/arrayDestructuring36-expected.txt | 687 ++ .../test/compiler/ts/arrayDestructuring36.ts | 22 + .../ts/arrayDestructuring37-expected.txt | 587 ++ .../test/compiler/ts/arrayDestructuring37.ts | 21 + .../ts/arrayDestructuring38-expected.txt | 175 + .../test/compiler/ts/arrayDestructuring38.ts | 18 + .../ts/arrayDestructuring39-expected.txt | 275 + .../test/compiler/ts/arrayDestructuring39.ts | 19 + .../ts/arrayDestructuring4-expected.txt | 145 + .../test/compiler/ts/arrayDestructuring4.ts | 17 + .../ts/arrayDestructuring40-expected.txt | 190 + .../test/compiler/ts/arrayDestructuring40.ts | 18 + .../ts/arrayDestructuring41-expected.txt | 234 + .../test/compiler/ts/arrayDestructuring41.ts | 19 + .../ts/arrayDestructuring42-expected.txt | 202 + .../test/compiler/ts/arrayDestructuring42.ts | 19 + .../ts/arrayDestructuring43-expected.txt | 186 + .../test/compiler/ts/arrayDestructuring43.ts | 19 + .../ts/arrayDestructuring44-expected.txt | 343 + .../test/compiler/ts/arrayDestructuring44.ts | 20 + .../ts/arrayDestructuring5-expected.txt | 228 + .../test/compiler/ts/arrayDestructuring5.ts | 17 + .../ts/arrayDestructuring6-expected.txt | 271 + .../test/compiler/ts/arrayDestructuring6.ts | 18 + .../ts/arrayDestructuring7-expected.txt | 204 + .../test/compiler/ts/arrayDestructuring7.ts | 17 + .../ts/arrayDestructuring8-expected.txt | 303 + .../test/compiler/ts/arrayDestructuring8.ts | 18 + .../ts/arrayDestructuring9-expected.txt | 203 + .../test/compiler/ts/arrayDestructuring9.ts | 18 + .../test/compiler/ts/array_1-expected.txt | 172 + es2panda/test/compiler/ts/array_1.ts | 18 + .../test/compiler/ts/array_10-expected.txt | 172 + es2panda/test/compiler/ts/array_10.ts | 18 + .../test/compiler/ts/array_11-expected.txt | 173 + es2panda/test/compiler/ts/array_11.ts | 18 + .../test/compiler/ts/array_12-expected.txt | 173 + es2panda/test/compiler/ts/array_12.ts | 18 + .../test/compiler/ts/array_13-expected.txt | 173 + es2panda/test/compiler/ts/array_13.ts | 18 + .../test/compiler/ts/array_14-expected.txt | 173 + es2panda/test/compiler/ts/array_14.ts | 18 + .../test/compiler/ts/array_15-expected.txt | 173 + es2panda/test/compiler/ts/array_15.ts | 18 + .../test/compiler/ts/array_16-expected.txt | 173 + es2panda/test/compiler/ts/array_16.ts | 18 + .../test/compiler/ts/array_17-expected.txt | 173 + es2panda/test/compiler/ts/array_17.ts | 18 + .../test/compiler/ts/array_18-expected.txt | 173 + es2panda/test/compiler/ts/array_18.ts | 18 + .../test/compiler/ts/array_19-expected.txt | 172 + es2panda/test/compiler/ts/array_19.ts | 18 + .../test/compiler/ts/array_2-expected.txt | 172 + es2panda/test/compiler/ts/array_2.ts | 18 + .../test/compiler/ts/array_20-expected.txt | 172 + es2panda/test/compiler/ts/array_20.ts | 18 + .../test/compiler/ts/array_21-expected.txt | 172 + es2panda/test/compiler/ts/array_21.ts | 18 + .../test/compiler/ts/array_22-expected.txt | 172 + es2panda/test/compiler/ts/array_22.ts | 18 + .../test/compiler/ts/array_23-expected.txt | 173 + es2panda/test/compiler/ts/array_23.ts | 18 + .../test/compiler/ts/array_24-expected.txt | 173 + es2panda/test/compiler/ts/array_24.ts | 18 + .../test/compiler/ts/array_3-expected.txt | 172 + es2panda/test/compiler/ts/array_3.ts | 18 + .../test/compiler/ts/array_4-expected.txt | 172 + es2panda/test/compiler/ts/array_4.ts | 18 + .../test/compiler/ts/array_5-expected.txt | 173 + es2panda/test/compiler/ts/array_5.ts | 18 + .../test/compiler/ts/array_6-expected.txt | 173 + es2panda/test/compiler/ts/array_6.ts | 18 + .../test/compiler/ts/array_7-expected.txt | 172 + es2panda/test/compiler/ts/array_7.ts | 18 + .../test/compiler/ts/array_8-expected.txt | 172 + es2panda/test/compiler/ts/array_8.ts | 18 + .../test/compiler/ts/array_9-expected.txt | 172 + es2panda/test/compiler/ts/array_9.ts | 18 + .../compiler/ts/as_expression_1-expected.txt | 100 + es2panda/test/compiler/ts/as_expression_1.ts | 17 + .../compiler/ts/as_expression_10-expected.txt | 228 + es2panda/test/compiler/ts/as_expression_10.ts | 18 + .../compiler/ts/as_expression_11-expected.txt | 257 + es2panda/test/compiler/ts/as_expression_11.ts | 18 + .../compiler/ts/as_expression_12-expected.txt | 257 + es2panda/test/compiler/ts/as_expression_12.ts | 18 + .../compiler/ts/as_expression_13-expected.txt | 257 + es2panda/test/compiler/ts/as_expression_13.ts | 18 + .../compiler/ts/as_expression_14-expected.txt | 257 + es2panda/test/compiler/ts/as_expression_14.ts | 18 + .../compiler/ts/as_expression_15-expected.txt | 257 + es2panda/test/compiler/ts/as_expression_15.ts | 18 + .../compiler/ts/as_expression_2-expected.txt | 143 + es2panda/test/compiler/ts/as_expression_2.ts | 18 + .../compiler/ts/as_expression_3-expected.txt | 285 + es2panda/test/compiler/ts/as_expression_3.ts | 18 + .../compiler/ts/as_expression_4-expected.txt | 285 + es2panda/test/compiler/ts/as_expression_4.ts | 18 + .../compiler/ts/as_expression_5-expected.txt | 285 + es2panda/test/compiler/ts/as_expression_5.ts | 18 + .../compiler/ts/as_expression_6-expected.txt | 285 + es2panda/test/compiler/ts/as_expression_6.ts | 18 + .../compiler/ts/as_expression_7-expected.txt | 299 + es2panda/test/compiler/ts/as_expression_7.ts | 18 + .../compiler/ts/as_expression_8-expected.txt | 271 + es2panda/test/compiler/ts/as_expression_8.ts | 18 + .../compiler/ts/as_expression_9-expected.txt | 257 + es2panda/test/compiler/ts/as_expression_9.ts | 18 + .../compiler/ts/assignment_never-expected.txt | 87 + es2panda/test/compiler/ts/assignment_never.ts | 17 + .../ts/assignment_unknown-expected.txt | 409 + .../test/compiler/ts/assignment_unknown.ts | 24 + .../ts/cannotAssignToConst-expected.txt | 130 + .../test/compiler/ts/cannotAssignToConst.ts | 18 + .../constUsedBeforeDeclaration-expected.txt | 130 + .../compiler/ts/constUsedBeforeDeclaration.ts | 18 + .../compiler/ts/functionCall-expected.txt | 5451 ++++++++++ es2panda/test/compiler/ts/functionCall.ts | 89 + .../compiler/ts/functionCall_1-expected.txt | 175 + es2panda/test/compiler/ts/functionCall_1.ts | 20 + .../compiler/ts/functionCall_10-expected.txt | 288 + es2panda/test/compiler/ts/functionCall_10.ts | 18 + .../compiler/ts/functionCall_11-expected.txt | 303 + es2panda/test/compiler/ts/functionCall_11.ts | 18 + .../compiler/ts/functionCall_12-expected.txt | 361 + es2panda/test/compiler/ts/functionCall_12.ts | 18 + .../compiler/ts/functionCall_13-expected.txt | 470 + es2panda/test/compiler/ts/functionCall_13.ts | 18 + .../compiler/ts/functionCall_14-expected.txt | 485 + es2panda/test/compiler/ts/functionCall_14.ts | 18 + .../compiler/ts/functionCall_15-expected.txt | 425 + es2panda/test/compiler/ts/functionCall_15.ts | 18 + .../compiler/ts/functionCall_2-expected.txt | 335 + es2panda/test/compiler/ts/functionCall_2.ts | 24 + .../compiler/ts/functionCall_3-expected.txt | 189 + es2panda/test/compiler/ts/functionCall_3.ts | 18 + .../compiler/ts/functionCall_4-expected.txt | 349 + es2panda/test/compiler/ts/functionCall_4.ts | 21 + .../compiler/ts/functionCall_5-expected.txt | 231 + es2panda/test/compiler/ts/functionCall_5.ts | 21 + .../compiler/ts/functionCall_6-expected.txt | 145 + es2panda/test/compiler/ts/functionCall_6.ts | 19 + .../compiler/ts/functionCall_7-expected.txt | 216 + es2panda/test/compiler/ts/functionCall_7.ts | 21 + .../compiler/ts/functionCall_8-expected.txt | 217 + es2panda/test/compiler/ts/functionCall_8.ts | 20 + .../compiler/ts/functionCall_9-expected.txt | 232 + es2panda/test/compiler/ts/functionCall_9.ts | 21 + .../ts/functionOverload1-expected.txt | 665 ++ .../test/compiler/ts/functionOverload1.ts | 23 + .../ts/functionOverload2-expected.txt | 784 ++ .../test/compiler/ts/functionOverload2.ts | 24 + .../ts/functionOverload3-expected.txt | 505 + .../test/compiler/ts/functionOverload3.ts | 21 + .../ts/functionOverload4-expected.txt | 607 ++ .../test/compiler/ts/functionOverload4.ts | 23 + .../ts/functionWithPattern1-expected.txt | 410 + .../test/compiler/ts/functionWithPattern1.ts | 21 + .../ts/functionWithPattern10-expected.txt | 1155 +++ .../test/compiler/ts/functionWithPattern10.ts | 21 + .../ts/functionWithPattern11-expected.txt | 1248 +++ .../test/compiler/ts/functionWithPattern11.ts | 21 + .../ts/functionWithPattern12-expected.txt | 1110 ++ .../test/compiler/ts/functionWithPattern12.ts | 21 + .../ts/functionWithPattern2-expected.txt | 369 + .../test/compiler/ts/functionWithPattern2.ts | 21 + .../ts/functionWithPattern3-expected.txt | 510 + .../test/compiler/ts/functionWithPattern3.ts | 21 + .../ts/functionWithPattern4-expected.txt | 679 ++ .../test/compiler/ts/functionWithPattern4.ts | 21 + .../ts/functionWithPattern5-expected.txt | 728 ++ .../test/compiler/ts/functionWithPattern5.ts | 21 + .../ts/functionWithPattern6-expected.txt | 821 ++ .../test/compiler/ts/functionWithPattern6.ts | 21 + .../ts/functionWithPattern7-expected.txt | 850 ++ .../test/compiler/ts/functionWithPattern7.ts | 21 + .../ts/functionWithPattern8-expected.txt | 973 ++ .../test/compiler/ts/functionWithPattern8.ts | 21 + .../ts/functionWithPattern9-expected.txt | 1080 ++ .../test/compiler/ts/functionWithPattern9.ts | 21 + .../ts/function_declaration_1-expected.txt | 88 + .../compiler/ts/function_declaration_1.ts | 18 + .../ts/function_declaration_10-expected.txt | 116 + .../compiler/ts/function_declaration_10.ts | 19 + .../ts/function_declaration_11-expected.txt | 88 + .../compiler/ts/function_declaration_11.ts | 18 + .../ts/function_declaration_2-expected.txt | 116 + .../compiler/ts/function_declaration_2.ts | 19 + .../ts/function_declaration_3-expected.txt | 116 + .../compiler/ts/function_declaration_3.ts | 19 + .../ts/function_declaration_4-expected.txt | 88 + .../compiler/ts/function_declaration_4.ts | 18 + .../ts/function_declaration_5-expected.txt | 116 + .../compiler/ts/function_declaration_5.ts | 19 + .../ts/function_declaration_6-expected.txt | 88 + .../compiler/ts/function_declaration_6.ts | 18 + .../ts/function_declaration_7-expected.txt | 116 + .../compiler/ts/function_declaration_7.ts | 19 + .../ts/function_declaration_8-expected.txt | 116 + .../compiler/ts/function_declaration_8.ts | 19 + .../ts/function_declaration_9-expected.txt | 88 + .../compiler/ts/function_declaration_9.ts | 18 + .../ts/generic_interface-expected.txt | 3304 ++++++ .../test/compiler/ts/generic_interface.ts | 70 + .../ts/generic_type_alias-expected.txt | 4049 ++++++++ .../test/compiler/ts/generic_type_alias.ts | 70 + .../ts/generic_type_alias_1-expected.txt | 201 + .../test/compiler/ts/generic_type_alias_1.ts | 19 + .../ts/generic_type_alias_10-expected.txt | 708 ++ .../test/compiler/ts/generic_type_alias_10.ts | 26 + .../ts/generic_type_alias_2-expected.txt | 285 + .../test/compiler/ts/generic_type_alias_2.ts | 19 + .../ts/generic_type_alias_3-expected.txt | 270 + .../test/compiler/ts/generic_type_alias_3.ts | 20 + .../ts/generic_type_alias_4-expected.txt | 466 + .../test/compiler/ts/generic_type_alias_4.ts | 21 + .../ts/generic_type_alias_5-expected.txt | 480 + .../test/compiler/ts/generic_type_alias_5.ts | 21 + .../ts/generic_type_alias_6-expected.txt | 480 + .../test/compiler/ts/generic_type_alias_6.ts | 21 + .../ts/generic_type_alias_7-expected.txt | 539 + .../test/compiler/ts/generic_type_alias_7.ts | 21 + .../ts/generic_type_alias_8-expected.txt | 806 ++ .../test/compiler/ts/generic_type_alias_8.ts | 25 + .../ts/generic_type_alias_9-expected.txt | 701 ++ .../test/compiler/ts/generic_type_alias_9.ts | 25 + .../identifierWithoutDeclaration-expected.txt | 315 + .../ts/identifierWithoutDeclaration.ts | 21 + es2panda/test/compiler/ts/in_1-expected.txt | 189 + es2panda/test/compiler/ts/in_1.ts | 19 + es2panda/test/compiler/ts/in_10-expected.txt | 230 + es2panda/test/compiler/ts/in_10.ts | 19 + es2panda/test/compiler/ts/in_11-expected.txt | 189 + es2panda/test/compiler/ts/in_11.ts | 19 + es2panda/test/compiler/ts/in_12-expected.txt | 189 + es2panda/test/compiler/ts/in_12.ts | 19 + es2panda/test/compiler/ts/in_13-expected.txt | 189 + es2panda/test/compiler/ts/in_13.ts | 19 + es2panda/test/compiler/ts/in_14-expected.txt | 189 + es2panda/test/compiler/ts/in_14.ts | 19 + es2panda/test/compiler/ts/in_15-expected.txt | 256 + es2panda/test/compiler/ts/in_15.ts | 19 + es2panda/test/compiler/ts/in_2-expected.txt | 189 + es2panda/test/compiler/ts/in_2.ts | 19 + es2panda/test/compiler/ts/in_3-expected.txt | 189 + es2panda/test/compiler/ts/in_3.ts | 19 + es2panda/test/compiler/ts/in_4-expected.txt | 189 + es2panda/test/compiler/ts/in_4.ts | 19 + es2panda/test/compiler/ts/in_5-expected.txt | 189 + es2panda/test/compiler/ts/in_5.ts | 19 + es2panda/test/compiler/ts/in_6-expected.txt | 189 + es2panda/test/compiler/ts/in_6.ts | 19 + es2panda/test/compiler/ts/in_7-expected.txt | 256 + es2panda/test/compiler/ts/in_7.ts | 19 + es2panda/test/compiler/ts/in_8-expected.txt | 189 + es2panda/test/compiler/ts/in_8.ts | 19 + es2panda/test/compiler/ts/in_9-expected.txt | 189 + es2panda/test/compiler/ts/in_9.ts | 19 + .../compiler/ts/instanceof_1-expected.txt | 189 + es2panda/test/compiler/ts/instanceof_1.ts | 19 + .../compiler/ts/instanceof_10-expected.txt | 189 + es2panda/test/compiler/ts/instanceof_10.ts | 19 + .../compiler/ts/instanceof_11-expected.txt | 189 + es2panda/test/compiler/ts/instanceof_11.ts | 19 + .../compiler/ts/instanceof_12-expected.txt | 189 + es2panda/test/compiler/ts/instanceof_12.ts | 19 + .../compiler/ts/instanceof_13-expected.txt | 189 + es2panda/test/compiler/ts/instanceof_13.ts | 19 + .../compiler/ts/instanceof_14-expected.txt | 256 + es2panda/test/compiler/ts/instanceof_14.ts | 19 + .../compiler/ts/instanceof_2-expected.txt | 245 + es2panda/test/compiler/ts/instanceof_2.ts | 20 + .../compiler/ts/instanceof_3-expected.txt | 189 + es2panda/test/compiler/ts/instanceof_3.ts | 19 + .../compiler/ts/instanceof_4-expected.txt | 245 + es2panda/test/compiler/ts/instanceof_4.ts | 20 + .../compiler/ts/instanceof_5-expected.txt | 189 + es2panda/test/compiler/ts/instanceof_5.ts | 19 + .../compiler/ts/instanceof_6-expected.txt | 246 + es2panda/test/compiler/ts/instanceof_6.ts | 20 + .../compiler/ts/instanceof_7-expected.txt | 189 + es2panda/test/compiler/ts/instanceof_7.ts | 19 + .../compiler/ts/instanceof_8-expected.txt | 245 + es2panda/test/compiler/ts/instanceof_8.ts | 20 + .../compiler/ts/instanceof_9-expected.txt | 256 + es2panda/test/compiler/ts/instanceof_9.ts | 19 + .../ts/interfaceAssignment-expected.txt | 3973 ++++++++ .../test/compiler/ts/interfaceAssignment.ts | 96 + .../ts/interfaceAssignment1-expected.txt | 325 + .../test/compiler/ts/interfaceAssignment1.ts | 25 + .../ts/interfaceAssignment2-expected.txt | 483 + .../test/compiler/ts/interfaceAssignment2.ts | 30 + .../ts/interfaceAssignment3-expected.txt | 771 ++ .../test/compiler/ts/interfaceAssignment3.ts | 37 + .../ts/interfaceAssignment4-expected.txt | 424 + .../test/compiler/ts/interfaceAssignment4.ts | 22 + .../ts/interfaceAssignment5-expected.txt | 629 ++ .../test/compiler/ts/interfaceAssignment5.ts | 29 + .../ts/interfaceAssignment6-expected.txt | 330 + .../test/compiler/ts/interfaceAssignment6.ts | 22 + .../ts/interfaceAssignment7-expected.txt | 411 + .../test/compiler/ts/interfaceAssignment7.ts | 23 + .../ts/interfaceAssignment8-expected.txt | 417 + .../test/compiler/ts/interfaceAssignment8.ts | 28 + .../ts/interfaceInheritance1-expected.txt | 232 + .../test/compiler/ts/interfaceInheritance1.ts | 27 + .../ts/interfaceInheritance2-expected.txt | 221 + .../test/compiler/ts/interfaceInheritance2.ts | 23 + .../ts/interfaceInheritance3-expected.txt | 231 + .../test/compiler/ts/interfaceInheritance3.ts | 23 + .../ts/interfaceInheritance4-expected.txt | 393 + .../test/compiler/ts/interfaceInheritance4.ts | 27 + ...yReferenceContainingInterface-expected.txt | 1066 ++ ...acePropertyReferenceContainingInterface.ts | 30 + ...ReferenceContainingInterface1-expected.txt | 591 ++ ...cePropertyReferenceContainingInterface1.ts | 28 + ...ertyWithIncompatibleIndexInfo-expected.txt | 159 + ...erfacePropertyWithIncompatibleIndexInfo.ts | 20 + .../ts/interfaceUsedAsValue-expected.txt | 362 + .../test/compiler/ts/interfaceUsedAsValue.ts | 24 + ...ceWithNonCompatibleIndexInfos-expected.txt | 170 + .../interfaceWithNonCompatibleIndexInfos.ts | 20 + .../ts/interface_enum_member-expected.txt | 205 + .../test/compiler/ts/interface_enum_member.ts | 23 + .../ts/letUsedBeforeDeclaration-expected.txt | 130 + .../compiler/ts/letUsedBeforeDeclaration.ts | 18 + .../compiler/ts/memberExpTest_1-expected.txt | 479 + es2panda/test/compiler/ts/memberExpTest_1.ts | 23 + .../compiler/ts/memberExpTest_2-expected.txt | 557 + es2panda/test/compiler/ts/memberExpTest_2.ts | 28 + .../compiler/ts/memberExpTest_3-expected.txt | 734 ++ es2panda/test/compiler/ts/memberExpTest_3.ts | 27 + .../compiler/ts/memberExpTest_4-expected.txt | 468 + es2panda/test/compiler/ts/memberExpTest_4.ts | 27 + .../compiler/ts/memberExpTest_5-expected.txt | 468 + es2panda/test/compiler/ts/memberExpTest_5.ts | 27 + .../compiler/ts/memberExpTest_6-expected.txt | 555 + es2panda/test/compiler/ts/memberExpTest_6.ts | 29 + .../compiler/ts/memberExpTests-expected.txt | 5920 +++++++++++ es2panda/test/compiler/ts/memberExpTests.ts | 109 + .../ts/member_expression_1-expected.txt | 420 + .../test/compiler/ts/member_expression_1.ts | 19 + .../ts/member_expression_10-expected.txt | 433 + .../test/compiler/ts/member_expression_10.ts | 19 + .../ts/member_expression_11-expected.txt | 432 + .../test/compiler/ts/member_expression_11.ts | 19 + .../ts/member_expression_12-expected.txt | 433 + .../test/compiler/ts/member_expression_12.ts | 19 + .../ts/member_expression_13-expected.txt | 432 + .../test/compiler/ts/member_expression_13.ts | 19 + .../ts/member_expression_14-expected.txt | 433 + .../test/compiler/ts/member_expression_14.ts | 19 + .../ts/member_expression_15-expected.txt | 432 + .../test/compiler/ts/member_expression_15.ts | 19 + .../ts/member_expression_16-expected.txt | 433 + .../test/compiler/ts/member_expression_16.ts | 19 + .../ts/member_expression_17-expected.txt | 432 + .../test/compiler/ts/member_expression_17.ts | 19 + .../ts/member_expression_18-expected.txt | 433 + .../test/compiler/ts/member_expression_18.ts | 19 + .../ts/member_expression_19-expected.txt | 432 + .../test/compiler/ts/member_expression_19.ts | 19 + .../ts/member_expression_2-expected.txt | 419 + .../test/compiler/ts/member_expression_2.ts | 19 + .../ts/member_expression_20-expected.txt | 433 + .../test/compiler/ts/member_expression_20.ts | 19 + .../ts/member_expression_21-expected.txt | 432 + .../test/compiler/ts/member_expression_21.ts | 19 + .../ts/member_expression_22-expected.txt | 433 + .../test/compiler/ts/member_expression_22.ts | 19 + .../ts/member_expression_23-expected.txt | 432 + .../test/compiler/ts/member_expression_23.ts | 19 + .../ts/member_expression_24-expected.txt | 433 + .../test/compiler/ts/member_expression_24.ts | 19 + .../ts/member_expression_25-expected.txt | 432 + .../test/compiler/ts/member_expression_25.ts | 19 + .../ts/member_expression_26-expected.txt | 433 + .../test/compiler/ts/member_expression_26.ts | 19 + .../ts/member_expression_27-expected.txt | 432 + .../test/compiler/ts/member_expression_27.ts | 19 + .../ts/member_expression_28-expected.txt | 433 + .../test/compiler/ts/member_expression_28.ts | 19 + .../ts/member_expression_29-expected.txt | 432 + .../test/compiler/ts/member_expression_29.ts | 19 + .../ts/member_expression_3-expected.txt | 420 + .../test/compiler/ts/member_expression_3.ts | 19 + .../ts/member_expression_30-expected.txt | 433 + .../test/compiler/ts/member_expression_30.ts | 19 + .../ts/member_expression_31-expected.txt | 432 + .../test/compiler/ts/member_expression_31.ts | 19 + .../ts/member_expression_32-expected.txt | 433 + .../test/compiler/ts/member_expression_32.ts | 19 + .../ts/member_expression_33-expected.txt | 432 + .../test/compiler/ts/member_expression_33.ts | 19 + .../ts/member_expression_34-expected.txt | 433 + .../test/compiler/ts/member_expression_34.ts | 19 + .../ts/member_expression_35-expected.txt | 432 + .../test/compiler/ts/member_expression_35.ts | 19 + .../ts/member_expression_36-expected.txt | 433 + .../test/compiler/ts/member_expression_36.ts | 19 + .../ts/member_expression_37-expected.txt | 432 + .../test/compiler/ts/member_expression_37.ts | 19 + .../ts/member_expression_38-expected.txt | 433 + .../test/compiler/ts/member_expression_38.ts | 19 + .../ts/member_expression_39-expected.txt | 432 + .../test/compiler/ts/member_expression_39.ts | 19 + .../ts/member_expression_4-expected.txt | 419 + .../test/compiler/ts/member_expression_4.ts | 19 + .../ts/member_expression_40-expected.txt | 433 + .../test/compiler/ts/member_expression_40.ts | 19 + .../ts/member_expression_41-expected.txt | 432 + .../test/compiler/ts/member_expression_41.ts | 19 + .../ts/member_expression_42-expected.txt | 433 + .../test/compiler/ts/member_expression_42.ts | 19 + .../ts/member_expression_43-expected.txt | 432 + .../test/compiler/ts/member_expression_43.ts | 19 + .../ts/member_expression_44-expected.txt | 433 + .../test/compiler/ts/member_expression_44.ts | 19 + .../ts/member_expression_45-expected.txt | 432 + .../test/compiler/ts/member_expression_45.ts | 19 + .../ts/member_expression_46-expected.txt | 289 + .../test/compiler/ts/member_expression_46.ts | 19 + .../ts/member_expression_47-expected.txt | 302 + .../test/compiler/ts/member_expression_47.ts | 19 + .../ts/member_expression_48-expected.txt | 289 + .../test/compiler/ts/member_expression_48.ts | 19 + .../ts/member_expression_49-expected.txt | 302 + .../test/compiler/ts/member_expression_49.ts | 19 + .../ts/member_expression_5-expected.txt | 420 + .../test/compiler/ts/member_expression_5.ts | 19 + .../ts/member_expression_50-expected.txt | 376 + .../test/compiler/ts/member_expression_50.ts | 20 + .../ts/member_expression_51-expected.txt | 389 + .../test/compiler/ts/member_expression_51.ts | 20 + .../ts/member_expression_52-expected.txt | 376 + .../test/compiler/ts/member_expression_52.ts | 20 + .../ts/member_expression_53-expected.txt | 389 + .../test/compiler/ts/member_expression_53.ts | 20 + .../ts/member_expression_54-expected.txt | 289 + .../test/compiler/ts/member_expression_54.ts | 19 + .../ts/member_expression_55-expected.txt | 302 + .../test/compiler/ts/member_expression_55.ts | 19 + .../ts/member_expression_56-expected.txt | 289 + .../test/compiler/ts/member_expression_56.ts | 19 + .../ts/member_expression_57-expected.txt | 302 + .../test/compiler/ts/member_expression_57.ts | 19 + .../ts/member_expression_58-expected.txt | 376 + .../test/compiler/ts/member_expression_58.ts | 20 + .../ts/member_expression_59-expected.txt | 389 + .../test/compiler/ts/member_expression_59.ts | 20 + .../ts/member_expression_6-expected.txt | 419 + .../test/compiler/ts/member_expression_6.ts | 19 + .../ts/member_expression_60-expected.txt | 376 + .../test/compiler/ts/member_expression_60.ts | 20 + .../ts/member_expression_61-expected.txt | 389 + .../test/compiler/ts/member_expression_61.ts | 20 + .../ts/member_expression_62-expected.txt | 289 + .../test/compiler/ts/member_expression_62.ts | 19 + .../ts/member_expression_63-expected.txt | 302 + .../test/compiler/ts/member_expression_63.ts | 19 + .../ts/member_expression_64-expected.txt | 289 + .../test/compiler/ts/member_expression_64.ts | 19 + .../ts/member_expression_65-expected.txt | 302 + .../test/compiler/ts/member_expression_65.ts | 19 + .../ts/member_expression_66-expected.txt | 376 + .../test/compiler/ts/member_expression_66.ts | 20 + .../ts/member_expression_67-expected.txt | 389 + .../test/compiler/ts/member_expression_67.ts | 20 + .../ts/member_expression_68-expected.txt | 376 + .../test/compiler/ts/member_expression_68.ts | 20 + .../ts/member_expression_69-expected.txt | 389 + .../test/compiler/ts/member_expression_69.ts | 20 + .../ts/member_expression_7-expected.txt | 420 + .../test/compiler/ts/member_expression_7.ts | 19 + .../ts/member_expression_70-expected.txt | 271 + .../test/compiler/ts/member_expression_70.ts | 18 + .../ts/member_expression_71-expected.txt | 271 + .../test/compiler/ts/member_expression_71.ts | 18 + .../ts/member_expression_72-expected.txt | 328 + .../test/compiler/ts/member_expression_72.ts | 21 + .../ts/member_expression_73-expected.txt | 328 + .../test/compiler/ts/member_expression_73.ts | 21 + .../ts/member_expression_74-expected.txt | 282 + .../test/compiler/ts/member_expression_74.ts | 18 + .../ts/member_expression_75-expected.txt | 339 + .../test/compiler/ts/member_expression_75.ts | 22 + .../ts/member_expression_76-expected.txt | 339 + .../test/compiler/ts/member_expression_76.ts | 22 + .../ts/member_expression_77-expected.txt | 282 + .../test/compiler/ts/member_expression_77.ts | 18 + .../ts/member_expression_78-expected.txt | 335 + .../test/compiler/ts/member_expression_78.ts | 22 + .../ts/member_expression_79-expected.txt | 391 + .../test/compiler/ts/member_expression_79.ts | 23 + .../ts/member_expression_8-expected.txt | 433 + .../test/compiler/ts/member_expression_8.ts | 19 + .../ts/member_expression_80-expected.txt | 274 + .../test/compiler/ts/member_expression_80.ts | 19 + .../ts/member_expression_81-expected.txt | 275 + .../test/compiler/ts/member_expression_81.ts | 19 + .../ts/member_expression_82-expected.txt | 274 + .../test/compiler/ts/member_expression_82.ts | 19 + .../ts/member_expression_9-expected.txt | 432 + .../test/compiler/ts/member_expression_9.ts | 19 + .../compiler/ts/new_expression_1-expected.txt | 262 + es2panda/test/compiler/ts/new_expression_1.ts | 18 + .../ts/new_expression_10-expected.txt | 262 + .../test/compiler/ts/new_expression_10.ts | 18 + .../ts/new_expression_100-expected.txt | 247 + .../test/compiler/ts/new_expression_100.ts | 18 + .../ts/new_expression_101-expected.txt | 247 + .../test/compiler/ts/new_expression_101.ts | 18 + .../ts/new_expression_102-expected.txt | 233 + .../test/compiler/ts/new_expression_102.ts | 18 + .../ts/new_expression_103-expected.txt | 247 + .../test/compiler/ts/new_expression_103.ts | 18 + .../ts/new_expression_104-expected.txt | 233 + .../test/compiler/ts/new_expression_104.ts | 18 + .../ts/new_expression_105-expected.txt | 247 + .../test/compiler/ts/new_expression_105.ts | 18 + .../ts/new_expression_106-expected.txt | 233 + .../test/compiler/ts/new_expression_106.ts | 18 + .../ts/new_expression_107-expected.txt | 247 + .../test/compiler/ts/new_expression_107.ts | 18 + .../ts/new_expression_108-expected.txt | 247 + .../test/compiler/ts/new_expression_108.ts | 18 + .../ts/new_expression_109-expected.txt | 233 + .../test/compiler/ts/new_expression_109.ts | 18 + .../ts/new_expression_11-expected.txt | 248 + .../test/compiler/ts/new_expression_11.ts | 18 + .../ts/new_expression_110-expected.txt | 247 + .../test/compiler/ts/new_expression_110.ts | 18 + .../ts/new_expression_111-expected.txt | 233 + .../test/compiler/ts/new_expression_111.ts | 18 + .../ts/new_expression_112-expected.txt | 247 + .../test/compiler/ts/new_expression_112.ts | 18 + .../ts/new_expression_113-expected.txt | 233 + .../test/compiler/ts/new_expression_113.ts | 18 + .../ts/new_expression_114-expected.txt | 247 + .../test/compiler/ts/new_expression_114.ts | 18 + .../ts/new_expression_115-expected.txt | 233 + .../test/compiler/ts/new_expression_115.ts | 18 + .../ts/new_expression_116-expected.txt | 247 + .../test/compiler/ts/new_expression_116.ts | 18 + .../ts/new_expression_117-expected.txt | 247 + .../test/compiler/ts/new_expression_117.ts | 18 + .../ts/new_expression_118-expected.txt | 233 + .../test/compiler/ts/new_expression_118.ts | 18 + .../ts/new_expression_119-expected.txt | 247 + .../test/compiler/ts/new_expression_119.ts | 18 + .../ts/new_expression_12-expected.txt | 262 + .../test/compiler/ts/new_expression_12.ts | 18 + .../ts/new_expression_120-expected.txt | 233 + .../test/compiler/ts/new_expression_120.ts | 18 + .../ts/new_expression_121-expected.txt | 247 + .../test/compiler/ts/new_expression_121.ts | 18 + .../ts/new_expression_122-expected.txt | 233 + .../test/compiler/ts/new_expression_122.ts | 18 + .../ts/new_expression_123-expected.txt | 247 + .../test/compiler/ts/new_expression_123.ts | 18 + .../ts/new_expression_124-expected.txt | 247 + .../test/compiler/ts/new_expression_124.ts | 18 + .../ts/new_expression_125-expected.txt | 233 + .../test/compiler/ts/new_expression_125.ts | 18 + .../ts/new_expression_126-expected.txt | 247 + .../test/compiler/ts/new_expression_126.ts | 18 + .../ts/new_expression_127-expected.txt | 233 + .../test/compiler/ts/new_expression_127.ts | 18 + .../ts/new_expression_128-expected.txt | 247 + .../test/compiler/ts/new_expression_128.ts | 18 + .../ts/new_expression_129-expected.txt | 233 + .../test/compiler/ts/new_expression_129.ts | 18 + .../ts/new_expression_13-expected.txt | 248 + .../test/compiler/ts/new_expression_13.ts | 18 + .../ts/new_expression_130-expected.txt | 247 + .../test/compiler/ts/new_expression_130.ts | 18 + .../ts/new_expression_131-expected.txt | 247 + .../test/compiler/ts/new_expression_131.ts | 18 + .../ts/new_expression_132-expected.txt | 233 + .../test/compiler/ts/new_expression_132.ts | 18 + .../ts/new_expression_133-expected.txt | 247 + .../test/compiler/ts/new_expression_133.ts | 18 + .../ts/new_expression_134-expected.txt | 233 + .../test/compiler/ts/new_expression_134.ts | 18 + .../ts/new_expression_135-expected.txt | 247 + .../test/compiler/ts/new_expression_135.ts | 18 + .../ts/new_expression_136-expected.txt | 233 + .../test/compiler/ts/new_expression_136.ts | 18 + .../ts/new_expression_137-expected.txt | 247 + .../test/compiler/ts/new_expression_137.ts | 18 + .../ts/new_expression_138-expected.txt | 233 + .../test/compiler/ts/new_expression_138.ts | 18 + .../ts/new_expression_139-expected.txt | 247 + .../test/compiler/ts/new_expression_139.ts | 18 + .../ts/new_expression_14-expected.txt | 262 + .../test/compiler/ts/new_expression_14.ts | 18 + .../ts/new_expression_140-expected.txt | 247 + .../test/compiler/ts/new_expression_140.ts | 18 + .../ts/new_expression_141-expected.txt | 233 + .../test/compiler/ts/new_expression_141.ts | 18 + .../ts/new_expression_142-expected.txt | 247 + .../test/compiler/ts/new_expression_142.ts | 18 + .../ts/new_expression_143-expected.txt | 233 + .../test/compiler/ts/new_expression_143.ts | 18 + .../ts/new_expression_144-expected.txt | 247 + .../test/compiler/ts/new_expression_144.ts | 18 + .../ts/new_expression_145-expected.txt | 233 + .../test/compiler/ts/new_expression_145.ts | 18 + .../ts/new_expression_146-expected.txt | 247 + .../test/compiler/ts/new_expression_146.ts | 18 + .../ts/new_expression_147-expected.txt | 247 + .../test/compiler/ts/new_expression_147.ts | 18 + .../ts/new_expression_148-expected.txt | 233 + .../test/compiler/ts/new_expression_148.ts | 18 + .../ts/new_expression_149-expected.txt | 247 + .../test/compiler/ts/new_expression_149.ts | 18 + .../ts/new_expression_15-expected.txt | 262 + .../test/compiler/ts/new_expression_15.ts | 18 + .../ts/new_expression_150-expected.txt | 233 + .../test/compiler/ts/new_expression_150.ts | 18 + .../ts/new_expression_151-expected.txt | 247 + .../test/compiler/ts/new_expression_151.ts | 18 + .../ts/new_expression_152-expected.txt | 233 + .../test/compiler/ts/new_expression_152.ts | 18 + .../ts/new_expression_153-expected.txt | 247 + .../test/compiler/ts/new_expression_153.ts | 18 + .../ts/new_expression_154-expected.txt | 247 + .../test/compiler/ts/new_expression_154.ts | 18 + .../ts/new_expression_155-expected.txt | 233 + .../test/compiler/ts/new_expression_155.ts | 18 + .../ts/new_expression_156-expected.txt | 218 + .../test/compiler/ts/new_expression_156.ts | 18 + .../ts/new_expression_157-expected.txt | 261 + .../test/compiler/ts/new_expression_157.ts | 18 + .../ts/new_expression_158-expected.txt | 217 + .../test/compiler/ts/new_expression_158.ts | 19 + .../ts/new_expression_159-expected.txt | 217 + .../test/compiler/ts/new_expression_159.ts | 19 + .../ts/new_expression_16-expected.txt | 248 + .../test/compiler/ts/new_expression_16.ts | 18 + .../ts/new_expression_160-expected.txt | 217 + .../test/compiler/ts/new_expression_160.ts | 19 + .../ts/new_expression_161-expected.txt | 217 + .../test/compiler/ts/new_expression_161.ts | 19 + .../ts/new_expression_162-expected.txt | 217 + .../test/compiler/ts/new_expression_162.ts | 19 + .../ts/new_expression_163-expected.txt | 217 + .../test/compiler/ts/new_expression_163.ts | 19 + .../ts/new_expression_17-expected.txt | 262 + .../test/compiler/ts/new_expression_17.ts | 18 + .../ts/new_expression_18-expected.txt | 248 + .../test/compiler/ts/new_expression_18.ts | 18 + .../ts/new_expression_19-expected.txt | 262 + .../test/compiler/ts/new_expression_19.ts | 18 + .../compiler/ts/new_expression_2-expected.txt | 262 + es2panda/test/compiler/ts/new_expression_2.ts | 18 + .../ts/new_expression_20-expected.txt | 248 + .../test/compiler/ts/new_expression_20.ts | 18 + .../ts/new_expression_21-expected.txt | 262 + .../test/compiler/ts/new_expression_21.ts | 18 + .../ts/new_expression_22-expected.txt | 248 + .../test/compiler/ts/new_expression_22.ts | 18 + .../ts/new_expression_23-expected.txt | 262 + .../test/compiler/ts/new_expression_23.ts | 18 + .../ts/new_expression_24-expected.txt | 248 + .../test/compiler/ts/new_expression_24.ts | 18 + .../ts/new_expression_25-expected.txt | 262 + .../test/compiler/ts/new_expression_25.ts | 18 + .../ts/new_expression_26-expected.txt | 248 + .../test/compiler/ts/new_expression_26.ts | 18 + .../ts/new_expression_27-expected.txt | 248 + .../test/compiler/ts/new_expression_27.ts | 18 + .../ts/new_expression_28-expected.txt | 262 + .../test/compiler/ts/new_expression_28.ts | 18 + .../ts/new_expression_29-expected.txt | 262 + .../test/compiler/ts/new_expression_29.ts | 18 + .../compiler/ts/new_expression_3-expected.txt | 248 + es2panda/test/compiler/ts/new_expression_3.ts | 18 + .../ts/new_expression_30-expected.txt | 248 + .../test/compiler/ts/new_expression_30.ts | 18 + .../ts/new_expression_31-expected.txt | 262 + .../test/compiler/ts/new_expression_31.ts | 18 + .../ts/new_expression_32-expected.txt | 248 + .../test/compiler/ts/new_expression_32.ts | 18 + .../ts/new_expression_33-expected.txt | 248 + .../test/compiler/ts/new_expression_33.ts | 18 + .../ts/new_expression_34-expected.txt | 262 + .../test/compiler/ts/new_expression_34.ts | 18 + .../ts/new_expression_35-expected.txt | 248 + .../test/compiler/ts/new_expression_35.ts | 18 + .../ts/new_expression_36-expected.txt | 262 + .../test/compiler/ts/new_expression_36.ts | 18 + .../ts/new_expression_37-expected.txt | 248 + .../test/compiler/ts/new_expression_37.ts | 18 + .../ts/new_expression_38-expected.txt | 248 + .../test/compiler/ts/new_expression_38.ts | 18 + .../ts/new_expression_39-expected.txt | 262 + .../test/compiler/ts/new_expression_39.ts | 18 + .../compiler/ts/new_expression_4-expected.txt | 262 + es2panda/test/compiler/ts/new_expression_4.ts | 18 + .../ts/new_expression_40-expected.txt | 262 + .../test/compiler/ts/new_expression_40.ts | 18 + .../ts/new_expression_41-expected.txt | 248 + .../test/compiler/ts/new_expression_41.ts | 18 + .../ts/new_expression_42-expected.txt | 262 + .../test/compiler/ts/new_expression_42.ts | 18 + .../ts/new_expression_43-expected.txt | 248 + .../test/compiler/ts/new_expression_43.ts | 18 + .../ts/new_expression_44-expected.txt | 248 + .../test/compiler/ts/new_expression_44.ts | 18 + .../ts/new_expression_45-expected.txt | 262 + .../test/compiler/ts/new_expression_45.ts | 18 + .../ts/new_expression_46-expected.txt | 248 + .../test/compiler/ts/new_expression_46.ts | 18 + .../ts/new_expression_47-expected.txt | 262 + .../test/compiler/ts/new_expression_47.ts | 18 + .../ts/new_expression_48-expected.txt | 248 + .../test/compiler/ts/new_expression_48.ts | 18 + .../ts/new_expression_49-expected.txt | 248 + .../test/compiler/ts/new_expression_49.ts | 18 + .../compiler/ts/new_expression_5-expected.txt | 248 + es2panda/test/compiler/ts/new_expression_5.ts | 18 + .../ts/new_expression_50-expected.txt | 262 + .../test/compiler/ts/new_expression_50.ts | 18 + .../ts/new_expression_51-expected.txt | 248 + .../test/compiler/ts/new_expression_51.ts | 18 + .../ts/new_expression_52-expected.txt | 262 + .../test/compiler/ts/new_expression_52.ts | 18 + .../ts/new_expression_53-expected.txt | 248 + .../test/compiler/ts/new_expression_53.ts | 18 + .../ts/new_expression_54-expected.txt | 248 + .../test/compiler/ts/new_expression_54.ts | 18 + .../ts/new_expression_55-expected.txt | 262 + .../test/compiler/ts/new_expression_55.ts | 18 + .../ts/new_expression_56-expected.txt | 248 + .../test/compiler/ts/new_expression_56.ts | 18 + .../ts/new_expression_57-expected.txt | 262 + .../test/compiler/ts/new_expression_57.ts | 18 + .../ts/new_expression_58-expected.txt | 248 + .../test/compiler/ts/new_expression_58.ts | 18 + .../ts/new_expression_59-expected.txt | 248 + .../test/compiler/ts/new_expression_59.ts | 18 + .../compiler/ts/new_expression_6-expected.txt | 262 + es2panda/test/compiler/ts/new_expression_6.ts | 18 + .../ts/new_expression_60-expected.txt | 262 + .../test/compiler/ts/new_expression_60.ts | 18 + .../ts/new_expression_61-expected.txt | 248 + .../test/compiler/ts/new_expression_61.ts | 18 + .../ts/new_expression_62-expected.txt | 262 + .../test/compiler/ts/new_expression_62.ts | 18 + .../ts/new_expression_63-expected.txt | 248 + .../test/compiler/ts/new_expression_63.ts | 18 + .../ts/new_expression_64-expected.txt | 248 + .../test/compiler/ts/new_expression_64.ts | 18 + .../ts/new_expression_65-expected.txt | 262 + .../test/compiler/ts/new_expression_65.ts | 18 + .../ts/new_expression_66-expected.txt | 248 + .../test/compiler/ts/new_expression_66.ts | 18 + .../ts/new_expression_67-expected.txt | 262 + .../test/compiler/ts/new_expression_67.ts | 18 + .../ts/new_expression_68-expected.txt | 248 + .../test/compiler/ts/new_expression_68.ts | 18 + .../ts/new_expression_69-expected.txt | 248 + .../test/compiler/ts/new_expression_69.ts | 18 + .../compiler/ts/new_expression_7-expected.txt | 248 + es2panda/test/compiler/ts/new_expression_7.ts | 18 + .../ts/new_expression_70-expected.txt | 262 + .../test/compiler/ts/new_expression_70.ts | 18 + .../ts/new_expression_71-expected.txt | 248 + .../test/compiler/ts/new_expression_71.ts | 18 + .../ts/new_expression_72-expected.txt | 262 + .../test/compiler/ts/new_expression_72.ts | 18 + .../ts/new_expression_73-expected.txt | 262 + .../test/compiler/ts/new_expression_73.ts | 18 + .../ts/new_expression_74-expected.txt | 248 + .../test/compiler/ts/new_expression_74.ts | 18 + .../ts/new_expression_75-expected.txt | 248 + .../test/compiler/ts/new_expression_75.ts | 18 + .../ts/new_expression_76-expected.txt | 262 + .../test/compiler/ts/new_expression_76.ts | 18 + .../ts/new_expression_77-expected.txt | 248 + .../test/compiler/ts/new_expression_77.ts | 18 + .../ts/new_expression_78-expected.txt | 262 + .../test/compiler/ts/new_expression_78.ts | 18 + .../ts/new_expression_79-expected.txt | 248 + .../test/compiler/ts/new_expression_79.ts | 18 + .../compiler/ts/new_expression_8-expected.txt | 262 + es2panda/test/compiler/ts/new_expression_8.ts | 18 + .../ts/new_expression_80-expected.txt | 248 + .../test/compiler/ts/new_expression_80.ts | 18 + .../ts/new_expression_81-expected.txt | 262 + .../test/compiler/ts/new_expression_81.ts | 18 + .../ts/new_expression_82-expected.txt | 248 + .../test/compiler/ts/new_expression_82.ts | 18 + .../ts/new_expression_83-expected.txt | 262 + .../test/compiler/ts/new_expression_83.ts | 18 + .../ts/new_expression_84-expected.txt | 262 + .../test/compiler/ts/new_expression_84.ts | 18 + .../ts/new_expression_85-expected.txt | 248 + .../test/compiler/ts/new_expression_85.ts | 18 + .../ts/new_expression_86-expected.txt | 248 + .../test/compiler/ts/new_expression_86.ts | 18 + .../ts/new_expression_87-expected.txt | 262 + .../test/compiler/ts/new_expression_87.ts | 18 + .../ts/new_expression_88-expected.txt | 248 + .../test/compiler/ts/new_expression_88.ts | 18 + .../ts/new_expression_89-expected.txt | 262 + .../test/compiler/ts/new_expression_89.ts | 18 + .../compiler/ts/new_expression_9-expected.txt | 248 + es2panda/test/compiler/ts/new_expression_9.ts | 18 + .../ts/new_expression_90-expected.txt | 248 + .../test/compiler/ts/new_expression_90.ts | 18 + .../ts/new_expression_91-expected.txt | 233 + .../test/compiler/ts/new_expression_91.ts | 18 + .../ts/new_expression_92-expected.txt | 291 + .../test/compiler/ts/new_expression_92.ts | 18 + .../ts/new_expression_93-expected.txt | 247 + .../test/compiler/ts/new_expression_93.ts | 18 + .../ts/new_expression_94-expected.txt | 247 + .../test/compiler/ts/new_expression_94.ts | 18 + .../ts/new_expression_95-expected.txt | 233 + .../test/compiler/ts/new_expression_95.ts | 18 + .../ts/new_expression_96-expected.txt | 247 + .../test/compiler/ts/new_expression_96.ts | 18 + .../ts/new_expression_97-expected.txt | 233 + .../test/compiler/ts/new_expression_97.ts | 18 + .../ts/new_expression_98-expected.txt | 247 + .../test/compiler/ts/new_expression_98.ts | 18 + .../ts/new_expression_99-expected.txt | 233 + .../test/compiler/ts/new_expression_99.ts | 18 + .../ts/objectDestructuring-expected.txt | 8633 ++++++++++++++++ .../test/compiler/ts/objectDestructuring.ts | 89 + .../ts/objectDestructuring1-expected.txt | 121 + .../test/compiler/ts/objectDestructuring1.ts | 17 + .../ts/objectDestructuring10-expected.txt | 382 + .../test/compiler/ts/objectDestructuring10.ts | 17 + .../ts/objectDestructuring11-expected.txt | 383 + .../test/compiler/ts/objectDestructuring11.ts | 17 + .../ts/objectDestructuring12-expected.txt | 513 + .../test/compiler/ts/objectDestructuring12.ts | 18 + .../ts/objectDestructuring13-expected.txt | 438 + .../test/compiler/ts/objectDestructuring13.ts | 18 + .../ts/objectDestructuring14-expected.txt | 217 + .../test/compiler/ts/objectDestructuring14.ts | 19 + .../ts/objectDestructuring15-expected.txt | 301 + .../test/compiler/ts/objectDestructuring15.ts | 17 + .../ts/objectDestructuring16-expected.txt | 373 + .../test/compiler/ts/objectDestructuring16.ts | 17 + .../ts/objectDestructuring17-expected.txt | 419 + .../test/compiler/ts/objectDestructuring17.ts | 17 + .../ts/objectDestructuring18-expected.txt | 392 + .../test/compiler/ts/objectDestructuring18.ts | 17 + .../ts/objectDestructuring19-expected.txt | 492 + .../test/compiler/ts/objectDestructuring19.ts | 17 + .../ts/objectDestructuring2-expected.txt | 214 + .../test/compiler/ts/objectDestructuring2.ts | 17 + .../ts/objectDestructuring20-expected.txt | 725 ++ .../test/compiler/ts/objectDestructuring20.ts | 19 + .../ts/objectDestructuring21-expected.txt | 326 + .../test/compiler/ts/objectDestructuring21.ts | 19 + .../ts/objectDestructuring22-expected.txt | 438 + .../test/compiler/ts/objectDestructuring22.ts | 18 + .../ts/objectDestructuring23-expected.txt | 377 + .../test/compiler/ts/objectDestructuring23.ts | 18 + .../ts/objectDestructuring24-expected.txt | 565 ++ .../test/compiler/ts/objectDestructuring24.ts | 19 + .../ts/objectDestructuring25-expected.txt | 737 ++ .../test/compiler/ts/objectDestructuring25.ts | 22 + .../ts/objectDestructuring26-expected.txt | 772 ++ .../test/compiler/ts/objectDestructuring26.ts | 17 + .../ts/objectDestructuring27-expected.txt | 658 ++ .../test/compiler/ts/objectDestructuring27.ts | 20 + .../ts/objectDestructuring28-expected.txt | 805 ++ .../test/compiler/ts/objectDestructuring28.ts | 20 + .../ts/objectDestructuring29-expected.txt | 177 + .../test/compiler/ts/objectDestructuring29.ts | 18 + .../ts/objectDestructuring3-expected.txt | 242 + .../test/compiler/ts/objectDestructuring3.ts | 17 + .../ts/objectDestructuring30-expected.txt | 224 + .../test/compiler/ts/objectDestructuring30.ts | 18 + .../ts/objectDestructuring31-expected.txt | 251 + .../test/compiler/ts/objectDestructuring31.ts | 18 + .../ts/objectDestructuring32-expected.txt | 166 + .../test/compiler/ts/objectDestructuring32.ts | 17 + .../ts/objectDestructuring33-expected.txt | 270 + .../test/compiler/ts/objectDestructuring33.ts | 18 + .../ts/objectDestructuring34-expected.txt | 236 + .../test/compiler/ts/objectDestructuring34.ts | 19 + .../ts/objectDestructuring35-expected.txt | 283 + .../test/compiler/ts/objectDestructuring35.ts | 19 + .../ts/objectDestructuring36-expected.txt | 387 + .../test/compiler/ts/objectDestructuring36.ts | 20 + .../ts/objectDestructuring37-expected.txt | 435 + .../test/compiler/ts/objectDestructuring37.ts | 20 + .../ts/objectDestructuring38-expected.txt | 435 + .../test/compiler/ts/objectDestructuring38.ts | 20 + .../ts/objectDestructuring39-expected.txt | 328 + .../test/compiler/ts/objectDestructuring39.ts | 19 + .../ts/objectDestructuring4-expected.txt | 225 + .../test/compiler/ts/objectDestructuring4.ts | 17 + .../ts/objectDestructuring40-expected.txt | 329 + .../test/compiler/ts/objectDestructuring40.ts | 19 + .../ts/objectDestructuring41-expected.txt | 601 ++ .../test/compiler/ts/objectDestructuring41.ts | 21 + .../ts/objectDestructuring5-expected.txt | 225 + .../test/compiler/ts/objectDestructuring5.ts | 17 + .../ts/objectDestructuring6-expected.txt | 410 + .../test/compiler/ts/objectDestructuring6.ts | 18 + .../ts/objectDestructuring7-expected.txt | 484 + .../test/compiler/ts/objectDestructuring7.ts | 18 + .../ts/objectDestructuring8-expected.txt | 549 + .../test/compiler/ts/objectDestructuring8.ts | 17 + .../ts/objectDestructuring9-expected.txt | 391 + .../test/compiler/ts/objectDestructuring9.ts | 18 + .../objectLiteralAssignability-expected.txt | 8934 ++++++++++++++++ .../compiler/ts/objectLiteralAssignability.ts | 97 + .../objectLiteralAssignability1-expected.txt | 270 + .../ts/objectLiteralAssignability1.ts | 17 + .../objectLiteralAssignability10-expected.txt | 363 + .../ts/objectLiteralAssignability10.ts | 17 + .../objectLiteralAssignability11-expected.txt | 460 + .../ts/objectLiteralAssignability11.ts | 17 + .../objectLiteralAssignability12-expected.txt | 564 ++ .../ts/objectLiteralAssignability12.ts | 17 + .../objectLiteralAssignability13-expected.txt | 610 ++ .../ts/objectLiteralAssignability13.ts | 17 + .../objectLiteralAssignability14-expected.txt | 656 ++ .../ts/objectLiteralAssignability14.ts | 17 + .../objectLiteralAssignability15-expected.txt | 470 + .../ts/objectLiteralAssignability15.ts | 27 + .../objectLiteralAssignability16-expected.txt | 810 ++ .../ts/objectLiteralAssignability16.ts | 36 + .../objectLiteralAssignability17-expected.txt | 384 + .../ts/objectLiteralAssignability17.ts | 19 + .../objectLiteralAssignability18-expected.txt | 814 ++ .../ts/objectLiteralAssignability18.ts | 21 + .../objectLiteralAssignability19-expected.txt | 935 ++ .../ts/objectLiteralAssignability19.ts | 19 + .../objectLiteralAssignability2-expected.txt | 226 + .../ts/objectLiteralAssignability2.ts | 17 + .../objectLiteralAssignability20-expected.txt | 477 + .../ts/objectLiteralAssignability20.ts | 19 + .../objectLiteralAssignability3-expected.txt | 254 + .../ts/objectLiteralAssignability3.ts | 17 + .../objectLiteralAssignability4-expected.txt | 252 + .../ts/objectLiteralAssignability4.ts | 17 + .../objectLiteralAssignability5-expected.txt | 565 ++ .../ts/objectLiteralAssignability5.ts | 18 + .../objectLiteralAssignability6-expected.txt | 342 + .../ts/objectLiteralAssignability6.ts | 17 + .../objectLiteralAssignability7-expected.txt | 313 + .../ts/objectLiteralAssignability7.ts | 17 + .../objectLiteralAssignability8-expected.txt | 492 + .../ts/objectLiteralAssignability8.ts | 17 + .../objectLiteralAssignability9-expected.txt | 270 + .../ts/objectLiteralAssignability9.ts | 17 + .../ts/recursiveFunction-expected.txt | 508 + .../test/compiler/ts/recursiveFunction.ts | 24 + .../recursiveTypeofWithProperty-expected.txt | 746 ++ .../ts/recursiveTypeofWithProperty.ts | 29 + .../compiler/ts/test-interface-expected.txt | 1081 ++ es2panda/test/compiler/ts/test-interface.ts | 32 + .../compiler/ts/test-interface4-expected.txt | 1 + es2panda/test/compiler/ts/test-interface4.ts | 17 + .../compiler/ts/test-interface5-expected.txt | 1 + es2panda/test/compiler/ts/test-interface5.ts | 17 + .../compiler/ts/test-interface6-expected.txt | 1 + es2panda/test/compiler/ts/test-interface6.ts | 17 + .../compiler/ts/test-interface7-expected.txt | 1 + es2panda/test/compiler/ts/test-interface7.ts | 17 + .../ts/test-type-literal-expected.txt | 1721 ++++ .../test/compiler/ts/test-type-literal.ts | 25 + .../ts/test-type-literal4-expected.txt | 1 + .../test/compiler/ts/test-type-literal4.ts | 17 + .../ts/test-type-literal5-expected.txt | 1 + .../test/compiler/ts/test-type-literal5.ts | 17 + .../ts/test-type-literal6-expected.txt | 1 + .../test/compiler/ts/test-type-literal6.ts | 17 + .../ts/test-type-literal7-expected.txt | 1 + .../test/compiler/ts/test-type-literal7.ts | 17 + .../ts/tupleAssignability-expected.txt | 7985 +++++++++++++++ .../test/compiler/ts/tupleAssignability.ts | 86 + .../ts/tupleAssignability1-expected.txt | 103 + .../test/compiler/ts/tupleAssignability1.ts | 17 + .../ts/tupleAssignability10-expected.txt | 173 + .../test/compiler/ts/tupleAssignability10.ts | 19 + .../ts/tupleAssignability11-expected.txt | 206 + .../test/compiler/ts/tupleAssignability11.ts | 19 + .../ts/tupleAssignability12-expected.txt | 481 + .../test/compiler/ts/tupleAssignability12.ts | 19 + .../ts/tupleAssignability13-expected.txt | 375 + .../test/compiler/ts/tupleAssignability13.ts | 23 + .../ts/tupleAssignability14-expected.txt | 88 + .../test/compiler/ts/tupleAssignability14.ts | 17 + .../ts/tupleAssignability15-expected.txt | 243 + .../test/compiler/ts/tupleAssignability15.ts | 19 + .../ts/tupleAssignability16-expected.txt | 200 + .../test/compiler/ts/tupleAssignability16.ts | 17 + .../ts/tupleAssignability17-expected.txt | 327 + .../test/compiler/ts/tupleAssignability17.ts | 19 + .../ts/tupleAssignability18-expected.txt | 781 ++ .../test/compiler/ts/tupleAssignability18.ts | 21 + .../ts/tupleAssignability19-expected.txt | 160 + .../test/compiler/ts/tupleAssignability19.ts | 17 + .../ts/tupleAssignability2-expected.txt | 158 + .../test/compiler/ts/tupleAssignability2.ts | 17 + .../ts/tupleAssignability20-expected.txt | 185 + .../test/compiler/ts/tupleAssignability20.ts | 17 + .../ts/tupleAssignability21-expected.txt | 199 + .../test/compiler/ts/tupleAssignability21.ts | 17 + .../ts/tupleAssignability22-expected.txt | 143 + .../test/compiler/ts/tupleAssignability22.ts | 17 + .../ts/tupleAssignability23-expected.txt | 258 + .../test/compiler/ts/tupleAssignability23.ts | 17 + .../ts/tupleAssignability24-expected.txt | 366 + .../test/compiler/ts/tupleAssignability24.ts | 19 + .../ts/tupleAssignability3-expected.txt | 157 + .../test/compiler/ts/tupleAssignability3.ts | 17 + .../ts/tupleAssignability4-expected.txt | 245 + .../test/compiler/ts/tupleAssignability4.ts | 19 + .../ts/tupleAssignability5-expected.txt | 144 + .../test/compiler/ts/tupleAssignability5.ts | 17 + .../ts/tupleAssignability6-expected.txt | 385 + .../test/compiler/ts/tupleAssignability6.ts | 17 + .../ts/tupleAssignability7-expected.txt | 371 + .../test/compiler/ts/tupleAssignability7.ts | 17 + .../ts/tupleAssignability8-expected.txt | 458 + .../test/compiler/ts/tupleAssignability8.ts | 17 + .../ts/tupleAssignability9-expected.txt | 331 + .../test/compiler/ts/tupleAssignability9.ts | 23 + .../ts/typeAliasUsedAsValue-expected.txt | 371 + .../test/compiler/ts/typeAliasUsedAsValue.ts | 20 + .../ts/undefined_as_value-expected.txt | 495 + .../test/compiler/ts/undefined_as_value.ts | 25 + .../ts/undefined_variable_name-expected.txt | 216 + .../compiler/ts/undefined_variable_name.ts | 21 + .../compiler/ts/varRedeclaration-expected.txt | 6691 ++++++++++++ es2panda/test/compiler/ts/varRedeclaration.ts | 116 + .../ts/varRedeclaration1-expected.txt | 119 + .../test/compiler/ts/varRedeclaration1.ts | 18 + .../ts/varRedeclaration10-expected.txt | 44 + .../test/compiler/ts/varRedeclaration10.ts | 22 + .../ts/varRedeclaration11-expected.txt | 396 + .../test/compiler/ts/varRedeclaration11.ts | 18 + .../ts/varRedeclaration12-expected.txt | 502 + .../test/compiler/ts/varRedeclaration12.ts | 27 + .../ts/varRedeclaration13-expected.txt | 735 ++ .../test/compiler/ts/varRedeclaration13.ts | 35 + .../ts/varRedeclaration14-expected.txt | 483 + .../test/compiler/ts/varRedeclaration14.ts | 30 + .../ts/varRedeclaration15-expected.txt | 279 + .../test/compiler/ts/varRedeclaration15.ts | 18 + .../ts/varRedeclaration2-expected.txt | 146 + .../test/compiler/ts/varRedeclaration2.ts | 18 + .../ts/varRedeclaration3-expected.txt | 160 + .../test/compiler/ts/varRedeclaration3.ts | 18 + .../ts/varRedeclaration4-expected.txt | 158 + .../test/compiler/ts/varRedeclaration4.ts | 18 + .../ts/varRedeclaration5-expected.txt | 44 + .../test/compiler/ts/varRedeclaration5.ts | 22 + .../ts/varRedeclaration6-expected.txt | 299 + .../test/compiler/ts/varRedeclaration6.ts | 18 + .../ts/varRedeclaration7-expected.txt | 44 + .../test/compiler/ts/varRedeclaration7.ts | 22 + .../ts/varRedeclaration8-expected.txt | 44 + .../test/compiler/ts/varRedeclaration8.ts | 24 + .../ts/varRedeclaration9-expected.txt | 275 + .../test/compiler/ts/varRedeclaration9.ts | 18 + ...hand-side-in-prefix-operation-expected.txt | 1 + ...alid-left-hand-side-in-prefix-operation.js | 17 + .../parser/js/new-expression-expected.txt | 1 + es2panda/test/parser/js/new-expression.js | 17 + .../js/test-array-expression-1-expected.txt | 1 + .../test/parser/js/test-array-expression-1.js | 17 + .../js/test-array-expression-2-expected.txt | 1 + .../test/parser/js/test-array-expression-2.js | 17 + .../js/test-array-expression-expected.txt | 492 + .../test/parser/js/test-array-expression.js | 33 + .../js/test-arrow-function-expected.txt | 1707 ++++ .../test/parser/js/test-arrow-function.js | 41 + .../test-assignment-expression-expected.txt | 828 ++ .../parser/js/test-assignment-expression.js | 30 + .../test-async-arrow-function-1-expected.txt | 358 + .../parser/js/test-async-arrow-function-1.js | 20 + .../js/test-async-function-1-expected.txt | 118 + .../test/parser/js/test-async-function-1.js | 17 + .../js/test-async-function-2-expected.txt | 74 + .../test/parser/js/test-async-function-2.js | 17 + .../js/test-binary-expression-expected.txt | 1758 ++++ .../test/parser/js/test-binary-expression.js | 43 + .../js/test-call-expression-expected.txt | 583 ++ .../test/parser/js/test-call-expression.js | 24 + .../js/test-class-async-method-expected.txt | 219 + .../test/parser/js/test-class-async-method.js | 19 + .../js/test-class-definition-expected.txt | 1317 +++ .../test/parser/js/test-class-definition.js | 41 + .../js/test-class-definition1-expected.txt | 1 + .../test/parser/js/test-class-definition1.js | 22 + .../js/test-class-definition2-expected.txt | 1 + .../test/parser/js/test-class-definition2.js | 25 + .../js/test-class-definition3-expected.txt | 1 + .../test/parser/js/test-class-definition3.js | 22 + .../js/test-class-definition4-expected.txt | 1 + .../test/parser/js/test-class-definition4.js | 20 + .../js/test-class-definition5-expected.txt | 1 + .../test/parser/js/test-class-definition5.js | 20 + .../js/test-class-expression-expected.txt | 756 ++ .../test/parser/js/test-class-expression.js | 32 + .../test/parser/js/test-comment-expected.txt | 14 + es2panda/test/parser/js/test-comment.js | 21 + .../test-conditional-expression-expected.txt | 471 + .../parser/js/test-conditional-expression.js | 25 + .../js/test-const-without-init-expected.txt | 1 + .../test/parser/js/test-const-without-init.js | 17 + .../js/test-continue-in-switch-expected.txt | 1 + .../test/parser/js/test-continue-in-switch.js | 26 + .../js/test-debugger-statement-expected.txt | 97 + .../test/parser/js/test-debugger-statement.js | 25 + .../js/test-delete-identifier-expected.txt | 1 + .../test/parser/js/test-delete-identifier.js | 18 + .../parser/js/test-do-while-1-expected.txt | 1 + es2panda/test/parser/js/test-do-while-1.js | 17 + .../test/parser/js/test-do-while-expected.txt | 719 ++ es2panda/test/parser/js/test-do-while.js | 44 + .../js/test-escaped-keyword-expected.txt | 1 + .../test/parser/js/test-escaped-keyword.js | 17 + .../parser/js/test-export-all-expected.txt | 1 + es2panda/test/parser/js/test-export-all.js | 21 + .../js/test-export-named-decl-expected.txt | 1 + .../test/parser/js/test-export-named-decl.js | 29 + ...ession-after-unary-expression-expected.txt | 1 + .../test-expression-after-unary-expression.js | 17 + .../test/parser/js/test-for-1-expected.txt | 1 + es2panda/test/parser/js/test-for-1.js | 17 + .../test/parser/js/test-for-2-expected.txt | 1 + es2panda/test/parser/js/test-for-2.js | 17 + .../test/parser/js/test-for-3-expected.txt | 1 + es2panda/test/parser/js/test-for-3.js | 17 + .../test/parser/js/test-for-4-expected.txt | 1 + es2panda/test/parser/js/test-for-4.js | 17 + es2panda/test/parser/js/test-for-expected.txt | 1818 ++++ es2panda/test/parser/js/test-for.js | 48 + .../parser/js/test-function-decl-expected.txt | 659 ++ es2panda/test/parser/js/test-function-decl.js | 33 + ...st-function-scope-violation-1-expected.txt | 1 + .../js/test-function-scope-violation-1.js | 22 + ...st-function-scope-violation-2-expected.txt | 1 + .../js/test-function-scope-violation-2.js | 21 + .../js/test-grouping-level-expected.txt | 1025 ++ .../test/parser/js/test-grouping-level.js | 27 + .../test/parser/js/test-if-1-expected.txt | 1 + es2panda/test/parser/js/test-if-1.js | 17 + .../test/parser/js/test-if-2-expected.txt | 1 + es2panda/test/parser/js/test-if-2.js | 17 + es2panda/test/parser/js/test-if-expected.txt | 887 ++ es2panda/test/parser/js/test-if.js | 34 + .../parser/js/test-import-decl-expected.txt | 1 + es2panda/test/parser/js/test-import-decl.js | 24 + .../js/test-import-expression-expected.txt | 1 + .../test/parser/js/test-import-expression.js | 22 + .../parser/js/test-import-meta-expected.txt | 1 + es2panda/test/parser/js/test-import-meta.js | 22 + .../js/test-imported-decl1-expected.txt | 1 + .../test/parser/js/test-imported-decl1.js | 22 + .../js/test-labelled-statement-expected.txt | 1276 +++ .../test/parser/js/test-labelled-statement.js | 64 + .../js/test-labelled-statement1-expected.txt | 1 + .../parser/js/test-labelled-statement1.js | 18 + .../js/test-labelled-statement2-expected.txt | 1 + .../parser/js/test-labelled-statement2.js | 21 + .../js/test-let-redeclaration-expected.txt | 1 + .../test/parser/js/test-let-redeclaration.js | 19 + .../js/test-logical-expression-expected.txt | 762 ++ .../test/parser/js/test-logical-expression.js | 24 + .../js/test-member-expression-1-expected.txt | 1 + .../parser/js/test-member-expression-1.js | 17 + .../js/test-member-expression-2-expected.txt | 1 + .../parser/js/test-member-expression-2.js | 17 + .../js/test-member-expression-3-expected.txt | 1 + .../parser/js/test-member-expression-3.js | 17 + .../js/test-member-expression-expected.txt | 776 ++ .../test/parser/js/test-member-expression.js | 24 + .../test-missing-catch-argument-expected.txt | 1 + .../parser/js/test-missing-catch-argument.js | 28 + .../js/test-multi-line-string-expected.txt | 1 + .../test/parser/js/test-multi-line-string.js | 20 + ...st-multiple-update-expression-expected.txt | 1 + .../js/test-multiple-update-expression.js | 17 + .../js/test-new-expression-expected.txt | 443 + .../test/parser/js/test-new-expression.js | 22 + .../js/test-nullish-coalescing-expected.txt | 1131 +++ .../test/parser/js/test-nullish-coalescing.js | 26 + .../js/test-nullish-coalescing1-expected.txt | 1 + .../parser/js/test-nullish-coalescing1.js | 17 + .../js/test-nullish-coalescing2-expected.txt | 1 + .../parser/js/test-nullish-coalescing2.js | 17 + .../js/test-numeric-separator-expected.txt | 177 + .../test/parser/js/test-numeric-separator.js | 22 + .../js/test-numeric-separator1-expected.txt | 1 + .../test/parser/js/test-numeric-separator1.js | 17 + .../js/test-numeric-separator2-expected.txt | 1 + .../test/parser/js/test-numeric-separator2.js | 17 + .../js/test-object-expression-expected.txt | 959 ++ .../test/parser/js/test-object-expression.js | 31 + .../js/test-object-expression1-expected.txt | 1 + .../test/parser/js/test-object-expression1.js | 19 + .../js/test-object-expression2-expected.txt | 1 + .../test/parser/js/test-object-expression2.js | 19 + .../js/test-object-expression3-expected.txt | 1 + .../test/parser/js/test-object-expression3.js | 19 + .../js/test-object-expression4-expected.txt | 1 + .../test/parser/js/test-object-expression4.js | 19 + .../js/test-object-expression5-expected.txt | 1 + .../test/parser/js/test-object-expression5.js | 19 + .../parser/js/test-object-proto-expected.txt | 1 + es2panda/test/parser/js/test-object-proto.js | 26 + ...st-one-default-export-allowed-expected.txt | 1 + .../js/test-one-default-export-allowed.js | 21 + .../js/test-optional-chain-expected.txt | 1 + .../test/parser/js/test-optional-chain.js | 17 + .../test/parser/js/test-patterns-expected.txt | 990 ++ es2panda/test/parser/js/test-patterns.js | 28 + .../js/test-sequence-expression-expected.txt | 421 + .../parser/js/test-sequence-expression.js | 25 + .../js/test-string-literal-expected.txt | 150 + .../test/parser/js/test-string-literal.js | 21 + .../js/test-super-expression-expected.txt | 1 + .../test/parser/js/test-super-expression.js | 17 + .../test/parser/js/test-switch-1-expected.txt | 1 + es2panda/test/parser/js/test-switch-1.js | 17 + .../test/parser/js/test-switch-2-expected.txt | 1 + es2panda/test/parser/js/test-switch-2.js | 19 + .../test/parser/js/test-switch-3-expected.txt | 1 + es2panda/test/parser/js/test-switch-3.js | 19 + .../test/parser/js/test-switch-4-expected.txt | 1 + es2panda/test/parser/js/test-switch-4.js | 19 + .../test/parser/js/test-switch-5-expected.txt | 1 + es2panda/test/parser/js/test-switch-5.js | 20 + .../test/parser/js/test-switch-6-expected.txt | 1 + es2panda/test/parser/js/test-switch-6.js | 19 + .../test/parser/js/test-switch-expected.txt | 267 + es2panda/test/parser/js/test-switch.js | 38 + ...st-tagged-template-expression-expected.txt | 1101 ++ .../js/test-tagged-template-expression.js | 38 + .../js/test-template-literal-1-expected.txt | 1 + .../test/parser/js/test-template-literal-1.js | 17 + .../js/test-template-literal-2-expected.txt | 1 + .../test/parser/js/test-template-literal-2.js | 17 + .../js/test-template-literal-expected.txt | 622 ++ .../test/parser/js/test-template-literal.js | 34 + .../js/test-this-expression-expected.txt | 234 + .../test/parser/js/test-this-expression.js | 20 + .../js/test-throw-statement-expected.txt | 343 + ...-statement-without-expression-expected.txt | 1 + ...test-throw-statement-without-expression.js | 17 + .../test/parser/js/test-throw-statement.js | 28 + ...try-catch-lexical-declaration-expected.txt | 1 + .../js/test-try-catch-lexical-declaration.js | 28 + .../parser/js/test-try-statement-expected.txt | 335 + es2panda/test/parser/js/test-try-statement.js | 32 + ...try-without-catch-and-finally-expected.txt | 1 + .../js/test-try-without-catch-and-finally.js | 17 + .../js/test-unary-expression-expected.txt | 519 + .../test/parser/js/test-unary-expression.js | 25 + .../js/test-update-expression-expected.txt | 363 + .../test/parser/js/test-update-expression.js | 21 + .../parser/js/test-use-strict-1-expected.txt | 1 + es2panda/test/parser/js/test-use-strict-1.js | 19 + .../parser/js/test-use-strict-2-expected.txt | 1 + es2panda/test/parser/js/test-use-strict-2.js | 19 + .../test/parser/js/test-var-decl-expected.txt | 468 + es2panda/test/parser/js/test-var-decl.js | 30 + .../test-wrong-function-decl-1-expected.txt | 1 + .../parser/js/test-wrong-function-decl-1.js | 17 + .../test-wrong-function-decl-2-expected.txt | 1 + .../parser/js/test-wrong-function-decl-2.js | 17 + .../test-wrong-function-decl-3-expected.txt | 1 + .../parser/js/test-wrong-function-decl-3.js | 20 + .../parser/js/this-expression-expected.txt | 1 + es2panda/test/parser/js/this-expression.js | 17 + .../ts/test-arrow-function-expected.txt | 363 + .../test/parser/ts/test-arrow-function.ts | 19 + .../parser/ts/test-as-expression-expected.txt | 1 + es2panda/test/parser/ts/test-as-expression.ts | 17 + .../ts/test-class-constructor-expected.txt | 916 ++ .../test/parser/ts/test-class-constructor.ts | 30 + .../ts/test-class-constructor1-expected.txt | 1 + .../test/parser/ts/test-class-constructor1.ts | 21 + .../ts/test-class-constructor2-expected.txt | 1 + .../test/parser/ts/test-class-constructor2.ts | 22 + .../ts/test-class-constructor3-expected.txt | 1 + .../test/parser/ts/test-class-constructor3.ts | 19 + .../ts/test-class-constructor4-expected.txt | 1 + .../test/parser/ts/test-class-constructor4.ts | 19 + .../ts/test-class-constructor5-expected.txt | 1 + .../test/parser/ts/test-class-constructor5.ts | 20 + .../ts/test-class-definition-expected.txt | 2384 +++++ .../test/parser/ts/test-class-definition.ts | 47 + .../ts/test-class-definiton1-expected.txt | 1 + .../test/parser/ts/test-class-definiton1.ts | 19 + .../ts/test-class-definiton10-expected.txt | 1 + .../test/parser/ts/test-class-definiton10.ts | 19 + .../ts/test-class-definiton11-expected.txt | 1 + .../test/parser/ts/test-class-definiton11.ts | 19 + .../ts/test-class-definiton12-expected.txt | 1 + .../test/parser/ts/test-class-definiton12.ts | 19 + .../ts/test-class-definiton13-expected.txt | 1 + .../test/parser/ts/test-class-definiton13.ts | 19 + .../ts/test-class-definiton14-expected.txt | 1 + .../test/parser/ts/test-class-definiton14.ts | 19 + .../ts/test-class-definiton15-expected.txt | 1 + .../test/parser/ts/test-class-definiton15.ts | 20 + .../ts/test-class-definiton16-expected.txt | 1 + .../test/parser/ts/test-class-definiton16.ts | 20 + .../ts/test-class-definiton17-expected.txt | 1 + .../test/parser/ts/test-class-definiton17.ts | 19 + .../ts/test-class-definiton18-expected.txt | 1 + .../test/parser/ts/test-class-definiton18.ts | 20 + .../ts/test-class-definiton2-expected.txt | 1 + .../test/parser/ts/test-class-definiton2.ts | 19 + .../ts/test-class-definiton3-expected.txt | 1 + .../test/parser/ts/test-class-definiton3.ts | 19 + .../ts/test-class-definiton4-expected.txt | 1 + .../test/parser/ts/test-class-definiton4.ts | 19 + .../ts/test-class-definiton5-expected.txt | 1 + .../test/parser/ts/test-class-definiton5.ts | 19 + .../ts/test-class-definiton6-expected.txt | 1 + .../test/parser/ts/test-class-definiton6.ts | 20 + .../ts/test-class-definiton7-expected.txt | 1 + .../test/parser/ts/test-class-definiton7.ts | 19 + .../ts/test-class-definiton8-expected.txt | 1 + .../test/parser/ts/test-class-definiton8.ts | 19 + .../ts/test-class-definiton9-expected.txt | 1 + .../test/parser/ts/test-class-definiton9.ts | 19 + .../test-class-method-overload-expected.txt | 1938 ++++ .../parser/ts/test-class-method-overload.ts | 45 + .../test-class-method-overload1-expected.txt | 1 + .../parser/ts/test-class-method-overload1.ts | 21 + .../test-class-method-overload10-expected.txt | 1 + .../parser/ts/test-class-method-overload10.ts | 20 + .../test-class-method-overload11-expected.txt | 1 + .../parser/ts/test-class-method-overload11.ts | 20 + .../test-class-method-overload12-expected.txt | 1 + .../parser/ts/test-class-method-overload12.ts | 20 + .../test-class-method-overload13-expected.txt | 1 + .../parser/ts/test-class-method-overload13.ts | 20 + .../test-class-method-overload2-expected.txt | 1 + .../parser/ts/test-class-method-overload2.ts | 22 + .../test-class-method-overload3-expected.txt | 1 + .../parser/ts/test-class-method-overload3.ts | 21 + .../test-class-method-overload4-expected.txt | 1 + .../parser/ts/test-class-method-overload4.ts | 19 + .../test-class-method-overload5-expected.txt | 1 + .../parser/ts/test-class-method-overload5.ts | 20 + .../test-class-method-overload6-expected.txt | 1 + .../parser/ts/test-class-method-overload6.ts | 21 + .../test-class-method-overload7-expected.txt | 1 + .../parser/ts/test-class-method-overload7.ts | 20 + .../test-class-method-overload8-expected.txt | 1 + .../parser/ts/test-class-method-overload8.ts | 20 + .../test-class-method-overload9-expected.txt | 1 + .../parser/ts/test-class-method-overload9.ts | 20 + .../ts/test-enum-declaration-expected.txt | 358 + .../test/parser/ts/test-enum-declaration.ts | 24 + .../ts/test-enum-declaration1-expected.txt | 1 + .../test/parser/ts/test-enum-declaration1.ts | 20 + .../ts/test-enum-declaration2-expected.txt | 1 + .../test/parser/ts/test-enum-declaration2.ts | 20 + .../ts/test-enum-declaration3-expected.txt | 1 + .../test/parser/ts/test-enum-declaration3.ts | 19 + .../ts/test-enum-declaration4-expected.txt | 1 + .../test/parser/ts/test-enum-declaration4.ts | 20 + .../ts/test-enum-declaration5-expected.txt | 1 + .../test/parser/ts/test-enum-declaration5.ts | 21 + .../parser/ts/test-func-decl1-expected.txt | 1 + es2panda/test/parser/ts/test-func-decl1.ts | 19 + .../parser/ts/test-func-param-expected.txt | 2314 +++++ es2panda/test/parser/ts/test-func-param.ts | 33 + .../parser/ts/test-func-param1-expected.txt | 1 + es2panda/test/parser/ts/test-func-param1.ts | 19 + .../parser/ts/test-func-param2-expected.txt | 1 + es2panda/test/parser/ts/test-func-param2.ts | 19 + .../parser/ts/test-func-param3-expected.txt | 1 + es2panda/test/parser/ts/test-func-param3.ts | 19 + .../parser/ts/test-func-param4-expected.txt | 1 + es2panda/test/parser/ts/test-func-param4.ts | 19 + .../parser/ts/test-func-param5-expected.txt | 1 + es2panda/test/parser/ts/test-func-param5.ts | 19 + .../parser/ts/test-func-param6-expected.txt | 1 + es2panda/test/parser/ts/test-func-param6.ts | 17 + .../parser/ts/test-func-param7-expected.txt | 1 + es2panda/test/parser/ts/test-func-param7.ts | 17 + .../parser/ts/test-func-param8-expected.txt | 1 + es2panda/test/parser/ts/test-func-param8.ts | 17 + .../ts/test-function-overload-expected.txt | 464 + .../test/parser/ts/test-function-overload.ts | 23 + .../ts/test-function-overload1-expected.txt | 150 + .../test/parser/ts/test-function-overload1.ts | 19 + .../ts/test-function-overload2-expected.txt | 164 + .../test/parser/ts/test-function-overload2.ts | 19 + es2panda/test/parser/ts/test-if-expected.txt | 159 + es2panda/test/parser/ts/test-if.ts | 22 + .../parser/ts/test-interface-expected.txt | 795 ++ es2panda/test/parser/ts/test-interface.ts | 24 + .../parser/ts/test-interface1-expected.txt | 1 + es2panda/test/parser/ts/test-interface1.ts | 19 + .../parser/ts/test-interface2-expected.txt | 1 + es2panda/test/parser/ts/test-interface2.ts | 17 + .../parser/ts/test-interface3-expected.txt | 1 + es2panda/test/parser/ts/test-interface3.ts | 19 + .../parser/ts/test-intersection-expected.txt | 1824 ++++ es2panda/test/parser/ts/test-intersection.ts | 30 + .../parser/ts/test-intersection1-expected.txt | 1 + es2panda/test/parser/ts/test-intersection1.ts | 17 + .../parser/ts/test-intersection2-expected.txt | 1 + es2panda/test/parser/ts/test-intersection2.ts | 17 + .../parser/ts/test-intersection3-expected.txt | 1 + es2panda/test/parser/ts/test-intersection3.ts | 17 + .../ts/test-keyword-declare-expected.txt | 1257 +++ .../test/parser/ts/test-keyword-declare.ts | 45 + .../ts/test-keyword-declare1-expected.txt | 1 + .../test/parser/ts/test-keyword-declare1.ts | 17 + .../ts/test-keyword-declare10-expected.txt | 1 + .../test/parser/ts/test-keyword-declare10.ts | 19 + .../ts/test-keyword-declare11-expected.txt | 1 + .../test/parser/ts/test-keyword-declare11.ts | 19 + .../ts/test-keyword-declare12-expected.txt | 1 + .../test/parser/ts/test-keyword-declare12.ts | 19 + .../ts/test-keyword-declare13-expected.txt | 1 + .../test/parser/ts/test-keyword-declare13.ts | 19 + .../ts/test-keyword-declare2-expected.txt | 1 + .../test/parser/ts/test-keyword-declare2.ts | 17 + .../ts/test-keyword-declare3-expected.txt | 1 + .../test/parser/ts/test-keyword-declare3.ts | 17 + .../ts/test-keyword-declare4-expected.txt | 1 + .../test/parser/ts/test-keyword-declare4.ts | 17 + .../ts/test-keyword-declare5-expected.txt | 106 + .../test/parser/ts/test-keyword-declare5.ts | 18 + .../ts/test-keyword-declare6-expected.txt | 146 + .../test/parser/ts/test-keyword-declare6.ts | 18 + .../ts/test-keyword-declare7-expected.txt | 191 + .../test/parser/ts/test-keyword-declare7.ts | 19 + .../ts/test-keyword-declare8-expected.txt | 1 + .../test/parser/ts/test-keyword-declare8.ts | 19 + .../ts/test-keyword-declare9-expected.txt | 1 + .../test/parser/ts/test-keyword-declare9.ts | 19 + .../ts/test-member-expression1-expected.txt | 1 + .../test/parser/ts/test-member-expression1.ts | 18 + .../ts/test-member-expression2-expected.txt | 1 + .../test/parser/ts/test-member-expression2.ts | 18 + .../ts/test-ts-as-expression-expected.txt | 418 + .../test/parser/ts/test-ts-as-expression.ts | 19 + .../ts/test-ts-conditional-type-expected.txt | 1762 ++++ .../parser/ts/test-ts-conditional-type.ts | 31 + .../ts/test-ts-conditional-type1-expected.txt | 1 + .../parser/ts/test-ts-conditional-type1.ts | 17 + .../ts/test-ts-conditional-type2-expected.txt | 1 + .../parser/ts/test-ts-conditional-type2.ts | 17 + .../ts/test-ts-conditional-type3-expected.txt | 1 + .../parser/ts/test-ts-conditional-type3.ts | 17 + .../ts/test-ts-conditional-type4-expected.txt | 1 + .../parser/ts/test-ts-conditional-type4.ts | 17 + .../ts/test-ts-conditional-type5-expected.txt | 1 + .../parser/ts/test-ts-conditional-type5.ts | 17 + .../ts/test-ts-conditional-type6-expected.txt | 1 + .../parser/ts/test-ts-conditional-type6.ts | 17 + .../ts/test-ts-conditional-type7-expected.txt | 1 + .../parser/ts/test-ts-conditional-type7.ts | 17 + .../ts/test-ts-constructor-type1-expected.txt | 1 + .../parser/ts/test-ts-constructor-type1.ts | 17 + .../ts/test-ts-constructor-type2-expected.txt | 1 + .../parser/ts/test-ts-constructor-type2.ts | 17 + .../ts/test-ts-constructor-type3-expected.txt | 1 + .../parser/ts/test-ts-constructor-type3.ts | 17 + .../ts/test-ts-constructor-type4-expected.txt | 1 + .../parser/ts/test-ts-constructor-type4.ts | 17 + .../ts/test-ts-mapped-type-expected.txt | 1255 +++ .../test/parser/ts/test-ts-mapped-type.ts | 23 + .../ts/test-ts-mapped-type1-expected.txt | 1 + .../test/parser/ts/test-ts-mapped-type1.ts | 17 + .../ts/test-ts-mapped-type2-expected.txt | 1 + .../test/parser/ts/test-ts-mapped-type2.ts | 17 + .../ts/test-ts-mapped-type3-expected.txt | 1 + .../test/parser/ts/test-ts-mapped-type3.ts | 17 + .../ts/test-ts-mapped-type4-expected.txt | 1 + .../test/parser/ts/test-ts-mapped-type4.ts | 17 + .../ts/test-ts-mapped-type5-expected.txt | 1 + .../test/parser/ts/test-ts-mapped-type5.ts | 17 + .../ts/test-ts-mapped-type6-expected.txt | 1 + .../test/parser/ts/test-ts-mapped-type6.ts | 17 + .../ts/test-ts-mapped-type7-expected.txt | 1 + .../test/parser/ts/test-ts-mapped-type7.ts | 17 + .../test-ts-non-null-expression-expected.txt | 409 + .../parser/ts/test-ts-non-null-expression.ts | 22 + .../test-ts-parameter-property-expected.txt | 1319 +++ .../parser/ts/test-ts-parameter-property.ts | 46 + .../test-ts-parameter-property1-expected.txt | 1 + .../parser/ts/test-ts-parameter-property1.ts | 17 + .../test-ts-parameter-property10-expected.txt | 1 + .../parser/ts/test-ts-parameter-property10.ts | 19 + .../test-ts-parameter-property11-expected.txt | 1 + .../parser/ts/test-ts-parameter-property11.ts | 19 + .../test-ts-parameter-property12-expected.txt | 1 + .../parser/ts/test-ts-parameter-property12.ts | 19 + .../test-ts-parameter-property2-expected.txt | 1 + .../parser/ts/test-ts-parameter-property2.ts | 20 + .../test-ts-parameter-property3-expected.txt | 1 + .../parser/ts/test-ts-parameter-property3.ts | 19 + .../test-ts-parameter-property4-expected.txt | 1 + .../parser/ts/test-ts-parameter-property4.ts | 19 + .../test-ts-parameter-property5-expected.txt | 1 + .../parser/ts/test-ts-parameter-property5.ts | 19 + .../test-ts-parameter-property6-expected.txt | 1 + .../parser/ts/test-ts-parameter-property6.ts | 19 + .../test-ts-parameter-property7-expected.txt | 1 + .../parser/ts/test-ts-parameter-property7.ts | 19 + .../test-ts-parameter-property8-expected.txt | 1 + .../parser/ts/test-ts-parameter-property8.ts | 19 + .../test-ts-parameter-property9-expected.txt | 1 + .../parser/ts/test-ts-parameter-property9.ts | 19 + .../ts/test-ts-type-assertion-expected.txt | 301 + .../test/parser/ts/test-ts-type-assertion.ts | 20 + .../ts/test-ts-type-predicate-expected.txt | 5943 +++++++++++ .../test/parser/ts/test-ts-type-predicate.ts | 83 + .../ts/test-ts-type-predicate1-expected.txt | 205 + .../test/parser/ts/test-ts-type-predicate1.ts | 17 + .../ts/test-ts-type-predicate2-expected.txt | 1 + .../test/parser/ts/test-ts-type-predicate2.ts | 17 + .../ts/test-ts-type-predicate3-expected.txt | 1 + .../test/parser/ts/test-ts-type-predicate3.ts | 17 + .../ts/test-ts-type-predicate4-expected.txt | 1 + .../test/parser/ts/test-ts-type-predicate4.ts | 17 + .../ts/test-ts-type-predicate5-expected.txt | 1 + .../test/parser/ts/test-ts-type-predicate5.ts | 17 + .../ts/test-ts-type-predicate6-expected.txt | 1 + .../test/parser/ts/test-ts-type-predicate6.ts | 17 + .../ts/test-ts-type-predicate7-expected.txt | 1 + .../test/parser/ts/test-ts-type-predicate7.ts | 17 + .../ts/test-ts-type-predicate8-expected.txt | 1 + .../test/parser/ts/test-ts-type-predicate8.ts | 17 + .../parser/ts/test-tuple-type-expected.txt | 919 ++ es2panda/test/parser/ts/test-tuple-type.ts | 21 + .../parser/ts/test-tuple-type1-expected.txt | 1 + es2panda/test/parser/ts/test-tuple-type1.ts | 17 + .../parser/ts/test-tuple-type2-expected.txt | 1 + es2panda/test/parser/ts/test-tuple-type2.ts | 17 + .../parser/ts/test-tuple-type3-expected.txt | 1 + es2panda/test/parser/ts/test-tuple-type3.ts | 17 + .../parser/ts/test-tuple-type4-expected.txt | 1 + es2panda/test/parser/ts/test-tuple-type4.ts | 17 + .../parser/ts/test-type-alias-expected.txt | 502 + es2panda/test/parser/ts/test-type-alias.ts | 20 + .../parser/ts/test-type-alias1-expected.txt | 1 + es2panda/test/parser/ts/test-type-alias1.ts | 17 + .../parser/ts/test-type-alias2-expected.txt | 1 + es2panda/test/parser/ts/test-type-alias2.ts | 17 + .../parser/ts/test-type-alias3-expected.txt | 1 + es2panda/test/parser/ts/test-type-alias3.ts | 17 + .../ts/test-type-annotation-expected.txt | 4090 ++++++++ .../test/parser/ts/test-type-annotation.ts | 55 + .../parser/ts/test-type-literal-expected.txt | 1010 ++ es2panda/test/parser/ts/test-type-literal.ts | 20 + .../parser/ts/test-type-literal1-expected.txt | 1 + es2panda/test/parser/ts/test-type-literal1.ts | 17 + .../parser/ts/test-type-literal2-expected.txt | 1 + es2panda/test/parser/ts/test-type-literal2.ts | 17 + .../parser/ts/test-type-literal3-expected.txt | 1 + es2panda/test/parser/ts/test-type-literal3.ts | 17 + .../parser/ts/test-type-query-expected.txt | 599 ++ es2panda/test/parser/ts/test-type-query.ts | 21 + .../parser/ts/test-type-query1-expected.txt | 1 + es2panda/test/parser/ts/test-type-query1.ts | 17 + .../parser/ts/test-type-query2-expected.txt | 1 + es2panda/test/parser/ts/test-type-query2.ts | 17 + .../parser/ts/test_decorator-expected.txt | 1023 ++ es2panda/test/parser/ts/test_decorator.ts | 30 + .../parser/ts/test_decorator1-expected.txt | 1 + es2panda/test/parser/ts/test_decorator1.ts | 17 + .../parser/ts/test_decorator2-expected.txt | 1 + es2panda/test/parser/ts/test_decorator2.ts | 20 + .../parser/ts/test_decorator3-expected.txt | 1 + es2panda/test/parser/ts/test_decorator3.ts | 21 + .../parser/ts/test_decorator4-expected.txt | 1 + es2panda/test/parser/ts/test_decorator4.ts | 19 + .../parser/ts/test_decorator5-expected.txt | 1 + es2panda/test/parser/ts/test_decorator5.ts | 19 + .../parser/ts/test_decorator6-expected.txt | 1 + es2panda/test/parser/ts/test_decorator6.ts | 19 + .../parser/ts/test_decorator7-expected.txt | 1 + es2panda/test/parser/ts/test_decorator7.ts | 19 + .../parser/ts/test_decorator8-expected.txt | 1 + es2panda/test/parser/ts/test_decorator8.ts | 19 + .../test/parser/ts/test_generic-expected.txt | 7045 +++++++++++++ es2panda/test/parser/ts/test_generic.ts | 74 + .../parser/ts/test_import_type-expected.txt | 839 ++ es2panda/test/parser/ts/test_import_type.ts | 26 + .../test/parser/ts/test_module-expected.txt | 1886 ++++ es2panda/test/parser/ts/test_module.ts | 81 + .../test/parser/ts/test_module1-expected.txt | 1 + es2panda/test/parser/ts/test_module1.ts | 19 + .../test/parser/ts/test_module2-expected.txt | 1 + es2panda/test/parser/ts/test_module2.ts | 19 + .../test/parser/ts/test_module3-expected.txt | 1 + es2panda/test/parser/ts/test_module3.ts | 19 + .../test/parser/ts/test_module4-expected.txt | 1 + es2panda/test/parser/ts/test_module4.ts | 19 + .../test/parser/ts/test_module5-expected.txt | 1 + es2panda/test/parser/ts/test_module5.ts | 19 + .../test/parser/ts/test_module6-expected.txt | 1 + es2panda/test/parser/ts/test_module6.ts | 19 + .../parser/ts/test_this_type-expected.txt | 431 + es2panda/test/parser/ts/test_this_type.ts | 23 + .../parser/ts/test_this_type1-expected.txt | 1 + es2panda/test/parser/ts/test_this_type1.ts | 17 + .../parser/ts/test_this_type2-expected.txt | 1 + es2panda/test/parser/ts/test_this_type2.ts | 19 + es2panda/test/runner.py | 746 ++ es2panda/test/test262harness.js | 59 + es2panda/test/test262skiplist-bco.txt | 0 .../test/test262skiplist-compiler-arm64.txt | 388 + es2panda/test/test262skiplist-flaky.txt | 10 + es2panda/test/test262skiplist-long.txt | 93 + es2panda/test/test262skiplist.txt | 8981 +++++++++++++++++ es2panda/test/test262util.py | 186 + es2panda/typescript/checker.cpp | 258 + es2panda/typescript/checker.h | 519 + .../typescript/core/binaryLikeExpression.cpp | 232 + es2panda/typescript/core/destructuring.cpp | 917 ++ es2panda/typescript/core/function.cpp | 441 + es2panda/typescript/core/generics.cpp | 293 + es2panda/typescript/core/helpers.cpp | 311 + es2panda/typescript/core/object.cpp | 761 ++ es2panda/typescript/core/typeCreation.cpp | 122 + es2panda/typescript/core/typeElaboration.cpp | 704 ++ es2panda/typescript/core/typeRelation.cpp | 122 + es2panda/typescript/core/util.cpp | 227 + es2panda/typescript/types/anyType.cpp | 56 + es2panda/typescript/types/anyType.h | 37 + es2panda/typescript/types/arrayType.cpp | 81 + es2panda/typescript/types/arrayType.h | 42 + .../typescript/types/bigintLiteralType.cpp | 71 + es2panda/typescript/types/bigintLiteralType.h | 43 + es2panda/typescript/types/bigintType.cpp | 52 + es2panda/typescript/types/bigintType.h | 36 + .../typescript/types/booleanLiteralType.cpp | 66 + .../typescript/types/booleanLiteralType.h | 41 + es2panda/typescript/types/booleanType.cpp | 52 + es2panda/typescript/types/booleanType.h | 36 + es2panda/typescript/types/constructorType.cpp | 54 + es2panda/typescript/types/constructorType.h | 34 + es2panda/typescript/types/elementFlags.h | 39 + es2panda/typescript/types/enumLiteralType.cpp | 79 + es2panda/typescript/types/enumLiteralType.h | 51 + es2panda/typescript/types/enumType.cpp | 67 + es2panda/typescript/types/enumType.h | 47 + es2panda/typescript/types/functionType.cpp | 64 + es2panda/typescript/types/functionType.h | 35 + .../typescript/types/globalTypesHolder.cpp | 173 + es2panda/typescript/types/globalTypesHolder.h | 83 + es2panda/typescript/types/indexInfo.cpp | 84 + es2panda/typescript/types/indexInfo.h | 49 + es2panda/typescript/types/interfaceType.cpp | 306 + es2panda/typescript/types/interfaceType.h | 55 + es2panda/typescript/types/neverType.cpp | 56 + es2panda/typescript/types/neverType.h | 37 + .../typescript/types/nonPrimitiveType.cpp | 52 + es2panda/typescript/types/nonPrimitiveType.h | 36 + es2panda/typescript/types/nullType.cpp | 53 + es2panda/typescript/types/nullType.h | 37 + .../typescript/types/numberLiteralType.cpp | 72 + es2panda/typescript/types/numberLiteralType.h | 41 + es2panda/typescript/types/numberType.cpp | 62 + es2panda/typescript/types/numberType.h | 36 + .../typescript/types/objectDescriptor.cpp | 80 + es2panda/typescript/types/objectDescriptor.h | 55 + .../typescript/types/objectLiteralType.cpp | 90 + es2panda/typescript/types/objectLiteralType.h | 35 + es2panda/typescript/types/objectType.cpp | 368 + es2panda/typescript/types/objectType.h | 123 + es2panda/typescript/types/signature.cpp | 199 + es2panda/typescript/types/signature.h | 68 + .../typescript/types/stringLiteralType.cpp | 61 + es2panda/typescript/types/stringLiteralType.h | 41 + es2panda/typescript/types/stringType.cpp | 52 + es2panda/typescript/types/stringType.h | 36 + es2panda/typescript/types/tupleType.cpp | 282 + es2panda/typescript/types/tupleType.h | 86 + es2panda/typescript/types/type.cpp | 93 + es2panda/typescript/types/type.h | 98 + es2panda/typescript/types/typeFacts.h | 121 + es2panda/typescript/types/typeFlag.h | 89 + es2panda/typescript/types/typeMapping.h | 51 + es2panda/typescript/types/typeParameter.cpp | 73 + es2panda/typescript/types/typeParameter.h | 45 + es2panda/typescript/types/typeReference.cpp | 72 + es2panda/typescript/types/typeReference.h | 42 + es2panda/typescript/types/typeRelation.cpp | 163 + es2panda/typescript/types/typeRelation.h | 112 + es2panda/typescript/types/types.h | 49 + es2panda/typescript/types/undefinedType.cpp | 55 + es2panda/typescript/types/undefinedType.h | 37 + es2panda/typescript/types/unionType.cpp | 251 + es2panda/typescript/types/unionType.h | 58 + es2panda/typescript/types/unknownType.cpp | 51 + es2panda/typescript/types/unknownType.h | 36 + es2panda/typescript/types/voidType.cpp | 47 + es2panda/typescript/types/voidType.h | 36 + es2panda/util/bitset.cpp | 74 + es2panda/util/bitset.h | 49 + es2panda/util/enumbitops.h | 76 + es2panda/util/helpers.cpp | 398 + es2panda/util/helpers.h | 87 + es2panda/util/ustring.cpp | 94 + es2panda/util/ustring.h | 476 + 2270 files changed, 403063 insertions(+) create mode 100644 es2panda/CMakeLists.txt create mode 100644 es2panda/README.md create mode 100644 es2panda/aot/CMakeLists.txt create mode 100644 es2panda/aot/main.cpp create mode 100644 es2panda/aot/options.cpp create mode 100644 es2panda/aot/options.h create mode 100644 es2panda/binder/binder.cpp create mode 100644 es2panda/binder/binder.h create mode 100644 es2panda/binder/declaration.cpp create mode 100644 es2panda/binder/declaration.h create mode 100644 es2panda/binder/enumMemberResult.h create mode 100644 es2panda/binder/scope.cpp create mode 100644 es2panda/binder/scope.h create mode 100644 es2panda/binder/tsBinding.h create mode 100644 es2panda/binder/variable.cpp create mode 100644 es2panda/binder/variable.h create mode 100644 es2panda/binder/variableFlags.h create mode 100644 es2panda/compiler/base/catchTable.cpp create mode 100644 es2panda/compiler/base/catchTable.h create mode 100644 es2panda/compiler/base/condition.cpp create mode 100644 es2panda/compiler/base/condition.h create mode 100644 es2panda/compiler/base/destructuring.cpp create mode 100644 es2panda/compiler/base/destructuring.h create mode 100644 es2panda/compiler/base/hoisting.cpp create mode 100644 es2panda/compiler/base/hoisting.h create mode 100644 es2panda/compiler/base/iterators.cpp create mode 100644 es2panda/compiler/base/iterators.h create mode 100644 es2panda/compiler/base/lexenv.cpp create mode 100644 es2panda/compiler/base/lexenv.h create mode 100644 es2panda/compiler/base/literals.cpp create mode 100644 es2panda/compiler/base/literals.h create mode 100644 es2panda/compiler/base/lreference.cpp create mode 100644 es2panda/compiler/base/lreference.h create mode 100644 es2panda/compiler/core/compileQueue.cpp create mode 100644 es2panda/compiler/core/compileQueue.h create mode 100644 es2panda/compiler/core/compilerContext.cpp create mode 100644 es2panda/compiler/core/compilerContext.h create mode 100644 es2panda/compiler/core/compilerImpl.cpp create mode 100644 es2panda/compiler/core/compilerImpl.h create mode 100644 es2panda/compiler/core/dynamicContext.cpp create mode 100644 es2panda/compiler/core/dynamicContext.h create mode 100644 es2panda/compiler/core/emitter.cpp create mode 100644 es2panda/compiler/core/emitter.h create mode 100644 es2panda/compiler/core/envScope.cpp create mode 100644 es2panda/compiler/core/envScope.h create mode 100644 es2panda/compiler/core/function.cpp create mode 100644 es2panda/compiler/core/function.h create mode 100644 es2panda/compiler/core/inlineCache.cpp create mode 100644 es2panda/compiler/core/inlineCache.h create mode 100644 es2panda/compiler/core/labelPair.h create mode 100644 es2panda/compiler/core/labelTarget.cpp create mode 100644 es2panda/compiler/core/labelTarget.h create mode 100644 es2panda/compiler/core/moduleContext.cpp create mode 100644 es2panda/compiler/core/moduleContext.h create mode 100644 es2panda/compiler/core/pandagen.cpp create mode 100644 es2panda/compiler/core/pandagen.h create mode 100644 es2panda/compiler/core/regAllocator.cpp create mode 100644 es2panda/compiler/core/regAllocator.h create mode 100644 es2panda/compiler/core/regScope.cpp create mode 100644 es2panda/compiler/core/regScope.h create mode 100644 es2panda/compiler/core/switchBuilder.cpp create mode 100644 es2panda/compiler/core/switchBuilder.h create mode 100644 es2panda/compiler/debugger/debuginfoDumper.cpp create mode 100644 es2panda/compiler/debugger/debuginfoDumper.h create mode 100644 es2panda/compiler/function/asyncFunctionBuilder.cpp create mode 100644 es2panda/compiler/function/asyncFunctionBuilder.h create mode 100644 es2panda/compiler/function/asyncGeneratorFunctionBuilder.cpp create mode 100644 es2panda/compiler/function/asyncGeneratorFunctionBuilder.h create mode 100644 es2panda/compiler/function/functionBuilder.cpp create mode 100644 es2panda/compiler/function/functionBuilder.h create mode 100644 es2panda/compiler/function/generatorFunctionBuilder.cpp create mode 100644 es2panda/compiler/function/generatorFunctionBuilder.h create mode 100644 es2panda/compiler/templates/formats.h.erb create mode 100644 es2panda/compiler/templates/isa.h.erb create mode 100644 es2panda/es2panda.cpp create mode 100644 es2panda/es2panda.h create mode 100644 es2panda/ir/astDump.cpp create mode 100644 es2panda/ir/astDump.h create mode 100644 es2panda/ir/astNode.h create mode 100644 es2panda/ir/astNodeMapping.h create mode 100644 es2panda/ir/base/catchClause.cpp create mode 100644 es2panda/ir/base/catchClause.h create mode 100644 es2panda/ir/base/classDefinition.cpp create mode 100644 es2panda/ir/base/classDefinition.h create mode 100644 es2panda/ir/base/classProperty.cpp create mode 100644 es2panda/ir/base/classProperty.h create mode 100644 es2panda/ir/base/decorator.cpp create mode 100644 es2panda/ir/base/decorator.h create mode 100644 es2panda/ir/base/metaProperty.cpp create mode 100644 es2panda/ir/base/metaProperty.h create mode 100644 es2panda/ir/base/methodDefinition.cpp create mode 100644 es2panda/ir/base/methodDefinition.h create mode 100644 es2panda/ir/base/property.cpp create mode 100644 es2panda/ir/base/property.h create mode 100644 es2panda/ir/base/scriptFunction.cpp create mode 100644 es2panda/ir/base/scriptFunction.h create mode 100644 es2panda/ir/base/spreadElement.cpp create mode 100644 es2panda/ir/base/spreadElement.h create mode 100644 es2panda/ir/base/templateElement.cpp create mode 100644 es2panda/ir/base/templateElement.h create mode 100644 es2panda/ir/expression.cpp create mode 100644 es2panda/ir/expression.h create mode 100644 es2panda/ir/expressions/arrayExpression.cpp create mode 100644 es2panda/ir/expressions/arrayExpression.h create mode 100644 es2panda/ir/expressions/arrowFunctionExpression.cpp create mode 100644 es2panda/ir/expressions/arrowFunctionExpression.h create mode 100644 es2panda/ir/expressions/assignmentExpression.cpp create mode 100644 es2panda/ir/expressions/assignmentExpression.h create mode 100644 es2panda/ir/expressions/awaitExpression.cpp create mode 100644 es2panda/ir/expressions/awaitExpression.h create mode 100644 es2panda/ir/expressions/binaryExpression.cpp create mode 100644 es2panda/ir/expressions/binaryExpression.h create mode 100644 es2panda/ir/expressions/callExpression.cpp create mode 100644 es2panda/ir/expressions/callExpression.h create mode 100644 es2panda/ir/expressions/chainExpression.cpp create mode 100644 es2panda/ir/expressions/chainExpression.h create mode 100644 es2panda/ir/expressions/classExpression.cpp create mode 100644 es2panda/ir/expressions/classExpression.h create mode 100644 es2panda/ir/expressions/conditionalExpression.cpp create mode 100644 es2panda/ir/expressions/conditionalExpression.h create mode 100644 es2panda/ir/expressions/functionExpression.cpp create mode 100644 es2panda/ir/expressions/functionExpression.h create mode 100644 es2panda/ir/expressions/identifier.cpp create mode 100644 es2panda/ir/expressions/identifier.h create mode 100644 es2panda/ir/expressions/importExpression.cpp create mode 100644 es2panda/ir/expressions/importExpression.h create mode 100644 es2panda/ir/expressions/literal.cpp create mode 100644 es2panda/ir/expressions/literal.h create mode 100644 es2panda/ir/expressions/literals/bigIntLiteral.cpp create mode 100644 es2panda/ir/expressions/literals/bigIntLiteral.h create mode 100644 es2panda/ir/expressions/literals/booleanLiteral.cpp create mode 100644 es2panda/ir/expressions/literals/booleanLiteral.h create mode 100644 es2panda/ir/expressions/literals/nullLiteral.cpp create mode 100644 es2panda/ir/expressions/literals/nullLiteral.h create mode 100644 es2panda/ir/expressions/literals/numberLiteral.cpp create mode 100644 es2panda/ir/expressions/literals/numberLiteral.h create mode 100644 es2panda/ir/expressions/literals/regExpLiteral.cpp create mode 100644 es2panda/ir/expressions/literals/regExpLiteral.h create mode 100644 es2panda/ir/expressions/literals/stringLiteral.cpp create mode 100644 es2panda/ir/expressions/literals/stringLiteral.h create mode 100644 es2panda/ir/expressions/literals/taggedLiteral.cpp create mode 100644 es2panda/ir/expressions/literals/taggedLiteral.h create mode 100644 es2panda/ir/expressions/memberExpression.cpp create mode 100644 es2panda/ir/expressions/memberExpression.h create mode 100644 es2panda/ir/expressions/newExpression.cpp create mode 100644 es2panda/ir/expressions/newExpression.h create mode 100644 es2panda/ir/expressions/objectExpression.cpp create mode 100644 es2panda/ir/expressions/objectExpression.h create mode 100644 es2panda/ir/expressions/omittedExpression.cpp create mode 100644 es2panda/ir/expressions/omittedExpression.h create mode 100644 es2panda/ir/expressions/sequenceExpression.cpp create mode 100644 es2panda/ir/expressions/sequenceExpression.h create mode 100644 es2panda/ir/expressions/superExpression.cpp create mode 100644 es2panda/ir/expressions/superExpression.h create mode 100644 es2panda/ir/expressions/taggedTemplateExpression.cpp create mode 100644 es2panda/ir/expressions/taggedTemplateExpression.h create mode 100644 es2panda/ir/expressions/templateLiteral.cpp create mode 100644 es2panda/ir/expressions/templateLiteral.h create mode 100644 es2panda/ir/expressions/thisExpression.cpp create mode 100644 es2panda/ir/expressions/thisExpression.h create mode 100644 es2panda/ir/expressions/unaryExpression.cpp create mode 100644 es2panda/ir/expressions/unaryExpression.h create mode 100644 es2panda/ir/expressions/updateExpression.cpp create mode 100644 es2panda/ir/expressions/updateExpression.h create mode 100644 es2panda/ir/expressions/yieldExpression.cpp create mode 100644 es2panda/ir/expressions/yieldExpression.h create mode 100644 es2panda/ir/irnode.h create mode 100644 es2panda/ir/module/exportAllDeclaration.cpp create mode 100644 es2panda/ir/module/exportAllDeclaration.h create mode 100644 es2panda/ir/module/exportDefaultDeclaration.cpp create mode 100644 es2panda/ir/module/exportDefaultDeclaration.h create mode 100644 es2panda/ir/module/exportNamedDeclaration.cpp create mode 100644 es2panda/ir/module/exportNamedDeclaration.h create mode 100644 es2panda/ir/module/exportSpecifier.cpp create mode 100644 es2panda/ir/module/exportSpecifier.h create mode 100644 es2panda/ir/module/importDeclaration.cpp create mode 100644 es2panda/ir/module/importDeclaration.h create mode 100644 es2panda/ir/module/importDefaultSpecifier.cpp create mode 100644 es2panda/ir/module/importDefaultSpecifier.h create mode 100644 es2panda/ir/module/importNamespaceSpecifier.cpp create mode 100644 es2panda/ir/module/importNamespaceSpecifier.h create mode 100644 es2panda/ir/module/importSpecifier.cpp create mode 100644 es2panda/ir/module/importSpecifier.h create mode 100644 es2panda/ir/opcodeMap.h create mode 100644 es2panda/ir/statement.cpp create mode 100644 es2panda/ir/statement.h create mode 100644 es2panda/ir/statements/blockStatement.cpp create mode 100644 es2panda/ir/statements/blockStatement.h create mode 100644 es2panda/ir/statements/breakStatement.cpp create mode 100644 es2panda/ir/statements/breakStatement.h create mode 100644 es2panda/ir/statements/classDeclaration.cpp create mode 100644 es2panda/ir/statements/classDeclaration.h create mode 100644 es2panda/ir/statements/continueStatement.cpp create mode 100644 es2panda/ir/statements/continueStatement.h create mode 100644 es2panda/ir/statements/debuggerStatement.cpp create mode 100644 es2panda/ir/statements/debuggerStatement.h create mode 100644 es2panda/ir/statements/doWhileStatement.cpp create mode 100644 es2panda/ir/statements/doWhileStatement.h create mode 100644 es2panda/ir/statements/emptyStatement.cpp create mode 100644 es2panda/ir/statements/emptyStatement.h create mode 100644 es2panda/ir/statements/expressionStatement.cpp create mode 100644 es2panda/ir/statements/expressionStatement.h create mode 100644 es2panda/ir/statements/forInStatement.cpp create mode 100644 es2panda/ir/statements/forInStatement.h create mode 100644 es2panda/ir/statements/forOfStatement.cpp create mode 100644 es2panda/ir/statements/forOfStatement.h create mode 100644 es2panda/ir/statements/forUpdateStatement.cpp create mode 100644 es2panda/ir/statements/forUpdateStatement.h create mode 100644 es2panda/ir/statements/functionDeclaration.cpp create mode 100644 es2panda/ir/statements/functionDeclaration.h create mode 100644 es2panda/ir/statements/ifStatement.cpp create mode 100644 es2panda/ir/statements/ifStatement.h create mode 100644 es2panda/ir/statements/labelledStatement.cpp create mode 100644 es2panda/ir/statements/labelledStatement.h create mode 100644 es2panda/ir/statements/loopStatement.cpp create mode 100644 es2panda/ir/statements/loopStatement.h create mode 100644 es2panda/ir/statements/returnStatement.cpp create mode 100644 es2panda/ir/statements/returnStatement.h create mode 100644 es2panda/ir/statements/switchCaseStatement.cpp create mode 100644 es2panda/ir/statements/switchCaseStatement.h create mode 100644 es2panda/ir/statements/switchStatement.cpp create mode 100644 es2panda/ir/statements/switchStatement.h create mode 100644 es2panda/ir/statements/throwStatement.cpp create mode 100644 es2panda/ir/statements/throwStatement.h create mode 100644 es2panda/ir/statements/tryStatement.cpp create mode 100644 es2panda/ir/statements/tryStatement.h create mode 100644 es2panda/ir/statements/variableDeclaration.cpp create mode 100644 es2panda/ir/statements/variableDeclaration.h create mode 100644 es2panda/ir/statements/variableDeclarator.cpp create mode 100644 es2panda/ir/statements/variableDeclarator.h create mode 100644 es2panda/ir/statements/whileStatement.cpp create mode 100644 es2panda/ir/statements/whileStatement.h create mode 100644 es2panda/ir/ts/tsAnyKeyword.cpp create mode 100644 es2panda/ir/ts/tsAnyKeyword.h create mode 100644 es2panda/ir/ts/tsArrayType.cpp create mode 100644 es2panda/ir/ts/tsArrayType.h create mode 100644 es2panda/ir/ts/tsAsExpression.cpp create mode 100644 es2panda/ir/ts/tsAsExpression.h create mode 100644 es2panda/ir/ts/tsBigintKeyword.cpp create mode 100644 es2panda/ir/ts/tsBigintKeyword.h create mode 100644 es2panda/ir/ts/tsBooleanKeyword.cpp create mode 100644 es2panda/ir/ts/tsBooleanKeyword.h create mode 100644 es2panda/ir/ts/tsClassImplements.cpp create mode 100644 es2panda/ir/ts/tsClassImplements.h create mode 100644 es2panda/ir/ts/tsConditionalType.cpp create mode 100644 es2panda/ir/ts/tsConditionalType.h create mode 100644 es2panda/ir/ts/tsConstructorType.cpp create mode 100644 es2panda/ir/ts/tsConstructorType.h create mode 100644 es2panda/ir/ts/tsEnumDeclaration.cpp create mode 100644 es2panda/ir/ts/tsEnumDeclaration.h create mode 100644 es2panda/ir/ts/tsEnumMember.cpp create mode 100644 es2panda/ir/ts/tsEnumMember.h create mode 100644 es2panda/ir/ts/tsExternalModuleReference.cpp create mode 100644 es2panda/ir/ts/tsExternalModuleReference.h create mode 100644 es2panda/ir/ts/tsFunctionType.cpp create mode 100644 es2panda/ir/ts/tsFunctionType.h create mode 100644 es2panda/ir/ts/tsImportEqualsDeclaration.cpp create mode 100644 es2panda/ir/ts/tsImportEqualsDeclaration.h create mode 100644 es2panda/ir/ts/tsImportType.cpp create mode 100644 es2panda/ir/ts/tsImportType.h create mode 100644 es2panda/ir/ts/tsIndexSignature.cpp create mode 100644 es2panda/ir/ts/tsIndexSignature.h create mode 100644 es2panda/ir/ts/tsIndexedAccessType.cpp create mode 100644 es2panda/ir/ts/tsIndexedAccessType.h create mode 100644 es2panda/ir/ts/tsInferType.cpp create mode 100644 es2panda/ir/ts/tsInferType.h create mode 100644 es2panda/ir/ts/tsInterfaceBody.cpp create mode 100644 es2panda/ir/ts/tsInterfaceBody.h create mode 100644 es2panda/ir/ts/tsInterfaceDeclaration.cpp create mode 100644 es2panda/ir/ts/tsInterfaceDeclaration.h create mode 100644 es2panda/ir/ts/tsInterfaceHeritage.cpp create mode 100644 es2panda/ir/ts/tsInterfaceHeritage.h create mode 100644 es2panda/ir/ts/tsIntersectionType.cpp create mode 100644 es2panda/ir/ts/tsIntersectionType.h create mode 100644 es2panda/ir/ts/tsLiteralType.cpp create mode 100644 es2panda/ir/ts/tsLiteralType.h create mode 100644 es2panda/ir/ts/tsMappedType.cpp create mode 100644 es2panda/ir/ts/tsMappedType.h create mode 100644 es2panda/ir/ts/tsMethodSignature.cpp create mode 100644 es2panda/ir/ts/tsMethodSignature.h create mode 100644 es2panda/ir/ts/tsModuleBlock.cpp create mode 100644 es2panda/ir/ts/tsModuleBlock.h create mode 100644 es2panda/ir/ts/tsModuleDeclaration.cpp create mode 100644 es2panda/ir/ts/tsModuleDeclaration.h create mode 100644 es2panda/ir/ts/tsNamedTupleMember.cpp create mode 100644 es2panda/ir/ts/tsNamedTupleMember.h create mode 100644 es2panda/ir/ts/tsNeverKeyword.cpp create mode 100644 es2panda/ir/ts/tsNeverKeyword.h create mode 100644 es2panda/ir/ts/tsNonNullExpression.cpp create mode 100644 es2panda/ir/ts/tsNonNullExpression.h create mode 100644 es2panda/ir/ts/tsNullKeyword.cpp create mode 100644 es2panda/ir/ts/tsNullKeyword.h create mode 100644 es2panda/ir/ts/tsNumberKeyword.cpp create mode 100644 es2panda/ir/ts/tsNumberKeyword.h create mode 100644 es2panda/ir/ts/tsObjectKeyword.cpp create mode 100644 es2panda/ir/ts/tsObjectKeyword.h create mode 100644 es2panda/ir/ts/tsParameterProperty.cpp create mode 100644 es2panda/ir/ts/tsParameterProperty.h create mode 100644 es2panda/ir/ts/tsParenthesizedType.cpp create mode 100644 es2panda/ir/ts/tsParenthesizedType.h create mode 100644 es2panda/ir/ts/tsPrivateIdentifier.cpp create mode 100644 es2panda/ir/ts/tsPrivateIdentifier.h create mode 100644 es2panda/ir/ts/tsPropertySignature.cpp create mode 100644 es2panda/ir/ts/tsPropertySignature.h create mode 100644 es2panda/ir/ts/tsQualifiedName.cpp create mode 100644 es2panda/ir/ts/tsQualifiedName.h create mode 100644 es2panda/ir/ts/tsSignatureDeclaration.cpp create mode 100644 es2panda/ir/ts/tsSignatureDeclaration.h create mode 100644 es2panda/ir/ts/tsStringKeyword.cpp create mode 100644 es2panda/ir/ts/tsStringKeyword.h create mode 100644 es2panda/ir/ts/tsThisType.cpp create mode 100644 es2panda/ir/ts/tsThisType.h create mode 100644 es2panda/ir/ts/tsTupleType.cpp create mode 100644 es2panda/ir/ts/tsTupleType.h create mode 100644 es2panda/ir/ts/tsTypeAliasDeclaration.cpp create mode 100644 es2panda/ir/ts/tsTypeAliasDeclaration.h create mode 100644 es2panda/ir/ts/tsTypeAssertion.cpp create mode 100644 es2panda/ir/ts/tsTypeAssertion.h create mode 100644 es2panda/ir/ts/tsTypeLiteral.cpp create mode 100644 es2panda/ir/ts/tsTypeLiteral.h create mode 100644 es2panda/ir/ts/tsTypeOperator.cpp create mode 100644 es2panda/ir/ts/tsTypeOperator.h create mode 100644 es2panda/ir/ts/tsTypeParameter.cpp create mode 100644 es2panda/ir/ts/tsTypeParameter.h create mode 100644 es2panda/ir/ts/tsTypeParameterDeclaration.cpp create mode 100644 es2panda/ir/ts/tsTypeParameterDeclaration.h create mode 100644 es2panda/ir/ts/tsTypeParameterInstantiation.cpp create mode 100644 es2panda/ir/ts/tsTypeParameterInstantiation.h create mode 100644 es2panda/ir/ts/tsTypePredicate.cpp create mode 100644 es2panda/ir/ts/tsTypePredicate.h create mode 100644 es2panda/ir/ts/tsTypeQuery.cpp create mode 100644 es2panda/ir/ts/tsTypeQuery.h create mode 100644 es2panda/ir/ts/tsTypeReference.cpp create mode 100644 es2panda/ir/ts/tsTypeReference.h create mode 100644 es2panda/ir/ts/tsUndefinedKeyword.cpp create mode 100644 es2panda/ir/ts/tsUndefinedKeyword.h create mode 100644 es2panda/ir/ts/tsUnionType.cpp create mode 100644 es2panda/ir/ts/tsUnionType.h create mode 100644 es2panda/ir/ts/tsUnknownKeyword.cpp create mode 100644 es2panda/ir/ts/tsUnknownKeyword.h create mode 100644 es2panda/ir/ts/tsVoidKeyword.cpp create mode 100644 es2panda/ir/ts/tsVoidKeyword.h create mode 100644 es2panda/ir/validationInfo.h create mode 100644 es2panda/lexer/keywordString.h create mode 100644 es2panda/lexer/keywordsUtil.cpp create mode 100644 es2panda/lexer/keywordsUtil.h create mode 100644 es2panda/lexer/lexer.cpp create mode 100644 es2panda/lexer/lexer.h create mode 100644 es2panda/lexer/regexp/regexp.cpp create mode 100644 es2panda/lexer/regexp/regexp.h create mode 100644 es2panda/lexer/scripts/keywords.rb create mode 100644 es2panda/lexer/templates/keywords.h.erb create mode 100644 es2panda/lexer/templates/keywordsMap.h.erb create mode 100644 es2panda/lexer/token/letters.h create mode 100644 es2panda/lexer/token/sourceLocation.cpp create mode 100644 es2panda/lexer/token/sourceLocation.h create mode 100644 es2panda/lexer/token/token.cpp create mode 100644 es2panda/lexer/token/token.h create mode 100644 es2panda/lexer/token/tokenType.h create mode 100644 es2panda/parser/context/parserContext.cpp create mode 100644 es2panda/parser/context/parserContext.h create mode 100644 es2panda/parser/expressionParser.cpp create mode 100644 es2panda/parser/parserFlags.h create mode 100644 es2panda/parser/parserImpl.cpp create mode 100644 es2panda/parser/parserImpl.h create mode 100644 es2panda/parser/program/program.cpp create mode 100644 es2panda/parser/program/program.h create mode 100644 es2panda/parser/statementParser.cpp create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_1-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_1.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_10-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_10.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_11-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_11.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_12-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_12.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_13-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_13.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_14-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_14.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_15-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_15.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_16-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_16.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_17-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_17.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_18-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_18.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_19-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_19.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_2-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_2.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_20-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_20.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_21-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_21.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_22-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_22.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_23-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_23.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_24-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_24.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_25-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_25.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_26-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_26.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_27-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_27.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_28-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_28.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_29-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_29.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_3-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_3.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_30-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_30.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_31-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_31.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_32-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_32.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_33-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_33.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_34-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_34.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_35-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_35.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_36-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_36.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_37-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_37.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_38-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_38.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_39-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_39.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_4-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_4.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_40-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_40.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_41-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_41.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_42-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_42.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_43-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_43.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_44-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_44.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_45-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_45.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_46-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_46.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_47-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_47.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_48-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_48.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_49-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_49.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_5-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_5.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_50-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_50.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_51-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_51.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_52-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_52.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_53-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_53.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_54-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_54.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_55-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_55.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_56-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_56.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_57-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_57.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_58-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_58.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_59-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_59.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_6-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_6.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_60-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_60.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_61-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_61.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_62-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_62.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_63-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_63.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_64-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_64.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_7-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_7.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_8-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_8.ts create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_9-expected.txt create mode 100644 es2panda/test/compiler/ts/arithmetic_operators_9.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring1-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring1.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring10-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring10.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring11-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring11.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring12-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring12.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring13-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring13.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring14-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring14.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring15-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring15.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring16-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring16.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring17-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring17.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring18-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring18.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring19-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring19.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring2-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring2.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring20-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring20.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring21-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring21.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring22-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring22.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring23-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring23.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring24-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring24.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring25-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring25.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring26-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring26.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring27-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring27.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring28-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring28.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring29-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring29.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring3-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring3.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring30-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring30.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring31-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring31.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring32-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring32.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring33-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring33.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring34-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring34.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring35-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring35.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring36-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring36.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring37-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring37.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring38-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring38.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring39-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring39.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring4-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring4.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring40-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring40.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring41-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring41.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring42-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring42.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring43-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring43.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring44-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring44.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring5-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring5.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring6-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring6.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring7-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring7.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring8-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring8.ts create mode 100644 es2panda/test/compiler/ts/arrayDestructuring9-expected.txt create mode 100644 es2panda/test/compiler/ts/arrayDestructuring9.ts create mode 100644 es2panda/test/compiler/ts/array_1-expected.txt create mode 100644 es2panda/test/compiler/ts/array_1.ts create mode 100644 es2panda/test/compiler/ts/array_10-expected.txt create mode 100644 es2panda/test/compiler/ts/array_10.ts create mode 100644 es2panda/test/compiler/ts/array_11-expected.txt create mode 100644 es2panda/test/compiler/ts/array_11.ts create mode 100644 es2panda/test/compiler/ts/array_12-expected.txt create mode 100644 es2panda/test/compiler/ts/array_12.ts create mode 100644 es2panda/test/compiler/ts/array_13-expected.txt create mode 100644 es2panda/test/compiler/ts/array_13.ts create mode 100644 es2panda/test/compiler/ts/array_14-expected.txt create mode 100644 es2panda/test/compiler/ts/array_14.ts create mode 100644 es2panda/test/compiler/ts/array_15-expected.txt create mode 100644 es2panda/test/compiler/ts/array_15.ts create mode 100644 es2panda/test/compiler/ts/array_16-expected.txt create mode 100644 es2panda/test/compiler/ts/array_16.ts create mode 100644 es2panda/test/compiler/ts/array_17-expected.txt create mode 100644 es2panda/test/compiler/ts/array_17.ts create mode 100644 es2panda/test/compiler/ts/array_18-expected.txt create mode 100644 es2panda/test/compiler/ts/array_18.ts create mode 100644 es2panda/test/compiler/ts/array_19-expected.txt create mode 100644 es2panda/test/compiler/ts/array_19.ts create mode 100644 es2panda/test/compiler/ts/array_2-expected.txt create mode 100644 es2panda/test/compiler/ts/array_2.ts create mode 100644 es2panda/test/compiler/ts/array_20-expected.txt create mode 100644 es2panda/test/compiler/ts/array_20.ts create mode 100644 es2panda/test/compiler/ts/array_21-expected.txt create mode 100644 es2panda/test/compiler/ts/array_21.ts create mode 100644 es2panda/test/compiler/ts/array_22-expected.txt create mode 100644 es2panda/test/compiler/ts/array_22.ts create mode 100644 es2panda/test/compiler/ts/array_23-expected.txt create mode 100644 es2panda/test/compiler/ts/array_23.ts create mode 100644 es2panda/test/compiler/ts/array_24-expected.txt create mode 100644 es2panda/test/compiler/ts/array_24.ts create mode 100644 es2panda/test/compiler/ts/array_3-expected.txt create mode 100644 es2panda/test/compiler/ts/array_3.ts create mode 100644 es2panda/test/compiler/ts/array_4-expected.txt create mode 100644 es2panda/test/compiler/ts/array_4.ts create mode 100644 es2panda/test/compiler/ts/array_5-expected.txt create mode 100644 es2panda/test/compiler/ts/array_5.ts create mode 100644 es2panda/test/compiler/ts/array_6-expected.txt create mode 100644 es2panda/test/compiler/ts/array_6.ts create mode 100644 es2panda/test/compiler/ts/array_7-expected.txt create mode 100644 es2panda/test/compiler/ts/array_7.ts create mode 100644 es2panda/test/compiler/ts/array_8-expected.txt create mode 100644 es2panda/test/compiler/ts/array_8.ts create mode 100644 es2panda/test/compiler/ts/array_9-expected.txt create mode 100644 es2panda/test/compiler/ts/array_9.ts create mode 100644 es2panda/test/compiler/ts/as_expression_1-expected.txt create mode 100644 es2panda/test/compiler/ts/as_expression_1.ts create mode 100644 es2panda/test/compiler/ts/as_expression_10-expected.txt create mode 100644 es2panda/test/compiler/ts/as_expression_10.ts create mode 100644 es2panda/test/compiler/ts/as_expression_11-expected.txt create mode 100644 es2panda/test/compiler/ts/as_expression_11.ts create mode 100644 es2panda/test/compiler/ts/as_expression_12-expected.txt create mode 100644 es2panda/test/compiler/ts/as_expression_12.ts create mode 100644 es2panda/test/compiler/ts/as_expression_13-expected.txt create mode 100644 es2panda/test/compiler/ts/as_expression_13.ts create mode 100644 es2panda/test/compiler/ts/as_expression_14-expected.txt create mode 100644 es2panda/test/compiler/ts/as_expression_14.ts create mode 100644 es2panda/test/compiler/ts/as_expression_15-expected.txt create mode 100644 es2panda/test/compiler/ts/as_expression_15.ts create mode 100644 es2panda/test/compiler/ts/as_expression_2-expected.txt create mode 100644 es2panda/test/compiler/ts/as_expression_2.ts create mode 100644 es2panda/test/compiler/ts/as_expression_3-expected.txt create mode 100644 es2panda/test/compiler/ts/as_expression_3.ts create mode 100644 es2panda/test/compiler/ts/as_expression_4-expected.txt create mode 100644 es2panda/test/compiler/ts/as_expression_4.ts create mode 100644 es2panda/test/compiler/ts/as_expression_5-expected.txt create mode 100644 es2panda/test/compiler/ts/as_expression_5.ts create mode 100644 es2panda/test/compiler/ts/as_expression_6-expected.txt create mode 100644 es2panda/test/compiler/ts/as_expression_6.ts create mode 100644 es2panda/test/compiler/ts/as_expression_7-expected.txt create mode 100644 es2panda/test/compiler/ts/as_expression_7.ts create mode 100644 es2panda/test/compiler/ts/as_expression_8-expected.txt create mode 100644 es2panda/test/compiler/ts/as_expression_8.ts create mode 100644 es2panda/test/compiler/ts/as_expression_9-expected.txt create mode 100644 es2panda/test/compiler/ts/as_expression_9.ts create mode 100644 es2panda/test/compiler/ts/assignment_never-expected.txt create mode 100644 es2panda/test/compiler/ts/assignment_never.ts create mode 100644 es2panda/test/compiler/ts/assignment_unknown-expected.txt create mode 100644 es2panda/test/compiler/ts/assignment_unknown.ts create mode 100644 es2panda/test/compiler/ts/cannotAssignToConst-expected.txt create mode 100644 es2panda/test/compiler/ts/cannotAssignToConst.ts create mode 100644 es2panda/test/compiler/ts/constUsedBeforeDeclaration-expected.txt create mode 100644 es2panda/test/compiler/ts/constUsedBeforeDeclaration.ts create mode 100644 es2panda/test/compiler/ts/functionCall-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall.ts create mode 100644 es2panda/test/compiler/ts/functionCall_1-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall_1.ts create mode 100644 es2panda/test/compiler/ts/functionCall_10-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall_10.ts create mode 100644 es2panda/test/compiler/ts/functionCall_11-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall_11.ts create mode 100644 es2panda/test/compiler/ts/functionCall_12-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall_12.ts create mode 100644 es2panda/test/compiler/ts/functionCall_13-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall_13.ts create mode 100644 es2panda/test/compiler/ts/functionCall_14-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall_14.ts create mode 100644 es2panda/test/compiler/ts/functionCall_15-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall_15.ts create mode 100644 es2panda/test/compiler/ts/functionCall_2-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall_2.ts create mode 100644 es2panda/test/compiler/ts/functionCall_3-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall_3.ts create mode 100644 es2panda/test/compiler/ts/functionCall_4-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall_4.ts create mode 100644 es2panda/test/compiler/ts/functionCall_5-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall_5.ts create mode 100644 es2panda/test/compiler/ts/functionCall_6-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall_6.ts create mode 100644 es2panda/test/compiler/ts/functionCall_7-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall_7.ts create mode 100644 es2panda/test/compiler/ts/functionCall_8-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall_8.ts create mode 100644 es2panda/test/compiler/ts/functionCall_9-expected.txt create mode 100644 es2panda/test/compiler/ts/functionCall_9.ts create mode 100644 es2panda/test/compiler/ts/functionOverload1-expected.txt create mode 100644 es2panda/test/compiler/ts/functionOverload1.ts create mode 100644 es2panda/test/compiler/ts/functionOverload2-expected.txt create mode 100644 es2panda/test/compiler/ts/functionOverload2.ts create mode 100644 es2panda/test/compiler/ts/functionOverload3-expected.txt create mode 100644 es2panda/test/compiler/ts/functionOverload3.ts create mode 100644 es2panda/test/compiler/ts/functionOverload4-expected.txt create mode 100644 es2panda/test/compiler/ts/functionOverload4.ts create mode 100644 es2panda/test/compiler/ts/functionWithPattern1-expected.txt create mode 100644 es2panda/test/compiler/ts/functionWithPattern1.ts create mode 100644 es2panda/test/compiler/ts/functionWithPattern10-expected.txt create mode 100644 es2panda/test/compiler/ts/functionWithPattern10.ts create mode 100644 es2panda/test/compiler/ts/functionWithPattern11-expected.txt create mode 100644 es2panda/test/compiler/ts/functionWithPattern11.ts create mode 100644 es2panda/test/compiler/ts/functionWithPattern12-expected.txt create mode 100644 es2panda/test/compiler/ts/functionWithPattern12.ts create mode 100644 es2panda/test/compiler/ts/functionWithPattern2-expected.txt create mode 100644 es2panda/test/compiler/ts/functionWithPattern2.ts create mode 100644 es2panda/test/compiler/ts/functionWithPattern3-expected.txt create mode 100644 es2panda/test/compiler/ts/functionWithPattern3.ts create mode 100644 es2panda/test/compiler/ts/functionWithPattern4-expected.txt create mode 100644 es2panda/test/compiler/ts/functionWithPattern4.ts create mode 100644 es2panda/test/compiler/ts/functionWithPattern5-expected.txt create mode 100644 es2panda/test/compiler/ts/functionWithPattern5.ts create mode 100644 es2panda/test/compiler/ts/functionWithPattern6-expected.txt create mode 100644 es2panda/test/compiler/ts/functionWithPattern6.ts create mode 100644 es2panda/test/compiler/ts/functionWithPattern7-expected.txt create mode 100644 es2panda/test/compiler/ts/functionWithPattern7.ts create mode 100644 es2panda/test/compiler/ts/functionWithPattern8-expected.txt create mode 100644 es2panda/test/compiler/ts/functionWithPattern8.ts create mode 100644 es2panda/test/compiler/ts/functionWithPattern9-expected.txt create mode 100644 es2panda/test/compiler/ts/functionWithPattern9.ts create mode 100644 es2panda/test/compiler/ts/function_declaration_1-expected.txt create mode 100644 es2panda/test/compiler/ts/function_declaration_1.ts create mode 100644 es2panda/test/compiler/ts/function_declaration_10-expected.txt create mode 100644 es2panda/test/compiler/ts/function_declaration_10.ts create mode 100644 es2panda/test/compiler/ts/function_declaration_11-expected.txt create mode 100644 es2panda/test/compiler/ts/function_declaration_11.ts create mode 100644 es2panda/test/compiler/ts/function_declaration_2-expected.txt create mode 100644 es2panda/test/compiler/ts/function_declaration_2.ts create mode 100644 es2panda/test/compiler/ts/function_declaration_3-expected.txt create mode 100644 es2panda/test/compiler/ts/function_declaration_3.ts create mode 100644 es2panda/test/compiler/ts/function_declaration_4-expected.txt create mode 100644 es2panda/test/compiler/ts/function_declaration_4.ts create mode 100644 es2panda/test/compiler/ts/function_declaration_5-expected.txt create mode 100644 es2panda/test/compiler/ts/function_declaration_5.ts create mode 100644 es2panda/test/compiler/ts/function_declaration_6-expected.txt create mode 100644 es2panda/test/compiler/ts/function_declaration_6.ts create mode 100644 es2panda/test/compiler/ts/function_declaration_7-expected.txt create mode 100644 es2panda/test/compiler/ts/function_declaration_7.ts create mode 100644 es2panda/test/compiler/ts/function_declaration_8-expected.txt create mode 100644 es2panda/test/compiler/ts/function_declaration_8.ts create mode 100644 es2panda/test/compiler/ts/function_declaration_9-expected.txt create mode 100644 es2panda/test/compiler/ts/function_declaration_9.ts create mode 100644 es2panda/test/compiler/ts/generic_interface-expected.txt create mode 100644 es2panda/test/compiler/ts/generic_interface.ts create mode 100644 es2panda/test/compiler/ts/generic_type_alias-expected.txt create mode 100644 es2panda/test/compiler/ts/generic_type_alias.ts create mode 100644 es2panda/test/compiler/ts/generic_type_alias_1-expected.txt create mode 100644 es2panda/test/compiler/ts/generic_type_alias_1.ts create mode 100644 es2panda/test/compiler/ts/generic_type_alias_10-expected.txt create mode 100644 es2panda/test/compiler/ts/generic_type_alias_10.ts create mode 100644 es2panda/test/compiler/ts/generic_type_alias_2-expected.txt create mode 100644 es2panda/test/compiler/ts/generic_type_alias_2.ts create mode 100644 es2panda/test/compiler/ts/generic_type_alias_3-expected.txt create mode 100644 es2panda/test/compiler/ts/generic_type_alias_3.ts create mode 100644 es2panda/test/compiler/ts/generic_type_alias_4-expected.txt create mode 100644 es2panda/test/compiler/ts/generic_type_alias_4.ts create mode 100644 es2panda/test/compiler/ts/generic_type_alias_5-expected.txt create mode 100644 es2panda/test/compiler/ts/generic_type_alias_5.ts create mode 100644 es2panda/test/compiler/ts/generic_type_alias_6-expected.txt create mode 100644 es2panda/test/compiler/ts/generic_type_alias_6.ts create mode 100644 es2panda/test/compiler/ts/generic_type_alias_7-expected.txt create mode 100644 es2panda/test/compiler/ts/generic_type_alias_7.ts create mode 100644 es2panda/test/compiler/ts/generic_type_alias_8-expected.txt create mode 100644 es2panda/test/compiler/ts/generic_type_alias_8.ts create mode 100644 es2panda/test/compiler/ts/generic_type_alias_9-expected.txt create mode 100644 es2panda/test/compiler/ts/generic_type_alias_9.ts create mode 100644 es2panda/test/compiler/ts/identifierWithoutDeclaration-expected.txt create mode 100644 es2panda/test/compiler/ts/identifierWithoutDeclaration.ts create mode 100644 es2panda/test/compiler/ts/in_1-expected.txt create mode 100644 es2panda/test/compiler/ts/in_1.ts create mode 100644 es2panda/test/compiler/ts/in_10-expected.txt create mode 100644 es2panda/test/compiler/ts/in_10.ts create mode 100644 es2panda/test/compiler/ts/in_11-expected.txt create mode 100644 es2panda/test/compiler/ts/in_11.ts create mode 100644 es2panda/test/compiler/ts/in_12-expected.txt create mode 100644 es2panda/test/compiler/ts/in_12.ts create mode 100644 es2panda/test/compiler/ts/in_13-expected.txt create mode 100644 es2panda/test/compiler/ts/in_13.ts create mode 100644 es2panda/test/compiler/ts/in_14-expected.txt create mode 100644 es2panda/test/compiler/ts/in_14.ts create mode 100644 es2panda/test/compiler/ts/in_15-expected.txt create mode 100644 es2panda/test/compiler/ts/in_15.ts create mode 100644 es2panda/test/compiler/ts/in_2-expected.txt create mode 100644 es2panda/test/compiler/ts/in_2.ts create mode 100644 es2panda/test/compiler/ts/in_3-expected.txt create mode 100644 es2panda/test/compiler/ts/in_3.ts create mode 100644 es2panda/test/compiler/ts/in_4-expected.txt create mode 100644 es2panda/test/compiler/ts/in_4.ts create mode 100644 es2panda/test/compiler/ts/in_5-expected.txt create mode 100644 es2panda/test/compiler/ts/in_5.ts create mode 100644 es2panda/test/compiler/ts/in_6-expected.txt create mode 100644 es2panda/test/compiler/ts/in_6.ts create mode 100644 es2panda/test/compiler/ts/in_7-expected.txt create mode 100644 es2panda/test/compiler/ts/in_7.ts create mode 100644 es2panda/test/compiler/ts/in_8-expected.txt create mode 100644 es2panda/test/compiler/ts/in_8.ts create mode 100644 es2panda/test/compiler/ts/in_9-expected.txt create mode 100644 es2panda/test/compiler/ts/in_9.ts create mode 100644 es2panda/test/compiler/ts/instanceof_1-expected.txt create mode 100644 es2panda/test/compiler/ts/instanceof_1.ts create mode 100644 es2panda/test/compiler/ts/instanceof_10-expected.txt create mode 100644 es2panda/test/compiler/ts/instanceof_10.ts create mode 100644 es2panda/test/compiler/ts/instanceof_11-expected.txt create mode 100644 es2panda/test/compiler/ts/instanceof_11.ts create mode 100644 es2panda/test/compiler/ts/instanceof_12-expected.txt create mode 100644 es2panda/test/compiler/ts/instanceof_12.ts create mode 100644 es2panda/test/compiler/ts/instanceof_13-expected.txt create mode 100644 es2panda/test/compiler/ts/instanceof_13.ts create mode 100644 es2panda/test/compiler/ts/instanceof_14-expected.txt create mode 100644 es2panda/test/compiler/ts/instanceof_14.ts create mode 100644 es2panda/test/compiler/ts/instanceof_2-expected.txt create mode 100644 es2panda/test/compiler/ts/instanceof_2.ts create mode 100644 es2panda/test/compiler/ts/instanceof_3-expected.txt create mode 100644 es2panda/test/compiler/ts/instanceof_3.ts create mode 100644 es2panda/test/compiler/ts/instanceof_4-expected.txt create mode 100644 es2panda/test/compiler/ts/instanceof_4.ts create mode 100644 es2panda/test/compiler/ts/instanceof_5-expected.txt create mode 100644 es2panda/test/compiler/ts/instanceof_5.ts create mode 100644 es2panda/test/compiler/ts/instanceof_6-expected.txt create mode 100644 es2panda/test/compiler/ts/instanceof_6.ts create mode 100644 es2panda/test/compiler/ts/instanceof_7-expected.txt create mode 100644 es2panda/test/compiler/ts/instanceof_7.ts create mode 100644 es2panda/test/compiler/ts/instanceof_8-expected.txt create mode 100644 es2panda/test/compiler/ts/instanceof_8.ts create mode 100644 es2panda/test/compiler/ts/instanceof_9-expected.txt create mode 100644 es2panda/test/compiler/ts/instanceof_9.ts create mode 100644 es2panda/test/compiler/ts/interfaceAssignment-expected.txt create mode 100644 es2panda/test/compiler/ts/interfaceAssignment.ts create mode 100644 es2panda/test/compiler/ts/interfaceAssignment1-expected.txt create mode 100644 es2panda/test/compiler/ts/interfaceAssignment1.ts create mode 100644 es2panda/test/compiler/ts/interfaceAssignment2-expected.txt create mode 100644 es2panda/test/compiler/ts/interfaceAssignment2.ts create mode 100644 es2panda/test/compiler/ts/interfaceAssignment3-expected.txt create mode 100644 es2panda/test/compiler/ts/interfaceAssignment3.ts create mode 100644 es2panda/test/compiler/ts/interfaceAssignment4-expected.txt create mode 100644 es2panda/test/compiler/ts/interfaceAssignment4.ts create mode 100644 es2panda/test/compiler/ts/interfaceAssignment5-expected.txt create mode 100644 es2panda/test/compiler/ts/interfaceAssignment5.ts create mode 100644 es2panda/test/compiler/ts/interfaceAssignment6-expected.txt create mode 100644 es2panda/test/compiler/ts/interfaceAssignment6.ts create mode 100644 es2panda/test/compiler/ts/interfaceAssignment7-expected.txt create mode 100644 es2panda/test/compiler/ts/interfaceAssignment7.ts create mode 100644 es2panda/test/compiler/ts/interfaceAssignment8-expected.txt create mode 100644 es2panda/test/compiler/ts/interfaceAssignment8.ts create mode 100644 es2panda/test/compiler/ts/interfaceInheritance1-expected.txt create mode 100644 es2panda/test/compiler/ts/interfaceInheritance1.ts create mode 100644 es2panda/test/compiler/ts/interfaceInheritance2-expected.txt create mode 100644 es2panda/test/compiler/ts/interfaceInheritance2.ts create mode 100644 es2panda/test/compiler/ts/interfaceInheritance3-expected.txt create mode 100644 es2panda/test/compiler/ts/interfaceInheritance3.ts create mode 100644 es2panda/test/compiler/ts/interfaceInheritance4-expected.txt create mode 100644 es2panda/test/compiler/ts/interfaceInheritance4.ts create mode 100644 es2panda/test/compiler/ts/interfacePropertyReferenceContainingInterface-expected.txt create mode 100644 es2panda/test/compiler/ts/interfacePropertyReferenceContainingInterface.ts create mode 100644 es2panda/test/compiler/ts/interfacePropertyReferenceContainingInterface1-expected.txt create mode 100644 es2panda/test/compiler/ts/interfacePropertyReferenceContainingInterface1.ts create mode 100644 es2panda/test/compiler/ts/interfacePropertyWithIncompatibleIndexInfo-expected.txt create mode 100644 es2panda/test/compiler/ts/interfacePropertyWithIncompatibleIndexInfo.ts create mode 100644 es2panda/test/compiler/ts/interfaceUsedAsValue-expected.txt create mode 100644 es2panda/test/compiler/ts/interfaceUsedAsValue.ts create mode 100644 es2panda/test/compiler/ts/interfaceWithNonCompatibleIndexInfos-expected.txt create mode 100644 es2panda/test/compiler/ts/interfaceWithNonCompatibleIndexInfos.ts create mode 100644 es2panda/test/compiler/ts/interface_enum_member-expected.txt create mode 100644 es2panda/test/compiler/ts/interface_enum_member.ts create mode 100644 es2panda/test/compiler/ts/letUsedBeforeDeclaration-expected.txt create mode 100644 es2panda/test/compiler/ts/letUsedBeforeDeclaration.ts create mode 100644 es2panda/test/compiler/ts/memberExpTest_1-expected.txt create mode 100644 es2panda/test/compiler/ts/memberExpTest_1.ts create mode 100644 es2panda/test/compiler/ts/memberExpTest_2-expected.txt create mode 100644 es2panda/test/compiler/ts/memberExpTest_2.ts create mode 100644 es2panda/test/compiler/ts/memberExpTest_3-expected.txt create mode 100644 es2panda/test/compiler/ts/memberExpTest_3.ts create mode 100644 es2panda/test/compiler/ts/memberExpTest_4-expected.txt create mode 100644 es2panda/test/compiler/ts/memberExpTest_4.ts create mode 100644 es2panda/test/compiler/ts/memberExpTest_5-expected.txt create mode 100644 es2panda/test/compiler/ts/memberExpTest_5.ts create mode 100644 es2panda/test/compiler/ts/memberExpTest_6-expected.txt create mode 100644 es2panda/test/compiler/ts/memberExpTest_6.ts create mode 100644 es2panda/test/compiler/ts/memberExpTests-expected.txt create mode 100644 es2panda/test/compiler/ts/memberExpTests.ts create mode 100644 es2panda/test/compiler/ts/member_expression_1-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_1.ts create mode 100644 es2panda/test/compiler/ts/member_expression_10-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_10.ts create mode 100644 es2panda/test/compiler/ts/member_expression_11-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_11.ts create mode 100644 es2panda/test/compiler/ts/member_expression_12-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_12.ts create mode 100644 es2panda/test/compiler/ts/member_expression_13-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_13.ts create mode 100644 es2panda/test/compiler/ts/member_expression_14-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_14.ts create mode 100644 es2panda/test/compiler/ts/member_expression_15-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_15.ts create mode 100644 es2panda/test/compiler/ts/member_expression_16-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_16.ts create mode 100644 es2panda/test/compiler/ts/member_expression_17-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_17.ts create mode 100644 es2panda/test/compiler/ts/member_expression_18-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_18.ts create mode 100644 es2panda/test/compiler/ts/member_expression_19-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_19.ts create mode 100644 es2panda/test/compiler/ts/member_expression_2-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_2.ts create mode 100644 es2panda/test/compiler/ts/member_expression_20-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_20.ts create mode 100644 es2panda/test/compiler/ts/member_expression_21-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_21.ts create mode 100644 es2panda/test/compiler/ts/member_expression_22-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_22.ts create mode 100644 es2panda/test/compiler/ts/member_expression_23-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_23.ts create mode 100644 es2panda/test/compiler/ts/member_expression_24-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_24.ts create mode 100644 es2panda/test/compiler/ts/member_expression_25-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_25.ts create mode 100644 es2panda/test/compiler/ts/member_expression_26-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_26.ts create mode 100644 es2panda/test/compiler/ts/member_expression_27-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_27.ts create mode 100644 es2panda/test/compiler/ts/member_expression_28-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_28.ts create mode 100644 es2panda/test/compiler/ts/member_expression_29-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_29.ts create mode 100644 es2panda/test/compiler/ts/member_expression_3-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_3.ts create mode 100644 es2panda/test/compiler/ts/member_expression_30-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_30.ts create mode 100644 es2panda/test/compiler/ts/member_expression_31-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_31.ts create mode 100644 es2panda/test/compiler/ts/member_expression_32-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_32.ts create mode 100644 es2panda/test/compiler/ts/member_expression_33-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_33.ts create mode 100644 es2panda/test/compiler/ts/member_expression_34-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_34.ts create mode 100644 es2panda/test/compiler/ts/member_expression_35-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_35.ts create mode 100644 es2panda/test/compiler/ts/member_expression_36-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_36.ts create mode 100644 es2panda/test/compiler/ts/member_expression_37-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_37.ts create mode 100644 es2panda/test/compiler/ts/member_expression_38-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_38.ts create mode 100644 es2panda/test/compiler/ts/member_expression_39-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_39.ts create mode 100644 es2panda/test/compiler/ts/member_expression_4-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_4.ts create mode 100644 es2panda/test/compiler/ts/member_expression_40-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_40.ts create mode 100644 es2panda/test/compiler/ts/member_expression_41-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_41.ts create mode 100644 es2panda/test/compiler/ts/member_expression_42-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_42.ts create mode 100644 es2panda/test/compiler/ts/member_expression_43-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_43.ts create mode 100644 es2panda/test/compiler/ts/member_expression_44-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_44.ts create mode 100644 es2panda/test/compiler/ts/member_expression_45-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_45.ts create mode 100644 es2panda/test/compiler/ts/member_expression_46-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_46.ts create mode 100644 es2panda/test/compiler/ts/member_expression_47-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_47.ts create mode 100644 es2panda/test/compiler/ts/member_expression_48-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_48.ts create mode 100644 es2panda/test/compiler/ts/member_expression_49-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_49.ts create mode 100644 es2panda/test/compiler/ts/member_expression_5-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_5.ts create mode 100644 es2panda/test/compiler/ts/member_expression_50-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_50.ts create mode 100644 es2panda/test/compiler/ts/member_expression_51-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_51.ts create mode 100644 es2panda/test/compiler/ts/member_expression_52-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_52.ts create mode 100644 es2panda/test/compiler/ts/member_expression_53-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_53.ts create mode 100644 es2panda/test/compiler/ts/member_expression_54-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_54.ts create mode 100644 es2panda/test/compiler/ts/member_expression_55-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_55.ts create mode 100644 es2panda/test/compiler/ts/member_expression_56-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_56.ts create mode 100644 es2panda/test/compiler/ts/member_expression_57-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_57.ts create mode 100644 es2panda/test/compiler/ts/member_expression_58-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_58.ts create mode 100644 es2panda/test/compiler/ts/member_expression_59-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_59.ts create mode 100644 es2panda/test/compiler/ts/member_expression_6-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_6.ts create mode 100644 es2panda/test/compiler/ts/member_expression_60-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_60.ts create mode 100644 es2panda/test/compiler/ts/member_expression_61-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_61.ts create mode 100644 es2panda/test/compiler/ts/member_expression_62-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_62.ts create mode 100644 es2panda/test/compiler/ts/member_expression_63-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_63.ts create mode 100644 es2panda/test/compiler/ts/member_expression_64-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_64.ts create mode 100644 es2panda/test/compiler/ts/member_expression_65-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_65.ts create mode 100644 es2panda/test/compiler/ts/member_expression_66-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_66.ts create mode 100644 es2panda/test/compiler/ts/member_expression_67-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_67.ts create mode 100644 es2panda/test/compiler/ts/member_expression_68-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_68.ts create mode 100644 es2panda/test/compiler/ts/member_expression_69-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_69.ts create mode 100644 es2panda/test/compiler/ts/member_expression_7-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_7.ts create mode 100644 es2panda/test/compiler/ts/member_expression_70-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_70.ts create mode 100644 es2panda/test/compiler/ts/member_expression_71-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_71.ts create mode 100644 es2panda/test/compiler/ts/member_expression_72-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_72.ts create mode 100644 es2panda/test/compiler/ts/member_expression_73-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_73.ts create mode 100644 es2panda/test/compiler/ts/member_expression_74-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_74.ts create mode 100644 es2panda/test/compiler/ts/member_expression_75-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_75.ts create mode 100644 es2panda/test/compiler/ts/member_expression_76-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_76.ts create mode 100644 es2panda/test/compiler/ts/member_expression_77-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_77.ts create mode 100644 es2panda/test/compiler/ts/member_expression_78-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_78.ts create mode 100644 es2panda/test/compiler/ts/member_expression_79-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_79.ts create mode 100644 es2panda/test/compiler/ts/member_expression_8-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_8.ts create mode 100644 es2panda/test/compiler/ts/member_expression_80-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_80.ts create mode 100644 es2panda/test/compiler/ts/member_expression_81-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_81.ts create mode 100644 es2panda/test/compiler/ts/member_expression_82-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_82.ts create mode 100644 es2panda/test/compiler/ts/member_expression_9-expected.txt create mode 100644 es2panda/test/compiler/ts/member_expression_9.ts create mode 100644 es2panda/test/compiler/ts/new_expression_1-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_1.ts create mode 100644 es2panda/test/compiler/ts/new_expression_10-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_10.ts create mode 100644 es2panda/test/compiler/ts/new_expression_100-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_100.ts create mode 100644 es2panda/test/compiler/ts/new_expression_101-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_101.ts create mode 100644 es2panda/test/compiler/ts/new_expression_102-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_102.ts create mode 100644 es2panda/test/compiler/ts/new_expression_103-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_103.ts create mode 100644 es2panda/test/compiler/ts/new_expression_104-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_104.ts create mode 100644 es2panda/test/compiler/ts/new_expression_105-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_105.ts create mode 100644 es2panda/test/compiler/ts/new_expression_106-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_106.ts create mode 100644 es2panda/test/compiler/ts/new_expression_107-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_107.ts create mode 100644 es2panda/test/compiler/ts/new_expression_108-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_108.ts create mode 100644 es2panda/test/compiler/ts/new_expression_109-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_109.ts create mode 100644 es2panda/test/compiler/ts/new_expression_11-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_11.ts create mode 100644 es2panda/test/compiler/ts/new_expression_110-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_110.ts create mode 100644 es2panda/test/compiler/ts/new_expression_111-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_111.ts create mode 100644 es2panda/test/compiler/ts/new_expression_112-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_112.ts create mode 100644 es2panda/test/compiler/ts/new_expression_113-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_113.ts create mode 100644 es2panda/test/compiler/ts/new_expression_114-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_114.ts create mode 100644 es2panda/test/compiler/ts/new_expression_115-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_115.ts create mode 100644 es2panda/test/compiler/ts/new_expression_116-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_116.ts create mode 100644 es2panda/test/compiler/ts/new_expression_117-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_117.ts create mode 100644 es2panda/test/compiler/ts/new_expression_118-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_118.ts create mode 100644 es2panda/test/compiler/ts/new_expression_119-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_119.ts create mode 100644 es2panda/test/compiler/ts/new_expression_12-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_12.ts create mode 100644 es2panda/test/compiler/ts/new_expression_120-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_120.ts create mode 100644 es2panda/test/compiler/ts/new_expression_121-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_121.ts create mode 100644 es2panda/test/compiler/ts/new_expression_122-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_122.ts create mode 100644 es2panda/test/compiler/ts/new_expression_123-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_123.ts create mode 100644 es2panda/test/compiler/ts/new_expression_124-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_124.ts create mode 100644 es2panda/test/compiler/ts/new_expression_125-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_125.ts create mode 100644 es2panda/test/compiler/ts/new_expression_126-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_126.ts create mode 100644 es2panda/test/compiler/ts/new_expression_127-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_127.ts create mode 100644 es2panda/test/compiler/ts/new_expression_128-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_128.ts create mode 100644 es2panda/test/compiler/ts/new_expression_129-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_129.ts create mode 100644 es2panda/test/compiler/ts/new_expression_13-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_13.ts create mode 100644 es2panda/test/compiler/ts/new_expression_130-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_130.ts create mode 100644 es2panda/test/compiler/ts/new_expression_131-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_131.ts create mode 100644 es2panda/test/compiler/ts/new_expression_132-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_132.ts create mode 100644 es2panda/test/compiler/ts/new_expression_133-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_133.ts create mode 100644 es2panda/test/compiler/ts/new_expression_134-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_134.ts create mode 100644 es2panda/test/compiler/ts/new_expression_135-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_135.ts create mode 100644 es2panda/test/compiler/ts/new_expression_136-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_136.ts create mode 100644 es2panda/test/compiler/ts/new_expression_137-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_137.ts create mode 100644 es2panda/test/compiler/ts/new_expression_138-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_138.ts create mode 100644 es2panda/test/compiler/ts/new_expression_139-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_139.ts create mode 100644 es2panda/test/compiler/ts/new_expression_14-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_14.ts create mode 100644 es2panda/test/compiler/ts/new_expression_140-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_140.ts create mode 100644 es2panda/test/compiler/ts/new_expression_141-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_141.ts create mode 100644 es2panda/test/compiler/ts/new_expression_142-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_142.ts create mode 100644 es2panda/test/compiler/ts/new_expression_143-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_143.ts create mode 100644 es2panda/test/compiler/ts/new_expression_144-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_144.ts create mode 100644 es2panda/test/compiler/ts/new_expression_145-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_145.ts create mode 100644 es2panda/test/compiler/ts/new_expression_146-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_146.ts create mode 100644 es2panda/test/compiler/ts/new_expression_147-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_147.ts create mode 100644 es2panda/test/compiler/ts/new_expression_148-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_148.ts create mode 100644 es2panda/test/compiler/ts/new_expression_149-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_149.ts create mode 100644 es2panda/test/compiler/ts/new_expression_15-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_15.ts create mode 100644 es2panda/test/compiler/ts/new_expression_150-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_150.ts create mode 100644 es2panda/test/compiler/ts/new_expression_151-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_151.ts create mode 100644 es2panda/test/compiler/ts/new_expression_152-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_152.ts create mode 100644 es2panda/test/compiler/ts/new_expression_153-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_153.ts create mode 100644 es2panda/test/compiler/ts/new_expression_154-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_154.ts create mode 100644 es2panda/test/compiler/ts/new_expression_155-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_155.ts create mode 100644 es2panda/test/compiler/ts/new_expression_156-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_156.ts create mode 100644 es2panda/test/compiler/ts/new_expression_157-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_157.ts create mode 100644 es2panda/test/compiler/ts/new_expression_158-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_158.ts create mode 100644 es2panda/test/compiler/ts/new_expression_159-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_159.ts create mode 100644 es2panda/test/compiler/ts/new_expression_16-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_16.ts create mode 100644 es2panda/test/compiler/ts/new_expression_160-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_160.ts create mode 100644 es2panda/test/compiler/ts/new_expression_161-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_161.ts create mode 100644 es2panda/test/compiler/ts/new_expression_162-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_162.ts create mode 100644 es2panda/test/compiler/ts/new_expression_163-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_163.ts create mode 100644 es2panda/test/compiler/ts/new_expression_17-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_17.ts create mode 100644 es2panda/test/compiler/ts/new_expression_18-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_18.ts create mode 100644 es2panda/test/compiler/ts/new_expression_19-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_19.ts create mode 100644 es2panda/test/compiler/ts/new_expression_2-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_2.ts create mode 100644 es2panda/test/compiler/ts/new_expression_20-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_20.ts create mode 100644 es2panda/test/compiler/ts/new_expression_21-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_21.ts create mode 100644 es2panda/test/compiler/ts/new_expression_22-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_22.ts create mode 100644 es2panda/test/compiler/ts/new_expression_23-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_23.ts create mode 100644 es2panda/test/compiler/ts/new_expression_24-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_24.ts create mode 100644 es2panda/test/compiler/ts/new_expression_25-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_25.ts create mode 100644 es2panda/test/compiler/ts/new_expression_26-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_26.ts create mode 100644 es2panda/test/compiler/ts/new_expression_27-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_27.ts create mode 100644 es2panda/test/compiler/ts/new_expression_28-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_28.ts create mode 100644 es2panda/test/compiler/ts/new_expression_29-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_29.ts create mode 100644 es2panda/test/compiler/ts/new_expression_3-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_3.ts create mode 100644 es2panda/test/compiler/ts/new_expression_30-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_30.ts create mode 100644 es2panda/test/compiler/ts/new_expression_31-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_31.ts create mode 100644 es2panda/test/compiler/ts/new_expression_32-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_32.ts create mode 100644 es2panda/test/compiler/ts/new_expression_33-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_33.ts create mode 100644 es2panda/test/compiler/ts/new_expression_34-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_34.ts create mode 100644 es2panda/test/compiler/ts/new_expression_35-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_35.ts create mode 100644 es2panda/test/compiler/ts/new_expression_36-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_36.ts create mode 100644 es2panda/test/compiler/ts/new_expression_37-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_37.ts create mode 100644 es2panda/test/compiler/ts/new_expression_38-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_38.ts create mode 100644 es2panda/test/compiler/ts/new_expression_39-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_39.ts create mode 100644 es2panda/test/compiler/ts/new_expression_4-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_4.ts create mode 100644 es2panda/test/compiler/ts/new_expression_40-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_40.ts create mode 100644 es2panda/test/compiler/ts/new_expression_41-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_41.ts create mode 100644 es2panda/test/compiler/ts/new_expression_42-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_42.ts create mode 100644 es2panda/test/compiler/ts/new_expression_43-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_43.ts create mode 100644 es2panda/test/compiler/ts/new_expression_44-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_44.ts create mode 100644 es2panda/test/compiler/ts/new_expression_45-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_45.ts create mode 100644 es2panda/test/compiler/ts/new_expression_46-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_46.ts create mode 100644 es2panda/test/compiler/ts/new_expression_47-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_47.ts create mode 100644 es2panda/test/compiler/ts/new_expression_48-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_48.ts create mode 100644 es2panda/test/compiler/ts/new_expression_49-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_49.ts create mode 100644 es2panda/test/compiler/ts/new_expression_5-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_5.ts create mode 100644 es2panda/test/compiler/ts/new_expression_50-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_50.ts create mode 100644 es2panda/test/compiler/ts/new_expression_51-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_51.ts create mode 100644 es2panda/test/compiler/ts/new_expression_52-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_52.ts create mode 100644 es2panda/test/compiler/ts/new_expression_53-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_53.ts create mode 100644 es2panda/test/compiler/ts/new_expression_54-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_54.ts create mode 100644 es2panda/test/compiler/ts/new_expression_55-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_55.ts create mode 100644 es2panda/test/compiler/ts/new_expression_56-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_56.ts create mode 100644 es2panda/test/compiler/ts/new_expression_57-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_57.ts create mode 100644 es2panda/test/compiler/ts/new_expression_58-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_58.ts create mode 100644 es2panda/test/compiler/ts/new_expression_59-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_59.ts create mode 100644 es2panda/test/compiler/ts/new_expression_6-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_6.ts create mode 100644 es2panda/test/compiler/ts/new_expression_60-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_60.ts create mode 100644 es2panda/test/compiler/ts/new_expression_61-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_61.ts create mode 100644 es2panda/test/compiler/ts/new_expression_62-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_62.ts create mode 100644 es2panda/test/compiler/ts/new_expression_63-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_63.ts create mode 100644 es2panda/test/compiler/ts/new_expression_64-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_64.ts create mode 100644 es2panda/test/compiler/ts/new_expression_65-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_65.ts create mode 100644 es2panda/test/compiler/ts/new_expression_66-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_66.ts create mode 100644 es2panda/test/compiler/ts/new_expression_67-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_67.ts create mode 100644 es2panda/test/compiler/ts/new_expression_68-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_68.ts create mode 100644 es2panda/test/compiler/ts/new_expression_69-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_69.ts create mode 100644 es2panda/test/compiler/ts/new_expression_7-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_7.ts create mode 100644 es2panda/test/compiler/ts/new_expression_70-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_70.ts create mode 100644 es2panda/test/compiler/ts/new_expression_71-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_71.ts create mode 100644 es2panda/test/compiler/ts/new_expression_72-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_72.ts create mode 100644 es2panda/test/compiler/ts/new_expression_73-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_73.ts create mode 100644 es2panda/test/compiler/ts/new_expression_74-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_74.ts create mode 100644 es2panda/test/compiler/ts/new_expression_75-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_75.ts create mode 100644 es2panda/test/compiler/ts/new_expression_76-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_76.ts create mode 100644 es2panda/test/compiler/ts/new_expression_77-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_77.ts create mode 100644 es2panda/test/compiler/ts/new_expression_78-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_78.ts create mode 100644 es2panda/test/compiler/ts/new_expression_79-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_79.ts create mode 100644 es2panda/test/compiler/ts/new_expression_8-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_8.ts create mode 100644 es2panda/test/compiler/ts/new_expression_80-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_80.ts create mode 100644 es2panda/test/compiler/ts/new_expression_81-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_81.ts create mode 100644 es2panda/test/compiler/ts/new_expression_82-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_82.ts create mode 100644 es2panda/test/compiler/ts/new_expression_83-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_83.ts create mode 100644 es2panda/test/compiler/ts/new_expression_84-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_84.ts create mode 100644 es2panda/test/compiler/ts/new_expression_85-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_85.ts create mode 100644 es2panda/test/compiler/ts/new_expression_86-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_86.ts create mode 100644 es2panda/test/compiler/ts/new_expression_87-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_87.ts create mode 100644 es2panda/test/compiler/ts/new_expression_88-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_88.ts create mode 100644 es2panda/test/compiler/ts/new_expression_89-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_89.ts create mode 100644 es2panda/test/compiler/ts/new_expression_9-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_9.ts create mode 100644 es2panda/test/compiler/ts/new_expression_90-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_90.ts create mode 100644 es2panda/test/compiler/ts/new_expression_91-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_91.ts create mode 100644 es2panda/test/compiler/ts/new_expression_92-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_92.ts create mode 100644 es2panda/test/compiler/ts/new_expression_93-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_93.ts create mode 100644 es2panda/test/compiler/ts/new_expression_94-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_94.ts create mode 100644 es2panda/test/compiler/ts/new_expression_95-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_95.ts create mode 100644 es2panda/test/compiler/ts/new_expression_96-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_96.ts create mode 100644 es2panda/test/compiler/ts/new_expression_97-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_97.ts create mode 100644 es2panda/test/compiler/ts/new_expression_98-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_98.ts create mode 100644 es2panda/test/compiler/ts/new_expression_99-expected.txt create mode 100644 es2panda/test/compiler/ts/new_expression_99.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring1-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring1.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring10-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring10.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring11-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring11.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring12-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring12.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring13-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring13.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring14-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring14.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring15-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring15.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring16-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring16.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring17-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring17.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring18-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring18.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring19-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring19.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring2-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring2.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring20-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring20.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring21-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring21.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring22-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring22.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring23-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring23.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring24-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring24.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring25-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring25.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring26-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring26.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring27-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring27.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring28-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring28.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring29-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring29.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring3-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring3.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring30-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring30.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring31-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring31.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring32-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring32.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring33-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring33.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring34-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring34.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring35-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring35.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring36-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring36.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring37-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring37.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring38-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring38.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring39-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring39.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring4-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring4.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring40-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring40.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring41-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring41.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring5-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring5.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring6-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring6.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring7-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring7.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring8-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring8.ts create mode 100644 es2panda/test/compiler/ts/objectDestructuring9-expected.txt create mode 100644 es2panda/test/compiler/ts/objectDestructuring9.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability1-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability1.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability10-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability10.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability11-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability11.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability12-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability12.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability13-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability13.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability14-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability14.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability15-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability15.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability16-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability16.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability17-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability17.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability18-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability18.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability19-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability19.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability2-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability2.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability20-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability20.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability3-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability3.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability4-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability4.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability5-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability5.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability6-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability6.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability7-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability7.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability8-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability8.ts create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability9-expected.txt create mode 100644 es2panda/test/compiler/ts/objectLiteralAssignability9.ts create mode 100644 es2panda/test/compiler/ts/recursiveFunction-expected.txt create mode 100644 es2panda/test/compiler/ts/recursiveFunction.ts create mode 100644 es2panda/test/compiler/ts/recursiveTypeofWithProperty-expected.txt create mode 100644 es2panda/test/compiler/ts/recursiveTypeofWithProperty.ts create mode 100644 es2panda/test/compiler/ts/test-interface-expected.txt create mode 100644 es2panda/test/compiler/ts/test-interface.ts create mode 100644 es2panda/test/compiler/ts/test-interface4-expected.txt create mode 100644 es2panda/test/compiler/ts/test-interface4.ts create mode 100644 es2panda/test/compiler/ts/test-interface5-expected.txt create mode 100644 es2panda/test/compiler/ts/test-interface5.ts create mode 100644 es2panda/test/compiler/ts/test-interface6-expected.txt create mode 100644 es2panda/test/compiler/ts/test-interface6.ts create mode 100644 es2panda/test/compiler/ts/test-interface7-expected.txt create mode 100644 es2panda/test/compiler/ts/test-interface7.ts create mode 100644 es2panda/test/compiler/ts/test-type-literal-expected.txt create mode 100644 es2panda/test/compiler/ts/test-type-literal.ts create mode 100644 es2panda/test/compiler/ts/test-type-literal4-expected.txt create mode 100644 es2panda/test/compiler/ts/test-type-literal4.ts create mode 100644 es2panda/test/compiler/ts/test-type-literal5-expected.txt create mode 100644 es2panda/test/compiler/ts/test-type-literal5.ts create mode 100644 es2panda/test/compiler/ts/test-type-literal6-expected.txt create mode 100644 es2panda/test/compiler/ts/test-type-literal6.ts create mode 100644 es2panda/test/compiler/ts/test-type-literal7-expected.txt create mode 100644 es2panda/test/compiler/ts/test-type-literal7.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability1-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability1.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability10-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability10.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability11-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability11.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability12-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability12.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability13-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability13.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability14-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability14.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability15-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability15.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability16-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability16.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability17-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability17.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability18-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability18.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability19-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability19.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability2-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability2.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability20-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability20.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability21-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability21.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability22-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability22.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability23-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability23.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability24-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability24.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability3-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability3.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability4-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability4.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability5-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability5.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability6-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability6.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability7-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability7.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability8-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability8.ts create mode 100644 es2panda/test/compiler/ts/tupleAssignability9-expected.txt create mode 100644 es2panda/test/compiler/ts/tupleAssignability9.ts create mode 100644 es2panda/test/compiler/ts/typeAliasUsedAsValue-expected.txt create mode 100644 es2panda/test/compiler/ts/typeAliasUsedAsValue.ts create mode 100644 es2panda/test/compiler/ts/undefined_as_value-expected.txt create mode 100644 es2panda/test/compiler/ts/undefined_as_value.ts create mode 100644 es2panda/test/compiler/ts/undefined_variable_name-expected.txt create mode 100644 es2panda/test/compiler/ts/undefined_variable_name.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration1-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration1.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration10-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration10.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration11-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration11.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration12-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration12.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration13-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration13.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration14-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration14.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration15-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration15.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration2-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration2.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration3-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration3.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration4-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration4.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration5-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration5.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration6-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration6.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration7-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration7.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration8-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration8.ts create mode 100644 es2panda/test/compiler/ts/varRedeclaration9-expected.txt create mode 100644 es2panda/test/compiler/ts/varRedeclaration9.ts create mode 100644 es2panda/test/parser/js/invalid-left-hand-side-in-prefix-operation-expected.txt create mode 100644 es2panda/test/parser/js/invalid-left-hand-side-in-prefix-operation.js create mode 100644 es2panda/test/parser/js/new-expression-expected.txt create mode 100644 es2panda/test/parser/js/new-expression.js create mode 100644 es2panda/test/parser/js/test-array-expression-1-expected.txt create mode 100644 es2panda/test/parser/js/test-array-expression-1.js create mode 100644 es2panda/test/parser/js/test-array-expression-2-expected.txt create mode 100644 es2panda/test/parser/js/test-array-expression-2.js create mode 100644 es2panda/test/parser/js/test-array-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-array-expression.js create mode 100644 es2panda/test/parser/js/test-arrow-function-expected.txt create mode 100644 es2panda/test/parser/js/test-arrow-function.js create mode 100644 es2panda/test/parser/js/test-assignment-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-assignment-expression.js create mode 100644 es2panda/test/parser/js/test-async-arrow-function-1-expected.txt create mode 100644 es2panda/test/parser/js/test-async-arrow-function-1.js create mode 100644 es2panda/test/parser/js/test-async-function-1-expected.txt create mode 100644 es2panda/test/parser/js/test-async-function-1.js create mode 100644 es2panda/test/parser/js/test-async-function-2-expected.txt create mode 100644 es2panda/test/parser/js/test-async-function-2.js create mode 100644 es2panda/test/parser/js/test-binary-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-binary-expression.js create mode 100644 es2panda/test/parser/js/test-call-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-call-expression.js create mode 100644 es2panda/test/parser/js/test-class-async-method-expected.txt create mode 100644 es2panda/test/parser/js/test-class-async-method.js create mode 100644 es2panda/test/parser/js/test-class-definition-expected.txt create mode 100644 es2panda/test/parser/js/test-class-definition.js create mode 100644 es2panda/test/parser/js/test-class-definition1-expected.txt create mode 100644 es2panda/test/parser/js/test-class-definition1.js create mode 100644 es2panda/test/parser/js/test-class-definition2-expected.txt create mode 100644 es2panda/test/parser/js/test-class-definition2.js create mode 100644 es2panda/test/parser/js/test-class-definition3-expected.txt create mode 100644 es2panda/test/parser/js/test-class-definition3.js create mode 100644 es2panda/test/parser/js/test-class-definition4-expected.txt create mode 100644 es2panda/test/parser/js/test-class-definition4.js create mode 100644 es2panda/test/parser/js/test-class-definition5-expected.txt create mode 100644 es2panda/test/parser/js/test-class-definition5.js create mode 100644 es2panda/test/parser/js/test-class-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-class-expression.js create mode 100644 es2panda/test/parser/js/test-comment-expected.txt create mode 100644 es2panda/test/parser/js/test-comment.js create mode 100644 es2panda/test/parser/js/test-conditional-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-conditional-expression.js create mode 100644 es2panda/test/parser/js/test-const-without-init-expected.txt create mode 100644 es2panda/test/parser/js/test-const-without-init.js create mode 100644 es2panda/test/parser/js/test-continue-in-switch-expected.txt create mode 100644 es2panda/test/parser/js/test-continue-in-switch.js create mode 100644 es2panda/test/parser/js/test-debugger-statement-expected.txt create mode 100644 es2panda/test/parser/js/test-debugger-statement.js create mode 100644 es2panda/test/parser/js/test-delete-identifier-expected.txt create mode 100644 es2panda/test/parser/js/test-delete-identifier.js create mode 100644 es2panda/test/parser/js/test-do-while-1-expected.txt create mode 100644 es2panda/test/parser/js/test-do-while-1.js create mode 100644 es2panda/test/parser/js/test-do-while-expected.txt create mode 100644 es2panda/test/parser/js/test-do-while.js create mode 100644 es2panda/test/parser/js/test-escaped-keyword-expected.txt create mode 100644 es2panda/test/parser/js/test-escaped-keyword.js create mode 100644 es2panda/test/parser/js/test-export-all-expected.txt create mode 100644 es2panda/test/parser/js/test-export-all.js create mode 100644 es2panda/test/parser/js/test-export-named-decl-expected.txt create mode 100644 es2panda/test/parser/js/test-export-named-decl.js create mode 100644 es2panda/test/parser/js/test-expression-after-unary-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-expression-after-unary-expression.js create mode 100644 es2panda/test/parser/js/test-for-1-expected.txt create mode 100644 es2panda/test/parser/js/test-for-1.js create mode 100644 es2panda/test/parser/js/test-for-2-expected.txt create mode 100644 es2panda/test/parser/js/test-for-2.js create mode 100644 es2panda/test/parser/js/test-for-3-expected.txt create mode 100644 es2panda/test/parser/js/test-for-3.js create mode 100644 es2panda/test/parser/js/test-for-4-expected.txt create mode 100644 es2panda/test/parser/js/test-for-4.js create mode 100644 es2panda/test/parser/js/test-for-expected.txt create mode 100644 es2panda/test/parser/js/test-for.js create mode 100644 es2panda/test/parser/js/test-function-decl-expected.txt create mode 100644 es2panda/test/parser/js/test-function-decl.js create mode 100644 es2panda/test/parser/js/test-function-scope-violation-1-expected.txt create mode 100644 es2panda/test/parser/js/test-function-scope-violation-1.js create mode 100644 es2panda/test/parser/js/test-function-scope-violation-2-expected.txt create mode 100644 es2panda/test/parser/js/test-function-scope-violation-2.js create mode 100644 es2panda/test/parser/js/test-grouping-level-expected.txt create mode 100644 es2panda/test/parser/js/test-grouping-level.js create mode 100644 es2panda/test/parser/js/test-if-1-expected.txt create mode 100644 es2panda/test/parser/js/test-if-1.js create mode 100644 es2panda/test/parser/js/test-if-2-expected.txt create mode 100644 es2panda/test/parser/js/test-if-2.js create mode 100644 es2panda/test/parser/js/test-if-expected.txt create mode 100644 es2panda/test/parser/js/test-if.js create mode 100644 es2panda/test/parser/js/test-import-decl-expected.txt create mode 100644 es2panda/test/parser/js/test-import-decl.js create mode 100644 es2panda/test/parser/js/test-import-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-import-expression.js create mode 100644 es2panda/test/parser/js/test-import-meta-expected.txt create mode 100644 es2panda/test/parser/js/test-import-meta.js create mode 100644 es2panda/test/parser/js/test-imported-decl1-expected.txt create mode 100644 es2panda/test/parser/js/test-imported-decl1.js create mode 100644 es2panda/test/parser/js/test-labelled-statement-expected.txt create mode 100644 es2panda/test/parser/js/test-labelled-statement.js create mode 100644 es2panda/test/parser/js/test-labelled-statement1-expected.txt create mode 100644 es2panda/test/parser/js/test-labelled-statement1.js create mode 100644 es2panda/test/parser/js/test-labelled-statement2-expected.txt create mode 100644 es2panda/test/parser/js/test-labelled-statement2.js create mode 100644 es2panda/test/parser/js/test-let-redeclaration-expected.txt create mode 100644 es2panda/test/parser/js/test-let-redeclaration.js create mode 100644 es2panda/test/parser/js/test-logical-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-logical-expression.js create mode 100644 es2panda/test/parser/js/test-member-expression-1-expected.txt create mode 100644 es2panda/test/parser/js/test-member-expression-1.js create mode 100644 es2panda/test/parser/js/test-member-expression-2-expected.txt create mode 100644 es2panda/test/parser/js/test-member-expression-2.js create mode 100644 es2panda/test/parser/js/test-member-expression-3-expected.txt create mode 100644 es2panda/test/parser/js/test-member-expression-3.js create mode 100644 es2panda/test/parser/js/test-member-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-member-expression.js create mode 100644 es2panda/test/parser/js/test-missing-catch-argument-expected.txt create mode 100644 es2panda/test/parser/js/test-missing-catch-argument.js create mode 100644 es2panda/test/parser/js/test-multi-line-string-expected.txt create mode 100644 es2panda/test/parser/js/test-multi-line-string.js create mode 100644 es2panda/test/parser/js/test-multiple-update-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-multiple-update-expression.js create mode 100644 es2panda/test/parser/js/test-new-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-new-expression.js create mode 100644 es2panda/test/parser/js/test-nullish-coalescing-expected.txt create mode 100644 es2panda/test/parser/js/test-nullish-coalescing.js create mode 100644 es2panda/test/parser/js/test-nullish-coalescing1-expected.txt create mode 100644 es2panda/test/parser/js/test-nullish-coalescing1.js create mode 100644 es2panda/test/parser/js/test-nullish-coalescing2-expected.txt create mode 100644 es2panda/test/parser/js/test-nullish-coalescing2.js create mode 100644 es2panda/test/parser/js/test-numeric-separator-expected.txt create mode 100644 es2panda/test/parser/js/test-numeric-separator.js create mode 100644 es2panda/test/parser/js/test-numeric-separator1-expected.txt create mode 100644 es2panda/test/parser/js/test-numeric-separator1.js create mode 100644 es2panda/test/parser/js/test-numeric-separator2-expected.txt create mode 100644 es2panda/test/parser/js/test-numeric-separator2.js create mode 100644 es2panda/test/parser/js/test-object-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-object-expression.js create mode 100644 es2panda/test/parser/js/test-object-expression1-expected.txt create mode 100644 es2panda/test/parser/js/test-object-expression1.js create mode 100644 es2panda/test/parser/js/test-object-expression2-expected.txt create mode 100644 es2panda/test/parser/js/test-object-expression2.js create mode 100644 es2panda/test/parser/js/test-object-expression3-expected.txt create mode 100644 es2panda/test/parser/js/test-object-expression3.js create mode 100644 es2panda/test/parser/js/test-object-expression4-expected.txt create mode 100644 es2panda/test/parser/js/test-object-expression4.js create mode 100644 es2panda/test/parser/js/test-object-expression5-expected.txt create mode 100644 es2panda/test/parser/js/test-object-expression5.js create mode 100644 es2panda/test/parser/js/test-object-proto-expected.txt create mode 100644 es2panda/test/parser/js/test-object-proto.js create mode 100644 es2panda/test/parser/js/test-one-default-export-allowed-expected.txt create mode 100644 es2panda/test/parser/js/test-one-default-export-allowed.js create mode 100644 es2panda/test/parser/js/test-optional-chain-expected.txt create mode 100644 es2panda/test/parser/js/test-optional-chain.js create mode 100644 es2panda/test/parser/js/test-patterns-expected.txt create mode 100644 es2panda/test/parser/js/test-patterns.js create mode 100644 es2panda/test/parser/js/test-sequence-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-sequence-expression.js create mode 100644 es2panda/test/parser/js/test-string-literal-expected.txt create mode 100644 es2panda/test/parser/js/test-string-literal.js create mode 100644 es2panda/test/parser/js/test-super-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-super-expression.js create mode 100644 es2panda/test/parser/js/test-switch-1-expected.txt create mode 100644 es2panda/test/parser/js/test-switch-1.js create mode 100644 es2panda/test/parser/js/test-switch-2-expected.txt create mode 100644 es2panda/test/parser/js/test-switch-2.js create mode 100644 es2panda/test/parser/js/test-switch-3-expected.txt create mode 100644 es2panda/test/parser/js/test-switch-3.js create mode 100644 es2panda/test/parser/js/test-switch-4-expected.txt create mode 100644 es2panda/test/parser/js/test-switch-4.js create mode 100644 es2panda/test/parser/js/test-switch-5-expected.txt create mode 100644 es2panda/test/parser/js/test-switch-5.js create mode 100644 es2panda/test/parser/js/test-switch-6-expected.txt create mode 100644 es2panda/test/parser/js/test-switch-6.js create mode 100644 es2panda/test/parser/js/test-switch-expected.txt create mode 100644 es2panda/test/parser/js/test-switch.js create mode 100644 es2panda/test/parser/js/test-tagged-template-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-tagged-template-expression.js create mode 100644 es2panda/test/parser/js/test-template-literal-1-expected.txt create mode 100644 es2panda/test/parser/js/test-template-literal-1.js create mode 100644 es2panda/test/parser/js/test-template-literal-2-expected.txt create mode 100644 es2panda/test/parser/js/test-template-literal-2.js create mode 100644 es2panda/test/parser/js/test-template-literal-expected.txt create mode 100644 es2panda/test/parser/js/test-template-literal.js create mode 100644 es2panda/test/parser/js/test-this-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-this-expression.js create mode 100644 es2panda/test/parser/js/test-throw-statement-expected.txt create mode 100644 es2panda/test/parser/js/test-throw-statement-without-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-throw-statement-without-expression.js create mode 100644 es2panda/test/parser/js/test-throw-statement.js create mode 100644 es2panda/test/parser/js/test-try-catch-lexical-declaration-expected.txt create mode 100644 es2panda/test/parser/js/test-try-catch-lexical-declaration.js create mode 100644 es2panda/test/parser/js/test-try-statement-expected.txt create mode 100644 es2panda/test/parser/js/test-try-statement.js create mode 100644 es2panda/test/parser/js/test-try-without-catch-and-finally-expected.txt create mode 100644 es2panda/test/parser/js/test-try-without-catch-and-finally.js create mode 100644 es2panda/test/parser/js/test-unary-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-unary-expression.js create mode 100644 es2panda/test/parser/js/test-update-expression-expected.txt create mode 100644 es2panda/test/parser/js/test-update-expression.js create mode 100644 es2panda/test/parser/js/test-use-strict-1-expected.txt create mode 100644 es2panda/test/parser/js/test-use-strict-1.js create mode 100644 es2panda/test/parser/js/test-use-strict-2-expected.txt create mode 100644 es2panda/test/parser/js/test-use-strict-2.js create mode 100644 es2panda/test/parser/js/test-var-decl-expected.txt create mode 100644 es2panda/test/parser/js/test-var-decl.js create mode 100644 es2panda/test/parser/js/test-wrong-function-decl-1-expected.txt create mode 100644 es2panda/test/parser/js/test-wrong-function-decl-1.js create mode 100644 es2panda/test/parser/js/test-wrong-function-decl-2-expected.txt create mode 100644 es2panda/test/parser/js/test-wrong-function-decl-2.js create mode 100644 es2panda/test/parser/js/test-wrong-function-decl-3-expected.txt create mode 100644 es2panda/test/parser/js/test-wrong-function-decl-3.js create mode 100644 es2panda/test/parser/js/this-expression-expected.txt create mode 100644 es2panda/test/parser/js/this-expression.js create mode 100644 es2panda/test/parser/ts/test-arrow-function-expected.txt create mode 100644 es2panda/test/parser/ts/test-arrow-function.ts create mode 100644 es2panda/test/parser/ts/test-as-expression-expected.txt create mode 100644 es2panda/test/parser/ts/test-as-expression.ts create mode 100644 es2panda/test/parser/ts/test-class-constructor-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-constructor.ts create mode 100644 es2panda/test/parser/ts/test-class-constructor1-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-constructor1.ts create mode 100644 es2panda/test/parser/ts/test-class-constructor2-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-constructor2.ts create mode 100644 es2panda/test/parser/ts/test-class-constructor3-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-constructor3.ts create mode 100644 es2panda/test/parser/ts/test-class-constructor4-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-constructor4.ts create mode 100644 es2panda/test/parser/ts/test-class-constructor5-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-constructor5.ts create mode 100644 es2panda/test/parser/ts/test-class-definition-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definition.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton1-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton1.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton10-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton10.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton11-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton11.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton12-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton12.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton13-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton13.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton14-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton14.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton15-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton15.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton16-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton16.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton17-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton17.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton18-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton18.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton2-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton2.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton3-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton3.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton4-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton4.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton5-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton5.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton6-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton6.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton7-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton7.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton8-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton8.ts create mode 100644 es2panda/test/parser/ts/test-class-definiton9-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-definiton9.ts create mode 100644 es2panda/test/parser/ts/test-class-method-overload-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-method-overload.ts create mode 100644 es2panda/test/parser/ts/test-class-method-overload1-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-method-overload1.ts create mode 100644 es2panda/test/parser/ts/test-class-method-overload10-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-method-overload10.ts create mode 100644 es2panda/test/parser/ts/test-class-method-overload11-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-method-overload11.ts create mode 100644 es2panda/test/parser/ts/test-class-method-overload12-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-method-overload12.ts create mode 100644 es2panda/test/parser/ts/test-class-method-overload13-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-method-overload13.ts create mode 100644 es2panda/test/parser/ts/test-class-method-overload2-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-method-overload2.ts create mode 100644 es2panda/test/parser/ts/test-class-method-overload3-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-method-overload3.ts create mode 100644 es2panda/test/parser/ts/test-class-method-overload4-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-method-overload4.ts create mode 100644 es2panda/test/parser/ts/test-class-method-overload5-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-method-overload5.ts create mode 100644 es2panda/test/parser/ts/test-class-method-overload6-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-method-overload6.ts create mode 100644 es2panda/test/parser/ts/test-class-method-overload7-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-method-overload7.ts create mode 100644 es2panda/test/parser/ts/test-class-method-overload8-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-method-overload8.ts create mode 100644 es2panda/test/parser/ts/test-class-method-overload9-expected.txt create mode 100644 es2panda/test/parser/ts/test-class-method-overload9.ts create mode 100644 es2panda/test/parser/ts/test-enum-declaration-expected.txt create mode 100644 es2panda/test/parser/ts/test-enum-declaration.ts create mode 100644 es2panda/test/parser/ts/test-enum-declaration1-expected.txt create mode 100644 es2panda/test/parser/ts/test-enum-declaration1.ts create mode 100644 es2panda/test/parser/ts/test-enum-declaration2-expected.txt create mode 100644 es2panda/test/parser/ts/test-enum-declaration2.ts create mode 100644 es2panda/test/parser/ts/test-enum-declaration3-expected.txt create mode 100644 es2panda/test/parser/ts/test-enum-declaration3.ts create mode 100644 es2panda/test/parser/ts/test-enum-declaration4-expected.txt create mode 100644 es2panda/test/parser/ts/test-enum-declaration4.ts create mode 100644 es2panda/test/parser/ts/test-enum-declaration5-expected.txt create mode 100644 es2panda/test/parser/ts/test-enum-declaration5.ts create mode 100644 es2panda/test/parser/ts/test-func-decl1-expected.txt create mode 100644 es2panda/test/parser/ts/test-func-decl1.ts create mode 100644 es2panda/test/parser/ts/test-func-param-expected.txt create mode 100644 es2panda/test/parser/ts/test-func-param.ts create mode 100644 es2panda/test/parser/ts/test-func-param1-expected.txt create mode 100644 es2panda/test/parser/ts/test-func-param1.ts create mode 100644 es2panda/test/parser/ts/test-func-param2-expected.txt create mode 100644 es2panda/test/parser/ts/test-func-param2.ts create mode 100644 es2panda/test/parser/ts/test-func-param3-expected.txt create mode 100644 es2panda/test/parser/ts/test-func-param3.ts create mode 100644 es2panda/test/parser/ts/test-func-param4-expected.txt create mode 100644 es2panda/test/parser/ts/test-func-param4.ts create mode 100644 es2panda/test/parser/ts/test-func-param5-expected.txt create mode 100644 es2panda/test/parser/ts/test-func-param5.ts create mode 100644 es2panda/test/parser/ts/test-func-param6-expected.txt create mode 100644 es2panda/test/parser/ts/test-func-param6.ts create mode 100644 es2panda/test/parser/ts/test-func-param7-expected.txt create mode 100644 es2panda/test/parser/ts/test-func-param7.ts create mode 100644 es2panda/test/parser/ts/test-func-param8-expected.txt create mode 100644 es2panda/test/parser/ts/test-func-param8.ts create mode 100644 es2panda/test/parser/ts/test-function-overload-expected.txt create mode 100644 es2panda/test/parser/ts/test-function-overload.ts create mode 100644 es2panda/test/parser/ts/test-function-overload1-expected.txt create mode 100644 es2panda/test/parser/ts/test-function-overload1.ts create mode 100644 es2panda/test/parser/ts/test-function-overload2-expected.txt create mode 100644 es2panda/test/parser/ts/test-function-overload2.ts create mode 100644 es2panda/test/parser/ts/test-if-expected.txt create mode 100644 es2panda/test/parser/ts/test-if.ts create mode 100644 es2panda/test/parser/ts/test-interface-expected.txt create mode 100644 es2panda/test/parser/ts/test-interface.ts create mode 100644 es2panda/test/parser/ts/test-interface1-expected.txt create mode 100644 es2panda/test/parser/ts/test-interface1.ts create mode 100644 es2panda/test/parser/ts/test-interface2-expected.txt create mode 100644 es2panda/test/parser/ts/test-interface2.ts create mode 100644 es2panda/test/parser/ts/test-interface3-expected.txt create mode 100644 es2panda/test/parser/ts/test-interface3.ts create mode 100644 es2panda/test/parser/ts/test-intersection-expected.txt create mode 100644 es2panda/test/parser/ts/test-intersection.ts create mode 100644 es2panda/test/parser/ts/test-intersection1-expected.txt create mode 100644 es2panda/test/parser/ts/test-intersection1.ts create mode 100644 es2panda/test/parser/ts/test-intersection2-expected.txt create mode 100644 es2panda/test/parser/ts/test-intersection2.ts create mode 100644 es2panda/test/parser/ts/test-intersection3-expected.txt create mode 100644 es2panda/test/parser/ts/test-intersection3.ts create mode 100644 es2panda/test/parser/ts/test-keyword-declare-expected.txt create mode 100644 es2panda/test/parser/ts/test-keyword-declare.ts create mode 100644 es2panda/test/parser/ts/test-keyword-declare1-expected.txt create mode 100644 es2panda/test/parser/ts/test-keyword-declare1.ts create mode 100644 es2panda/test/parser/ts/test-keyword-declare10-expected.txt create mode 100644 es2panda/test/parser/ts/test-keyword-declare10.ts create mode 100644 es2panda/test/parser/ts/test-keyword-declare11-expected.txt create mode 100644 es2panda/test/parser/ts/test-keyword-declare11.ts create mode 100644 es2panda/test/parser/ts/test-keyword-declare12-expected.txt create mode 100644 es2panda/test/parser/ts/test-keyword-declare12.ts create mode 100644 es2panda/test/parser/ts/test-keyword-declare13-expected.txt create mode 100644 es2panda/test/parser/ts/test-keyword-declare13.ts create mode 100644 es2panda/test/parser/ts/test-keyword-declare2-expected.txt create mode 100644 es2panda/test/parser/ts/test-keyword-declare2.ts create mode 100644 es2panda/test/parser/ts/test-keyword-declare3-expected.txt create mode 100644 es2panda/test/parser/ts/test-keyword-declare3.ts create mode 100644 es2panda/test/parser/ts/test-keyword-declare4-expected.txt create mode 100644 es2panda/test/parser/ts/test-keyword-declare4.ts create mode 100644 es2panda/test/parser/ts/test-keyword-declare5-expected.txt create mode 100644 es2panda/test/parser/ts/test-keyword-declare5.ts create mode 100644 es2panda/test/parser/ts/test-keyword-declare6-expected.txt create mode 100644 es2panda/test/parser/ts/test-keyword-declare6.ts create mode 100644 es2panda/test/parser/ts/test-keyword-declare7-expected.txt create mode 100644 es2panda/test/parser/ts/test-keyword-declare7.ts create mode 100644 es2panda/test/parser/ts/test-keyword-declare8-expected.txt create mode 100644 es2panda/test/parser/ts/test-keyword-declare8.ts create mode 100644 es2panda/test/parser/ts/test-keyword-declare9-expected.txt create mode 100644 es2panda/test/parser/ts/test-keyword-declare9.ts create mode 100644 es2panda/test/parser/ts/test-member-expression1-expected.txt create mode 100644 es2panda/test/parser/ts/test-member-expression1.ts create mode 100644 es2panda/test/parser/ts/test-member-expression2-expected.txt create mode 100644 es2panda/test/parser/ts/test-member-expression2.ts create mode 100644 es2panda/test/parser/ts/test-ts-as-expression-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-as-expression.ts create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type.ts create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type1-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type1.ts create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type2-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type2.ts create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type3-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type3.ts create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type4-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type4.ts create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type5-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type5.ts create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type6-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type6.ts create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type7-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-conditional-type7.ts create mode 100644 es2panda/test/parser/ts/test-ts-constructor-type1-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-constructor-type1.ts create mode 100644 es2panda/test/parser/ts/test-ts-constructor-type2-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-constructor-type2.ts create mode 100644 es2panda/test/parser/ts/test-ts-constructor-type3-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-constructor-type3.ts create mode 100644 es2panda/test/parser/ts/test-ts-constructor-type4-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-constructor-type4.ts create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type.ts create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type1-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type1.ts create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type2-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type2.ts create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type3-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type3.ts create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type4-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type4.ts create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type5-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type5.ts create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type6-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type6.ts create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type7-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-mapped-type7.ts create mode 100644 es2panda/test/parser/ts/test-ts-non-null-expression-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-non-null-expression.ts create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property.ts create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property1-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property1.ts create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property10-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property10.ts create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property11-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property11.ts create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property12-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property12.ts create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property2-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property2.ts create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property3-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property3.ts create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property4-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property4.ts create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property5-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property5.ts create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property6-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property6.ts create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property7-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property7.ts create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property8-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property8.ts create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property9-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-parameter-property9.ts create mode 100644 es2panda/test/parser/ts/test-ts-type-assertion-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-type-assertion.ts create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate.ts create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate1-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate1.ts create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate2-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate2.ts create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate3-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate3.ts create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate4-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate4.ts create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate5-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate5.ts create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate6-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate6.ts create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate7-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate7.ts create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate8-expected.txt create mode 100644 es2panda/test/parser/ts/test-ts-type-predicate8.ts create mode 100644 es2panda/test/parser/ts/test-tuple-type-expected.txt create mode 100644 es2panda/test/parser/ts/test-tuple-type.ts create mode 100644 es2panda/test/parser/ts/test-tuple-type1-expected.txt create mode 100644 es2panda/test/parser/ts/test-tuple-type1.ts create mode 100644 es2panda/test/parser/ts/test-tuple-type2-expected.txt create mode 100644 es2panda/test/parser/ts/test-tuple-type2.ts create mode 100644 es2panda/test/parser/ts/test-tuple-type3-expected.txt create mode 100644 es2panda/test/parser/ts/test-tuple-type3.ts create mode 100644 es2panda/test/parser/ts/test-tuple-type4-expected.txt create mode 100644 es2panda/test/parser/ts/test-tuple-type4.ts create mode 100644 es2panda/test/parser/ts/test-type-alias-expected.txt create mode 100644 es2panda/test/parser/ts/test-type-alias.ts create mode 100644 es2panda/test/parser/ts/test-type-alias1-expected.txt create mode 100644 es2panda/test/parser/ts/test-type-alias1.ts create mode 100644 es2panda/test/parser/ts/test-type-alias2-expected.txt create mode 100644 es2panda/test/parser/ts/test-type-alias2.ts create mode 100644 es2panda/test/parser/ts/test-type-alias3-expected.txt create mode 100644 es2panda/test/parser/ts/test-type-alias3.ts create mode 100644 es2panda/test/parser/ts/test-type-annotation-expected.txt create mode 100644 es2panda/test/parser/ts/test-type-annotation.ts create mode 100644 es2panda/test/parser/ts/test-type-literal-expected.txt create mode 100644 es2panda/test/parser/ts/test-type-literal.ts create mode 100644 es2panda/test/parser/ts/test-type-literal1-expected.txt create mode 100644 es2panda/test/parser/ts/test-type-literal1.ts create mode 100644 es2panda/test/parser/ts/test-type-literal2-expected.txt create mode 100644 es2panda/test/parser/ts/test-type-literal2.ts create mode 100644 es2panda/test/parser/ts/test-type-literal3-expected.txt create mode 100644 es2panda/test/parser/ts/test-type-literal3.ts create mode 100644 es2panda/test/parser/ts/test-type-query-expected.txt create mode 100644 es2panda/test/parser/ts/test-type-query.ts create mode 100644 es2panda/test/parser/ts/test-type-query1-expected.txt create mode 100644 es2panda/test/parser/ts/test-type-query1.ts create mode 100644 es2panda/test/parser/ts/test-type-query2-expected.txt create mode 100644 es2panda/test/parser/ts/test-type-query2.ts create mode 100644 es2panda/test/parser/ts/test_decorator-expected.txt create mode 100644 es2panda/test/parser/ts/test_decorator.ts create mode 100644 es2panda/test/parser/ts/test_decorator1-expected.txt create mode 100644 es2panda/test/parser/ts/test_decorator1.ts create mode 100644 es2panda/test/parser/ts/test_decorator2-expected.txt create mode 100644 es2panda/test/parser/ts/test_decorator2.ts create mode 100644 es2panda/test/parser/ts/test_decorator3-expected.txt create mode 100644 es2panda/test/parser/ts/test_decorator3.ts create mode 100644 es2panda/test/parser/ts/test_decorator4-expected.txt create mode 100644 es2panda/test/parser/ts/test_decorator4.ts create mode 100644 es2panda/test/parser/ts/test_decorator5-expected.txt create mode 100644 es2panda/test/parser/ts/test_decorator5.ts create mode 100644 es2panda/test/parser/ts/test_decorator6-expected.txt create mode 100644 es2panda/test/parser/ts/test_decorator6.ts create mode 100644 es2panda/test/parser/ts/test_decorator7-expected.txt create mode 100644 es2panda/test/parser/ts/test_decorator7.ts create mode 100644 es2panda/test/parser/ts/test_decorator8-expected.txt create mode 100644 es2panda/test/parser/ts/test_decorator8.ts create mode 100644 es2panda/test/parser/ts/test_generic-expected.txt create mode 100644 es2panda/test/parser/ts/test_generic.ts create mode 100644 es2panda/test/parser/ts/test_import_type-expected.txt create mode 100644 es2panda/test/parser/ts/test_import_type.ts create mode 100644 es2panda/test/parser/ts/test_module-expected.txt create mode 100644 es2panda/test/parser/ts/test_module.ts create mode 100644 es2panda/test/parser/ts/test_module1-expected.txt create mode 100644 es2panda/test/parser/ts/test_module1.ts create mode 100644 es2panda/test/parser/ts/test_module2-expected.txt create mode 100644 es2panda/test/parser/ts/test_module2.ts create mode 100644 es2panda/test/parser/ts/test_module3-expected.txt create mode 100644 es2panda/test/parser/ts/test_module3.ts create mode 100644 es2panda/test/parser/ts/test_module4-expected.txt create mode 100644 es2panda/test/parser/ts/test_module4.ts create mode 100644 es2panda/test/parser/ts/test_module5-expected.txt create mode 100644 es2panda/test/parser/ts/test_module5.ts create mode 100644 es2panda/test/parser/ts/test_module6-expected.txt create mode 100644 es2panda/test/parser/ts/test_module6.ts create mode 100644 es2panda/test/parser/ts/test_this_type-expected.txt create mode 100644 es2panda/test/parser/ts/test_this_type.ts create mode 100644 es2panda/test/parser/ts/test_this_type1-expected.txt create mode 100644 es2panda/test/parser/ts/test_this_type1.ts create mode 100644 es2panda/test/parser/ts/test_this_type2-expected.txt create mode 100644 es2panda/test/parser/ts/test_this_type2.ts create mode 100644 es2panda/test/runner.py create mode 100644 es2panda/test/test262harness.js create mode 100644 es2panda/test/test262skiplist-bco.txt create mode 100644 es2panda/test/test262skiplist-compiler-arm64.txt create mode 100644 es2panda/test/test262skiplist-flaky.txt create mode 100644 es2panda/test/test262skiplist-long.txt create mode 100644 es2panda/test/test262skiplist.txt create mode 100644 es2panda/test/test262util.py create mode 100644 es2panda/typescript/checker.cpp create mode 100644 es2panda/typescript/checker.h create mode 100644 es2panda/typescript/core/binaryLikeExpression.cpp create mode 100644 es2panda/typescript/core/destructuring.cpp create mode 100644 es2panda/typescript/core/function.cpp create mode 100644 es2panda/typescript/core/generics.cpp create mode 100644 es2panda/typescript/core/helpers.cpp create mode 100644 es2panda/typescript/core/object.cpp create mode 100644 es2panda/typescript/core/typeCreation.cpp create mode 100644 es2panda/typescript/core/typeElaboration.cpp create mode 100644 es2panda/typescript/core/typeRelation.cpp create mode 100644 es2panda/typescript/core/util.cpp create mode 100644 es2panda/typescript/types/anyType.cpp create mode 100644 es2panda/typescript/types/anyType.h create mode 100644 es2panda/typescript/types/arrayType.cpp create mode 100644 es2panda/typescript/types/arrayType.h create mode 100644 es2panda/typescript/types/bigintLiteralType.cpp create mode 100644 es2panda/typescript/types/bigintLiteralType.h create mode 100644 es2panda/typescript/types/bigintType.cpp create mode 100644 es2panda/typescript/types/bigintType.h create mode 100644 es2panda/typescript/types/booleanLiteralType.cpp create mode 100644 es2panda/typescript/types/booleanLiteralType.h create mode 100644 es2panda/typescript/types/booleanType.cpp create mode 100644 es2panda/typescript/types/booleanType.h create mode 100644 es2panda/typescript/types/constructorType.cpp create mode 100644 es2panda/typescript/types/constructorType.h create mode 100644 es2panda/typescript/types/elementFlags.h create mode 100644 es2panda/typescript/types/enumLiteralType.cpp create mode 100644 es2panda/typescript/types/enumLiteralType.h create mode 100644 es2panda/typescript/types/enumType.cpp create mode 100644 es2panda/typescript/types/enumType.h create mode 100644 es2panda/typescript/types/functionType.cpp create mode 100644 es2panda/typescript/types/functionType.h create mode 100644 es2panda/typescript/types/globalTypesHolder.cpp create mode 100644 es2panda/typescript/types/globalTypesHolder.h create mode 100644 es2panda/typescript/types/indexInfo.cpp create mode 100644 es2panda/typescript/types/indexInfo.h create mode 100644 es2panda/typescript/types/interfaceType.cpp create mode 100644 es2panda/typescript/types/interfaceType.h create mode 100644 es2panda/typescript/types/neverType.cpp create mode 100644 es2panda/typescript/types/neverType.h create mode 100644 es2panda/typescript/types/nonPrimitiveType.cpp create mode 100644 es2panda/typescript/types/nonPrimitiveType.h create mode 100644 es2panda/typescript/types/nullType.cpp create mode 100644 es2panda/typescript/types/nullType.h create mode 100644 es2panda/typescript/types/numberLiteralType.cpp create mode 100644 es2panda/typescript/types/numberLiteralType.h create mode 100644 es2panda/typescript/types/numberType.cpp create mode 100644 es2panda/typescript/types/numberType.h create mode 100644 es2panda/typescript/types/objectDescriptor.cpp create mode 100644 es2panda/typescript/types/objectDescriptor.h create mode 100644 es2panda/typescript/types/objectLiteralType.cpp create mode 100644 es2panda/typescript/types/objectLiteralType.h create mode 100644 es2panda/typescript/types/objectType.cpp create mode 100644 es2panda/typescript/types/objectType.h create mode 100644 es2panda/typescript/types/signature.cpp create mode 100644 es2panda/typescript/types/signature.h create mode 100644 es2panda/typescript/types/stringLiteralType.cpp create mode 100644 es2panda/typescript/types/stringLiteralType.h create mode 100644 es2panda/typescript/types/stringType.cpp create mode 100644 es2panda/typescript/types/stringType.h create mode 100644 es2panda/typescript/types/tupleType.cpp create mode 100644 es2panda/typescript/types/tupleType.h create mode 100644 es2panda/typescript/types/type.cpp create mode 100644 es2panda/typescript/types/type.h create mode 100644 es2panda/typescript/types/typeFacts.h create mode 100644 es2panda/typescript/types/typeFlag.h create mode 100644 es2panda/typescript/types/typeMapping.h create mode 100644 es2panda/typescript/types/typeParameter.cpp create mode 100644 es2panda/typescript/types/typeParameter.h create mode 100644 es2panda/typescript/types/typeReference.cpp create mode 100644 es2panda/typescript/types/typeReference.h create mode 100644 es2panda/typescript/types/typeRelation.cpp create mode 100644 es2panda/typescript/types/typeRelation.h create mode 100644 es2panda/typescript/types/types.h create mode 100644 es2panda/typescript/types/undefinedType.cpp create mode 100644 es2panda/typescript/types/undefinedType.h create mode 100644 es2panda/typescript/types/unionType.cpp create mode 100644 es2panda/typescript/types/unionType.h create mode 100644 es2panda/typescript/types/unknownType.cpp create mode 100644 es2panda/typescript/types/unknownType.h create mode 100644 es2panda/typescript/types/voidType.cpp create mode 100644 es2panda/typescript/types/voidType.h create mode 100644 es2panda/util/bitset.cpp create mode 100644 es2panda/util/bitset.h create mode 100644 es2panda/util/enumbitops.h create mode 100644 es2panda/util/helpers.cpp create mode 100644 es2panda/util/helpers.h create mode 100644 es2panda/util/ustring.cpp create mode 100644 es2panda/util/ustring.h diff --git a/es2panda/CMakeLists.txt b/es2panda/CMakeLists.txt new file mode 100644 index 0000000000..58cbe2c823 --- /dev/null +++ b/es2panda/CMakeLists.txt @@ -0,0 +1,337 @@ +# Copyright (c) 2021-2022 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. + +cmake_minimum_required (VERSION 3.5.0) + +project (es2panda) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +set(OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/out) +set(GENERATED_DIR ${OUTPUT_DIR}/gen) +set(GENERATED_STAMP ${OUTPUT_DIR}/gen_dir.stamp) +add_custom_target(es2panda-gen) + +add_custom_command( + OUTPUT ${GENERATED_STAMP} + COMMAND ${CMAKE_COMMAND} -E make_directory ${OUTPUT_DIR} + COMMAND ${CMAKE_COMMAND} -E make_directory ${GENERATED_DIR} + COMMAND ${CMAKE_COMMAND} -E touch ${GENERATED_STAMP} +) + +set(TEMPLATES + isa.h.erb + formats.h.erb +) + +panda_isa_gen( + TEMPLATES ${TEMPLATES} + SOURCE ${CMAKE_CURRENT_LIST_DIR}/compiler/templates + DESTINATION ${GENERATED_DIR} + EXTRA_DEPENDENCIES ${GENERATED_STAMP} +) + +add_dependencies(es2panda-gen isa_gen_es2panda) + +function(gen_keywords TEMPLATE OUT_DIR) + set(TEMPLATE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/lexer/templates/${TEMPLATE}) + + string(REGEX REPLACE "\.erb$" "" NAME ${TEMPLATE}) + string(REPLACE "\." "_" CUSTOM_TARGET ${NAME}) + string(REPLACE "/" "_" CUSTOM_TARGET ${CUSTOM_TARGET}) + set(CUSTOM_TARGET "panda_es2panda_parser_gen_${CUSTOM_TARGET}") + + set(OUT_FILE ${OUT_DIR}/${NAME}) + set(GENERATOR ${CMAKE_CURRENT_SOURCE_DIR}/lexer/scripts/keywords.rb) + + add_custom_command(OUTPUT ${OUT_FILE} + COMMAND ruby ${GENERATOR} ${TEMPLATE_FILE} ${OUT_FILE} + DEPENDS ${GENERATED_STAMP} ${GENERATOR} ${TEMPLATE_FILE} + ) + + add_custom_target(${CUSTOM_TARGET} DEPENDS ${OUT_FILE}) + add_dependencies(es2panda-gen ${CUSTOM_TARGET}) +endfunction() + +gen_keywords(keywords.h.erb ${GENERATED_DIR}) +gen_keywords(keywordsMap.h.erb ${GENERATED_DIR}) + +set(ES2PANDA_LIB_SRC + es2panda.cpp + binder/binder.cpp + binder/declaration.cpp + binder/scope.cpp + binder/variable.cpp + compiler/base/catchTable.cpp + compiler/base/condition.cpp + compiler/base/destructuring.cpp + compiler/base/hoisting.cpp + compiler/base/iterators.cpp + compiler/base/lexenv.cpp + compiler/base/literals.cpp + compiler/base/lreference.cpp + compiler/core/compileQueue.cpp + compiler/core/compilerContext.cpp + compiler/core/compilerImpl.cpp + compiler/core/dynamicContext.cpp + compiler/core/emitter.cpp + compiler/core/envScope.cpp + compiler/core/function.cpp + compiler/core/inlineCache.cpp + compiler/core/labelTarget.cpp + compiler/core/moduleContext.cpp + compiler/core/pandagen.cpp + compiler/core/regAllocator.cpp + compiler/core/regScope.cpp + compiler/core/switchBuilder.cpp + compiler/debugger/debuginfoDumper.cpp + compiler/function/asyncFunctionBuilder.cpp + compiler/function/asyncGeneratorFunctionBuilder.cpp + compiler/function/functionBuilder.cpp + compiler/function/generatorFunctionBuilder.cpp + ir/astDump.cpp + ir/base/catchClause.cpp + ir/base/classDefinition.cpp + ir/base/classProperty.cpp + ir/base/decorator.cpp + ir/base/metaProperty.cpp + ir/base/methodDefinition.cpp + ir/base/property.cpp + ir/base/scriptFunction.cpp + ir/base/spreadElement.cpp + ir/base/templateElement.cpp + ir/expression.cpp + ir/expressions/arrayExpression.cpp + ir/expressions/arrowFunctionExpression.cpp + ir/expressions/assignmentExpression.cpp + ir/expressions/awaitExpression.cpp + ir/expressions/binaryExpression.cpp + ir/expressions/callExpression.cpp + ir/expressions/chainExpression.cpp + ir/expressions/classExpression.cpp + ir/expressions/conditionalExpression.cpp + ir/expressions/functionExpression.cpp + ir/expressions/identifier.cpp + ir/expressions/importExpression.cpp + ir/expressions/literal.cpp + ir/expressions/literals/bigIntLiteral.cpp + ir/expressions/literals/booleanLiteral.cpp + ir/expressions/literals/nullLiteral.cpp + ir/expressions/literals/numberLiteral.cpp + ir/expressions/literals/regExpLiteral.cpp + ir/expressions/literals/stringLiteral.cpp + ir/expressions/literals/taggedLiteral.cpp + ir/expressions/memberExpression.cpp + ir/expressions/newExpression.cpp + ir/expressions/objectExpression.cpp + ir/expressions/omittedExpression.cpp + ir/expressions/sequenceExpression.cpp + ir/expressions/superExpression.cpp + ir/expressions/taggedTemplateExpression.cpp + ir/expressions/templateLiteral.cpp + ir/expressions/thisExpression.cpp + ir/expressions/unaryExpression.cpp + ir/expressions/updateExpression.cpp + ir/expressions/yieldExpression.cpp + ir/module/exportAllDeclaration.cpp + ir/module/exportDefaultDeclaration.cpp + ir/module/exportNamedDeclaration.cpp + ir/module/exportSpecifier.cpp + ir/module/importDeclaration.cpp + ir/module/importDefaultSpecifier.cpp + ir/module/importNamespaceSpecifier.cpp + ir/module/importSpecifier.cpp + ir/statement.cpp + ir/statements/blockStatement.cpp + ir/statements/breakStatement.cpp + ir/statements/classDeclaration.cpp + ir/statements/continueStatement.cpp + ir/statements/debuggerStatement.cpp + ir/statements/doWhileStatement.cpp + ir/statements/emptyStatement.cpp + ir/statements/expressionStatement.cpp + ir/statements/forInStatement.cpp + ir/statements/forOfStatement.cpp + ir/statements/forUpdateStatement.cpp + ir/statements/functionDeclaration.cpp + ir/statements/ifStatement.cpp + ir/statements/labelledStatement.cpp + ir/statements/loopStatement.cpp + ir/statements/returnStatement.cpp + ir/statements/switchCaseStatement.cpp + ir/statements/switchStatement.cpp + ir/statements/throwStatement.cpp + ir/statements/tryStatement.cpp + ir/statements/variableDeclaration.cpp + ir/statements/variableDeclarator.cpp + ir/statements/whileStatement.cpp + ir/ts/tsAnyKeyword.cpp + ir/ts/tsArrayType.cpp + ir/ts/tsAsExpression.cpp + ir/ts/tsBigintKeyword.cpp + ir/ts/tsBooleanKeyword.cpp + ir/ts/tsClassImplements.cpp + ir/ts/tsConditionalType.cpp + ir/ts/tsConstructorType.cpp + ir/ts/tsEnumDeclaration.cpp + ir/ts/tsEnumMember.cpp + ir/ts/tsExternalModuleReference.cpp + ir/ts/tsFunctionType.cpp + ir/ts/tsImportEqualsDeclaration.cpp + ir/ts/tsImportType.cpp + ir/ts/tsIndexSignature.cpp + ir/ts/tsIndexedAccessType.cpp + ir/ts/tsInferType.cpp + ir/ts/tsInterfaceBody.cpp + ir/ts/tsInterfaceDeclaration.cpp + ir/ts/tsInterfaceHeritage.cpp + ir/ts/tsIntersectionType.cpp + ir/ts/tsLiteralType.cpp + ir/ts/tsMappedType.cpp + ir/ts/tsMethodSignature.cpp + ir/ts/tsModuleBlock.cpp + ir/ts/tsModuleDeclaration.cpp + ir/ts/tsNamedTupleMember.cpp + ir/ts/tsNeverKeyword.cpp + ir/ts/tsNonNullExpression.cpp + ir/ts/tsNullKeyword.cpp + ir/ts/tsNumberKeyword.cpp + ir/ts/tsObjectKeyword.cpp + ir/ts/tsParameterProperty.cpp + ir/ts/tsParenthesizedType.cpp + ir/ts/tsPrivateIdentifier.cpp + ir/ts/tsPropertySignature.cpp + ir/ts/tsQualifiedName.cpp + ir/ts/tsSignatureDeclaration.cpp + ir/ts/tsStringKeyword.cpp + ir/ts/tsThisType.cpp + ir/ts/tsTupleType.cpp + ir/ts/tsTypeAliasDeclaration.cpp + ir/ts/tsTypeAssertion.cpp + ir/ts/tsTypeLiteral.cpp + ir/ts/tsTypeOperator.cpp + ir/ts/tsTypeParameter.cpp + ir/ts/tsTypeParameterDeclaration.cpp + ir/ts/tsTypeParameterInstantiation.cpp + ir/ts/tsTypePredicate.cpp + ir/ts/tsTypeQuery.cpp + ir/ts/tsTypeReference.cpp + ir/ts/tsUndefinedKeyword.cpp + ir/ts/tsUnionType.cpp + ir/ts/tsUnknownKeyword.cpp + ir/ts/tsVoidKeyword.cpp + lexer/keywordsUtil.cpp + lexer/lexer.cpp + lexer/regexp/regexp.cpp + lexer/token/sourceLocation.cpp + lexer/token/token.cpp + parser/context/parserContext.cpp + parser/expressionParser.cpp + parser/parserImpl.cpp + parser/program/program.cpp + parser/statementParser.cpp + typescript/checker.cpp + typescript/core/binaryLikeExpression.cpp + typescript/core/destructuring.cpp + typescript/core/function.cpp + typescript/core/generics.cpp + typescript/core/helpers.cpp + typescript/core/object.cpp + typescript/core/typeCreation.cpp + typescript/core/typeElaboration.cpp + typescript/core/typeRelation.cpp + typescript/core/util.cpp + typescript/types/anyType.cpp + typescript/types/arrayType.cpp + typescript/types/bigintLiteralType.cpp + typescript/types/bigintType.cpp + typescript/types/booleanLiteralType.cpp + typescript/types/booleanType.cpp + typescript/types/constructorType.cpp + typescript/types/enumLiteralType.cpp + typescript/types/enumType.cpp + typescript/types/functionType.cpp + typescript/types/globalTypesHolder.cpp + typescript/types/indexInfo.cpp + typescript/types/interfaceType.cpp + typescript/types/neverType.cpp + typescript/types/nonPrimitiveType.cpp + typescript/types/nullType.cpp + typescript/types/numberLiteralType.cpp + typescript/types/numberType.cpp + typescript/types/objectDescriptor.cpp + typescript/types/objectLiteralType.cpp + typescript/types/objectType.cpp + typescript/types/signature.cpp + typescript/types/stringLiteralType.cpp + typescript/types/stringType.cpp + typescript/types/tupleType.cpp + typescript/types/type.cpp + typescript/types/typeParameter.cpp + typescript/types/typeReference.cpp + typescript/types/typeRelation.cpp + typescript/types/undefinedType.cpp + typescript/types/unionType.cpp + typescript/types/unknownType.cpp + typescript/types/voidType.cpp + util/bitset.cpp + util/helpers.cpp + util/ustring.cpp +) + +add_library(es2panda-lib ${PANDA_DEFAULT_LIB_TYPE} ${ES2PANDA_LIB_SRC}) +add_dependencies(es2panda-lib es2panda-gen) + +set(ICU_INCLUDE_DIRS + ${PANDA_THIRD_PARTY_SOURCES_DIR}/icu/icu4c/source/common + ${PANDA_THIRD_PARTY_SOURCES_DIR}/icu/icu4c/source/i18n + ${PANDA_THIRD_PARTY_SOURCES_DIR}/icu/icu4c/source +) + +target_include_directories(es2panda-lib + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${OUTPUT_DIR} + PRIVATE ${ICU_INCLUDE_DIRS} +) + +target_compile_options(es2panda-lib + PRIVATE -fexceptions -Werror=shadow +) + +target_link_libraries(es2panda-lib + PUBLIC arkbase hmicuuc.z + PRIVATE arkassembler +) + +if (PANDA_FUZZILLI) + target_compile_options(es2panda-lib + PRIVATE -fPIC + ) +endif() + +panda_add_sanitizers(TARGET es2panda-lib SANITIZERS ${PANDA_SANITIZERS_LIST}) +panda_add_to_clang_tidy(TARGET es2panda-lib CHECKS + "-modernize-use-trailing-return-type" + "-llvmlibc-restrict-system-libc-headers" + "-llvmlibc-callee-namespace" + "-cert-dcl21-cpp" + "-cppcoreguidelines-macro-usage" + "-cppcoreguidelines-pro-bounds-pointer-arithmetic" + "-fuchsia-default-arguments-calls" + "-fuchsia-default-arguments-declarations" + "-readability-implicit-bool-conversion" + "-misc-non-private-member-variables-in-classes" + "-hicpp-signed-bitwise" + "-altera-struct-pack-align" +) + +add_subdirectory(aot) diff --git a/es2panda/README.md b/es2panda/README.md new file mode 100644 index 0000000000..43a3d5500d --- /dev/null +++ b/es2panda/README.md @@ -0,0 +1,43 @@ +# Es2panda + +All in one JavaScript/TypeScript parser and compiler. + +## Usage +```sh +es2panda [OPTIONS] [input file] -- [arguments] +``` + +## Optional arguments + - `--debug-info`: Compile with debug info + - `--dump-assembly`: Dump pandasm + - `--dump-ast`: Dump the parsed AST + - `--dump-debug-info`: Dump debug info + - `--dump-size-stat`: Dump binary size statistics + - `--extension`: Parse the input as the given extension (options: js | ts | as) + - `--module`: Parse the input as module + - `--opt-level`: Compiler optimization level (options: 0 | 1 | 2) + - `--output`: Compiler binary output (.abc) + - `--parse-only`: Parse the input only + - `--strict`: Parse the input in strict mode + +## Tail arguments + - `input`: input file + +## Running the tests +```sh +pip install tqdm +``` +```sh +python3 test/runner.py [OPTIONS] [build_directory] +``` + +### Optional arguments + - `--regression`: Run regression tests + - `--test262`: Run test262 + - `--no-progress`: Don't show progress bar + +### Tail arguments + - `build_directory`: Path to panda build directory + +### Skip list +Skip list for the runtime: `test/test262skiplist.txt, test/test262skiplist-long.txt`. diff --git a/es2panda/aot/CMakeLists.txt b/es2panda/aot/CMakeLists.txt new file mode 100644 index 0000000000..f4c3942474 --- /dev/null +++ b/es2panda/aot/CMakeLists.txt @@ -0,0 +1,47 @@ +# Copyright (c) 2021-2022 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(ES2PANDA_AOT_SRC + options.cpp + main.cpp +) + +panda_add_executable(es2panda ${ES2PANDA_AOT_SRC}) +target_link_libraries(es2panda es2panda-lib arkassembler arkbytecodeopt) +target_include_directories(es2panda PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + +if (PANDA_FUZZILLI) + target_compile_options(es2panda + PRIVATE -fPIC + ) +endif() + +target_compile_options(es2panda + PRIVATE -Werror=shadow +) + +panda_add_sanitizers(TARGET es2panda SANITIZERS ${PANDA_SANITIZERS_LIST}) +panda_add_to_clang_tidy(TARGET es2panda CHECKS + "-modernize-use-trailing-return-type" + "-llvmlibc-restrict-system-libc-headers" + "-llvmlibc-callee-namespace" + "-cert-dcl21-cpp" + "-cppcoreguidelines-macro-usage" + "-cppcoreguidelines-pro-bounds-pointer-arithmetic" + "-fuchsia-default-arguments-calls" + "-fuchsia-default-arguments-declarations" + "-readability-implicit-bool-conversion" + "-misc-non-private-member-variables-in-classes" + "-hicpp-signed-bitwise" + "-altera-struct-pack-align" +) diff --git a/es2panda/aot/main.cpp b/es2panda/aot/main.cpp new file mode 100644 index 0000000000..8dbd680977 --- /dev/null +++ b/es2panda/aot/main.cpp @@ -0,0 +1,146 @@ +/** + * Copyright (c) 2021-2022 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 +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace panda::es2panda::aot { + +using mem::MemConfig; + +class MemManager { +public: + explicit MemManager() + { + constexpr auto COMPILER_SIZE = 128_MB; + + MemConfig::Initialize(0, 0, COMPILER_SIZE, 0); + PoolManager::Initialize(PoolType::MMAP); + } + + NO_COPY_SEMANTIC(MemManager); + NO_MOVE_SEMANTIC(MemManager); + + ~MemManager() + { + PoolManager::Finalize(); + MemConfig::Finalize(); + } +}; + +static int GenerateProgram(panda::pandasm::Program *prog, const std::string &output, int optLevel, bool dumpAsm, + bool dumpSize) +{ + std::map stat; + std::map *statp = optLevel != 0 ? &stat : nullptr; + panda::pandasm::AsmEmitter::PandaFileToPandaAsmMaps maps {}; + panda::pandasm::AsmEmitter::PandaFileToPandaAsmMaps *mapsp = optLevel != 0 ? &maps : nullptr; + +#ifdef PANDA_WITH_BYTECODE_OPTIMIZER + if (optLevel != 0) { + const uint32_t COMPONENT_MASK = panda::Logger::Component::ASSEMBLER | + panda::Logger::Component::BYTECODE_OPTIMIZER | + panda::Logger::Component::COMPILER; + panda::Logger::InitializeStdLogging(panda::Logger::Level::ERROR, COMPONENT_MASK); + + if (!panda::pandasm::AsmEmitter::Emit(output, *prog, statp, mapsp, true)) { + return 1; + } + + panda::bytecodeopt::options.SetOptLevel(optLevel); + panda::bytecodeopt::OptimizeBytecode(prog, mapsp, output, true, true); + } +#endif + + if (dumpAsm) { + es2panda::Compiler::DumpAsm(prog); + } + + if (!panda::pandasm::AsmEmitter::Emit(output, *prog, statp, mapsp, true)) { + return 1; + } + + if (dumpSize && optLevel != 0) { + size_t totalSize = 0; + std::cout << "Panda file size statistic:" << std::endl; + constexpr std::array INFO_STATS = {"instructions_number", "codesize"}; + + for (const auto &[name, size] : stat) { + if (find(INFO_STATS.begin(), INFO_STATS.end(), name) != INFO_STATS.end()) { + continue; + } + std::cout << name << " section: " << size << std::endl; + totalSize += size; + } + + for (const auto &name : INFO_STATS) { + std::cout << name << ": " << stat.at(std::string(name)) << std::endl; + } + + std::cout << "total: " << totalSize << std::endl; + } + + return 0; +} + +int Run(int argc, const char **argv) +{ + auto options = std::make_unique(); + + if (!options->Parse(argc, argv)) { + std::cerr << options->ErrorMsg() << std::endl; + return 1; + } + + es2panda::Compiler compiler(options->Extension(), options->ThreadCount()); + es2panda::SourceFile input(options->SourceFile(), options->ParserInput(), options->ParseModule()); + + auto *program = compiler.Compile(input, options->CompilerOptions()); + + if (!program) { + const auto &err = compiler.GetError(); + + if (err.Message().empty() && options->ParseOnly()) { + return 0; + } + + std::cout << err.TypeString() << ": " << err.Message(); + std::cout << " [" << options->SourceFile() << ":" << err.Line() << ":" << err.Col() << "]" << std::endl; + + return err.ErrorCode(); + } + + GenerateProgram(program, options->CompilerOutput(), options->OptLevel(), options->CompilerOptions().dumpAsm, + options->SizeStat()); + delete program; + + return 0; +} + +} // namespace panda::es2panda::aot + +int main(int argc, const char **argv) +{ + panda::es2panda::aot::MemManager mm; + return panda::es2panda::aot::Run(argc, argv); +} diff --git a/es2panda/aot/options.cpp b/es2panda/aot/options.cpp new file mode 100644 index 0000000000..9be3f001c5 --- /dev/null +++ b/es2panda/aot/options.cpp @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2021-2022 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 "options.h" + +#include + +#include + +namespace panda::es2panda::aot { + +template +T BaseName(T const &path, T const &delims = "/") +{ + return path.substr(path.find_last_of(delims) + 1); +} + +template +T RemoveExtension(T const &filename) +{ + typename T::size_type const P(filename.find_last_of('.')); + return P > 0 && P != T::npos ? filename.substr(0, P) : filename; +} + +// Options + +Options::Options() : argparser_(new panda::PandArgParser()) {} + +Options::~Options() +{ + delete argparser_; +} + +bool Options::Parse(int argc, const char **argv) +{ + panda::PandArg opHelp("help", false, "Print this message and exit"); + + // parser + panda::PandArg inputExtension("extension", "js", + "Parse the input as the given extension (options: js | ts | as)"); + panda::PandArg opModule("module", false, "Parse the input as module"); + panda::PandArg opParseOnly("parse-only", false, "Parse the input only"); + panda::PandArg opDumpAst("dump-ast", false, "Dump the parsed AST"); + + // compiler + panda::PandArg opDumpAssembly("dump-assembly", false, "Dump pandasm"); + panda::PandArg opDebugInfo("debug-info", false, "Compile with debug info"); + panda::PandArg opDumpDebugInfo("dump-debug-info", false, "Dump debug info"); + panda::PandArg opOptLevel("opt-level", 0, "Compiler optimization level (options: 0 | 1 | 2)"); + panda::PandArg opThreadCount("thread", 0, "Number of worker theads"); + panda::PandArg opSizeStat("dump-size-stat", false, "Dump size statistics"); + panda::PandArg outputFile("output", "", "Compiler binary output (.abc)"); + + // tail arguments + panda::PandArg inputFile("input", "", "input file"); + + argparser_->Add(&opHelp); + argparser_->Add(&opModule); + argparser_->Add(&opDumpAst); + argparser_->Add(&opParseOnly); + argparser_->Add(&opDumpAssembly); + argparser_->Add(&opDebugInfo); + argparser_->Add(&opDumpDebugInfo); + + argparser_->Add(&opOptLevel); + argparser_->Add(&opThreadCount); + argparser_->Add(&opSizeStat); + + argparser_->Add(&inputExtension); + argparser_->Add(&outputFile); + + argparser_->PushBackTail(&inputFile); + argparser_->EnableTail(); + argparser_->EnableRemainder(); + + if (!argparser_->Parse(argc, argv) || inputFile.GetValue().empty() || opHelp.GetValue()) { + std::stringstream ss; + + ss << argparser_->GetErrorString() << std::endl; + ss << "Usage: " + << "es2panda" + << " [OPTIONS] [input file] -- [arguments]" << std::endl; + ss << std::endl; + ss << "optional arguments:" << std::endl; + ss << argparser_->GetHelpString() << std::endl; + + errorMsg_ = ss.str(); + return false; + } + + sourceFile_ = inputFile.GetValue(); + std::ifstream inputStream(sourceFile_.c_str()); + + if (inputStream.fail()) { + errorMsg_ = "Failed to open file: "; + errorMsg_.append(sourceFile_); + return false; + } + + std::stringstream ss; + ss << inputStream.rdbuf(); + parserInput_ = ss.str(); + + sourceFile_ = BaseName(sourceFile_); + + if (!outputFile.GetValue().empty()) { + compilerOutput_ = outputFile.GetValue(); + } else { + compilerOutput_ = RemoveExtension(sourceFile_).append(".abc"); + } + + std::string extension = inputExtension.GetValue(); + + if (!extension.empty()) { + if (extension == "js") { + extension_ = es2panda::ScriptExtension::JS; + } else if (extension == "ts") { + extension_ = es2panda::ScriptExtension::TS; + } else if (extension == "as") { + extension_ = es2panda::ScriptExtension::AS; + } else { + errorMsg_ = "Invalid extension (available options: js, ts, as)"; + return false; + } + } + + optLevel_ = opOptLevel.GetValue(); + threadCount_ = opThreadCount.GetValue(); + + if (opParseOnly.GetValue()) { + options_ |= OptionFlags::PARSE_ONLY; + } + + if (opModule.GetValue()) { + options_ |= OptionFlags::PARSE_MODULE; + } + + if (opSizeStat.GetValue()) { + options_ |= OptionFlags::SIZE_STAT; + } + + compilerOptions_.dumpAsm = opDumpAssembly.GetValue(); + compilerOptions_.dumpAst = opDumpAst.GetValue(); + compilerOptions_.dumpDebugInfo = opDumpDebugInfo.GetValue(); + compilerOptions_.isDebug = opDebugInfo.GetValue(); + compilerOptions_.parseOnly = opParseOnly.GetValue(); + + return true; +} + +} // namespace panda::es2panda::aot diff --git a/es2panda/aot/options.h b/es2panda/aot/options.h new file mode 100644 index 0000000000..af8c8e3093 --- /dev/null +++ b/es2panda/aot/options.h @@ -0,0 +1,134 @@ +/** + * Copyright (c) 2021-2022 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_AOT_OPTIONS_H +#define ES2PANDA_AOT_OPTIONS_H + +#include +#include + +#include +#include +#include + +namespace panda { +class PandArgParser; +class PandaArg; +} // namespace panda + +namespace panda::es2panda::aot { + +enum class OptionFlags { + DEFAULT = 0, + PARSE_ONLY = 1 << 1, + PARSE_MODULE = 1 << 2, + SIZE_STAT = 1 << 3, +}; + +inline std::underlying_type_t operator&(OptionFlags a, OptionFlags b) +{ + using utype = std::underlying_type_t; + /* NOLINTNEXTLINE(hicpp-signed-bitwise) */ + return static_cast(static_cast(a) & static_cast(b)); +} + +inline OptionFlags &operator|=(OptionFlags &a, OptionFlags b) +{ + using utype = std::underlying_type_t; + /* NOLINTNEXTLINE(hicpp-signed-bitwise) */ + return a = static_cast(static_cast(a) | static_cast(b)); +} + +class Options { +public: + Options(); + NO_COPY_SEMANTIC(Options); + NO_MOVE_SEMANTIC(Options); + ~Options(); + + bool Parse(int argc, const char **argv); + + es2panda::ScriptExtension Extension() const + { + return extension_; + } + + const es2panda::CompilerOptions &CompilerOptions() const + { + return compilerOptions_; + } + + const std::string &ParserInput() const + { + return parserInput_; + } + + const std::string &CompilerOutput() const + { + return compilerOutput_; + } + + const std::string &SourceFile() const + { + return sourceFile_; + } + + const std::string &ErrorMsg() const + { + return errorMsg_; + } + + int OptLevel() const + { + return optLevel_; + } + + int ThreadCount() const + { + return threadCount_; + } + + bool ParseModule() const + { + return (options_ & OptionFlags::PARSE_MODULE) != 0; + } + + bool ParseOnly() const + { + return (options_ & OptionFlags::PARSE_ONLY) != 0; + } + + bool SizeStat() const + { + return (options_ & OptionFlags::SIZE_STAT) != 0; + } + +private: + es2panda::ScriptExtension extension_ {es2panda::ScriptExtension::JS}; + es2panda::CompilerOptions compilerOptions_ {}; + OptionFlags options_ {OptionFlags::DEFAULT}; + panda::PandArgParser *argparser_; + std::string parserInput_; + std::string compilerOutput_; + std::string result_; + std::string sourceFile_; + std::string errorMsg_; + int optLevel_ {0}; + int threadCount_ {0}; +}; + +} // namespace panda::es2panda::aot + +#endif // AOT_OPTIONS_H diff --git a/es2panda/binder/binder.cpp b/es2panda/binder/binder.cpp new file mode 100644 index 0000000000..d2a8b2ad39 --- /dev/null +++ b/es2panda/binder/binder.cpp @@ -0,0 +1,509 @@ +/** + * Copyright (c) 2021 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 "binder.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace panda::es2panda::binder { +void Binder::InitTopScope() +{ + if (program_->Kind() == parser::ScriptKind::MODULE) { + topScope_ = Allocator()->New(Allocator()); + } else { + topScope_ = Allocator()->New(Allocator()); + } + + scope_ = topScope_; +} + +ParameterDecl *Binder::AddParamDecl(const ir::AstNode *param) +{ + ASSERT(scope_->IsFunctionParamScope() || scope_->IsCatchParamScope()); + auto [decl, node] = static_cast(scope_)->AddParamDecl(Allocator(), param); + + if (!node) { + return decl; + } + + ThrowRedeclaration(node->Start(), decl->Name()); +} + +void Binder::ThrowRedeclaration(const lexer::SourcePosition &pos, const util::StringView &name) +{ + lexer::LineIndex index(program_->SourceCode()); + lexer::SourceLocation loc = index.GetLocation(pos); + + std::stringstream ss; + ss << "Variable '" << name << "' has already been declared."; + throw Error(ErrorType::SYNTAX, ss.str(), loc.line, loc.col); +} + +void Binder::IdentifierAnalysis() +{ + ASSERT(program_->Ast()); + ASSERT(scope_ == topScope_); + + BuildFunction(topScope_, "main"); + ResolveReferences(program_->Ast()); + AddMandatoryParams(); +} + +void Binder::LookupReference(const util::StringView &name) +{ + ScopeFindResult res = scope_->Find(name); + if (res.level == 0) { + return; + } + + ASSERT(res.variable); + res.variable->SetLexical(res.scope); +} + +void Binder::InstantiateArguments() +{ + auto *iter = scope_; + while (true) { + Scope *scope = iter->IsFunctionParamScope() ? iter : iter->EnclosingVariableScope(); + + const auto *node = scope->Node(); + + if (scope->IsLoopScope()) { + iter = scope->Parent(); + continue; + } + + if (!node->IsScriptFunction()) { + break; + } + + if (!node->AsScriptFunction()->IsArrow()) { + auto *argumentsVariable = + scope->AddDecl(Allocator(), FUNCTION_ARGUMENTS, VariableFlags::INITIALIZED); + + if (iter->IsFunctionParamScope()) { + if (!argumentsVariable) { + break; + } + + scope = iter->AsFunctionParamScope()->GetFunctionScope(); + scope->Bindings().insert({argumentsVariable->Name(), argumentsVariable}); + } + + scope->AsVariableScope()->AddFlag(VariableScopeFlags::USE_ARGS); + + break; + } + + iter = scope->Parent(); + } +} + +void Binder::LookupIdentReference(ir::Identifier *ident) +{ + if (ident->Name().Is(FUNCTION_ARGUMENTS)) { + InstantiateArguments(); + } + + ScopeFindResult res = scope_->Find(ident->Name()); + if (res.level != 0) { + ASSERT(res.variable); + res.variable->SetLexical(res.scope); + } + + if (!res.variable) { + return; + } + + if (res.variable->Declaration()->IsLetOrConstDecl() && !res.variable->HasFlag(VariableFlags::INITIALIZED)) { + ident->SetTdz(); + } + + ident->SetVariable(res.variable); +} + +void Binder::BuildFunction(FunctionScope *funcScope, util::StringView name) +{ + uint32_t idx = functionScopes_.size(); + functionScopes_.push_back(funcScope); + + std::stringstream ss; + ss << "func_" << name << "_" << std::to_string(idx); + util::UString internalName(ss.str(), Allocator()); + + funcScope->BindName(name, internalName.View()); +} + +void Binder::BuildScriptFunction(Scope *outerScope, const ir::ScriptFunction *scriptFunc) +{ + if (scriptFunc->IsArrow()) { + VariableScope *outerVarScope = outerScope->EnclosingVariableScope(); + outerVarScope->AddFlag(VariableScopeFlags::INNER_ARROW); + } + + BuildFunction(scope_->AsFunctionScope(), util::Helpers::FunctionName(scriptFunc)); +} + +void Binder::BuildVarDeclaratorId(const ir::AstNode *parent, ir::AstNode *childNode) +{ + childNode->SetParent(parent); + + switch (childNode->Type()) { + case ir::AstNodeType::IDENTIFIER: { + const auto &name = childNode->AsIdentifier()->Name(); + if (util::Helpers::IsGlobalIdentifier(childNode->AsIdentifier()->Name())) { + break; + } + + auto *variable = scope_->FindLocal(name); + variable->AddFlag(VariableFlags::INITIALIZED); + break; + } + case ir::AstNodeType::OBJECT_PATTERN: { + for (auto *prop : childNode->AsObjectPattern()->Properties()) { + BuildVarDeclaratorId(childNode, prop); + } + break; + } + case ir::AstNodeType::ARRAY_PATTERN: { + for (auto *element : childNode->AsArrayPattern()->Elements()) { + BuildVarDeclaratorId(childNode, element); + } + break; + } + case ir::AstNodeType::ASSIGNMENT_PATTERN: { + ResolveReference(childNode, childNode->AsAssignmentPattern()->Right()); + BuildVarDeclaratorId(childNode, childNode->AsAssignmentPattern()->Left()); + break; + } + case ir::AstNodeType::PROPERTY: { + ResolveReference(childNode, childNode->AsProperty()->Key()); + BuildVarDeclaratorId(childNode, childNode->AsProperty()->Value()); + break; + } + case ir::AstNodeType::REST_ELEMENT: { + BuildVarDeclaratorId(childNode, childNode->AsRestElement()->Argument()); + break; + } + default: + break; + } +} + +void Binder::BuildVarDeclarator(ir::VariableDeclarator *varDecl) +{ + if (varDecl->Parent()->AsVariableDeclaration()->Kind() == ir::VariableDeclaration::VariableDeclarationKind::VAR) { + ResolveReferences(varDecl); + return; + } + + if (varDecl->Init()) { + ResolveReference(varDecl, varDecl->Init()); + } + + BuildVarDeclaratorId(varDecl, varDecl->Id()); +} + +void Binder::BuildClassDefinition(ir::ClassDefinition *classDef) +{ + if (classDef->Parent()->IsClassDeclaration()) { + ScopeFindResult res = scope_->Find(classDef->Ident()->Name()); + + ASSERT(res.variable && res.variable->Declaration()->IsLetDecl()); + res.variable->AddFlag(VariableFlags::INITIALIZED); + } + + auto scopeCtx = LexicalScope::Enter(this, classDef->Scope()); + + if (classDef->Super()) { + ResolveReference(classDef, classDef->Super()); + } + + if (classDef->Ident()) { + ScopeFindResult res = scope_->Find(classDef->Ident()->Name()); + + ASSERT(res.variable && res.variable->Declaration()->IsConstDecl()); + res.variable->AddFlag(VariableFlags::INITIALIZED); + } + + ResolveReference(classDef, classDef->Ctor()); + + for (auto *stmt : classDef->Body()) { + ResolveReference(classDef, stmt); + } +} + +void Binder::BuildForUpdateLoop(ir::ForUpdateStatement *forUpdateStmt) +{ + auto *loopScope = forUpdateStmt->Scope(); + + auto declScopeCtx = LexicalScope::Enter(this, loopScope->DeclScope()); + + if (forUpdateStmt->Init()) { + ResolveReference(forUpdateStmt, forUpdateStmt->Init()); + } + + if (forUpdateStmt->Update()) { + ResolveReference(forUpdateStmt, forUpdateStmt->Update()); + } + + auto loopCtx = LexicalScope::Enter(this, loopScope); + + if (forUpdateStmt->Test()) { + ResolveReference(forUpdateStmt, forUpdateStmt->Test()); + } + + ResolveReference(forUpdateStmt, forUpdateStmt->Body()); + + loopCtx.GetScope()->ConvertToVariableScope(Allocator()); +} + +void Binder::BuildForInOfLoop(const ir::Statement *parent, binder::LoopScope *loopScope, ir::AstNode *left, + ir::Expression *right, ir::Statement *body) +{ + auto declScopeCtx = LexicalScope::Enter(this, loopScope->DeclScope()); + + ResolveReference(parent, right); + ResolveReference(parent, left); + + auto loopCtx = LexicalScope::Enter(this, loopScope); + + ResolveReference(parent, body); + loopCtx.GetScope()->ConvertToVariableScope(Allocator()); +} + +void Binder::BuildCatchClause(ir::CatchClause *catchClauseStmt) +{ + if (catchClauseStmt->Param()) { + auto paramScopeCtx = LexicalScope::Enter(this, catchClauseStmt->Scope()->ParamScope()); + ResolveReference(catchClauseStmt, catchClauseStmt->Param()); + } + + auto scopeCtx = LexicalScope::Enter(this, catchClauseStmt->Scope()); + ResolveReference(catchClauseStmt, catchClauseStmt->Body()); +} + +void Binder::ResolveReference(const ir::AstNode *parent, ir::AstNode *childNode) +{ + childNode->SetParent(parent); + + switch (childNode->Type()) { + case ir::AstNodeType::IDENTIFIER: { + auto *ident = childNode->AsIdentifier(); + + if (ident->IsReference()) { + LookupIdentReference(ident); + } + + ResolveReferences(childNode); + break; + } + case ir::AstNodeType::SUPER_EXPRESSION: { + VariableScope *varScope = scope_->EnclosingVariableScope(); + varScope->AddFlag(VariableScopeFlags::USE_SUPER); + + ResolveReferences(childNode); + break; + } + case ir::AstNodeType::SCRIPT_FUNCTION: { + auto *scriptFunc = childNode->AsScriptFunction(); + auto *funcScope = scriptFunc->Scope(); + + auto *outerScope = scope_; + + { + auto paramScopeCtx = LexicalScope::Enter(this, funcScope->ParamScope()); + + for (auto *param : scriptFunc->Params()) { + ResolveReference(scriptFunc, param); + } + } + + auto scopeCtx = LexicalScope::Enter(this, funcScope); + + BuildScriptFunction(outerScope, scriptFunc); + + ResolveReference(scriptFunc, scriptFunc->Body()); + break; + } + case ir::AstNodeType::VARIABLE_DECLARATOR: { + BuildVarDeclarator(childNode->AsVariableDeclarator()); + + break; + } + case ir::AstNodeType::CLASS_DEFINITION: { + BuildClassDefinition(childNode->AsClassDefinition()); + + break; + } + case ir::AstNodeType::CLASS_PROPERTY: { + const ir::ScriptFunction *ctor = util::Helpers::GetContainingConstructor(childNode->AsClassProperty()); + auto scopeCtx = LexicalScope::Enter(this, ctor->Scope()); + + ResolveReferences(childNode); + break; + } + case ir::AstNodeType::BLOCK_STATEMENT: { + auto scopeCtx = LexicalScope::Enter(this, childNode->AsBlockStatement()->Scope()); + + ResolveReferences(childNode); + break; + } + case ir::AstNodeType::SWITCH_STATEMENT: { + auto scopeCtx = LexicalScope::Enter(this, childNode->AsSwitchStatement()->Scope()); + + ResolveReferences(childNode); + break; + } + case ir::AstNodeType::DO_WHILE_STATEMENT: { + auto *doWhileStatement = childNode->AsDoWhileStatement(); + + { + auto loopScopeCtx = LexicalScope::Enter(this, doWhileStatement->Scope()); + ResolveReference(doWhileStatement, doWhileStatement->Body()); + } + + ResolveReference(doWhileStatement, doWhileStatement->Test()); + break; + } + case ir::AstNodeType::WHILE_STATEMENT: { + auto *whileStatement = childNode->AsWhileStatement(); + ResolveReference(whileStatement, whileStatement->Test()); + + auto loopScopeCtx = LexicalScope::Enter(this, whileStatement->Scope()); + ResolveReference(whileStatement, whileStatement->Body()); + + break; + } + case ir::AstNodeType::FOR_UPDATE_STATEMENT: { + BuildForUpdateLoop(childNode->AsForUpdateStatement()); + break; + } + case ir::AstNodeType::FOR_IN_STATEMENT: { + auto *forInStmt = childNode->AsForInStatement(); + BuildForInOfLoop(forInStmt, forInStmt->Scope(), forInStmt->Left(), forInStmt->Right(), forInStmt->Body()); + + break; + } + case ir::AstNodeType::FOR_OF_STATEMENT: { + auto *forOfStmt = childNode->AsForOfStatement(); + BuildForInOfLoop(forOfStmt, forOfStmt->Scope(), forOfStmt->Left(), forOfStmt->Right(), forOfStmt->Body()); + break; + } + case ir::AstNodeType::CATCH_CLAUSE: { + BuildCatchClause(childNode->AsCatchClause()); + break; + } + default: { + ResolveReferences(childNode); + break; + } + } +} +void Binder::ResolveReferences(const ir::AstNode *parent) +{ + parent->Iterate([this, parent](auto *childNode) { ResolveReference(parent, childNode); }); +} + +void Binder::AddMandatoryParam(const std::string_view &name) +{ + ASSERT(scope_->IsFunctionVariableScope()); + + auto *decl = Allocator()->New(name); + auto *param = Allocator()->New(decl, VariableFlags::VAR); + + auto &funcParams = scope_->AsFunctionVariableScope()->ParamScope()->Params(); + funcParams.insert(funcParams.begin(), param); + scope_->AsFunctionVariableScope()->Bindings().insert({decl->Name(), param}); +} + +void Binder::AddMandatoryParams(const MandatoryParams ¶ms) +{ + for (auto iter = params.rbegin(); iter != params.rend(); iter++) { + AddMandatoryParam(*iter); + } +} + +void Binder::AddMandatoryParams() +{ + ASSERT(scope_ == topScope_); + ASSERT(!functionScopes_.empty()); + auto iter = functionScopes_.begin(); + [[maybe_unused]] auto *funcScope = *iter++; + + ASSERT(funcScope->IsGlobalScope() || funcScope->IsModuleScope()); + AddMandatoryParams(FUNCTION_MANDATORY_PARAMS); + + for (; iter != functionScopes_.end(); iter++) { + funcScope = *iter; + const auto *scriptFunc = funcScope->Node()->AsScriptFunction(); + + auto scopeCtx = LexicalScope::Enter(this, funcScope); + + if (!scriptFunc->IsArrow()) { + AddMandatoryParams(FUNCTION_MANDATORY_PARAMS); + continue; + } + + const ir::ScriptFunction *ctor = util::Helpers::GetContainingConstructor(scriptFunc); + bool lexicalFunctionObject {}; + + if (ctor && util::Helpers::GetClassDefiniton(ctor)->Super() && + funcScope->HasFlag(VariableScopeFlags::USE_SUPER)) { + ASSERT(ctor->Scope()->HasFlag(VariableScopeFlags::INNER_ARROW)); + ctor->Scope()->AddFlag(VariableScopeFlags::SET_LEXICAL_FUNCTION); + lexicalFunctionObject = true; + AddMandatoryParams(CTOR_ARROW_MANDATORY_PARAMS); + } else { + AddMandatoryParams(ARROW_MANDATORY_PARAMS); + } + + LookupReference(MANDATORY_PARAM_NEW_TARGET); + LookupReference(MANDATORY_PARAM_THIS); + + if (funcScope->HasFlag(VariableScopeFlags::USE_ARGS)) { + LookupReference(FUNCTION_ARGUMENTS); + } + + if (lexicalFunctionObject) { + LookupReference(MANDATORY_PARAM_FUNC); + } + } +} +} // namespace panda::es2panda::binder diff --git a/es2panda/binder/binder.h b/es2panda/binder/binder.h new file mode 100644 index 0000000000..28f4b038d2 --- /dev/null +++ b/es2panda/binder/binder.h @@ -0,0 +1,210 @@ +/** + * Copyright (c) 2021 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_BINDER_BINDER_H +#define ES2PANDA_BINDER_BINDER_H + +#include +#include +#include +#include +#include + +namespace panda::es2panda::ir { +class AstNode; +class BlockStatement; +class CatchClause; +class ClassDefinition; +class Expression; +class ForUpdateStatement; +class Identifier; +class ScriptFunction; +class Statement; +class VariableDeclarator; +} // namespace panda::es2panda::ir + +namespace panda::es2panda::binder { +class Scope; +class VariableScope; + +class Binder { +public: + explicit Binder(parser::Program *program) : program_(program), functionScopes_(Allocator()->Adapter()) {} + NO_COPY_SEMANTIC(Binder); + DEFAULT_MOVE_SEMANTIC(Binder); + ~Binder() = default; + + void InitTopScope(); + void IdentifierAnalysis(); + + template + T *AddDecl(const lexer::SourcePosition &pos, Args &&... args); + + template + T *AddTsDecl(const lexer::SourcePosition &pos, Args &&... args); + + ParameterDecl *AddParamDecl(const ir::AstNode *param); + + Scope *GetScope() const + { + return scope_; + } + + GlobalScope *TopScope() const + { + return topScope_; + } + + [[noreturn]] void ThrowRedeclaration(const lexer::SourcePosition &pos, const util::StringView &name); + + template + friend class LexicalScope; + + inline ArenaAllocator *Allocator() const + { + return program_->Allocator(); + } + + const ArenaVector &Functions() const + { + return functionScopes_; + } + + ArenaVector Functions() + { + return functionScopes_; + } + + const parser::Program *Program() const + { + return program_; + } + + static constexpr std::string_view FUNCTION_ARGUMENTS = "arguments"; + static constexpr std::string_view MANDATORY_PARAM_FUNC = "=f"; + static constexpr std::string_view MANDATORY_PARAM_NEW_TARGET = "=nt"; + static constexpr std::string_view MANDATORY_PARAM_THIS = "=t"; + + static constexpr uint32_t MANDATORY_PARAM_FUNC_REG = 0; + static constexpr uint32_t MANDATORY_PARAMS_NUMBER = 3; + + static constexpr std::string_view LEXICAL_MANDATORY_PARAM_FUNC = "!f"; + static constexpr std::string_view LEXICAL_MANDATORY_PARAM_NEW_TARGET = "!nt"; + static constexpr std::string_view LEXICAL_MANDATORY_PARAM_THIS = "!t"; + +private: + using MandatoryParams = std::array; + + static constexpr MandatoryParams FUNCTION_MANDATORY_PARAMS = {MANDATORY_PARAM_FUNC, MANDATORY_PARAM_NEW_TARGET, + MANDATORY_PARAM_THIS}; + + static constexpr MandatoryParams ARROW_MANDATORY_PARAMS = {MANDATORY_PARAM_FUNC, LEXICAL_MANDATORY_PARAM_NEW_TARGET, + LEXICAL_MANDATORY_PARAM_THIS}; + + static constexpr MandatoryParams CTOR_ARROW_MANDATORY_PARAMS = { + LEXICAL_MANDATORY_PARAM_FUNC, LEXICAL_MANDATORY_PARAM_NEW_TARGET, LEXICAL_MANDATORY_PARAM_THIS}; + + void AddMandatoryParam(const std::string_view &name); + void AddMandatoryParams(const MandatoryParams ¶ms); + void AddMandatoryParams(); + void BuildFunction(FunctionScope *funcScope, util::StringView name); + void BuildScriptFunction(Scope *outerScope, const ir::ScriptFunction *scriptFunc); + void BuildClassDefinition(ir::ClassDefinition *classDef); + void LookupReference(const util::StringView &name); + void InstantiateArguments(); + void BuildVarDeclarator(ir::VariableDeclarator *varDecl); + void BuildVarDeclaratorId(const ir::AstNode *parent, ir::AstNode *childNode); + void BuildForUpdateLoop(ir::ForUpdateStatement *forUpdateStmt); + void BuildForInOfLoop(const ir::Statement *parent, binder::LoopScope *loopScope, ir::AstNode *left, + ir::Expression *right, ir::Statement *body); + void BuildCatchClause(ir::CatchClause *catchClauseStmt); + void LookupIdentReference(ir::Identifier *ident); + void ResolveReference(const ir::AstNode *parent, ir::AstNode *childNode); + void ResolveReferences(const ir::AstNode *parent); + + parser::Program *program_ {}; + GlobalScope *topScope_ {}; + Scope *scope_ {}; + ArenaVector functionScopes_; +}; + +template +class LexicalScope { +public: + template + explicit LexicalScope(Binder *binder, Args &&... args) + : LexicalScope(binder->Allocator()->New(binder->Allocator(), binder->scope_, std::forward(args)...), + binder) + { + } + + T *GetScope() const + { + return scope_; + } + + ~LexicalScope() + { + ASSERT(binder_); + binder_->scope_ = prevScope_; + } + + [[nodiscard]] static LexicalScope Enter(Binder *binder, T *scope) + { + LexicalScope lexScope(scope, binder); + return lexScope; + } + + DEFAULT_MOVE_SEMANTIC(LexicalScope); + +private: + NO_COPY_SEMANTIC(LexicalScope); + + explicit LexicalScope(T *scope, Binder *binder) : binder_(binder), scope_(scope), prevScope_(binder->scope_) + { + binder_->scope_ = scope_; + } + + Binder *binder_ {}; + T *scope_ {}; + Scope *prevScope_ {}; +}; + +template +T *Binder::AddTsDecl(const lexer::SourcePosition &pos, Args &&... args) +{ + T *decl = Allocator()->New(std::forward(args)...); + + if (scope_->AddTsDecl(Allocator(), decl, program_->Extension())) { + return decl; + } + + ThrowRedeclaration(pos, decl->Name()); +} + +template +T *Binder::AddDecl(const lexer::SourcePosition &pos, Args &&... args) +{ + T *decl = Allocator()->New(std::forward(args)...); + + if (scope_->AddDecl(Allocator(), decl, program_->Extension())) { + return decl; + } + + ThrowRedeclaration(pos, decl->Name()); +} +} // namespace panda::es2panda::binder + +#endif diff --git a/es2panda/binder/declaration.cpp b/es2panda/binder/declaration.cpp new file mode 100644 index 0000000000..0af5673365 --- /dev/null +++ b/es2panda/binder/declaration.cpp @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2021-2022 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 "declaration.h" + +namespace panda::es2panda::binder { + +} // namespace panda::es2panda::binder diff --git a/es2panda/binder/declaration.h b/es2panda/binder/declaration.h new file mode 100644 index 0000000000..ab65a7579a --- /dev/null +++ b/es2panda/binder/declaration.h @@ -0,0 +1,313 @@ +/** + * Copyright (c) 2021 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_SCOPES_DECLARATION_H +#define ES2PANDA_COMPILER_SCOPES_DECLARATION_H + +#include +#include +#include + +namespace panda::es2panda::ir { +class AstNode; +class FunctionDeclaration; +class TSInterfaceDeclaration; +class ImportDeclaration; +} // namespace panda::es2panda::ir + +namespace panda::es2panda::binder { + +class Scope; +class LocalScope; + +#define DECLARE_CLASSES(decl_kind, className) class className; +DECLARATION_KINDS(DECLARE_CLASSES) +#undef DECLARE_CLASSES + +class Decl { +public: + virtual ~Decl() = default; + NO_COPY_SEMANTIC(Decl); + NO_MOVE_SEMANTIC(Decl); + + virtual DeclType Type() const = 0; + + const util::StringView &Name() const + { + return name_; + } + + const ir::AstNode *Node() const + { + return node_; + } + +#define DECLARE_CHECKS_CASTS(declKind, className) \ + bool Is##className() const \ + { \ + return Type() == DeclType::declKind; \ + } \ + className *As##className() \ + { \ + ASSERT(Is##className()); \ + return reinterpret_cast(this); \ + } \ + const className *As##className() const \ + { \ + ASSERT(Is##className()); \ + return reinterpret_cast(this); \ + } + DECLARATION_KINDS(DECLARE_CHECKS_CASTS) +#undef DECLARE_CHECKS_CASTS + + void BindNode(const ir::AstNode *node) + { + node_ = node; + } + + bool IsLetOrConstDecl() const + { + return IsLetDecl() || IsConstDecl(); + } + +protected: + explicit Decl(util::StringView name) : name_(name) {} + + util::StringView name_; + const ir::AstNode *node_ {}; +}; + +template +class MultiDecl : public Decl { +public: + explicit MultiDecl(ArenaAllocator *allocator, util::StringView name) + : Decl(name), declarations_(allocator->Adapter()) + { + } + + const ArenaVector &Decls() const + { + return declarations_; + } + + void Add(T *decl) + { + declarations_.push_back(decl); + } + +private: + ArenaVector declarations_; +}; + +class EnumLiteralDecl : public Decl { +public: + explicit EnumLiteralDecl(util::StringView name, bool isConst) : Decl(name), isConst_(isConst) {} + + DeclType Type() const override + { + return DeclType::ENUM_LITERAL; + } + + bool IsConst() const + { + return isConst_; + } + + void BindScope(LocalScope *scope) + { + scope_ = scope; + } + + LocalScope *Scope() + { + return scope_; + } + +private: + LocalScope *scope_ {}; + bool isConst_ {}; +}; + +class InterfaceDecl : public MultiDecl { +public: + explicit InterfaceDecl(ArenaAllocator *allocator, util::StringView name) : MultiDecl(allocator, name) {} + + DeclType Type() const override + { + return DeclType::INTERFACE; + } +}; + +class FunctionDecl : public MultiDecl { +public: + explicit FunctionDecl(ArenaAllocator *allocator, util::StringView name, const ir::AstNode *node) + : MultiDecl(allocator, name) + { + node_ = node; + } + + DeclType Type() const override + { + return DeclType::FUNC; + } +}; + +class TypeParameterDecl : public Decl { +public: + explicit TypeParameterDecl(util::StringView name, const ir::AstNode *node); + + DeclType Type() const override + { + return DeclType::TYPE_PARAMETER; + } +}; + +class EnumDecl : public Decl { +public: + explicit EnumDecl(util::StringView name) : Decl(name) {} + + DeclType Type() const override + { + return DeclType::ENUM; + } +}; + +class TypeAliasDecl : public Decl { +public: + explicit TypeAliasDecl(util::StringView name) : Decl(name) {} + + DeclType Type() const override + { + return DeclType::TYPE_ALIAS; + } +}; + +class NameSpaceDecl : public Decl { +public: + explicit NameSpaceDecl(util::StringView name) : Decl(name) {} + + DeclType Type() const override + { + return DeclType::NAMESPACE; + } +}; + +class VarDecl : public Decl { +public: + explicit VarDecl(util::StringView name) : Decl(name) {} + + DeclType Type() const override + { + return DeclType::VAR; + } +}; + +class LetDecl : public Decl { +public: + explicit LetDecl(util::StringView name) : Decl(name) {} + + DeclType Type() const override + { + return DeclType::LET; + } +}; + +class ConstDecl : public Decl { +public: + explicit ConstDecl(util::StringView name) : Decl(name) {} + + DeclType Type() const override + { + return DeclType::CONST; + } +}; + +class ParameterDecl : public Decl { +public: + explicit ParameterDecl(util::StringView name) : Decl(name) {} + + DeclType Type() const override + { + return DeclType::PARAM; + } +}; + +class ImportDecl : public Decl { +public: + explicit ImportDecl(util::StringView importName, util::StringView localName) + : Decl(localName), importName_(importName) + { + } + + explicit ImportDecl(util::StringView importName, util::StringView localName, const ir::AstNode *node) + : Decl(localName), importName_(importName) + { + BindNode(node); + } + + const util::StringView &ImportName() const + { + return importName_; + } + + const util::StringView &LocalName() const + { + return name_; + } + + DeclType Type() const override + { + return DeclType::IMPORT; + } + +private: + util::StringView importName_; +}; + +class ExportDecl : public Decl { +public: + explicit ExportDecl(util::StringView exportName, util::StringView localName) + : Decl(localName), exportName_(exportName) + { + } + + explicit ExportDecl(util::StringView exportName, util::StringView localName, const ir::AstNode *node) + : Decl(localName), exportName_(exportName) + { + BindNode(node); + } + + const util::StringView &ExportName() const + { + return exportName_; + } + + const util::StringView &LocalName() const + { + return name_; + } + + DeclType Type() const override + { + return DeclType::EXPORT; + } + +private: + util::StringView exportName_; +}; + +} // namespace panda::es2panda::binder + +#endif diff --git a/es2panda/binder/enumMemberResult.h b/es2panda/binder/enumMemberResult.h new file mode 100644 index 0000000000..e0acb7709c --- /dev/null +++ b/es2panda/binder/enumMemberResult.h @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2021-2022 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_SCOPES_ENUM_MEMBER_RESULT_H +#define ES2PANDA_COMPILER_SCOPES_ENUM_MEMBER_RESULT_H + +#include + +#include + +namespace panda::es2panda::binder { + +// Note: if the bool operand is present, the expression cannot be evaluated during compliation +using EnumMemberResult = std::variant; + +} // namespace panda::es2panda::binder + +#endif diff --git a/es2panda/binder/scope.cpp b/es2panda/binder/scope.cpp new file mode 100644 index 0000000000..402bdd7a0c --- /dev/null +++ b/es2panda/binder/scope.cpp @@ -0,0 +1,505 @@ +/** + * Copyright (c) 2021 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 "scope.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace panda::es2panda::binder { + +VariableScope *Scope::EnclosingVariableScope() +{ + Scope *iter = this; + + while (iter) { + if (iter->IsVariableScope()) { + return iter->AsVariableScope(); + } + + iter = iter->Parent(); + } + + return nullptr; +} + +Variable *Scope::FindLocal(const util::StringView &name, ResolveBindingOptions options) const +{ + if (options & ResolveBindingOptions::INTERFACES) { + util::StringView interfaceNameView(binder::TSBinding::ToTSBinding(name)); + + auto res = bindings_.find(interfaceNameView); + if (res != bindings_.end()) { + return res->second; + } + + if (!(options & ResolveBindingOptions::BINDINGS)) { + return nullptr; + } + } + + auto res = bindings_.find(name); + if (res == bindings_.end()) { + return nullptr; + } + + return res->second; +} + +ScopeFindResult Scope::Find(const util::StringView &name, ResolveBindingOptions options) const +{ + uint32_t level = 0; + uint32_t lexLevel = 0; + const auto *iter = this; + + while (iter != nullptr) { + Variable *v = iter->FindLocal(name, options); + + if (v != nullptr) { + return {name, const_cast(iter), level, lexLevel, v}; + } + + if (iter->IsVariableScope()) { + level++; + + if (iter->AsVariableScope()->NeedLexEnv()) { + lexLevel++; + } + } + + iter = iter->Parent(); + } + + return {name, nullptr, 0, 0, nullptr}; +} + +Decl *Scope::FindDecl(const util::StringView &name) const +{ + for (auto *it : decls_) { + if (it->Name() == name) { + return it; + } + } + + return nullptr; +} + +std::tuple Scope::IterateShadowedVariables(const util::StringView &name, const VariableVisitior &visitor) +{ + auto *iter = this; + + while (true) { + auto *v = iter->FindLocal(name); + + if (v && visitor(v)) { + return {iter, true}; + } + + if (iter->IsFunctionVariableScope()) { + break; + } + + iter = iter->Parent(); + } + + return {iter, false}; +} + +bool Scope::AddLocal(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) +{ + VariableFlags flags = VariableFlags::NONE; + switch (newDecl->Type()) { + case DeclType::VAR: { + auto [scope, shadowed] = IterateShadowedVariables( + newDecl->Name(), [](const Variable *v) { return !v->HasFlag(VariableFlags::VAR); }); + + if (shadowed) { + return false; + } + + VariableFlags varFlags = VariableFlags::HOIST_VAR | VariableFlags::LEXICAL_VAR; + if (scope->IsGlobalScope()) { + scope->Bindings().insert({newDecl->Name(), allocator->New(newDecl, varFlags)}); + } else { + scope->PropagateBinding(allocator, newDecl->Name(), newDecl, varFlags); + } + + return true; + } + case DeclType::ENUM: { + bindings_.insert({newDecl->Name(), allocator->New(newDecl, false)}); + return true; + } + case DeclType::ENUM_LITERAL: { + bindings_.insert({newDecl->Name(), allocator->New(newDecl, VariableFlags::ENUM_LITERAL)}); + return true; + } + case DeclType::INTERFACE: { + bindings_.insert({newDecl->Name(), allocator->New(newDecl, VariableFlags::INTERFACE)}); + return true; + } + case DeclType::FUNC: { + flags = VariableFlags::HOIST; + [[fallthrough]]; + } + default: { + if (currentVariable) { + return false; + } + + auto [_, shadowed] = IterateShadowedVariables( + newDecl->Name(), [](const Variable *v) { return v->HasFlag(VariableFlags::LEXICAL_VAR); }); + (void)_; + + if (shadowed) { + return false; + } + + bindings_.insert({newDecl->Name(), allocator->New(newDecl, flags)}); + return true; + } + } +} + +bool ParamScope::AddParam(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, VariableFlags flags) +{ + ASSERT(newDecl->IsParameterDecl()); + + if (currentVariable) { + return false; + } + + auto *param = allocator->New(newDecl, flags); + + params_.push_back(param); + bindings_.insert({newDecl->Name(), param}); + return true; +} + +std::tuple ParamScope::AddParamDecl(ArenaAllocator *allocator, + const ir::AstNode *param) +{ + const auto [name, pattern] = util::Helpers::ParamName(allocator, param, params_.size()); + + auto *decl = NewDecl(allocator, name); + + if (!AddParam(allocator, FindLocal(name), decl, VariableFlags::VAR)) { + return {decl, param}; + } + + if (!pattern) { + return {decl, nullptr}; + } + + std::vector bindings = util::Helpers::CollectBindingNames(param); + + for (const auto *binding : bindings) { + auto *varDecl = NewDecl(allocator, binding->Name()); + varDecl->BindNode(binding); + + if (FindLocal(varDecl->Name())) { + return {decl, binding}; + } + + auto *paramVar = allocator->New(varDecl, VariableFlags::VAR); + bindings_.insert({varDecl->Name(), paramVar}); + } + + return {decl, nullptr}; +} + +void FunctionParamScope::BindName(ArenaAllocator *allocator, util::StringView name) +{ + nameVar_ = AddDecl(allocator, name, VariableFlags::INITIALIZED); + functionScope_->Bindings().insert({name, nameVar_}); +} + +bool FunctionParamScope::AddBinding([[maybe_unused]] ArenaAllocator *allocator, + [[maybe_unused]] Variable *currentVariable, [[maybe_unused]] Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) +{ + UNREACHABLE(); +} + +bool FunctionScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) +{ + switch (newDecl->Type()) { + case DeclType::VAR: { + return AddVar(allocator, currentVariable, newDecl); + } + case DeclType::FUNC: { + return AddFunction(allocator, currentVariable, newDecl, extension); + } + case DeclType::ENUM: { + bindings_.insert({newDecl->Name(), allocator->New(newDecl, false)}); + return true; + } + case DeclType::ENUM_LITERAL: { + return AddTSBinding(allocator, currentVariable, newDecl, VariableFlags::ENUM_LITERAL); + } + case DeclType::INTERFACE: { + return AddTSBinding(allocator, currentVariable, newDecl, VariableFlags::INTERFACE); + } + default: { + return AddLexical(allocator, currentVariable, newDecl); + } + } +} + +bool GlobalScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) +{ + switch (newDecl->Type()) { + case DeclType::VAR: { + return AddVar(allocator, currentVariable, newDecl); + } + case DeclType::FUNC: { + return AddFunction(allocator, currentVariable, newDecl, extension); + } + case DeclType::ENUM: { + bindings_.insert({newDecl->Name(), allocator->New(newDecl, false)}); + return true; + } + case DeclType::ENUM_LITERAL: { + return AddTSBinding(allocator, currentVariable, newDecl, VariableFlags::ENUM_LITERAL); + } + case DeclType::INTERFACE: { + return AddTSBinding(allocator, currentVariable, newDecl, VariableFlags::INTERFACE); + } + default: { + return AddLexical(allocator, currentVariable, newDecl); + } + } + + return true; +} + +// ModuleScope + +bool ModuleScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) +{ + switch (newDecl->Type()) { + case DeclType::VAR: { + return AddVar(allocator, currentVariable, newDecl); + } + case DeclType::FUNC: { + return AddFunction(allocator, currentVariable, newDecl, extension); + } + case DeclType::ENUM: { + bindings_.insert({newDecl->Name(), allocator->New(newDecl, false)}); + return true; + } + case DeclType::ENUM_LITERAL: { + return AddTSBinding(allocator, currentVariable, newDecl, VariableFlags::ENUM_LITERAL); + } + case DeclType::INTERFACE: { + return AddTSBinding(allocator, currentVariable, newDecl, VariableFlags::INTERFACE); + } + case DeclType::IMPORT: { + return AddImport(allocator, currentVariable, newDecl); + } + case DeclType::EXPORT: { + return true; + } + default: { + return AddLexical(allocator, currentVariable, newDecl); + } + } +} + +void ModuleScope::AddImportDecl(const ir::ImportDeclaration *importDecl, ImportDeclList &&decls) +{ + auto res = imports_.emplace_back(importDecl, decls); + + for (auto &decl : res.second) { + decl->BindNode(importDecl); + } +} + +void ModuleScope::AddExportDecl(const ir::AstNode *exportDecl, ExportDecl *decl) +{ + decl->BindNode(exportDecl); + + ArenaVector decls(allocator_->Adapter()); + decls.push_back(decl); + + AddExportDecl(exportDecl, std::move(decls)); +} + +void ModuleScope::AddExportDecl(const ir::AstNode *exportDecl, ExportDeclList &&decls) +{ + auto res = exports_.emplace_back(exportDecl, decls); + + for (auto &decl : res.second) { + decl->BindNode(exportDecl); + } +} + +bool ModuleScope::AddImport(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl) +{ + if (currentVariable && currentVariable->Declaration()->Type() != DeclType::VAR) { + return false; + } + + if (newDecl->Node()->IsImportNamespaceSpecifier()) { + bindings_.insert({newDecl->Name(), allocator->New(newDecl, VariableFlags::READONLY)}); + } else { + auto *variable = allocator->New(newDecl, VariableFlags::NONE); + variable->ExoticName() = newDecl->AsImportDecl()->ImportName(); + bindings_.insert({newDecl->Name(), variable}); + } + + return true; +} + +bool ModuleScope::ExportAnalysis() +{ + std::set exportedNames; + + for (const auto &[exportDecl, decls] : exports_) { + if (exportDecl->IsExportAllDeclaration()) { + const auto *exportAllDecl = exportDecl->AsExportAllDeclaration(); + + if (exportAllDecl->Exported() != nullptr) { + auto result = exportedNames.insert(exportAllDecl->Exported()->Name()); + if (!result.second) { + return false; + } + } + + continue; + } + + if (exportDecl->IsExportNamedDeclaration()) { + const auto *exportNamedDecl = exportDecl->AsExportNamedDeclaration(); + + if (exportNamedDecl->Source()) { + continue; + } + } + + for (const auto *decl : decls) { + binder::Variable *variable = FindLocal(decl->LocalName()); + + if (!variable) { + continue; + } + + auto result = exportedNames.insert(decl->ExportName()); + if (!result.second) { + return false; + } + + if (!variable->IsModuleVariable()) { + variable->AddFlag(VariableFlags::LOCAL_EXPORT); + localExports_.insert({variable, decl->ExportName()}); + } + } + } + + return true; +} + +// LocalScope + +bool LocalScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) +{ + return AddLocal(allocator, currentVariable, newDecl, extension); +} + +void LoopDeclarationScope::ConvertToVariableScope(ArenaAllocator *allocator) +{ + if (NeedLexEnv()) { + return; + } + + for (auto &[name, var] : bindings_) { + if (!var->LexicalBound() || !var->Declaration()->IsLetOrConstDecl()) { + continue; + } + + slotIndex_++; + loopType_ = ScopeType::LOOP_DECL; + auto *copiedVar = var->AsLocalVariable()->Copy(allocator, var->Declaration()); + copiedVar->AddFlag(VariableFlags::INITIALIZED | VariableFlags::PER_ITERATION); + var->AddFlag(VariableFlags::LOOP_DECL); + loopScope_->Bindings().insert({name, copiedVar}); + } + + if (loopType_ == ScopeType::LOOP_DECL) { + slotIndex_ = std::max(slotIndex_, parent_->EnclosingVariableScope()->LexicalSlots()); + initScope_ = allocator->New(allocator, parent_); + initScope_->BindNode(node_); + initScope_->Bindings() = bindings_; + } +} + +void LoopScope::ConvertToVariableScope(ArenaAllocator *allocator) +{ + declScope_->ConvertToVariableScope(allocator); + + if (loopType_ != ScopeType::LOCAL) { + return; + } + + for (const auto &[_, var] : bindings_) { + (void)_; + if (var->LexicalBound() && var->Declaration()->IsLetDecl()) { + ASSERT(declScope_->NeedLexEnv()); + loopType_ = ScopeType::LOOP; + break; + } + } + + if (loopType_ == ScopeType::LOOP) { + slotIndex_ = std::max(slotIndex_, declScope_->LexicalSlots()); + } +} + +bool CatchParamScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) +{ + return AddParam(allocator, currentVariable, newDecl, VariableFlags::INITIALIZED); +} + +bool CatchScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) +{ + if (!newDecl->IsVarDecl() && paramScope_->FindLocal(newDecl->Name())) { + return false; + } + + return AddLocal(allocator, currentVariable, newDecl, extension); +} + +} // namespace panda::es2panda::binder diff --git a/es2panda/binder/scope.h b/es2panda/binder/scope.h new file mode 100644 index 0000000000..9621858f36 --- /dev/null +++ b/es2panda/binder/scope.h @@ -0,0 +1,742 @@ +/** + * Copyright (c) 2021 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_SCOPES_SCOPE_H +#define ES2PANDA_COMPILER_SCOPES_SCOPE_H + +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace panda::es2panda::compiler { +class IRNode; +} // namespace panda::es2panda::compiler + +namespace panda::es2panda::binder { + +#define DECLARE_CLASSES(type, className) class className; +SCOPE_TYPES(DECLARE_CLASSES) +#undef DECLARE_CLASSES + +class Scope; +class VariableScope; +class Variable; + +using VariableMap = ArenaUnorderedMap; + +class ScopeFindResult { +public: + ScopeFindResult() = default; + ScopeFindResult(util::StringView n, Scope *s, uint32_t l, Variable *v) : ScopeFindResult(n, s, l, l, v) {} + ScopeFindResult(Scope *s, uint32_t l, uint32_t ll, Variable *v) : scope(s), level(l), lexLevel(ll), variable(v) {} + ScopeFindResult(util::StringView n, Scope *s, uint32_t l, uint32_t ll, Variable *v) + : name(n), scope(s), level(l), lexLevel(ll), variable(v) + { + } + + util::StringView name {}; + Scope *scope {}; + uint32_t level {}; + uint32_t lexLevel {}; + Variable *variable {}; +}; + +class Scope { +public: + virtual ~Scope() = default; + NO_COPY_SEMANTIC(Scope); + NO_MOVE_SEMANTIC(Scope); + + virtual ScopeType Type() const = 0; + +#define DECLARE_CHECKS_CASTS(scopeType, className) \ + bool Is##className() const \ + { \ + return Type() == ScopeType::scopeType; \ + } \ + className *As##className() \ + { \ + ASSERT(Is##className()); \ + return reinterpret_cast(this); \ + } \ + const className *As##className() const \ + { \ + ASSERT(Is##className()); \ + return reinterpret_cast(this); \ + } + SCOPE_TYPES(DECLARE_CHECKS_CASTS) +#undef DECLARE_CHECKS_CASTS + + bool IsVariableScope() const + { + return Type() > ScopeType::LOCAL; + } + + bool IsFunctionVariableScope() const + { + return Type() >= ScopeType::FUNCTION; + } + + FunctionScope *AsFunctionVariableScope() + { + ASSERT(IsFunctionVariableScope()); + return reinterpret_cast(this); + } + + const FunctionScope *AsFunctionVariableScope() const + { + ASSERT(IsFunctionVariableScope()); + return reinterpret_cast(this); + } + + VariableScope *AsVariableScope() + { + ASSERT(IsVariableScope()); + return reinterpret_cast(this); + } + + const VariableScope *AsVariableScope() const + { + ASSERT(IsVariableScope()); + return reinterpret_cast(this); + } + + VariableScope *EnclosingVariableScope(); + + const ArenaVector &Decls() const + { + return decls_; + } + + Scope *Parent() + { + return parent_; + } + + const Scope *Parent() const + { + return parent_; + } + + const compiler::IRNode *ScopeStart() const + { + return startIns_; + } + + const compiler::IRNode *ScopeEnd() const + { + return endIns_; + } + + void SetScopeStart(const compiler::IRNode *ins) + { + startIns_ = ins; + } + + void SetScopeEnd(const compiler::IRNode *ins) + { + endIns_ = ins; + } + + const ir::AstNode *Node() const + { + return node_; + } + + void BindNode(const ir::AstNode *node) + { + node_ = node; + } + + bool AddDecl(ArenaAllocator *allocator, Decl *decl, [[maybe_unused]] ScriptExtension extension) + { + decls_.push_back(decl); + return AddBinding(allocator, FindLocal(decl->Name()), decl, extension); + } + + bool AddTsDecl(ArenaAllocator *allocator, Decl *decl, [[maybe_unused]] ScriptExtension extension) + { + decls_.push_back(decl); + return AddBinding(allocator, FindLocal(decl->Name(), ResolveBindingOptions::ALL), decl, extension); + } + + template + T *NewDecl(ArenaAllocator *allocator, Args &&... args); + + template + VariableType *AddDecl(ArenaAllocator *allocator, util::StringView name, VariableFlags flags); + + template + static VariableType *CreateVar(ArenaAllocator *allocator, util::StringView name, VariableFlags flags, + const ir::AstNode *node); + + template + void PropagateBinding(ArenaAllocator *allocator, util::StringView name, Args &&... args); + + VariableMap &Bindings() + { + return bindings_; + } + + const VariableMap &Bindings() const + { + return bindings_; + } + + virtual bool AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) = 0; + + Variable *FindLocal(const util::StringView &name, + ResolveBindingOptions options = ResolveBindingOptions::BINDINGS) const; + + ScopeFindResult Find(const util::StringView &name, + ResolveBindingOptions options = ResolveBindingOptions::BINDINGS) const; + + Decl *FindDecl(const util::StringView &name) const; + +protected: + explicit Scope(ArenaAllocator *allocator, Scope *parent) + : parent_(parent), decls_(allocator->Adapter()), bindings_(allocator->Adapter()) + { + } + + /** + * @return true - if the variable is shadowed + * false - otherwise + */ + using VariableVisitior = std::function; + + /** + * @return true - if the variable is shadowed + * false - otherwise + */ + std::tuple IterateShadowedVariables(const util::StringView &name, const VariableVisitior &visitor); + + bool AddLocal(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension); + + Scope *parent_ {}; + ArenaVector decls_; + VariableMap bindings_; + const ir::AstNode *node_ {}; + const compiler::IRNode *startIns_ {}; + const compiler::IRNode *endIns_ {}; +}; + +class VariableScope : public Scope { +public: + ~VariableScope() override = default; + NO_COPY_SEMANTIC(VariableScope); + NO_MOVE_SEMANTIC(VariableScope); + + void AddFlag(VariableScopeFlags flag) + { + flags_ |= flag; + } + + void ClearFlag(VariableScopeFlags flag) + { + flags_ &= ~flag; + } + + bool HasFlag(VariableScopeFlags flag) const + { + return (flags_ & flag) != 0; + } + + uint32_t NextSlot() + { + return slotIndex_++; + } + + uint32_t LexicalSlots() const + { + return slotIndex_; + } + + bool NeedLexEnv() const + { + return slotIndex_ != 0; + } + +protected: + explicit VariableScope(ArenaAllocator *allocator, Scope *parent) : Scope(allocator, parent) {} + + template + bool AddVar(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl); + + template + bool AddFunction(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension); + + template + bool AddTSBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, VariableFlags flags); + + template + bool AddLexical(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl); + + VariableScopeFlags flags_ {}; + uint32_t slotIndex_ {}; +}; + +class ParamScope : public Scope { +public: + ScopeType Type() const override + { + return ScopeType::PARAM; + } + + ArenaVector &Params() + { + return params_; + } + + const ArenaVector &Params() const + { + return params_; + } + + std::tuple AddParamDecl(ArenaAllocator *allocator, const ir::AstNode *param); + +protected: + explicit ParamScope(ArenaAllocator *allocator, Scope *parent) + : Scope(allocator, parent), params_(allocator->Adapter()) + { + } + + bool AddParam(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, VariableFlags flags); + + ArenaVector params_; +}; + +class FunctionScope; + +class FunctionParamScope : public ParamScope { +public: + explicit FunctionParamScope(ArenaAllocator *allocator, Scope *parent) : ParamScope(allocator, parent) {} + + FunctionScope *GetFunctionScope() const + { + return functionScope_; + } + + void BindFunctionScope(FunctionScope *funcScope) + { + functionScope_ = funcScope; + } + + LocalVariable *NameVar() const + { + return nameVar_; + } + + void BindName(ArenaAllocator *allocator, util::StringView name); + + ScopeType Type() const override + { + return ScopeType::FUNCTION_PARAM; + } + + bool AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) override; + + friend class FunctionScope; + template + friend class ScopeWithParamScope; + +private: + FunctionScope *functionScope_ {}; + LocalVariable *nameVar_ {}; +}; + +template +class ScopeWithParamScope : public E { +public: + explicit ScopeWithParamScope(ArenaAllocator *allocator, Scope *parent) : E(allocator, parent) {} + + void BindParamScope(T *paramScope) + { + AssignParamScope(paramScope); + this->bindings_ = paramScope->Bindings(); + } + + void AssignParamScope(T *paramScope) + { + ASSERT(this->parent_ == paramScope); + ASSERT(this->bindings_.empty()); + + paramScope_ = paramScope; + } + + T *ParamScope() + { + return paramScope_; + } + + const T *ParamScope() const + { + return paramScope_; + } + +protected: + T *paramScope_; +}; + +class FunctionScope : public ScopeWithParamScope { +public: + explicit FunctionScope(ArenaAllocator *allocator, Scope *parent) : ScopeWithParamScope(allocator, parent) {} + + ScopeType Type() const override + { + return ScopeType::FUNCTION; + } + + void BindName(util::StringView name, util::StringView internalName) + { + name_ = name; + internalName_ = internalName; + } + + const util::StringView &Name() const + { + return name_; + } + + const util::StringView &InternalName() const + { + return internalName_; + } + + bool AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) override; + +private: + util::StringView name_ {}; + util::StringView internalName_ {}; +}; + +class LocalScope : public Scope { +public: + explicit LocalScope(ArenaAllocator *allocator, Scope *parent) : Scope(allocator, parent) {} + + ScopeType Type() const override + { + return ScopeType::LOCAL; + } + + bool AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) override; +}; + +class CatchParamScope : public ParamScope { +public: + explicit CatchParamScope(ArenaAllocator *allocator, Scope *parent) : ParamScope(allocator, parent) {} + + ScopeType Type() const override + { + return ScopeType::CATCH_PARAM; + } + + bool AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) override; + + friend class CatchScope; +}; + +class CatchScope : public ScopeWithParamScope { +public: + explicit CatchScope(ArenaAllocator *allocator, Scope *parent) : ScopeWithParamScope(allocator, parent) {} + + ScopeType Type() const override + { + return ScopeType::CATCH; + } + + bool AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) override; +}; + +class LoopScope; + +class LoopDeclarationScope : public VariableScope { +public: + explicit LoopDeclarationScope(ArenaAllocator *allocator, Scope *parent) : VariableScope(allocator, parent) {} + + ScopeType Type() const override + { + return loopType_; + } + + bool AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) override + { + return AddLocal(allocator, currentVariable, newDecl, extension); + } + + Scope *InitScope() + { + if (NeedLexEnv()) { + return initScope_; + } + + return this; + } + + void ConvertToVariableScope(ArenaAllocator *allocator); + +private: + friend class LoopScope; + LoopScope *loopScope_ {}; + LocalScope *initScope_ {}; + ScopeType loopType_ {ScopeType::LOCAL}; +}; + +class LoopScope : public VariableScope { +public: + explicit LoopScope(ArenaAllocator *allocator, Scope *parent) : VariableScope(allocator, parent) {} + + LoopDeclarationScope *DeclScope() + { + return declScope_; + } + + void BindDecls(LoopDeclarationScope *declScope) + { + declScope_ = declScope; + declScope_->loopScope_ = this; + } + + ScopeType Type() const override + { + return loopType_; + } + + void ConvertToVariableScope(ArenaAllocator *allocator); + + bool AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) override + { + return AddLocal(allocator, currentVariable, newDecl, extension); + } + +protected: + LoopDeclarationScope *declScope_ {}; + ScopeType loopType_ {ScopeType::LOCAL}; +}; + +class GlobalScope : public FunctionScope { +public: + explicit GlobalScope(ArenaAllocator *allocator) : FunctionScope(allocator, nullptr) + { + auto *paramScope = allocator->New(allocator, this); + paramScope_ = paramScope; + } + + ScopeType Type() const override + { + return ScopeType::GLOBAL; + } + + bool AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) override; +}; + +class ModuleScope : public GlobalScope { +public: + template + using ModuleEntry = ArenaVector>; + using ImportDeclList = ArenaVector; + using ExportDeclList = ArenaVector; + using LocalExportNameMap = ArenaMultiMap; + + explicit ModuleScope(ArenaAllocator *allocator) + : GlobalScope(allocator), + allocator_(allocator), + imports_(allocator_->Adapter()), + exports_(allocator_->Adapter()), + localExports_(allocator_->Adapter()) + { + } + + ScopeType Type() const override + { + return ScopeType::MODULE; + } + + const ModuleEntry &Imports() const + { + return imports_; + } + + const ModuleEntry &Exports() const + { + return exports_; + } + + const LocalExportNameMap &LocalExports() const + { + return localExports_; + } + + void AddImportDecl(const ir::ImportDeclaration *importDecl, ImportDeclList &&decls); + + void AddExportDecl(const ir::AstNode *exportDecl, ExportDecl *decl); + + void AddExportDecl(const ir::AstNode *exportDecl, ExportDeclList &&decls); + + bool AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) override; + + bool ExportAnalysis(); + +private: + bool AddImport(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl); + + ArenaAllocator *allocator_; + ModuleEntry imports_; + ModuleEntry exports_; + LocalExportNameMap localExports_; +}; + +template +bool VariableScope::AddVar(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl) +{ + if (!currentVariable) { + bindings_.insert({newDecl->Name(), allocator->New(newDecl, VariableFlags::HOIST_VAR)}); + return true; + } + + switch (currentVariable->Declaration()->Type()) { + case DeclType::VAR: { + currentVariable->Reset(newDecl, VariableFlags::HOIST_VAR); + break; + } + case DeclType::PARAM: + case DeclType::FUNC: { + break; + } + default: { + return false; + } + } + + return true; +} + +template +bool VariableScope::AddFunction(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, + [[maybe_unused]] ScriptExtension extension) +{ + VariableFlags flags = (extension == ScriptExtension::JS) ? VariableFlags::HOIST_VAR : VariableFlags::HOIST; + + if (!currentVariable) { + bindings_.insert({newDecl->Name(), allocator->New(newDecl, flags)}); + return true; + } + + if (extension != ScriptExtension::JS || IsModuleScope()) { + return false; + } + + switch (currentVariable->Declaration()->Type()) { + case DeclType::VAR: + case DeclType::FUNC: { + currentVariable->Reset(newDecl, VariableFlags::HOIST_VAR); + break; + } + default: { + return false; + } + } + + return true; +} + +template +bool VariableScope::AddTSBinding(ArenaAllocator *allocator, [[maybe_unused]] Variable *currentVariable, Decl *newDecl, + VariableFlags flags) +{ + ASSERT(!currentVariable); + bindings_.insert({newDecl->Name(), allocator->New(newDecl, flags)}); + return true; +} + +template +bool VariableScope::AddLexical(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl) +{ + if (currentVariable) { + return false; + } + + bindings_.insert({newDecl->Name(), allocator->New(newDecl, VariableFlags::NONE)}); + return true; +} + +template +T *Scope::NewDecl(ArenaAllocator *allocator, Args &&... args) +{ + T *decl = allocator->New(std::forward(args)...); + decls_.push_back(decl); + + return decl; +} + +template +VariableType *Scope::AddDecl(ArenaAllocator *allocator, util::StringView name, VariableFlags flags) +{ + if (FindLocal(name)) { + return nullptr; + } + + auto *decl = allocator->New(name); + auto *variable = allocator->New(decl, flags); + + decls_.push_back(decl); + bindings_.insert({decl->Name(), variable}); + + return variable; +} + +template +VariableType *Scope::CreateVar(ArenaAllocator *allocator, util::StringView name, VariableFlags flags, + const ir::AstNode *node) +{ + auto *decl = allocator->New(name); + auto *variable = allocator->New(decl, flags); + decl->BindNode(node); + return variable; +} + +template +void Scope::PropagateBinding(ArenaAllocator *allocator, util::StringView name, Args &&... args) +{ + auto res = bindings_.find(name); + if (res == bindings_.end()) { + bindings_.insert({name, allocator->New(std::forward(args)...)}); + return; + } + + res->second->Reset(std::forward(args)...); +} + +} // namespace panda::es2panda::binder + +#endif diff --git a/es2panda/binder/tsBinding.h b/es2panda/binder/tsBinding.h new file mode 100644 index 0000000000..4d586ceaf4 --- /dev/null +++ b/es2panda/binder/tsBinding.h @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2021 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_BINDER_TS_BINDING_H +#define ES2PANDA_BINDER_TS_BINDING_H + +#include + +#include + +namespace panda::es2panda::binder { +// Note: if the bool operand is present, the expression cannot be evaluated during compliation +using EnumMemberResult = std::variant; + +class TSBinding : public util::UString { +public: + explicit TSBinding(ArenaAllocator *allocator, util::StringView name) + : util::UString(std::string {TS_PREFIX}, allocator) + { + Append(name); + } + + static std::string ToTSBinding(util::StringView name) + { + return std::string {TS_PREFIX}.append(name.Utf8()); + } + + static constexpr std::string_view TS_PREFIX = "#"; +}; +} // namespace panda::es2panda::binder + +#endif diff --git a/es2panda/binder/variable.cpp b/es2panda/binder/variable.cpp new file mode 100644 index 0000000000..fb57097d38 --- /dev/null +++ b/es2panda/binder/variable.cpp @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2021 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 "variable.h" + +#include + +#include + +namespace panda::es2panda::binder { + +LocalVariable::LocalVariable(Decl *decl, VariableFlags flags) : Variable(decl, flags) +{ + if (decl->IsConstDecl()) { + flags_ |= VariableFlags::READONLY; + } +} + +const util::StringView &Variable::Name() const +{ + return decl_->Name(); +} + +LocalVariable *LocalVariable::Copy(ArenaAllocator *allocator, Decl *decl) const +{ + auto *var = allocator->New(decl, flags_); + var->vreg_ = vreg_; + return var; +} + +void LocalVariable::SetLexical(Scope *scope) +{ + if (LexicalBound()) { + return; + } + + VariableScope *varScope = scope->EnclosingVariableScope(); + + BindLexEnvSlot(varScope->NextSlot()); +} + +void GlobalVariable::SetLexical([[maybe_unused]] Scope *scope) {} +void ModuleVariable::SetLexical([[maybe_unused]] Scope *scope) {} +void EnumVariable::SetLexical([[maybe_unused]] Scope *scope) {} + +void EnumVariable::ResetDecl(Decl *decl) +{ + decl_ = decl; +} + +} // namespace panda::es2panda::binder diff --git a/es2panda/binder/variable.h b/es2panda/binder/variable.h new file mode 100644 index 0000000000..4302048a8b --- /dev/null +++ b/es2panda/binder/variable.h @@ -0,0 +1,254 @@ +/** + * Copyright (c) 2021 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_SCOPES_VARIABLE_H +#define ES2PANDA_COMPILER_SCOPES_VARIABLE_H + +#include +#include +#include +#include +#include + +#include + +namespace panda::es2panda::checker { +class Type; +} // namespace panda::es2panda::checker + +namespace panda::es2panda::binder { + +class Decl; +class Scope; +class VariableScope; + +#define DECLARE_CLASSES(type, className) class className; +VARIABLE_TYPES(DECLARE_CLASSES) +#undef DECLARE_CLASSES + +class Variable { +public: + virtual ~Variable() = default; + NO_COPY_SEMANTIC(Variable); + NO_MOVE_SEMANTIC(Variable); + + VariableType virtual Type() const = 0; + +#define DECLARE_CHECKS_CASTS(variableType, className) \ + bool Is##className() const \ + { \ + return Type() == VariableType::variableType; \ + } \ + className *As##className() \ + { \ + ASSERT(Is##className()); \ + return reinterpret_cast(this); \ + } \ + const className *As##className() const \ + { \ + ASSERT(Is##className()); \ + return reinterpret_cast(this); \ + } + VARIABLE_TYPES(DECLARE_CHECKS_CASTS) +#undef DECLARE_CHECKS_CASTS + + Decl *Declaration() const + { + return decl_; + } + + VariableFlags Flags() const + { + return flags_; + } + + checker::Type *TsType() const + { + return tsType_; + } + + void SetTsType(checker::Type *tsType) + { + tsType_ = tsType; + } + + void AddFlag(VariableFlags flag) + { + flags_ |= flag; + } + + bool HasFlag(VariableFlags flag) const + { + return (flags_ & flag) != 0; + } + + void RemoveFlag(VariableFlags flag) + { + flags_ &= ~flag; + } + + void Reset(Decl *decl, VariableFlags flags) + { + decl_ = decl; + flags_ = flags; + } + + bool LexicalBound() const + { + return HasFlag(VariableFlags::LEXICAL_BOUND); + } + + const util::StringView &Name() const; + virtual void SetLexical(Scope *scope) = 0; + +protected: + explicit Variable(Decl *decl, VariableFlags flags) : decl_(decl), flags_(flags) {} + + Decl *decl_; + VariableFlags flags_ {}; + checker::Type *tsType_ {}; +}; + +class LocalVariable : public Variable { +public: + explicit LocalVariable(Decl *decl, VariableFlags flags); + + VariableType Type() const override + { + return VariableType::LOCAL; + } + + void BindVReg(compiler::VReg vreg) + { + ASSERT(!LexicalBound()); + vreg_ = vreg; + } + + void BindLexEnvSlot(uint32_t slot) + { + ASSERT(!LexicalBound()); + AddFlag(VariableFlags::LEXICAL_BOUND); + vreg_ = slot; + } + + compiler::VReg Vreg() const + { + return vreg_; + } + + uint32_t LexIdx() const + { + ASSERT(LexicalBound()); + return vreg_; + } + + void SetLexical([[maybe_unused]] Scope *scope) override; + LocalVariable *Copy(ArenaAllocator *allocator, Decl *decl) const; + +private: + uint32_t vreg_ {}; +}; + +class GlobalVariable : public Variable { +public: + explicit GlobalVariable(Decl *decl, VariableFlags flags) : Variable(decl, flags) {} + + VariableType Type() const override + { + return VariableType::GLOBAL; + } + + void SetLexical([[maybe_unused]] Scope *scope) override; +}; + +class ModuleVariable : public Variable { +public: + explicit ModuleVariable(Decl *decl, VariableFlags flags) : Variable(decl, flags) {} + + VariableType Type() const override + { + return VariableType::MODULE; + } + + compiler::VReg &ModuleReg() + { + return moduleReg_; + } + + compiler::VReg ModuleReg() const + { + return moduleReg_; + } + + const util::StringView &ExoticName() const + { + return exoticName_; + } + + util::StringView &ExoticName() + { + return exoticName_; + } + + void SetLexical([[maybe_unused]] Scope *scope) override; + +private: + compiler::VReg moduleReg_ {}; + util::StringView exoticName_ {}; +}; + +class EnumVariable : public Variable { +public: + explicit EnumVariable(Decl *decl, bool backReference = false) + : Variable(decl, VariableFlags::NONE), backReference_(backReference) + { + } + + VariableType Type() const override + { + return VariableType::ENUM; + } + + void SetValue(EnumMemberResult value) + { + value_ = value; + } + + const EnumMemberResult &Value() const + { + return value_; + } + + bool BackReference() const + { + return backReference_; + } + + void SetBackReference() + { + backReference_ = true; + } + + void ResetDecl(Decl *decl); + + void SetLexical([[maybe_unused]] Scope *scope) override; + +private: + EnumMemberResult value_ {false}; + bool backReference_ {}; +}; + +} // namespace panda::es2panda::binder +#endif diff --git a/es2panda/binder/variableFlags.h b/es2panda/binder/variableFlags.h new file mode 100644 index 0000000000..dee8b14757 --- /dev/null +++ b/es2panda/binder/variableFlags.h @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2021 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_SCOPES_VARIABLE_FLAGS_H +#define ES2PANDA_COMPILER_SCOPES_VARIABLE_FLAGS_H + +#include + +namespace panda::es2panda::binder { + +#define DECLARATION_KINDS(_) \ + _(VAR, VarDecl) \ + _(LET, LetDecl) \ + _(CONST, ConstDecl) \ + _(FUNC, FunctionDecl) \ + _(PARAM, ParameterDecl) \ + _(IMPORT, ImportDecl) \ + _(EXPORT, ExportDecl) \ + /* TS */ \ + _(TYPE_ALIAS, TypeAliasDecl) \ + _(NAMESPACE, NameSpaceDecl) \ + _(INTERFACE, InterfaceDecl) \ + _(ENUM_LITERAL, EnumLiteralDecl) \ + _(TYPE_PARAMETER, TypeParameterDecl) \ + _(ENUM, EnumDecl) + +enum class DeclType { + NONE, +#define DECLARE_TYPES(decl_kind, class_name) decl_kind, + DECLARATION_KINDS(DECLARE_TYPES) +#undef DECLARE_TYPES +}; + +#define SCOPE_TYPES(_) \ + _(PARAM, ParamScope) \ + _(CATCH_PARAM, CatchParamScope) \ + _(FUNCTION_PARAM, FunctionParamScope) \ + _(CATCH, CatchScope) \ + _(LOCAL, LocalScope) \ + /* Variable Scopes */ \ + _(LOOP, LoopScope) \ + _(LOOP_DECL, LoopDeclarationScope) \ + _(FUNCTION, FunctionScope) \ + _(GLOBAL, GlobalScope) \ + _(MODULE, ModuleScope) + +enum class ScopeType { +#define GEN_SCOPE_TYPES(type, class_name) type, + SCOPE_TYPES(GEN_SCOPE_TYPES) +#undef GEN_SCOPE_TYPES +}; + +enum class ResolveBindingOptions { + BINDINGS = 1U << 0U, + INTERFACES = 1U << 1U, + + ALL = BINDINGS | INTERFACES, +}; + +DEFINE_BITOPS(ResolveBindingOptions) + +#define VARIABLE_TYPES(_) \ + _(LOCAL, LocalVariable) \ + _(GLOBAL, GlobalVariable) \ + _(MODULE, ModuleVariable) \ + _(ENUM, EnumVariable) + +enum class VariableType { +#define GEN_VARIABLE_TYPES(type, class_name) type, + VARIABLE_TYPES(GEN_VARIABLE_TYPES) +#undef GEN_VARIABLE_TYPES +}; + +enum class VariableKind { + NONE, + VAR, + LEXICAL, + FUNCTION, + MODULE, +}; + +enum class VariableFlags { + NONE = 0, + OPTIONAL = 1 << 0, + PROPERTY = 1 << 1, + METHOD = 1 << 2, + TYPE_ALIAS = 1 << 3, + INTERFACE = 1 << 4, + ENUM_LITERAL = 1 << 5, + READONLY = 1 << 6, + COMPUTED = 1 << 7, + COMPUTED_IDENT = 1 << 8, + COMPUTED_INDEX = 1 << 9, + INDEX_NAME = 1 << 10, + LOCAL_EXPORT = 1 << 12, + INFERED_IN_PATTERN = 1 << 13, + REST_ARG = 1 << 14, + + INDEX_LIKE = COMPUTED_INDEX | INDEX_NAME, + + LOOP_DECL = 1 << 25, + PER_ITERATION = 1 << 26, + LEXICAL_VAR = 1 << 27, + HOIST = 1 << 28, + VAR = 1 << 29, + INITIALIZED = 1 << 30, + LEXICAL_BOUND = 1 << 31, + + HOIST_VAR = HOIST | VAR, +}; + +DEFINE_BITOPS(VariableFlags) + +enum class LetOrConstStatus { + INITIALIZED, + UNINITIALIZED, +}; + +enum class VariableScopeFlags { + NONE = 0, + SET_LEXICAL_FUNCTION = 1U << 0U, + USE_ARGS = 1U << 2U, + USE_SUPER = 1U << 3U, + INNER_ARROW = 1U << 4U, +}; + +DEFINE_BITOPS(VariableScopeFlags) + +} // namespace panda::es2panda::binder + +#endif diff --git a/es2panda/compiler/base/catchTable.cpp b/es2panda/compiler/base/catchTable.cpp new file mode 100644 index 0000000000..2bafa48df0 --- /dev/null +++ b/es2panda/compiler/base/catchTable.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2021-2022 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 "catchTable.h" + +#include + +namespace panda::es2panda::compiler { + +TryLabelSet::TryLabelSet(PandaGen *pg) + : try_(pg->AllocLabel(), pg->AllocLabel()), catch_(pg->AllocLabel(), pg->AllocLabel()) +{ +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/base/catchTable.h b/es2panda/compiler/base/catchTable.h new file mode 100644 index 0000000000..9954ae9ff7 --- /dev/null +++ b/es2panda/compiler/base/catchTable.h @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2021-2022 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_BASE_CATCH_TABLE_H +#define ES2PANDA_COMPILER_BASE_CATCH_TABLE_H + +#include +#include + +namespace panda::es2panda::compiler { + +class PandaGen; + +class TryLabelSet { +public: + explicit TryLabelSet(PandaGen *pg); + + ~TryLabelSet() = default; + DEFAULT_COPY_SEMANTIC(TryLabelSet); + DEFAULT_MOVE_SEMANTIC(TryLabelSet); + + const LabelPair &TryLabelPair() const + { + return try_; + } + + const LabelPair &CatchLabelPair() const + { + return catch_; + } + + Label *TryBegin() const + { + return try_.Begin(); + } + + Label *TryEnd() const + { + return try_.End(); + } + + Label *CatchBegin() const + { + return catch_.Begin(); + } + + Label *CatchEnd() const + { + return catch_.End(); + } + +private: + LabelPair try_; + LabelPair catch_; +}; + +class CatchTable { +public: + CatchTable(PandaGen *pg, uint32_t depth) : labelSet_(pg), depth_(depth) {} + + ~CatchTable() = default; + NO_COPY_SEMANTIC(CatchTable); + NO_MOVE_SEMANTIC(CatchTable); + + const TryLabelSet &LabelSet() const + { + return labelSet_; + } + + uint32_t Depth() const + { + return depth_; + } + +private: + TryLabelSet labelSet_; + uint32_t depth_; +}; + +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/base/condition.cpp b/es2panda/compiler/base/condition.cpp new file mode 100644 index 0000000000..644e9195fe --- /dev/null +++ b/es2panda/compiler/base/condition.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2021-2022 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 "condition.h" + +#include +#include +#include + +namespace panda::es2panda::compiler { + +void Condition::Compile(PandaGen *pg, const ir::Expression *expr, Label *falseLabel) +{ + if (expr->IsBinaryExpression()) { + const auto *binExpr = expr->AsBinaryExpression(); + + switch (binExpr->OperatorType()) { + case lexer::TokenType::PUNCTUATOR_EQUAL: + case lexer::TokenType::PUNCTUATOR_NOT_EQUAL: + case lexer::TokenType::PUNCTUATOR_STRICT_EQUAL: + case lexer::TokenType::PUNCTUATOR_NOT_STRICT_EQUAL: + case lexer::TokenType::PUNCTUATOR_LESS_THAN: + case lexer::TokenType::PUNCTUATOR_LESS_THAN_EQUAL: + case lexer::TokenType::PUNCTUATOR_GREATER_THAN: + case lexer::TokenType::PUNCTUATOR_GREATER_THAN_EQUAL: { + // This is a special case + // These operators are expressed via cmp instructions and the following + // if-else branches. Condition also expressed via cmp instruction and + // the following if-else. + // the goal of this method is to merge these two sequences of instructions. + RegScope rs(pg); + VReg lhs = pg->AllocReg(); + + binExpr->Left()->Compile(pg); + pg->StoreAccumulator(binExpr, lhs); + binExpr->Right()->Compile(pg); + pg->Condition(binExpr, binExpr->OperatorType(), lhs, falseLabel); + return; + } + case lexer::TokenType::PUNCTUATOR_LOGICAL_AND: { + binExpr->Left()->Compile(pg); + pg->ToBoolean(binExpr); + pg->BranchIfFalse(binExpr, falseLabel); + + binExpr->Right()->Compile(pg); + pg->ToBoolean(binExpr); + pg->BranchIfFalse(binExpr, falseLabel); + return; + } + case lexer::TokenType::PUNCTUATOR_LOGICAL_OR: { + auto *endLabel = pg->AllocLabel(); + + binExpr->Left()->Compile(pg); + pg->ToBoolean(binExpr); + pg->BranchIfTrue(binExpr, endLabel); + + binExpr->Right()->Compile(pg); + pg->ToBoolean(binExpr); + pg->BranchIfFalse(binExpr, falseLabel); + pg->SetLabel(binExpr, endLabel); + return; + } + default: { + break; + } + } + } else if (expr->IsUnaryExpression() && + expr->AsUnaryExpression()->OperatorType() == lexer::TokenType::PUNCTUATOR_EXCLAMATION_MARK) { + expr->AsUnaryExpression()->Argument()->Compile(pg); + + pg->Negate(expr); + pg->BranchIfFalse(expr, falseLabel); + return; + } + + // General case including some binExpr i.E.(a+b) + expr->Compile(pg); + pg->ToBoolean(expr); + pg->BranchIfFalse(expr, falseLabel); +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/base/condition.h b/es2panda/compiler/base/condition.h new file mode 100644 index 0000000000..e6ad51d835 --- /dev/null +++ b/es2panda/compiler/base/condition.h @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2021-2022 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_BASE_CONDITION_H +#define ES2PANDA_COMPILER_BASE_CONDITION_H + +#include + +namespace panda::es2panda::compiler { + +class PandaGen; +class Label; + +class Condition { +public: + Condition() = delete; + + static void Compile(PandaGen *pg, const ir::Expression *expr, Label *falseLabel); +}; + +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/base/destructuring.cpp b/es2panda/compiler/base/destructuring.cpp new file mode 100644 index 0000000000..7ff756529f --- /dev/null +++ b/es2panda/compiler/base/destructuring.cpp @@ -0,0 +1,262 @@ +/** + * Copyright (c) 2021-2022 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 "destructuring.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace panda::es2panda::compiler { + +static void GenRestElement(PandaGen *pg, const ir::SpreadElement *restElement, + const DestructuringIterator &destIterator, bool isDeclaration) +{ + VReg array = pg->AllocReg(); + VReg index = pg->AllocReg(); + + auto *next = pg->AllocLabel(); + auto *done = pg->AllocLabel(); + + DestructuringRestIterator iterator(destIterator); + + // create left reference for rest element + LReference lref = LReference::CreateLRef(pg, restElement, isDeclaration); + + // create an empty array first + pg->CreateEmptyArray(restElement); + pg->StoreAccumulator(restElement, array); + + // index = 0 + pg->LoadAccumulatorInt(restElement, 0); + pg->StoreAccumulator(restElement, index); + + pg->SetLabel(restElement, next); + + iterator.Step(done); + pg->StoreObjByValue(restElement, array, index); + + // index++ + pg->LoadAccumulatorInt(restElement, 1); + pg->Binary(restElement, lexer::TokenType::PUNCTUATOR_PLUS, index); + pg->StoreAccumulator(restElement, index); + + pg->Branch(restElement, next); + + pg->SetLabel(restElement, done); + pg->LoadAccumulator(restElement, array); + + lref.SetValue(); +} + +static void GenArray(PandaGen *pg, const ir::ArrayExpression *array) +{ + // RegScope rs(pg); + DestructuringIterator iterator(pg, array); + + if (array->Elements().empty()) { + iterator.Close(false); + return; + } + + TryContext tryCtx(pg); + const auto &labelSet = tryCtx.LabelSet(); + pg->SetLabel(array, labelSet.TryBegin()); + + for (const auto *element : array->Elements()) { + RegScope ers(pg); + + if (element->IsRestElement()) { + GenRestElement(pg, element->AsRestElement(), iterator, array->IsDeclaration()); + break; + } + + // if a hole exist, just let the iterator step ahead + if (element->IsOmittedExpression()) { + iterator.Step(); + continue; + } + + const ir::Expression *init = nullptr; + const ir::Expression *target = element; + + if (element->IsAssignmentPattern()) { + target = element->AsAssignmentPattern()->Left(); + init = element->AsAssignmentPattern()->Right(); + } + + LReference lref = LReference::CreateLRef(pg, target, array->IsDeclaration()); + iterator.Step(); + + if (init) { + auto *assingValue = pg->AllocLabel(); + auto *defaultInit = pg->AllocLabel(); + pg->BranchIfUndefined(element, defaultInit); + pg->LoadAccumulator(element, iterator.Result()); + pg->Branch(element, assingValue); + + pg->SetLabel(element, defaultInit); + init->Compile(pg); + pg->SetLabel(element, assingValue); + } + + lref.SetValue(); + } + + pg->SetLabel(array, labelSet.TryEnd()); + + // Normal completion + pg->LoadAccumulator(array, iterator.Done()); + pg->BranchIfTrue(array, labelSet.CatchEnd()); + iterator.Close(false); + + pg->Branch(array, labelSet.CatchEnd()); + + Label *end = pg->AllocLabel(); + pg->SetLabel(array, labelSet.CatchBegin()); + pg->StoreAccumulator(array, iterator.Result()); + pg->LoadAccumulator(array, iterator.Done()); + + pg->BranchIfTrue(array, end); + pg->LoadAccumulator(array, iterator.Result()); + iterator.Close(true); + pg->SetLabel(array, end); + pg->LoadAccumulator(array, iterator.Result()); + pg->EmitThrow(array); + pg->SetLabel(array, labelSet.CatchEnd()); +} + +static void GenObjectProperty(PandaGen *pg, const ir::ObjectExpression *object, const ir::Expression *element, + VReg value, VReg propReg) +{ + RegScope propScope(pg); + VReg loadedValue = pg->AllocReg(); + + const ir::Property *propExpr = element->AsProperty(); + + const ir::Expression *init = nullptr; + const ir::Expression *key = propExpr->Key(); + const ir::Expression *target = propExpr->Value(); + + if (target->IsAssignmentPattern()) { + init = target->AsAssignmentPattern()->Right(); + target = target->AsAssignmentPattern()->Left(); + } + + // compile key + if (key->IsIdentifier()) { + pg->LoadAccumulatorString(key, key->AsIdentifier()->Name()); + } else { + key->Compile(pg); + } + + pg->StoreAccumulator(key, propReg); + + LReference lref = LReference::CreateLRef(pg, target, object->IsDeclaration()); + + // load obj property from rhs, return undefined if no corresponding property exists + pg->LoadObjByValue(element, value, propReg); + pg->StoreAccumulator(element, loadedValue); + + if (init != nullptr) { + auto *getDefault = pg->AllocLabel(); + auto *store = pg->AllocLabel(); + + pg->BranchIfUndefined(element, getDefault); + pg->LoadAccumulator(element, loadedValue); + pg->Branch(element, store); + + // load default value + pg->SetLabel(element, getDefault); + init->Compile(pg); + + pg->SetLabel(element, store); + } + + lref.SetValue(); +} + +static void GenObjectWithRest(PandaGen *pg, const ir::ObjectExpression *object, VReg rhs) +{ + const auto &properties = object->Properties(); + + RegScope rs(pg); + VReg propStart = pg->NextReg(); + + for (const auto *element : properties) { + if (element->IsRestElement()) { + RegScope restScope(pg); + LReference lref = LReference::CreateLRef(pg, element, object->IsDeclaration()); + pg->CreateObjectWithExcludedKeys(element, rhs, propStart, properties.size() - 1); + lref.SetValue(); + break; + } + + VReg propReg = pg->AllocReg(); + GenObjectProperty(pg, object, element, rhs, propReg); + } +} + +static void GenObject(PandaGen *pg, const ir::ObjectExpression *object, VReg rhs) +{ + const auto &properties = object->Properties(); + + if (properties.empty() || properties.back()->IsRestElement()) { + auto *notNullish = pg->AllocLabel(); + + pg->LoadAccumulator(object, rhs); + pg->BranchIfCoercible(object, notNullish); + pg->ThrowObjectNonCoercible(object); + + pg->SetLabel(object, notNullish); + + if (!properties.empty()) { + return GenObjectWithRest(pg, object, rhs); + } + } + + for (const auto *element : properties) { + RegScope rs(pg); + VReg propReg = pg->AllocReg(); + + GenObjectProperty(pg, object, element, rhs, propReg); + } +} + +void Destructuring::Compile(PandaGen *pg, const ir::Expression *pattern) +{ + RegScope rs(pg); + + VReg rhs = pg->AllocReg(); + pg->StoreAccumulator(pattern, rhs); + + if (pattern->IsArrayPattern()) { + GenArray(pg, pattern->AsArrayPattern()); + } else { + GenObject(pg, pattern->AsObjectPattern(), rhs); + } + + pg->LoadAccumulator(pattern, rhs); +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/base/destructuring.h b/es2panda/compiler/base/destructuring.h new file mode 100644 index 0000000000..081d7801b3 --- /dev/null +++ b/es2panda/compiler/base/destructuring.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2021-2022 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_BASE_DESTRUCTURING_H +#define ES2PANDA_COMPILER_BASE_DESTRUCTURING_H + +#include + +namespace panda::es2panda::compiler { + +class PandaGen; + +class Destructuring { +public: + Destructuring() = delete; + + static void Compile(PandaGen *pg, const ir::Expression *pattern); +}; + +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/base/hoisting.cpp b/es2panda/compiler/base/hoisting.cpp new file mode 100644 index 0000000000..07621e8d63 --- /dev/null +++ b/es2panda/compiler/base/hoisting.cpp @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2021 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 "hoisting.h" + +#include +#include +#include + +namespace panda::es2panda::compiler { + +static void HoistVar(PandaGen *pg, binder::Variable *var, const binder::VarDecl *decl) +{ + auto *scope = pg->Scope(); + + if (scope->IsGlobalScope()) { + pg->LoadConst(decl->Node(), Constant::JS_UNDEFINED); + pg->StoreGlobalVar(decl->Node(), decl->Name()); + return; + } + + binder::ScopeFindResult result(decl->Name(), scope, 0, var); + + pg->LoadConst(decl->Node(), Constant::JS_UNDEFINED); + pg->StoreAccToLexEnv(decl->Node(), result, true); +} + +static void HoistFunction(PandaGen *pg, binder::Variable *var, const binder::FunctionDecl *decl) +{ + const ir::ScriptFunction *scriptFunction = decl->Node()->AsScriptFunction(); + auto *scope = pg->Scope(); + + const auto &internalName = scriptFunction->Scope()->InternalName(); + + if (scope->IsGlobalScope()) { + pg->DefineFunction(decl->Node(), scriptFunction, internalName); + pg->StoreGlobalVar(decl->Node(), var->Declaration()->Name()); + return; + } + + ASSERT(scope->IsFunctionScope() || scope->IsCatchScope() || scope->IsLocalScope() || scope->IsModuleScope()); + binder::ScopeFindResult result(decl->Name(), scope, 0, var); + + pg->DefineFunction(decl->Node(), scriptFunction, internalName); + pg->StoreAccToLexEnv(decl->Node(), result, true); +} + +void Hoisting::Hoist(PandaGen *pg) +{ + const auto *scope = pg->Scope(); + + for (const auto &[_, var] : scope->Bindings()) { + (void)_; + if (!var->HasFlag(binder::VariableFlags::HOIST)) { + continue; + } + + const auto *decl = var->Declaration(); + + if (decl->IsVarDecl()) { + HoistVar(pg, var, decl->AsVarDecl()); + } else { + ASSERT(decl->IsFunctionDecl()); + HoistFunction(pg, var, decl->AsFunctionDecl()); + } + } +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/base/hoisting.h b/es2panda/compiler/base/hoisting.h new file mode 100644 index 0000000000..2448cf2228 --- /dev/null +++ b/es2panda/compiler/base/hoisting.h @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2021-2022 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_BASE_HOISTING_H +#define ES2PANDA_COMPILER_BASE_HOISTING_H + +namespace panda::es2panda::compiler { + +class PandaGen; + +class Hoisting { +public: + static void Hoist(PandaGen *pg); +}; + +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/base/iterators.cpp b/es2panda/compiler/base/iterators.cpp new file mode 100644 index 0000000000..1bf7ad8887 --- /dev/null +++ b/es2panda/compiler/base/iterators.cpp @@ -0,0 +1,216 @@ +/* + * Copyright (c) 2021-2022 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 "iterators.h" + +#include +#include +#include + +namespace panda::es2panda::compiler { + +// Iterator + +Iterator::Iterator(PandaGen *pg, const ir::AstNode *node, IteratorType type) + : pg_(pg), node_(node), method_(pg->AllocReg()), iterator_(pg->AllocReg()), nextResult_(pg->AllocReg()), type_(type) +{ + if (type_ == IteratorType::ASYNC) { + pg_->GetAsyncIterator(node); + } else { + pg_->GetIterator(node); + } + + pg_->StoreAccumulator(node, iterator_); + pg_->LoadObjByName(node_, iterator_, "next"); + pg_->StoreAccumulator(node_, method_); + + pg_->ThrowIfNotObject(node_); +} + +void Iterator::GetMethod(util::StringView name) const +{ + pg_->GetMethod(node_, iterator_, name); + pg_->StoreAccumulator(node_, method_); +} + +void Iterator::CallMethodWithValue() const +{ + pg_->CallThis(node_, method_, 2); +} + +void Iterator::CallMethod() const +{ + pg_->CallThis(node_, method_, 1); +} + +void Iterator::Next() const +{ + CallMethod(); + + if (type_ == IteratorType::ASYNC) { + pg_->FuncBuilder()->Await(node_); + } + + pg_->ThrowIfNotObject(node_); + pg_->StoreAccumulator(node_, nextResult_); +} + +void Iterator::Complete() const +{ + pg_->LoadObjByName(node_, nextResult_, "done"); + pg_->ToBoolean(node_); +} + +void Iterator::Value() const +{ + pg_->LoadObjByName(node_, nextResult_, "value"); +} + +void Iterator::Close(bool abruptCompletion) const +{ + if (type_ == IteratorType::SYNC) { + if (!abruptCompletion) { + pg_->LoadConst(node_, Constant::JS_HOLE); + } + pg_->CloseIterator(node_, iterator_); + return; + } + + RegScope rs(pg_); + VReg completion = pg_->AllocReg(); + VReg innerResult = pg_->AllocReg(); + VReg innerResultType = pg_->AllocReg(); + + pg_->StoreAccumulator(node_, completion); + pg_->StoreConst(node_, innerResultType, Constant::JS_HOLE); + + TryContext tryCtx(pg_); + const auto &labelSet = tryCtx.LabelSet(); + Label *returnExits = pg_->AllocLabel(); + + pg_->SetLabel(node_, labelSet.TryBegin()); + + // 4. Let innerResult be GetMethod(iterator, "return"). + GetMethod("return"); + + // 5. If innerResult.[[Type]] is normal, then + { + // b. If return is undefined, return Completion(completion). + pg_->BranchIfNotUndefined(node_, returnExits); + // a. Let return be innerResult.[[Value]]. + pg_->LoadAccumulator(node_, completion); + + if (abruptCompletion) { + pg_->EmitThrow(node_); + } else { + pg_->DirectReturn(node_); + } + + pg_->SetLabel(node_, returnExits); + + { + TryContext innerTryCtx(pg_); + const auto &innerLabelSet = innerTryCtx.LabelSet(); + + pg_->SetLabel(node_, innerLabelSet.TryBegin()); + // c. Set innerResult to Call(return, iterator). + CallMethod(); + // d. If innerResult.[[Type]] is normal, set innerResult to Await(innerResult.[[Value]]). + pg_->FuncBuilder()->Await(node_); + pg_->StoreAccumulator(node_, innerResult); + pg_->SetLabel(node_, innerLabelSet.TryEnd()); + pg_->Branch(node_, innerLabelSet.CatchEnd()); + + pg_->SetLabel(node_, innerLabelSet.CatchBegin()); + pg_->StoreAccumulator(node_, innerResult); + pg_->StoreAccumulator(node_, innerResultType); + pg_->SetLabel(node_, innerLabelSet.CatchEnd()); + } + } + + pg_->SetLabel(node_, labelSet.TryEnd()); + pg_->Branch(node_, labelSet.CatchEnd()); + + pg_->SetLabel(node_, labelSet.CatchBegin()); + pg_->StoreAccumulator(node_, innerResult); + pg_->StoreAccumulator(node_, innerResultType); + pg_->SetLabel(node_, labelSet.CatchEnd()); + + // 6. If completion.[[Type]] is throw, return Completion(completion). + if (abruptCompletion) { + pg_->LoadAccumulator(node_, completion); + pg_->EmitThrow(node_); + } else { + // 7. If innerResult.[[Type]] is throw, return Completion(innerResult). + pg_->LoadAccumulator(node_, innerResultType); + pg_->EmitRethrow(node_); + } + + // 8. If Type(innerResult.[[Value]]) is not Object, throw a TypeError exception. + pg_->LoadAccumulator(node_, innerResult); + pg_->ThrowIfNotObject(node_); +} + +DestructuringIterator::DestructuringIterator(PandaGen *pg, const ir::AstNode *node) + : Iterator(pg, node, IteratorType::SYNC), done_(pg->AllocReg()), result_(pg->AllocReg()) +{ + pg_->StoreConst(node, done_, Constant::JS_FALSE); + pg_->StoreConst(node, result_, Constant::JS_UNDEFINED); +} + +void DestructuringIterator::Step(Label *doneTarget) const +{ + TryContext tryCtx(pg_); + const auto &labelSet = tryCtx.LabelSet(); + Label *normalClose = pg_->AllocLabel(); + Label *noClose = pg_->AllocLabel(); + + pg_->SetLabel(node_, labelSet.TryBegin()); + Next(); + Complete(); + pg_->StoreAccumulator(node_, done_); + pg_->BranchIfFalse(node_, normalClose); + pg_->StoreConst(node_, done_, Constant::JS_TRUE); + pg_->LoadConst(node_, Constant::JS_UNDEFINED); + OnIterDone(doneTarget); + pg_->Branch(node_, noClose); + + pg_->SetLabel(node_, normalClose); + Value(); + pg_->StoreAccumulator(node_, result_); + pg_->SetLabel(node_, noClose); + + pg_->SetLabel(node_, labelSet.TryEnd()); + pg_->Branch(node_, labelSet.CatchEnd()); + + pg_->SetLabel(node_, labelSet.CatchBegin()); + pg_->StoreAccumulator(node_, result_); + pg_->StoreConst(node_, done_, Constant::JS_TRUE); + pg_->LoadAccumulator(node_, result_); + pg_->EmitThrow(node_); + pg_->SetLabel(node_, labelSet.CatchEnd()); +} + +void DestructuringIterator::OnIterDone([[maybe_unused]] Label *doneTarget) const +{ + pg_->LoadConst(node_, Constant::JS_UNDEFINED); +} + +void DestructuringRestIterator::OnIterDone([[maybe_unused]] Label *doneTarget) const +{ + pg_->Branch(node_, doneTarget); +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/base/iterators.h b/es2panda/compiler/base/iterators.h new file mode 100644 index 0000000000..0f23818d9e --- /dev/null +++ b/es2panda/compiler/base/iterators.h @@ -0,0 +1,119 @@ +/** + * Copyright (c) 2021-2022 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_BASE_ITERATORS_H +#define ES2PANDA_COMPILER_BASE_ITERATORS_H + +#include + +namespace panda::es2panda::ir { +class AstNode; +} // namespace panda::es2panda::ir + +namespace panda::es2panda::compiler { + +class PandaGen; + +enum class IteratorType { SYNC, ASYNC }; + +class Iterator { +public: + Iterator(PandaGen *pg, const ir::AstNode *node, IteratorType type); + DEFAULT_COPY_SEMANTIC(Iterator); + DEFAULT_MOVE_SEMANTIC(Iterator); + ~Iterator() = default; + + IteratorType Type() const + { + return type_; + } + + VReg Method() const + { + return method_; + } + + VReg NextResult() const + { + return nextResult_; + } + + const ir::AstNode *Node() const + { + return node_; + } + + void GetMethod(util::StringView name) const; + void CallMethod() const; + void CallMethodWithValue() const; + + void Next() const; + void Complete() const; + void Value() const; + void Close(bool abruptCompletion) const; + +protected: + PandaGen *pg_; + const ir::AstNode *node_; + // These 3 regs must be allocated continously + VReg method_; + VReg iterator_; + VReg nextResult_; + IteratorType type_; +}; + +class DestructuringIterator : public Iterator { +public: + explicit DestructuringIterator(PandaGen *pg, const ir::AstNode *node); + + DEFAULT_COPY_SEMANTIC(DestructuringIterator); + DEFAULT_MOVE_SEMANTIC(DestructuringIterator); + ~DestructuringIterator() = default; + + VReg Done() const + { + return done_; + } + + VReg Result() const + { + return result_; + } + + void Step(Label *doneTarget = nullptr) const; + + virtual void OnIterDone([[maybe_unused]] Label *doneTarget) const; + + friend class DestructuringRestIterator; + +protected: + VReg done_; + VReg result_; +}; + +class DestructuringRestIterator : public DestructuringIterator { +public: + explicit DestructuringRestIterator(const DestructuringIterator &iterator) : DestructuringIterator(iterator) {} + + DEFAULT_COPY_SEMANTIC(DestructuringRestIterator); + DEFAULT_MOVE_SEMANTIC(DestructuringRestIterator); + ~DestructuringRestIterator() = default; + + void OnIterDone([[maybe_unused]] Label *doneTarget) const override; +}; + +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/base/lexenv.cpp b/es2panda/compiler/base/lexenv.cpp new file mode 100644 index 0000000000..f3410f06c2 --- /dev/null +++ b/es2panda/compiler/base/lexenv.cpp @@ -0,0 +1,142 @@ +/** + * Copyright (c) 2021 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 "lexenv.h" + +#include +#include +#include +#include +#include + +namespace panda::es2panda::compiler { + +// Helpers + +static bool CheckTdz(const ir::AstNode *node) +{ + return node->IsIdentifier() && node->AsIdentifier()->IsTdz(); +} + +static void CheckConstAssignment(PandaGen *pg, const ir::AstNode *node, binder::Variable *variable) +{ + if (!variable->Declaration()->IsConstDecl()) { + return; + } + + pg->ThrowConstAssignment(node, variable->Name()); +} + +// VirtualLoadVar + +static void ExpandLoadLexVar(PandaGen *pg, const ir::AstNode *node, const binder::ScopeFindResult &result) +{ + pg->LoadLexicalVar(node, result.lexLevel, result.variable->AsLocalVariable()->LexIdx()); + pg->ThrowUndefinedIfHole(node, result.variable->Name()); +} + +static void ExpandLoadNormalVar(PandaGen *pg, const ir::AstNode *node, const binder::ScopeFindResult &result) +{ + auto *local = result.variable->AsLocalVariable(); + + if (CheckTdz(node)) { + pg->LoadConst(node, Constant::JS_HOLE); + pg->ThrowUndefinedIfHole(node, local->Name()); + } else { + pg->LoadAccumulator(node, local->Vreg()); + } +} + +void VirtualLoadVar::Expand(PandaGen *pg, const ir::AstNode *node, const binder::ScopeFindResult &result) +{ + if (result.variable->LexicalBound()) { + ExpandLoadLexVar(pg, node, result); + } else { + ExpandLoadNormalVar(pg, node, result); + } +} + +// VirtualStoreVar + +static void StoreLocalExport(PandaGen *pg, const ir::AstNode *node, binder::Variable *variable) +{ + if (!variable->HasFlag(binder::VariableFlags::LOCAL_EXPORT) || !pg->Scope()->IsModuleScope()) { + return; + } + + auto range = pg->Scope()->AsModuleScope()->LocalExports().equal_range(variable); + + for (auto it = range.first; it != range.second; ++it) { + if (it->second != "default") { + pg->StoreModuleVar(node, it->second); + } + } +} + +static void ExpandStoreLexVar(PandaGen *pg, const ir::AstNode *node, const binder::ScopeFindResult &result, bool isDecl) +{ + binder::LocalVariable *local = result.variable->AsLocalVariable(); + + const auto *decl = result.variable->Declaration(); + + if (decl->IsLetOrConstDecl() && !isDecl) { + RegScope rs(pg); + + VReg valueReg = pg->AllocReg(); + pg->StoreAccumulator(node, valueReg); + + ExpandLoadLexVar(pg, node, result); + + if (decl->IsConstDecl()) { + pg->ThrowConstAssignment(node, local->Name()); + } + + pg->LoadAccumulator(node, valueReg); + } + + pg->StoreLexicalVar(node, result.lexLevel, local->LexIdx()); + + StoreLocalExport(pg, node, local); +} + +static void ExpandStoreNormalVar(PandaGen *pg, const ir::AstNode *node, const binder::ScopeFindResult &result, + bool isDecl) +{ + auto *local = result.variable->AsLocalVariable(); + VReg localReg = local->Vreg(); + + if (!isDecl) { + if (CheckTdz(node)) { + pg->LoadConst(node, Constant::JS_HOLE); + pg->ThrowUndefinedIfHole(node, local->Name()); + } + + CheckConstAssignment(pg, node, local); + } + + pg->StoreAccumulator(node, localReg); + StoreLocalExport(pg, node, local); +} + +void VirtualStoreVar::Expand(PandaGen *pg, const ir::AstNode *node, const binder::ScopeFindResult &result, bool isDecl) +{ + if (result.variable->LexicalBound()) { + ExpandStoreLexVar(pg, node, result, isDecl); + } else { + ExpandStoreNormalVar(pg, node, result, isDecl); + } +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/base/lexenv.h b/es2panda/compiler/base/lexenv.h new file mode 100644 index 0000000000..128b8c4579 --- /dev/null +++ b/es2panda/compiler/base/lexenv.h @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2021-2022 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_SCOPES_LEXENV_H +#define ES2PANDA_COMPILER_SCOPES_LEXENV_H + +#include +#include + +namespace panda::es2panda::compiler { + +class PandaGen; + +class VirtualLoadVar { +public: + VirtualLoadVar() = delete; + + static void Expand(PandaGen *pg, const ir::AstNode *node, const binder::ScopeFindResult &result); +}; + +class VirtualStoreVar { +public: + VirtualStoreVar() = delete; + + static void Expand(PandaGen *pg, const ir::AstNode *node, const binder::ScopeFindResult &result, bool isDecl); +}; +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/base/literals.cpp b/es2panda/compiler/base/literals.cpp new file mode 100644 index 0000000000..0690bb6602 --- /dev/null +++ b/es2panda/compiler/base/literals.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2021-2022 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 "literals.h" + +#include +#include +#include +#include + +namespace panda::es2panda::compiler { + +// Literals + +void Literals::GetTemplateObject(PandaGen *pg, const ir::TaggedTemplateExpression *lit) +{ + RegScope rs(pg); + VReg templateArg = pg->AllocReg(); + VReg indexReg = pg->AllocReg(); + VReg rawArr = pg->AllocReg(); + VReg cookedArr = pg->AllocReg(); + + const ir::TemplateLiteral *templateLit = lit->Quasi(); + + pg->CreateEmptyArray(templateLit); + pg->StoreAccumulator(templateLit, rawArr); + + pg->CreateEmptyArray(templateLit); + pg->StoreAccumulator(templateLit, cookedArr); + + size_t elemIndex = 0; + + for (const auto *element : templateLit->Quasis()) { + pg->LoadAccumulatorInt(element, elemIndex); + pg->StoreAccumulator(element, indexReg); + + pg->LoadAccumulatorString(element, element->Raw()); + pg->StoreObjByValue(element, rawArr, indexReg); + + pg->LoadAccumulatorString(element, element->Cooked()); + pg->StoreObjByValue(element, cookedArr, indexReg); + + elemIndex++; + } + + pg->CreateEmptyArray(lit); + pg->StoreAccumulator(lit, templateArg); + + elemIndex = 0; + pg->LoadAccumulatorInt(lit, elemIndex); + pg->StoreAccumulator(lit, indexReg); + + pg->LoadAccumulator(lit, rawArr); + pg->StoreObjByValue(lit, templateArg, indexReg); + + elemIndex++; + pg->LoadAccumulatorInt(lit, elemIndex); + pg->StoreAccumulator(lit, indexReg); + + pg->LoadAccumulator(lit, cookedArr); + pg->StoreObjByValue(lit, templateArg, indexReg); + + pg->GetTemplateObject(lit, templateArg); +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/base/literals.h b/es2panda/compiler/base/literals.h new file mode 100644 index 0000000000..ddda8fc238 --- /dev/null +++ b/es2panda/compiler/base/literals.h @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2021-2022 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_BASE_LITERALS_H +#define ES2PANDA_COMPILER_BASE_LITERALS_H + +#include +#include + +#include + +namespace panda::es2panda::ir { +class Literal; +} // namespace panda::es2panda::ir + +namespace panda::es2panda::checker { +class Checker; +class Type; +} // namespace panda::es2panda::checker + +namespace panda::es2panda::compiler { + +class PandaGen; + +class LiteralBuffer { +public: + explicit LiteralBuffer(ArenaAllocator *allocator) : literals_(allocator->Adapter()) {} + ~LiteralBuffer() = default; + NO_COPY_SEMANTIC(LiteralBuffer); + NO_MOVE_SEMANTIC(LiteralBuffer); + + void Add(ir::Literal *lit) + { + literals_.push_back(lit); + } + + bool IsEmpty() const + { + return literals_.empty(); + } + + size_t Size() const + { + return literals_.size(); + } + + int32_t Index() const + { + return index_; + } + + void ResetLiteral(size_t index, const ir::Literal *literal) + { + literals_[index] = literal; + } + + const ArenaVector &Literals() const + { + return literals_; + } + + void Insert(LiteralBuffer *other) + { + literals_.insert(literals_.end(), other->literals_.begin(), other->literals_.end()); + other->literals_.clear(); + } + + void SetIndex(int32_t index) + { + index_ = index; + } + +private: + ArenaVector literals_; + int32_t index_ {}; +}; + +class Literals { +public: + Literals() = delete; + + static void GetTemplateObject(PandaGen *pg, const ir::TaggedTemplateExpression *lit); +}; + +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/base/lreference.cpp b/es2panda/compiler/base/lreference.cpp new file mode 100644 index 0000000000..6fd21e14ee --- /dev/null +++ b/es2panda/compiler/base/lreference.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2021-2022 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 "lreference.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace panda::es2panda::compiler { + +// LReference + +LReference::LReference(const ir::AstNode *node, PandaGen *pg, bool isDeclaration, ReferenceKind refKind, + binder::ScopeFindResult res) + : node_(node), pg_(pg), refKind_(refKind), res_(res), isDeclaration_(isDeclaration) +{ + if (refKind == ReferenceKind::MEMBER) { + obj_ = pg_->AllocReg(); + + node_->AsMemberExpression()->CompileObject(pg_, obj_); + prop_ = node->AsMemberExpression()->CompileKey(pg_); + } +} + +void LReference::GetValue() +{ + switch (refKind_) { + case ReferenceKind::VAR_OR_GLOBAL: { + pg_->LoadVar(node_->AsIdentifier(), res_); + break; + } + case ReferenceKind::MEMBER: { + pg_->LoadObjProperty(node_, obj_, prop_); + break; + } + default: { + UNREACHABLE(); + } + } +} + +void LReference::SetValue() +{ + switch (refKind_) { + case ReferenceKind::VAR_OR_GLOBAL: { + pg_->StoreVar(node_, res_, isDeclaration_); + break; + } + case ReferenceKind::MEMBER: { + if (node_->AsMemberExpression()->Object()->IsSuperExpression()) { + pg_->StoreSuperProperty(node_, obj_, prop_); + } else { + pg_->StoreObjProperty(node_, obj_, prop_); + } + + break; + } + case ReferenceKind::DESTRUCTURING: { + Destructuring::Compile(pg_, node_->AsExpression()); + break; + } + default: { + UNREACHABLE(); + } + } +} + +ReferenceKind LReference::Kind() const +{ + return refKind_; +} + +binder::Variable *LReference::Variable() const +{ + return res_.variable; +} + +LReference LReference::CreateLRef(PandaGen *pg, const ir::AstNode *node, bool isDeclaration) +{ + switch (node->Type()) { + case ir::AstNodeType::IDENTIFIER: { + const util::StringView &name = node->AsIdentifier()->Name(); + binder::ScopeFindResult res = pg->Scope()->Find(name); + + return {node, pg, isDeclaration, ReferenceKind::VAR_OR_GLOBAL, res}; + } + case ir::AstNodeType::MEMBER_EXPRESSION: { + return {node, pg, false, ReferenceKind::MEMBER, {}}; + } + case ir::AstNodeType::VARIABLE_DECLARATION: { + ASSERT(node->AsVariableDeclaration()->Declarators().size() == 1); + return LReference::CreateLRef(pg, node->AsVariableDeclaration()->Declarators()[0]->Id(), true); + } + case ir::AstNodeType::VARIABLE_DECLARATOR: { + return LReference::CreateLRef(pg, node->AsVariableDeclarator()->Id(), true); + } + case ir::AstNodeType::ARRAY_PATTERN: + case ir::AstNodeType::OBJECT_PATTERN: { + return {node, pg, isDeclaration, ReferenceKind::DESTRUCTURING, {}}; + } + case ir::AstNodeType::ASSIGNMENT_PATTERN: { + return LReference::CreateLRef(pg, node->AsAssignmentPattern()->Left(), true); + } + case ir::AstNodeType::REST_ELEMENT: { + return LReference::CreateLRef(pg, node->AsRestElement()->Argument(), true); + } + default: { + UNREACHABLE(); + } + } +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/base/lreference.h b/es2panda/compiler/base/lreference.h new file mode 100644 index 0000000000..e7edf06f7b --- /dev/null +++ b/es2panda/compiler/base/lreference.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2021-2022 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_BASE_LREFERENCE_H +#define ES2PANDA_COMPILER_BASE_LREFERENCE_H + +#include +#include + +namespace panda::es2panda::ir { +class AstNode; +} // namespace panda::es2panda::ir + +namespace panda::es2panda::compiler { + +enum class ReferenceKind { + MEMBER, + VAR_OR_GLOBAL, + DESTRUCTURING, +}; + +enum class ReferenceFlags { + NONE = 0, + DECLARATION = 1U << 0U, +}; + +class PandaGen; + +class LReference { +public: + LReference(const ir::AstNode *node, PandaGen *pg, bool isDeclaration, ReferenceKind refKind, + binder::ScopeFindResult res); + ~LReference() = default; + NO_COPY_SEMANTIC(LReference); + NO_MOVE_SEMANTIC(LReference); + + void GetValue(); + void SetValue(); + binder::Variable *Variable() const; + ReferenceKind Kind() const; + + static LReference CreateLRef(PandaGen *pg, const ir::AstNode *node, bool isDeclaration); + +private: + const ir::AstNode *node_; + PandaGen *pg_; + ReferenceKind refKind_; + binder::ScopeFindResult res_; + VReg obj_; + Operand prop_; + bool isDeclaration_; +}; + +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/core/compileQueue.cpp b/es2panda/compiler/core/compileQueue.cpp new file mode 100644 index 0000000000..29460a7b3b --- /dev/null +++ b/es2panda/compiler/core/compileQueue.cpp @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2021-2022 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 "compileQueue.h" + +#include +#include +#include +#include +#include +#include + +namespace panda::es2panda::compiler { + +void CompileJob::Run() +{ + std::unique_lock lock(m_); + cond_.wait(lock, [this] { return dependencies_ == 0; }); + + ArenaAllocator allocator(SpaceType::SPACE_TYPE_COMPILER, nullptr, true); + PandaGen pg(&allocator, context_, scope_); + + Function::Compile(&pg); + + FunctionEmitter funcEmitter(&allocator, &pg); + funcEmitter.Generate(); + + context_->GetEmitter()->AddFunction(&funcEmitter); + + if (dependant_) { + dependant_->Signal(); + } +} + +void CompileJob::DependsOn(CompileJob *job) +{ + job->dependant_ = this; + dependencies_++; +} + +void CompileJob::Signal() +{ + { + std::lock_guard lock(m_); + dependencies_--; + } + + cond_.notify_one(); +} + +CompileQueue::CompileQueue(size_t threadCount) +{ + threads_.reserve(threadCount); + + for (size_t i = 0; i < threadCount; i++) { + threads_.push_back(os::thread::ThreadStart(Worker, this)); + } +} + +CompileQueue::~CompileQueue() +{ + void *retval = nullptr; + + std::unique_lock lock(m_); + terminate_ = true; + lock.unlock(); + jobsAvailable_.notify_all(); + + for (const auto handle_id : threads_) { + os::thread::ThreadJoin(handle_id, &retval); + } +} + +void CompileQueue::Schedule(CompilerContext *context) +{ + ASSERT(jobsCount_ == 0); + std::unique_lock lock(m_); + const auto &functions = context->Binder()->Functions(); + jobs_ = new CompileJob[functions.size()](); + + for (auto *function : functions) { + jobs_[jobsCount_++].SetConext(context, function); + } + + lock.unlock(); + jobsAvailable_.notify_all(); +} + +void CompileQueue::Worker(CompileQueue *queue) +{ + while (true) { + std::unique_lock lock(queue->m_); + queue->jobsAvailable_.wait(lock, [queue]() { return queue->terminate_ || queue->jobsCount_ != 0; }); + + if (queue->terminate_) { + return; + } + + lock.unlock(); + + queue->Consume(); + queue->jobsFinished_.notify_one(); + } +} + +void CompileQueue::Consume() +{ + std::unique_lock lock(m_); + activeWorkers_++; + + while (jobsCount_ > 0) { + --jobsCount_; + auto &job = jobs_[jobsCount_]; + + lock.unlock(); + + try { + job.Run(); + } catch (const Error &e) { + lock.lock(); + errors_.push_back(e); + lock.unlock(); + } + + lock.lock(); + } + + activeWorkers_--; +} + +void CompileQueue::Wait() +{ + std::unique_lock lock(m_); + jobsFinished_.wait(lock, [this]() { return activeWorkers_ == 0 && jobsCount_ == 0; }); + delete[] jobs_; + + if (!errors_.empty()) { + // NOLINTNEXTLINE + throw errors_.front(); + } +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/core/compileQueue.h b/es2panda/compiler/core/compileQueue.h new file mode 100644 index 0000000000..5e227475ba --- /dev/null +++ b/es2panda/compiler/core/compileQueue.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2021-2022 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_CORE_COMPILEQUEUE_H +#define ES2PANDA_COMPILER_CORE_COMPILEQUEUE_H + +#include +#include +#include + +#include +#include + +namespace panda::es2panda::binder { +class FunctionScope; +} // namespace panda::es2panda::binder + +namespace panda::es2panda::compiler { + +class CompilerContext; + +class CompileJob { +public: + CompileJob() = default; + NO_COPY_SEMANTIC(CompileJob); + NO_MOVE_SEMANTIC(CompileJob); + ~CompileJob() = default; + + binder::FunctionScope *Scope() const + { + return scope_; + } + + void SetConext(CompilerContext *context, binder::FunctionScope *scope) + { + context_ = context; + scope_ = scope; + } + + void Run(); + void DependsOn(CompileJob *job); + void Signal(); + +private: + std::mutex m_; + std::condition_variable cond_; + CompilerContext *context_ {}; + binder::FunctionScope *scope_ {}; + CompileJob *dependant_ {}; + size_t dependencies_ {0}; +}; + +class CompileQueue { +public: + explicit CompileQueue(size_t threadCount); + NO_COPY_SEMANTIC(CompileQueue); + NO_MOVE_SEMANTIC(CompileQueue); + ~CompileQueue(); + + void Schedule(CompilerContext *context); + void Consume(); + void Wait(); + +private: + static void Worker(CompileQueue *queue); + + std::vector threads_; + std::vector errors_; + std::mutex m_; + std::condition_variable jobsAvailable_; + std::condition_variable jobsFinished_; + CompileJob *jobs_ {}; + size_t jobsCount_ {0}; + size_t activeWorkers_ {0}; + bool terminate_ {false}; +}; + +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/core/compilerContext.cpp b/es2panda/compiler/core/compilerContext.cpp new file mode 100644 index 0000000000..6a97c410fd --- /dev/null +++ b/es2panda/compiler/core/compilerContext.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2021-2022 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 "compilerContext.h" + +#include + +namespace panda::es2panda::compiler { + +CompilerContext::CompilerContext(binder::Binder *binder, bool isDebug) + : binder_(binder), emitter_(std::make_unique(this)), isDebug_(isDebug) +{ +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/core/compilerContext.h b/es2panda/compiler/core/compilerContext.h new file mode 100644 index 0000000000..517163ae62 --- /dev/null +++ b/es2panda/compiler/core/compilerContext.h @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2021-2022 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_CORE_COMPILER_CONTEXT_H +#define ES2PANDA_COMPILER_CORE_COMPILER_CONTEXT_H + +#include +#include + +#include +#include + +namespace panda::es2panda::binder { +class Binder; +} // namespace panda::es2panda::binder + +namespace panda::es2panda::compiler { + +class DebugInfo; +class Emitter; + +class CompilerContext { +public: + CompilerContext(binder::Binder *binder, bool isDebug); + NO_COPY_SEMANTIC(CompilerContext); + NO_MOVE_SEMANTIC(CompilerContext); + ~CompilerContext() = default; + + binder::Binder *Binder() const + { + return binder_; + } + + Emitter *GetEmitter() const + { + return emitter_.get(); + } + + int32_t LiteralCount() const + { + return literalBufferIdx_; + } + + int32_t NewLiteralIndex() + { + std::lock_guard lock(m_); + return literalBufferIdx_++; + } + + std::mutex &Mutex() + { + return m_; + } + + bool IsDebug() const + { + return isDebug_; + } + +private: + binder::Binder *binder_; + std::unique_ptr emitter_; + int32_t literalBufferIdx_ {0}; + std::mutex m_; + bool isDebug_; +}; + +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/core/compilerImpl.cpp b/es2panda/compiler/core/compilerImpl.cpp new file mode 100644 index 0000000000..c4ff569b2a --- /dev/null +++ b/es2panda/compiler/core/compilerImpl.cpp @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2021 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 "compilerImpl.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace panda::es2panda::compiler { + +CompilerImpl::CompilerImpl(size_t threadCount) : queue_(new CompileQueue(threadCount)) {} + +CompilerImpl::~CompilerImpl() +{ + delete queue_; +} + +panda::pandasm::Program *CompilerImpl::Compile(parser::Program *program, const es2panda::CompilerOptions &options) +{ + CompilerContext context(program->Binder(), options.isDebug); + + if (program->Extension() == ScriptExtension::TS) { + ArenaAllocator localAllocator(SpaceType::SPACE_TYPE_COMPILER, nullptr, true); + auto checker = std::make_unique(&localAllocator, context.Binder()); + checker->StartChecker(); + + /* TODO(): TS files are not yet compiled */ + return nullptr; + } + + queue_->Schedule(&context); + + /* Main thread can also be used instead of idling */ + queue_->Consume(); + queue_->Wait(); + + return context.GetEmitter()->Finalize(options.dumpDebugInfo); +} + +void CompilerImpl::DumpAsm(const panda::pandasm::Program *prog) +{ + Emitter::DumpAsm(prog); +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/core/compilerImpl.h b/es2panda/compiler/core/compilerImpl.h new file mode 100644 index 0000000000..19c6061347 --- /dev/null +++ b/es2panda/compiler/core/compilerImpl.h @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2021-2022 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_INCLUDE_COMPILER_IMPL_H +#define ES2PANDA_COMPILER_INCLUDE_COMPILER_IMPL_H + +#include +#include +#include +#include + +#include + +namespace panda::pandasm { +struct Program; +} // namespace panda::pandasm + +namespace panda::es2panda::parser { +class Program; +} // namespace panda::es2panda::parser + +namespace panda::es2panda::compiler { +class CompileQueue; + +class CompilerImpl { +public: + explicit CompilerImpl(size_t threadCount); + ~CompilerImpl(); + NO_COPY_SEMANTIC(CompilerImpl); + NO_MOVE_SEMANTIC(CompilerImpl); + + panda::pandasm::Program *Compile(parser::Program *program, const es2panda::CompilerOptions &options); + static void DumpAsm(const panda::pandasm::Program *prog); + +private: + CompileQueue *queue_; +}; +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/core/dynamicContext.cpp b/es2panda/compiler/core/dynamicContext.cpp new file mode 100644 index 0000000000..73e9e9ddcb --- /dev/null +++ b/es2panda/compiler/core/dynamicContext.cpp @@ -0,0 +1,178 @@ +/** + * Copyright (c) 2021 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 "dynamicContext.h" + +#include +#include +#include +#include +#include +#include + +namespace panda::es2panda::compiler { +DynamicContext::DynamicContext(PandaGen *pg, LabelTarget target) : pg_(pg), target_(target), prev_(pg_->dynamicContext_) +{ + pg_->dynamicContext_ = this; +} + +DynamicContext::~DynamicContext() +{ + pg_->dynamicContext_ = prev_; +} + +LabelContext::LabelContext(PandaGen *pg, const ir::LabelledStatement *labelledStmt) + : DynamicContext(pg, LabelTarget(labelledStmt->Ident()->Name())), labelledStmt_(labelledStmt) +{ + if (!labelledStmt->Body()->IsBlockStatement()) { + return; + } + + label_ = pg->AllocLabel(); + target_.SetBreakTarget(label_); +} + +LabelContext::~LabelContext() +{ + if (!label_) { + return; + } + + pg_->SetLabel(labelledStmt_, label_); +} + +LexEnvContext::LexEnvContext(LoopEnvScope *envScope, PandaGen *pg, LabelTarget target) + : DynamicContext(pg, target), envScope_(envScope) +{ + if (!envScope_->HasEnv()) { + return; + } + + catchTable_ = pg_->CreateCatchTable(); + const auto &labelSet = catchTable_->LabelSet(); + const auto *node = envScope_->Scope()->Node(); + + pg_->SetLabel(node, labelSet.TryBegin()); +} + +LexEnvContext::~LexEnvContext() +{ + if (!envScope_->HasEnv()) { + return; + } + + const auto &labelSet = catchTable_->LabelSet(); + const auto *node = envScope_->Scope()->Node(); + + pg_->SetLabel(node, labelSet.TryEnd()); + pg_->Branch(node, labelSet.CatchEnd()); + + pg_->SetLabel(node, labelSet.CatchBegin()); + pg_->PopLexEnv(node); + pg_->EmitThrow(node); + pg_->SetLabel(node, labelSet.CatchEnd()); + pg_->PopLexEnv(node); +} + +bool LexEnvContext::HasTryCatch() const +{ + return envScope_->HasEnv(); +} + +void LexEnvContext::AbortContext([[maybe_unused]] ControlFlowChange cfc, + [[maybe_unused]] const util::StringView &targetLabel) +{ + if (cfc == ControlFlowChange::CONTINUE || !envScope_->HasEnv()) { + return; + } + + const auto *node = envScope_->Scope()->Node(); + pg_->PopLexEnv(node); +} + +IteratorContext::IteratorContext(PandaGen *pg, const Iterator &iterator, LabelTarget target) + : DynamicContext(pg, target), iterator_(iterator), catchTable_(pg->CreateCatchTable()) +{ + const auto &labelSet = catchTable_->LabelSet(); + pg_->SetLabel(iterator_.Node(), labelSet.TryBegin()); +} + +IteratorContext::~IteratorContext() +{ + const auto &labelSet = catchTable_->LabelSet(); + const auto *node = iterator_.Node(); + + pg_->SetLabel(node, labelSet.TryEnd()); + pg_->Branch(node, labelSet.CatchEnd()); + + pg_->SetLabel(node, labelSet.CatchBegin()); + iterator_.Close(true); + pg_->SetLabel(node, labelSet.CatchEnd()); +} + +void IteratorContext::AbortContext([[maybe_unused]] ControlFlowChange cfc, + [[maybe_unused]] const util::StringView &targetLabel) +{ + if (cfc == ControlFlowChange::CONTINUE && target_.ContinueLabel() == targetLabel) { + return; + } + + iterator_.Close(false); +} + +void TryContext::InitFinalizer() +{ + ASSERT(tryStmt_); + + if (!hasFinalizer_ || !tryStmt_->FinallyBlock()) { + return; + } + + finalizerRun_ = pg_->AllocReg(); + pg_->StoreConst(tryStmt_, finalizerRun_, Constant::JS_UNDEFINED); +} + +void TryContext::InitCatchTable() +{ + catchTable_ = pg_->CreateCatchTable(); +} + +const TryLabelSet &TryContext::LabelSet() const +{ + return catchTable_->LabelSet(); +} + +bool TryContext::HasFinalizer() const +{ + return hasFinalizer_; +} + +void TryContext::EmitFinalizer() +{ + if (!hasFinalizer_ || inFinalizer_ || !tryStmt_->FinallyBlock()) { + return; + } + + inFinalizer_ = true; + tryStmt_->FinallyBlock()->Compile(pg_); + inFinalizer_ = false; +} + +void TryContext::AbortContext([[maybe_unused]] ControlFlowChange cfc, + [[maybe_unused]] const util::StringView &targetLabel) +{ + EmitFinalizer(); +} +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/core/dynamicContext.h b/es2panda/compiler/core/dynamicContext.h new file mode 100644 index 0000000000..2e13faab6e --- /dev/null +++ b/es2panda/compiler/core/dynamicContext.h @@ -0,0 +1,211 @@ +/** + * Copyright (c) 2021 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_CORE_DYNAMIC_CONTEXT_H +#define ES2PANDA_COMPILER_CORE_DYNAMIC_CONTEXT_H + +#include +#include +#include +#include + +namespace panda::es2panda::ir { +class TryStatement; +class ForOfStatement; +class LabelledStatement; +} // namespace panda::es2panda::ir + +namespace panda::es2panda::compiler { +class PandaGen; +class LoopEnvScope; +class CatchTable; +class TryLabelSet; + +enum class DynamicContextType { NONE, LABEL, LEX_ENV, ITERATOR, TRY }; + +class DynamicContext { +public: + NO_COPY_SEMANTIC(DynamicContext); + NO_MOVE_SEMANTIC(DynamicContext); + ~DynamicContext(); + + void *operator new(size_t) = delete; + void *operator new[](size_t) = delete; + + virtual void AbortContext([[maybe_unused]] ControlFlowChange cfc, + [[maybe_unused]] const util::StringView &targetLabel) {}; + + virtual bool HasTryCatch() const + { + return false; + } + + virtual bool HasFinalizer() const + { + return HasTryCatch(); + } + + virtual DynamicContextType Type() const = 0; + + DynamicContext *Prev() + { + return prev_; + } + + const DynamicContext *Prev() const + { + return prev_; + } + + const LabelTarget &Target() const + { + return target_; + } + +protected: + explicit DynamicContext(PandaGen *pg, LabelTarget target); + + PandaGen *pg_; + LabelTarget target_; + DynamicContext *prev_ {}; +}; + +class LabelContext : public DynamicContext { +public: + explicit LabelContext(PandaGen *pg, LabelTarget target) : DynamicContext(pg, target) {} + explicit LabelContext(PandaGen *pg, const ir::LabelledStatement *labelledStmt); + NO_COPY_SEMANTIC(LabelContext); + NO_MOVE_SEMANTIC(LabelContext); + ~LabelContext(); + + DynamicContextType Type() const override + { + return DynamicContextType::LABEL; + } + +private: + Label *label_ {}; + const ir::LabelledStatement *labelledStmt_ {}; +}; + +class LexEnvContext : public DynamicContext { +public: + explicit LexEnvContext(LoopEnvScope *envScope, PandaGen *pg, LabelTarget target); + NO_COPY_SEMANTIC(LexEnvContext); + NO_MOVE_SEMANTIC(LexEnvContext); + ~LexEnvContext(); + + DynamicContextType Type() const override + { + return DynamicContextType::LEX_ENV; + } + + bool HasTryCatch() const override; + void AbortContext([[maybe_unused]] ControlFlowChange cfc, + [[maybe_unused]] const util::StringView &targetLabel) override; + +private: + LoopEnvScope *envScope_; + CatchTable *catchTable_ {}; +}; + +class IteratorContext : public DynamicContext { +public: + explicit IteratorContext(PandaGen *pg, const Iterator &iterator, LabelTarget target); + NO_COPY_SEMANTIC(IteratorContext); + NO_MOVE_SEMANTIC(IteratorContext); + ~IteratorContext(); + + DynamicContextType Type() const override + { + return DynamicContextType::ITERATOR; + } + + const Iterator &GetIterator() const + { + return iterator_; + } + + bool HasTryCatch() const override + { + return true; + } + + void AbortContext([[maybe_unused]] ControlFlowChange cfc, + [[maybe_unused]] const util::StringView &targetLabel) override; + +private: + const Iterator &iterator_; + CatchTable *catchTable_; +}; + +class TryContext : public DynamicContext { +public: + explicit TryContext(PandaGen *pg, const ir::TryStatement *tryStmt, bool hasFinalizer = true) + : DynamicContext(pg, {}), tryStmt_(tryStmt), hasFinalizer_(hasFinalizer) + { + InitCatchTable(); + InitFinalizer(); + } + + explicit TryContext(PandaGen *pg) : DynamicContext(pg, {}) + { + InitCatchTable(); + } + + NO_COPY_SEMANTIC(TryContext); + NO_MOVE_SEMANTIC(TryContext); + ~TryContext() = default; + + DynamicContextType Type() const override + { + return DynamicContextType::TRY; + } + + bool HasTryCatch() const override + { + return true; + } + + VReg FinalizerRun() const + { + return finalizerRun_; + } + + CatchTable *GetCatchTable() const + { + return catchTable_; + } + + const TryLabelSet &LabelSet() const; + bool HasFinalizer() const override; + void InitFinalizer(); + void EmitFinalizer(); + + void AbortContext([[maybe_unused]] ControlFlowChange cfc, + [[maybe_unused]] const util::StringView &targetLabel) override; + +private: + void InitCatchTable(); + + const ir::TryStatement *tryStmt_ {}; + CatchTable *catchTable_ {}; + VReg finalizerRun_ {}; + bool hasFinalizer_ {}; + bool inFinalizer_ {}; +}; +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/core/emitter.cpp b/es2panda/compiler/core/emitter.cpp new file mode 100644 index 0000000000..6e617cb41f --- /dev/null +++ b/es2panda/compiler/core/emitter.cpp @@ -0,0 +1,446 @@ +/** + * Copyright (c) 2021 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 "emitter.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace panda::es2panda::compiler { + +constexpr const auto LANG_EXT = panda::pandasm::extensions::Language::ECMASCRIPT; + +FunctionEmitter::FunctionEmitter(ArenaAllocator *allocator, const PandaGen *pg) + : pg_(pg), literalBuffers_(allocator->Adapter()) +{ + func_ = allocator->New(pg->InternalName().Mutf8(), LANG_EXT); + + size_t paramCount = pg->InternalParamCount(); + func_->params.reserve(paramCount); + + for (uint32_t i = 0; i < paramCount; ++i) { + func_->params.emplace_back(panda::pandasm::Type("any", 0), LANG_EXT); + } + + func_->regs_num = pg->TotalRegsNum(); + func_->return_type = panda::pandasm::Type("any", 0); +} + +void FunctionEmitter::Generate() +{ + GenFunctionInstructions(); + GenVariablesDebugInfo(); + GenSourceFileDebugInfo(); + GenFunctionCatchTables(); + GenFunctionICSize(); + GenLiteralBuffers(); +} + +const ArenaSet &FunctionEmitter::Strings() const +{ + return pg_->Strings(); +} + +void FunctionEmitter::GenBufferLiterals(const LiteralBuffer *buff) +{ + auto &[idx, array] = literalBuffers_.emplace_back(); + idx = buff->Index(); + array.reserve(buff->Literals().size() * 2); + + for (const auto *literal : buff->Literals()) { + panda::pandasm::LiteralArray::Literal valueLit; + panda::pandasm::LiteralArray::Literal tagLit; + + ir::LiteralTag tag = literal->Tag(); + + switch (tag) { + case ir::LiteralTag::BOOLEAN: { + valueLit.tag_ = panda::panda_file::LiteralTag::BOOL; + valueLit.value_ = literal->GetBoolean(); + break; + } + case ir::LiteralTag::INTEGER: { + valueLit.tag_ = panda::panda_file::LiteralTag::INTEGER; + valueLit.value_ = literal->GetInt(); + break; + } + case ir::LiteralTag::DOUBLE: { + valueLit.tag_ = panda::panda_file::LiteralTag::DOUBLE; + valueLit.value_ = literal->GetDouble(); + break; + } + case ir::LiteralTag::STRING: { + valueLit.tag_ = panda::panda_file::LiteralTag::STRING; + valueLit.value_ = literal->GetString().Mutf8(); + break; + } + case ir::LiteralTag::ACCESSOR: { + valueLit.tag_ = panda::panda_file::LiteralTag::ACCESSOR; + valueLit.value_ = static_cast(0); + break; + } + case ir::LiteralTag::METHOD: { + valueLit.tag_ = panda::panda_file::LiteralTag::METHOD; + valueLit.value_ = literal->GetMethod().Mutf8(); + break; + } + case ir::LiteralTag::GENERATOR_METHOD: { + valueLit.tag_ = panda::panda_file::LiteralTag::GENERATORMETHOD; + valueLit.value_ = literal->GetMethod().Mutf8(); + break; + } + case ir::LiteralTag::ASYNC_GENERATOR_METHOD: { + valueLit.tag_ = panda::panda_file::LiteralTag::ASYNCGENERATORMETHOD; + valueLit.value_ = literal->GetMethod().Mutf8(); + break; + } + case ir::LiteralTag::NULL_VALUE: { + valueLit.tag_ = panda::panda_file::LiteralTag::NULLVALUE; + valueLit.value_ = static_cast(0); + break; + } + default: + break; + } + + tagLit.tag_ = panda::panda_file::LiteralTag::TAGVALUE; + tagLit.value_ = static_cast(valueLit.tag_); + + array.emplace_back(tagLit); + array.emplace_back(valueLit); + } +} + +util::StringView FunctionEmitter::SourceCode() const +{ + return pg_->Binder()->Program()->SourceCode(); +} + +static Format MatchFormat(const IRNode *node, const Formats &formats) +{ + std::array regs {}; + auto regCnt = node->Registers(®s); + auto registers = Span(regs.data(), regs.data() + regCnt); + + const auto *iter = formats.begin(); + + for (; iter != formats.end(); iter++) { + auto format = *iter; + size_t limit = 0; + for (const auto &formatItem : format.GetFormatItem()) { + if (formatItem.IsVReg()) { + limit = 1 << formatItem.Bitwidth(); + break; + } + } + + if (std::all_of(registers.begin(), registers.end(), [limit](const VReg *reg) { return *reg < limit; })) { + return format; + } + } + + UNREACHABLE(); + return *iter; +} + +static size_t GetIRNodeWholeLength(const IRNode *node) +{ + Formats formats = node->GetFormats(); + if (formats.empty()) { + return 0; + } + + size_t len = 1; + const auto format = MatchFormat(node, formats); + + for (auto fi : format.GetFormatItem()) { + len += fi.Bitwidth() / 8; + } + + return len; +} + +static std::string WholeLine(const util::StringView &source, lexer::SourceRange range) +{ + return source.Substr(range.start.index, range.end.index).EscapeSymbol(); +} + +void FunctionEmitter::GenInstructionDebugInfo(const IRNode *ins, panda::pandasm::Ins *pandaIns) +{ + const ir::AstNode *astNode = ins->Node(); + + ASSERT(astNode != nullptr); + + if (astNode == FIRST_NODE_OF_FUNCTION) { + astNode = pg_->Debuginfo().firstStmt; + if (!astNode) { + return; + } + } + + pandaIns->ins_debug.line_number = astNode->Range().start.line + 1; + + 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.whole_line = WholeLine(SourceCode(), astNode->Range()); + } +} + +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); + } +} + +void FunctionEmitter::GenFunctionICSize() +{ + panda::pandasm::AnnotationData funcAnnotationData("_ESAnnotation"); + panda::pandasm::AnnotationElement icSizeAnnotationElement( + "icSize", std::make_unique( + panda::pandasm::ScalarValue::Create(pg_->IcSize()))); + funcAnnotationData.AddElement(std::move(icSizeAnnotationElement)); + + panda::pandasm::AnnotationElement parameterLengthAnnotationElement( + "parameterLength", + std::make_unique( + panda::pandasm::ScalarValue::Create(pg_->FormalParametersCount()))); + funcAnnotationData.AddElement(std::move(parameterLengthAnnotationElement)); + + panda::pandasm::AnnotationElement funcNameAnnotationElement( + "funcName", + std::make_unique( + panda::pandasm::ScalarValue::Create(pg_->FunctionName().Mutf8()))); + funcAnnotationData.AddElement(std::move(funcNameAnnotationElement)); + + func_->metadata->AddAnnotations({funcAnnotationData}); +} + +void FunctionEmitter::GenFunctionCatchTables() +{ + func_->catch_blocks.reserve(pg_->CatchList().size()); + + for (const auto *catchBlock : pg_->CatchList()) { + const auto &labelSet = catchBlock->LabelSet(); + + auto &pandaCatchBlock = func_->catch_blocks.emplace_back(); + pandaCatchBlock.try_begin_label = labelSet.TryBegin()->Id(); + pandaCatchBlock.try_end_label = labelSet.TryEnd()->Id(); + pandaCatchBlock.catch_begin_label = labelSet.CatchBegin()->Id(); + pandaCatchBlock.catch_end_label = labelSet.CatchEnd()->Id(); + } +} + +void FunctionEmitter::GenLiteralBuffers() +{ + for (const auto *buff : pg_->BuffStorage()) { + GenBufferLiterals(buff); + } +} + +void FunctionEmitter::GenSourceFileDebugInfo() +{ + func_->source_file = std::string {pg_->Binder()->Program()->SourceFile()}; + + if (!pg_->IsDebug()) { + return; + } + + if (pg_->RootNode()->IsProgram()) { + func_->source_code = SourceCode().EscapeSymbol(); + } +} + +void FunctionEmitter::GenScopeVariableInfo(const binder::Scope *scope) +{ + const auto *startIns = scope->ScopeStart(); + const auto *endIns = scope->ScopeEnd(); + + uint32_t start = 0; + uint32_t count = 0; + + for (const auto *it : pg_->Insns()) { + if (startIns == it) { + start = count; + } else if (endIns == it) { + auto varsLength = static_cast(count - start + 1); + + for (const auto &[name, variable] : scope->Bindings()) { + if (!variable->IsLocalVariable() || variable->LexicalBound()) { + continue; + } + + auto &variableDebug = func_->local_variable_debug.emplace_back(); + variableDebug.name = name.Mutf8(); + variableDebug.signature = "any"; + variableDebug.signature_type = "any"; + variableDebug.reg = static_cast(variable->AsLocalVariable()->Vreg()); + variableDebug.start = start; + variableDebug.length = static_cast(varsLength); + } + + break; + } + + count++; + } +} + +void FunctionEmitter::GenVariablesDebugInfo() +{ + if (!pg_->IsDebug()) { + return; + } + + for (const auto *scope : pg_->Debuginfo().variableDebugInfo) { + GenScopeVariableInfo(scope); + } +} + +// Emitter + +Emitter::Emitter(const CompilerContext *context) +{ + prog_ = new panda::pandasm::Program(); + prog_->lang = panda::pandasm::extensions::Language::ECMASCRIPT; + + prog_->function_table.reserve(context->Binder()->Functions().size()); + GenESAnnoatationRecord(); + GenESModuleModeRecord(context->Binder()->Program()->Kind() == parser::ScriptKind::MODULE); +} + +Emitter::~Emitter() +{ + delete prog_; +} + +void Emitter::GenESAnnoatationRecord() +{ + auto annotationRecord = panda::pandasm::Record("_ESAnnotation", LANG_EXT); + annotationRecord.metadata->SetAttribute("external"); + annotationRecord.metadata->SetAccessFlags(panda::ACC_ANNOTATION); + prog_->record_table.emplace(annotationRecord.name, std::move(annotationRecord)); +} + +void Emitter::GenESModuleModeRecord(bool isModule) +{ + auto modeRecord = panda::pandasm::Record("_ESModuleMode", LANG_EXT); + modeRecord.metadata->SetAccessFlags(panda::ACC_PUBLIC); + + auto modeField = panda::pandasm::Field(LANG_EXT); + modeField.name = "isModule"; + modeField.type = panda::pandasm::Type("u8", 0); + modeField.metadata->SetValue( + panda::pandasm::ScalarValue::Create(static_cast(isModule))); + + modeRecord.field_list.emplace_back(std::move(modeField)); + + prog_->record_table.emplace(modeRecord.name, std::move(modeRecord)); +} + +void Emitter::AddFunction(FunctionEmitter *func) +{ + std::lock_guard lock(m_); + + for (const auto &str : func->Strings()) { + prog_->strings.insert(str.Mutf8()); + } + + for (auto &[idx, buf] : func->LiteralBuffers()) { + auto literalArrayInstance = panda::pandasm::LiteralArray(std::move(buf)); + prog_->literalarray_table.emplace(std::to_string(idx), std::move(literalArrayInstance)); + } + + auto *function = func->Function(); + prog_->function_table.emplace(function->name, std::move(*function)); +} + +void Emitter::DumpAsm(const panda::pandasm::Program *prog) +{ + auto &ss = std::cout; + + ss << ".language ECMAScript" << std::endl << std::endl; + + for (auto &[name, func] : prog->function_table) { + ss << ".function any " << name << '('; + + for (uint32_t i = 0; i < func.GetParamsNum(); i++) { + ss << "any a" << std::to_string(i); + + if (i != func.GetParamsNum() - 1) { + ss << ", "; + } + } + + ss << ") {" << std::endl; + + for (const auto &ins : func.ins) { + ss << (ins.set_label ? "" : "\t") << ins.ToString("", true, func.GetTotalRegs()) << std::endl; + } + + ss << "}" << std::endl << std::endl; + + for (const auto &ct : func.catch_blocks) { + ss << ".catchall " << ct.try_begin_label << ", " << ct.try_end_label << ", " << ct.catch_begin_label + << std::endl + << std::endl; + } + } + + ss << std::endl; +} + +panda::pandasm::Program *Emitter::Finalize(bool dumpDebugInfo) +{ + if (dumpDebugInfo) { + debuginfo::DebugInfoDumper dumper(prog_); + dumper.Dump(); + } + + auto *prog = prog_; + prog_ = nullptr; + return prog; +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/core/emitter.h b/es2panda/compiler/core/emitter.h new file mode 100644 index 0000000000..addf4b142b --- /dev/null +++ b/es2panda/compiler/core/emitter.h @@ -0,0 +1,115 @@ +/** + * Copyright (c) 2021-2022 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_IR_EMITTER_H +#define ES2PANDA_COMPILER_IR_EMITTER_H + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace panda::pandasm { +struct Program; +struct Function; +struct Ins; +} // namespace panda::pandasm + +namespace panda::es2panda::ir { +class Statement; +} // namespace panda::es2panda::ir + +namespace panda::es2panda::binder { +class Scope; +} // namespace panda::es2panda::binder + +namespace panda::es2panda::compiler { + +class PandaGen; +class LiteralBuffer; +class DebugInfo; +class Label; +class IRNode; +class CompilerContext; + +class FunctionEmitter { +public: + explicit FunctionEmitter(ArenaAllocator *allocator, const PandaGen *pg); + ~FunctionEmitter() = default; + NO_COPY_SEMANTIC(FunctionEmitter); + NO_MOVE_SEMANTIC(FunctionEmitter); + + panda::pandasm::Function *Function() + { + return func_; + } + + auto &LiteralBuffers() + { + return literalBuffers_; + } + + void Generate(); + const ArenaSet &Strings() const; + +private: + void GenInstructionDebugInfo(const IRNode *ins, panda::pandasm::Ins *pandaIns); + void GenFunctionInstructions(); + void GenFunctionCatchTables(); + void GenFunctionICSize(); + void GenScopeVariableInfo(const binder::Scope *scope); + void GenSourceFileDebugInfo(); + void GenVariablesDebugInfo(); + util::StringView SourceCode() const; + + void GenLiteralBuffers(); + void GenBufferLiterals(const LiteralBuffer *buff); + + const PandaGen *pg_; + panda::pandasm::Function *func_ {}; + ArenaVector>> literalBuffers_; + size_t offset_ {0}; +}; + +class Emitter { +public: + explicit Emitter(const CompilerContext *context); + ~Emitter(); + NO_COPY_SEMANTIC(Emitter); + NO_MOVE_SEMANTIC(Emitter); + + void AddFunction(FunctionEmitter *func); + static void DumpAsm(const panda::pandasm::Program *prog); + panda::pandasm::Program *Finalize(bool dumpDebugInfo); + +private: + void GenESAnnoatationRecord(); + void GenESModuleModeRecord(bool isModule); + + std::mutex m_; + panda::pandasm::Program *prog_; +}; + +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/core/envScope.cpp b/es2panda/compiler/core/envScope.cpp new file mode 100644 index 0000000000..6e2fa13c78 --- /dev/null +++ b/es2panda/compiler/core/envScope.cpp @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2021-2022 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 "envScope.h" + +#include +#include + +namespace panda::es2panda::compiler { + +ScopeContext::ScopeContext(PandaGen *pg, binder::Scope *newScope) : pg_(pg), prevScope_(pg_->scope_) +{ + pg_->scope_ = newScope; +} + +ScopeContext::~ScopeContext() +{ + pg_->scope_ = prevScope_; +} + +void EnvScope::Initialize(PandaGen *pg, VReg lexEnv) +{ + pg_ = pg; + prev_ = pg_->envScope_; + lexEnv_ = lexEnv; + pg_->envScope_ = this; +} + +EnvScope::~EnvScope() +{ + if (!pg_) { + return; + } + + pg_->envScope_ = prev_; +} + +void LoopEnvScope::CopyBindings(PandaGen *pg, binder::VariableScope *scope, binder::VariableFlags flag) +{ + if (!HasEnv()) { + return; + } + + Initialize(pg, pg->AllocReg()); + + pg_->NewLexEnv(scope_->Node(), scope->LexicalSlots()); + pg_->StoreAccumulator(scope_->Node(), lexEnv_); + + ASSERT(scope->NeedLexEnv()); + + for (const auto &[_, variable] : scope_->Bindings()) { + (void)_; + if (!variable->HasFlag(flag)) { + continue; + } + + pg->LoadLexicalVar(scope_->Node(), 1, variable->AsLocalVariable()->LexIdx()); + pg->StoreLexicalVar(scope_->Parent()->Node(), 0, variable->AsLocalVariable()->LexIdx()); + } +} + +void LoopEnvScope::CopyPetIterationCtx() +{ + if (!HasEnv()) { + return; + } + + pg_->CopyLexEnv(scope_->Node()); + pg_->StoreAccumulator(scope_->Node(), lexEnv_); +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/core/envScope.h b/es2panda/compiler/core/envScope.h new file mode 100644 index 0000000000..55b801a7a1 --- /dev/null +++ b/es2panda/compiler/core/envScope.h @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2021-2022 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_CORE_ENV_SCOPE_H +#define ES2PANDA_COMPILER_CORE_ENV_SCOPE_H + +#include +#include +#include +#include +#include + +namespace panda::es2panda::ir { +class AstNode; +class Statement; +} // namespace panda::es2panda::ir + +namespace panda::es2panda::compiler { + +class PandaGen; + +class ScopeContext { +public: + explicit ScopeContext(PandaGen *pg, binder::Scope *newScope); + ~ScopeContext(); + + NO_COPY_SEMANTIC(ScopeContext); + NO_MOVE_SEMANTIC(ScopeContext); + +private: + PandaGen *pg_; + binder::Scope *prevScope_; +}; + +class EnvScope { +public: + explicit EnvScope() = default; + + NO_COPY_SEMANTIC(EnvScope); + NO_MOVE_SEMANTIC(EnvScope); + ~EnvScope(); + + void Initialize(PandaGen *pg, VReg lexEnv); + + VReg LexEnv() const + { + return lexEnv_; + } + + EnvScope *Prev() const + { + return prev_; + } + +protected: + friend class PandaGen; + + PandaGen *pg_ {}; + EnvScope *prev_ {}; + VReg lexEnv_ {}; +}; + +class LoopEnvScope : public EnvScope { +public: + explicit LoopEnvScope(PandaGen *pg, binder::LoopScope *scope, LabelTarget target) + : scope_(NeedEnv(scope) ? scope : nullptr), regScope_(pg, scope), lexEnvCtx_(this, pg, target) + { + CopyBindings(pg, scope, binder::VariableFlags::PER_ITERATION); + } + + explicit LoopEnvScope(PandaGen *pg, LabelTarget target, binder::LoopScope *scope) + : scope_(NeedEnv(scope) ? scope : nullptr), regScope_(pg), lexEnvCtx_(this, pg, target) + { + CopyBindings(pg, scope, binder::VariableFlags::PER_ITERATION); + } + + explicit LoopEnvScope(PandaGen *pg, binder::LoopDeclarationScope *scope) + : scope_(NeedEnv(scope) ? scope : nullptr), regScope_(pg), lexEnvCtx_(this, pg, {}) + { + CopyBindings(pg, scope, binder::VariableFlags::LOOP_DECL); + } + + binder::VariableScope *Scope() const + { + ASSERT(HasEnv()); + return scope_; + } + + bool HasEnv() const + { + return scope_ != nullptr; + } + + void CopyPetIterationCtx(); + +private: + static bool NeedEnv(binder::VariableScope *scope) + { + return scope->IsVariableScope() && scope->AsVariableScope()->NeedLexEnv(); + } + + void CopyBindings(PandaGen *pg, binder::VariableScope *scope, binder::VariableFlags flag); + + binder::VariableScope *scope_ {}; + LocalRegScope regScope_; + LexEnvContext lexEnvCtx_; +}; + +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/core/function.cpp b/es2panda/compiler/core/function.cpp new file mode 100644 index 0000000000..8625e3f281 --- /dev/null +++ b/es2panda/compiler/core/function.cpp @@ -0,0 +1,208 @@ +/** + * Copyright (c) 2021-2022 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 "function.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace panda::es2panda::compiler { + +static void CompileSourceBlock(PandaGen *pg, const ir::BlockStatement *block) +{ + bool hasReturn = false; + + const auto &statements = block->Statements(); + pg->SetFirstStmt(statements.empty() ? block : statements.front()); + + for (const auto *stmt : statements) { + stmt->Compile(pg); + + if (stmt->IsReturnStatement()) { + hasReturn = true; + } + } + + if (hasReturn) { + return; + } + + pg->ImplicitReturn(statements.empty() ? block : statements.back()); +} + +static void CompileFunctionParameterDeclaration(PandaGen *pg, const ir::ScriptFunction *func) +{ + ScopeContext scopeCtx(pg, func->Scope()->ParamScope()); + + uint32_t index = 0; + + for (const auto *param : func->Params()) { + LReference ref = LReference::CreateLRef(pg, param, true); + + [[maybe_unused]] binder::Variable *paramVar = ref.Variable(); + + if (ref.Kind() == ReferenceKind::DESTRUCTURING) { + util::StringView name = util::Helpers::ToStringView(pg->Allocator(), index); + paramVar = pg->Scope()->FindLocal(name, binder::ResolveBindingOptions::BINDINGS); + } + + ASSERT(paramVar && paramVar->IsLocalVariable()); + + VReg paramReg = binder::Binder::MANDATORY_PARAMS_NUMBER + index++; + ASSERT(paramVar->LexicalBound() || paramVar->AsLocalVariable()->Vreg() == paramReg); + + if (param->IsAssignmentPattern()) { + RegScope rs(pg); + pg->LoadAccumulator(func, paramReg); + auto *nonDefaultLabel = pg->AllocLabel(); + + if (ref.Kind() == ReferenceKind::DESTRUCTURING) { + auto *loadParamLabel = pg->AllocLabel(); + + pg->BranchIfNotUndefined(func, loadParamLabel); + param->AsAssignmentPattern()->Right()->Compile(pg); + pg->Branch(func, nonDefaultLabel); + + pg->SetLabel(func, loadParamLabel); + pg->LoadAccumulator(func, paramReg); + + pg->SetLabel(func, nonDefaultLabel); + ref.SetValue(); + } else { + pg->BranchIfNotUndefined(func, nonDefaultLabel); + + param->AsAssignmentPattern()->Right()->Compile(pg); + ref.SetValue(); + pg->SetLabel(func, nonDefaultLabel); + } + + continue; + } + + if (param->IsRestElement()) { + pg->CopyRestArgs(param, func->Params().size() - 1); + } else if (ref.Kind() == ReferenceKind::DESTRUCTURING) { + pg->LoadAccumulator(func, paramReg); + } else { + continue; + } + ref.SetValue(); + } +} + +static void CompileInstanceFields(PandaGen *pg, const ir::ScriptFunction *decl) +{ + const auto &statements = decl->Parent()->Parent()->Parent()->AsClassDefinition()->Body(); + + RegScope rs(pg); + auto thisReg = pg->AllocReg(); + pg->GetThis(decl); + pg->StoreAccumulator(decl, thisReg); + + for (auto const &stmt : statements) { + if (stmt->IsClassProperty()) { + const auto *prop = stmt->AsClassProperty(); + if (!prop->Value()) { + pg->LoadConst(stmt, Constant::JS_UNDEFINED); + } else { + RegScope rsProp(pg); + prop->Value()->Compile(pg); + } + + if (!prop->Key()->IsIdentifier()) { + PandaGen::Unimplemented(); + } + + pg->StoreObjByName(stmt, thisReg, prop->Key()->AsIdentifier()->Name()); + } + } +} + +static void CompileFunction(PandaGen *pg) +{ + const auto *decl = pg->RootNode()->AsScriptFunction(); + + // TODO(szilagyia): move after super call + if (decl->IsConstructor()) { + CompileInstanceFields(pg, decl); + } + + auto *funcParamScope = pg->TopScope()->ParamScope(); + if (funcParamScope->NameVar()) { + RegScope rs(pg); + pg->GetFunctionObject(pg->RootNode()); + pg->StoreAccToLexEnv(pg->RootNode(), funcParamScope->Find(funcParamScope->NameVar()->Name()), true); + } + + CompileFunctionParameterDeclaration(pg, decl); + + pg->FunctionEnter(); + const ir::AstNode *body = decl->Body(); + + if (body->IsExpression()) { + body->Compile(pg); + pg->DirectReturn(decl); + } else { + CompileSourceBlock(pg, body->AsBlockStatement()); + } + + pg->FunctionExit(); +} + +static VReg CompileFunctionOrProgram(PandaGen *pg) +{ + FunctionRegScope lrs(pg); + const auto *topScope = pg->TopScope(); + + if (pg->FunctionHasFinalizer()) { + ASSERT(topScope->IsFunctionScope()); + + TryContext tryCtx(pg); + pg->FunctionInit(tryCtx.GetCatchTable()); + + CompileFunction(pg); + } else { + pg->FunctionInit(nullptr); + + if (topScope->IsFunctionScope()) { + CompileFunction(pg); + } else { + ASSERT(topScope->IsGlobalScope() || topScope->IsModuleScope()); + CompileSourceBlock(pg, pg->RootNode()->AsBlockStatement()); + } + } + + return pg->GetEnvScope()->LexEnv(); +} + +void Function::Compile(PandaGen *pg) +{ + VReg lexEnv = CompileFunctionOrProgram(pg); + pg->CopyFunctionArguments(pg->RootNode()); + pg->InitializeLexEnv(pg->RootNode(), lexEnv); + pg->SortCatchTables(); +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/core/function.h b/es2panda/compiler/core/function.h new file mode 100644 index 0000000000..4be6f755aa --- /dev/null +++ b/es2panda/compiler/core/function.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021-2022 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_CORE_FUNCTION_H +#define ES2PANDA_COMPILER_CORE_FUNCTION_H + +namespace panda::es2panda::compiler { + +class PandaGen; + +class Function { +public: + Function() = delete; + + static void Compile(PandaGen *pg); +}; + +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/core/inlineCache.cpp b/es2panda/compiler/core/inlineCache.cpp new file mode 100644 index 0000000000..0570e0f897 --- /dev/null +++ b/es2panda/compiler/core/inlineCache.cpp @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2021-2022 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 "inlineCache.h" + +#include + +namespace panda::es2panda::compiler { + +size_t InlineCache::Size() const +{ + return size_; +} + +uint32_t InlineCache::Offset(uint32_t slotSize) +{ + uint32_t offset = size_ + slotSize; + + constexpr uint32_t LIMIT = std::numeric_limits::max(); + if (offset > LIMIT) { + return LIMIT; + } + + size_ = offset; + return offset; +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/core/inlineCache.h b/es2panda/compiler/core/inlineCache.h new file mode 100644 index 0000000000..3b8ee40827 --- /dev/null +++ b/es2panda/compiler/core/inlineCache.h @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2021-2022 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_IR_INLINE_CACHE_H +#define ES2PANDA_COMPILER_IR_INLINE_CACHE_H + +#include + +namespace panda::es2panda::compiler { + +class InlineCache { +public: + explicit InlineCache() = default; + + size_t Size() const; + uint32_t Offset(uint32_t slotSize); + +private: + size_t size_ {}; +}; + +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/core/labelPair.h b/es2panda/compiler/core/labelPair.h new file mode 100644 index 0000000000..ec85351877 --- /dev/null +++ b/es2panda/compiler/core/labelPair.h @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2021-2022 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_CORE_LABEL_PAIR_H +#define ES2PANDA_COMPILER_CORE_LABEL_PAIR_H + +#include +#include + +namespace panda::es2panda::compiler { +class LabelPair { +public: + LabelPair(Label *begin, Label *end) : begin_(begin), end_(end) {} + + Label *Begin() const + { + return begin_; + } + + Label *End() const + { + return end_; + } + +protected: + Label *begin_ {}; + Label *end_ {}; +}; +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/core/labelTarget.cpp b/es2panda/compiler/core/labelTarget.cpp new file mode 100644 index 0000000000..3fc9530fa0 --- /dev/null +++ b/es2panda/compiler/core/labelTarget.cpp @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2021-2022 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 "labelTarget.h" + +#include + +namespace panda::es2panda::compiler { + +LabelTarget::LabelTarget(PandaGen *pg) + : LabelPair(pg->AllocLabel(), pg->AllocLabel()), breakLabel_(BREAK_LABEL), continueLabel_(CONTINUE_LABEL) +{ +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/core/labelTarget.h b/es2panda/compiler/core/labelTarget.h new file mode 100644 index 0000000000..6c9ee9792b --- /dev/null +++ b/es2panda/compiler/core/labelTarget.h @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2021 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_CORE_LABEL_TARGET_H +#define ES2PANDA_COMPILER_CORE_LABEL_TARGET_H + +#include +#include + +#include + +namespace panda::es2panda::ir { +class AstNode; +class Identifier; +} // namespace panda::es2panda::ir + +namespace panda::es2panda::compiler { + +class LabelTarget; +class PandaGen; + +enum class ControlFlowChange { + CONTINUE, + BREAK, +}; + +class LabelTarget : public LabelPair { +public: + explicit LabelTarget(PandaGen *pg); + explicit LabelTarget(const util::StringView &label) : LabelTarget(nullptr, label) {} + explicit LabelTarget(Label *target, const util::StringView &label) + : LabelPair(target, nullptr), breakLabel_(label), continueLabel_(label) + { + } + LabelTarget() : LabelPair(nullptr, nullptr) {}; + + ~LabelTarget() = default; + DEFAULT_COPY_SEMANTIC(LabelTarget); + DEFAULT_MOVE_SEMANTIC(LabelTarget); + + const util::StringView &BreakLabel() const + { + return breakLabel_; + } + + Label *BreakTarget() const + { + return begin_; + } + + void SetBreakTarget(Label *label) + { + begin_ = label; + } + + const util::StringView &ContinueLabel() const + { + return continueLabel_; + } + + Label *ContinueTarget() const + { + return end_; + } + + static constexpr std::string_view BREAK_LABEL = "#b"; + static constexpr std::string_view CONTINUE_LABEL = "#c"; + +private: + util::StringView breakLabel_ {}; + util::StringView continueLabel_ {}; +}; + +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/core/moduleContext.cpp b/es2panda/compiler/core/moduleContext.cpp new file mode 100644 index 0000000000..272a319c36 --- /dev/null +++ b/es2panda/compiler/core/moduleContext.cpp @@ -0,0 +1,84 @@ +/** + * Copyright (c) 2021 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 "moduleContext.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace panda::es2panda::compiler { +void CompileImports(PandaGen *pg, binder::ModuleScope *scope) +{ + for (const auto &[importDecl, decls] : scope->Imports()) { + pg->ImportModule(importDecl, importDecl->Source()->Str()); + + VReg moduleReg = pg->AllocReg(); + pg->StoreAccumulator(importDecl, moduleReg); + + for (const auto *decl : decls) { + binder::Variable *v = scope->FindLocal(decl->LocalName()); + + if (!v->IsModuleVariable()) { + ASSERT(decl->ImportName() == "*"); + + binder::ScopeFindResult result(decl->LocalName(), scope, 0, v); + pg->StoreAccToLexEnv(decl->Node(), result, true); + } else { + v->AsModuleVariable()->ModuleReg() = moduleReg; + } + } + } +} + +void CompileExports(PandaGen *pg, const binder::ModuleScope *scope) +{ + for (const auto &[exportDecl, decls] : scope->Exports()) { + if (exportDecl->IsExportAllDeclaration()) { + pg->ImportModule(exportDecl, exportDecl->AsExportAllDeclaration()->Source()->Str()); + } else if (exportDecl->IsExportNamedDeclaration() && exportDecl->AsExportNamedDeclaration()->Source()) { + pg->ImportModule(exportDecl, exportDecl->AsExportNamedDeclaration()->Source()->Str()); + } else { + continue; + } + + VReg moduleReg = pg->AllocReg(); + pg->StoreAccumulator(exportDecl, moduleReg); + + if (exportDecl->IsExportAllDeclaration()) { + pg->StoreModuleVar(exportDecl, decls.front()->ExportName()); + continue; + } + + pg->CopyModule(exportDecl, moduleReg); + + for (const auto *decl : decls) { + pg->LoadObjByName(decl->Node(), moduleReg, decl->LocalName()); + pg->StoreModuleVar(decl->Node(), decl->ExportName()); + } + } +} + +void ModuleContext::Compile(PandaGen *pg, binder::ModuleScope *scope) +{ + CompileImports(pg, scope); + CompileExports(pg, scope); +} +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/core/moduleContext.h b/es2panda/compiler/core/moduleContext.h new file mode 100644 index 0000000000..da15b229fe --- /dev/null +++ b/es2panda/compiler/core/moduleContext.h @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2021-2022 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_CORE_MODULE_CONTEXT_H +#define ES2PANDA_COMPILER_CORE_MODULE_CONTEXT_H + +#include + +#include + +namespace panda::es2panda::binder { +class Variable; +class ModuleScope; +} // namespace panda::es2panda::binder + +namespace panda::es2panda::compiler { +class PandaGen; + +class ModuleContext { +public: + ModuleContext() = delete; + + static void Compile(PandaGen *pg, binder::ModuleScope *scope); +}; +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/core/pandagen.cpp b/es2panda/compiler/core/pandagen.cpp new file mode 100644 index 0000000000..7d58fa71c4 --- /dev/null +++ b/es2panda/compiler/core/pandagen.cpp @@ -0,0 +1,1526 @@ +/* + * Copyright (c) 2021-2022 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 "pandagen.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace panda::es2panda::compiler { + +// PandaGen + +Label *PandaGen::AllocLabel() +{ + std::string id = std::string {Label::PREFIX} + std::to_string(labelId_++); + return sa_.AllocLabel(std::move(id)); +} + +bool PandaGen::IsDebug() const +{ + return context_->IsDebug(); +} + +uint32_t PandaGen::ParamCount() const +{ + if (rootNode_->IsProgram()) { + return 0; + } + + return rootNode_->AsScriptFunction()->Params().size(); +} + +uint32_t PandaGen::FormalParametersCount() const +{ + if (rootNode_->IsProgram()) { + return 0; + } + + ASSERT(rootNode_->IsScriptFunction()); + + return rootNode_->AsScriptFunction()->FormalParamsLength(); +} + +uint32_t PandaGen::InternalParamCount() const +{ + static const uint32_t HIDDEN_PARAMS = 3; + return ParamCount() + HIDDEN_PARAMS; +} + +const util::StringView &PandaGen::InternalName() const +{ + return topScope_->InternalName(); +} + +const util::StringView &PandaGen::FunctionName() const +{ + return topScope_->Name(); +} + +binder::Binder *PandaGen::Binder() const +{ + return context_->Binder(); +} + +void PandaGen::FunctionInit(CatchTable *catchTable) +{ + if (rootNode_->IsProgram()) { + builder_ = allocator_->New(this, catchTable); + return; + } + + const ir::ScriptFunction *func = rootNode_->AsScriptFunction(); + + if (func->IsAsync()) { + if (func->IsGenerator()) { + builder_ = allocator_->New(this, catchTable); + return; + } + + builder_ = allocator_->New(this, catchTable); + return; + } + + if (func->IsGenerator()) { + builder_ = allocator_->New(this, catchTable); + return; + } + + builder_ = allocator_->New(this, catchTable); +} + +bool PandaGen::FunctionHasFinalizer() const +{ + if (rootNode_->IsProgram()) { + return false; + } + + const ir::ScriptFunction *func = rootNode_->AsScriptFunction(); + + return func->IsAsync() || func->IsGenerator(); +} + +void PandaGen::FunctionEnter() +{ + builder_->Prepare(rootNode_->AsScriptFunction()); +} + +void PandaGen::FunctionExit() +{ + builder_->CleanUp(rootNode_->AsScriptFunction()); +} + +void PandaGen::InitializeLexEnv(const ir::AstNode *node, VReg lexEnv) +{ + FrontAllocator fa(this); + + if (topScope_->NeedLexEnv()) { + NewLexEnv(node, topScope_->LexicalSlots()); + } else { + LdLexEnv(node); + } + + StoreAccumulator(node, lexEnv); +} + +void PandaGen::CopyFunctionArguments(const ir::AstNode *node) +{ + FrontAllocator fa(this); + VReg targetReg = totalRegs_; + + for (const auto *param : topScope_->ParamScope()->Params()) { + if (param->LexicalBound()) { + LoadAccumulator(node, targetReg++); + StoreLexicalVar(node, 0, param->LexIdx()); + } else { + ra_.Emit(node, param->Vreg(), targetReg++); + } + } +} + +LiteralBuffer *PandaGen::NewLiteralBuffer() +{ + return allocator_->New(allocator_); +} + +int32_t PandaGen::AddLiteralBuffer(LiteralBuffer *buf) +{ + buffStorage_.push_back(buf); + buf->SetIndex(context_->NewLiteralIndex()); + return buf->Index(); +} + +void PandaGen::GetFunctionObject(const ir::AstNode *node) +{ + LoadAccFromLexEnv(node, scope_->Find(binder::Binder::MANDATORY_PARAM_FUNC)); +} + +void PandaGen::GetNewTarget(const ir::AstNode *node) +{ + LoadAccFromLexEnv(node, scope_->Find(binder::Binder::MANDATORY_PARAM_NEW_TARGET)); +} + +void PandaGen::GetThis(const ir::AstNode *node) +{ + LoadAccFromLexEnv(node, scope_->Find(binder::Binder::MANDATORY_PARAM_THIS)); +} + +void PandaGen::SetThis(const ir::AstNode *node) +{ + StoreAccToLexEnv(node, scope_->Find(binder::Binder::MANDATORY_PARAM_THIS), true); +} + +void PandaGen::LoadVar(const ir::Identifier *node, const binder::ScopeFindResult &result) +{ + auto *var = result.variable; + + if (!var) { + TryLoadGlobalByName(node, result.name); + return; + } + + if (var->IsGlobalVariable()) { + LoadGlobalVar(node, var->Name()); + return; + } + + if (var->IsModuleVariable()) { + LoadModuleVariable(node, var->AsModuleVariable()->ModuleReg(), var->AsModuleVariable()->ExoticName()); + return; + } + + ASSERT(var->IsLocalVariable()); + LoadAccFromLexEnv(node, result); +} + +void PandaGen::StoreVar(const ir::AstNode *node, const binder::ScopeFindResult &result, bool isDeclaration) +{ + binder::Variable *var = result.variable; + + if (!var) { + TryStoreGlobalByName(node, result.name); + return; + } + + if (var->IsGlobalVariable()) { + StoreGlobalVar(node, var->Name()); + return; + } + + if (var->IsModuleVariable()) { + ThrowConstAssignment(node, var->Name()); + return; + } + + ASSERT(var->IsLocalVariable()); + StoreAccToLexEnv(node, result, isDeclaration); +} + +void PandaGen::StoreAccumulator(const ir::AstNode *node, VReg vreg) +{ + ra_.Emit(node, vreg); +} + +void PandaGen::LoadAccFromArgs(const ir::AstNode *node) +{ + const auto *varScope = scope_->AsVariableScope(); + + if (!varScope->HasFlag(binder::VariableScopeFlags::USE_ARGS)) { + return; + } + + binder::ScopeFindResult res = scope_->Find(binder::Binder::FUNCTION_ARGUMENTS); + ASSERT(res.scope); + + GetUnmappedArgs(node); + StoreAccToLexEnv(node, res, true); +} + +void PandaGen::LoadObjProperty(const ir::AstNode *node, VReg obj, const Operand &prop) +{ + if (std::holds_alternative(prop)) { + LoadObjByValue(node, obj, std::get(prop)); + return; + } + + if (std::holds_alternative(prop)) { + LoadObjByIndex(node, obj, std::get(prop)); + return; + } + + ASSERT(std::holds_alternative(prop)); + LoadObjByName(node, obj, std::get(prop)); +} + +void PandaGen::StoreObjProperty(const ir::AstNode *node, VReg obj, const Operand &prop) +{ + if (std::holds_alternative(prop)) { + StoreObjByValue(node, obj, std::get(prop)); + return; + } + + if (std::holds_alternative(prop)) { + StoreObjByIndex(node, obj, std::get(prop)); + return; + } + + ASSERT(std::holds_alternative(prop)); + StoreObjByName(node, obj, std::get(prop)); +} + +void PandaGen::StoreOwnProperty(const ir::AstNode *node, VReg obj, const Operand &prop) +{ + if (std::holds_alternative(prop)) { + StOwnByValue(node, obj, std::get(prop)); + return; + } + + if (std::holds_alternative(prop)) { + StOwnByIndex(node, obj, std::get(prop)); + return; + } + + ASSERT(std::holds_alternative(prop)); + StOwnByName(node, obj, std::get(prop)); +} + +void PandaGen::TryLoadGlobalByName(const ir::AstNode *node, const util::StringView &name) +{ + sa_.Emit(node, name); + strings_.insert(name); +} + +void PandaGen::TryStoreGlobalByName(const ir::AstNode *node, const util::StringView &name) +{ + sa_.Emit(node, name); + strings_.insert(name); +} + +void PandaGen::LoadObjByName(const ir::AstNode *node, VReg obj, const util::StringView &prop) +{ + ra_.Emit(node, prop, obj); + strings_.insert(prop); +} + +void PandaGen::StoreObjByName(const ir::AstNode *node, VReg obj, const util::StringView &prop) +{ + ra_.Emit(node, prop, obj); + strings_.insert(prop); +} + +void PandaGen::LoadObjByIndex(const ir::AstNode *node, VReg obj, int64_t index) +{ + ra_.Emit(node, index, obj); +} + +void PandaGen::LoadObjByValue(const ir::AstNode *node, VReg obj, VReg prop) +{ + ra_.Emit(node, obj, prop); +} + +void PandaGen::StoreObjByValue(const ir::AstNode *node, VReg obj, VReg prop) +{ + ra_.Emit(node, obj, prop); +} + +void PandaGen::StoreObjByIndex(const ir::AstNode *node, VReg obj, int64_t index) +{ + ra_.Emit(node, index, obj); +} + +void PandaGen::StOwnByName(const ir::AstNode *node, VReg obj, const util::StringView &prop) +{ + ra_.Emit(node, prop, obj); + strings_.insert(prop); +} + +void PandaGen::StOwnByValue(const ir::AstNode *node, VReg obj, VReg prop) +{ + ra_.Emit(node, obj, prop); +} + +void PandaGen::StOwnByIndex(const ir::AstNode *node, VReg obj, int64_t index) +{ + ra_.Emit(node, index, obj); +} + +void PandaGen::DeleteObjProperty(const ir::AstNode *node, VReg obj, const Operand &prop) +{ + VReg property {}; + + if (std::holds_alternative(prop)) { + property = std::get(prop); + } else if (std::holds_alternative(prop)) { + LoadAccumulatorInt(node, static_cast(std::get(prop))); + property = AllocReg(); + StoreAccumulator(node, property); + } else { + ASSERT(std::holds_alternative(prop)); + LoadAccumulatorString(node, std::get(prop)); + property = AllocReg(); + StoreAccumulator(node, property); + } + + ra_.Emit(node, obj, property); +} + +void PandaGen::LoadAccumulator(const ir::AstNode *node, VReg reg) +{ + ra_.Emit(node, reg); +} + +void PandaGen::LoadGlobalVar(const ir::AstNode *node, const util::StringView &name) +{ + sa_.Emit(node, name); + strings_.insert(name); +} + +void PandaGen::StoreGlobalVar(const ir::AstNode *node, const util::StringView &name) +{ + sa_.Emit(node, name); + strings_.insert(name); +} + +void PandaGen::StoreGlobalLet(const ir::AstNode *node, const util::StringView &name) +{ + sa_.Emit(node, name); + strings_.insert(name); +} + +VReg PandaGen::LexEnv() const +{ + return envScope_->LexEnv(); +} + +void PandaGen::LoadAccFromLexEnv(const ir::AstNode *node, const binder::ScopeFindResult &result) +{ + VirtualLoadVar::Expand(this, node, result); +} + +void PandaGen::StoreAccToLexEnv(const ir::AstNode *node, const binder::ScopeFindResult &result, bool isDeclaration) +{ + VirtualStoreVar::Expand(this, node, result, isDeclaration); +} + +void PandaGen::LoadAccumulatorString(const ir::AstNode *node, const util::StringView &str) +{ + sa_.Emit(node, str); + strings_.insert(str); +} + +void PandaGen::LoadAccumulatorFloat(const ir::AstNode *node, double num) +{ + sa_.Emit(node, num); +} + +void PandaGen::LoadAccumulatorInt(const ir::AstNode *node, int32_t num) +{ + sa_.Emit(node, num); +} + +void PandaGen::LoadAccumulatorInt(const ir::AstNode *node, size_t num) +{ + sa_.Emit(node, static_cast(num)); +} + +void PandaGen::StoreConst(const ir::AstNode *node, VReg reg, Constant id) +{ + LoadConst(node, id); + StoreAccumulator(node, reg); +} + +void PandaGen::LoadConst(const ir::AstNode *node, Constant id) +{ + switch (id) { + case Constant::JS_HOLE: { + sa_.Emit(node); + break; + } + case Constant::JS_NAN: { + sa_.Emit(node); + break; + } + case Constant::JS_INFINITY: { + sa_.Emit(node); + break; + } + case Constant::JS_GLOBAL: { + sa_.Emit(node); + break; + } + case Constant::JS_UNDEFINED: { + sa_.Emit(node); + break; + } + case Constant::JS_SYMBOL: { + sa_.Emit(node); + break; + } + case Constant::JS_NULL: { + sa_.Emit(node); + break; + } + case Constant::JS_TRUE: { + sa_.Emit(node); + break; + } + case Constant::JS_FALSE: { + sa_.Emit(node); + break; + } + default: { + UNREACHABLE(); + } + } +} + +void PandaGen::MoveVreg(const ir::AstNode *node, VReg vd, VReg vs) +{ + ra_.Emit(node, vd, vs); +} + +void PandaGen::SetLabel([[maybe_unused]] const ir::AstNode *node, Label *label) +{ + sa_.AddLabel(label); +} + +void PandaGen::Branch(const ir::AstNode *node, Label *label) +{ + sa_.Emit(node, label); +} + +bool PandaGen::CheckControlFlowChange() +{ + const auto *iter = dynamicContext_; + + while (iter) { + if (iter->HasFinalizer()) { + return true; + } + + iter = iter->Prev(); + } + + return false; +} + +Label *PandaGen::ControlFlowChangeBreak(const ir::Identifier *label) +{ + auto *iter = dynamicContext_; + + util::StringView labelName = label ? label->Name() : LabelTarget::BREAK_LABEL; + Label *breakTarget = nullptr; + + while (iter) { + iter->AbortContext(ControlFlowChange::BREAK, labelName); + + const auto &labelTargetName = iter->Target().BreakLabel(); + + if (iter->Target().BreakTarget()) { + breakTarget = iter->Target().BreakTarget(); + } + + if (labelTargetName == labelName) { + break; + } + + iter = iter->Prev(); + } + + return breakTarget; +} + +Label *PandaGen::ControlFlowChangeContinue(const ir::Identifier *label) +{ + auto *iter = dynamicContext_; + util::StringView labelName = label ? label->Name() : LabelTarget::CONTINUE_LABEL; + Label *continueTarget = nullptr; + + while (iter) { + iter->AbortContext(ControlFlowChange::CONTINUE, labelName); + + const auto &labelTargetName = iter->Target().ContinueLabel(); + + if (iter->Target().ContinueTarget()) { + continueTarget = iter->Target().ContinueTarget(); + } + + if (labelTargetName == labelName) { + break; + } + + iter = iter->Prev(); + } + + return continueTarget; +} + +void PandaGen::Condition(const ir::AstNode *node, lexer::TokenType op, VReg lhs, Label *ifFalse) +{ + switch (op) { + case lexer::TokenType::PUNCTUATOR_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_NOT_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_STRICT_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_NOT_STRICT_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_LESS_THAN: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_LESS_THAN_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_GREATER_THAN: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_GREATER_THAN_EQUAL: { + ra_.Emit(node, lhs); + break; + } + default: { + UNREACHABLE(); + } + } + + BranchIfFalse(node, ifFalse); +} + +void PandaGen::Unary(const ir::AstNode *node, lexer::TokenType op, VReg operand) +{ + switch (op) { + case lexer::TokenType::PUNCTUATOR_PLUS: { + ra_.Emit(node, operand); + break; + } + case lexer::TokenType::PUNCTUATOR_MINUS: { + ra_.Emit(node, operand); + break; + } + case lexer::TokenType::PUNCTUATOR_TILDE: { + ra_.Emit(node, operand); + break; + } + case lexer::TokenType::PUNCTUATOR_EXCLAMATION_MARK: { + sa_.Emit(node); + break; + } + case lexer::TokenType::PUNCTUATOR_PLUS_PLUS: { + ra_.Emit(node, operand); + break; + } + case lexer::TokenType::PUNCTUATOR_MINUS_MINUS: { + ra_.Emit(node, operand); + break; + } + case lexer::TokenType::KEYW_VOID: + case lexer::TokenType::KEYW_DELETE: { + LoadConst(node, Constant::JS_UNDEFINED); + break; + } + default: { + UNREACHABLE(); + } + } +} + +void PandaGen::Binary(const ir::AstNode *node, lexer::TokenType op, VReg lhs) +{ + switch (op) { + case lexer::TokenType::PUNCTUATOR_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_NOT_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_STRICT_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_NOT_STRICT_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_LESS_THAN: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_LESS_THAN_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_GREATER_THAN: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_GREATER_THAN_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_PLUS: + case lexer::TokenType::PUNCTUATOR_PLUS_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_MINUS: + case lexer::TokenType::PUNCTUATOR_MINUS_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_MULTIPLY: + case lexer::TokenType::PUNCTUATOR_MULTIPLY_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_DIVIDE: + case lexer::TokenType::PUNCTUATOR_DIVIDE_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_MOD: + case lexer::TokenType::PUNCTUATOR_MOD_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_EXPONENTIATION_EQUAL: + case lexer::TokenType::PUNCTUATOR_EXPONENTIATION: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_LEFT_SHIFT: + case lexer::TokenType::PUNCTUATOR_LEFT_SHIFT_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_RIGHT_SHIFT: + case lexer::TokenType::PUNCTUATOR_RIGHT_SHIFT_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_UNSIGNED_RIGHT_SHIFT: + case lexer::TokenType::PUNCTUATOR_UNSIGNED_RIGHT_SHIFT_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_BITWISE_AND: + case lexer::TokenType::PUNCTUATOR_BITWISE_AND_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_BITWISE_OR: + case lexer::TokenType::PUNCTUATOR_BITWISE_OR_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_BITWISE_XOR: + case lexer::TokenType::PUNCTUATOR_BITWISE_XOR_EQUAL: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::KEYW_IN: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::KEYW_INSTANCEOF: { + ra_.Emit(node, lhs); + break; + } + case lexer::TokenType::PUNCTUATOR_NULLISH_COALESCING: + case lexer::TokenType::PUNCTUATOR_LOGICAL_NULLISH_EQUAL: { + Unimplemented(); + break; + } + default: { + UNREACHABLE(); + } + } +} + +void PandaGen::BranchIfUndefined(const ir::AstNode *node, Label *target) +{ + sa_.Emit(node); + BranchIfTrue(node, target); +} + +void PandaGen::BranchIfNotUndefined(const ir::AstNode *node, Label *target) +{ + sa_.Emit(node); + BranchIfFalse(node, target); +} + +void PandaGen::BranchIfTrue(const ir::AstNode *node, Label *target) +{ + sa_.Emit(node, target); +} + +void PandaGen::BranchIfNotTrue(const ir::AstNode *node, Label *target) +{ + sa_.Emit(node); + BranchIfFalse(node, target); +} + +void PandaGen::BranchIfFalse(const ir::AstNode *node, Label *target) +{ + sa_.Emit(node, target); +} + +void PandaGen::BranchIfCoercible(const ir::AstNode *node, Label *target) +{ + sa_.Emit(node); + BranchIfTrue(node, target); +} + +void PandaGen::EmitThrow(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::EmitRethrow(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::EmitReturn(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::EmitReturnUndefined(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::ImplicitReturn(const ir::AstNode *node) +{ + builder_->ImplicitReturn(node); +} + +void PandaGen::DirectReturn(const ir::AstNode *node) +{ + builder_->DirectReturn(node); +} + +void PandaGen::ValidateClassDirectReturn(const ir::AstNode *node) +{ + const ir::ScriptFunction *func = util::Helpers::GetContainingFunction(node); + + if (!func || !func->IsConstructor()) { + return; + } + + RegScope rs(this); + VReg value = AllocReg(); + StoreAccumulator(node, value); + + auto *notUndefined = AllocLabel(); + auto *condEnd = AllocLabel(); + + BranchIfNotUndefined(node, notUndefined); + GetThis(func); + ThrowIfSuperNotCorrectCall(func, 0); + Branch(node, condEnd); + + SetLabel(node, notUndefined); + LoadAccumulator(node, value); + + SetLabel(node, condEnd); +} + +void PandaGen::EmitAwait(const ir::AstNode *node) +{ + builder_->Await(node); +} + +void PandaGen::CallThis(const ir::AstNode *node, VReg startReg, size_t argCount) +{ + rra_.Emit(node, startReg, argCount + 2, static_cast(argCount), startReg); +} + +void PandaGen::Call(const ir::AstNode *node, VReg startReg, size_t argCount) +{ + VReg callee = startReg; + + switch (argCount) { + case 0: { // 0 args + ra_.Emit(node, callee); + break; + } + case 1: { // 1 arg + VReg arg0 = callee + 1; + ra_.Emit(node, callee, arg0); + break; + } + case 2: { // 2 args + VReg arg0 = callee + 1; + VReg arg1 = arg0 + 1; + ra_.Emit(node, callee, arg0, arg1); + break; + } + case 3: { // 3 args + VReg arg0 = callee + 1; + VReg arg1 = arg0 + 1; + VReg arg2 = arg1 + 1; + ra_.Emit(node, callee, arg0, arg1, arg2); + break; + } + default: { + rra_.Emit(node, startReg, argCount + 1, static_cast(argCount), startReg); + break; + } + } +} + +void PandaGen::SuperCall(const ir::AstNode *node, VReg startReg, size_t argCount) +{ + rra_.Emit(node, startReg, argCount, static_cast(argCount), startReg); +} + +void PandaGen::SuperCallSpread(const ir::AstNode *node, VReg vs) +{ + ra_.Emit(node, vs); +} + +void PandaGen::NewObject(const ir::AstNode *node, VReg startReg, size_t argCount) +{ + rra_.Emit(node, startReg, argCount, static_cast(argCount), startReg); +} + +void PandaGen::LoadHomeObject(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::DefineFunction(const ir::AstNode *node, const ir::ScriptFunction *realNode, const util::StringView &name) +{ + if (realNode->IsAsync()) { + if (realNode->IsGenerator()) { + ra_.Emit(node, name, LexEnv()); + } else { + ra_.Emit(node, name, LexEnv()); + } + } else if (realNode->IsGenerator()) { + ra_.Emit(node, name, LexEnv()); + } else if (realNode->IsArrow()) { + LoadHomeObject(node); + ra_.Emit(node, name, LexEnv()); + } else if (realNode->IsMethod()) { + ra_.Emit(node, name, LexEnv()); + } else { + ra_.Emit(node, name, LexEnv()); + } + + strings_.insert(name); +} + +void PandaGen::TypeOf(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::CallSpread(const ir::AstNode *node, VReg func, VReg thisReg, VReg args) +{ + ra_.Emit(node, func, thisReg, args); +} + +void PandaGen::NewObjSpread(const ir::AstNode *node, VReg obj, VReg target) +{ + ra_.Emit(node, obj, target); +} + +void PandaGen::GetUnmappedArgs(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::Negate(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::ToBoolean(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::ToNumber(const ir::AstNode *node, VReg arg) +{ + ra_.Emit(node, arg); +} + +void PandaGen::GetMethod(const ir::AstNode *node, VReg obj, const util::StringView &name) +{ + ra_.Emit(node, name, obj); + strings_.insert(name); +} + +void PandaGen::CreateGeneratorObj(const ir::AstNode *node, VReg funcObj) +{ + ra_.Emit(node, funcObj); +} + +void PandaGen::CreateAsyncGeneratorObj(const ir::AstNode *node, VReg funcObj) +{ + ra_.Emit(node, funcObj); +} + +void PandaGen::CreateIterResultObject(const ir::AstNode *node, bool done) +{ + ra_.Emit(node, static_cast(done)); +} + +void PandaGen::SuspendGenerator(const ir::AstNode *node, VReg genObj) +{ + ra_.Emit(node, genObj); +} + +void PandaGen::SuspendAsyncGenerator(const ir::AstNode *node, VReg asyncGenObj) +{ + ra_.Emit(node, asyncGenObj); +} + +void PandaGen::GeneratorYield(const ir::AstNode *node, VReg genObj) +{ + ra_.Emit(node, genObj, static_cast(GeneratorState::SUSPENDED_YIELD)); +} + +void PandaGen::GeneratorComplete(const ir::AstNode *node, VReg genObj) +{ + ra_.Emit(node, genObj, static_cast(GeneratorState::COMPLETED)); +} + +void PandaGen::ResumeGenerator(const ir::AstNode *node, VReg genObj) +{ + ra_.Emit(node, genObj); +} + +void PandaGen::GetResumeMode(const ir::AstNode *node, VReg genObj) +{ + ra_.Emit(node, genObj); +} + +void PandaGen::AsyncFunctionEnter(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::AsyncFunctionAwait(const ir::AstNode *node, VReg asyncFuncObj) +{ + ra_.Emit(node, asyncFuncObj); +} + +void PandaGen::AsyncFunctionResolve(const ir::AstNode *node, VReg asyncFuncObj) +{ + ra_.Emit(node, asyncFuncObj); +} + +void PandaGen::AsyncFunctionReject(const ir::AstNode *node, VReg asyncFuncObj) +{ + ra_.Emit(node, asyncFuncObj); +} + +void PandaGen::AsyncGeneratorResolve(const ir::AstNode *node, VReg asyncGenObj) +{ + ra_.Emit(node, asyncGenObj); +} + +void PandaGen::AsyncGeneratorReject(const ir::AstNode *node, VReg asyncGenObj) +{ + ra_.Emit(node, asyncGenObj); +} + +void PandaGen::GetTemplateObject(const ir::AstNode *node, VReg value) +{ + ra_.Emit(node, value); +} + +void PandaGen::CopyRestArgs(const ir::AstNode *node, uint32_t index) +{ + sa_.Emit(node, index); +} + +void PandaGen::GetPropIterator(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::GetNextPropName(const ir::AstNode *node, VReg iter) +{ + ra_.Emit(node, iter); +} + +void PandaGen::CreateEmptyObject(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::CreateObjectWithBuffer(const ir::AstNode *node, uint32_t idx) +{ + ASSERT(util::Helpers::IsInteger(idx)); + sa_.Emit(node, idx); +} + +void PandaGen::CreateObjectHavingMethod(const ir::AstNode *node, uint32_t idx) +{ + ASSERT(util::Helpers::IsInteger(idx)); + LoadAccumulator(node, LexEnv()); + sa_.Emit(node, idx); +} + +void PandaGen::SetObjectWithProto(const ir::AstNode *node, VReg proto, VReg obj) +{ + ra_.Emit(node, proto, obj); +} + +void PandaGen::CopyDataProperties(const ir::AstNode *node, VReg dst, VReg src) +{ + ra_.Emit(node, dst, src); +} + +void PandaGen::DefineGetterSetterByValue(const ir::AstNode *node, VReg obj, VReg name, VReg getter, VReg setter, + bool setName) +{ + LoadConst(node, setName ? Constant::JS_TRUE : Constant::JS_FALSE); + ra_.Emit(node, obj, name, getter, setter); +} + +void PandaGen::CreateEmptyArray(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::CreateArrayWithBuffer(const ir::AstNode *node, uint32_t idx) +{ + ASSERT(util::Helpers::IsInteger(idx)); + sa_.Emit(node, idx); +} + +void PandaGen::CreateArray(const ir::AstNode *node, const ArenaVector &elements, VReg obj) +{ + if (elements.empty()) { + CreateEmptyArray(node); + StoreAccumulator(node, obj); + return; + } + + auto *buf = NewLiteralBuffer(); + + size_t i = 0; + // This loop handles constant literal data by collecting it into a literal buffer + // until a non-constant element is encountered. + while (i < elements.size() && util::Helpers::IsConstantExpr(elements[i])) { + buf->Add(elements[i]->AsLiteral()); + i++; + } + + if (buf->IsEmpty()) { + CreateEmptyArray(node); + } else { + uint32_t bufIdx = AddLiteralBuffer(buf); + CreateArrayWithBuffer(node, bufIdx); + } + + StoreAccumulator(node, obj); + + if (i == elements.size()) { + return; + } + + bool hasSpread = false; + + // This loop handles array elements until a spread element is encountered + for (; i < elements.size(); i++) { + const ir::Expression *elem = elements[i]; + + if (elem->IsOmittedExpression()) { + continue; + } + + if (elem->IsSpreadElement()) { + // The next loop will handle arrays that have a spread element + hasSpread = true; + break; + } + + elem->Compile(this); + StOwnByIndex(elem, obj, i); + } + + RegScope rs(this); + VReg idxReg {}; + + if (hasSpread) { + idxReg = AllocReg(); + LoadAccumulatorInt(node, i); + StoreAccumulator(node, idxReg); + } + + // This loop handles arrays that contain spread elements + for (; i < elements.size(); i++) { + const ir::Expression *elem = elements[i]; + + if (elem->IsSpreadElement()) { + elem->AsSpreadElement()->Argument()->Compile(this); + + StoreArraySpread(elem, obj, idxReg); + + LoadObjByName(node, obj, "length"); + StoreAccumulator(elem, idxReg); + continue; + } + + if (!elem->IsOmittedExpression()) { + elem->Compile(this); + StOwnByValue(elem, obj, idxReg); + } + + Unary(elem, lexer::TokenType::PUNCTUATOR_PLUS_PLUS, idxReg); + StoreAccumulator(elem, idxReg); + } + + // If the last element is omitted, we also have to update the length property + if (elements.back()->IsOmittedExpression()) { + // if there was a spread value then acc already contains the length + if (!hasSpread) { + LoadAccumulatorInt(node, i); + } + + StOwnByName(node, obj, "length"); + } + + LoadAccumulator(node, obj); +} + +void PandaGen::StoreArraySpread(const ir::AstNode *node, VReg array, VReg index) +{ + ra_.Emit(node, array, index); +} + +void PandaGen::ThrowIfNotObject(const ir::AstNode *node) +{ + ra_.Emit(node); +} + +void PandaGen::ThrowThrowNotExist(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::GetIterator(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::GetAsyncIterator(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::CreateObjectWithExcludedKeys(const ir::AstNode *node, VReg obj, VReg argStart, size_t argCount) +{ + ASSERT(argStart == obj + 1); + if (argCount == 0) { // Do not emit undefined register + argStart = obj; + } + + rra_.Emit(node, argStart, argCount, static_cast(argCount), obj, + argStart); +} + +void PandaGen::ThrowObjectNonCoercible(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::CloseIterator(const ir::AstNode *node, VReg iter) +{ + ra_.Emit(node, iter); +} + +void PandaGen::ImportModule(const ir::AstNode *node, const util::StringView &name) +{ + sa_.Emit(node, name); + strings_.insert(name); +} + +void PandaGen::DefineClassWithBuffer(const ir::AstNode *node, const util::StringView &ctorId, int32_t litIdx, + VReg lexenv, VReg base) +{ + ra_.Emit(node, ctorId, litIdx, lexenv, base); + strings_.insert(ctorId); +} + +void PandaGen::LoadModuleVariable(const ir::AstNode *node, VReg module, const util::StringView &name) +{ + ra_.Emit(node, name, module); + strings_.insert(name); +} + +void PandaGen::StoreModuleVar(const ir::AstNode *node, const util::StringView &name) +{ + sa_.Emit(node, name); + strings_.insert(name); +} + +void PandaGen::CopyModule(const ir::AstNode *node, VReg module) +{ + ra_.Emit(node, module); +} + +void PandaGen::StSuperByName(const ir::AstNode *node, VReg obj, const util::StringView &key) +{ + ra_.Emit(node, key, obj); + strings_.insert(key); +} + +void PandaGen::LdSuperByName(const ir::AstNode *node, VReg obj, const util::StringView &key) +{ + ra_.Emit(node, key, obj); + strings_.insert(key); +} + +void PandaGen::StSuperByValue(const ir::AstNode *node, VReg obj, VReg prop) +{ + ra_.Emit(node, obj, prop); +} + +void PandaGen::LdSuperByValue(const ir::AstNode *node, VReg obj, VReg prop) +{ + ra_.Emit(node, obj, prop); +} + +void PandaGen::StoreSuperProperty(const ir::AstNode *node, VReg obj, const Operand &prop) +{ + if (std::holds_alternative(prop)) { + StSuperByName(node, obj, std::get(prop)); + return; + } + + if (std::holds_alternative(prop)) { + StSuperByValue(node, obj, std::get(prop)); + return; + } + + ASSERT(std::holds_alternative(prop)); + RegScope rs(this); + VReg property = AllocReg(); + VReg value = AllocReg(); + + StoreAccumulator(node, value); + LoadAccumulatorInt(node, static_cast(std::get(prop))); + StoreAccumulator(node, property); + LoadAccumulator(node, value); + StSuperByValue(node, obj, property); +} + +void PandaGen::LoadSuperProperty(const ir::AstNode *node, VReg obj, const Operand &prop) +{ + if (std::holds_alternative(prop)) { + LdSuperByName(node, obj, std::get(prop)); + return; + } + + if (std::holds_alternative(prop)) { + LdSuperByValue(node, obj, std::get(prop)); + return; + } + + ASSERT(std::holds_alternative(prop)); + RegScope rs(this); + + LoadAccumulatorInt(node, static_cast(std::get(prop))); + VReg property = AllocReg(); + StoreAccumulator(node, property); + LdSuperByValue(node, obj, property); +} + +void PandaGen::LoadLexicalVar(const ir::AstNode *node, uint32_t level, uint32_t slot) +{ + sa_.Emit(node, level, slot); +} + +void PandaGen::StoreLexicalVar(const ir::AstNode *node, uint32_t level, uint32_t slot) +{ + ra_.Emit(node, level, slot); +} + +void PandaGen::ThrowIfSuperNotCorrectCall(const ir::AstNode *node, int64_t num) +{ + sa_.Emit(node, num); +} + +void PandaGen::ThrowUndefinedIfHole(const ir::AstNode *node, const util::StringView &name) +{ + ra_.Emit(node, name); + strings_.insert(name); +} + +void PandaGen::ThrowConstAssignment(const ir::AstNode *node, const util::StringView &name) +{ + ra_.Emit(node, name); + strings_.insert(name); +} + +void PandaGen::PopLexEnv(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::CopyLexEnv(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +void PandaGen::NewLexEnv(const ir::AstNode *node, uint32_t num) +{ + sa_.Emit(node, num); +} + +void PandaGen::LdLexEnv(const ir::AstNode *node) +{ + sa_.Emit(node); +} + +uint32_t PandaGen::TryDepth() const +{ + const auto *iter = dynamicContext_; + uint32_t depth = 0; + + while (iter) { + if (iter->HasTryCatch()) { + depth++; + } + + iter = iter->Prev(); + } + + return depth; +} + +CatchTable *PandaGen::CreateCatchTable() +{ + auto *catchTable = allocator_->New(this, TryDepth()); + catchList_.push_back(catchTable); + return catchTable; +} + +void PandaGen::SortCatchTables() +{ + std::sort(catchList_.begin(), catchList_.end(), + [](const CatchTable *a, const CatchTable *b) { return b->Depth() < a->Depth(); }); +} + +Operand PandaGen::ToNamedPropertyKey(const ir::Expression *prop, bool isComputed) +{ + VReg res {0}; + + if (!isComputed) { + if (prop->IsIdentifier()) { + return prop->AsIdentifier()->Name(); + } + } else if (prop->IsStringLiteral()) { + const util::StringView &str = prop->AsStringLiteral()->Str(); + + /* TODO(dbatyai): remove this when runtime handles __proto__ as property name correctly */ + if (str.Is("__proto__")) { + return res; + } + + int64_t index = util::Helpers::GetIndex(str); + if (index != util::Helpers::INVALID_INDEX) { + return index; + } + + return str; + } else if (prop->IsNumberLiteral()) { + auto num = prop->AsNumberLiteral()->Number(); + if (util::Helpers::IsIndex(num)) { + return static_cast(num); + } + + return prop->AsNumberLiteral()->Str(); + } + + return res; +} + +Operand PandaGen::ToPropertyKey(const ir::Expression *prop, bool isComputed) +{ + Operand op = ToNamedPropertyKey(prop, isComputed); + if (!std::holds_alternative(op)) { + ASSERT(std::holds_alternative(op) || std::holds_alternative(op)); + return op; + } + + VReg propReg = AllocReg(); + + prop->Compile(this); + StoreAccumulator(prop, propReg); + + return propReg; +} + +VReg PandaGen::LoadPropertyKey(const ir::Expression *prop, bool isComputed) +{ + Operand op = ToNamedPropertyKey(prop, isComputed); + + if (std::holds_alternative(op)) { + LoadAccumulatorString(prop, std::get(op)); + } else if (std::holds_alternative(op)) { + LoadAccumulatorInt(prop, static_cast(std::get(op))); + } else { + prop->Compile(this); + } + + VReg propReg = AllocReg(); + StoreAccumulator(prop, propReg); + + return propReg; +} + +} // namespace panda::es2panda::compiler diff --git a/es2panda/compiler/core/pandagen.h b/es2panda/compiler/core/pandagen.h new file mode 100644 index 0000000000..eefd2e4b24 --- /dev/null +++ b/es2panda/compiler/core/pandagen.h @@ -0,0 +1,421 @@ +/** + * Copyright (c) 2021-2022 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_CORE_PANDAGEN_H +#define ES2PANDA_COMPILER_CORE_PANDAGEN_H + +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace panda::es2panda::binder { +class FunctionScope; +class ScopeFindResult; +class Scope; +} // namespace panda::es2panda::binder + +namespace panda::es2panda::ir { +class AstNode; +class ScriptFunction; +class Statement; +class Expression; +class Identifier; +} // namespace panda::es2panda::ir + +namespace panda::es2panda::compiler { + +class FunctionBuilder; +class CompilerContext; +class LiteralBuffer; +class DynamicContext; +class CatchTable; + +enum class Constant { + JS_NAN, + JS_HOLE, + JS_INFINITY, + JS_UNDEFINED, + JS_NULL, + JS_TRUE, + JS_FALSE, + JS_SYMBOL, + JS_GLOBAL, +}; + +class DebugInfo { +public: + explicit DebugInfo(ArenaAllocator *allocator) : variableDebugInfo(allocator->Adapter()) {}; + DEFAULT_COPY_SEMANTIC(DebugInfo); + DEFAULT_MOVE_SEMANTIC(DebugInfo); + ~DebugInfo() = default; + + ArenaVector variableDebugInfo; + const ir::Statement *firstStmt {}; +}; + +class PandaGen { +public: + explicit PandaGen(ArenaAllocator *allocator, CompilerContext *context, binder::FunctionScope *scope) + : allocator_(allocator), + context_(context), + builder_(nullptr), + debugInfo_(allocator_), + topScope_(scope), + scope_(topScope_), + rootNode_(scope->Node()), + insns_(allocator_->Adapter()), + catchList_(allocator_->Adapter()), + strings_(allocator_->Adapter()), + buffStorage_(allocator_->Adapter()), + sa_(this), + ra_(this), + rra_(this) + { + } + ~PandaGen() = default; + NO_COPY_SEMANTIC(PandaGen); + NO_MOVE_SEMANTIC(PandaGen); + + inline ArenaAllocator *Allocator() const + { + return allocator_; + } + + const ArenaSet &Strings() const + { + return strings_; + } + + const ArenaVector &CatchList() const + { + return catchList_; + } + + binder::FunctionScope *TopScope() const + { + return topScope_; + } + + binder::Scope *Scope() const + { + return scope_; + } + + const ir::AstNode *RootNode() const + { + return rootNode_; + } + + ArenaList &Insns() + { + return insns_; + } + + const ArenaList &Insns() const + { + return insns_; + } + + VReg AllocReg() + { + return usedRegs_++; + } + + VReg NextReg() const + { + return usedRegs_; + } + + uint32_t TotalRegsNum() const + { + return totalRegs_; + } + + size_t LabelCount() const + { + return labelId_; + } + + const DebugInfo &Debuginfo() const + { + return debugInfo_; + } + + FunctionBuilder *FuncBuilder() const + { + return builder_; + } + + EnvScope *GetEnvScope() const + { + return envScope_; + } + + const ArenaVector &BuffStorage() const + { + return buffStorage_; + } + + uint32_t IcSize() const + { + return ic_.Size(); + } + + bool IsDebug() const; + uint32_t ParamCount() const; + uint32_t FormalParametersCount() const; + uint32_t InternalParamCount() const; + const util::StringView &InternalName() const; + const util::StringView &FunctionName() const; + binder::Binder *Binder() const; + + Label *AllocLabel(); + + VReg LexEnv() const; + + bool FunctionHasFinalizer() const; + void FunctionInit(CatchTable* catchTable); + void FunctionEnter(); + void FunctionExit(); + + LiteralBuffer *NewLiteralBuffer(); + int32_t AddLiteralBuffer(LiteralBuffer *buf); + + void InitializeLexEnv(const ir::AstNode *node, VReg lexEnv); + void CopyFunctionArguments(const ir::AstNode *node); + void GetFunctionObject(const ir::AstNode *node); + void GetNewTarget(const ir::AstNode *node); + void GetThis(const ir::AstNode *node); + void SetThis(const ir::AstNode *node); + void LoadVar(const ir::Identifier *node, const binder::ScopeFindResult &result); + void StoreVar(const ir::AstNode *node, const binder::ScopeFindResult &result, bool isDeclaration); + + void StoreAccumulator(const ir::AstNode *node, VReg vreg); + void LoadAccFromArgs(const ir::AstNode *node); + void LoadObjProperty(const ir::AstNode *node, VReg obj, const Operand &prop); + + void LoadObjByName(const ir::AstNode *node, VReg obj, const util::StringView &prop); + + void StoreObjProperty(const ir::AstNode *node, VReg obj, const Operand &prop); + void StoreOwnProperty(const ir::AstNode *node, VReg obj, const Operand &prop); + void DeleteObjProperty(const ir::AstNode *node, VReg obj, const Operand &prop); + void LoadAccumulator(const ir::AstNode *node, VReg reg); + void LoadGlobalVar(const ir::AstNode *node, const util::StringView &name); + void StoreGlobalVar(const ir::AstNode *node, const util::StringView &name); + void StoreGlobalLet(const ir::AstNode *node, const util::StringView &name); + + void TryLoadGlobalByValue(const ir::AstNode *node, VReg key); + void TryStoreGlobalByValue(const ir::AstNode *node, VReg key); + void TryLoadGlobalByName(const ir::AstNode *node, const util::StringView &name); + void TryStoreGlobalByName(const ir::AstNode *node, const util::StringView &name); + + void LoadAccFromLexEnv(const ir::AstNode *node, const binder::ScopeFindResult &result); + void StoreAccToLexEnv(const ir::AstNode *node, const binder::ScopeFindResult &result, bool isDeclaration); + + void LoadAccumulatorString(const ir::AstNode *node, const util::StringView &str); + void LoadAccumulatorFloat(const ir::AstNode *node, double num); + void LoadAccumulatorInt(const ir::AstNode *node, int32_t num); + void LoadAccumulatorInt(const ir::AstNode *node, size_t num); + + void LoadConst(const ir::AstNode *node, Constant id); + void StoreConst(const ir::AstNode *node, VReg reg, Constant id); + void MoveVreg(const ir::AstNode *node, VReg vd, VReg vs); + + void SetLabel(const ir::AstNode *node, Label *label); + void Branch(const ir::AstNode *node, class Label *label); + bool CheckControlFlowChange(); + Label *ControlFlowChangeBreak(const ir::Identifier *label = nullptr); + Label *ControlFlowChangeContinue(const ir::Identifier *label); + + void Condition(const ir::AstNode *node, lexer::TokenType op, VReg lhs, class Label *ifFalse); + void Unary(const ir::AstNode *node, lexer::TokenType op, VReg operand); + void Binary(const ir::AstNode *node, lexer::TokenType op, VReg lhs); + + void BranchIfUndefined(const ir::AstNode *node, class Label *target); + void BranchIfNotUndefined(const ir::AstNode *node, class Label *target); + void BranchIfHole(const ir::AstNode *node, class Label *target); + void BranchIfTrue(const ir::AstNode *node, class Label *target); + void BranchIfNotTrue(const ir::AstNode *node, class Label *target); + void BranchIfFalse(const ir::AstNode *node, class Label *target); + void BranchIfCoercible(const ir::AstNode *node, class Label *target); + + void EmitThrow(const ir::AstNode *node); + void EmitRethrow(const ir::AstNode *node); + void EmitReturn(const ir::AstNode *node); + void EmitReturnUndefined(const ir::AstNode *node); + void ValidateClassDirectReturn(const ir::AstNode *node); + void DirectReturn(const ir::AstNode *node); + void ImplicitReturn(const ir::AstNode *node); + void EmitAwait(const ir::AstNode *node); + + void CallThis(const ir::AstNode *node, VReg startReg, size_t argCount); + void Call(const ir::AstNode *node, VReg startReg, size_t argCount); + void CallSpread(const ir::AstNode *node, VReg func, VReg thisReg, VReg args); + void SuperCall(const ir::AstNode *node, VReg startReg, size_t argCount); + void SuperCallSpread(const ir::AstNode *node, VReg vs); + + void LoadHomeObject(const ir::AstNode *node); + void NewObject(const ir::AstNode *node, VReg startReg, size_t argCount); + void DefineFunction(const ir::AstNode *node, const ir::ScriptFunction *realNode, const util::StringView &name); + + void TypeOf(const ir::AstNode *node); + void NewObjSpread(const ir::AstNode *node, VReg obj, VReg target); + void GetUnmappedArgs(const ir::AstNode *node); + + void Negate(const ir::AstNode *node); + void ToBoolean(const ir::AstNode *node); + void ToNumber(const ir::AstNode *node, VReg arg); + + void CreateGeneratorObj(const ir::AstNode *node, VReg funcObj); + void ResumeGenerator(const ir::AstNode *node, VReg genObj); + void GetResumeMode(const ir::AstNode *node, VReg genObj); + + void AsyncFunctionEnter(const ir::AstNode *node); + void AsyncFunctionAwait(const ir::AstNode *node, VReg asyncFuncObj); + void AsyncFunctionResolve(const ir::AstNode *node, VReg asyncFuncObj); + void AsyncFunctionReject(const ir::AstNode *node, VReg asyncFuncObj); + + void GetMethod(const ir::AstNode *node, VReg obj, const util::StringView &name); + void GeneratorYield(const ir::AstNode *node, VReg genObj); + void GeneratorComplete(const ir::AstNode *node, VReg genObj); + void CreateAsyncGeneratorObj(const ir::AstNode *node, VReg funcObj); + void CreateIterResultObject(const ir::AstNode *node, bool done); + void SuspendGenerator(const ir::AstNode *node, VReg genObj); + void SuspendAsyncGenerator(const ir::AstNode *node, VReg asyncGenObj); + + void AsyncGeneratorResolve(const ir::AstNode *node, VReg asyncGenObj); + void AsyncGeneratorReject(const ir::AstNode *node, VReg asyncGenObj); + + void GetTemplateObject(const ir::AstNode *node, VReg value); + void CopyRestArgs(const ir::AstNode *node, uint32_t index); + + void GetPropIterator(const ir::AstNode *node); + void GetNextPropName(const ir::AstNode *node, VReg iter); + void CreateEmptyObject(const ir::AstNode *node); + void CreateObjectWithBuffer(const ir::AstNode *node, uint32_t idx); + void CreateObjectHavingMethod(const ir::AstNode *node, uint32_t idx); + void SetObjectWithProto(const ir::AstNode *node, VReg proto, VReg obj); + void CopyDataProperties(const ir::AstNode *node, VReg dst, VReg src); + void DefineGetterSetterByValue(const ir::AstNode *node, VReg obj, VReg name, VReg getter, VReg setter, + bool setName); + void CreateEmptyArray(const ir::AstNode *node); + void CreateArray(const ir::AstNode *node, const ArenaVector &elements, VReg obj); + void CreateArrayWithBuffer(const ir::AstNode *node, uint32_t idx); + void StoreArraySpread(const ir::AstNode *node, VReg array, VReg index); + + void ThrowIfNotObject(const ir::AstNode *node); + void ThrowThrowNotExist(const ir::AstNode *node); + void GetIterator(const ir::AstNode *node); + void GetAsyncIterator(const ir::AstNode *node); + + void CreateObjectWithExcludedKeys(const ir::AstNode *node, VReg obj, VReg argStart, size_t argCount); + void ThrowObjectNonCoercible(const ir::AstNode *node); + void CloseIterator(const ir::AstNode *node, VReg iter); + void DefineClassWithBuffer(const ir::AstNode *node, const util::StringView &ctorId, int32_t litIdx, VReg lexenv, + VReg base); + + void ImportModule(const ir::AstNode *node, const util::StringView &name); + void LoadModuleVariable(const ir::AstNode *node, VReg module, const util::StringView &name); + void StoreModuleVar(const ir::AstNode *node, const util::StringView &name); + void CopyModule(const ir::AstNode *node, VReg module); + + void StSuperByName(const ir::AstNode *node, VReg obj, const util::StringView &key); + void LdSuperByName(const ir::AstNode *node, VReg obj, const util::StringView &key); + void StSuperByValue(const ir::AstNode *node, VReg obj, VReg prop); + void LdSuperByValue(const ir::AstNode *node, VReg obj, VReg prop); + void StoreSuperProperty(const ir::AstNode *node, VReg obj, const Operand &prop); + void LoadSuperProperty(const ir::AstNode *node, VReg obj, const Operand &prop); + + void LdLexEnv(const ir::AstNode *node); + void PopLexEnv(const ir::AstNode *node); + void CopyLexEnv(const ir::AstNode *node); + void NewLexEnv(const ir::AstNode *node, uint32_t num); + void LoadLexicalVar(const ir::AstNode *node, uint32_t level, uint32_t slot); + void StoreLexicalVar(const ir::AstNode *node, uint32_t level, uint32_t slot); + + void ThrowIfSuperNotCorrectCall(const ir::AstNode *node, int64_t num); + void ThrowUndefinedIfHole(const ir::AstNode *node, const util::StringView &name); + void ThrowConstAssignment(const ir::AstNode *node, const util::StringView &name); + + uint32_t TryDepth() const; + CatchTable *CreateCatchTable(); + void SortCatchTables(); + + void LoadObjByIndex(const ir::AstNode *node, VReg obj, int64_t index); + void LoadObjByValue(const ir::AstNode *node, VReg obj, VReg prop); + + void StoreObjByName(const ir::AstNode *node, VReg obj, const util::StringView &prop); + void StoreObjByIndex(const ir::AstNode *node, VReg obj, int64_t index); + void StoreObjByValue(const ir::AstNode *node, VReg obj, VReg prop); + + void StOwnByName(const ir::AstNode *node, VReg obj, const util::StringView &prop); + void StOwnByValue(const ir::AstNode *node, VReg obj, VReg prop); + void StOwnByIndex(const ir::AstNode *node, VReg obj, int64_t index); + + static Operand ToNamedPropertyKey(const ir::Expression *prop, bool isComputed); + Operand ToPropertyKey(const ir::Expression *prop, bool isComputed); + VReg LoadPropertyKey(const ir::Expression *prop, bool isComputed); + + void SetFirstStmt(const ir::Statement *stmt) + { + debugInfo_.firstStmt = stmt; + } + + [[noreturn]] static void Unimplemented() + { + throw Error(ErrorType::GENERIC, "Unimplemented code path"); + } + +private: + ArenaAllocator *allocator_; + CompilerContext *context_; + FunctionBuilder *builder_; + DebugInfo debugInfo_; + binder::FunctionScope *topScope_; + binder::Scope *scope_; + const ir::AstNode *rootNode_; + ArenaList insns_; + ArenaVector catchList_; + ArenaSet strings_; + ArenaVector buffStorage_; + EnvScope *envScope_ {}; + DynamicContext *dynamicContext_ {}; + InlineCache ic_; + SimpleAllocator sa_; + RegAllocator ra_; + RangeRegAllocator rra_; + + uint32_t usedRegs_ {0}; + uint32_t totalRegs_ {0}; + friend class ScopeContext; + friend class RegScope; + friend class LocalRegScope; + friend class LoopRegScope; + friend class ParamRegScope; + friend class FunctionRegScope; + friend class EnvScope; + friend class LoopEnvScope; + friend class DynamicContext; + size_t labelId_ {0}; +}; +} // namespace panda::es2panda::compiler + +#endif diff --git a/es2panda/compiler/core/regAllocator.cpp b/es2panda/compiler/core/regAllocator.cpp new file mode 100644 index 0000000000..7ed5763f54 --- /dev/null +++ b/es2panda/compiler/core/regAllocator.cpp @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2021-2022 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 "regAllocator.h" + +#include + +#include + +namespace panda::es2panda::compiler { + +// RegAllocatorBase + +void AllocatorBase::PushBack(IRNode *ins) +{ + pg_->Insns().push_back(ins); +} + +ArenaAllocator *AllocatorBase::Allocator() const +{ + return pg_->Allocator(); +} + +// SimpleAllocator + +Label *SimpleAllocator::AllocLabel(std::string &&id) +{ + const auto *lastInsNode = pg_->Insns().empty() ? FIRST_NODE_OF_FUNCTION : pg_->Insns().back()->Node(); + return Alloc