📄 interp.cxx
字号:
return result;}CdlTransactionCdlInterpreterBody::get_transaction() const{ CYG_REPORT_FUNCNAMETYPE("CdlInterpreter::get_transaction", "result %p"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CdlTransaction result = transaction; CYG_REPORT_RETVAL(result); return result;}CdlLoadableCdlInterpreterBody::get_loadable() const{ CYG_REPORT_FUNCNAMETYPE("CdlInterpreter:get_loadable", "result %p"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CdlLoadable result = loadable; CYG_REPORT_RETVAL(result); return result;}CdlContainerCdlInterpreterBody::get_container() const{ CYG_REPORT_FUNCNAMETYPE("CdlInterpreter::get_container", "result %p"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CdlContainer result = container; CYG_REPORT_RETVAL(result); return result;}CdlNodeCdlInterpreterBody::get_node() const{ CYG_REPORT_FUNCNAMETYPE("CdlInterpreter::get_node", "result %p"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CdlNode result = node; CYG_REPORT_RETVAL(result); return result;}std::stringCdlInterpreterBody::get_context() const{ CYG_REPORT_FUNCNAME("CdlInterpreter::get_context"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CYG_REPORT_RETURN(); return context;}CdlDiagnosticFnPtrCdlInterpreterBody::get_error_fn_ptr() const{ CYG_REPORT_FUNCNAMETYPE("CdlInterpreter::get_error_fn_ptr", "result %p"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CdlDiagnosticFnPtr result = error_fn_ptr; CYG_REPORT_RETVAL(result); return result;}CdlDiagnosticFnPtrCdlInterpreterBody::get_warning_fn_ptr() const{ CYG_REPORT_FUNCNAMETYPE("CdlInterpreter::get_warning_fn_ptr", "result %p"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CdlDiagnosticFnPtr result = warning_fn_ptr; CYG_REPORT_RETVAL(result); return result;}voidCdlInterpreterBody::set_toplevel(CdlToplevel new_toplevel){ CYG_REPORT_FUNCNAME("CdlInterpreter::set_toplevel"); CYG_REPORT_FUNCARG2XV(this, new_toplevel); CYG_PRECONDITION_THISC(); CYG_PRECONDITION(0 == toplevel, "changing toplevels is not allowed"); CYG_PRECONDITION_CLASSC(new_toplevel); toplevel = new_toplevel; CYG_REPORT_RETURN();}voidCdlInterpreterBody::set_transaction(CdlTransaction new_transaction){ CYG_REPORT_FUNCNAME("CdlInterpreter::set_transaction"); CYG_REPORT_FUNCARG2XV(this, new_transaction); CYG_PRECONDITION_THISC(); CYG_PRECONDITION_ZERO_OR_CLASSC(new_transaction); transaction = new_transaction; CYG_REPORT_RETURN();}CdlContainerCdlInterpreterBody::push_container(CdlContainer new_container){ CYG_REPORT_FUNCNAMETYPE("CdlInterpreter::push_container", "result %p"); CYG_REPORT_FUNCARG2XV(this, new_container); CYG_PRECONDITION_THISC(); CYG_PRECONDITION_CLASSC(new_container); CdlContainer result = container; container = new_container; CYG_REPORT_RETVAL(result); return result;}voidCdlInterpreterBody::pop_container(CdlContainer old_container){ CYG_REPORT_FUNCNAME("CdlInterpreter::pop_container"); CYG_REPORT_FUNCARG2XV(this, old_container); CYG_PRECONDITION_THISC(); CYG_PRECONDITION_ZERO_OR_CLASSC(old_container); CYG_PRECONDITIONC(0 != container); container = old_container; CYG_REPORT_RETURN();}CdlNodeCdlInterpreterBody::push_node(CdlNode new_node){ CYG_REPORT_FUNCNAMETYPE("CdlInterpreter::push_node", "result %p"); CYG_REPORT_FUNCARG2XV(this, new_node); CYG_PRECONDITION_THISC(); CYG_PRECONDITION_CLASSC(new_node); CdlNode result = node; node = new_node; CYG_REPORT_RETVAL(result); return result;}voidCdlInterpreterBody::pop_node(CdlNode old_node){ CYG_REPORT_FUNCNAME("CdlInterpreter::pop_node"); CYG_REPORT_FUNCARG2XV(this, old_node); CYG_PRECONDITION_THISC(); CYG_PRECONDITIONC(0 != node); CYG_PRECONDITION_ZERO_OR_CLASSC(old_node); node = old_node; CYG_REPORT_RETURN();}std::stringCdlInterpreterBody::push_context(std::string new_context){ CYG_REPORT_FUNCNAME("CdlInterpreter::push_context"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CYG_PRECONDITIONC("" != new_context); std::string result = context; context = new_context; return result;}voidCdlInterpreterBody::pop_context(std::string old_context){ CYG_REPORT_FUNCNAME("CdlInterpreter::pop_context"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); CYG_PRECONDITIONC("" != context); context = old_context; CYG_REPORT_RETURN();}CdlDiagnosticFnPtrCdlInterpreterBody::push_error_fn_ptr(CdlDiagnosticFnPtr new_fn_ptr){ CYG_REPORT_FUNCNAMETYPE("CdlInterpreter::push_error_fn_ptr", "result %p"); CYG_REPORT_FUNCARG2XV(this, new_fn_ptr); CYG_PRECONDITION_THISC(); CYG_PRECONDITIONC(0 != new_fn_ptr); CdlDiagnosticFnPtr result = error_fn_ptr; error_fn_ptr = new_fn_ptr; CYG_REPORT_RETVAL(result); return result;}voidCdlInterpreterBody::pop_error_fn_ptr(CdlDiagnosticFnPtr old_fn_ptr){ CYG_REPORT_FUNCNAME("CdlInterpreter::pop_error_fn_ptr"); CYG_REPORT_FUNCARG2XV(this, old_fn_ptr); CYG_PRECONDITION_THISC(); CYG_PRECONDITIONC(0 != error_fn_ptr); error_fn_ptr = old_fn_ptr; CYG_REPORT_RETURN();}CdlDiagnosticFnPtrCdlInterpreterBody::push_warning_fn_ptr(CdlDiagnosticFnPtr new_fn_ptr){ CYG_REPORT_FUNCNAMETYPE("CdlInterpreter::push_warning_fn_ptr", "result %p"); CYG_REPORT_FUNCARG2XV(this, new_fn_ptr); CYG_PRECONDITION_THISC(); CYG_PRECONDITIONC(0 != new_fn_ptr); CdlDiagnosticFnPtr result = warning_fn_ptr; warning_fn_ptr = new_fn_ptr; CYG_REPORT_RETVAL(result); return result;}voidCdlInterpreterBody::pop_warning_fn_ptr(CdlDiagnosticFnPtr old_fn_ptr){ CYG_REPORT_FUNCNAME("CdlInterpreter::pop_warning_fn_ptr"); CYG_REPORT_FUNCARG2XV(this, old_fn_ptr); CYG_PRECONDITION_THISC(); CYG_PRECONDITIONC(0 != warning_fn_ptr); warning_fn_ptr = old_fn_ptr; CYG_REPORT_RETURN();}//}}}//{{{ CdlInterpreter:: get information // ----------------------------------------------------------------------------// Get hold of the underlying Tcl interpreter. This makes it easier to// use miscellaneous Tcl library facilities such as Tcl_SplitList()Tcl_Interp*CdlInterpreterBody::get_tcl_interpreter(void) const{ CYG_REPORT_FUNCNAMETYPE("CdlInterpreter::get_tcl_interpreter", "interpreter %p"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); Tcl_Interp* result = tcl_interp; CYG_REPORT_RETVAL(result); return result;}//}}}//{{{ CdlInterpreter:: eval() // ----------------------------------------------------------------------------// Evaluate a Cdl script held in a string. The result of this evaluation, // e.g. TCL_OK, is returned directly. The string result is made available// in an in-out parameter.//// According to the spec the underlying Tcl_Eval() routine needs to be able// to make temporary changes to the script, so the latter must be held in// writable memory. This requires a copy operation.intCdlInterpreterBody::eval(std::string script, std::string& str_result){ CYG_REPORT_FUNCNAMETYPE("CdInterpreter::eval", "result %d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); int result = TCL_OK; int size = script.size(); // Distinguish between results set by the Tcl interpreter and results // set by CDL-related commands running in that interpreter. cdl_result = false; if (size < 2048) { char buf[2048]; script.copy(buf, size, 0); buf[size] = '\0'; result = Tcl_Eval(tcl_interp, buf); } else { char* buf = static_cast<char*>(malloc(script.size() + 1)); if (0 == buf) { this->set_result(CdlParse::construct_diagnostic(this, "internal error", "", "Out of memory")); result = TCL_ERROR; } else { script.copy(buf, size, 0); buf[size] = '\0'; result = Tcl_Eval(tcl_interp, buf); free(buf); } } // The distinction between TCL_OK and TCL_RETURN is probably not worth // worrying about. if (TCL_RETURN == result) { result = TCL_OK; } // If we have an error condition that was raised by the Tcl // interpreter rather than by the library, it needs to be // raised up to the library level. That way the error count // etc. are kept accurate. if ((TCL_OK != result) && !cdl_result) { char* tcl_result = Tcl_GetStringResult(tcl_interp); if ((0 == tcl_result) || ('\0' == tcl_result[0])) { tcl_result = "Internal error, no additional information available."; } CdlParse::report_error(this, "", tcl_result); } str_result = Tcl_GetStringResult(tcl_interp); CYG_REPORT_RETVAL(result); return result;}// Ditto for Tcl Code that comes from a CDL file. Currently this is held// as a string. In future it may be appropriate to store a byte-compiled// version as well.intCdlInterpreterBody::eval_cdl_code(const cdl_tcl_code script, std::string& str_result){ CYG_REPORT_FUNCNAMETYPE("CdInterpreter::eval_cdl_code", "result %d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); int result = TCL_OK; int size = script.size(); // Distinguish between results set by the Tcl interpreter and results // set by CDL-related commands running in that interpreter. cdl_result = false; if (size < 2048) { char buf[2048]; script.copy(buf, size, 0); buf[size] = '\0'; result = Tcl_Eval(tcl_interp, buf); } else { char* buf = static_cast<char*>(malloc(script.size() + 1)); if (0 == buf) { this->set_result(CdlParse::construct_diagnostic(this, "internal error", "", "Out of memory")); result = TCL_ERROR; } else { script.copy(buf, size, 0); buf[size] = '\0'; result = Tcl_Eval(tcl_interp, buf); free(buf); } } // The distinction between TCL_OK and TCL_RETURN is probably not worth // worrying about. if (TCL_RETURN == result) { result = TCL_OK;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -