![]() |
v8
3.11.10(node0.8.26)
V8 is Google's open source JavaScript engine
|
#include <v8.h>
#include <v8-debug.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
Go to the source code of this file.
Macros | |
#define | SUPPORT_DEBUGGING |
Enumerations | |
enum | MainCycleType { CycleInCpp, CycleInJs } |
Functions | |
const char * | ToCString (const v8::String::Utf8Value &value) |
void | ReportException (v8::TryCatch *handler) |
v8::Handle< v8::String > | ReadFile (const char *name) |
v8::Handle< v8::String > | ReadLine () |
v8::Handle< v8::Value > | Print (const v8::Arguments &args) |
v8::Handle< v8::Value > | ReadLine (const v8::Arguments &args) |
bool | RunCppCycle (v8::Handle< v8::Script > script, v8::Local< v8::Context > context, bool report_exceptions) |
void | DispatchDebugMessages () |
int | RunMain (int argc, char *argv[]) |
int | main (int argc, char *argv[]) |
Variables | |
v8::Persistent< v8::Context > | debug_message_context |
#define SUPPORT_DEBUGGING |
Definition at line 34 of file lineprocessor.cc.
enum MainCycleType |
This sample program should demonstrate certain aspects of debugging standalone V8-based application.
The program reads input stream, processes it line by line and print the result to output. The actual processing is done by custom JavaScript script. The script is specified with command line parameters.
The main cycle of the program will sequentially read lines from standard input, process them and print to standard output until input closes. There are 2 possible configuration in regard to main cycle.
function ProcessLine(input_line) { return ">>>" + input_line + "<<<"; }
while (true) { var line = read_line(); if (!line) { break; } var res = line + " | " + line; print(res); }
When run with "-p" argument, the program starts V8 Debugger Agent and allows remote debugger to attach and debug JavaScript code.
Interesting aspects:
Enumerator | |
---|---|
CycleInCpp | |
CycleInJs |
Definition at line 103 of file lineprocessor.cc.
void DispatchDebugMessages | ( | ) |
Definition at line 122 of file lineprocessor.cc.
References Debug::ProcessDebugMessages().
Referenced by RunMain().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 325 of file lineprocessor.cc.
References V8::Dispose(), and RunMain().
v8::Handle< v8::Value > Print | ( | const v8::Arguments & | args | ) |
Definition at line 396 of file lineprocessor.cc.
References Arguments::Length(), ToCString(), and v8::Undefined().
Referenced by Heap::GarbageCollectionEpilogue(), Heap::GarbageCollectionPrologue(), JSObject::NormalizeElements(), JSObject::NormalizeProperties(), RunMain(), JSObject::SetDictionaryElement(), TEST(), ToBooleanStub::Types::TraceTransition(), Interface::Unify(), and CppByteSink::WriteSnapshot().
v8::Handle< v8::String > ReadFile | ( | const char * | name | ) |
Definition at line 339 of file lineprocessor.cc.
References String::New(), and NULL.
Referenced by RunMain().
v8::Handle< v8::String > ReadLine | ( | ) |
Definition at line 424 of file lineprocessor.cc.
References String::Cast(), String::New(), NULL, and v8::Undefined().
Referenced by ReadLine(), RunCppCycle(), and RunMain().
v8::Handle< v8::Value > ReadLine | ( | const v8::Arguments & | args | ) |
Definition at line 417 of file lineprocessor.cc.
References Arguments::Length(), String::New(), ReadLine(), and v8::ThrowException().
void ReportException | ( | v8::TryCatch * | handler | ) |
Definition at line 360 of file lineprocessor.cc.
References TryCatch::Exception(), Message::GetEndColumn(), Message::GetLineNumber(), Message::GetScriptResourceName(), Message::GetSourceLine(), Message::GetStartColumn(), Handle< T >::IsEmpty(), TryCatch::Message(), and ToCString().
Referenced by RunCppCycle(), and RunMain().
bool RunCppCycle | ( | v8::Handle< v8::Script > | script, |
v8::Local< v8::Context > | context, | ||
bool | report_exceptions | ||
) |
Definition at line 273 of file lineprocessor.cc.
References Function::Call(), Handle< T >::Cast(), Context::GetCurrent(), TryCatch::HasCaught(), Value::IsFunction(), String::New(), ReadLine(), ReportException(), ToCString(), and v8::Undefined().
Referenced by RunMain().
int RunMain | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 141 of file lineprocessor.cc.
References Script::Compile(), CycleInCpp, CycleInJs, DispatchDebugMessages(), Debug::EnableAgent(), Context::GetCurrent(), TryCatch::HasCaught(), Handle< T >::IsEmpty(), Persistent< T >::New(), String::New(), FunctionTemplate::New(), ObjectTemplate::New(), Context::New(), NULL, Print(), ReadFile(), ReadLine(), ReportException(), Script::Run(), RunCppCycle(), Template::Set(), Debug::SetDebugMessageDispatchHandler(), and V8::SetFlagsFromCommandLine().
Referenced by main().
const char * ToCString | ( | const v8::String::Utf8Value & | value | ) |
Definition at line 333 of file lineprocessor.cc.
Referenced by HGraphBuilder::Bailout(), SharedFunctionInfo::DisableOptimization(), Isolate::DoThrow(), Print(), LStoreNamedField::PrintDataTo(), LStoreNamedGeneric::PrintDataTo(), LTypeofIsAndBranch::PrintDataTo(), HLoadNamedFieldPolymorphic::PrintDataTo(), HLoadNamedGeneric::PrintDataTo(), HStoreNamedField::PrintDataTo(), HStoreNamedGeneric::PrintDataTo(), ReportException(), RunCppCycle(), and String::ToCString().
v8::Persistent<v8::Context> debug_message_context |
Definition at line 120 of file lineprocessor.cc.