VALUE require_compiled(VALUE fname, VALUE* result) { VALUE path; char* szName = 0; // FilePathValue(fname); szName = RSTRING_PTR(fname); RAWTRACE1("require_compiled: %s", szName); rb_funcall(fname, rb_intern("sub!"), 2, rb_str_new2(".rb"), rb_str_new2("") ); if ( strcmp("strscan",szName)==0 || strcmp("enumerator",szName)==0 ) return Qtrue; path = find_file(fname); if ( path != 0 ) { VALUE seq; if ( isAlreadyLoaded(path) == Qtrue ) return Qtrue; rb_ary_push(GET_VM()->loaded_features, path); seq = loadISeqFromFile(path); //*result = rb_funcall(seq, rb_intern("eval"), 0 ); *result = rb_iseq_eval(seq); return Qtrue; } return Qnil; }
VALUE rb_f_eval_compiled(int argc, VALUE *argv, VALUE self) { VALUE scope, fname, iseqval; const char *file = 0; rb_scan_args(argc, argv, "11", &fname, &scope); iseqval = loadISeqFromFile(RhoPreparePath(fname)); return eval_string_with_cref( self, iseqval, scope, 0, file, 1 ); //return eval_iseq_with_scope(self, scope, iseqval ); }
VALUE require_compiled(VALUE fname, VALUE* result) { VALUE path; char* szName1 = 0; rb_funcall(fname, rb_intern("sub!"), 2, rb_str_new2(".rb"), rb_str_new2("") ); szName1 = RSTRING_PTR(fname); if ( strcmp("strscan",szName1)==0 || strcmp("enumerator",szName1)==0 || strcmp("stringio",szName1)==0 || strcmp("socket",szName1)==0 || strcmp("digest.so",szName1)==0 || strcmp("openssl.so",szName1)==0 || strcmp("fcntl",szName1)==0 || strcmp("digest/md5",szName1)==0 || strcmp("digest/sha1",szName1)==0 ) return Qtrue; if ( isAlreadyLoaded(fname) == Qtrue ) return Qtrue; //RAWLOG_INFO1("find_file: %s", RSTRING_PTR(fname)); path = find_file(fname); if ( path != 0 ) { VALUE seq; // if ( isAlreadyLoaded(path) == Qtrue ) // return Qtrue; RAWLOG_INFO1("require_compiled: %s", szName1); //optimize require //rb_ary_push(GET_VM()->loaded_features, path); rb_ary_push(GET_VM()->loaded_features, fname); rb_gc_disable(); seq = loadISeqFromFile(path); rb_gc_enable(); //*result = rb_funcall(seq, rb_intern("eval"), 0 ); *result = rb_iseq_eval(seq); return Qtrue; } RAWLOG_ERROR1("require_compiled: error: can not find %s", RSTRING_PTR(fname)); return Qnil; }
VALUE rb_f_eval_compiled(int argc, VALUE *argv, VALUE self) { VALUE scope, fname, iseqval, res; const char *file = 0; //rb_gc_disable(); rb_scan_args(argc, argv, "11", &fname, &scope); //RAWLOG_INFO1("eval_compiled: %s", RSTRING_PTR(fname)); iseqval = loadISeqFromFile(RhoPreparePath(fname)); res = eval_string_with_cref( self, iseqval, scope, 0, file, 1 ); //rb_gc_enable(); return res; //return eval_iseq_with_scope(self, scope, iseqval ); }
VALUE require_compiled(VALUE fname, VALUE* result, int bLoad) { VALUE path; char* szName1 = 0; VALUE retval = Qtrue; if (TYPE(fname) != T_STRING) rb_raise(rb_eLoadError, "can not load non-string"); szName1 = RSTRING_PTR(fname); if ( String_endsWith(szName1,".rb") ) { rb_str_chop_bang(fname); rb_str_chop_bang(fname); rb_str_chop_bang(fname); } //rb_funcall(fname, rb_intern("sub!"), 2, rb_str_new2(".rb"), rb_str_new2("") ); szName1 = RSTRING_PTR(fname); if ( strcmp("strscan",szName1)==0 || strcmp("enumerator",szName1)==0 || strcmp("stringio",szName1)==0 || strcmp("socket",szName1)==0 ) return Qtrue; RHO_LOCK(require_lock); if ( !bLoad && isAlreadyLoaded(fname) == Qtrue ) goto RCompExit; path = find_file(fname); if ( path != 0 ) { VALUE seq; RAWLOG_INFO1("require_compiled: %s", szName1); //optimize require //rb_ary_push(GET_VM()->loaded_features, path); rb_ary_push(GET_VM()->loaded_features, fname); #ifdef RHODES_EMULATOR if ( strstr( RSTRING_PTR(path), ".rb") == 0 ) rb_str_cat(path,".rb",3); GET_VM()->src_encoding_index = rb_utf8_encindex(); rb_load(path, 0); if( rho_simconf_getBool("reload_app_changes") ) { if ( strncmp( RSTRING_PTR(path), rho_native_rhopath(), strlen(rho_native_rhopath()) ) == 0 ) rb_ary_delete(GET_VM()->loaded_features, fname); } #else //rb_gc_disable(); seq = loadISeqFromFile(path); //*result = rb_funcall(seq, rb_intern("eval"), 0 ); *result = rb_iseq_eval(seq); //rb_gc_enable(); #endif goto RCompExit; } RAWLOG_ERROR1("require_compiled: error: can not find %s", RSTRING_PTR(fname)); retval = Qnil; RCompExit: RHO_UNLOCK(require_lock); return retval; }