lvm.js

changeset 13
f259da6951e8
parent 12
7d748aba47ab
child 14
21a2fce50931
equal deleted inserted replaced
12:7d748aba47ab 13:f259da6951e8
54 function LValueFromFunction(func) 54 function LValueFromFunction(func)
55 { 55 {
56 return new LValue("function", func); 56 return new LValue("function", func);
57 } 57 }
58 58
59 function LBinaryChunk(chunk) 59 function LBinaryChunk(chunk, start)
60 { 60 {
61 this.chunk = chunk; 61 this.chunk = chunk;
62 this.pos = 12; 62 this.pos = start||12;
63 63
64 this.sourceName = this.readString(); 64 this.sourceName = this.readString();
65 this.lineDefined = this.readInt(); 65 this.lineDefined = this.readInt();
66 this.lastLineDefined = this.readInt(); 66 this.lastLineDefined = this.readInt();
67 this.numUpvalues = this.readByte(); 67 this.numUpvalues = this.readByte();
109 this.constants.push(LValueFromString(this.readString())); 109 this.constants.push(LValueFromString(this.readString()));
110 break; 110 break;
111 default: 111 default:
112 throw "Invalid constant type "+type+" in bytecode"; 112 throw "Invalid constant type "+type+" in bytecode";
113 } 113 }
114 }
115
116 this.prototypes = [];
117
118 this.numPrototypes = this.readInt();
119 for(var i=0;i<this.numPrototypes;i++)
120 {
121 var p = new LBinaryChunk(chunk, this.pos);
122 this.pos = p.pos;
123 this.prototypes.push(p);
124 }
125
126 this.sourceLines = [];
127
128 this.numSourceLines = this.readInt();
129 for(var i=0;i<this.numSourceLines;i++)
130 {
131 this.sourceLines.push(this.readInt());
132 }
133
134 this.localList = [];
135 this.numLocalList = this.readInt();
136 for(var i=0;i<this.numLocalList;i++)
137 {
138 this.localList.push([this.readString(),this.readInt(),this.readInt()]);
139 }
140
141 this.upvalueList = [];
142 this.numUpvalueList = this.readInt();
143 for(var i=0;i<this.numUpvalueList;i++)
144 {
145 this.upvalueList.push(this.readString());
114 } 146 }
115 147
116 return this; 148 return this;
117 } 149 }
118 150

mercurial