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 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 ~CachedData(); | 1113 ~CachedData(); |
1114 // TODO(marja): Async compilation; add constructors which take a callback | 1114 // TODO(marja): Async compilation; add constructors which take a callback |
1115 // which will be called when V8 no longer needs the data. | 1115 // which will be called when V8 no longer needs the data. |
1116 const uint8_t* data; | 1116 const uint8_t* data; |
1117 int length; | 1117 int length; |
1118 BufferPolicy buffer_policy; | 1118 BufferPolicy buffer_policy; |
1119 | 1119 |
1120 private: | 1120 private: |
1121 // Prevent copying. Not implemented. | 1121 // Prevent copying. Not implemented. |
1122 CachedData(const CachedData&); | 1122 CachedData(const CachedData&); |
| 1123 CachedData& operator=(const CachedData&); |
1123 }; | 1124 }; |
1124 | 1125 |
1125 /** | 1126 /** |
1126 * Source code which can be then compiled to a UnboundScript or | 1127 * Source code which can be then compiled to a UnboundScript or |
1127 * BoundScript. | 1128 * BoundScript. |
1128 */ | 1129 */ |
1129 class Source { | 1130 class Source { |
1130 public: | 1131 public: |
1131 // Source takes ownership of CachedData. | 1132 // Source takes ownership of CachedData. |
1132 Source(Local<String> source_string, const ScriptOrigin& origin, | 1133 V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin, |
1133 CachedData* cached_data = NULL); | 1134 CachedData* cached_data = NULL); |
1134 Source(Local<String> source_string, CachedData* cached_data = NULL); | 1135 V8_INLINE Source(Local<String> source_string, |
1135 ~Source(); | 1136 CachedData* cached_data = NULL); |
| 1137 V8_INLINE ~Source(); |
1136 | 1138 |
1137 // Ownership of the CachedData or its buffers is *not* transferred to the | 1139 // Ownership of the CachedData or its buffers is *not* transferred to the |
1138 // caller. The CachedData object is alive as long as the Source object is | 1140 // caller. The CachedData object is alive as long as the Source object is |
1139 // alive. | 1141 // alive. |
1140 const CachedData* GetCachedData() const; | 1142 V8_INLINE const CachedData* GetCachedData() const; |
1141 | 1143 |
1142 private: | 1144 private: |
1143 friend class ScriptCompiler; | 1145 friend class ScriptCompiler; |
1144 // Prevent copying. Not implemented. | 1146 // Prevent copying. Not implemented. |
1145 Source(const Source&); | 1147 Source(const Source&); |
| 1148 Source& operator=(const Source&); |
1146 | 1149 |
1147 Local<String> source_string; | 1150 Local<String> source_string; |
1148 | 1151 |
1149 // Origin information | 1152 // Origin information |
1150 Handle<Value> resource_name; | 1153 Handle<Value> resource_name; |
1151 Handle<Integer> resource_line_offset; | 1154 Handle<Integer> resource_line_offset; |
1152 Handle<Integer> resource_column_offset; | 1155 Handle<Integer> resource_column_offset; |
1153 Handle<Boolean> resource_is_shared_cross_origin; | 1156 Handle<Boolean> resource_is_shared_cross_origin; |
1154 | 1157 |
1155 // Cached data from previous compilation (if any), or generated during | 1158 // Cached data from previous compilation (if any), or generated during |
(...skipping 4910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6066 | 6069 |
6067 Handle<Integer> ScriptOrigin::ResourceColumnOffset() const { | 6070 Handle<Integer> ScriptOrigin::ResourceColumnOffset() const { |
6068 return resource_column_offset_; | 6071 return resource_column_offset_; |
6069 } | 6072 } |
6070 | 6073 |
6071 Handle<Boolean> ScriptOrigin::ResourceIsSharedCrossOrigin() const { | 6074 Handle<Boolean> ScriptOrigin::ResourceIsSharedCrossOrigin() const { |
6072 return resource_is_shared_cross_origin_; | 6075 return resource_is_shared_cross_origin_; |
6073 } | 6076 } |
6074 | 6077 |
6075 | 6078 |
| 6079 ScriptCompiler::Source::Source(Local<String> string, const ScriptOrigin& origin, |
| 6080 CachedData* data) |
| 6081 : source_string(string), |
| 6082 resource_name(origin.ResourceName()), |
| 6083 resource_line_offset(origin.ResourceLineOffset()), |
| 6084 resource_column_offset(origin.ResourceColumnOffset()), |
| 6085 resource_is_shared_cross_origin(origin.ResourceIsSharedCrossOrigin()), |
| 6086 cached_data(data) {} |
| 6087 |
| 6088 |
| 6089 ScriptCompiler::Source::Source(Local<String> string, |
| 6090 CachedData* data) |
| 6091 : source_string(string), cached_data(data) {} |
| 6092 |
| 6093 |
| 6094 ScriptCompiler::Source::~Source() { |
| 6095 delete cached_data; |
| 6096 } |
| 6097 |
| 6098 |
| 6099 const ScriptCompiler::CachedData* ScriptCompiler::Source::GetCachedData() |
| 6100 const { |
| 6101 return cached_data; |
| 6102 } |
| 6103 |
| 6104 |
6076 Handle<Boolean> Boolean::New(Isolate* isolate, bool value) { | 6105 Handle<Boolean> Boolean::New(Isolate* isolate, bool value) { |
6077 return value ? True(isolate) : False(isolate); | 6106 return value ? True(isolate) : False(isolate); |
6078 } | 6107 } |
6079 | 6108 |
6080 | 6109 |
6081 void Template::Set(Isolate* isolate, const char* name, v8::Handle<Data> value) { | 6110 void Template::Set(Isolate* isolate, const char* name, v8::Handle<Data> value) { |
6082 Set(v8::String::NewFromUtf8(isolate, name), value); | 6111 Set(v8::String::NewFromUtf8(isolate, name), value); |
6083 } | 6112 } |
6084 | 6113 |
6085 | 6114 |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6603 */ | 6632 */ |
6604 | 6633 |
6605 | 6634 |
6606 } // namespace v8 | 6635 } // namespace v8 |
6607 | 6636 |
6608 | 6637 |
6609 #undef TYPE_CHECK | 6638 #undef TYPE_CHECK |
6610 | 6639 |
6611 | 6640 |
6612 #endif // V8_H_ | 6641 #endif // V8_H_ |
OLD | NEW |