예제 #1
0
파일: typecheck.c 프로젝트: Saruta/a2c
bool check_prog(struct prog* prog, struct symtable *syms)
{
  bool correct = true;
  fill_std_types(syms);
  fill_std_fun(syms);
  constdecllist_t consts = prog->entry_point->const_decls;

  for(unsigned i =0; i < consts.size; ++i)
    correct = correct && check_const(list_nth(consts,i), syms, true);
  correct = correct && add_types(syms, prog->entry_point->type_decls);
  correct = correct && add_variables(syms, prog->entry_point->var_decl, true, false, false);
  for(unsigned i = 0; i < prog->algos.size; ++i)
  {
    struct algo* al = list_nth(prog->algos, i);
    struct function* f = malloc(sizeof(struct function));
    f->ident = al->ident;
    f->ret = find_type(syms->types, al->return_type);
    f->arg = get_args(al->declarations->param_decl, syms);
    add_function(syms->functions, f);
  }
  for (unsigned i = 0; i < prog->entry_point->instructions.size; ++i)
    if (!check_inst(
          prog->entry_point->instructions.data[i],
          find_type(syms->types, TYPE_INT), syms))
      correct = false;
  for(unsigned i = 0; i < prog->algos.size; ++i)
  {
    struct algo* al = list_nth(prog->algos, i);
    if (!check_algo(al, syms))
      correct = false;
  }
  return correct;
}
예제 #2
0
파일: typecheck.c 프로젝트: Saruta/a2c
args_t get_args(struct param_decl *params, struct symtable *syms)
{
  args_t args;
  list_init(args);
  for (unsigned i = 0; i < params->local_param.size; ++i)
  {
    for (unsigned j = 0; j < params->local_param.data[i]->var_idents.size; ++j)
    {
      struct argument *arg = malloc(sizeof(struct argument));
      arg->global = false;
      arg->type = find_type(syms->types, params->local_param.data[i]->type_ident);
      list_push_back(args, arg);
    }
  }
  for (unsigned i = 0; i < params->global_param.size; ++i)
  {
    for (unsigned j = 0; j < params->global_param.data[i]->var_idents.size; ++j)
    {
      struct argument *arg = malloc(sizeof(struct argument));
      arg->global = true;
      arg->type = find_type(syms->types, params->global_param.data[i]->type_ident);
      list_push_back(args, arg);
    }
  }
  return args;
}
예제 #3
0
파일: typecheck.c 프로젝트: Saruta/a2c
bool equal_types(char *tname1, char *tname2, struct symtable *syms)
{
  struct type *t1 = find_type(syms->types, tname1);
  struct type *t2 = find_type(syms->types, tname2);
  return ((t1 && t1->type_kind == pointer_t && strcmp(tname2, "nul") == 0)
      || (t2 && t2->type_kind == pointer_t && strcmp(tname1, "nul") == 0)
      || strcmp(tname1, tname2) == 0);
}
예제 #4
0
int get_topics_for_keyword(THD *thd, TABLE *topics, TABLE *relations,
			   struct st_find_field *find_fields, int16 key_id,
			   List<String> *names,
			   String *name, String *description, String *example)
{
  uchar buff[8];	// Max int length
  int count= 0;
  int iindex_topic, iindex_relations;
  Field *rtopic_id, *rkey_id;
  DBUG_ENTER("get_topics_for_keyword");

  if ((iindex_topic= find_type((char*) primary_key_name,
			       &topics->s->keynames, 1+2)-1)<0 ||
      (iindex_relations= find_type((char*) primary_key_name,
				   &relations->s->keynames, 1+2)-1)<0)
  {
    my_message(ER_CORRUPT_HELP_DB, ER(ER_CORRUPT_HELP_DB), MYF(0));
    DBUG_RETURN(-1);
  }
  rtopic_id= find_fields[help_relation_help_topic_id].field;
  rkey_id=   find_fields[help_relation_help_keyword_id].field;

  topics->file->ha_index_init(iindex_topic,1);
  relations->file->ha_index_init(iindex_relations,1);

  rkey_id->store((longlong) key_id, TRUE);
  rkey_id->get_key_image(buff, rkey_id->pack_length(), Field::itRAW);
  int key_res= relations->file->index_read_map(relations->record[0],
                                               buff, (key_part_map) 1,
                                               HA_READ_KEY_EXACT);

  for ( ;
        !key_res && key_id == (int16) rkey_id->val_int() ;
	key_res= relations->file->index_next(relations->record[0]))
  {
    uchar topic_id_buff[8];
    longlong topic_id= rtopic_id->val_int();
    Field *field= find_fields[help_topic_help_topic_id].field;
    field->store((longlong) topic_id, TRUE);
    field->get_key_image(topic_id_buff, field->pack_length(), Field::itRAW);

    if (!topics->file->index_read_map(topics->record[0], topic_id_buff,
                                      (key_part_map)1, HA_READ_KEY_EXACT))
    {
      memorize_variant_topic(thd,topics,count,find_fields,
			     names,name,description,example);
      count++;
    }
  }
  topics->file->ha_index_end();
  relations->file->ha_index_end();
  DBUG_RETURN(count);
}
예제 #5
0
파일: ombre.c 프로젝트: fave-r/RT
int		ombre(t_obj *obj, t_eye *eye, t_light l, t_spot *cur_spot)
{
  t_obj		*c_obj;
  t_vec3	*inter;
  t_vec3	*vec_light;

  c_obj = obj->next;
  inter = xmalloc(sizeof(*inter));
  inter = inter_obj(inter, eye, l.k2);
  vec_light = to_light_(inter, cur_spot);
  while (c_obj != NULL)
    {
      if (c_obj != l.clos_obj
	  && my_strcmp(l.clos_obj->info->type, "CONE") != 0)
        {
	  translate_pos(inter, c_obj->pos);
	  l.k2 = tab[find_type(c_obj)].inter(inter, vec_light, c_obj->info->R);
	  translate_pos_inv(inter, c_obj->pos);
          if (l.k2 > ZERO && l.k2 < 1 + ZERO)
	    return (free_inter(1, inter, vec_light));
        }
      c_obj = c_obj->next;
    }
  return (free_inter(0, inter, vec_light));
}
예제 #6
0
파일: shadow.c 프로젝트: rebryant/Cloud-BDD
/* Only call this when removing r from unique table */
void shadow_deref(shadow_mgr mgr, ref_t r) {
    if (!mgr->do_cudd)
	return;
    DdNode *n = get_ddnode(mgr, r);
    dd_type_t dtype = find_type(mgr, r);

#if RPT >= 5
    char buf[24];
    shadow_show(mgr, r, buf);
    report(5, "Deleting reference %s for node %p", buf, n);
#endif

    unreference_dd(mgr, n, dtype);

    if (!do_ref(mgr))
	return;

    keyvalue_remove(mgr->c2r_table, (word_t ) n, NULL, NULL);
    keyvalue_remove(mgr->r2c_table, (word_t ) r, NULL, NULL);


    if (dtype == IS_BDD) {
	ref_t nr = shadow_negate(mgr, r);
	DdNode *nn = get_ddnode(mgr, nr);
#if RPT >= 5
	shadow_show(mgr, nr, buf);
	report(5, "Deleting reference %s for node %p", buf, nn);
#endif
	keyvalue_remove(mgr->c2r_table, (word_t ) nn, NULL, NULL);
	keyvalue_remove(mgr->r2c_table, (word_t ) nr, NULL, NULL);
	unreference_dd(mgr, nn, IS_BDD);
    }
}
예제 #7
0
// create new type in extracter
void extracter_t::find_type(const char *tname1, const char *varname)
	{
		char *tname = new char [255];
		strcpy(tname, tname1);

		//cout << tname << endl;
		if (typexist(tname)) return;
		if (typexist(nop(tname))) return;
		char bf[255];
		char bf1[255];
		char bf2[255];
		if (instring("vector<", tname))
		{
			tospace('<', tname);
			tospace('>', tname);
			sscanf(tname,"%s %s", bf1, bf);
			type_t *t = new type_t(-1, tname1, type);
			t->vec = 1;
			t->basetype = basetype(nop(bf));
			t->addfield(bf, varname);
	//		cout << bf;
			type->push_back(t);
			//find_type(nop(bf), varname);
			find_type(nop(bf), varname);
			//return;
		}
		//else cout << bf << endl;
		else find_type_infile(nop(tname1));

	}
