porffor 0.33.2 → 0.34.0

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.
@@ -5772,7 +5772,6 @@ const generateMember = (scope, decl, _global, _name, _objectWasm = undefined) =>
5772
5772
 
5773
5773
  const generateClass = (scope, decl) => {
5774
5774
  const expr = decl.type === 'ClassExpression';
5775
- if (decl.superClass) return todo(scope, 'class extends is not supported yet', expr);
5776
5775
 
5777
5776
  const name = decl.id ? decl.id.name : `#anonymous${uniqId()}`;
5778
5777
  if (name == null) return todo(scope, 'unknown name for class', expr);
@@ -5782,6 +5781,16 @@ const generateClass = (scope, decl) => {
5782
5781
  type: 'Identifier',
5783
5782
  name
5784
5783
  };
5784
+ const proto = {
5785
+ type: 'MemberExpression',
5786
+ object: root,
5787
+ property: {
5788
+ type: 'Identifier',
5789
+ name: 'prototype'
5790
+ },
5791
+ computed: false,
5792
+ optional: false
5793
+ };
5785
5794
 
5786
5795
  const constr = body.find(x => x.kind === 'constructor')?.value ?? {
5787
5796
  type: 'FunctionExpression',
@@ -5799,22 +5808,39 @@ const generateClass = (scope, decl) => {
5799
5808
  type: expr ? 'FunctionExpression' : 'FunctionDeclaration'
5800
5809
  });
5801
5810
 
5811
+ if (decl.superClass) {
5812
+ out.push(
5813
+ ...generateCall(scope, {
5814
+ type: 'CallExpression',
5815
+ callee: {
5816
+ type: 'Identifier',
5817
+ name: '__Porffor_object_assignAll'
5818
+ },
5819
+ arguments: [
5820
+ proto,
5821
+ {
5822
+ type: 'MemberExpression',
5823
+ object: decl.superClass,
5824
+ property: {
5825
+ type: 'Identifier',
5826
+ name: 'prototype'
5827
+ },
5828
+ computed: false,
5829
+ optional: false
5830
+ }
5831
+ ]
5832
+ }),
5833
+ [ Opcodes.drop ]
5834
+ );
5835
+ }
5836
+
5802
5837
  for (const x of body) {
5803
5838
  let { type, key, value, kind, static: _static, computed } = x;
5804
5839
  if (type !== 'MethodDefinition' && type !== 'PropertyDefinition') return todo(scope, `class body type ${type} is not supported yet`, expr);
5805
5840
 
5806
5841
  if (kind === 'constructor') continue;
5807
5842
 
5808
- let object = _static ? root : {
5809
- type: 'MemberExpression',
5810
- object: root,
5811
- property: {
5812
- type: 'Identifier',
5813
- name: 'prototype'
5814
- },
5815
- computed: false,
5816
- optional: false
5817
- };
5843
+ let object = _static ? root : proto;
5818
5844
 
5819
5845
  let k = key;
5820
5846
  if (!computed && key.type !== 'Literal') k = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js",
4
- "version": "0.33.2+07307e244",
4
+ "version": "0.34.0+947ac1287",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/runner/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.33.2+07307e244';
3
+ globalThis.version = '0.34.0+947ac1287';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {