Changeset 60631 in webkit for trunk/JavaScriptCore/jsc.cpp
- Timestamp:
- Jun 3, 2010, 1:00:18 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/jsc.cpp
r60392 r60631 72 72 static bool fillBufferWithContentsOfFile(const UString& fileName, Vector<char>& buffer); 73 73 74 static JSValue JSC_HOST_CALL functionPrint(ExecState*);75 static JSValue JSC_HOST_CALL functionDebug(ExecState*);76 static JSValue JSC_HOST_CALL functionGC(ExecState*);77 static JSValue JSC_HOST_CALL functionVersion(ExecState*);78 static JSValue JSC_HOST_CALL functionRun(ExecState*);79 static JSValue JSC_HOST_CALL functionLoad(ExecState*);80 static JSValue JSC_HOST_CALL functionCheckSyntax(ExecState*);81 static JSValue JSC_HOST_CALL functionReadline(ExecState*);82 static NO_RETURN_WITH_VALUE JSValue JSC_HOST_CALL functionQuit(ExecState*);74 static EncodedJSValue JSC_HOST_CALL functionPrint(ExecState*); 75 static EncodedJSValue JSC_HOST_CALL functionDebug(ExecState*); 76 static EncodedJSValue JSC_HOST_CALL functionGC(ExecState*); 77 static EncodedJSValue JSC_HOST_CALL functionVersion(ExecState*); 78 static EncodedJSValue JSC_HOST_CALL functionRun(ExecState*); 79 static EncodedJSValue JSC_HOST_CALL functionLoad(ExecState*); 80 static EncodedJSValue JSC_HOST_CALL functionCheckSyntax(ExecState*); 81 static EncodedJSValue JSC_HOST_CALL functionReadline(ExecState*); 82 static NO_RETURN_WITH_VALUE EncodedJSValue JSC_HOST_CALL functionQuit(ExecState*); 83 83 84 84 #if ENABLE(SAMPLING_FLAGS) 85 static JSValue JSC_HOST_CALL functionSetSamplingFlags(ExecState*);86 static JSValue JSC_HOST_CALL functionClearSamplingFlags(ExecState*);85 static EncodedJSValue JSC_HOST_CALL functionSetSamplingFlags(ExecState*); 86 static EncodedJSValue JSC_HOST_CALL functionClearSamplingFlags(ExecState*); 87 87 #endif 88 88 … … 172 172 } 173 173 174 JSValue JSC_HOST_CALL functionPrint(ExecState* exec)174 EncodedJSValue JSC_HOST_CALL functionPrint(ExecState* exec) 175 175 { 176 176 for (unsigned i = 0; i < exec->argumentCount(); ++i) { … … 183 183 putchar('\n'); 184 184 fflush(stdout); 185 return jsUndefined();186 } 187 188 JSValue JSC_HOST_CALL functionDebug(ExecState* exec)185 return JSValue::encode(jsUndefined()); 186 } 187 188 EncodedJSValue JSC_HOST_CALL functionDebug(ExecState* exec) 189 189 { 190 190 fprintf(stderr, "--> %s\n", exec->argument(0).toString(exec).UTF8String().data()); 191 return jsUndefined();192 } 193 194 JSValue JSC_HOST_CALL functionGC(ExecState* exec)191 return JSValue::encode(jsUndefined()); 192 } 193 194 EncodedJSValue JSC_HOST_CALL functionGC(ExecState* exec) 195 195 { 196 196 JSLock lock(SilenceAssertionsOnly); 197 197 exec->heap()->collectAllGarbage(); 198 return jsUndefined();199 } 200 201 JSValue JSC_HOST_CALL functionVersion(ExecState*)198 return JSValue::encode(jsUndefined()); 199 } 200 201 EncodedJSValue JSC_HOST_CALL functionVersion(ExecState*) 202 202 { 203 203 // We need this function for compatibility with the Mozilla JS tests but for now 204 204 // we don't actually do any version-specific handling 205 return jsUndefined();206 } 207 208 JSValue JSC_HOST_CALL functionRun(ExecState* exec)205 return JSValue::encode(jsUndefined()); 206 } 207 208 EncodedJSValue JSC_HOST_CALL functionRun(ExecState* exec) 209 209 { 210 210 StopWatch stopWatch; … … 212 212 Vector<char> script; 213 213 if (!fillBufferWithContentsOfFile(fileName, script)) 214 return throwError(exec, GeneralError, "Could not open file.");214 return JSValue::encode(throwError(exec, GeneralError, "Could not open file.")); 215 215 216 216 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); … … 220 220 stopWatch.stop(); 221 221 222 return jsNumber(globalObject->globalExec(), stopWatch.getElapsedMS());223 } 224 225 JSValue JSC_HOST_CALL functionLoad(ExecState* exec)222 return JSValue::encode(jsNumber(globalObject->globalExec(), stopWatch.getElapsedMS())); 223 } 224 225 EncodedJSValue JSC_HOST_CALL functionLoad(ExecState* exec) 226 226 { 227 227 UString fileName = exec->argument(0).toString(exec); 228 228 Vector<char> script; 229 229 if (!fillBufferWithContentsOfFile(fileName, script)) 230 return throwError(exec, GeneralError, "Could not open file.");230 return JSValue::encode(throwError(exec, GeneralError, "Could not open file.")); 231 231 232 232 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); … … 234 234 if (result.complType() == Throw) 235 235 exec->setException(result.value()); 236 return result.value();237 } 238 239 JSValue JSC_HOST_CALL functionCheckSyntax(ExecState* exec)236 return JSValue::encode(result.value()); 237 } 238 239 EncodedJSValue JSC_HOST_CALL functionCheckSyntax(ExecState* exec) 240 240 { 241 241 UString fileName = exec->argument(0).toString(exec); 242 242 Vector<char> script; 243 243 if (!fillBufferWithContentsOfFile(fileName, script)) 244 return throwError(exec, GeneralError, "Could not open file.");244 return JSValue::encode(throwError(exec, GeneralError, "Could not open file.")); 245 245 246 246 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); … … 248 248 if (result.complType() == Throw) 249 249 exec->setException(result.value()); 250 return result.value();250 return JSValue::encode(result.value()); 251 251 } 252 252 253 253 #if ENABLE(SAMPLING_FLAGS) 254 JSValue JSC_HOST_CALL functionSetSamplingFlags(ExecState* exec)254 EncodedJSValue JSC_HOST_CALL functionSetSamplingFlags(ExecState* exec) 255 255 { 256 256 for (unsigned i = 0; i < exec->argumentCount(); ++i) { … … 259 259 SamplingFlags::setFlag(flag); 260 260 } 261 return jsNull();262 } 263 264 JSValue JSC_HOST_CALL functionClearSamplingFlags(ExecState* exec)261 return JSValue::encode(jsNull()); 262 } 263 264 EncodedJSValue JSC_HOST_CALL functionClearSamplingFlags(ExecState* exec) 265 265 { 266 266 for (unsigned i = 0; i < exec->argumentCount(); ++i) { … … 269 269 SamplingFlags::clearFlag(flag); 270 270 } 271 return jsNull();272 } 273 #endif 274 275 JSValue JSC_HOST_CALL functionReadline(ExecState* exec)271 return JSValue::encode(jsNull()); 272 } 273 #endif 274 275 EncodedJSValue JSC_HOST_CALL functionReadline(ExecState* exec) 276 276 { 277 277 Vector<char, 256> line; … … 284 284 } 285 285 line.append('\0'); 286 return jsString(exec, line.data());287 } 288 289 JSValue JSC_HOST_CALL functionQuit(ExecState* exec)286 return JSValue::encode(jsString(exec, line.data())); 287 } 288 289 EncodedJSValue JSC_HOST_CALL functionQuit(ExecState* exec) 290 290 { 291 291 // Technically, destroying the heap in the middle of JS execution is a no-no, … … 299 299 #if COMPILER(MSVC) && OS(WINCE) 300 300 // Without this, Visual Studio will complain that this method does not return a value. 301 return jsUndefined();301 return JSValue::encode(jsUndefined()); 302 302 #endif 303 303 }
Note:
See TracChangeset
for help on using the changeset viewer.