Esempio n. 1
0
// Load all variables from EEPROM
//
bool AP_Param::load_all(void)
{
    struct Param_header phdr;
    uint16_t ofs = sizeof(AP_Param::EEPROM_header);

    while (ofs < _eeprom_size) {
        hal.storage->read_block(&phdr, ofs, sizeof(phdr));
        // note that this is an || not an && for robustness
        // against power off while adding a variable
        if (phdr.type == _sentinal_type ||
            phdr.key == _sentinal_key ||
            phdr.group_element == _sentinal_group) {
            // we've reached the sentinal
            return true;
        }

        const struct AP_Param::Info *info;
        void *ptr;

        info = find_by_header(phdr, &ptr);
        if (info != NULL) {
            hal.storage->read_block(ptr, ofs+sizeof(phdr), type_size((enum ap_var_type)phdr.type));
        }

        ofs += type_size((enum ap_var_type)phdr.type) + sizeof(phdr);
    }

    // we didn't find the sentinal
    serialDebug("no sentinal in load_all");
    return false;
}
Esempio n. 2
0
symbol_t *
build_struct (int su, symbol_t *tag, symtab_t *symtab, type_t *type)
{
	symbol_t   *sym = find_struct (su, tag, type);
	symbol_t   *s;

	symtab->parent = 0;		// disconnect struct's symtab from parent scope

	if (sym->table == current_symtab && sym->type->t.symtab) {
		error (0, "%s defined as wrong kind of tag", tag->name);
		return sym;
	}
	for (s = symtab->symbols; s; s = s->next) {
		if (s->sy_type != sy_var)
			continue;
		if (su == 's') {
			s->s.offset = symtab->size;
			symtab->size += type_size (s->type);
		} else {
			int         size = type_size (s->type);
			if (size > symtab->size)
				symtab->size = size;
		}
	}
	if (!type)
		sym->type = find_type (sym->type);	// checks the tag, not the symtab
	sym->type->t.symtab = symtab;
	if (!type && sym->type->type_def->external)	//FIXME should not be necessary
		sym->type->type_def = qfo_encode_type (sym->type);
	return sym;
}
Esempio n. 3
0
static unsigned
type_size(const struct glsl_type *type)
{
   unsigned int size, i;

   switch (glsl_get_base_type(type)) {
   case GLSL_TYPE_UINT:
   case GLSL_TYPE_INT:
   case GLSL_TYPE_FLOAT:
   case GLSL_TYPE_BOOL:
      return glsl_get_components(type);
   case GLSL_TYPE_ARRAY:
      return type_size(glsl_get_array_element(type)) * glsl_get_length(type);
   case GLSL_TYPE_STRUCT:
      size = 0;
      for (i = 0; i < glsl_get_length(type); i++) {
         size += type_size(glsl_get_struct_field(type, i));
      }
      return size;
   case GLSL_TYPE_SAMPLER:
      return 0;
   case GLSL_TYPE_ATOMIC_UINT:
      return 0;
   case GLSL_TYPE_INTERFACE:
      return 0;
   case GLSL_TYPE_IMAGE:
      return 0;
   case GLSL_TYPE_VOID:
   case GLSL_TYPE_ERROR:
   case GLSL_TYPE_DOUBLE:
      unreachable("not reached");
   }

   return 0;
}
Esempio n. 4
0
static void print_instr_cat1(instr_t *instr)
{
	instr_cat1_t *cat1 = &instr->cat1;

	if (cat1->ul)
		printf("(ul)");

	if (cat1->src_type == cat1->dst_type) {
		if ((cat1->src_type == TYPE_S16) && (((reg_t)cat1->dst).num == REG_A0)) {
			/* special case (nmemonic?): */
			printf("mova");
		} else {
			printf("mov.%s%s", type[cat1->src_type], type[cat1->dst_type]);
		}
	} else {
		printf("cov.%s%s", type[cat1->src_type], type[cat1->dst_type]);
	}

	printf(" ");

	if (cat1->even)
		printf("(even)");

	if (cat1->pos_inf)
		printf("(pos_infinity)");

	print_reg_dst((reg_t)(cat1->dst), type_size(cat1->dst_type) == 32,
			cat1->dst_rel);

	printf(", ");

	/* ugg, have to special case this.. vs print_reg().. */
	if (cat1->src_im) {
		if (type_float(cat1->src_type))
			printf("(%f)", cat1->fim_val);
		else if (type_uint(cat1->src_type))
			printf("0x%08x", cat1->uim_val);
		else
			printf("%d", cat1->iim_val);
	} else if (cat1->src_rel && !cat1->src_c) {
		/* I would just use %+d but trying to make it diff'able with
		 * libllvm-a3xx...
		 */
		char type = cat1->src_rel_c ? 'c' : 'r';
		if (cat1->off < 0)
			printf("%c<a0.x - %d>", type, -cat1->off);
		else if (cat1->off > 0)
			printf("%c<a0.x + %d>", type, cat1->off);
		else
			printf("c<a0.x>");
	} else {
		print_reg_src((reg_t)(cat1->src), type_size(cat1->src_type) == 32,
				cat1->src_r, cat1->src_c, cat1->src_im, false, false, false);
	}

	if ((debug & PRINT_VERBOSE) && (cat1->must_be_0))
		printf("\t{1: %x}", cat1->must_be_0);
}
Esempio n. 5
0
unsigned type_size(type *r, const where *from)
{
	switch(r->type){
		case type_auto:
			ICE("__auto_type");

		case type_btype:
			return btype_size(r->bits.type, from);

		case type_tdef:
		{
			decl *d = r->bits.tdef.decl;
			type *sub;

			if(d)
				return type_size(d->ref, from);

			sub = r->bits.tdef.type_of->tree_type;
			UCC_ASSERT(sub, "type_size for unfolded typedef");
			return type_size(sub, from);
		}

		case type_attr:
		case type_cast:
		case type_where:
			return type_size(r->ref, from);

		case type_ptr:
		case type_block:
			return platform_word_size();

		case type_func:
			/* function size is one, sizeof(main) is valid */
			return 1;

		case type_array:
		{
			integral_t sz;

			if(type_is_void(r->ref))
				die_at(from, "array of void");

			if(!r->bits.array.size)
				die_at(from, "array has an incomplete size");

			sz = const_fold_val_i(r->bits.array.size);

			return sz * type_size(r->ref, from);
		}
	}

	ucc_unreach(0);
}
Esempio n. 6
0
File: eu.c Progetto: krh/ksim
static void
builder_emit_dst_store(struct builder *bld, int avx_reg,
		       struct inst *inst, struct inst_dst *dst)
{
	struct inst_common common = unpack_inst_common(inst);
	int subnum;

