Lines Matching full:this
4 * you may not use this file except in compliance with the License.
21 * This file should not contain import from irnodes.ts.
141 this.rootNode = node;
142 this.pandaGen = pandaGen;
143 this.compilerDriver = compilerDriver;
144 this.recorder = recorder;
145 this.funcBuilder = new FunctionBuilder(pandaGen);
147 …// At the beginning of function compile, alloc pandagen.local for 4funcObj/newTarget/this/paramete…
148 // maybe no one used this parameter, will get undefined for RA
149 this.scope = this.pandaGen.getScope()!;
150 let parameters = (<VariableScope>this.scope).getParameters();
153 this.pandaGen.getVregForVariable(parameters[i]);
157 getVregisterCache(this.pandaGen, CacheList.LexEnv);
159 this.pandaGen.loadAccFromArgs(this.rootNode);
163 this.storeFuncObj2LexEnvIfNeeded();
164 this.compileLexicalBindingForArrowFunction();
166 if (this.rootNode.kind == ts.SyntaxKind.SourceFile) {
167 this.compileSourceFileOrBlock(<ts.SourceFile>this.rootNode);
169 this.compileFunctionLikeDeclaration(<ts.FunctionLikeDeclaration>this.rootNode);
174 this.envUnion.push(env);
178 this.envUnion.pop();
182 return this.envUnion[this.envUnion.length - 1];
186 let rootNode = this.rootNode;
190 let functionScope = this.recorder.getScopeOfNode(rootNode);
195 this.pandaGen.loadAccumulator(NodeKind.FirstNodeOfFunction,
196 getVregisterCache(this.pandaGen, CacheList.FUNC));
197 … this.pandaGen.storeAccToLexEnv(NodeKind.FirstNodeOfFunction, v.scope, v.level, v.v, true);
203 let rootNode = this.rootNode;
208 this.storeMandatoryArgToLexEnv(MandatoryFuncObj);
209 this.storeMandatoryArgToLexEnv(MandatoryNewTarget);
210 this.storeMandatoryArgToLexEnv(MandatoryThis);
212 let rootScope: VariableScope = <VariableScope>this.recorder.getScopeOfNode(rootNode);
214 this.storeMandatoryArgToLexEnv(MandatoryArguments);
219 let v = this.scope.findLocal(arg);
227 let vreg = arg == MandatoryFuncObj ? getVregisterCache(this.pandaGen, CacheList.FUNC) :
228 this.pandaGen.getVregForVariable(v);
229 this.pandaGen.storeLexicalVar(this.rootNode, 0, v.lexIndex(), vreg);
237 compileDefaultInitClassMembers(this, body.parent)
241 this.compileStatement(stmt);
248 compileReturnThis4Ctor(this, body.parent, unreachableFlag);
255 this.funcBuilder.implicitReturn(NodeKind.Invalid);
259 let pandaGen = this.pandaGen;
262 this.pushScope(body);
263 this.compileSourceFileOrBlock(<ts.Block>body);
264 this.popScope();
266 this.compileExpression(<ts.Expression>body);
271 …if (this.funcBuilder instanceof AsyncFunctionBuilder || this.funcBuilder instanceof AsyncGenerator…
272 this.funcBuilder.resolve(body, retValue);
280 … throw new Error("Node " + this.getNodeName(body) + " is unimplemented as a function body");
285 let pandaGen = this.pandaGen;
290 let paramRef = LReference.generateLReference(this, parameter, true);
297 variable = <Variable>this.scope.find(paramName).v;
302 let scope = this.pandaGen.getScope();
319 this.compileExpression(param.initializer);
333 let pandaGen = this.pandaGen;
340 return new AsyncGeneratorFunctionBuilder(pandaGen, this);
349 return new GeneratorFunctionBuilder(pandaGen, this);
356 let pandaGen = this.pandaGen;
357 this.compileFunctionParameterDeclaration(decl);
362 compileDefaultConstructor(this, decl);
374 this.funcBuilder = this.createFuncBuilder(decl);
375 this.funcBuilder.prepare(decl);
377 this.compileFunctionBody(decl.kind, decl.body);
380 this.funcBuilder.cleanUp(decl);
386 this.pandaGen.setFirstStmt(stmt);
389 LOGD(this.debugTag, "compile statement: " + this.getNodeName(stmt));
392 this.compileBlock(<ts.Block>stmt);
397 this.compileVariableStatement(<ts.VariableStatement>stmt);
400 this.compileExpression((<ts.ExpressionStatement>stmt).expression);
403 this.compileIfStatement(<ts.IfStatement>stmt);
406 compileDoStatement(<ts.DoStatement>stmt, this);
409 compileWhileStatement(<ts.WhileStatement>stmt, this);
412 compileForStatement(<ts.ForStatement>stmt, this);
415 compileForInStatement(<ts.ForInStatement>stmt, this);
418 compileForOfStatement(<ts.ForOfStatement>stmt, this);
421 this.compileContinueStatement(<ts.ContinueStatement>stmt);
424 this.compileBreakStatement(<ts.BreakStatement>stmt);
427 compileReturnStatement(<ts.ReturnStatement>stmt, this);
430 compileSwitchStatement(<ts.SwitchStatement>stmt, this);
433 this.compileLabeledStatement(<ts.LabeledStatement>stmt);
436 this.compileThrowStatement(<ts.ThrowStatement>stmt);
439 this.compileTryStatement(<ts.TryStatement>stmt);
442 this.pandaGen.debugger(stmt);
445 this.compileFunctionDeclaration(<ts.FunctionDeclaration>stmt);
448 compileClassDeclaration(this, <ts.ClassLikeDeclaration>stmt);
452 this.compileExportAssignment(<ts.ExportAssignment>stmt);
463 throw new Error("Statement " + this.getNodeName(stmt) + " is unimplemented");
468 this.pushScope(block);
469 hoistFunctionInBlock(this.scope, this.pandaGen, isStrictMode(block), this);
471 block.statements.forEach((stmt) => this.compileStatement(stmt));
473 this.popScope();
479 this.compileVariableDeclaration(decl)
484 let lref = LReference.generateLReference(this, decl.name, true);
486 this.compileExpression(decl.initializer);
495 … this.pandaGen.loadAccumulator(decl, getVregisterCache(this.pandaGen, CacheList.undefined));
502 this.pushScope(stmt);
506 this.compileCondition(stmt.expression, stmt.elseStatement ? ifElseLabel : ifEndLabel);
507 this.compileStatement(stmt.thenStatement);
509 this.pandaGen.branch(DebugInfo.getLastNode(), ifEndLabel);
510 this.pandaGen.label(stmt, ifElseLabel);
511 this.compileStatement(stmt.elseStatement);
513 this.pandaGen.label(stmt, ifEndLabel);
514 this.popScope();
519 this.pandaGen.popLexicalEnv(node);
529 this.popLoopEnv(node, loopEnvLevel - 1);
536 this.popLoopEnv(node, popTimes);
543 this.popLoopEnv(node, loopEnvLevel);
551 this.popLoopEnv(node, loopEnvLevel);
559 this.compileFinallyBeforeCFC(
567 this.popLoopEnvWhenContinueOrBreak(continueLabelTarget, true);
570 this.pandaGen.branch(stmt, continueLabelTarget.getContinueTargetLabel()!);
576 this.compileFinallyBeforeCFC(
584 this.popLoopEnvWhenContinueOrBreak(breakLabelTarget, false);
587 this.pandaGen.branch(stmt, breakLabelTarget.getBreakTargetLabel());
591 this.pushScope(stmt);
604 this.compileStatement(stmt.statement);
607 this.pandaGen.label(stmt, blockEndLabel);
612 this.popScope();
616 let pandaGen = this.pandaGen;
618 this.compileExpression(stmt.expression);
625 this.popLoopEnv(stmt, popTimes);
633 let currentScope = this.scope;
644 this.pandaGen.label(startTry.getStatement(), inlineFinallyBegin);
646 this.pandaGen.label(startTry.getStatement(), inlineFinallyEnd);
673 this.scope = currentScope;
677 let pandaGen = this.pandaGen;
696 let loopScope = <LoopScope>this.getRecorder().getScopeOfNode(node);
713 this.pushScope(stmt);
717 stmt = transformTryCatchFinally(stmt, this.recorder);
720 let tryBuilder = new TryBuilder(this, this.pandaGen, stmt);
721 this.constructTry(stmt, tryBuilder);
722 this.popScope();
727 if (hasExportKeywordModifier(decl) && this.scope instanceof ModuleScope) {
735 this.compileExpression(stmt.expression);
736 … let defaultV: ModuleVariable = <ModuleVariable>(this.pandaGen.getScope().findLocal("*default*"));
737 this.pandaGen.storeModuleVariable(stmt, defaultV);
741 let pandaGen = this.pandaGen;
754 // This is a special case
758 // the goal of this method is to merge these two sequences of instructions.
760 this.compileExpression(binExpr.left);
762 this.compileExpression(binExpr.right);
768 this.compileExpression(binExpr.left);
770 this.compileExpression(binExpr.right);
776 this.compileExpression(binExpr.left);
778 this.compileExpression(binExpr.right);
789 this.compileExpression(expr);
795 LOGD(this.debugTag, "compile expr: " + ts.SyntaxKind[expr.kind] + " " + expr.kind);
798 compileNumericLiteral(this.pandaGen, <ts.NumericLiteral>expr);
801 compileBigIntLiteral(this.pandaGen, <ts.BigIntLiteral>expr);
804 compileStringLiteral(this.pandaGen, <ts.StringLiteral>expr);
807 compileRegularExpressionLiteral(this, <ts.RegularExpressionLiteral>expr);
810 this.compileIdentifier(<ts.Identifier>expr);
814 this.compileBooleanLiteral(<ts.BooleanLiteral>expr);
817 compileCallExpression(<ts.CallExpression>expr, this);
820 … this.pandaGen.loadAccumulator(expr, getVregisterCache(this.pandaGen, CacheList.Null));
823 this.compileThisKeyword(expr);
826 compileMetaProperty(<ts.MetaProperty>expr, this);
829 compileArrayLiteralExpression(this, <ts.ArrayLiteralExpression>expr);
832 compileObjectLiteralExpression(this, <ts.ObjectLiteralExpression>expr);
836 …ompileMemberAccessExpression(<ts.ElementAccessExpression | ts.PropertyAccessExpression>expr, this);
839 compileNewExpression(<ts.NewExpression>expr, this);
842 … this.compileExpression(findInnerExprOfParenthesis(<ts.ParenthesizedExpression>expr));
845 this.compileFunctionExpression(<ts.FunctionExpression>expr);
848 this.compileDeleteExpression(<ts.DeleteExpression>expr);
851 this.compileTypeOfExpression(<ts.TypeOfExpression>expr);
854 this.compileVoidExpression(<ts.VoidExpression>expr);
857 this.compileAwaitExpression(<ts.AwaitExpression>expr);
860 this.compilePrefixUnaryExpression(<ts.PrefixUnaryExpression>expr);
863 this.compilePostfixUnaryExpression(<ts.PostfixUnaryExpression>expr);
866 this.compileBinaryExpression(<ts.BinaryExpression>expr);
869 this.compileConditionalExpression(<ts.ConditionalExpression>expr);
872 compileYieldExpression(this, <ts.YieldExpression>expr);
875 this.compileArrowFunction(<ts.ArrowFunction>expr);
878 this.compileTemplateExpression(<ts.TemplateExpression>expr);
883 this.compileNoSubstitutionTemplateLiteral(<ts.NoSubstitutionTemplateLiteral>expr);
886 this.compileTaggedTemplateExpression(<ts.TaggedTemplateExpression>expr);
893 compileClassDeclaration(this, <ts.ClassLikeDeclaration>expr);
896 this.compileExpression((<ts.PartiallyEmittedExpression>expr).expression);
899 compileCommaListExpression(this, <ts.CommaListExpression>expr);
902 … throw new Error("Expression of type " + this.getNodeName(expr) + " is unimplemented");
908 let { scope, level, v } = this.scope.find(name);
912 this.compileUnscopedIdentifier(id);
914 this.loadTarget(id, { scope, level, v });
920 let pandaGen = this.pandaGen;
924 pandaGen.loadAccumulator(id, getVregisterCache(this.pandaGen, CacheList.NaN));
927 pandaGen.loadAccumulator(id, getVregisterCache(this.pandaGen, CacheList.Infinity));
930 pandaGen.loadAccumulator(id, getVregisterCache(this.pandaGen, CacheList.Global));
933 pandaGen.loadAccumulator(id, getVregisterCache(this.pandaGen, CacheList.undefined));
952 this.pandaGen.loadAccumulator(lit, getVregisterCache(this.pandaGen, CacheList.True));
954 this.pandaGen.loadAccumulator(lit, getVregisterCache(this.pandaGen, CacheList.False));
968 if (arg.text.match(/ *return +this[;]? *$/) == null) {
971 … this.pandaGen.loadAccumulator(expr, getVregisterCache(this.pandaGen, CacheList.Global))
981 let pandaGen = this.pandaGen;
983 checkValidUseSuperBeforeSuper(this, node);
985 let { scope, level, v } = this.scope.find(MandatoryThis);
988 throw new Error("\"this\" not found");
1001 throw new Error("\"this\" must be a local variable");
1005 let internalName = this.compilerDriver.getFuncInternalName(expr, this.recorder);
1006 this.pandaGen.defineFunction(expr, expr, internalName);
1010 let pandaGen = this.pandaGen;
1016 // Check if this is a known variable.
1018 let { scope, v } = this.scope.find(name);
1044 …ndProp(<ts.PropertyAccessExpression | ts.ElementAccessExpression>unaryExpr, objReg, propReg, this);
1063 this.compileExpression(unaryExpr);
1072 this.compileExpression(expr.expression);
1073 this.pandaGen.typeOf(expr);
1077 let pandaGen = this.pandaGen;
1080 this.compileExpression(expr.expression);
1085 let pandaGen = this.pandaGen;
1087 …if (!(this.funcBuilder instanceof AsyncFunctionBuilder || this.funcBuilder instanceof AsyncGenerat…
1092 this.compileExpression(expr.expression);
1093 this.funcBuilder.await(expr);
1096 this.funcBuilder.await(expr);
1101 let pandaGen = this.pandaGen;
1108 let lref = LReference.generateLReference(this, expr.operand, false);
1119 this.compileExpression(expr.operand);
1131 let pandaGen = this.pandaGen;
1134 let lref = LReference.generateLReference(this, expr.operand, false);
1155 let pandaGen = this.pandaGen;
1163 this.compileExpression(expr.left);
1168 this.compileExpression(expr.right);
1182 this.compileExpression(expr.left);
1187 this.compileExpression(expr.right);
1200 this.compileExpression(expr.left);
1211 this.compileExpression(expr.right);
1216 …throw new Error("BinaryExpression with operatorToken " + this.getNodeName(expr.operatorToken) + " …
1223 …this.compileAssignmentExpression(expr.left, expr.right, <AssignmentOperator>expr.operatorToken.kin…
1230 this.compileLogicalExpression(expr);
1234 let pandaGen = this.pandaGen;
1236 this.compileExpression(expr.left);
1238 this.compileExpression(expr.right);
1251 this.compileCondition(expr.condition, falseLabel);
1252 this.compileExpression(expr.whenTrue);
1253 this.pandaGen.branch(expr, endLabel);
1254 this.pandaGen.label(expr, falseLabel);
1255 this.compileExpression(expr.whenFalse);
1256 this.pandaGen.label(expr, endLabel);
1260 let internalName = this.compilerDriver.getFuncInternalName(expr, this.recorder);
1261 this.pandaGen.defineFunction(expr, expr, internalName);
1266 this.compileExpression(span);
1268 let lrh = this.pandaGen.getTemp();
1272 this.pandaGen.storeAccumulator(expr, lrh);
1273 this.pandaGen.loadAccumulatorString(expr, text);
1274 this.pandaGen.binary(expr, ts.SyntaxKind.PlusToken, lrh);
1277 this.pandaGen.freeTemps(lrh);
1281 let pandaGen = this.pandaGen;
1291 this.compileTemplateSpan(spanExp);
1301 this.pandaGen.loadAccumulatorString(expr, text);
1305 let pandaGen = this.pandaGen;
1311 …s: argRegs, passThis: passThis } = getHiddenParameters(expr.tag, this); // +3 for function and this
1320 this.compileExpression(spanExp.expression);
1333 let lref = LReference.generateLReference(this, lhs, false);
1336 let lhsVreg = this.pandaGen.getTemp();
1339 this.pandaGen.storeAccumulator(lhs, lhsVreg);
1340 this.compileExpression(rhs);
1341 this.pandaGen.binary(lhs.parent, operator, lhsVreg);
1342 this.pandaGen.freeTemps(lhsVreg);
1344 this.compileExpression(rhs);
1351 let scope = <Scope>this.recorder.getScopeOfNode(node);
1352 this.scope = scope;
1354 DebugInfo.addDebugIns(scope, this.pandaGen, true);
1359 DebugInfo.addDebugIns(this.scope, this.pandaGen, false);
1360 this.scope = <Scope>this.scope.getParent();
1368 let pandaGen = this.pandaGen;
1369 let thisInfo = this.getCurrentScope().find(MandatoryThis);
1383 let pandaGen = this.pandaGen;
1384 let thisInfo = this.getCurrentScope().find(MandatoryThis);
1398 return this.pandaGen;
1402 return this.scope;
1406 return this.compilerDriver;
1410 return this.recorder;
1414 return this.funcBuilder;
1425 this.pandaGen.stLetOrClassToGlobalRecord(node, variable.v.getName());
1427 this.pandaGen.stConstToGlobalRecord(node, variable.v.getName());
1434 this.pandaGen.tryStoreGlobalByName(node, variable.v.getName());
1438 … this.pandaGen.storeAccToLexEnv(node, variable.scope!, variable.level, variable.v, isDeclaration);
1441 this.pandaGen.tryStoreGlobalByName(node, variable.v.getName());
1443 this.pandaGen.storeGlobalVar(node, variable.v.getName());
1448 let nameReg = this.pandaGen.getTemp();
1449 this.pandaGen.loadAccumulatorString(node, variable.v.getName());
1450 this.pandaGen.storeAccumulator(node, nameReg);
1451 this.pandaGen.throwConstAssignment(node, nameReg);
1452 this.pandaGen.freeTemps(nameReg);
1461 let valueReg = this.pandaGen.getTemp();
1462 this.pandaGen.storeAccumulator(node, valueReg);
1463 this.pandaGen.loadModuleVariable(node, variable.v, true);
1464 this.pandaGen.throwUndefinedIfHole(node, variable.v.getName());
1465 this.pandaGen.loadAccumulator(node, valueReg);
1466 this.pandaGen.freeTemps(valueReg);
1469 this.pandaGen.storeModuleVariable(node, variable.v);
1479 this.pandaGen.tryLoadGlobalByName(node, variable.v.getName());
1484 …this.pandaGen.loadAccFromLexEnv(node, variable.scope!, variable.level, (<LocalVariable>variable.v)…
1490 … this.pandaGen.loadByNameViaDebugger(node, variable.v.getName(), CacheList.False) :
1491 … this.pandaGen.loadObjProperty(node, getVregisterCache(this.pandaGen, CacheList.Global),
1494 this.pandaGen.tryLoadGlobalByName(node, variable.v.getName());
1497 this.pandaGen.loadGlobalVar(node, variable.v.getName());
1501 this.pandaGen.loadModuleVariable(node, variable.v, isLocal);
1503 this.pandaGen.throwUndefinedIfHole(node, variable.v.getName());