Browse Source

handle bytecode version 3

Nicolas Cannasse 7 years ago
parent
commit
88da00aecc
1 changed files with 12 additions and 2 deletions
  1. 12 2
      src/code.c

+ 12 - 2
src/code.c

@@ -432,7 +432,7 @@ hl_code *hl_code_read( const unsigned char *data, int size ) {
 		EXIT("Invalid header");
 	r->code = c;
 	c->version = READ();
-	if( c->version <= 1 || c->version > 2 ) {
+	if( c->version <= 1 || c->version > 3 ) {
 		printf("VER=%d\n",c->version);
 		EXIT("Unsupported bytecode version");
 	}
@@ -485,8 +485,18 @@ hl_code *hl_code_read( const unsigned char *data, int size ) {
 	for(i=0;i<c->nfunctions;i++) {
 		hl_read_function(r,c->functions+i);
 		CHK_ERROR();
-		if( c->hasdebug )
+		if( c->hasdebug ) {
 			c->functions[i].debug = hl_read_debug_infos(r,c->functions[i].nops);
+			if( c->version >= 3 ) {
+				// skip assigns (no need here)
+				int nassigns = UINDEX();
+				int j;
+				for(j=0;j<nassigns;j++) {
+					UINDEX();
+					INDEX();
+				}
+			}
+		}
 	}
 	CHK_ERROR();
 	return c;