예제 #8
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;
}
static gchar *get_text_for_data(RyostklconfigProDimnessSelector *dimness_selector) {
	RyostklconfigProDimnessSelectorPrivate *priv = dimness_selector->priv;
	GtkTreeIter iter;
	gboolean valid;
	guint type;
	GtkTreeModel *model;
	gchar *text;

	type = priv->dimness_type;

	switch (type) {
	case RYOS_LIGHT_DIMNESS_TYPE_MACRO:
		text = g_strdup_printf(_("Macro: %s/%s"), priv->light_macro->macroset_name, priv->light_macro->macro_name);
		break;
	default:
		model = gtk_combo_box_get_model(GTK_COMBO_BOX(dimness_selector));
		valid = find_type(model, type, &iter);
		if (valid)
			text = get_title(model, &iter);
		else
			text = g_strdup_printf(_("FIXME (0x%02x)"), type);
		break;
	}

	return text;
}
예제 #10
0
파일: typelib.c 프로젝트: Blumfield/TBCPvP
my_ulonglong find_typeset(char *x, TYPELIB *lib, int *err)
{
  my_ulonglong result;
  int find;
  char *i;
  DBUG_ENTER("find_set");
  DBUG_PRINT("enter",("x: '%s'  lib: 0x%lx", x, (long) lib));

  if (!lib->count)
  {
    DBUG_PRINT("exit",("no count"));
    DBUG_RETURN(0);
  }
  result= 0;
  *err= 0;
  while (*x)
  {
    (*err)++;
    i= x;
    while (*x && !is_field_separator(*x))
      x++;
    if (x[0] && x[1])      /* skip separator if found */
      x++;
    if ((find= find_type(i, lib, FIND_TYPE_COMMA_TERM) - 1) < 0)
      DBUG_RETURN(0);
    result|= (ULL(1) << find);
  }
  *err= 0;
  DBUG_RETURN(result);
} /* find_set */
예제 #11
0
파일: typecheck.c 프로젝트: Saruta/a2c
bool check_algo(struct algo* al, struct symtable *syms)
{
  bool correct = true;
  struct function* f = malloc(sizeof(struct function));
  f->ret = find_type(syms->types, al->return_type);
  struct declarations* decl = al->declarations;

  if(decl != NULL)
  {
    struct param_decl* p_decl = decl->param_decl;
    vardecllist_t loc = p_decl->local_param;
    vardecllist_t glo = p_decl->global_param;
    vardecllist_t vars = decl->var_decl;
    typedecllist_t typelist = decl->type_decls;
    constdecllist_t consts = decl->const_decls;
    for(unsigned i =0; i < consts.size; ++i)
      correct = correct && check_const(list_nth(consts,i), syms, true);
    if(loc.size > 0)
      correct = add_variables(syms, loc, false, false, false) && correct;
    if(glo.size > 0)
      correct = add_variables(syms, glo, false, true, false) && correct;
    correct = add_types(syms, typelist) && correct;
    correct = add_variables(syms, vars, false, false, false) && correct;
  }
  for(unsigned i = 0; i < al->instructions.size; i++)
    if(!check_inst(list_nth(al->instructions, i), f->ret, syms))
      correct = false;

  remove_decls(syms, decl);
  free(f);
  return correct;
}
예제 #12
0
파일: compiler.c 프로젝트: lerno/coil
static void parse_type_assignment()
{
	int local_id = compiler.num_locals++;
	Local *local = &(compiler.locals[local_id]);
	local->name = parser.previous.start;
	local->length = parser.previous.length;

	// Consume the :
	advance();
	consume(TOKEN_IDENTIFIER, "Expected type");

    // Get the identifier
    Type *type = find_type(&parser.previous);
    if (!type)
    {
        error_at(&parser.previous, "Unknown type");
        return;

    }
	// Ignore type for now, otherwise it's not stored in prev

	// Consume the assignment
	consume(TOKEN_ASSIGN, "Expected =");

	advance();
	if (parser.current.type == TOKEN_NO_INIT)
	{
		// No init!
		return;
	}
	expression_after_advance();
    // Conversion here!
	emit_byte(OP_ASSIGN);
	emit_byte((uint8_t)local_id);
}
예제 #13
0
파일: typelib.c 프로젝트: Blumfield/TBCPvP
static uint parse_name(const TYPELIB *lib, const char **strpos, const char *end)
{
  const char *pos= *strpos;
  uint find= find_type(pos, lib, FIND_TYPE_COMMA_TERM);
  for (; pos != end && *pos != '=' && *pos !=',' ; pos++);
  *strpos= pos;
  return find;
}
예제 #14
0
파일: obj_list.c 프로젝트: Succubae/42
t_obj	*build_lnk(char *buf)
{
	t_obj	*lst;

	lst = (t_obj*)malloc(sizeof(t_obj));
	lst = find_type(lst, buf);
	lst->next = NULL;
	return (lst);
}
예제 #15
0
파일: shadow.c 프로젝트: rebryant/Cloud-BDD
void shadow_show(shadow_mgr mgr, ref_t r, char *buf) {
    if (do_ref(mgr)) {
	ref_show(r, buf);
    } else {
	dd_type_t dtype = find_type(mgr, r);
	DdNode *n = ref2dd(mgr, r);
	sprintf(buf, "%c%p", dtype == IS_ZDD ? 'Z' : dtype == IS_ADD ? 'A' : 'B', n);
    }		
}
예제 #16
0
int type_length(string type)
{
  int count;
  char *tp;

  count = 0;
  for (tp = type; *tp != (char) NULL; tp++)	// loop over all elements
    count += find_type(tp)->size;		// add size of each element
  return (count);
}
예제 #17
0
파일: shadow.c 프로젝트: rebryant/Cloud-BDD
ref_t shadow_absval(shadow_mgr mgr, ref_t r) {
    if (do_ref(mgr))
	return REF_ABSVAL(r);
    else {
	dd_type_t dtype = find_type(mgr, r);
	DdNode *n = ref2dd(mgr, r);
	DdNode *an = Cudd_Regular(n);
	return dd2ref(an, dtype);
    }
}
예제 #18
0
파일: decoder.c 프로젝트: dpbriggs/mocp
struct decoder *get_decoder (const char *file)
{
    int i;

