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