	/* FIXME: write masks */

	if (dst->hstride > 1)
		stub("eu: dst hstride %d is > 1", dst->hstride);

	if (common.saturate) {
		int zero = builder_get_reg_with_uniform(bld, 0);
		int one = builder_get_reg_with_uniform(bld, float_to_u32(1.0f));
		ksim_assert(is_float(dst->file, dst->type));
		builder_emit_vmaxps(bld, avx_reg, avx_reg, zero);
		builder_emit_vminps(bld, avx_reg, avx_reg, one);
	}

	if (common.access_mode == BRW_ALIGN_1)
		subnum = dst->da1_subnum;
	else
		subnum = dst->da16_subnum;

	uint32_t offset =
		offsetof(struct thread, grf[dst->num]) + subnum +
		bld->exec_offset * dst->hstride * type_size(dst->type);

	switch (bld->exec_size * type_size(dst->type)) {
	case 32:
		builder_emit_m256i_store(bld, avx_reg, offset);
		break;
	case 16:
		builder_emit_m128i_store(bld, avx_reg, offset);
		break;
	case 4:
		builder_emit_u32_store(bld, avx_reg, offset);
		break;
	default:
		stub("eu: type size %d in dest store", type_size(dst->type));
		break;
	}

	/* FIXME: For a straight move, this makes the AVX2 register
	 * refer to the dst region.  That's fine, but the register may
	 * still also shadow the src region, but since we only track
	 * one region per AVX2 reg, that is lost. */
	fill_region_for_dst(&bld->regs[avx_reg].region, dst, offset, bld);
	builder_invalidate_region(bld, &bld->regs[avx_reg].region);
	bld->regs[avx_reg].contents |= BUILDER_REG_CONTENTS_EU_REG;
}
Esempio n. 7
0
// Save the variable to EEPROM, if supported
//
bool AP_Param::save(void)
{
    uint8_t group_element = 0;
    const struct GroupInfo *ginfo;
    uint8_t idx;
    const struct AP_Param::Info *info = find_var_info(&group_element, &ginfo, &idx);
    const AP_Param *ap;

    if (info == NULL) {
        // we don't have any info on how to store it
        return false;
    }

    struct Param_header phdr;

    // create the header we will use to store the variable
    if (ginfo != NULL) {
        phdr.type = PGM_UINT8(&ginfo->type);
    } else {
        phdr.type = PGM_UINT8(&info->type);
    }
    phdr.key  = PGM_UINT8(&info->key);
    phdr.group_element = group_element;

    ap = this;
    if (phdr.type != AP_PARAM_VECTOR3F && idx != 0) {
        // only vector3f can have non-zero idx for now
        return false;
    }
    if (idx != 0) {
        ap = (const AP_Param *)((uintptr_t)ap) - (idx*sizeof(float));
    }

    // scan EEPROM to find the right location
    uint16_t ofs;
    if (scan(&phdr, &ofs)) {
        // found an existing copy of the variable
        eeprom_write_check(ap, ofs+sizeof(phdr), type_size((enum ap_var_type)phdr.type));
        return true;
    }
    if (ofs == (uint16_t)~0) {
        return false;
    }

    // write a new sentinal, then the data, then the header
    write_sentinal(ofs + sizeof(phdr) + type_size((enum ap_var_type)phdr.type));
    eeprom_write_check(ap, ofs+sizeof(phdr), type_size((enum ap_var_type)phdr.type));
    eeprom_write_check(&phdr, ofs, sizeof(phdr));
    return true;
}
Esempio n. 8
0
END_TEST

