Skip to content

Commit

Permalink
Fix evalCall subclass method index
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxiaomao committed Jun 17, 2024
1 parent 99476d8 commit 26d37b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 0 additions & 4 deletions hld/Eval.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1320,10 +1320,6 @@ class Eval {
if( f != null && ptr != null ) {
// HMethod
var vt = readPointer(ptr);
if( f.pindex >= 0 ) {
var vp = readPointer(vt.offset(align.ptr*2));
return AMethod(v, readPointer(vp.offset(f.index * align.ptr)), f.t);
}
var vobj = readPointer(vt.offset(align.ptr));
var vrt = readPointer(vobj.offset(4 * 2 + align.ptr + align.ptr * 7));
var vmethods = readPointer(vrt.offset(align.ptr + 4 * 6));
Expand Down
16 changes: 12 additions & 4 deletions hld/Module.hx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@ class Module {
var parent = o.tsuper == null ? null : switch( o.tsuper ) { case HObj(o), HStruct(o): getObjectProto(o,isStruct); default: throw "assert"; };
var size = parent == null ? (isStruct ? 0 : align.ptr) : parent.size;
var fields = parent == null ? new Map() : [for( k in parent.fields.keys() ) k => parent.fields.get(k)];
var methods = parent == null ? new Map() : [for( k in parent.methods.keys() ) k => parent.methods.get(k)];
var mindex = 0;
var methods = parent == null ? new Map() : [for( k => v in parent.methods ) k => {
mindex++;
v;
}];

for( f in o.fields ) {
var pad = f.t;
Expand Down Expand Up @@ -235,12 +239,16 @@ class Module {
}
}

var mindex = 0;
for( m in o.proto ) {
var idx = functionsIndexes.get(m.findex);
var f = code.functions[idx];
// todo : fix method index wrt subclasses & prototypes
methods.set(m.name, { t : f.t, index : mindex++, pindex : m.pindex });
// parent methods are placed before child
if( parent != null && m.pindex >= 0) {
var v = parent.methods.get(m.name);
methods.set(m.name, { t : f.t, index : v.index, pindex : m.pindex });
} else {
methods.set(m.name, { t : f.t, index : mindex++, pindex : m.pindex });
}
}

p = {
Expand Down

0 comments on commit 26d37b5

Please sign in to comment.