global void def_functor(DefType *dt) { Cons *cp; Expr *lhs; if (dt->dt_arity == 0) { /* * Nullary type T gives the definition * --- T x <= x; */ def_value( apply_expr(id_expr(dt->dt_name), id_expr(variable[0])), id_expr(variable[0])); } else if (IsSynType(dt)) { /* * A type synonym definition * type T(a1, ..., an) == t; * generates a value definition * --- T(a1, ..., an) <= t; */ lhs = dt->dt_tupled ? apply_expr(id_expr(dt->dt_name), expr_of_typelist(dt->dt_varlist)) : multi_apply_expr(id_expr(dt->dt_name), dt->dt_varlist); def_value(lhs, expr_of_type(dt->dt_type)); } else { /* * A data type definition * data T(a1, ..., an) == ... ++ c t1 ... tk ++ ...; * generates value definitions * --- T(a1, ..., an) (c x1 ... xk) <= * c (t1 x1) ... (tk xk); * Similarly for T a1 ... an */ for (cp = dt->dt_cons; cp != NULL; cp = cp->c_next) { lhs = dt->dt_tupled ? apply_expr(id_expr(dt->dt_name), expr_of_typelist(dt->dt_varlist)) : multi_apply_expr(id_expr(dt->dt_name), dt->dt_varlist); def_value(apply_expr(lhs, pat_of_constr(cp)), body_of_constr(cp)); } } fn_local(dt->dt_name)->f_explicit_def = FALSE; }
VisReturnType TNodeVisitorRecursive::visit(TNode_statement_switch* node,VisExtraParam p) { if (node->token.word == "switch") { node->expr_cond->accept(*this,p); for(TNode_statement_switch::case_iterator it1=node->case_list.begin();it1!=node->case_list.end();++it1) { //for(TNode_statement_switch::item_iterator it2=(*it1)->case_value.begin(); // it2!=(*it1)->case_value.end();++it2) //{ // (*it2)->accept(*this,p); //} if ((*it1)->case_value) (*it1)->case_value->accept(*this, p); (*it1)->case_stmt->accept(*this,p); } } else if (node->token.word == "judge") { for(TNode_statement_switch::case_iterator it1=node->case_list.begin();it1!=node->case_list.end();++it1) { if((*it1)->case_value) (*it1)->case_value->accept(*this, p); (*it1)->case_stmt->accept(*this,p); } } return def_value(); }
VisReturnType TNodeVisitorRecursive::visit(TNode_item_select* node,VisExtraParam p) { for (size_t i = 0; i < node->exp_list->aList.size(); i++) { if (node->exp_list->aList[i]) node->exp_list->aList[i]->accept(*this, p); } return def_value(); }
VisReturnType TNodeVisitorRecursive::visit(TNode_expression_list* node,VisExtraParam p) { for(TNode_expression_list::nodelist::iterator it=node->aList.begin();it!=node->aList.end();++it) { (*it)->accept(*this,p); } return def_value(); }
VisReturnType TNodeVisitorRecursive::visit(TNode_expression_op* node,VisExtraParam p) { int s=node->size(); for(int i=0;i<s;i++) { node->getp(s)->accept(*this,p); } return def_value(); }
VisReturnType TNodeVisitorRecursive::visit(TNode_statement_if* node,VisExtraParam p) { node->expr_cond->accept(*this,p); if(node->stmt_if_1) { node->stmt_if_1->accept(*this,p); } if(node->stmt_if_0) { node->stmt_if_0->accept(*this,p); } return def_value(); }
VisReturnType TNodeVisitorRecursive::visit(TNode_expression_call* node,VisExtraParam p) { if(node->cls) { node->cls->accept(*this,p); } node->tbl->accept(*this,p); node->exp_list->accept(*this,p); return def_value(); }
VisReturnType TNodeVisitorRecursive::visit(TNode_val_function* node,VisExtraParam p) { if(node->exp_list) { node->exp_list->accept(*this,p); } if(node->func_name) { node->func_name->accept(*this,1); } node->func_body->accept(*this,p); return def_value(); }
ErrorCode WriteVtk::write_tag(std::ostream& stream, Tag tag, const Range& entities, const Range& tagged, const int) { ErrorCode rval; const unsigned long n = entities.size(); // Get tag properties std::string name; int vals_per_tag; if (MB_SUCCESS != mbImpl->tag_get_name(tag, name) || MB_SUCCESS != mbImpl->tag_get_length(tag, vals_per_tag)) return MB_FAILURE; // Get a tag value for each entity. Do this by initializing the // "data" vector with zero, and then filling in the values for // the entities that actually have the tag set. std::vector<T> data; data.resize(n * vals_per_tag, 0); // If there is a default value for the tag, set the actual default value std::vector<T> def_value(vals_per_tag); rval = mbImpl->tag_get_default_value(tag, &(def_value[0])); if (MB_SUCCESS == rval) SysUtil::setmem(&(data[0]), &(def_value[0]), vals_per_tag * sizeof(T), n); Range::const_iterator t = tagged.begin(); typename std::vector<T>::iterator d = data.begin(); for (Range::const_iterator i = entities.begin(); i != entities.end() && t != tagged.end(); ++i, d += vals_per_tag) { if (*i == *t) { ++t; rval = mbImpl->tag_get_data(tag, &(*i), 1, &(*d)); if (MB_SUCCESS != rval) return rval; } } // Write the tag values, one entity per line. write_data(stream, data, vals_per_tag); return MB_SUCCESS; }
VisReturnType TNodeVisitorRecursive::visit(TNode_statement_loop* node,VisExtraParam p) { if(node->stmt_init) { node->stmt_init->accept(*this,p); } if(node->expr_cond) { node->expr_cond->accept(*this,p); } if(node->stmt_fini) { node->stmt_fini->accept(*this,p); } if(node->stmt_body) { node->stmt_body->accept(*this,p); } if(node->fe_container) { node->fe_container->accept(*this,p); } return def_value(); }
set::set(int argc, char *argv[]): valid_(0) { Vb vb; // construct a Vb object Oid req; if ( argc < 2) return; target_.get_write_community(community_); address_ = argv[argc - 1]; if ( !address_.valid()) { cout << "ERROR: Invalid IPv4 address or DNS hostname: " \ << argv[argc] << "\n"; return; } ACE_Get_Opt get_opt (argc, argv, "o:c:r:t:I:U:C:G:T:O:S:P:"); for (int c; (c = get_opt ()) != -1; ) switch (c) { case 'o': req = get_opt.optarg; if (req.valid() == 0) cout << "ERROR: oid value: " <<get_opt.optarg \ << "is not valid. using default.\n"; break; case 'c': community_ = get_opt.optarg; target_.set_write_community(community_); break; case 'r': target_.set_retry(ACE_OS::atoi (get_opt.optarg)); break; case 't': target_.set_timeout(ACE_OS::atoi (get_opt.optarg)); break; case 'I': // Integer32 { SnmpInt32 o(ACE_OS::atoi(get_opt.optarg)); vb.set_value(o); pdu_ += vb; } break; case 'U': // Unsigned32 { SnmpUInt32 o(ACE_OS::atoi(get_opt.optarg)); vb.set_value(o); pdu_ += vb; } break; case 'C': // Counter32 { Counter32 o(ACE_OS::atoi(get_opt.optarg)); vb.set_value(o); pdu_ += vb; } break; case 'G': // Gauge32 { Gauge32 o(ACE_OS::atoi(get_opt.optarg)); vb.set_value(o); pdu_ += vb; } break; case 'T': // TimeTicks { TimeTicks o(ACE_OS::atoi(get_opt.optarg)); vb.set_value(o); pdu_ += vb; } break; case 'O': // Oid as a variable identifier { oid_ = get_opt.optarg; vb.set_oid(oid_); // when value is set, pdu updated } break; case 'S': // Octet String { OctetStr o(get_opt.optarg); vb.set_value(o); // set the Oid portion of the Vb pdu_ += vb; } break; case 'P': // Oid String as a value { Oid o(get_opt.optarg); vb.set_value(o); // set the Oid portion of the Vb pdu_ += vb; } break; default: break; } // if user didn't set anything use defaults if (pdu_.get_vb_count() == 0) { Oid def_oid("1.3.6.1.2.1.1.4.0"); // defualt is sysName OctetStr def_value("sysName.0 updated by ASNMP set command"); vb.set_oid(def_oid); vb.set_value(def_value); pdu_ += vb; cout << "INFO: using defaults, setting sysName to : " << \ def_value.to_string() << endl; } valid_ = 1; }
VisReturnType TNodeVisitorRecursive::visit(TNode_expression_op2* node,VisExtraParam p) { if(node->param[1]) node->param[1]->accept(*this,p); if(node->param[0]) node->param[0]->accept(*this,p); return def_value(); }
VisReturnType TNodeVisitorRecursive::visit(TNode_statement_assignment* node,VisExtraParam p) { node->value->accept(*this,p); return def_value(); }
VisReturnType TNodeVisitorRecursive::visit(TNode_expression_dot* node,VisExtraParam p) { node->tbl->accept(*this,p); return def_value(); }
VisReturnType TNodeVisitorVisitBase::visit(TNode* node,VisExtraParam) { handle(node); return def_value(); }