porffor 0.35.2 → 0.35.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/builtins/object.ts +26 -2
- package/compiler/builtins_precompiled.js +25 -20
- package/compiler/codegen.js +30 -20
- package/package.json +1 -1
- package/runner/index.js +1 -1
@@ -193,8 +193,7 @@ export const __Porffor_object_in = (obj: any, prop: any) => {
|
|
193
193
|
return true;
|
194
194
|
}
|
195
195
|
|
196
|
-
|
197
|
-
if (t != Porffor.TYPES.object) {
|
196
|
+
if (Porffor.rawType(obj) != Porffor.TYPES.object) {
|
198
197
|
return false;
|
199
198
|
}
|
200
199
|
|
@@ -206,6 +205,31 @@ export const __Porffor_object_in = (obj: any, prop: any) => {
|
|
206
205
|
|
207
206
|
if (__Object_prototype_hasOwnProperty(obj, prop)) return true;
|
208
207
|
}
|
208
|
+
|
209
|
+
return false;
|
210
|
+
};
|
211
|
+
|
212
|
+
export const __Porffor_object_instanceof = (obj: any, constr: any) => {
|
213
|
+
if (Porffor.rawType(constr) != Porffor.TYPES.function) {
|
214
|
+
throw new TypeError('instanceof right-hand side is not a function');
|
215
|
+
}
|
216
|
+
|
217
|
+
const checkProto: any = constr.prototype;
|
218
|
+
if (!Porffor.object.isObject(checkProto)) {
|
219
|
+
throw new TypeError('instanceof right-hand side has non-object prototype');
|
220
|
+
}
|
221
|
+
|
222
|
+
let lastProto = obj;
|
223
|
+
while (true) {
|
224
|
+
obj = obj.__proto__;
|
225
|
+
if (Porffor.fastOr(obj == null, Porffor.wasm`local.get ${obj}` == Porffor.wasm`local.get ${lastProto}`)) break;
|
226
|
+
lastProto = obj;
|
227
|
+
|
228
|
+
console.log(obj === Object.prototype);
|
229
|
+
if (obj === checkProto) return true;
|
230
|
+
}
|
231
|
+
|
232
|
+
return false;
|
209
233
|
};
|
210
234
|
|
211
235
|
|