X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FLibraries%2Flibspiderscript.so_src%2Fbytecode_makefile.c;fp=Usermode%2FLibraries%2Flibspiderscript.so_src%2Fbytecode_makefile.c;h=e2b5547573e95040067097158e9c0398ef3bfda1;hb=239f2374299c1471a40b1087725b32f3f163d9b3;hp=033f8d72ec209e186884aebeedbb867838e46ce4;hpb=2c8989ea0849b0e207e6c357626d41c991dc423f;p=tpg%2Facess2.git diff --git a/Usermode/Libraries/libspiderscript.so_src/bytecode_makefile.c b/Usermode/Libraries/libspiderscript.so_src/bytecode_makefile.c index 033f8d72..e2b55475 100644 --- a/Usermode/Libraries/libspiderscript.so_src/bytecode_makefile.c +++ b/Usermode/Libraries/libspiderscript.so_src/bytecode_makefile.c @@ -21,11 +21,12 @@ int Bytecode_ConvertScript(tSpiderScript *Script, const char *DestFile) { tStringList strings = {0}; - tAST_Function *fcn; + tScript_Function *fcn; FILE *fp; int fcn_hdr_offset = 0; int fcn_count = 0; int strtab_ofs; + int i; void _put8(uint8_t val) { @@ -52,12 +53,11 @@ int Bytecode_ConvertScript(tSpiderScript *Script, const char *DestFile) fcn_hdr_offset = ftell(fp); // Create function descriptors - for(fcn = Script->Script->Functions; fcn; fcn = fcn->Next, fcn_count ++) + for(fcn = Script->Functions; fcn; fcn = fcn->Next, fcn_count ++) { - tAST_Node *arg; - _put32( StringList_GetString(&strings, fcn->Name, strlen(fcn->Name)) ); _put32( 0 ); // Code offset + // TODO: _put8( fcn->ReturnType ); if(fcn->ArgumentCount > 255) { @@ -67,19 +67,18 @@ int Bytecode_ConvertScript(tSpiderScript *Script, const char *DestFile) _put8( fcn->ArgumentCount ); // Argument types? - for(arg = fcn->Arguments; arg; arg = arg->NextSibling) + for( i = 0; i < fcn->ArgumentCount; i ++ ) { - _put32( StringList_GetString(&strings, arg->DefVar.Name, strlen(arg->DefVar.Name)) ); - _put8( arg->DefVar.DataType ); + _put32( StringList_GetString(&strings, fcn->Arguments[i].Name, strlen(fcn->Arguments[i].Name)) ); + _put8( fcn->Arguments[i].Type ); } } // Put function code in - for(fcn = Script->Script->Functions; fcn; fcn = fcn->Next) + for(fcn = Script->Functions; fcn; fcn = fcn->Next) { char *code; int len, code_pos; - tBC_Function *bc_fcn; // Fix header code_pos = ftell(fp); @@ -90,9 +89,8 @@ int Bytecode_ConvertScript(tSpiderScript *Script, const char *DestFile) fcn_hdr_offset += 4+4+1+1+(4+1)*fcn->ArgumentCount; // Write code - bc_fcn = Bytecode_ConvertFunction(fcn); - code = Bytecode_SerialiseFunction(bc_fcn, &len, &strings); - Bytecode_DeleteFunction(bc_fcn); + if( !fcn->BCFcn ) Bytecode_ConvertFunction(fcn); + code = Bytecode_SerialiseFunction(fcn->BCFcn, &len, &strings); fwrite(code, len, 1, fp); free(code); }