| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 101 class Integer; | 101 class Integer; | 
| 102 class Isolate; | 102 class Isolate; | 
| 103 class Number; | 103 class Number; | 
| 104 class NumberObject; | 104 class NumberObject; | 
| 105 class Object; | 105 class Object; | 
| 106 class ObjectOperationDescriptor; | 106 class ObjectOperationDescriptor; | 
| 107 class ObjectTemplate; | 107 class ObjectTemplate; | 
| 108 class Platform; | 108 class Platform; | 
| 109 class Primitive; | 109 class Primitive; | 
| 110 class RawOperationDescriptor; | 110 class RawOperationDescriptor; | 
|  | 111 class Script; | 
| 111 class Signature; | 112 class Signature; | 
| 112 class StackFrame; | 113 class StackFrame; | 
| 113 class StackTrace; | 114 class StackTrace; | 
| 114 class String; | 115 class String; | 
| 115 class StringObject; | 116 class StringObject; | 
| 116 class Symbol; | 117 class Symbol; | 
| 117 class SymbolObject; | 118 class SymbolObject; | 
| 118 class Private; | 119 class Private; | 
| 119 class Uint32; | 120 class Uint32; | 
| 120 class Utils; | 121 class Utils; | 
| (...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1139   V8_INLINE Handle<Boolean> ResourceIsSharedCrossOrigin() const; | 1140   V8_INLINE Handle<Boolean> ResourceIsSharedCrossOrigin() const; | 
| 1140  private: | 1141  private: | 
| 1141   Handle<Value> resource_name_; | 1142   Handle<Value> resource_name_; | 
| 1142   Handle<Integer> resource_line_offset_; | 1143   Handle<Integer> resource_line_offset_; | 
| 1143   Handle<Integer> resource_column_offset_; | 1144   Handle<Integer> resource_column_offset_; | 
| 1144   Handle<Boolean> resource_is_shared_cross_origin_; | 1145   Handle<Boolean> resource_is_shared_cross_origin_; | 
| 1145 }; | 1146 }; | 
| 1146 | 1147 | 
| 1147 | 1148 | 
| 1148 /** | 1149 /** | 
| 1149  * A compiled JavaScript script. | 1150  * A compiled JavaScript script, not yet tied to a Context. | 
| 1150  */ | 1151  */ | 
| 1151 class V8_EXPORT Script { | 1152 class V8_EXPORT UnboundScript { | 
| 1152  public: | 1153  public: | 
| 1153   /** | 1154   /** | 
| 1154    * Compiles the specified script (context-independent). | 1155    * Binds the script to the currently entered context. | 
| 1155    * |  | 
| 1156    * \param source Script source code. |  | 
| 1157    * \param origin Script origin, owned by caller, no references are kept |  | 
| 1158    *   when New() returns |  | 
| 1159    * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile() |  | 
| 1160    *   using pre_data speeds compilation if it's done multiple times. |  | 
| 1161    *   Owned by caller, no references are kept when New() returns. |  | 
| 1162    * \return Compiled script object (context independent; when run it |  | 
| 1163    *   will use the currently entered context). |  | 
| 1164    */ | 1156    */ | 
| 1165   static Local<Script> New(Handle<String> source, | 1157   Local<Script> BindToCurrentContext(); | 
| 1166                            ScriptOrigin* origin = NULL, |  | 
| 1167                            ScriptData* pre_data = NULL); |  | 
| 1168 | 1158 | 
| 1169   /** |  | 
| 1170    * Compiles the specified script using the specified file name |  | 
| 1171    * object (typically a string) as the script's origin. |  | 
| 1172    * |  | 
| 1173    * \param source Script source code. |  | 
| 1174    * \param file_name file name object (typically a string) to be used |  | 
| 1175    *   as the script's origin. |  | 
| 1176    * \return Compiled script object (context independent; when run it |  | 
| 1177    *   will use the currently entered context). |  | 
| 1178    */ |  | 
| 1179   static Local<Script> New(Handle<String> source, |  | 
| 1180                            Handle<Value> file_name); |  | 
| 1181 |  | 
| 1182   /** |  | 
| 1183    * Compiles the specified script (bound to current context). |  | 
| 1184    * |  | 
| 1185    * \param source Script source code. |  | 
| 1186    * \param origin Script origin, owned by caller, no references are kept |  | 
| 1187    *   when Compile() returns |  | 
| 1188    * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile() |  | 
| 1189    *   using pre_data speeds compilation if it's done multiple times. |  | 
| 1190    *   Owned by caller, no references are kept when Compile() returns. |  | 
| 1191    * \return Compiled script object, bound to the context that was active |  | 
| 1192    *   when this function was called.  When run it will always use this |  | 
| 1193    *   context. |  | 
| 1194    */ |  | 
| 1195   static Local<Script> Compile(Handle<String> source, |  | 
| 1196                                ScriptOrigin* origin = NULL, |  | 
| 1197                                ScriptData* pre_data = NULL); |  | 
| 1198 |  | 
| 1199   /** |  | 
| 1200    * Compiles the specified script using the specified file name |  | 
| 1201    * object (typically a string) as the script's origin. |  | 
| 1202    * |  | 
| 1203    * \param source Script source code. |  | 
| 1204    * \param file_name File name to use as script's origin |  | 
| 1205    * \return Compiled script object, bound to the context that was active |  | 
| 1206    *   when this function was called.  When run it will always use this |  | 
| 1207    *   context. |  | 
| 1208    */ |  | 
| 1209   static Local<Script> Compile(Handle<String> source, |  | 
| 1210                                Handle<Value> file_name); |  | 
| 1211 |  | 
| 1212   /** |  | 
| 1213    * Runs the script returning the resulting value.  If the script is |  | 
| 1214    * context independent (created using ::New) it will be run in the |  | 
| 1215    * currently entered context.  If it is context specific (created |  | 
| 1216    * using ::Compile) it will be run in the context in which it was |  | 
| 1217    * compiled. |  | 
| 1218    */ |  | 
| 1219   Local<Value> Run(); |  | 
| 1220 |  | 
| 1221   /** |  | 
| 1222    * Returns the script id. |  | 
| 1223    */ |  | 
| 1224   int GetId(); | 1159   int GetId(); | 
| 1225 |  | 
| 1226   /** |  | 
| 1227    * Returns the name value of one Script. |  | 
| 1228    */ |  | 
| 1229   Handle<Value> GetScriptName(); | 1160   Handle<Value> GetScriptName(); | 
| 1230 | 1161 | 
| 1231   /** | 1162   /** | 
| 1232    * Returns zero based line number of the code_pos location in the script. | 1163    * Returns zero based line number of the code_pos location in the script. | 
| 1233    * -1 will be returned if no information available. | 1164    * -1 will be returned if no information available. | 
| 1234    */ | 1165    */ | 
| 1235   int GetLineNumber(int code_pos); | 1166   int GetLineNumber(int code_pos); | 
| 1236 | 1167 | 
| 1237   static const int kNoScriptId = 0; | 1168   static const int kNoScriptId = 0; | 
| 1238 }; | 1169 }; | 
| 1239 | 1170 | 
| 1240 | 1171 | 
|  | 1172 /** | 
|  | 1173  * A compiled JavaScript script, tied to a Context which was active when the | 
|  | 1174  * script was compiled. | 
|  | 1175  */ | 
|  | 1176 class V8_EXPORT Script { | 
|  | 1177  public: | 
|  | 1178   /** | 
|  | 1179    * A shorthand for ScriptCompiler::Compile(). | 
|  | 1180    * The ScriptData parameter will be deprecated; use ScriptCompiler::Compile if | 
|  | 1181    * you want to pass it. | 
|  | 1182    */ | 
|  | 1183   static Local<Script> Compile(Handle<String> source, | 
|  | 1184                                ScriptOrigin* origin = NULL, | 
|  | 1185                                ScriptData* script_data = NULL); | 
|  | 1186 | 
|  | 1187   // To be decprecated, use the Compile above. | 
|  | 1188   static Local<Script> Compile(Handle<String> source, | 
|  | 1189                                Handle<String> file_name); | 
|  | 1190 | 
|  | 1191   /** | 
|  | 1192    * Runs the script returning the resulting value. It will be run in the | 
|  | 1193    * context in which it was created (ScriptCompiler::CompileBound or | 
|  | 1194    * UnboundScript::BindToGlobalContext()). | 
|  | 1195    */ | 
|  | 1196   Local<Value> Run(); | 
|  | 1197 | 
|  | 1198   /** | 
|  | 1199    * Returns the corresponding context-unbound script. | 
|  | 1200    */ | 
|  | 1201   Local<UnboundScript> GetUnboundScript(); | 
|  | 1202 | 
|  | 1203   // To be deprecated; use GetUnboundScript()->GetId(); | 
|  | 1204   int GetId() { | 
|  | 1205     return GetUnboundScript()->GetId(); | 
|  | 1206   } | 
|  | 1207 | 
|  | 1208   // Use GetUnboundScript()->GetId(); | 
|  | 1209   V8_DEPRECATED("Use GetUnboundScript()->GetId()", | 
|  | 1210                 Handle<Value> GetScriptName()) { | 
|  | 1211     return GetUnboundScript()->GetScriptName(); | 
|  | 1212   } | 
|  | 1213 | 
|  | 1214   /** | 
|  | 1215    * Returns zero based line number of the code_pos location in the script. | 
|  | 1216    * -1 will be returned if no information available. | 
|  | 1217    */ | 
|  | 1218   V8_DEPRECATED("Use GetUnboundScript()->GetLineNumber()", | 
|  | 1219                 int GetLineNumber(int code_pos)) { | 
|  | 1220     return GetUnboundScript()->GetLineNumber(code_pos); | 
|  | 1221   } | 
|  | 1222 }; | 
|  | 1223 | 
|  | 1224 | 
|  | 1225 /** | 
|  | 1226  * For compiling scripts. | 
|  | 1227  */ | 
|  | 1228 class V8_EXPORT ScriptCompiler { | 
|  | 1229  public: | 
|  | 1230   /** | 
|  | 1231    * Compilation data that the embedder can cache and pass back to speed up | 
|  | 1232    * future compilations. The data is produced if the CompilerOptions passed to | 
|  | 1233    * the compilation functions in ScriptCompiler contains produce_data_to_cache | 
|  | 1234    * = true. The data to cache can then can be retrieved from | 
|  | 1235    * UnboundScript. | 
|  | 1236    */ | 
|  | 1237   struct V8_EXPORT CachedData { | 
|  | 1238     CachedData() : data(NULL), length(0) {} | 
|  | 1239     // Caller keeps the ownership of data and guarantees that the data stays | 
|  | 1240     // alive long enough. | 
|  | 1241     CachedData(const uint8_t* data, int length) : data(data), length(length) {} | 
|  | 1242     // TODO(marja): Async compilation; add constructors which take a callback | 
|  | 1243     // which will be called when V8 no longer needs the data. | 
|  | 1244     const uint8_t* data; | 
|  | 1245     int length; | 
|  | 1246   }; | 
|  | 1247 | 
|  | 1248   /** | 
|  | 1249    * Source code which can be then compiled to a UnboundScript or | 
|  | 1250    * BoundScript. | 
|  | 1251    */ | 
|  | 1252   struct V8_EXPORT Source { | 
|  | 1253     Source(Local<String> source_string, const ScriptOrigin& origin, | 
|  | 1254            const CachedData& cached_data = CachedData()); | 
|  | 1255     Source(Local<String> source_string, | 
|  | 1256            const CachedData& cached_data = CachedData()); | 
|  | 1257 | 
|  | 1258     Local<String> source_string; | 
|  | 1259 | 
|  | 1260     // Origin information | 
|  | 1261     Handle<Value> resource_name; | 
|  | 1262     Handle<Integer> resource_line_offset; | 
|  | 1263     Handle<Integer> resource_column_offset; | 
|  | 1264     Handle<Boolean> resource_is_shared_cross_origin; | 
|  | 1265 | 
|  | 1266     // Cached data from previous compilation (if any). | 
|  | 1267     CachedData cached_data; | 
|  | 1268   }; | 
|  | 1269 | 
|  | 1270   enum CompileOptions { | 
|  | 1271     kNoCompileOptions, | 
|  | 1272     kProduceDataToCache = 1 << 0 | 
|  | 1273   }; | 
|  | 1274 | 
|  | 1275   /** | 
|  | 1276    * Compiles the specified script (context-independent). | 
|  | 1277    * | 
|  | 1278    * \param source Script source code. | 
|  | 1279    * \return Compiled script object (context independent; for running it must be | 
|  | 1280    *   bound to a context). | 
|  | 1281    */ | 
|  | 1282   static Local<UnboundScript> CompileUnbound( | 
|  | 1283       Isolate* isolate, const Source& source, | 
|  | 1284       CompileOptions options = kNoCompileOptions); | 
|  | 1285 | 
|  | 1286   /** | 
|  | 1287    * Compiles the specified script (bound to current context). | 
|  | 1288    * | 
|  | 1289    * \param source Script source code. | 
|  | 1290    * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile() | 
|  | 1291    *   using pre_data speeds compilation if it's done multiple times. | 
|  | 1292    *   Owned by caller, no references are kept when this function returns. | 
|  | 1293    * \return Compiled script object, bound to the context that was active | 
|  | 1294    *   when this function was called. When run it will always use this | 
|  | 1295    *   context. | 
|  | 1296    */ | 
|  | 1297   static Local<Script> Compile( | 
|  | 1298       Isolate* isolate, const Source& source, | 
|  | 1299       CompileOptions options = kNoCompileOptions); | 
|  | 1300 }; | 
|  | 1301 | 
|  | 1302 | 
| 1241 /** | 1303 /** | 
| 1242  * An error message. | 1304  * An error message. | 
| 1243  */ | 1305  */ | 
| 1244 class V8_EXPORT Message { | 1306 class V8_EXPORT Message { | 
| 1245  public: | 1307  public: | 
| 1246   Local<String> Get() const; | 1308   Local<String> Get() const; | 
| 1247   Local<String> GetSourceLine() const; | 1309   Local<String> GetSourceLine() const; | 
| 1248 | 1310 | 
| 1249   /** | 1311   /** | 
| 1250    * Returns the resource name for the script from where the function causing | 1312    * Returns the resource name for the script from where the function causing | 
| (...skipping 5446 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6697  */ | 6759  */ | 
| 6698 | 6760 | 
| 6699 | 6761 | 
| 6700 }  // namespace v8 | 6762 }  // namespace v8 | 
| 6701 | 6763 | 
| 6702 | 6764 | 
| 6703 #undef TYPE_CHECK | 6765 #undef TYPE_CHECK | 
| 6704 | 6766 | 
| 6705 | 6767 | 
| 6706 #endif  // V8_H_ | 6768 #endif  // V8_H_ | 
| OLD | NEW | 
|---|