lvm.js

changeset 80
beb0bb936aca
parent 79
94c0441b7321
child 81
1deed5894ff6
equal deleted inserted replaced
79:94c0441b7321 80:beb0bb936aca
116 // Plain addition 116 // Plain addition
117 return this.vm.LValue(parseFloat(this.value, 10) + parseFloat(op2.value, 10)); 117 return this.vm.LValue(parseFloat(this.value, 10) + parseFloat(op2.value, 10));
118 } 118 }
119 else 119 else
120 throw "Attempt to perform arithmetic on a "+this.type+" and "+op2.type; 120 throw "Attempt to perform arithmetic on a "+this.type+" and "+op2.type;
121 },
122 equals: function (op2)
123 {
124 if(this.type != op2.type)
125 return false;
126 if(this.value == op2.value)
127 return true;
128 var __eq = this.vm.LValue("__eq");
129 if(this.metatable && op2.metatable)
130 {
131 var metamethod1 = this.metatable.index(__eq);
132 var metamethod2 = op2.metatable.index(__eq);
133 if(metamethod1.equals(metamethod2))
134 {
135 var result = metamethod1.call([this, op2]);
136 return (result[0].type != "nil"
137 && (result[0].type != "boolean" || result[0].value == true)
138 );
139 }
140 }
141 return false;
121 } 142 }
122 }; 143 };
123 144
124 function LBinaryChunk(vm, chunk, start) 145 function LBinaryChunk(vm, chunk, start)
125 { 146 {

mercurial