LEFT | RIGHT |
| 1 "use strict"; |
| 2 |
1 "Compiled from https://hg.adblockplus.org/adblockplus/ with Emscripten {{{EMSCRI
PTEN_VERSION}}}"; | 3 "Compiled from https://hg.adblockplus.org/adblockplus/ with Emscripten {{{EMSCRI
PTEN_VERSION}}}"; |
2 | 4 |
3 var sizeofString = 0; | |
4 var FilterNotifier = require("filterNotifier").FilterNotifier; | 5 var FilterNotifier = require("filterNotifier").FilterNotifier; |
5 | |
6 function createString(str) | |
7 { | |
8 var length = 0; | |
9 var buffer = 0; | |
10 if (str) | |
11 { | |
12 length = str.length; | |
13 buffer = Runtime.stackAlloc(length * 2); | |
14 for (var i = 0, pointer = (buffer >> 1); i < length; i++, pointer++) | |
15 HEAP16[pointer] = str.charCodeAt(i); | |
16 } | |
17 | |
18 if (!sizeofString) | |
19 sizeofString = Module._GetSizeofString(); | |
20 var result = Module.Runtime.stackAlloc(sizeofString); | |
21 Module._InitString(result, buffer, length); | |
22 return result; | |
23 } | |
24 | |
25 function getStringData(str) | |
26 { | |
27 var length = Module._GetStringLength(str); | |
28 var pointer = Module._GetStringData(str) >> 1; | |
29 return String.fromCharCode.apply(String, HEAP16.slice(pointer, pointer + lengt
h)); | |
30 } | |
31 | |
32 function convertGetter(call) | |
33 { | |
34 return function() | |
35 { | |
36 return call(this._pointer); | |
37 }; | |
38 } | |
39 | |
40 function convertSetter(call) | |
41 { | |
42 return function(value) | |
43 { | |
44 call(this._pointer, value); | |
45 } | |
46 } | |
47 | |
48 function convertMethod(call) | |
49 { | |
50 return function() | |
51 { | |
52 var params = Array.slice(arguments); | |
53 params.unshift(this._pointer); | |
54 return call.apply(this, params); | |
55 }; | |
56 } | |
57 | 6 |
58 var regexps = | 7 var regexps = |
59 { | 8 { |
60 _data: Object.create(null), | 9 _data: Object.create(null), |
61 _counter: 0, | 10 _counter: 0, |
62 | 11 |
63 create: function(source, matchCase) | 12 create: function(source, matchCase) |
64 { | 13 { |
65 var id = ++this._counter; | 14 var id = ++this._counter; |
66 try | 15 try |
67 { | 16 { |
68 this._data[id] = new RegExp(getStringData(source), matchCase ? "" : "i"); | 17 this._data[id] = new RegExp(readString(source), matchCase ? "" : "i"); |
| 18 return id; |
69 } | 19 } |
70 catch (e) | 20 catch (e) |
71 { | 21 { |
72 this._data[id] = String(e); | 22 return -1; |
73 } | 23 } |
74 return id; | |
75 }, | |
76 | |
77 getError: function(id) | |
78 { | |
79 if (typeof this._data[id] == "string") | |
80 return createString(this._data[id]); | |
81 else | |
82 return 0; | |
83 }, | 24 }, |
84 | 25 |
85 delete: function(id) | 26 delete: function(id) |
86 { | 27 { |
87 delete this._data[id]; | 28 delete this._data[id]; |
88 }, | 29 }, |
89 | 30 |
90 test: function(id, str) | 31 test: function(id, str) |
91 { | 32 { |
92 return this._data[id].test(getStringData(str)); | 33 return this._data[id].test(readString(str)); |
93 } | 34 } |
94 }; | 35 }; |
95 | 36 |
96 var Module = | 37 var Module = |
97 { | 38 { |
98 preRun: [], | 39 preRun: [], |
99 postRun: [], | 40 postRun: [], |
100 print: console.log.bind(console), | 41 print: console.log.bind(console), |
101 printErr: console.error.bind(console), | 42 printErr: console.error.bind(console), |
102 | 43 |
103 RegExpFilter_typeMap: {}, | 44 getMemoryLayout: function() |
104 | |
105 createClass: function(superclass) | |
106 { | 45 { |
107 var result = function(pointer) | 46 return { |
108 { | 47 'static_base': STATIC_BASE, |
109 this._pointer = pointer; | 48 'static_top': STATICTOP, |
| 49 'stack_base': STACK_BASE, |
| 50 'stack_top': STACKTOP, |
| 51 'stack_max': STACK_MAX, |
| 52 'dynamic_base': DYNAMIC_BASE, |
| 53 'dynamic_top': DYNAMICTOP, |
| 54 'total_memory': TOTAL_MEMORY |
110 }; | 55 }; |
111 if (superclass) | |
112 result.prototype = Object.create(superclass.prototype); | |
113 result.prototype.delete = function() | |
114 { | |
115 Module._DeletePointer(this._pointer); | |
116 }; | |
117 return result; | |
118 }, | |
119 | |
120 wrapCall: function(call) | |
121 { | |
122 return function() | |
123 { | |
124 var sp = Module.Runtime.stackSave(); | |
125 try | |
126 { | |
127 return call.apply(this, arguments); | |
128 } | |
129 catch (e) | |
130 { | |
131 throw typeof e == "number" ? new Error(Module.AsciiToString(Module._GetE
xception(e))) : e; | |
132 } | |
133 finally | |
134 { | |
135 Module.Runtime.stackRestore(sp); | |
136 } | |
137 }; | |
138 }, | |
139 | |
140 stringArg: function(argPos, call) | |
141 { | |
142 return function() | |
143 { | |
144 var params = Array.slice(arguments); | |
145 params[argPos] = createString(params[argPos]); | |
146 try | |
147 { | |
148 return call.apply(this, params); | |
149 } | |
150 finally | |
151 { | |
152 Module._DestroyString(params[argPos]); | |
153 } | |
154 }; | |
155 }, | |
156 | |
157 stringResult: function(call) | |
158 { | |
159 return function() | |
160 { | |
161 var params = Array.slice(arguments); | |
162 try | |
163 { | |
164 params.unshift(createString()); | |
165 call.apply(this, params); | |
166 return getStringData(params[0]); | |
167 } | |
168 finally | |
169 { | |
170 Module._DestroyString(params[0]); | |
171 } | |
172 }; | |
173 }, | |
174 | |
175 defineProperty: function(cls, name, getter, setter) | |
176 { | |
177 var descriptor = | |
178 { | |
179 enumerable: true, | |
180 get: Module.wrapCall(convertGetter(getter)) | |
181 }; | |
182 if (setter) | |
183 descriptor.set = Module.wrapCall(convertSetter(setter)); | |
184 Object.defineProperty(cls.prototype, name, descriptor); | |
185 }, | |
186 | |
187 defineStringProperty: function(cls, name, getter, setter) | |
188 { | |
189 Module.defineProperty(cls, name, Module.stringResult(getter), | |
190 (setter ? Module.stringArg(1, setter) : null)); | |
191 }, | |
192 | |
193 defineMethod: function(cls, name, method) | |
194 { | |
195 cls.prototype[name] = Module.wrapCall(convertMethod(method)); | |
196 } | 56 } |
197 }; | 57 }; |
198 var ENVIRONMENT_IS_WEB = false, ENVIRONMENT_IS_NODE = false, | 58 var ENVIRONMENT_IS_WEB = false, ENVIRONMENT_IS_NODE = false, |
199 ENVIRONMENT_IS_WORKER = false, ENVIRONMENT_IS_SHELL = true; | 59 ENVIRONMENT_IS_WORKER = false, ENVIRONMENT_IS_SHELL = true; |
200 | 60 |
201 {{BODY}} | 61 {{BODY}} |
202 | 62 |
203 Object.assign(exports, Module); | 63 Object.assign(exports, Module); |
LEFT | RIGHT |