START_TEST (test_type_size)
{
	Type t;

	t = (Type){INT,0,0};
	ck_assert_int_eq(4, type_size(t));

	t = (Type){REAL,0,0};
	ck_assert_int_eq(8, type_size(t));

	t = (Type){AREAL,4,8};
	ck_assert_int_eq(40, type_size(t));
}
Esempio n. 9
0
oz::gpu_image oz::cpu_image::gpu() const {
    if (!is_valid()) return gpu_image();
    gpu_image dst(size(), format(), type_size());
    cudaMemcpy2D(dst.ptr<void>(), dst.pitch(), ptr<void>(), pitch(),
                 row_size(), h(), cudaMemcpyHostToDevice);
    return dst;
}
Esempio n. 10
0
oz::cpu_image oz::gpu_image::cpu() const {
    if (!is_valid()) return cpu_image();
    cpu_image dst(size(), format(), type_size());
    OZ_CUDA_SAFE_CALL(cudaMemcpy2D(dst.ptr<void>(), dst.pitch(), ptr<void>(), pitch(),
                                   row_size(), h(), cudaMemcpyDeviceToHost));
    return dst;
}
Esempio n. 11
0
bool AS_Param::load(void)
{
     uint8_t idx;
    const struct AS_Param::Info *info = find_var_info();
    if (info == NULL) {
        // we don't have any info on how to load it
        return false;
    }

    struct Param_header phdr;

 
    phdr.type = info->type;

    phdr.key  = info->key;

    // scan EEPROM to find the right location
    uint16_t ofs;
    if (!scan(&phdr, &ofs)) {
         set_value((enum as_var_type)phdr.type, (void*) info->ptr,  info->value);

        return false;
    }

    
    AS_Param *ap;
    ap = this;
    if (idx != 0) {
        ap = (AS_Param *)((uintptr_t)ap) - (idx*sizeof(float));
    }

    // found it
    eeprom_read_block(ap,(void*)(ofs+sizeof(phdr)), type_size((enum as_var_type)phdr.type));
    return true;
}
Esempio n. 12
0
/*===========================================================================*/
void store_identifier_table()
{
   identifier_info_type *idinfo,*idovf;
   relative_address_type reladdr;
   long count;
   object_table_type ooo,ooostore;
   type_flagword_type sc;
   Memix ixid;
   Boolean is_array,is_double;
   /*-------------------------------------------------------*/
   idinfo=identifier_table;
   idovf=idinfo+nele_identifier_table;
   for (ixid=0;idinfo<idovf;++idinfo,++ixid){
      ooo = cvt_to_object_table_type((*idinfo).flags);
      if (bitset((*idinfo).flags,SSVAR_TYPE)) ooo = OBJ_SOFF_DATA;
      sc = ooo;
      if (sc == OBJ_SOFF_DATA)
         count = 1;
      else{
         DECIDE_IS_ARRAY_IS_DOUBLE(idinfo);
         count = 1;
         if (is_array){
            count = dim_range((*idinfo).index.dims.first);
            if (is_double) count *= dim_range((*idinfo).index.dims.second);}}
      Set_ooostore();
      if ((*idinfo).ptr.vvv==NULL) reladdr=NIX_ADDR;
      else reladdr =
         store_in_object_file(ooostore,(*idinfo).ptr.vvv,type_size(sc),count);
      (*idinfo).ptr.relative_address = reladdr;}
   store_in_object_file(OBJ_IDTABLE,(void *) identifier_table,
                        sizeof(identifier_info_type),nele_identifier_table);
   /*-------------------------------------------------------*/
}
Esempio n. 13
0
void decl_size_align_inc_bitfield(decl *d, unsigned *const sz, unsigned *const align)
{
	type *ty = decl_type_for_bitfield(d);

	*sz = type_size(ty, NULL);
	*align = type_align(ty, NULL);
}
Esempio n. 14
0
int initialize() {
	sample_t d_type;

	if (param_get_int_name("data_type",&data_type)) {
		moderror("Error getting parameter data_type\n");
		return -1;
	}

	if (type_param_2_type(data_type,&d_type)) {
		moderror_msg("Invalid data_type parameter %d\n",data_type);
		return -1;
	}
	input_sample_sz = type_size(d_type);
	output_sample_sz = input_sample_sz;

	if (param_get_int_name("nof_inputs",&nof_inputs)) {
		moderror("Error getting parameter nof_inputs\n");
		return -1;
	}
	nof_input_itf = nof_inputs;
	if (nof_inputs > NOF_INPUT_ITF) {
		moderror_msg("Only %d interfaces are supported. nof_inputs=%d\n",NOF_INPUT_ITF,nof_inputs);
		return -1;
	}
	memset(input_padding_pre,0,sizeof(int)*nof_inputs);
	return 0;
}
Esempio n. 15
0
static
ptr_inc_sz(type) {
    if ( type[0] == '[]' || type[0] == '*' )
        return type_size( type[3] );
    else
        return 1;
}
Esempio n. 16
0
// scan the EEPROM looking for a given variable by header content
// return true if found, along with the offset in the EEPROM where
// the variable is stored
// if not found return the offset of the sentinal, or
bool AP_Param::scan(const AP_Param::Param_header *target, uint16_t *pofs)
{
    struct Param_header phdr;
    uint16_t ofs = sizeof(AP_Param::EEPROM_header);
    while (ofs < _eeprom_size) {
        hal.storage->read_block(&phdr, ofs, sizeof(phdr));
        if (phdr.type == target->type &&
            phdr.key == target->key &&
            phdr.group_element == target->group_element) {
            // found it
            *pofs = ofs;
            return true;
        }
        // note that this is an ||, not an &&, as this makes us more
        // robust to power off while adding a variable to EEPROM
        if (phdr.type == _sentinal_type ||
            phdr.key == _sentinal_key ||
            phdr.group_element == _sentinal_group) {
            // we've reached the sentinal
            *pofs = ofs;
            return false;
        }
        ofs += type_size((enum ap_var_type)phdr.type) + sizeof(phdr);
    }
    *pofs = ~0;
    serialDebug("scan past end of eeprom");
    return false;
}
Esempio n. 17
0
static
subscript(stream, node, need_lval) {
    auto type = node[3][2];  /* type being subscripted */

    /* For (hopefully temporary) compatibility with stage-4, we allow an 
     * implicit int to be dereferenced as an int*. */
    extern compat_flag;
    auto elt_sz = compat_flag && type == implct_int() ? 4 
        : type_size( type[3] );        /* remove * or [] from type */

    auto sz = type_size( node[2] );

    scale_elt(stream, elt_sz, 1);
    pop_add(stream, 0, 4);
    dereference(stream, sz, need_lval);
}
Esempio n. 18
0
const out_val *out_aalloct(out_ctx *octx, type *ty)
{
	return out_aalloc(octx,
			type_size(ty, NULL),
			type_align(ty, NULL),
			ty);
}
Esempio n. 19
0
File: dt.c Progetto: Govelius/dmd
void init_common(symbol *s)
{
    //printf("init_common('%s')\n", s->Sident);
    dtnzeros(&s->Sdt,type_size(s->Stype));
    if (s->Sdt)
        s->Sdt->dt = DT_common;
}
Esempio n. 20
0
// convert one old vehicle parameter to new object parameter
void AP_Param::convert_old_parameter(const struct ConversionInfo *info)
{

    // find the old value in EEPROM.
    uint16_t pofs;
    AP_Param::Param_header header;
    header.type = PGM_UINT8(&info->type);
    header.key = PGM_UINT8(&info->old_key);
    header.group_element = PGM_UINT8(&info->old_group_element);
    if (!scan(&header, &pofs)) {
        // the old parameter isn't saved in the EEPROM. It was
        // probably still set to the default value, which isn't stored
        // no need to convert
        return;
    }

    // load the old value from EEPROM
    uint8_t old_value[type_size((enum ap_var_type)header.type)];
    _storage.read_block(old_value, pofs+sizeof(header), sizeof(old_value));
    const AP_Param *ap = (const AP_Param *)&old_value[0];

    // find the new variable in the variable structures
    enum ap_var_type ptype;
    AP_Param *ap2;
    ap2 = find_P((const prog_char_t *)&info->new_name[0], &ptype);
    if (ap2 == NULL) {
        hal.console->printf_P(PSTR("Unknown conversion '%s'\n"), info->new_name);
        return;
    }

    // see if we can load it from EEPROM
    if (ap2->load()) {
        // the new parameter already has a value set by the user, or
        // has already been converted
        return;
    }

    // see if they are the same type
    if (ptype == (ap_var_type)header.type) {
        // copy the value over only if the new parameter does not already
        // have the old value (via a default).
        if (memcmp(ap2, ap, sizeof(old_value)) != 0) {
            memcpy(ap2, ap, sizeof(old_value));
            // and save
            ap2->save();
        }
    } else if (ptype <= AP_PARAM_FLOAT && header.type <= AP_PARAM_FLOAT) {
        // perform scalar->scalar conversion
        float v = ap->cast_to_float((enum ap_var_type)header.type);
        if (!is_equal(v,ap2->cast_to_float(ptype))) {
            // the value needs to change
            set_value(ptype, ap2, v);
            ap2->save();
        }
    } else {
        // can't do vector<->scalar conversion, or different vector types
        hal.console->printf_P(PSTR("Bad conversion type '%s'\n"), info->new_name);
    }
}
Esempio n. 21
0
def_t *
emit_structure (const char *name, int su, struct_def_t *defs, type_t *type,
				void *data, storage_class_t storage)
{
	int         i, j;
	int         saw_null = 0;
	int         saw_func = 0;
	symbol_t   *struct_sym;
	symbol_t   *field_sym;
	def_t      *struct_def;
	def_t       field_def;

	name = save_string (name);
	if (!type)
		type = make_structure (0, su, defs, 0)->type;
	if (!is_struct (type) || (su == 's' && type->meta != ty_struct)
		|| (su == 'u' && type->meta != ty_union))
		internal_error (0, "structure %s type mismatch", name);
	for (i = 0, field_sym = type->t.symtab->symbols; field_sym;
		 i++, field_sym = field_sym->next) {
		if (!defs[i].name)
			internal_error (0, "structure %s unexpected end of defs", name);
		if (field_sym->type != defs[i].type)
			internal_error (0, "structure %s.%s field type mismatch", name,
							defs[i].name);
		if ((!defs[i].emit && saw_func) || (defs[i].emit && saw_null))
			internal_error (0, "structure %s mixed emit/copy", name);
		if (!defs[i].emit)
			saw_null = 1;
		if (defs[i].emit)
			saw_func = 1;
	}
	if (defs[i].name)
		internal_error (0, "structure %s too many defs", name);
	if (storage != sc_global && storage != sc_static)
		internal_error (0, "structure %s must be global or static", name);

	struct_sym = make_symbol (name, type, pr.far_data, storage);

	struct_def = struct_sym->s.def;
	if (struct_def->initialized)
		internal_error (0, "structure %s already initialized", name);
	struct_def->initialized = struct_def->constant = 1;
	struct_def->nosave = 1;

	for (i = 0, field_sym = type->t.symtab->symbols; field_sym;
		 i++, field_sym = field_sym->next) {
		field_def.type = field_sym->type;
		field_def.name = save_string (va ("%s.%s", name, field_sym->name));
		field_def.space = struct_def->space;
		field_def.offset = struct_def->offset + field_sym->s.offset;
		if (!defs[i].emit) {
			//FIXME relocs? arrays? structs?
			pr_type_t  *val = (pr_type_t *) data;
			memcpy (D_POINTER (void, &field_def), val,
					type_size (field_def.type) * sizeof (pr_type_t));
			data = &val[type_size (field_def.type)];
		} else {
			if (is_array (field_def.type)) {
Esempio n. 22
0
File: type.c Progetto: tomtix/uuc
static struct type *type_new(enum enum_type et)
{
    struct type *t = calloc(sizeof *t, 1);
    t->type = et;
    t->size = type_size(t);
    t->is_vector = false; // the default
    return t;
}
Esempio n. 23
0
File: type.c Progetto: aunali1/exopc
size_t type_to_blocks(xn_elem_t type, int nelem) {
	long size;

	if((size = type_size(type)) < 0)
		fatal(Type must be in catalogue!);

        return bytes_to_blocks(nelem * size);
}
Esempio n. 24
0
/* Identical to nir_assign_var_locations_packed except that it assigns
 * locations to the variables that are used 100% directly first and then
 * assigns locations to variables that are used indirectly.
 */
void
nir_assign_var_locations_scalar_direct_first(nir_shader *shader,
                                             struct exec_list *var_list,
                                             unsigned *direct_size,
                                             unsigned *size)
{
   struct set *indirect_set = _mesa_set_create(NULL, _mesa_hash_pointer,
                                               _mesa_key_pointer_equal);

   nir_foreach_overload(shader, overload) {
      if (overload->impl)
         nir_foreach_block(overload->impl, mark_indirect_uses_block,
                           indirect_set);
   }

   unsigned location = 0;

   foreach_list_typed(nir_variable, var, node, var_list) {
      if (var->data.mode == nir_var_uniform && var->interface_type != NULL)
         continue;

      if (_mesa_set_search(indirect_set, var))
         continue;

      var->data.driver_location = location;
      location += type_size(var->type);
   }

   *direct_size = location;

   foreach_list_typed(nir_variable, var, node, var_list) {
      if (var->data.mode == nir_var_uniform && var->interface_type != NULL)
         continue;

      if (!_mesa_set_search(indirect_set, var))
         continue;

      var->data.driver_location = location;
      location += type_size(var->type);
   }

   *size = location;

   _mesa_set_destroy(indirect_set, NULL);
}
Esempio n. 25
0
static
add_op(stream, node, is_ass, argsz) {
    auto op = node[0];

    /* Pointer plus integer needs scaling.  We canonicalised this during
     * parsing so the pointer is always the first arg which is in node[3]. */
    if ( is_pointer( node[3][2] ) && is_integral( node[4][2] ) )
        scale_elt( stream, type_size( node[3][2][3] ), 1 );
   
    if ( op == '-' || op == '-=' )
        pop_sub(stream, is_ass, argsz);
    else 
        pop_add(stream, is_ass, argsz);

    /* Pointer minus pointer needs scaling down. */
    if ( is_pointer( node[3][2] ) && is_pointer( node[4][2] ) )
        scale_elt( stream, type_size( node[3][2][3] ), -1 );
}
Esempio n. 26
0
File: type.c Progetto: michelf/dmd
int type_jparam(type *t)
{
    targ_size_t sz;
    type_debug(t);
    return tyjparam(t->Tty) ||
                ((tybasic(t->Tty) == TYstruct || tybasic(t->Tty) == TYarray) &&
                 (sz = type_size(t)) <= NPTRSIZE &&
                 (sz == 1 || sz == 2 || sz == 4 || sz == 8));
}
Esempio n. 27
0
bool 
Frame::has_references () const
{
  std::set<symbol> all;
  entries (all);
  
  for (std::set<symbol>::const_iterator i = all.begin ();
       i != all.end ();
       i++)
    {
      const symbol key = *i;
      if (is_reference (key))
        return true;;
      if (!check (key))
        continue;
      
      Attribute::type type = lookup (key);
      int size = type_size (key);
      switch (type)
        {
        case Attribute::Submodel:
          if (size == Attribute::Singleton)
            {
              if (submodel (key).has_references ())
                return true;
            }
          else
            {
              const std::vector<boost::shared_ptr<const FrameSubmodel> >& models
                = submodel_sequence (key);
              for (size_t i = 0; i < models.size (); i++)
                if (models[i]->has_references ())
                  return true;
            }
          break;
        case Attribute::Model:
          if (size == Attribute::Singleton)
            {
              if (model (key).has_references ())
                return true;
            }
          else
            {
              const std::vector<boost::shared_ptr<const FrameModel> >& models
                = model_sequence (key);
              for (size_t i = 0; i < models.size (); i++)
                if (models[i]->has_references ())
                  return true;
            }
          break;
        default:
          break;
        }
    }
  return false;
}
Esempio n. 28
0
static
unary_post(stream, node, need_lval) {
    auto sz = type_size(node[2]), elt_sz = ptr_inc_sz(node[2]);

    expr_code( stream, node[3], 1 );

    if      ( node[0] == '++' ) postfix_inc( stream, sz,  elt_sz );
    else if ( node[0] == '--' ) postfix_inc( stream, sz, -elt_sz );
    else int_error( "Unknown operator: '%Mc'", node[0] );
}
Esempio n. 29
0
unsigned decl_size(decl *d)
{
	if(type_is_void(d->ref))
		die_at(&d->where, "%s is void", d->spel);

	if(!type_is(d->ref, type_func) && d->bits.var.field_width)
		die_at(&d->where, "can't take size of a bitfield");

	return type_size(d->ref, &d->where);
}
Esempio n. 30
0
int main()
{
	object_t o;

	init();
	o = make_env(scheme_null,scheme_null);
	printf("object->type: %s\n",type_name(o));
	printf("object->type: %d\n",type_size(o));
	return 0;
}