Changeset 38249 in webkit for trunk/JavaScriptCore/jsc.cpp


Ignore:
Timestamp:
Nov 9, 2008, 5:28:10 PM (17 years ago)
Author:
Darin Adler
Message:

2008-11-09 Darin Adler <Darin Adler>

Reviewed by Tim Hatcher.

  • VM/CodeBlock.h: Added include.
  • VM/Machine.cpp: (JSC::Machine::execute): Use the types from
DeclarationStacks as DeclarationStacks
rather than Node:: since "Node" really has little to do with it.
  • bytecompiler/CodeGenerator.cpp: (JSC::CodeGenerator::CodeGenerator): Ditto.
  • jsc.cpp: (Options::Options): Removed prettyPrint option. (runWithScripts): Ditto. (printUsageStatement): Ditto. (parseArguments): Ditto. (jscmain): Ditto.
  • parser/Grammar.y: Removed use of obsolete ImmediateNumberNode.
  • parser/Nodes.cpp: (JSC::ThrowableExpressionData::emitThrowError): Use inline functions instead of direct member access for ThrowableExpressionData values. (JSC::BracketAccessorNode::emitCode): Ditto. (JSC::DotAccessorNode::emitCode): Ditto. (JSC::NewExprNode::emitCode): Ditto. (JSC::EvalFunctionCallNode::emitCode): Ditto. (JSC::FunctionCallValueNode::emitCode): Ditto. (JSC::FunctionCallResolveNode::emitCode): Ditto. (JSC::FunctionCallBracketNode::emitCode): Ditto. (JSC::FunctionCallDotNode::emitCode): Ditto. (JSC::PostfixResolveNode::emitCode): Ditto. (JSC::PostfixBracketNode::emitCode): Ditto. (JSC::PostfixDotNode::emitCode): Ditto. (JSC::DeleteResolveNode::emitCode): Ditto. (JSC::DeleteBracketNode::emitCode): Ditto. (JSC::DeleteDotNode::emitCode): Ditto. (JSC::PrefixResolveNode::emitCode): Ditto. (JSC::PrefixBracketNode::emitCode): Ditto. (JSC::PrefixDotNode::emitCode): Ditto. (JSC::ThrowableBinaryOpNode::emitCode): Ditto. (JSC::InstanceOfNode::emitCode): Ditto. (JSC::ReadModifyResolveNode::emitCode): Ditto. (JSC::AssignResolveNode::emitCode): Ditto. (JSC::AssignDotNode::emitCode): Ditto. (JSC::ReadModifyDotNode::emitCode): Ditto. (JSC::AssignBracketNode::emitCode): Ditto. (JSC::ReadModifyBracketNode::emitCode): Ditto. (JSC::statementListEmitCode): Take a const StatementVector instead of a non-const one. Also removed unused statementListPushFIFO. (JSC::ForInNode::emitCode): Inline functions instead of member access. (JSC::ThrowNode::emitCode): Ditto. (JSC::EvalNode::emitCode): Ditto. (JSC::FunctionBodyNode::emitCode): Ditto. (JSC::ProgramNode::emitCode): Ditto.
  • parser/Nodes.h: Removed unused includes and forward declarations. Removed Precedence enum. Made many more members private instead of protected or public. Removed unused NodeStack typedef. Moved the VarStack and FunctionStack typedefs from Node to ScopeNode. Made Node::emitCode pure virtual and changed classes that don't emit any code to inherit from ParserRefCounted rather than Node. Moved isReturnNode from Node to StatementNode. Removed the streamTo, precedence, and needsParensIfLeftmost functions from all classes. Removed the ImmediateNumberNode class and make NumberNode::setValue nonvirtual.
  • parser/nodes2string.cpp: Removed.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/jsc.cpp

    r38162 r38249  
    7979    Options()
    8080        : interactive(false)
    81         , prettyPrint(false)
    8281        , dump(false)
    8382    {
     
    8584
    8685    bool interactive;
    87     bool prettyPrint;
    8886    bool dump;
    8987    Vector<UString> fileNames;
     
    300298}
    301299
    302 static bool prettyPrintScript(ExecState* exec, const UString& fileName, const Vector<char>& script)
    303 {
    304     int errLine = 0;
    305     UString errMsg;
    306     RefPtr<ProgramNode> programNode = exec->globalData().parser->parse<ProgramNode>(exec, exec->dynamicGlobalObject()->debugger(), makeSource(script.data(), fileName), &errLine, &errMsg);
    307     if (!programNode) {
    308         fprintf(stderr, "%s:%d: %s.\n", fileName.UTF8String().c_str(), errLine, errMsg.UTF8String().c_str());
    309         return false;
    310     }
    311 
    312     printf("%s\n", programNode->toString().UTF8String().c_str());
    313     return true;
    314 }
    315 
    316 static bool runWithScripts(GlobalObject* globalObject, const Vector<UString>& fileNames, bool prettyPrint, bool dump)
     300static bool runWithScripts(GlobalObject* globalObject, const Vector<UString>& fileNames, bool dump)
    317301{
    318302    Vector<char> script;
     
    333317            return false; // fail early so we can catch missing files
    334318
    335         if (prettyPrint)
    336             prettyPrintScript(globalObject->globalExec(), fileName, script);
    337         else {
    338319#if ENABLE(OPCODE_SAMPLING)
    339             machine->sampler()->start();
    340 #endif
    341             Completion completion = Interpreter::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script.data(), fileName));
    342             success = success && completion.complType() != Throw;
    343             if (dump) {
    344                 if (completion.complType() == Throw)
    345                     printf("Exception: %s\n", completion.value()->toString(globalObject->globalExec()).ascii());
    346                 else
    347                     printf("End: %s\n", completion.value()->toString(globalObject->globalExec()).ascii());
    348             }
    349 
    350             globalObject->globalExec()->clearException();
     320        machine->sampler()->start();
     321#endif
     322        Completion completion = Interpreter::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script.data(), fileName));
     323        success = success && completion.complType() != Throw;
     324        if (dump) {
     325            if (completion.complType() == Throw)
     326                printf("Exception: %s\n", completion.value()->toString(globalObject->globalExec()).ascii());
     327            else
     328                printf("End: %s\n", completion.value()->toString(globalObject->globalExec()).ascii());
     329        }
     330
     331        globalObject->globalExec()->clearException();
    351332
    352333#if ENABLE(OPCODE_SAMPLING)
    353             machine->sampler()->stop();
    354 #endif
    355         }
     334        machine->sampler()->stop();
     335#endif
    356336    }
    357337
     
    404384    fprintf(stderr, "  -h|--help  Prints this help message\n");
    405385    fprintf(stderr, "  -i         Enables interactive mode (default if no files are specified)\n");
    406     fprintf(stderr, "  -p         Prints formatted source code\n");
    407386    fprintf(stderr, "  -s         Installs signal handlers that exit on a crash (Unix platforms only)\n");
    408387    exit(-1);
     
    427406            continue;
    428407        }
    429         if (strcmp(arg, "-p") == 0) {
    430             options.prettyPrint = true;
    431             continue;
    432         }
    433408        if (strcmp(arg, "-d") == 0) {
    434409            options.dump = true;
     
    468443
    469444    GlobalObject* globalObject = new (globalData) GlobalObject(options.arguments);
    470     bool success = runWithScripts(globalObject, options.fileNames, options.prettyPrint, options.dump);
     445    bool success = runWithScripts(globalObject, options.fileNames, options.dump);
    471446    if (options.interactive && success)
    472447        runInteractive(globalObject);
Note: See TracChangeset for help on using the changeset viewer.