Merge pull request #15126 from s-hadinger/berry_bec_fixed

Berry fixed pre-compiled .bec files for static methods
This commit is contained in:
s-hadinger 2022-03-13 19:14:52 +01:00 committed by GitHub
commit 587af1c69e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

View File

@ -23,7 +23,7 @@
#define MAGIC_NUMBER1 0xBE
#define MAGIC_NUMBER2 0xCD
#define MAGIC_NUMBER3 0xFE
#define BYTECODE_VERSION 3
#define BYTECODE_VERSION 4
#define USE_64BIT_INT (BE_INTGER_TYPE == 2 \
|| BE_INTGER_TYPE == 1 && LONG_MAX == 9223372036854775807L)
@ -333,7 +333,6 @@ static int load_head(void *fp)
res = buffer[0] == MAGIC_NUMBER1 &&
buffer[1] == MAGIC_NUMBER2 &&
buffer[2] == MAGIC_NUMBER3 &&
buffer[3] <= BYTECODE_VERSION &&
buffer[4] == vm_sizeinfo();
if (res) {
return buffer[3];
@ -425,7 +424,8 @@ static void load_class(bvm *vm, void *fp, bvalue *v, int version)
be_incrtop(vm);
if (load_proto(vm, fp, (bproto**)&var_toobj(value), -3, version)) {
/* actual method */
be_class_method_bind(vm, c, name, var_toobj(value), bfalse);
bbool is_method = ((bproto*)var_toobj(value))->varg & BE_VA_METHOD;
be_class_method_bind(vm, c, name, var_toobj(value), !is_method);
} else {
/* no proto, static member set to nil */
be_class_member_bind(vm, c, name, bfalse);
@ -572,7 +572,7 @@ bclosure* be_bytecode_load(bvm *vm, const char *filename)
"can not open file '%s'.", filename));
} else {
int version = load_head(fp);
if (version) {
if (version == BYTECODE_VERSION) {
bclosure *cl = be_newclosure(vm, 0);
var_setclosure(vm->top, cl);
be_stackpush(vm);
@ -582,6 +582,8 @@ bclosure* be_bytecode_load(bvm *vm, const char *filename)
be_fclose(fp);
return cl;
}
bytecode_error(vm, be_pushfstring(vm,
"invalid bytecode version '%s'.", filename));
}
bytecode_error(vm, be_pushfstring(vm,
"invalid bytecode file '%s'.", filename));

View File

@ -21,7 +21,7 @@ bytecode_file: -- little endian
header: 8
magic_number: 3 -- 0xbecdfe (berry code file)
version: 2 -- update with file structure definition
version: 1 -- 0x03 update with file structure definition
integer_size: .1
float_size: .1
-- reserved space

Binary file not shown.