Beispiel #1
0
int McpServlet::get_grab_list_by_type(const idl::mcp_get_grab_list_by_type_params& in, idl::mcp_get_grab_list_by_type_response& out)
{
    UB_LOG_TRACE( "get_grab_list_by_type start" );
    string type_id(in.type_id());
    uint32_t page(in.page());
    uint32_t page_size(in.page_size());

    vector<grab_t> grab_list;
    int count=0;
    ContentType type(type_id);
    type.set_page_info(page, page_size);
    int res=type.getGrabList(count, grab_list);
    if(res!=0){
        UB_LOG_FATAL( "getGrabList failed, [%s:%d]", __FILE__, __LINE__ );
        count = res;
        goto end;
    }
end:
    out.m_result_params()->set_result(count);
    vector<grab_t>::const_iterator iter=grab_list.begin();
    for(int i=0; iter!=grab_list.end(); ++i, ++iter){
        setGrabInfoResult(out.m_result_params()->mutable_grab_list(i), *iter);
    }
    UB_LOG_TRACE( "get_grab_list_by_type end" );
    return 0;
}
void scalar_base::set(const pn_atom_t& atom) {
    if (type_id_is_string_like(type_id(atom.type))) {
        set(bin(atom.u.as_bytes), atom.type);
    } else {
        atom_ = atom;
        bytes_.clear();
    }
}
Beispiel #3
0
void SIERRA_FORTRAN(register_user_subroutine)(
  type_info_func *		type_id,
  void *			user_subroutine,
  const char *			name,
  int				name_len)
{
  sierra::Plugin::Registry::rootInstance().registerIt(std::make_pair(type_id(), std::string(name, name_len)), user_subroutine);
}
Beispiel #4
0
 /* The whole point of this is inlining */
 size_t size_in_bytes(VM* vm) const {
   register size_t size = TypeInfo::instance_sizes[type_id()];
   if(size != 0) {
     return size;
   } else {
     return slow_size_in_bytes(vm);
   }
 }
Beispiel #5
0
Base& Base::operator=(const Base& that)
{
	const auto type1 = type_id();
	const auto type2 = that.type_id();
	if(type1 != type2)
	{
		throw std::runtime_error("can not copy " + std::to_string(type2) + " to " + std::to_string(type1));
	}
	return *this;
}
Beispiel #6
0
int typedef_name(struct token *token)
{
    printf("Hello from typedef_name\n");//DEBUG
    
    if (token->type != ID_KW){
        printf("Not an identifier!\n");//DEBUG
        log_error(TYPEDEF_NAME);
        return -1;
    }

    struct hashentry *ifkw = hash_retrieve(kwtable, token->lexeme);
    if (ifkw != NULL){ //not a keyword
        printf("%s, not an identifier\n", token->lexeme);//DEBUG
        log_error(TYPEDEF_NAME);
        return -1;
    }
    else{ //add to symboltable
        //create a new identifier for symbol table
        struct identifier *newid = malloc(sizeof(struct identifier *));
        type_id(newid->type);
        newid->op_type = 0;
        newid->kw_name = 0;
        newid->lexeme = token->lexeme;

        //ensure not already in the symbol table
        struct hashentry *entry = hash_insert(symboltable, newid);
        if (entry == NULL){
            log_error(TYPEDEF_NAME);
            printf("Error inserting into symbol table!\n");
            return -1;
        }
        else if (entry == (void *)1){
            log_error(TYPEDEF_NAME);
            printf("%s is already defined!\n", newid->lexeme);
            return -1;
        }

        //make the tree node, and add the attribute
        tree_mknode(TYPEDEF_NAME);
        stack_pop();
        tree_add_attr(newid, 3);//TODO
        input_consume(); //consume the identifier

        struct token *t = input_peek();
        if (t->op_type == OPENBRACKET){
            input_consume();
            stack_push(DEFINE_ARRAY);
        }
        free(token);
    }
    printf("leaving typedef_name\n");//DEBUG;

    return 0;
}
Beispiel #7
0
int main(int argc, char** argv) {
    std::cout << type_id(0) << "\n";
    std::cout << type_id("test") << "\n";
    std::cout << type_id(0) << "\n";
    std::cout << type_id("test") << "\n";
    std::cout << type_id("test") << "\n";
    std::cout << type_id(0) << "\n";
    std::cout << type_id(0) << "\n";
    return 0;
}
Beispiel #8
0
bool Slot::add_connection(Slot *slot) {
  if (type_id() == NO_TYPE_TAG_ID ||  slot->type_id() == NO_TYPE_TAG_ID) return false; // one of them is a NoIO
  assert(type().size() > 0);
  assert(slot->type().size()  > 0);
  if ((kind_of(Inlet)        && can_receive(slot->type()[0])) ||
      (slot->kind_of(Inlet)  && slot->can_receive(type()[0]))) {
    // same type signature or inlet receiving any type
    // OrderedList makes sure the link is not created again if it already exists.
    connections_.push(slot); 
    return true;
  } else {
    return false;
  }
}
			/// returns the index of a set of types (given by thier ids)
			static std::size_t index(Handle<Types...> const& handle, OtherTypes const&... other_params)
			{
				auto size =
					meta::size<
						typename meta::apply_list<
							meta::cartesian_product,
							typename meta::map<
								make_list,
								detail::list<OtherTypes...>
							>::type
						>::type::type
					>::value;

				// note: type_id is part of the interface for handles
				return type_id(handle) * size + type_index_dispatch<OtherTypes...>::index(other_params...);
			}
