Changeset 215779 in webkit for trunk/Source/JavaScriptCore/interpreter
- Timestamp:
- Apr 25, 2017, 5:57:59 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r215720 r215779 1099 1099 1100 1100 unsigned numVariables = eval->numVariables(); 1101 unsigned numTopLevelFunctionDecls = eval->numTopLevelFunctionDecls(); 1102 unsigned numFunctionHoistingCandidates = eval->numFunctionHoistingCandidates(); 1101 int numFunctions = eval->numberOfFunctionDecls(); 1103 1102 1104 1103 JSScope* variableObject; 1105 if ((numVariables || num TopLevelFunctionDecls) && eval->isStrictMode()) {1104 if ((numVariables || numFunctions) && eval->isStrictMode()) { 1106 1105 scope = StrictEvalActivation::create(callFrame, scope); 1107 1106 variableObject = scope; … … 1134 1133 1135 1134 // We can't declare a "var"/"function" that overwrites a global "let"/"const"/"class" in a sloppy-mode eval. 1136 if (variableObject->isGlobalObject() && !eval->isStrictMode() && (numVariables || num TopLevelFunctionDecls)) {1135 if (variableObject->isGlobalObject() && !eval->isStrictMode() && (numVariables || numFunctions)) { 1137 1136 JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsCast<JSGlobalObject*>(variableObject)->globalLexicalEnvironment(); 1138 1137 for (unsigned i = 0; i < numVariables; ++i) { … … 1144 1143 } 1145 1144 1146 for ( unsigned i = 0; i < numTopLevelFunctionDecls; ++i) {1145 for (int i = 0; i < numFunctions; ++i) { 1147 1146 FunctionExecutable* function = codeBlock->functionDecl(i); 1148 1147 PropertySlot slot(globalLexicalEnvironment, PropertySlot::InternalMethodType::VMInquiry); … … 1156 1155 variableObject->flattenDictionaryObject(vm); 1157 1156 1158 if (numVariables || num TopLevelFunctionDecls || numFunctionHoistingCandidates) {1157 if (numVariables || numFunctions) { 1159 1158 BatchedTransitionOptimizer optimizer(vm, variableObject); 1160 1159 if (variableObject->next() && !eval->isStrictMode()) … … 1173 1172 } 1174 1173 } 1175 1176 if (eval->isStrictMode()) { 1177 for (unsigned i = 0; i < numTopLevelFunctionDecls; ++i) { 1178 FunctionExecutable* function = codeBlock->functionDecl(i); 1179 PutPropertySlot slot(variableObject); 1180 variableObject->methodTable()->put(variableObject, callFrame, function->name(), JSFunction::create(vm, function, scope), slot); 1181 } 1182 } else { 1183 for (unsigned i = 0; i < numTopLevelFunctionDecls; ++i) { 1184 FunctionExecutable* function = codeBlock->functionDecl(i); 1185 JSValue resolvedScope = JSScope::resolveScopeForHoistingFuncDeclInEval(callFrame, scope, function->name()); 1186 if (resolvedScope.isUndefined()) 1187 return checkedReturn(throwSyntaxError(callFrame, throwScope, makeString("Can't create duplicate variable in eval: '", String(function->name().impl()), "'"))); 1188 PutPropertySlot slot(variableObject); 1189 variableObject->methodTable()->put(variableObject, callFrame, function->name(), JSFunction::create(vm, function, scope), slot); 1190 RETURN_IF_EXCEPTION(throwScope, checkedReturn(throwScope.exception())); 1191 } 1192 1193 for (unsigned i = 0; i < numFunctionHoistingCandidates; ++i) { 1194 const Identifier& ident = codeBlock->functionHoistingCandidate(i); 1195 JSValue resolvedScope = JSScope::resolveScopeForHoistingFuncDeclInEval(callFrame, scope, ident); 1196 if (!resolvedScope.isUndefined()) { 1197 if (!variableObject->hasProperty(callFrame, ident)) { 1198 PutPropertySlot slot(variableObject); 1199 variableObject->methodTable()->put(variableObject, callFrame, ident, jsUndefined(), slot); 1200 RETURN_IF_EXCEPTION(throwScope, checkedReturn(throwScope.exception())); 1201 } 1202 } 1203 } 1174 1175 for (int i = 0; i < numFunctions; ++i) { 1176 FunctionExecutable* function = codeBlock->functionDecl(i); 1177 PutPropertySlot slot(variableObject); 1178 variableObject->methodTable()->put(variableObject, callFrame, function->name(), JSFunction::create(vm, function, scope), slot); 1179 RETURN_IF_EXCEPTION(throwScope, checkedReturn(throwScope.exception())); 1204 1180 } 1205 1181 }
Note:
See TracChangeset
for help on using the changeset viewer.