    i = find_type (file);
    if (i != -1)
        return plugins[i].decoder;

    return NULL;
}
예제 #19
0
파일: module.c 프로젝트: 0bliv10n/s2e
void module_call_init(module_init_type type)
{
    ModuleTypeList *l;
    ModuleEntry *e;

    l = find_type(type);

    QTAILQ_FOREACH(e, l, node) {
        e->init();
    }
}
예제 #20
0
파일: module.c 프로젝트: 0bliv10n/s2e
void register_module_init(void (*fn)(void), module_init_type type)
{
    ModuleEntry *e;
    ModuleTypeList *l;

    e = g_malloc0(sizeof(*e));
    e->init = fn;

    l = find_type(type);

    QTAILQ_INSERT_TAIL(l, e, node);
}
예제 #21
0
Class* VM::new_basic_class(Class* sup) {
    Class *cls = om->new_object_enduring<Class>(G(klass));
    cls->init(shared.inc_class_count());

    if(sup->nil_p()) {
        cls->instance_type(this, Fixnum::from(ObjectType));
        cls->set_type_info(find_type(ObjectType));
    } else {
        cls->instance_type(this, sup->instance_type()); // HACK test that this is always true
        cls->set_type_info(sup->type_info());
    }
    cls->superclass(this, sup);

    return cls;
}
예제 #22
0
void test_release()
{
    Block block;
    block.compile("type T = handle_type()");
    block.compile("def T.release(self)");

    install_function(&block, "T.release", my_release_func);

    Type* T = find_type(&block, "T");
    test_assert(T != NULL);
    test_assert(find_method(NULL, T, "release") != NULL);

    gTimesReleaseCalled = 0;

    Value value;
    make(T, &value);
    test_assert(is_handle(&value));
    test_equals(gTimesReleaseCalled, 0);

    set_int(handle_get_value(&value), 5);
    set_null(&value);

    test_equals(gTimesReleaseCalled, 1);

    gTimesReleaseCalled = 0;

    Value value2;
    make(T, &value);
    copy(&value, &value2);

    test_assert(gTimesReleaseCalled == 0);

    set_null(&value2);
    test_assert(gTimesReleaseCalled == 0);

    set_null(&value);
    test_assert(gTimesReleaseCalled == 1);

    gTimesReleaseCalled = 0;
    make(T, &value);
    make(T, &value2);

    set_null(&value);
    test_assert(gTimesReleaseCalled == 1);

    set_null(&value2);
    test_assert(gTimesReleaseCalled == 2);
}
예제 #23
0
파일: shadow.c 프로젝트: rebryant/Cloud-BDD
static DdNode *ref2dd(shadow_mgr mgr, ref_t r) {
    dd_type_t dtype = find_type(mgr, r);
    switch (dtype) {
    case IS_BDD:
	break;
    case IS_ZDD:
	r -= 2;
	break;
    case IS_ADD:
	r -= 3;
	break;
    default:
	err(false, "Internal DD error.  No DD type %d", dtype);
    }
    return (DdNode *) r;
}
예제 #24
0
파일: main.cpp 프로젝트: HSEFZ/CloudIDE
int main (int argc, char** argv) {
	if (argc == 3) {
		std::string filename = argv [1];
		std::string output = argv [2];
		
		std::string type = get_type (filename);
		
		if (type == "" || !find_type (type)) {
			type = "original";
		}
		
		read_color (type_location (type));
		
		print_highlight (filename, output);
	}
}
예제 #25
0
파일: default.c 프로젝트: isleon/Jaxer
static int handle_default_option(void *in_ctx, const char *group_name,
                                 const char *option)
{
  char *tmp;
  struct handle_option_ctx *ctx= (struct handle_option_ctx *) in_ctx;

  if (find_type((char *)group_name, ctx->group, 3))
  {
    if (!(tmp= alloc_root(ctx->alloc, (uint) strlen(option) + 1)))
      return 1;
    if (insert_dynamic(ctx->args, (gptr) &tmp))
      return 1;
    strmov(tmp, option);
  }

  return 0;
}
예제 #26
0
void				get_index(char **tab, int *t, char *type)
{
	int		i;
	char	*s;

	i = -1;
	if (tab)
	{
		while (tab[++i])
		{
			if ((s = find_type(tab[i], type, SEP_2)))
			{
				*t++ = i;
				free(s);
			}
		}
	}
}
예제 #27
0
파일: rush2.c 프로젝트: lhurt51/42-piscine
int		main(void)
{
	int		row;
	int		col;
	char	*ret;

	row = 0;
	col = 0;
	ret = find_dimensions(&row, &col);
	if ((row * col) >= 1000000000)
	{
		ft_putstr("aucune");
		return (1);
	}
	find_type(ret, row, col);
	ft_putchar('\n');
	return (0);
}
예제 #28
0
int					obj_number(char **tab, char *type)
{
	int		len;
	char	*s;

	len = 0;
	if (tab)
	{
		while (*tab)
		{
			if (((s = find_type(*tab++, type, SEP_2))))
			{
				len++;
				free(s);
			}
		}
	}
	return (len);
}
예제 #29
0
    std::shared_ptr<Object<Impl>>
    Module_scanner<Impl>::create_object(ast::Variable_def const& node) {
      std::shared_ptr<Object<Impl>> obj(new Object<Impl>());

      // get name
      obj->name = dynamic_cast<ast::Identifier const&>(node.identifier()).identifier();
      if( m_mod.objects.count(obj->name) > 0 )
        throw std::runtime_error(std::string("Variable with name ")
            + obj->name
            + std::string(" already exists"));

      // get type
      if( typeid(node.type()) == typeid(ast::Qualified_name) ) {
        auto const& type_name = dynamic_cast<ast::Qualified_name const&>(node.type()).name();

        LOG4CXX_TRACE(this->m_logger, "qualified name of type: "
            << boost::algorithm::join(type_name, "::"));

        if( type_name.size() > 1 ) {
          obj->type = find_by_path(m_mod,
              &Module<Impl>::types,
              type_name);
        } else {
          obj->type = find_type(m_mod, type_name[0]);
        }
        if( !obj->type ) {
          std::stringstream strm;
          strm << node.type().location();
          std::string type_name_join = boost::algorithm::join(type_name, "::");
          strm << ": typename '" << type_name_join << "' not found.";
          throw std::runtime_error(strm.str());
        }
      } else if( typeid(node.type()) == typeid(ast::Array_type) ) {
        auto& ar_type = dynamic_cast<ast::Array_type const&>(node.type());

        obj->type = this->create_array_type(ar_type);
        m_mod.types[obj->type->name] = obj->type;
      } else {
        throw std::runtime_error("Unexpected type of type specification for variable definition.");
      }

      return obj;
    }
예제 #30
0
파일: typelib.c 프로젝트: AllenWeb/mariadb
int find_type_with_warning(const char *x, TYPELIB *typelib, const char *option)
{
  int res;
  const char **ptr;

  if ((res= find_type((char *) x, typelib, FIND_TYPE_BASIC)) <= 0)
  {
    ptr= typelib->type_names;
    if (!*x)
      fprintf(stderr, "No option given to %s\n", option);
    else
      fprintf(stderr, "Unknown option to %s: %s\n", option, x);
    fprintf(stderr, "Alternatives are: '%s'", *ptr);
    while (*++ptr)
      fprintf(stderr, ",'%s'", *ptr);
    fprintf(stderr, "\n");
  }
  return res;
}