Logo Search packages:      
Sourcecode: osb-jscore version File versions  Download package

Completion Interpreter::evaluate ( const UString sourceURL,
int  startingLineNumber,
const UString code,
const Value thisV = Value() 

Evaluates the supplied ECMAScript code.

Since this method returns a Completion, you should check the type of completion to detect an error or before attempting to access the returned value. For example, if an error occurs during script execution and is not caught by the script, the completion type will be Throw.

If the supplied code is invalid, a SyntaxError will be thrown.

code The code to evaluate
thisV The value to pass in as the "this" value for the script execution. This should either be Null() or an Object.
A completion object representing the result of the execution.

Definition at line 123 of file interpreter.cpp.

References KJS::UString::ascii(), KJS::Completion::complType(), KJS::Value::toObject(), KJS::Value::toString(), and KJS::Completion::value().

  Completion comp = rep->evaluate(code,thisV, sourceURL, startingLineNumber);

  if (shouldPrintExceptions() && comp.complType() == Throw) {
    ExecState *exec = rep->globalExec();
    char *f = strdup(sourceURL.ascii());
    const char *message = comp.value().toObject(exec).toString(exec).ascii();
    printf("%s:%s\n", f, message);

  return comp;

Generated by  Doxygen 1.6.0   Back to index