説明を見る。00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef V8_PARSER_H_
00029 #define V8_PARSER_H_
00030
00031 #include "scanner.h"
00032
00033 namespace v8 { namespace internal {
00034
00035
00036 class ParserMessage : public Malloced {
00037 public:
00038 ParserMessage(Scanner::Location loc, const char* message,
00039 Vector<const char*> args)
00040 : loc_(loc),
00041 message_(message),
00042 args_(args) { }
00043 ~ParserMessage();
00044 Scanner::Location location() { return loc_; }
00045 const char* message() { return message_; }
00046 Vector<const char*> args() { return args_; }
00047 private:
00048 Scanner::Location loc_;
00049 const char* message_;
00050 Vector<const char*> args_;
00051 };
00052
00053
00054 class FunctionEntry BASE_EMBEDDED {
00055 public:
00056 explicit FunctionEntry(Vector<unsigned> backing) : backing_(backing) { }
00057 FunctionEntry() : backing_(Vector<unsigned>::empty()) { }
00058
00059 int start_pos() { return backing_[kStartPosOffset]; }
00060 void set_start_pos(int value) { backing_[kStartPosOffset] = value; }
00061
00062 int end_pos() { return backing_[kEndPosOffset]; }
00063 void set_end_pos(int value) { backing_[kEndPosOffset] = value; }
00064
00065 int literal_count() { return backing_[kLiteralCountOffset]; }
00066 void set_literal_count(int value) { backing_[kLiteralCountOffset] = value; }
00067
00068 int property_count() { return backing_[kPropertyCountOffset]; }
00069 void set_property_count(int value) { backing_[kPropertyCountOffset] = value; }
00070
00071 bool contains_array_literal() {
00072 return backing_[kContainsArrayLiteralOffset] != 0;
00073 }
00074 void set_contains_array_literal(bool value) {
00075 backing_[kContainsArrayLiteralOffset] = value ? 1 : 0;
00076 }
00077
00078 bool is_valid() { return backing_.length() > 0; }
00079
00080 static const int kSize = 5;
00081
00082 private:
00083 Vector<unsigned> backing_;
00084 static const int kStartPosOffset = 0;
00085 static const int kEndPosOffset = 1;
00086 static const int kLiteralCountOffset = 2;
00087 static const int kPropertyCountOffset = 3;
00088 static const int kContainsArrayLiteralOffset = 4;
00089 };
00090
00091
00092 class ScriptDataImpl : public ScriptData {
00093 public:
00094 explicit ScriptDataImpl(Vector<unsigned> store)
00095 : store_(store),
00096 last_entry_(0) { }
00097 virtual ~ScriptDataImpl();
00098 virtual int Length();
00099 virtual unsigned* Data();
00100 FunctionEntry GetFunctionEnd(int start);
00101 bool SanityCheck();
00102
00103 Scanner::Location MessageLocation();
00104 const char* BuildMessage();
00105 Vector<const char*> BuildArgs();
00106
00107 bool has_error() { return store_[kHasErrorOffset]; }
00108 unsigned magic() { return store_[kMagicOffset]; }
00109 unsigned version() { return store_[kVersionOffset]; }
00110
00111 static const unsigned kMagicNumber = 0xBadDead;
00112 static const unsigned kCurrentVersion = 1;
00113
00114 static const unsigned kMagicOffset = 0;
00115 static const unsigned kVersionOffset = 1;
00116 static const unsigned kHasErrorOffset = 2;
00117 static const unsigned kSizeOffset = 3;
00118 static const unsigned kHeaderSize = 4;
00119
00120 private:
00121 unsigned Read(int position);
00122 unsigned* ReadAddress(int position);
00123 int EntryCount();
00124 FunctionEntry nth(int n);
00125
00126 Vector<unsigned> store_;
00127
00128
00129
00130
00131 int last_entry_;
00132 };
00133
00134
00135
00136
00137
00138 FunctionLiteral* MakeAST(bool compile_in_global_context,
00139 Handle<Script> script,
00140 v8::Extension* extension,
00141 ScriptDataImpl* pre_data);
00142
00143
00144 ScriptDataImpl* PreParse(unibrow::CharacterStream* stream,
00145 v8::Extension* extension);
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 FunctionLiteral* MakeLazyAST(Handle<Script> script,
00158 Handle<String> name,
00159 int start_position,
00160 int end_position,
00161 bool is_expression);
00162
00163 } }
00164
00165 #endif // V8_PARSER_H_