Beispiel #10
0
//TODO
int labeled_statement(struct token *token)
{
    printf("hello from labeled statement\n");//DEBUG
    //need to make node
    //consume the "begin" kw (check for it first)
    //consume and add the next identifier token (check)
    //check and consume the final ':'
    input_consume(); // "begin"
    free_token(token);
    struct token *t = input_consume(); // the identifier
    struct hashentry *label = hash_retrieve(kwtable, t->lexeme);
    struct token *colon = input_consume(); //should be ':'

    if(label == NULL && colon->op_type == TERNC){ //good, not a keyword
        tree_mknode(LABELED_STATEMENT);

        struct hashentry *predefined;
        struct identifier *labelsym = malloc(sizeof(struct identifier));
        labelsym->lexeme = t->lexeme;

        predefined = hash_insert(symboltable, labelsym);
        if(predefined == NULL || predefined == (void *)1){
            log_error(LABELED_STATEMENT);
            printf("Symbol: %s has previously been defined\n", t->lexeme);
            return -1;
        }
        type_id(labelsym->type);
        labelsym->op_type = 0;

        struct hashentry *beginkw = hash_retrieve(kwtable, "begin");

        tree_add_attr(beginkw->data, 0);
        tree_add_attr(labelsym, 1);
        free(t);
        free(colon);
        stack_pop();
        return 0;
    }
    else{
        log_error(LABELED_STATEMENT);
        return -1;
    }
}
Beispiel #11
0
  void ObjectHeader::initialize_copy(Object* other, unsigned int new_age) {
    /* Even though we dup it, we have to be careful to maintain
     * the zone. */

    // DO NOT, EVER, CHANGE obj_type_.
    // obj_type_ indicates the shape of the object in memory. There are
    // f****d up cases where this is called where other is another type
    // (that, btw, is likely a bug in itself), but we should never,
    // MUST never change obj_type_ to make them match. This causes the GC
    // to get confused about the memory shape of the object!
    assert(type_id() == other->type_id());
    set_age(new_age);
    klass_ = other->klass_;
    ivars_ = other->ivars_;

#ifdef RBX_OBJECT_ID_IN_HEADER
    set_object_id(other->object_id());
#endif

    clear_forwarded();

    if(other->is_tainted_p()) set_tainted();
  }
Beispiel #12
0
 bool regular_call() const {
   return type_id() == MonoInlineCacheType || type_id() == PolyInlineCacheType;
 }
Beispiel #13
0
int jump_statement(struct token *token)
{
    printf("Hello from jump_statement\n");//DEBUG
    // goto label conditional
    if( strncmp("goto", token->lexeme, 4) == 0){
        tree_mknode(JUMP_STATEMENT);
        input_consume(); //consume the goto
        free_token(token);
        struct token *label = input_consume();
        struct token *conditional = input_consume();
        if (label->type == ID_KW){
            struct hashentry *ifkw = hash_retrieve(kwtable, label->lexeme);
            if (ifkw == NULL){//not a keyword, an identifier

                struct hashentry *predefined;
                struct hashentry *predefined2;

                //get symboltable entry for label
                predefined = hash_retrieve(symboltable, label->lexeme);
                if(predefined == NULL){
                    predefined = malloc(sizeof(struct hashentry));
                    predefined->data = malloc(sizeof(struct identifier));
                    predefined->data->lexeme = label->lexeme;
                    type_id(predefined->data->type);
                    //log_error(LABELED_STATEMENT);
                    //printf("Symbol: %s has not been defined!\n", label->lexeme);
                    //return -1;
                }
                //get symboltable entry for conditional
                predefined2 = hash_retrieve(symboltable, conditional->lexeme);
                if(predefined2 == NULL){
                    log_error(LABELED_STATEMENT);
                    printf("Symbol: %s has not been defined!\n", conditional->lexeme);
                    return -1;
                }

                struct hashentry *gokw = hash_retrieve(kwtable, "goto");

                tree_add_attr(gokw->data, 0);
                tree_add_attr(predefined->data, 1);
                tree_add_attr(predefined2->data, 2);

                printf("Consumed: goto %s %s\n", 
                    label->lexeme, conditional->lexeme);//DEBUG
                stack_pop();
                stack_push(TOKEN_ENDSTATEMENT);
                free(label);
                free(conditional);
                return 0;
            }
            else{
                log_error(JUMP_STATEMENT);
                free_token(label);
                free_token(conditional);
                return -1;
            }
        }
        else{
            printf("Incorrect goto label: %s\n", label->lexeme);//DEBUG
            free_token(label);
            free_token(conditional);
            log_error(JUMP_STATEMENT);
            return -1;
        }
    }
    else{
        log_error(JUMP_STATEMENT);
        return -1;
    }
}
Beispiel #14
0
 void validate() const {
   assert(this && (!reference_p() || (type_id() > InvalidType && type_id() < LastObjectType)));
 }
