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 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 public: | 1004 public: |
1005 /** | 1005 /** |
1006 * Compiles the specified script (context-independent). | 1006 * Compiles the specified script (context-independent). |
1007 * | 1007 * |
1008 * \param source Script source code. | 1008 * \param source Script source code. |
1009 * \param origin Script origin, owned by caller, no references are kept | 1009 * \param origin Script origin, owned by caller, no references are kept |
1010 * when New() returns | 1010 * when New() returns |
1011 * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile() | 1011 * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile() |
1012 * using pre_data speeds compilation if it's done multiple times. | 1012 * using pre_data speeds compilation if it's done multiple times. |
1013 * Owned by caller, no references are kept when New() returns. | 1013 * Owned by caller, no references are kept when New() returns. |
1014 * \param script_data Arbitrary data associated with script. Using | |
1015 * this has same effect as calling SetData(), but allows data to be | |
1016 * available to compile event handlers. | |
1017 * \return Compiled script object (context independent; when run it | 1014 * \return Compiled script object (context independent; when run it |
1018 * will use the currently entered context). | 1015 * will use the currently entered context). |
1019 */ | 1016 */ |
1020 static Local<Script> New(Handle<String> source, | 1017 static Local<Script> New(Handle<String> source, |
1021 ScriptOrigin* origin = NULL, | 1018 ScriptOrigin* origin = NULL, |
1022 ScriptData* pre_data = NULL, | 1019 ScriptData* pre_data = NULL); |
1023 Handle<String> script_data = Handle<String>()); | |
1024 | 1020 |
1025 /** | 1021 /** |
1026 * Compiles the specified script using the specified file name | 1022 * Compiles the specified script using the specified file name |
1027 * object (typically a string) as the script's origin. | 1023 * object (typically a string) as the script's origin. |
1028 * | 1024 * |
1029 * \param source Script source code. | 1025 * \param source Script source code. |
1030 * \param file_name file name object (typically a string) to be used | 1026 * \param file_name file name object (typically a string) to be used |
1031 * as the script's origin. | 1027 * as the script's origin. |
1032 * \return Compiled script object (context independent; when run it | 1028 * \return Compiled script object (context independent; when run it |
1033 * will use the currently entered context). | 1029 * will use the currently entered context). |
1034 */ | 1030 */ |
1035 static Local<Script> New(Handle<String> source, | 1031 static Local<Script> New(Handle<String> source, |
1036 Handle<Value> file_name); | 1032 Handle<Value> file_name); |
1037 | 1033 |
1038 /** | 1034 /** |
1039 * Compiles the specified script (bound to current context). | 1035 * Compiles the specified script (bound to current context). |
1040 * | 1036 * |
1041 * \param source Script source code. | 1037 * \param source Script source code. |
1042 * \param origin Script origin, owned by caller, no references are kept | 1038 * \param origin Script origin, owned by caller, no references are kept |
1043 * when Compile() returns | 1039 * when Compile() returns |
1044 * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile() | 1040 * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile() |
1045 * using pre_data speeds compilation if it's done multiple times. | 1041 * using pre_data speeds compilation if it's done multiple times. |
1046 * Owned by caller, no references are kept when Compile() returns. | 1042 * Owned by caller, no references are kept when Compile() returns. |
1047 * \param script_data Arbitrary data associated with script. Using | |
1048 * this has same effect as calling SetData(), but makes data available | |
1049 * earlier (i.e. to compile event handlers). | |
1050 * \return Compiled script object, bound to the context that was active | 1043 * \return Compiled script object, bound to the context that was active |
1051 * when this function was called. When run it will always use this | 1044 * when this function was called. When run it will always use this |
1052 * context. | 1045 * context. |
1053 */ | 1046 */ |
1054 static Local<Script> Compile(Handle<String> source, | 1047 static Local<Script> Compile(Handle<String> source, |
1055 ScriptOrigin* origin = NULL, | 1048 ScriptOrigin* origin = NULL, |
1056 ScriptData* pre_data = NULL, | 1049 ScriptData* pre_data = NULL); |
1057 Handle<String> script_data = Handle<String>()); | |
1058 | 1050 |
1059 /** | 1051 /** |
1060 * Compiles the specified script using the specified file name | 1052 * Compiles the specified script using the specified file name |
1061 * object (typically a string) as the script's origin. | 1053 * object (typically a string) as the script's origin. |
1062 * | 1054 * |
1063 * \param source Script source code. | 1055 * \param source Script source code. |
1064 * \param file_name File name to use as script's origin | 1056 * \param file_name File name to use as script's origin |
1065 * \param script_data Arbitrary data associated with script. Using | |
1066 * this has same effect as calling SetData(), but makes data available | |
1067 * earlier (i.e. to compile event handlers). | |
1068 * \return Compiled script object, bound to the context that was active | 1057 * \return Compiled script object, bound to the context that was active |
1069 * when this function was called. When run it will always use this | 1058 * when this function was called. When run it will always use this |
1070 * context. | 1059 * context. |
1071 */ | 1060 */ |
1072 static Local<Script> Compile(Handle<String> source, | 1061 static Local<Script> Compile(Handle<String> source, |
1073 Handle<Value> file_name, | 1062 Handle<Value> file_name); |
1074 Handle<String> script_data = Handle<String>()); | |
1075 | 1063 |
1076 /** | 1064 /** |
1077 * Runs the script returning the resulting value. If the script is | 1065 * Runs the script returning the resulting value. If the script is |
1078 * context independent (created using ::New) it will be run in the | 1066 * context independent (created using ::New) it will be run in the |
1079 * currently entered context. If it is context specific (created | 1067 * currently entered context. If it is context specific (created |
1080 * using ::Compile) it will be run in the context in which it was | 1068 * using ::Compile) it will be run in the context in which it was |
1081 * compiled. | 1069 * compiled. |
1082 */ | 1070 */ |
1083 Local<Value> Run(); | 1071 Local<Value> Run(); |
1084 | 1072 |
1085 /** | 1073 /** |
1086 * Returns the script id. | 1074 * Returns the script id. |
1087 */ | 1075 */ |
1088 int GetId(); | 1076 int GetId(); |
1089 | 1077 |
1090 /** | 1078 /** |
1091 * Associate an additional data object with the script. This is mainly used | |
1092 * with the debugger as this data object is only available through the | |
1093 * debugger API. | |
1094 */ | |
1095 void SetData(Handle<String> data); | |
1096 | |
1097 /** | |
1098 * Returns the name value of one Script. | 1079 * Returns the name value of one Script. |
1099 */ | 1080 */ |
1100 Handle<Value> GetScriptName(); | 1081 Handle<Value> GetScriptName(); |
1101 | 1082 |
1102 /** | 1083 /** |
1103 * Returns zero based line number of the code_pos location in the script. | 1084 * Returns zero based line number of the code_pos location in the script. |
1104 * -1 will be returned if no information available. | 1085 * -1 will be returned if no information available. |
1105 */ | 1086 */ |
1106 int GetLineNumber(int code_pos); | 1087 int GetLineNumber(int code_pos); |
1107 | 1088 |
(...skipping 5347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6455 */ | 6436 */ |
6456 | 6437 |
6457 | 6438 |
6458 } // namespace v8 | 6439 } // namespace v8 |
6459 | 6440 |
6460 | 6441 |
6461 #undef TYPE_CHECK | 6442 #undef TYPE_CHECK |
6462 | 6443 |
6463 | 6444 |
6464 #endif // V8_H_ | 6445 #endif // V8_H_ |
OLD | NEW |