Changeset 26639 in webkit for trunk/JavaScriptCore/kjs/testkjs.cpp
- Timestamp:
- Oct 15, 2007, 6:30:22 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/testkjs.cpp
r26185 r26639 124 124 virtual JSValue* callAsFunction(ExecState* exec, JSObject* thisObj, const List &args); 125 125 126 enum { Print, Debug, Quit, GC, Version, Run };126 enum { Print, Debug, Quit, GC, Version, Run, Load }; 127 127 128 128 private: … … 139 139 switch (id) { 140 140 case Print: 141 printf(" -->%s\n", args[0]->toString(exec).UTF8String().c_str());141 printf("%s\n", args[0]->toString(exec).UTF8String().c_str()); 142 142 return jsUndefined(); 143 143 case Debug: … … 159 159 char* fileName = strdup(args[0]->toString(exec).UTF8String().c_str()); 160 160 char* script = createStringWithContentsOfFile(fileName); 161 if (!script) 161 if (!script) { 162 free(fileName); 162 163 return throwError(exec, GeneralError, "Could not open file."); 164 } 163 165 164 166 stopWatch.start(); … … 170 172 171 173 return jsNumber(stopWatch.getElapsedMS()); 174 } 175 case Load: 176 { 177 char* fileName = strdup(args[0]->toString(exec).UTF8String().c_str()); 178 char* script = createStringWithContentsOfFile(fileName); 179 if (!script) { 180 free(fileName); 181 return throwError(exec, GeneralError, "Could not open file."); 182 } 183 184 exec->dynamicInterpreter()->evaluate(fileName, 0, script); 185 186 free(script); 187 free(fileName); 188 189 return jsUndefined(); 172 190 } 173 191 case Quit: … … 247 265 global->put(interp->globalExec(), "version", new TestFunctionImp(TestFunctionImp::Version, 1)); 248 266 global->put(interp->globalExec(), "run", new TestFunctionImp(TestFunctionImp::Run, 1)); 267 global->put(interp->globalExec(), "load", new TestFunctionImp(TestFunctionImp::Load, 1)); 249 268 250 269 Interpreter::setShouldPrintExceptions(true); … … 307 326 #endif 308 327 309 if (success)310 fprintf(stderr, "OK.\n");311 312 328 #ifdef KJS_DEBUG_MEM 313 329 Interpreter::finalCheck();
Note:
See TracChangeset
for help on using the changeset viewer.