Implement OP_CONCAT (no metamethod yet)

Sun, 21 Nov 2010 16:25:08 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Sun, 21 Nov 2010 16:25:08 +0000
changeset 101
f1247747f025
parent 100
d20586b6104c
child 102
7bf985fd9e03

Implement OP_CONCAT (no metamethod yet)

lvm.js file | annotate | diff | comparison | revisions
--- a/lvm.js	Sat Nov 20 15:19:42 2010 +0000
+++ b/lvm.js	Sun Nov 21 16:25:08 2010 +0000
@@ -14,6 +14,7 @@
 var OP_ADD = 12;
 var OP_SUB = 13;
 var OP_DIV = 15;
+var OP_CONCAT = 21;
 var OP_JMP = 22;
 var OP_EQ = 23;
 var OP_LT = 24;
@@ -571,6 +572,14 @@
 			case OP_JMP:
 				frame.pc+=INS_sBx(instruction);
 				break;
+			case OP_CONCAT:
+				var A = INS_A(instruction);
+				var B = INS_B(instruction);
+				var C = INS_C(instruction);
+				var values = [];
+				for(var i = B; i<=C; i++)
+					values.push(frame.reg[i].value);
+				frame.reg[A] = new LValue(this, "string", values.join());
 			case OP_ADD:
 				var RB = RK(frame, INS_B(instruction));
 				var RC = RK(frame, INS_C(instruction));

mercurial