Beispiel #1
0
	//==========================================================================
	// проверяет поглощение одного типа другим
	//--------------------------------------------------------------------------
	// t1 - [in] 1-й тип
	// t2 - [in] 2-й тип
	//==========================================================================
	Type* GetMaxType(Type *t1, Type *t2)
	{
		if (CompareType(t1, t2)) return t1;
		if (CompareType(t2, t1)) return t2;

		return 0;
	}
Beispiel #2
0
unit_t * unit_new (svc_t * svc, svc_instance_t * inst)
{
#define CompareType(typ)                                                       \
    !strcasecmp (svc_object_get_property_string (svc, "Unit.Strategy"), typ)

    unit_t * unitnew = s16mem_alloc (sizeof (unit_t));

    unitnew->name = inst_object_get_property_string (inst, "S16.FMRI");
    unitnew->state = S_OFFLINE;
    unitnew->svc = svc;
    unitnew->inst = inst;
    unitnew->timer_id = 0;
    unitnew->main_pid = 0;
    unitnew->rtype = R_YES;
    unitnew->state = S_OFFLINE;
    unitnew->pids = List_new ();
    if (!unitnew->pids)
    {
        fprintf (stderr, "unit alloc! (%s pids)\n",
                 inst_object_get_property_string (inst, "S16.FMRI"));
        return 0;
    }

    if (CompareType ("exec"))
        unitnew->type = T_EXEC;
    else if (CompareType ("forks"))
        unitnew->type = T_FORKS;
    else if (CompareType ("oneshot"))
        unitnew->type = T_ONESHOT;
    else
    {
        fprintf (stderr, "Unit <%s> lacks a known type\n", unitnew->name);
        List_destroy (unitnew->pids);
        s16mem_free (unitnew);
        return 0;
    }

    unitnew->method[M_PRESTART] =
        svc_object_get_property_string (svc, "Method.Prestart");
    unitnew->method[M_START] =
        svc_object_get_property_string (svc, "Method.Start");
    unitnew->method[M_POSTSTART] =
        svc_object_get_property_string (svc, "Method.Poststart");
    unitnew->method[M_STOP] =
        svc_object_get_property_string (svc, "Method.Stop");

    unitnew->timeout_secs = 12;

    fprintf (stderr, "[%s] new unit formed\n", unitnew->name);

    return unitnew;
}
Beispiel #3
0
	//==========================================================================
	// сравнивает два типа массив
	//--------------------------------------------------------------------------
	// t1 - [in] 1-й тип массив
	// t2 - [in] 2-й тип массив
	//==========================================================================
	bool CompareTypeArray(TypeArray *t1, TypeArray *t2)
	{
		if(t1->size == 0 && t2->size == 0)		// открытые массивы
			return CompareType(t1->type, t2->type);

		return false;
	}
Beispiel #4
0
	//==========================================================================
	// сравнивает два типа указателя
	//--------------------------------------------------------------------------
	// t1 - [in] 1-й тип указатель
	// t2 - [in] 2-й тип указатель
	//==========================================================================
	bool CompareTypePtr(TypePtr *t1, TypePtr *t2)
	{
		// проверка на присвоение NULL
		if (!t1->IsNil && t2->IsNil || t1->IsNil && t2->IsNil)
			return true;

		return CompareType(t1->type, t2->type);
	}
Beispiel #5
0
	//==========================================================================
	// сравнивает специализацию и простой тип
	//--------------------------------------------------------------------------
	// t1 - [in] 1-й тип обобщение
	// t2 - [in] 2-й тип специализация
	//==========================================================================
	bool CompareTypeSpec(Type *t1, TypeSpec *t2)
	{
		Type* t = static_cast<Type*>(t2->base);
		if (!t)
			return false;

		// проверяем тип спец-ии
		return CompareType(t1, t);
	}
