Changeset 33979 in webkit for trunk/JavaScriptCore/kjs/testkjs.cpp
- Timestamp:
- May 21, 2008, 6:20:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/testkjs.cpp
r33038 r33979 23 23 #include "config.h" 24 24 25 #include "CodeGenerator.h" 25 26 #include "JSGlobalObject.h" 26 27 #include "JSLock.h" … … 184 185 return throwError(exec, GeneralError, "Could not open file."); 185 186 187 JSGlobalObject* globalObject = exec->dynamicGlobalObject(); 188 186 189 stopWatch.start(); 187 Interpreter::evaluate( exec->dynamicGlobalObject()->globalExec(), fileName, 0, script.data());190 Interpreter::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), fileName, 0, script.data()); 188 191 stopWatch.stop(); 189 192 … … 198 201 return throwError(exec, GeneralError, "Could not open file."); 199 202 200 Interpreter::evaluate(exec->dynamicGlobalObject()->globalExec(), fileName, 0, script.data()); 203 JSGlobalObject* globalObject = exec->dynamicGlobalObject(); 204 Interpreter::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), fileName, 0, script.data()); 201 205 202 206 return jsUndefined(); … … 259 263 } 260 264 261 static bool prettyPrintScript( const UString& fileName, const Vector<char>& script)265 static bool prettyPrintScript(ExecState* exec, const UString& fileName, const Vector<char>& script) 262 266 { 263 267 int errLine = 0; 264 268 UString errMsg; 265 269 UString scriptUString(script.data()); 266 RefPtr<ProgramNode> programNode = parser().parse<ProgramNode>( fileName, 0, scriptUString.data(), scriptUString.size(), 0, &errLine, &errMsg);270 RefPtr<ProgramNode> programNode = parser().parse<ProgramNode>(exec, fileName, 0, UStringSourceProvider::create(scriptUString), 0, &errLine, &errMsg); 267 271 if (!programNode) { 268 272 fprintf(stderr, "%s:%d: %s.\n", fileName.UTF8String().c_str(), errLine, errMsg.UTF8String().c_str()); … … 274 278 } 275 279 276 static bool runWithScripts(const Vector<UString>& fileNames, Vector<UString>& arguments, bool prettyPrint )280 static bool runWithScripts(const Vector<UString>& fileNames, Vector<UString>& arguments, bool prettyPrint, bool dump) 277 281 { 278 282 GlobalObject* globalObject = new GlobalObject(arguments); 279 283 Vector<char> script; 280 284 285 if (dump) 286 CodeGenerator::setDumpsGeneratedCode(true); 287 281 288 bool success = true; 282 289 … … 288 295 289 296 if (prettyPrint) 290 prettyPrintScript( fileName, script);297 prettyPrintScript(globalObject->globalExec(), fileName, script); 291 298 else { 292 Completion completion = Interpreter::evaluate(globalObject->globalExec(), fileName, 0, script.data());299 Completion completion = Interpreter::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), fileName, 0, script.data()); 293 300 success = success && completion.complType() != Throw; 301 if (dump) { 302 if (success) 303 printf("End: %s\n", completion.value()->toString(globalObject->globalExec()).ascii()); 304 else 305 printf("Exception: %s\n", completion.value()->toString(globalObject->globalExec()).ascii()); 306 } 294 307 } 295 308 } … … 303 316 } 304 317 305 static void parseArguments(int argc, char** argv, Vector<UString>& fileNames, Vector<UString>& arguments, bool& prettyPrint )318 static void parseArguments(int argc, char** argv, Vector<UString>& fileNames, Vector<UString>& arguments, bool& prettyPrint, bool& dump) 306 319 { 307 320 if (argc < 3) … … 321 334 continue; 322 335 } 336 if (strcmp(arg, "-d") == 0) { 337 dump = true; 338 continue; 339 } 340 if (strcmp(arg, "-s") == 0) { 341 #if PLATFORM(UNIX) 342 signal(SIGILL, _exit); 343 signal(SIGFPE, _exit); 344 signal(SIGBUS, _exit); 345 signal(SIGSEGV, _exit); 346 #endif 347 continue; 348 } 323 349 if (strcmp(arg, "--") == 0) { 324 350 ++i; … … 339 365 340 366 bool prettyPrint = false; 367 bool dump = false; 341 368 Vector<UString> fileNames; 342 369 Vector<UString> arguments; 343 parseArguments(argc, argv, fileNames, arguments, prettyPrint );344 345 bool success = runWithScripts(fileNames, arguments, prettyPrint );370 parseArguments(argc, argv, fileNames, arguments, prettyPrint, dump); 371 372 bool success = runWithScripts(fileNames, arguments, prettyPrint, dump); 346 373 347 374 #ifndef NDEBUG
Note:
See TracChangeset
for help on using the changeset viewer.