Example #1
0
/// Moves items from a furnace above the hopper into this hopper. Returns true if contents have changed.
bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
{
	cFurnaceEntity * Furnace = (cFurnaceEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ);
	if (Furnace == NULL)
	{
		LOGWARNING("%s: A furnace entity was not found where expected, at {%d, %d, %d}", __FUNCTION__, m_PosX, m_PosY + 1, m_PosZ);
		return false;
	}
	
	// Try move from the output slot:
	if (MoveItemsFromSlot(*Furnace, cFurnaceEntity::fsOutput, true))
	{
		cItem NewOutput(Furnace->GetOutputSlot());
		Furnace->SetOutputSlot(NewOutput.AddCount(-1));
		return true;
	}
	
	// No output moved, check if we can move an empty bucket out of the fuel slot:
	if (Furnace->GetFuelSlot().m_ItemType == E_ITEM_BUCKET)
	{
		if (MoveItemsFromSlot(*Furnace, cFurnaceEntity::fsFuel, true))
		{
			Furnace->SetFuelSlot(cItem());
			return true;
		}
	}
	
	// Nothing can be moved
	return false;
}
Example #2
0
/// Moves items from a furnace above the hopper into this hopper. Returns true if contents have changed.
bool cHopperEntity::MoveItemsFromFurnace(cChunk & a_Chunk)
{
	cFurnaceEntity * Furnace = (cFurnaceEntity *)a_Chunk.GetBlockEntity(m_PosX, m_PosY + 1, m_PosZ);
	ASSERT(Furnace != NULL);
	
	// Try move from the output slot:
	if (MoveItemsFromSlot(Furnace->GetOutputSlot(), true))
	{
		cItem NewOutput(Furnace->GetOutputSlot());
		Furnace->SetOutputSlot(NewOutput.AddCount(-1));
		return true;
	}
	
	// No output moved, check if we can move an empty bucket out of the fuel slot:
	if (Furnace->GetFuelSlot().m_ItemType == E_ITEM_BUCKET)
	{
		if (MoveItemsFromSlot(Furnace->GetFuelSlot(), true))
		{
			Furnace->SetFuelSlot(cItem());
			return true;
		}
	}
	
	// Nothing can be moved
	return false;
}
Example #3
0
// [S]
const Register& CodeEmitter::Shl(
    const Type& outy,
    const Operand& src,
    int const amount) {
  auto& out = *NewOutput(outy).StaticCast<Register>();
  Emit(*new(zone()) ShlI(outy, out, src, NewLiteral(*Ty_Int32, amount)));
  return out;
}
Example #4
0
const Register& Builder::EmitI(Op const opcode, const Type& outy,
                               const Operand& src) {
  auto& inst = Instruction::New(zone(), opcode);
  auto& out = *NewOutput(outy).StaticCast<Register>();
  inst.set_output(out);
  inst.set_output_type(outy);
  inst.AppendOperand(src);
  EmitI(inst);
  return out;
}
Example #5
0
/// <summary>
///   <list type="number">
///     <item>Set output type of PrologueI.</item>
///     <item>Load parameters</item>
///   </list>
/// </summary>
void Builder::SetUpMethodBody(Function& fun, MethodDef& method_def) {
  auto const pPrologueI = fun.GetStartBB()->GetFirstI();
  auto const pRefI = pPrologueI->GetNext();
  auto const pBB = pPrologueI->GetBBlock();
  auto& v1 = *pPrologueI->GetVd();

  ValuesTypeBuilder tybuilder(
      method_def.IsStatic()
          ? method_def.CountParams()
          : method_def.CountParams() + 1);

  auto nth = 0;

  // "this" parameter.
  if (!method_def.IsStatic()) {
    tybuilder.Append(method_def.owner_class_def().GetClass());
    nth++;
  }

  foreach (MethodDef::EnumParam, oEnum, method_def) {
    auto const pParamDef = oEnum.Get();
    auto& var = pParamDef->GetVariable();
    auto& varty = var.GetTy();
    tybuilder.Append(varty);
    DEBUG_FORMAT("%s %s", varty, var);

    auto& cell_class = Ty_ClosedCell->Construct(varty);
    //auto& r2 = *NewOutput(varty).StaticCast<Register>();
    auto& r2 = *NewOutput(varty).StaticCast<Register>();
    r2.SetVariable(var);

    auto const pSelectI = new(zone()) SelectI(varty, r2, v1, nth);
    pSelectI->SetSourceInfo(pParamDef->GetSourceInfo());
    pBB->InsertBeforeI(*pSelectI, pRefI);

    auto& r3 = NewRegister();
    auto& vardef_inst = *new(zone()) VarDefI(cell_class, r3, var, r2);
    vardef_inst.set_source_info(pParamDef->source_info());
    pBB->InsertBeforeI(vardef_inst, pRefI);

    ++nth;
  }
Example #6
0
const Register& Builder::EmitLoadI(const Operand& ptr) {
  auto& outy = ptr.type().StaticCast<PointerType>()->pointee_type();
  auto& out = NewOutput(outy);
  EmitI(*new(zone()) LoadI(outy, out, ptr));
  return *out.StaticCast<Register>();
}
VectorToBitmapLayer::VectorToBitmapLayer(std::string bmpfilename)
{
		NewOutput(1);
		if(!bmpfilename.empty()) SetOutput(0,bmpfilename);
}