bool benchIntrusive(BenchmarkParameters &params)
{
    std::vector<uint64_t> &keys = *reinterpret_cast<std::vector<uint64_t>*>(params.arg0);

    std::vector<DataType> values;
    values.reserve(params.itemCount);

    for(int i = 0; i < params.itemCount; ++i)
    {
        DataType d;
        d.key = keys[i];
        values.push_back(d);
    }

    {
        MapType m;

        for(DataType &d : values)
        {
            m.insert(d);
        }

        if(m.size() != static_cast<uint64_t>(params.itemCount))
        {
            return false;
        }

        int64_t searchCounter = 0;

        uint64_t ticks = getTicks();

        //=======================================================================

        while(searchCounter < params.iterCount)
        {
            for(int i = 0; i < params.itemCount && searchCounter < params.iterCount; ++i, ++searchCounter)
            {
                auto iter = m.find(keys[i], CompareType());

                if(iter == m.end() || iter->key != keys[i])
                {
                    return false;
                }
            }
        }

        //=======================================================================

        params.ticks = getTicks() - ticks;
    }

    return true;
}
Beispiel #7
0
/*
============
PR_ParseFunctionCall
============
*/
def_t *PR_ParseFunctionCall (def_t *func)
{
	def_t		*e;
	int			 arg;
	type_t		*t;

	t = func->type;

	if (t->type != ev_function)
		PR_ParseError ("not a function");

	// copy the arguments to the global parameter variables
	arg = 0;
	if (!PR_Check(")"))
	{
		do
		{
			if (arg >= t->num_parms || arg >= MAX_PARMS /* works properly with varargs */)
				PR_ParseError ("too many parameters");
			e = PR_Expression (TOP_PRIORITY);

			if (arg < (t->num_parms & VA_MASK) && !CompareType(e->type, t->parm_types[arg]))
				PR_ParseError ("type mismatch on parm %i", arg);
			// a vector copy will copy everything
			def_parms[arg].type = t->parm_types[arg];
			PR_Statement (&pr_opcodes[OP_STORE_V], e, &def_parms[arg]);
			arg++;
		} while (PR_Check (","));

		if (arg < (t->num_parms & VA_MASK))
			PR_ParseError ("too few parameters");
		PR_Expect (")");
	}
	if (arg > MAX_PARMS)
		PR_ParseError ("more than %d parameters", (int)MAX_PARMS);

	PR_Statement (&pr_opcodes[OP_CALL0+arg], func, 0);

	def_ret.type = t->aux_type;
	return &def_ret;
}
Beispiel #8
0
/*
================
PR_ParseInitialization

"<type> <name> = " was parsed, parse the rest
================
*/
void PR_ParseInitialization (type_t *type, char *name, def_t *def)
{
	if (def->initialized)
		PR_ParseError ("%s redeclared", name);

	if (pr_token_type != tt_immediate && pr_token_type != tt_name)
		PR_ParseError ("syntax error : '%s'", pr_token);

	if (pr_token_type == tt_name) {
		PR_ParseError ("initializer is not a constant");
	}

	if (!CompareType(pr_immediate_type, type))
		PR_ParseError ("wrong immediate type for %s", name);

	def->initialized = 1;
	if (type == &type_const_string || type == &type_string)
		pr_immediate.string = CopyString (pr_immediate_string);
	memcpy (pr_globals + def->ofs, &pr_immediate, 4*type_size[pr_immediate_type->type]);
	PR_Lex ();
}
Beispiel #9
0
	//==========================================================================
	// сравнивает два процедурных типа
	//--------------------------------------------------------------------------
	// t1 - [in] 1-й процедурный тип
	// t2 - [in] 2-й процедурный тип
	//==========================================================================
	bool CompareTypeProc(TypeProcedure *t1, TypeProcedure *t2)
	{
		if(t1->formalParams.size() == t2->formalParams.size() && t1->returnType == t2->returnType)
		{
			// сравниваю параметры
			for(unsigned int i = 0; i < t1->formalParams.size(); ++i)
			{
				Parameter *p1 = t1->formalParams[i];
				Parameter *p2 = t2->formalParams[i];
				if((p1->type->WhatIsIt() == ItIsTypeRef && p2->type->WhatIsIt() == ItIsTypeRef) ||
				   (p1->type->WhatIsIt() != ItIsTypeRef && p2->type->WhatIsIt() != ItIsTypeRef))
				{
					if(!CompareType(p1->type, p2->type))
						return false;
				}
				else
					return false;
			}
			return true;
		}

		return false;
	}
Beispiel #10
0
 void Visit(const Waypoint &waypoint) {
   if (CompareType(waypoint, type_index) &&
       (filter_data.distance_index == 0 || CompareName(waypoint, name)) &&
       CompareDirection(waypoint, direction_index, location, heading))
     waypoint_list.push_back(WaypointListItem(waypoint));
 }