Beispiel #1
0
static void set_method_types(reach_t* r, reach_method_t* m,
  pass_opt_t* opt)
{
  AST_GET_CHILDREN(m->r_fun, cap, id, typeparams, params, result, can_error,
    body);

  m->param_count = ast_childcount(params);
  m->params = (reach_param_t*)ponyint_pool_alloc_size(
    m->param_count * sizeof(reach_param_t));

  ast_t* param = ast_child(params);
  size_t i = 0;

  while(param != NULL)
  {
    AST_GET_CHILDREN(param, p_id, p_type);
    m->params[i].type = add_type(r, p_type, opt);
    if(ast_id(p_type) != TK_NOMINAL && ast_id(p_type) != TK_TYPEPARAMREF)
      m->params[i].cap = TK_REF;
    else
      m->params[i].cap = ast_id(cap_fetch(p_type));
    ++i;
    param = ast_sibling(param);
  }

  m->result = add_type(r, result, opt);
}
Beispiel #2
0
static void handle_stack(reachable_method_stack_t* s, reachable_types_t* r,
  uint32_t* next_type_id)
{
  while(s != NULL)
  {
    reachable_method_t* m;
    s = reachable_method_stack_pop(s, &m);

    AST_GET_CHILDREN(m->r_fun, cap, id, typeparams, params, result, can_error,
      body);

    m->param_count = ast_childcount(params);
    m->params = (reachable_type_t**)ponyint_pool_alloc_size(
      m->param_count * sizeof(reachable_type_t*));

    ast_t* param = ast_child(params);
    size_t i = 0;

    while(param != NULL)
    {
      AST_GET_CHILDREN(param, p_id, p_type);
      m->params[i++] = add_type(&s, r, next_type_id, p_type);
      param = ast_sibling(param);
    }

    m->result = add_type(&s, r, next_type_id, result);
    reachable_expr(&s, r, next_type_id, body);
  }
}
Beispiel #3
0
void collect_class(Stats& stats, const Index& index, const php::Class& cls) {
  ++stats.totalClasses;
  if (cls.attrs & AttrPersistent) {
    ++stats.persistentClasses;
  }
  if (cls.attrs & AttrUnique) {
    ++stats.uniqueClasses;
  }
  stats.totalMethods += cls.methods.size();

  for (auto& kv : index.lookup_private_props(&cls)) {
    add_type(stats.privateProps, kv.second);
  }
  for (auto& kv : index.lookup_private_statics(&cls)) {
    add_type(stats.privateStatics, kv.second);
  }

  for (auto& prop : cls.properties) {
    if (prop.attrs & AttrStatic) {
      ++stats.totalSProps;
      if (prop.attrs & AttrPersistent) {
        if (prop.attrs & AttrPublic)    ++stats.persistentSPropsPub;
        if (prop.attrs & AttrProtected) ++stats.persistentSPropsProt;
        if (prop.attrs & AttrPrivate)   ++stats.persistentSPropsPriv;
      }
    }
  }
}
Beispiel #4
0
static void reachable_ffi(reachable_method_stack_t** s, reachable_types_t* r,
  uint32_t* next_type_id, ast_t* ast)
{
  AST_GET_CHILDREN(ast, name, return_typeargs, args, namedargs, question);
  ast_t* decl = (ast_t*)ast_data(ast);

  if(decl != NULL)
  {
    AST_GET_CHILDREN(decl, decl_name, decl_ret_typeargs, params, named_params,
      decl_error);

    args = params;
    return_typeargs = decl_ret_typeargs;
  }

  ast_t* return_type = ast_child(return_typeargs);
  add_type(s, r, next_type_id, return_type);

  ast_t* arg = ast_child(args);

  while(arg != NULL)
  {
    if(ast_id(arg) != TK_ELLIPSIS)
    {
      ast_t* type = ast_type(arg);

      if(type == NULL)
        type = ast_childidx(arg, 1);

      add_type(s, r, next_type_id, type);
    }

    arg = ast_sibling(arg);
  }
}
Beispiel #5
0
static void reachable_ffi(reach_t* r, ast_t* ast, pass_opt_t* opt)
{
  AST_GET_CHILDREN(ast, name, return_typeargs, args, namedargs, question);
  ast_t* decl = (ast_t*)ast_data(ast);

  if(decl != NULL)
  {
    AST_GET_CHILDREN(decl, decl_name, decl_ret_typeargs, params, named_params,
      decl_error);

    args = params;
    return_typeargs = decl_ret_typeargs;
  }

  ast_t* return_type = ast_child(return_typeargs);
  add_type(r, return_type, opt);

  ast_t* arg = ast_child(args);

  while(arg != NULL)
  {
    if(ast_id(arg) != TK_ELLIPSIS)
    {
      ast_t* type = ast_type(arg);

      if(type == NULL)
        type = ast_childidx(arg, 1);

      add_type(r, type, opt);
    }

    arg = ast_sibling(arg);
  }
}
Beispiel #6
0
static void setup_types()
{
    add_type("i8", 1);
    add_type("u8", 1);
    add_type("i32", 4);
    add_type("u32", 4);
    add_type("i64", 8);
}
Beispiel #7
0
static void
handle_type (MonoClass *klass, guint32 flags)
{
	int i;
	guint32 missing;
	MonoCustomAttrInfo* cattrs;
	gpointer val = NULL, oldkey = NULL;
	MonoProperty* prop;
	MonoEvent* event;
	MonoMethod* method;
	MonoClassField* field;
	gpointer iter;
	
	if (g_hash_table_lookup_extended (type_table, klass, &oldkey, &val)) {
		missing = flags & ~(GPOINTER_TO_UINT (val));
	} else {
		missing = flags;
	}
	if (!missing)
		return;
	g_hash_table_insert (type_table, klass, GUINT_TO_POINTER (missing));
	if (verbose)
		g_print ("#processing klass: %s.%s\n", klass->name_space, klass->name);
	mono_class_init (klass);
	if (klass->parent)
		add_type (klass->parent);
	if (klass->nested_in)
		add_type (klass->nested_in);
	iter = NULL;
	while ((method = mono_class_get_methods (klass, &iter))) {
		if ((missing & TYPE_METHODS) || strcmp (method->name, ".cctor") == 0)
			add_types_from_method (method);
	}
	if (klass->enumtype) {
		add_field (mono_class_get_field_from_name (klass, "value__"));
	}
	if (force_enums || (missing & TYPE_FIELDS)) {
		iter = NULL;
		while ((field = mono_class_get_fields (klass, &iter)))
			add_field (field);
	}
	iter = NULL;
	while ((prop = mono_class_get_properties (klass, &iter))) {
		cattrs = mono_custom_attrs_from_property (klass, prop);
		handle_cattrs (cattrs);
	}
	iter = NULL;
	while ((event = mono_class_get_events (klass, &iter))) {
		cattrs = mono_custom_attrs_from_event (klass, event);
		handle_cattrs (cattrs);
	}
	for (i = 0; i < klass->interface_count; ++i)
		add_type (klass->interfaces [i]);
	cattrs = mono_custom_attrs_from_class (klass);
	handle_cattrs (cattrs);
}
Beispiel #8
0
static void
add_types_from_signature (MonoMethodSignature *sig)
{
	MonoClass *klass;
	int i;
	for (i = 0; i < sig->param_count; ++i) {
		klass = mono_class_from_mono_type (sig->params [i]);
		add_type (klass);
	}
	klass = mono_class_from_mono_type (sig->ret);
	add_type (klass);
}
usermessage::usermessage(QString msg_arg, int t_arg, QString receiver_arg):
        my_msg(msg_arg), my_type(t_arg), my_user(singleton<netcoupler>().nick), my_receiver(receiver_arg){

    Q_ASSERT_X(my_type & e_NOTICE || my_type & e_PRIVMSG || my_type & e_CTCP || my_type & e_RAWCOMMAND || my_type & e_GARBAGE || my_type & e_SCRIPTCOMMAND, Q_FUNC_INFO, qPrintable(QString::number(my_type)));
    if(my_msg.startsWith("\001ACTION",Qt::CaseInsensitive)){
        add_type(e_ACTION);
        my_msg.remove("\001ACTION",Qt::CaseInsensitive).remove('\001');
    } else if(my_msg.startsWith('\001')){
        add_type(e_CTCP);
        my_msg.remove('\001');
    }
    my_msg=my_msg.simplified();
}
Beispiel #10
0
static void
add_field (MonoClassField *field) {
	MonoClass *k;
	MonoCustomAttrInfo* cattrs;
	gpointer val = NULL, oldkey = NULL;

	if (g_hash_table_lookup_extended (field_table, field, &oldkey, &val))
		return;
	g_hash_table_insert (field_table, field, NULL);
	add_type (field->parent);
	k = mono_class_from_mono_type (field->type);
	add_type (k);
	cattrs = mono_custom_attrs_from_field (field->parent, field);
	handle_cattrs (cattrs);
}
Beispiel #11
0
static reachable_type_t* add_tuple(reachable_method_stack_t** s,
  reachable_types_t* r, uint32_t* next_type_id, ast_t* type)
{
  if(contains_dontcare(type))
    return NULL;

  reachable_type_t* t = reach_type(r, type);

  if(t != NULL)
    return t;

  t = add_reachable_type(r, type);
  t->type_id = ++(*next_type_id);

  t->field_count = (uint32_t)ast_childcount(t->ast);
  t->fields = (reachable_field_t*)calloc(t->field_count,
    sizeof(reachable_field_t));
  size_t index = 0;

  ast_t* child = ast_child(type);

  while(child != NULL)
  {
    t->fields[index].ast = ast_dup(child);
    t->fields[index].type = add_type(s, r, next_type_id, child);;
    index++;

    child = ast_sibling(child);
  }

  return t;
}
Beispiel #12
0
static void add_fields(reachable_method_stack_t** s, reachable_types_t* r,
  uint32_t* next_type_id, ast_t* type)
{
  ast_t* def = (ast_t*)ast_data(type);
  ast_t* members = ast_childidx(def, 4);
  ast_t* member = ast_child(members);

  while(member != NULL)
  {
    switch(ast_id(member))
    {
      case TK_FVAR:
      case TK_FLET:
      case TK_EMBED:
      {
        const char* name = ast_name(ast_child(member));
        ast_t* r_member = lookup(NULL, NULL, type, name);
        assert(r_member != NULL);

        AST_GET_CHILDREN(r_member, id, ftype);
        add_type(s, r, next_type_id, ftype);

        if(r_member != member)
          ast_free_unattached(r_member);

        break;
      }

      default: {}
    }

    member = ast_sibling(member);
  }
}
Beispiel #13
0
static reachable_type_t* add_tuple(reachable_method_stack_t** s,
  reachable_types_t* r, uint32_t* next_type_id, ast_t* type)
{
  if(contains_dontcare(type))
    return NULL;

  const char* type_name = genname_type(type);
  reachable_type_t* t = reach_type(r, type_name);

  if(t != NULL)
    return t;

  t = add_reachable_type(r, type, type_name);
  t->type_id = ++(*next_type_id);

  ast_t* child = ast_child(type);

  while(child != NULL)
  {
    add_type(s, r, next_type_id, child);
    child = ast_sibling(child);
  }

  return t;
}
Beispiel #14
0
static void reachable_method(reachable_method_stack_t** s,
  reachable_types_t* r, uint32_t* next_type_id, ast_t* type,
  const char* name, ast_t* typeargs)
{
  switch(ast_id(type))
  {
    case TK_NOMINAL:
    {
      reachable_type_t* t = add_type(s, r, next_type_id, type);
      add_method(s, t, name, typeargs);
      break;
    }

    case TK_UNIONTYPE:
    case TK_ISECTTYPE:
    {
      ast_t* child = ast_child(type);

      while(child != NULL)
      {
        ast_t* find = lookup_try(NULL, NULL, child, name);

        if(find != NULL)
          reachable_method(s, r, next_type_id, child, name, typeargs);

        child = ast_sibling(child);
      }

      break;
    }

    default:
      assert(0);
  }
}
Beispiel #15
0
void npc::load_info(std::string data)
{
 std::stringstream dump;
 dump << data;
// Standard player stuff
 dump >> id >> posx >> posy >> str_cur >> str_max >> dex_cur >> dex_max >>
         int_cur >> int_max >> per_cur >> per_max >> hunger >> thirst >>
         fatigue >> stim >> pain >> pkill >> radiation >> cash >> recoil >>
         scent >> moves >> underwater >> can_dodge >> oxygen;

 for (int i = 0; i < PF_MAX2; i++)
  dump >> my_traits[i];

 for (int i = 0; i < num_hp_parts; i++)
  dump >> hp_cur[i] >> hp_max[i];
 for (int i = 0; i < num_skill_types; i++)
  dump >> sklevel[i] >> skexercise[i];

 int numill;
 int typetmp;
 disease illtmp;
 dump >> numill;
 for (int i = 0; i < numill; i++) {
  dump >> typetmp >> illtmp.duration;
  illtmp.type = dis_type(typetmp);
  illness.push_back(illtmp);
 }
 int numadd;
 addiction addtmp;
 dump >> numadd;
 for (int i = 0; i < numadd; i++) {
  dump >> typetmp >> addtmp.intensity >> addtmp.sated;
  addtmp.type = add_type(typetmp);
  addictions.push_back(addtmp);
 }
 int numbio;
 bionic biotmp;
 dump >> numbio;
 for (int i = 0; i < numbio; i++) {
  dump >> typetmp >> biotmp.invlet >> biotmp.powered >> biotmp.charge;
  biotmp.id = bionic_id(typetmp);
  my_bionics.push_back(biotmp);
 }
// Special NPC stuff
 int misstmp, flagstmp, agg, bra, col, alt, tru, val, fea;
 dump >> agg >> bra >> col >> alt >> wandx >> wandy >> wandf >> omx >> omy >>
         omz >> mapx >> mapy >> plx >> ply >> goalx >> goaly >> misstmp >>
         tru >> val >> fea >> flagstmp >> fac_id;
 personality.aggression = agg;
 personality.bravery = bra;
 personality.collector = col;
 personality.altruism = alt;
 op_of_u.trust = tru;
 op_of_u.value = val;
 op_of_u.fear = fea;
 mission = npc_mission(misstmp);
 flags = flagstmp;
}
Beispiel #16
0
void EditorHelpIndex::_update_class_list() {

	class_list->clear();
	tree_item_map.clear();
	TreeItem *root = class_list->create_item();
	class_list->set_hide_root(true);

	String filter = search_box->get_text().strip_edges();
	String to_select = "";

	for(Map<String,DocData::ClassDoc>::Element *E=EditorHelp::get_doc_data()->class_list.front();E;E=E->next()) {

		if (filter == "") {
			add_type(E->key(),tree_item_map,root);
		} else {

			bool found = false;
			String type = E->key();

			while(type != "") {
				if (type.findn(filter)!=-1) {

					if (to_select.empty()) {
						to_select = type;
					}

					found=true;
					break;
				}

				type = EditorHelp::get_doc_data()->class_list[type].inherits;
			}

			if (found) {
				add_type(E->key(),tree_item_map,root);
			}
		}
	}

	if (tree_item_map.has(filter)) {
		select_class(filter);
	} else if (to_select != "") {
		select_class(to_select);
	}
}
Beispiel #17
0
static reachable_type_t* add_nominal(reachable_method_stack_t** s,
  reachable_types_t* r, uint32_t* next_type_id, ast_t* type)
{
  const char* type_name = genname_type(type);
  reachable_type_t* t = reach_type(r, type_name);

  if(t != NULL)
    return t;

  t = add_reachable_type(r, type, type_name);

  AST_GET_CHILDREN(type, pkg, id, typeparams);
  ast_t* typeparam = ast_child(typeparams);

  while(typeparam != NULL)
  {
    add_type(s, r, next_type_id, typeparam);
    typeparam = ast_sibling(typeparam);
  }

  ast_t* def = (ast_t*)ast_data(type);

  switch(ast_id(def))
  {
    case TK_INTERFACE:
    case TK_TRAIT:
      add_types_to_trait(s, r, t);
      break;

    case TK_PRIMITIVE:
      add_traits_to_type(s, r, t);
      add_special(s, t, type, "_init");
      add_special(s, t, type, "_final");
      break;

    case TK_STRUCT:
    case TK_CLASS:
      add_traits_to_type(s, r, t);
      add_special(s, t, type, "_final");
      add_fields(s, r, next_type_id, type);
      break;

    case TK_ACTOR:
      add_traits_to_type(s, r, t);
      add_special(s, t, type, "_event_notify");
      add_special(s, t, type, "_final");
      add_fields(s, r, next_type_id, type);
      break;

    default: {}
  }

  if(t->type_id == 0)
    t->type_id = ++(*next_type_id);

  return t;
}
Beispiel #18
0
void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p_types, TreeItem *p_root, TreeItem **to_select) {

	if (p_types.has(p_type))
		return;
	if (!ClassDB::is_parent_class(p_type, base_type) || p_type == base_type)
		return;

	String inherits = ClassDB::get_parent_class(p_type);

	TreeItem *parent = p_root;

	if (inherits.length()) {

		if (!p_types.has(inherits)) {

			add_type(inherits, p_types, p_root, to_select);
		}

		if (p_types.has(inherits))
			parent = p_types[inherits];
	}

	TreeItem *item = search_options->create_item(parent);
	item->set_text(0, p_type);
	if (!ClassDB::can_instance(p_type)) {
		item->set_custom_color(0, Color(0.5, 0.5, 0.5));
		item->set_selectable(0, false);
	} else {

		if ((!*to_select && (search_box->get_text().is_subsequence_ofi(p_type))) || search_box->get_text() == p_type) {
			*to_select = item;
		}
	}

	if (bool(EditorSettings::get_singleton()->get("docks/scene_tree/start_create_dialog_fully_expanded"))) {
		item->set_collapsed(false);
	} else {
		// don't collapse search results
		bool collapse = (search_box->get_text() == "");
		// don't collapse the root node
		collapse &= (item != p_root);
		// don't collapse abstract nodes on the first tree level
		collapse &= ((parent != p_root) || (ClassDB::can_instance(p_type)));
		item->set_collapsed(collapse);
	}

	const String &description = EditorHelp::get_doc_data()->class_list[p_type].brief_description;
	item->set_tooltip(0, description);

	if (has_icon(p_type, "EditorIcons")) {

		item->set_icon(0, get_icon(p_type, "EditorIcons"));
	}

	p_types[p_type] = item;
}
Beispiel #19
0
static void add_rmethod_to_subtypes(reach_t* r, reach_type_t* t,
  reach_method_name_t* n, reach_method_t* m, pass_opt_t* opt)
{
  switch(ast_id(t->ast))
  {
    case TK_NOMINAL:
    {
      ast_t* def = (ast_t*)ast_data(t->ast);

      switch(ast_id(def))
      {
        case TK_INTERFACE:
        case TK_TRAIT:
        {
          // Add to subtypes if we're an interface or trait.
          size_t i = HASHMAP_BEGIN;
          reach_type_t* t2;

          while((t2 = reach_type_cache_next(&t->subtypes, &i)) != NULL)
            add_rmethod_to_subtype(r, t2, n, m, opt);

          break;
        }

        default: {}
      }
      return;
    }

    case TK_UNIONTYPE:
    case TK_ISECTTYPE:
    {
      ast_t* child = ast_child(t->ast);

      while(child != NULL)
      {
        ast_t* find = lookup_try(NULL, NULL, child, n->name);

        if(find != NULL)
        {
          reach_type_t* t2 = add_type(r, child, opt);
          add_rmethod_to_subtype(r, t2, n, m, opt);
          ast_free_unattached(find);
        }

        child = ast_sibling(child);
      }
      return;
    }

    default: {}
  }

  assert(0);
}
Beispiel #20
0
static reachable_type_t* add_isect_or_union(reachable_method_stack_t** s,
  reachable_types_t* r, uint32_t* next_type_id, ast_t* type)
{
  ast_t* child = ast_child(type);

  while(child != NULL)
  {
    add_type(s, r, next_type_id, child);
    child = ast_sibling(child);
  }

  return NULL;
}
Beispiel #21
0
String Codegen_C::type_to_str( Type *type ) {
    std::ostringstream ss;
    if ( type->aryth )
        ss << *type;
    else if ( type->orig == ip->class_Ptr ) {
        add_type( ip->type_PI8 );
        ss << "TPTR";
    } else {
        ss << "GT" << type->size();
        spec_types[ type->size() ] = ss.str();
    }
    return ss.str();
}
Beispiel #22
0
void
c_initialize(void)
{
	/* add all the starting basic types */
	add_type(1, "int");
	add_type(1, "long");
	add_type(1, "short");
	add_type(1, "bool");
	add_type(1, "u_int");
	add_type(1, "u_long");
	add_type(1, "u_short");
}
Beispiel #23
0
AST_Attribute *UTL_Scope::add_attribute(AST_Attribute *a)
{
   if (a == NULL)
      return NULL;

   a->set_added(I_TRUE);

   if (!a->field_type()->added())
   {
      return add_type(a->field_type()) ? a : NULL;
   }
   else
      return a;
}
Beispiel #24
0
AST_Operation *UTL_Scope::add_operation(AST_Operation *o)
{
   if (o == NULL)
      return NULL;

   o->set_added(I_TRUE);

   if (!o->return_type()->added())
   {
      return add_type(o->return_type()) ? o : NULL;
   }
   else
      return o;
}
Beispiel #25
0
AST_Argument *UTL_Scope::add_argument(AST_Argument *a)
{
   if (a == NULL)
      return NULL;

   a->set_added(I_TRUE);

   if (!a->field_type()->added())
   {
      return add_type(a->field_type()) ? a : NULL;
   }
   else
      return a;
}
Beispiel #26
0
AST_UnionBranch *UTL_Scope::add_union_branch(AST_UnionBranch *u)
{
   if (u == NULL)
      return NULL;

   u->set_added(I_TRUE);

   if (!u->field_type()->added())
   {
      return add_type(u->field_type()) ? u : NULL;
   }
   else
      return u;
}
Beispiel #27
0
AST_Field *UTL_Scope::add_field(AST_Field *f)
{
   if (f == NULL)
      return NULL;

   f->set_added(I_TRUE);

   if (!f->field_type()->added())
   {
      return add_type(f->field_type()) ? f : NULL;
   }
   else
      return f;
}
Beispiel #28
0
AST_Typedef *UTL_Scope::add_typedef(AST_Typedef *t)
{
   if (t == NULL)
      return NULL;

   t->set_added(I_TRUE);

   if (!t->base_type()->added())
   {
      return add_type(t->base_type()) ? t : NULL;
   }
   else
      return t;
}
Beispiel #29
0
AST_Sequence *UTL_Scope::add_sequence(AST_Sequence *s)
{
   if (s == NULL)
      return NULL;

   s->set_added(I_TRUE);

   if (!s->base_type()->added())
   {
      return add_type(s->base_type()) ? s : NULL;
   }
   else
      return s;
}
Beispiel #30
0
AST_Array *UTL_Scope::add_array(AST_Array *a)
{
   if (a == NULL)
      return NULL;

   a->set_added(I_TRUE);

   if (!a->base_type()->added())
   {
      return add_type(a->base_type()) ? a : NULL;
   }
   else
      return a;
}