Wed, 07 Apr 2010 02:46:56 +0100
Support for reading all fields in the chunk (including function prototypes, required for OP_CLOSURE)
lvm.js | file | annotate | diff | comparison | revisions |
--- a/lvm.js Tue Apr 06 19:27:28 2010 +0100 +++ b/lvm.js Wed Apr 07 02:46:56 2010 +0100 @@ -56,10 +56,10 @@ return new LValue("function", func); } -function LBinaryChunk(chunk) +function LBinaryChunk(chunk, start) { this.chunk = chunk; - this.pos = 12; + this.pos = start||12; this.sourceName = this.readString(); this.lineDefined = this.readInt(); @@ -113,6 +113,38 @@ } } + this.prototypes = []; + + this.numPrototypes = this.readInt(); + for(var i=0;i<this.numPrototypes;i++) + { + var p = new LBinaryChunk(chunk, this.pos); + this.pos = p.pos; + this.prototypes.push(p); + } + + this.sourceLines = []; + + this.numSourceLines = this.readInt(); + for(var i=0;i<this.numSourceLines;i++) + { + this.sourceLines.push(this.readInt()); + } + + this.localList = []; + this.numLocalList = this.readInt(); + for(var i=0;i<this.numLocalList;i++) + { + this.localList.push([this.readString(),this.readInt(),this.readInt()]); + } + + this.upvalueList = []; + this.numUpvalueList = this.readInt(); + for(var i=0;i<this.numUpvalueList;i++) + { + this.upvalueList.push(this.readString()); + } + return this; }