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