void execute(void) { if ((output.error == qdb_e_uninitialized) && (_execute)) { _execute(this); } }
virtual int step(const Variant** p_inputs,Variant** p_outputs,StartMode p_start_mode,Variant* p_working_mem,Variant::CallError& r_error,String& r_error_str) { if (!expression->root || expression->error_set) { r_error_str=expression->error_str; r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD; return 0; } bool error = _execute(p_inputs,expression->root,*p_outputs[0],r_error_str,r_error); if (error && r_error.error==Variant::CallError::CALL_OK) { r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD; } #ifdef DEBUG_ENABLED if (!error && expression->output_type!=Variant::NIL && !Variant::can_convert_strict(p_outputs[0]->get_type(),expression->output_type)) { r_error_str+="Can't convert expression result from "+Variant::get_type_name(p_outputs[0]->get_type())+" to "+Variant::get_type_name(expression->output_type)+"."; r_error.error=Variant::CallError::CALL_ERROR_INVALID_METHOD; } #endif return 0; }
static void _execute_failing(const gchar *testcase, Checks checks, const gchar *user_data) { if (_execute(testcase, checks, user_data)) { _log_error("expected the subject to fail, but it succeeded"); _tests_failed = 1; } }
static void _execute_correct(const gchar *testcase, Checks checks, const gchar *user_data) { if (!_execute(testcase, checks, user_data)) { _log_error("expected the subject to succeed, but it failed"); _tests_failed = 1; } }
boolean MatrixCharlieplex::_reset() { _exeDDRDn[0] = _ioDDR[0]; _exeDDRDn[1] = _ioDDR[1]; _exeDDRUp[0] = MXCHARLIE_UPMASK; _exeDDRUp[1] = MXCHARLIE_UPMASK; _exePORTDn[0] = _ioPORT[0]; _exePORTDn[1] = _ioPORT[1]; _exePORTUp[0] = MXCHARLIE_UPMASK; _exePORTUp[1] = MXCHARLIE_UPMASK; return _execute(); }
int shell_loop(char * line, char cmd[255][255]) { _setup(cmd); _prompt(); if(_read(line)){ _parse(line, cmd); if (exec) _execute(cmd); } else { run = 0; } return 0; }
uint32 IDbConnection::execute(const String &sql) { try { return _execute(sql); } catch(std::exception &e) { logError(sql, e); throw(e); return 0; } }
int etime(char args[][ACOLS]) { char nested_args[255][ACOLS]; struct timeval start, end; margc--; for (int i = 0; i < ACOLS - 1; i++) { strcpy(nested_args[i], args[i+1]); } gettimeofday(&start, NULL); _execute(nested_args); gettimeofday(&end, NULL); float elapsed_time = ((end.tv_sec + (end.tv_usec / 1000000.0)) - (start.tv_sec + (start.tv_usec / 1000000.0))); printf("Elapsed Time: %.6fs\n", elapsed_time); return 0; }
inline void Vm::_executeThread(const Instruction* const base, ThreadList::iterator t, const byte* const cur, const uint64_t offset) { #ifdef LBT_TRACE_ENABLED pre_run_thread_json(std::clog, offset, *t, base); #endif _execute(base, t, cur); #ifdef LBT_TRACE_ENABLED post_run_thread_json(std::clog, offset, *t, base); #endif if (_executeEpSequence<10>(base, t, offset)) { if (t->PC->OpCode != FINISH_OP) { _markSeen(t->Label); } _markLive(t->Label); Next.push_back(*t); } }
bool Command::cycle() { bool finished = false; if (!initialized) { initialize(); _initialize(); initialized = true; } else if (isFinished()) { finished = true; end(); _end(); } else { execute(); _execute(); } return finished; }
Variant Expression::execute(Array p_inputs, Object *p_base, bool p_show_error) { if (error_set) { ERR_EXPLAIN("There was previously a parse error: " + error_str); ERR_FAIL_V(Variant()); } execution_error = false; Variant output; String error_txt; bool err = _execute(p_inputs, p_base, root, output, error_txt); if (err) { execution_error = true; error_str = error_txt; if (p_show_error) { ERR_EXPLAIN(error_str); ERR_FAIL_V(Variant()); } } return output; }
int compute_limits(char args[][ACOLS]) { char nested_args[255][ACOLS]; margc--; for (int i = 0; i < margc; i++) { strcpy(nested_args[i], args[i+1]); } pid_t childpid = fork(); char print_buf[400]; if (childpid == 0) { pid_t pid = getpid(); char proc[50]; sprintf(proc, "/proc/%ld/limits", (long)pid); FILE * limits = fopen(proc, "r"); if (limits != NULL) { char line[255]; while (fgets(line, 255, limits) != NULL) { if (strstr(line, "Max file size")) sprintf(print_buf, "%s", line); else if (strstr(line, "Max open files")) sprintf(print_buf + strlen(print_buf), "%s", line); else if (strstr(line, "Max processes")) sprintf(print_buf + strlen(print_buf), "%s", line); else if (strstr(line, "Max pending signals")) sprintf(print_buf + strlen(print_buf), "%s", line); } } fclose(limits); _execute(nested_args); printf("%s", print_buf); } return 0; }
boolean MatrixCharlieplex::_setNode(DiodeNode pin, uint8_t state) { if (state & HIGH) { // uint8_t _chkMatch = 0; // // if (_activeNode.vcc == pin.vcc) { // _chkMatch |= 0b10; // } else if (_activeNode.vcc == pin.gnd) { // _downPin(pin.gnd); // _chkMatch |= 0b01; // } else { // if (_state) // _sinkPin(_activeNode.vcc); // } // // if (_activeNode.gnd == pin.vcc) { // _upPin(pin.vcc); // _chkMatch |= 0b10; // } else if (_activeNode.gnd == pin.gnd) { // _chkMatch |= 0b01; // } else { // if (_state) // _sinkPin(_activeNode.gnd); // } // // // Now Set the requested pin's state // if ((0b10 & _chkMatch) != 0b10) { // _upPin(pin.vcc); // } // if ((0b01 & _chkMatch) != 0b01) { // _downPin(pin.gnd); // } if (_state){ _sinkPin(_activeNode.vcc); _sinkPin(_activeNode.gnd); } _upPin(pin.vcc); _downPin(pin.gnd); _activeNode.vcc = pin.vcc; _activeNode.gnd = pin.gnd; _state = MXCHARLIE_ACTIVE; return _execute(); } else { //The objective is to check the given Node doesn't get conflict uint8_t _chkMatch = 0; // Whether the given node is the ActiveNode uint8_t _chkConflict = 0; // Whether it conflicts with ActiveNode uint8_t _chkClear = 0; // Whether it doesn't conflict with ActiveNode if (_activeNode.vcc == pin.vcc) { _chkMatch = (_chkMatch << 1) | 1; } else if (_activeNode.vcc == pin.gnd) { _chkConflict = (_chkConflict << 1) | 1; } else { _chkClear = (_chkClear << 1) | 1; } if (_activeNode.gnd == pin.vcc) { _chkConflict = (_chkConflict << 1) | 1; } else if (_activeNode.gnd == pin.gnd) { _chkMatch = (_chkMatch << 1) | 1; } else { _chkClear = (_chkClear << 1) | 1; } if (0b11 == _chkClear) { // No harm in changing _sinkPin(pin.vcc); _sinkPin(pin.gnd); return _execute(); } else if (0b11 & _chkConflict) { // If any conflict happens return false; } else if (0b11 == _chkMatch) { // Exact match to ActiveNode _sinkPin(pin.vcc); _sinkPin(pin.gnd); _activeNode = (DiodeNode){0, 0}; _state = MXCHARLIE_INACTIVE; return _execute(); } return false; } return false; }
//执行SQL语句,不用输出结果集合的那种 int ZCE_Mysql_STMT_Command::execute(unsigned int &num_affect, unsigned int &lastid) { return _execute(&num_affect , &lastid); }
//执行SQL语句,SELECT语句,转储结果集合的那种, int ZCE_Mysql_STMT_Command::execute(unsigned int &num_affect) { return _execute(&num_affect, NULL); }
bool Vm::execute(ThreadList::iterator t, const byte* const cur) { return _execute(&(*Prog)[0], t, cur); }
bool Expression::_execute(const Array &p_inputs, Object *p_instance, Expression::ENode *p_node, Variant &r_ret, String &r_error_str) { switch (p_node->type) { case Expression::ENode::TYPE_INPUT: { const Expression::InputNode *in = static_cast<const Expression::InputNode *>(p_node); if (in->index < 0 || in->index >= p_inputs.size()) { r_error_str = vformat(RTR("Invalid input %i (not passed) in expression"), in->index); return true; } r_ret = p_inputs[in->index]; } break; case Expression::ENode::TYPE_CONSTANT: { const Expression::ConstantNode *c = static_cast<const Expression::ConstantNode *>(p_node); r_ret = c->value; } break; case Expression::ENode::TYPE_SELF: { if (!p_instance) { r_error_str = RTR("self can't be used because instance is null (not passed)"); return true; } r_ret = p_instance; } break; case Expression::ENode::TYPE_OPERATOR: { const Expression::OperatorNode *op = static_cast<const Expression::OperatorNode *>(p_node); Variant a; bool ret = _execute(p_inputs, p_instance, op->nodes[0], a, r_error_str); if (ret) return true; Variant b; if (op->nodes[1]) { ret = _execute(p_inputs, p_instance, op->nodes[1], b, r_error_str); if (ret) return true; } bool valid = true; Variant::evaluate(op->op, a, b, r_ret, valid); if (!valid) { r_error_str = vformat(RTR("Invalid operands to operator %s, %s and %s."), Variant::get_operator_name(op->op), Variant::get_type_name(a.get_type()), Variant::get_type_name(b.get_type())); return true; } } break; case Expression::ENode::TYPE_INDEX: { const Expression::IndexNode *index = static_cast<const Expression::IndexNode *>(p_node); Variant base; bool ret = _execute(p_inputs, p_instance, index->base, base, r_error_str); if (ret) return true; Variant idx; ret = _execute(p_inputs, p_instance, index->index, idx, r_error_str); if (ret) return true; bool valid; r_ret = base.get(idx, &valid); if (!valid) { r_error_str = vformat(RTR("Invalid index of type %s for base type %s"), Variant::get_type_name(idx.get_type()), Variant::get_type_name(base.get_type())); return true; } } break; case Expression::ENode::TYPE_NAMED_INDEX: { const Expression::NamedIndexNode *index = static_cast<const Expression::NamedIndexNode *>(p_node); Variant base; bool ret = _execute(p_inputs, p_instance, index->base, base, r_error_str); if (ret) return true; bool valid; r_ret = base.get_named(index->name, &valid); if (!valid) { r_error_str = vformat(RTR("Invalid named index '%s' for base type %s"), String(index->name), Variant::get_type_name(base.get_type())); return true; } } break; case Expression::ENode::TYPE_ARRAY: { const Expression::ArrayNode *array = static_cast<const Expression::ArrayNode *>(p_node); Array arr; arr.resize(array->array.size()); for (int i = 0; i < array->array.size(); i++) { Variant value; bool ret = _execute(p_inputs, p_instance, array->array[i], value, r_error_str); if (ret) return true; arr[i] = value; } r_ret = arr; } break; case Expression::ENode::TYPE_DICTIONARY: { const Expression::DictionaryNode *dictionary = static_cast<const Expression::DictionaryNode *>(p_node); Dictionary d; for (int i = 0; i < dictionary->dict.size(); i += 2) { Variant key; bool ret = _execute(p_inputs, p_instance, dictionary->dict[i + 0], key, r_error_str); if (ret) return true; Variant value; ret = _execute(p_inputs, p_instance, dictionary->dict[i + 1], value, r_error_str); if (ret) return true; d[key] = value; } r_ret = d; } break; case Expression::ENode::TYPE_CONSTRUCTOR: { const Expression::ConstructorNode *constructor = static_cast<const Expression::ConstructorNode *>(p_node); Vector<Variant> arr; Vector<const Variant *> argp; arr.resize(constructor->arguments.size()); argp.resize(constructor->arguments.size()); for (int i = 0; i < constructor->arguments.size(); i++) { Variant value; bool ret = _execute(p_inputs, p_instance, constructor->arguments[i], value, r_error_str); if (ret) return true; arr.write[i] = value; argp.write[i] = &arr[i]; } Variant::CallError ce; r_ret = Variant::construct(constructor->data_type, (const Variant **)argp.ptr(), argp.size(), ce); if (ce.error != Variant::CallError::CALL_OK) { r_error_str = vformat(RTR("Invalid arguments to construct '%s'"), Variant::get_type_name(constructor->data_type)); return true; } } break; case Expression::ENode::TYPE_BUILTIN_FUNC: { const Expression::BuiltinFuncNode *bifunc = static_cast<const Expression::BuiltinFuncNode *>(p_node); Vector<Variant> arr; Vector<const Variant *> argp; arr.resize(bifunc->arguments.size()); argp.resize(bifunc->arguments.size()); for (int i = 0; i < bifunc->arguments.size(); i++) { Variant value; bool ret = _execute(p_inputs, p_instance, bifunc->arguments[i], value, r_error_str); if (ret) return true; arr.write[i] = value; argp.write[i] = &arr[i]; } Variant::CallError ce; exec_func(bifunc->func, (const Variant **)argp.ptr(), &r_ret, ce, r_error_str); if (ce.error != Variant::CallError::CALL_OK) { r_error_str = "Builtin Call Failed. " + r_error_str; return true; } } break; case Expression::ENode::TYPE_CALL: { const Expression::CallNode *call = static_cast<const Expression::CallNode *>(p_node); Variant base; bool ret = _execute(p_inputs, p_instance, call->base, base, r_error_str); if (ret) return true; Vector<Variant> arr; Vector<const Variant *> argp; arr.resize(call->arguments.size()); argp.resize(call->arguments.size()); for (int i = 0; i < call->arguments.size(); i++) { Variant value; ret = _execute(p_inputs, p_instance, call->arguments[i], value, r_error_str); if (ret) return true; arr.write[i] = value; argp.write[i] = &arr[i]; } Variant::CallError ce; r_ret = base.call(call->method, (const Variant **)argp.ptr(), argp.size(), ce); if (ce.error != Variant::CallError::CALL_OK) { r_error_str = vformat(RTR("On call to '%s':"), String(call->method)); return true; } } break; } return false; }
void MatrixStateFill::update(float dt) { _execute(); }
void State::onDeactivate() { _execute( _onDeactivate ); }
lw::json::Node PreparedQueryBase::execute( const PreparedQueryParametersBase& parameters ){ bind( parameters ); return _execute(); }
//virtual int get_working_memory_size() const { return 0; } //execute by parsing the tree directly virtual bool _execute(const Variant **p_inputs, VisualScriptExpression::ENode *p_node, Variant &r_ret, String &r_error_str, Variant::CallError &ce) { switch (p_node->type) { case VisualScriptExpression::ENode::TYPE_INPUT: { const VisualScriptExpression::InputNode *in = static_cast<const VisualScriptExpression::InputNode *>(p_node); r_ret = *p_inputs[in->index]; } break; case VisualScriptExpression::ENode::TYPE_CONSTANT: { const VisualScriptExpression::ConstantNode *c = static_cast<const VisualScriptExpression::ConstantNode *>(p_node); r_ret = c->value; } break; case VisualScriptExpression::ENode::TYPE_SELF: { r_ret = instance->get_owner_ptr(); } break; case VisualScriptExpression::ENode::TYPE_OPERATOR: { const VisualScriptExpression::OperatorNode *op = static_cast<const VisualScriptExpression::OperatorNode *>(p_node); Variant a; bool ret = _execute(p_inputs, op->nodes[0], a, r_error_str, ce); if (ret) return true; Variant b; if (op->nodes[1]) { ret = _execute(p_inputs, op->nodes[1], b, r_error_str, ce); if (ret) return true; } bool valid = true; Variant::evaluate(op->op, a, b, r_ret, valid); if (!valid) { r_error_str = "Invalid operands to operator " + Variant::get_operator_name(op->op) + ": " + Variant::get_type_name(a.get_type()) + " and " + Variant::get_type_name(b.get_type()) + "."; return true; } } break; case VisualScriptExpression::ENode::TYPE_INDEX: { const VisualScriptExpression::IndexNode *index = static_cast<const VisualScriptExpression::IndexNode *>(p_node); Variant base; bool ret = _execute(p_inputs, index->base, base, r_error_str, ce); if (ret) return true; Variant idx; ret = _execute(p_inputs, index->index, idx, r_error_str, ce); if (ret) return true; bool valid; r_ret = base.get(idx, &valid); if (!valid) { r_error_str = "Invalid index of type " + Variant::get_type_name(idx.get_type()) + " for base of type " + Variant::get_type_name(base.get_type()) + "."; return true; } } break; case VisualScriptExpression::ENode::TYPE_NAMED_INDEX: { const VisualScriptExpression::NamedIndexNode *index = static_cast<const VisualScriptExpression::NamedIndexNode *>(p_node); Variant base; bool ret = _execute(p_inputs, index->base, base, r_error_str, ce); if (ret) return true; bool valid; r_ret = base.get_named(index->name, &valid); if (!valid) { r_error_str = "Invalid index '" + String(index->name) + "' for base of type " + Variant::get_type_name(base.get_type()) + "."; return true; } } break; case VisualScriptExpression::ENode::TYPE_ARRAY: { const VisualScriptExpression::ArrayNode *array = static_cast<const VisualScriptExpression::ArrayNode *>(p_node); Array arr; arr.resize(array->array.size()); for (int i = 0; i < array->array.size(); i++) { Variant value; bool ret = _execute(p_inputs, array->array[i], value, r_error_str, ce); if (ret) return true; arr[i] = value; } r_ret = arr; } break; case VisualScriptExpression::ENode::TYPE_DICTIONARY: { const VisualScriptExpression::DictionaryNode *dictionary = static_cast<const VisualScriptExpression::DictionaryNode *>(p_node); Dictionary d; for (int i = 0; i < dictionary->dict.size(); i += 2) { Variant key; bool ret = _execute(p_inputs, dictionary->dict[i + 0], key, r_error_str, ce); if (ret) return true; Variant value; ret = _execute(p_inputs, dictionary->dict[i + 1], value, r_error_str, ce); if (ret) return true; d[key] = value; } r_ret = d; } break; case VisualScriptExpression::ENode::TYPE_CONSTRUCTOR: { const VisualScriptExpression::ConstructorNode *constructor = static_cast<const VisualScriptExpression::ConstructorNode *>(p_node); Vector<Variant> arr; Vector<const Variant *> argp; arr.resize(constructor->arguments.size()); argp.resize(constructor->arguments.size()); for (int i = 0; i < constructor->arguments.size(); i++) { Variant value; bool ret = _execute(p_inputs, constructor->arguments[i], value, r_error_str, ce); if (ret) return true; arr[i] = value; argp[i] = &arr[i]; } r_ret = Variant::construct(constructor->data_type, argp.ptr(), argp.size(), ce); if (ce.error != Variant::CallError::CALL_OK) { r_error_str = "Invalid arguments to construct '" + Variant::get_type_name(constructor->data_type) + "'."; return true; } } break; case VisualScriptExpression::ENode::TYPE_BUILTIN_FUNC: { const VisualScriptExpression::BuiltinFuncNode *bifunc = static_cast<const VisualScriptExpression::BuiltinFuncNode *>(p_node); Vector<Variant> arr; Vector<const Variant *> argp; arr.resize(bifunc->arguments.size()); argp.resize(bifunc->arguments.size()); for (int i = 0; i < bifunc->arguments.size(); i++) { Variant value; bool ret = _execute(p_inputs, bifunc->arguments[i], value, r_error_str, ce); if (ret) return true; arr[i] = value; argp[i] = &arr[i]; } VisualScriptBuiltinFunc::exec_func(bifunc->func, argp.ptr(), &r_ret, ce, r_error_str); if (ce.error != Variant::CallError::CALL_OK) { r_error_str = "Builtin Call Failed. " + r_error_str; return true; } } break; case VisualScriptExpression::ENode::TYPE_CALL: { const VisualScriptExpression::CallNode *call = static_cast<const VisualScriptExpression::CallNode *>(p_node); Variant base; bool ret = _execute(p_inputs, call->base, base, r_error_str, ce); if (ret) return true; Vector<Variant> arr; Vector<const Variant *> argp; arr.resize(call->arguments.size()); argp.resize(call->arguments.size()); for (int i = 0; i < call->arguments.size(); i++) { Variant value; bool ret = _execute(p_inputs, call->arguments[i], value, r_error_str, ce); if (ret) return true; arr[i] = value; argp[i] = &arr[i]; } r_ret = base.call(call->method, argp.ptr(), argp.size(), ce); if (ce.error != Variant::CallError::CALL_OK) { r_error_str = "On call to '" + String(call->method) + "':"; return true; } } break; } return false; }
lw::json::Node PreparedQueryBase::execute( Connection& connection ){ if( !m_statement ){ _prepareQuery( connection ); } return _execute(); }