Changeset 215476 in webkit for trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
- Timestamp:
- Apr 18, 2017, 12:35:50 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r215072 r215476 1092 1092 1093 1093 unsigned numVariables = eval->numVariables(); 1094 int numFunctions = eval->numberOfFunctionDecls(); 1094 unsigned numTopLevelFunctionDecls = eval->numTopLevelFunctionDecls(); 1095 unsigned numFunctionHoistingCandidates = eval->numFunctionHoistingCandidates(); 1095 1096 1096 1097 JSScope* variableObject; 1097 if ((numVariables || num Functions) && eval->isStrictMode()) {1098 if ((numVariables || numTopLevelFunctionDecls) && eval->isStrictMode()) { 1098 1099 scope = StrictEvalActivation::create(callFrame, scope); 1099 1100 variableObject = scope; … … 1126 1127 1127 1128 // We can't declare a "var"/"function" that overwrites a global "let"/"const"/"class" in a sloppy-mode eval. 1128 if (variableObject->isGlobalObject() && !eval->isStrictMode() && (numVariables || num Functions)) {1129 if (variableObject->isGlobalObject() && !eval->isStrictMode() && (numVariables || numTopLevelFunctionDecls)) { 1129 1130 JSGlobalLexicalEnvironment* globalLexicalEnvironment = jsCast<JSGlobalObject*>(variableObject)->globalLexicalEnvironment(); 1130 1131 for (unsigned i = 0; i < numVariables; ++i) { … … 1136 1137 } 1137 1138 1138 for ( int i = 0; i < numFunctions; ++i) {1139 for (unsigned i = 0; i < numTopLevelFunctionDecls; ++i) { 1139 1140 FunctionExecutable* function = codeBlock->functionDecl(i); 1140 1141 PropertySlot slot(globalLexicalEnvironment, PropertySlot::InternalMethodType::VMInquiry); … … 1148 1149 variableObject->flattenDictionaryObject(vm); 1149 1150 1150 if (numVariables || num Functions) {1151 if (numVariables || numTopLevelFunctionDecls || numFunctionHoistingCandidates) { 1151 1152 BatchedTransitionOptimizer optimizer(vm, variableObject); 1152 1153 if (variableObject->next() && !eval->isStrictMode()) … … 1165 1166 } 1166 1167 } 1167 1168 for (int i = 0; i < numFunctions; ++i) { 1169 FunctionExecutable* function = codeBlock->functionDecl(i); 1170 PutPropertySlot slot(variableObject); 1171 variableObject->methodTable()->put(variableObject, callFrame, function->name(), JSFunction::create(vm, function, scope), slot); 1172 RETURN_IF_EXCEPTION(throwScope, checkedReturn(throwScope.exception())); 1168 1169 if (eval->isStrictMode()) { 1170 for (unsigned i = 0; i < numTopLevelFunctionDecls; ++i) { 1171 FunctionExecutable* function = codeBlock->functionDecl(i); 1172 PutPropertySlot slot(variableObject); 1173 variableObject->methodTable()->put(variableObject, callFrame, function->name(), JSFunction::create(vm, function, scope), slot); 1174 } 1175 } else { 1176 for (unsigned i = 0; i < numTopLevelFunctionDecls; ++i) { 1177 FunctionExecutable* function = codeBlock->functionDecl(i); 1178 JSValue resolvedScope = JSScope::resolveScopeForHoistingFuncDeclInEval(callFrame, scope, function->name()); 1179 if (resolvedScope.isUndefined()) 1180 return checkedReturn(throwSyntaxError(callFrame, throwScope, makeString("Can't create duplicate variable in eval: '", String(function->name().impl()), "'"))); 1181 PutPropertySlot slot(variableObject); 1182 variableObject->methodTable()->put(variableObject, callFrame, function->name(), JSFunction::create(vm, function, scope), slot); 1183 RETURN_IF_EXCEPTION(throwScope, checkedReturn(throwScope.exception())); 1184 } 1185 1186 for (unsigned i = 0; i < numFunctionHoistingCandidates; ++i) { 1187 const Identifier& ident = codeBlock->functionHoistingCandidate(i); 1188 JSValue resolvedScope = JSScope::resolveScopeForHoistingFuncDeclInEval(callFrame, scope, ident); 1189 if (!resolvedScope.isUndefined()) { 1190 if (!variableObject->hasProperty(callFrame, ident)) { 1191 PutPropertySlot slot(variableObject); 1192 variableObject->methodTable()->put(variableObject, callFrame, ident, jsUndefined(), slot); 1193 RETURN_IF_EXCEPTION(throwScope, checkedReturn(throwScope.exception())); 1194 } 1195 } 1196 } 1173 1197 } 1174 1198 }
Note:
See TracChangeset
for help on using the changeset viewer.