void scalar_base::ok(pn_type_t t) const {
    if (atom_.type != t) throw make_conversion_error(type_id(t), type());
}
bool CommonUniformElimPass::CommonUniformLoadElimination(ir::Function* func) {
  // Process all blocks in structured order. This is just one way (the
  // simplest?) to keep track of the most recent block outside of control
  // flow, used to copy common instructions, guaranteed to dominate all
  // following load sites.
  std::list<ir::BasicBlock*> structuredOrder;
  ComputeStructuredOrder(func, &structuredOrder);
  uniform2load_id_.clear();
  bool modified = false;
  // Find insertion point in first block to copy non-dominating loads.
  auto insertItr = func->begin()->begin();
  while (insertItr->opcode() == SpvOpVariable ||
      insertItr->opcode() == SpvOpNop)
    ++insertItr;
  uint32_t mergeBlockId = 0;
  for (auto bi = structuredOrder.begin(); bi != structuredOrder.end(); ++bi) {
    ir::BasicBlock* bp = *bi;
    // Check if we are exiting outermost control construct. If so, remember
    // new load insertion point. Trying to keep register pressure down.
    if (mergeBlockId == bp->id()) {
      mergeBlockId = 0;
      insertItr = bp->begin();
    }
    for (auto ii = bp->begin(); ii != bp->end(); ++ii) {
      if (ii->opcode() != SpvOpLoad)
        continue;
      uint32_t varId;
      ir::Instruction* ptrInst = GetPtr(&*ii, &varId);
      if (ptrInst->opcode() != SpvOpVariable)
        continue;
      if (!IsUniformVar(varId))
        continue;
      if (IsSamplerOrImageVar(varId))
        continue;
      if (HasUnsupportedDecorates(ii->result_id()))
        continue;
      uint32_t replId;
      const auto uItr = uniform2load_id_.find(varId);
      if (uItr != uniform2load_id_.end()) {
        replId = uItr->second;
      }
      else {
        if (mergeBlockId == 0) {
          // Load is in dominating block; just remember it
          uniform2load_id_[varId] = ii->result_id();
          continue;
        }
        else {
          // Copy load into most recent dominating block and remember it
          replId = TakeNextId();
          std::unique_ptr<ir::Instruction> newLoad(new ir::Instruction(SpvOpLoad,
            ii->type_id(), replId, {{spv_operand_type_t::SPV_OPERAND_TYPE_ID, {varId}}}));
          def_use_mgr_->AnalyzeInstDefUse(&*newLoad);
          insertItr = insertItr.InsertBefore(std::move(newLoad));
          ++insertItr;
          uniform2load_id_[varId] = replId;
        }
      }
      ReplaceAndDeleteLoad(&*ii, replId, ptrInst);
      modified = true;
    }
    // If we are outside of any control construct and entering one, remember
    // the id of the merge block
    if (mergeBlockId == 0) {
      uint32_t dummy;
      mergeBlockId = MergeBlockIdIfAny(*bp, &dummy);
    }
  }
  return modified;
}
type_id scalar_base::type() const { return type_id(atom_.type); }
Beispiel #18
0
 size_t ObjectHeader::slow_size_in_bytes(STATE) const {
   return state->om->type_info[type_id()]->object_size(this);
 }
			static std::size_t index(Handle<Types...> const& handle)
			{
				return type_id(handle);
			}
Beispiel #20
0
 size_t DataHeader::compute_size_in_bytes(VM* vm) const {
   return vm->memory()->type_info[type_id()]->object_size(this);
 }