示例#1
0
void TActualParamWithConversion::RunConversion(std::vector<TStaticValue> &static_fields, TStackValue &value)
{
	if (ref_to_rvalue)
	{
		assert(copy_constr != NULL);
		//if (copy_constr != NULL)
		{
			std::vector<TStackValue> constr_params;
			constr_params.push_back(value);
			TStackValue constr_result;
			TStackValue constructed_object(false, value.GetClass());
			copy_constr->Run(TMethodRunContext(&static_fields, &constr_params, &constr_result, &constructed_object));
			value = constructed_object;
		}
		//else
		//{
		//	TStackValue constructed_object(false, value.GetClass());
		//	memcpy(constructed_object.get(), value.get(), value.GetClass()->GetSize()*sizeof(int));
		//	value = constructed_object;
		//}
	}
	if (conversion != NULL)
	{
		std::vector<TStackValue> conv_params;
		conv_params.push_back(value);
		TStackValue result;
		conversion->Run(TMethodRunContext(&static_fields, &conv_params, &result, &value));
		value = result;
	}
}
示例#2
0
void TSConstructObject::Destruct(TStackValue& constructed_object, TGlobalRunContext run_context)
{
	TSMethod* destr = object_type->GetDestructor();
	if (destr != NULL)
	{
		destr->Run(TMethodRunContext(run_context.static_fields, nullptr, nullptr, &constructed_object));
	}
}
示例#3
0
void TActualParameters::Destroy(std::vector<TStackValue> &method_call_formal_params, TStatementRunContext run_context)
{
	auto it = input.begin();
	for (size_t i = 0; i < method_call_formal_params.size(); i++)
	{
		if (!it->result.IsRef() && it->result.GetClass()->GetDestructor() != NULL)
		{
			TStackValue destructor_result;
			std::vector<TStackValue> without_params;
			it->result.GetClass()->GetDestructor()->Run(TMethodRunContext(run_context.static_fields, &without_params, &destructor_result, &method_call_formal_params[i]));
		}
		it++;
	}
}
示例#4
0
void InitializeStaticClassFields(std::vector<TSClassField*> static_fields, std::vector<TStaticValue> &static_objects)
{
	for (TSClassField* v : static_fields)
	{
		v->SetOffset(static_objects.size());
		static_objects.emplace_back(false,v->GetClass());
		TSMethod* def_constr = v->GetClass()->GetDefConstr();
		static_objects[v->GetOffset()].Initialize();
		if (def_constr != NULL)
		{
			std::vector<TStackValue> constr_formal_params;
			TStackValue without_result, var_object(true, v->GetClass());
			var_object.SetAsReference(static_objects[v->GetOffset()].get());
			def_constr->Run(TMethodRunContext(&static_objects, &constr_formal_params, &without_result, &var_object));
		}
		
	}
}