12 #include "pol_global_config.h" 18 #ifndef BSCRIPT_BOBJECT_H 29 #include <format/format.h> 30 #include "../clib/refptr.h" 31 #include "../clib/spinlock.h" 52 #ifdef ESCRIPT_PROFILE 62 typedef std::map<std::string, profile_instr> escript_profile_map;
63 extern escript_profile_map EscriptProfileMap;
76 std::unique_ptr<BObjectRefVec>
Locals;
85 virtual size_t sizeEstimate()
const;
89 void seterror(
bool err );
104 bool AttachFunctionalityModules();
139 int getParams(
unsigned howMany );
143 int makeString(
unsigned param );
144 bool hasParams(
unsigned howmany )
const {
return ( fparams.size() >= howmany ); }
149 BObject* getParamObj(
unsigned param );
151 const String* getStringParam(
unsigned param );
152 const BLong* getLongParam(
unsigned param );
154 bool getStringParam(
unsigned param,
const String*& pstr );
155 bool getParam(
unsigned param,
int& value );
156 bool getParam(
unsigned param,
int& value,
int maxval );
157 bool getParam(
unsigned param,
int& value,
int minval,
int maxval );
158 bool getRealParam(
unsigned param,
double& value );
159 bool getObjArrayParam(
unsigned param,
ObjArray*& pobjarr );
161 bool getParam(
unsigned param,
unsigned& value );
163 bool getParam(
unsigned param,
unsigned short& value );
164 bool getParam(
unsigned param,
unsigned short& value,
unsigned short maxval );
165 bool getParam(
unsigned param,
unsigned short& value,
unsigned short minval,
166 unsigned short maxval );
168 bool getParam(
unsigned param,
short& value );
169 bool getParam(
unsigned param,
short& value,
short maxval );
170 bool getParam(
unsigned param,
short& value,
short minval,
short maxval );
172 void* getApplicPtrParam(
unsigned param,
const BApplicObjType* pointer_type );
176 const char* paramAsString(
unsigned param );
177 double paramAsDouble(
unsigned param );
178 int paramAsLong(
unsigned param );
181 int makeDouble(
unsigned param );
184 BObject* getParam(
unsigned param );
190 int getToken(
Token& token,
unsigned position );
194 int makeGlobal(
const Token& token );
195 void popParam(
const Token& token );
196 void popParamByRef(
const Token& token );
197 void getArg(
const Token& token );
220 void execFunc(
const Token& token );
248 void ins_set_member_consume(
const Instruction& ins );
252 void ins_set_member_id_consume(
const Instruction& ins );
253 void ins_set_member_id_consume_plusequal(
const Instruction& ins );
254 void ins_set_member_id_consume_minusequal(
const Instruction& ins );
255 void ins_set_member_id_consume_timesequal(
const Instruction& ins );
256 void ins_set_member_id_consume_divideequal(
const Instruction& ins );
257 void ins_set_member_id_consume_modulusequal(
const Instruction& ins );
259 void ins_assign_localvar(
const Instruction& ins );
260 void ins_assign_globalvar(
const Instruction& ins );
265 void ins_array_assign_consume(
const Instruction& ins );
266 void ins_multisubscript_assign(
const Instruction& ins );
267 void ins_multisubscript_assign_consume(
const Instruction& ins );
307 void ins_pop_param_byref(
const Instruction& ins );
318 void ins_dictionary_addmember(
const Instruction& ins );
320 void ins_addmember_assign(
const Instruction& ins );
334 static int ins_casejmp_findlong(
const Token& token,
BLong* blong );
335 static int ins_casejmp_findstring(
const Token& token,
String* bstringimp );
336 static int ins_casejmp_finddefault(
const Token& token );
338 bool running_to_completion()
const;
339 void set_running_to_completion(
bool to_completion );
341 bool runnable()
const;
345 void sethalt(
bool halt );
347 bool debugging()
const;
348 void setdebugging(
bool debugging );
350 void attach_debugger();
351 void detach_debugger();
352 std::string dbg_get_instruction(
size_t atPC )
const;
353 void dbg_ins_trace();
354 void dbg_step_into();
355 void dbg_step_over();
358 void dbg_setbp(
unsigned atPC );
359 void dbg_clrbp(
unsigned atPC );
364 void initForFnCall(
unsigned in_PC );
365 void show_context(
unsigned atPC );
366 void show_context( fmt::Writer& os,
unsigned atPC );
371 const std::string& scriptname()
const;
372 bool empty_scriptname();
395 DEBUG_STATE_STEPPING_OVER
407 #ifdef ESCRIPT_PROFILE 408 unsigned long GetTimeUs();
409 void profile_escript( std::string
name,
unsigned long profile_start );
420 return prog_->name.get().empty();
434 run_ok_ = !error_ && !halt_;
463 debugging_ = debugging;
469 return runs_to_completion_;
473 runs_to_completion_ = to_completion;
BObjectImp * func_result_
const EScriptProgram * prog() const
std::set< unsigned > breakpoints_
ValueStackCont ValueStack
void setDebugLevel(DEBUG_LEVEL level)
ValueStackCont ValueStack
void setdebugging(bool debugging)
std::vector< BObjectRef > ValueStackCont
std::vector< BObjectRef > BObjectRefVec
std::vector< ExecutorModule * > execmodules
void(Executor::* ExecInstrFunc)(const Instruction &)
std::set< unsigned > tmpbreakpoints_
std::vector< ReturnContext > ControlStack
std::vector< BObjectRef > fparams
std::vector< BObjectRefVec * > upperLocals2
ref_ptr< EScriptProgram > prog_
static UninitObject * m_SharedUninitObject
void list_script(UOExecutor *uoexec)
bool running_to_completion() const
const std::string & scriptname() const
bool hasParams(unsigned howmany) const
void setViewMode(bool vm)
static Clib::SpinLock _executor_lock
void set_running_to_completion(bool to_completion)
std::unique_ptr< BObjectRefVec > Locals
BApplicObj< T > * getApplicObjParam(ExecutorModule &ex, unsigned param, const BApplicObjType *object_type)
ModuleFunction * current_module_function
std::vector< ExecutorModule * > availmodules