Exemplo n.º 1
0
void BlockSummary::Write(Buffer *buf, const BlockSummary *sum)
{
  WriteOpenTag(buf, TAG_BlockSummary);
  BlockId::Write(buf, sum->GetId());

  size_t assert_count = VectorSize<AssertInfo>(sum->m_assert_list);
  for (size_t ind = 0; ind < assert_count; ind++) {
    const AssertInfo &info = sum->m_assert_list->At(ind);

    WriteOpenTag(buf, TAG_SummaryAssert);
    WriteTagUInt32(buf, TAG_Kind, info.kind);
    WriteTagUInt32(buf, TAG_OpCode, info.cls);
    WriteTagUInt32(buf, TAG_Index, info.point);
    Bit::Write(buf, info.bit);
    WriteCloseTag(buf, TAG_SummaryAssert);
  }

  size_t assume_count = VectorSize<Bit*>(sum->m_assume_list);
  for (size_t ind = 0; ind < assume_count; ind++) {
    WriteOpenTag(buf, TAG_SummaryAssume);
    Bit::Write(buf, sum->m_assume_list->At(ind));
    WriteCloseTag(buf, TAG_SummaryAssume);
  }

  WriteCloseTag(buf, TAG_BlockSummary);
}
Exemplo n.º 2
0
void BlockModset::Write(Buffer *buf, const BlockModset *mod)
{
  WriteOpenTag(buf, TAG_BlockModset);
  BlockId::Write(buf, mod->GetId());

  for (size_t ind = 0; ind < mod->GetModsetCount(); ind++) {
    const PointValue &v = mod->m_modset_list->At(ind);

    WriteOpenTag(buf, TAG_ModsetEntry);
    Exp::Write(buf, v.lval);
    if (v.kind)
      Exp::Write(buf, v.kind);
    WriteCloseTag(buf, TAG_ModsetEntry);
  }

  for (size_t ind = 0; ind < mod->GetAssignCount(); ind++) {
    const GuardAssign &v = mod->m_assign_list->At(ind);
    Assert(v.kind == NULL);

    WriteOpenTag(buf, TAG_ModsetAssign);
    Exp::Write(buf, v.left);
    Exp::Write(buf, v.right);
    Bit::Write(buf, v.guard);
    WriteCloseTag(buf, TAG_ModsetAssign);
  }

  WriteCloseTag(buf, TAG_BlockModset);
}
Exemplo n.º 3
0
Arquivo: type.cpp Projeto: wh5a/xgill
void Type::Write(Buffer *buf, const Type *y)
{
  WriteOpenTag(buf, TAG_Type);
  WriteTagUInt32(buf, TAG_Kind, y->Kind());

  switch (y->Kind()) {
  case YK_Void:
  case YK_Error:
    break;
  case YK_Int:
    WriteTagUInt32(buf, TAG_Width, y->Width());
    if (y->IsSigned())
      WriteTagEmpty(buf, TAG_Sign);
    break;
  case YK_Float:
    WriteTagUInt32(buf, TAG_Width, y->Width());
    break;
  case YK_Pointer: {
    const TypePointer *ny = (const TypePointer*)y;
    WriteTagUInt32(buf, TAG_Width, y->Width());
    Type::Write(buf, ny->GetTargetType());
    break;
  }
  case YK_Array: {
    const TypeArray *ny = (const TypeArray*)y;
    Type::Write(buf, ny->GetElementType());
    WriteTagUInt32(buf, TAG_Count, ny->GetElementCount());
    break;
  }
  case YK_CSU: {
    const TypeCSU *ny = (const TypeCSU*)y;
    String::WriteWithTag(buf, ny->GetCSUName(), TAG_Name);
    break;
  }
  case YK_Function: {
    const TypeFunction *ny = (const TypeFunction*)y;
    Type::Write(buf, ny->GetReturnType());
    if (ny->GetCSUType()) {
      WriteOpenTag(buf, TAG_TypeFunctionCSU);
      Type::Write(buf, ny->GetCSUType());
      WriteCloseTag(buf, TAG_TypeFunctionCSU);
    }
    if (ny->IsVarArgs())
      WriteTagEmpty(buf, TAG_TypeFunctionVarArgs);
    if (ny->GetArgumentCount() > 0) {
      WriteOpenTag(buf, TAG_TypeFunctionArguments);
      for (size_t aind = 0; aind < ny->GetArgumentCount(); aind++)
        Type::Write(buf, ny->GetArgumentType(aind));
      WriteCloseTag(buf, TAG_TypeFunctionArguments);
    }
    break;
  }
  default:
    Assert(false);
  }
  WriteCloseTag(buf, TAG_Type);
}
Exemplo n.º 4
0
void Location::Write(Buffer *buf, const Location *l)
{
  WriteOpenTag(buf, TAG_Location);
  String::WriteCache(buf, l->FileName());
  WriteUInt32(buf, l->Line());
  WriteCloseTag(buf, TAG_Location);
}
Exemplo n.º 5
0
Arquivo: type.cpp Projeto: wh5a/xgill
void Field::Write(Buffer *buf, const Field *f)
{
  WriteOpenTag(buf, TAG_Field);

  String::WriteWithTag(buf, f->GetName(), TAG_Name);
  if (f->GetSourceName())
    String::WriteWithTag(buf, f->GetSourceName(), TAG_Name);

  Type::Write(buf, f->GetType());

  WriteOpenTag(buf, TAG_FieldCSU);
  Type::Write(buf, f->GetCSUType());
  WriteCloseTag(buf, TAG_FieldCSU);

  if (f->IsInstanceFunction())
    WriteTagEmpty(buf, TAG_FieldInstanceFunction);

  WriteCloseTag(buf, TAG_Field);
}
Exemplo n.º 6
0
void String::WriteCache(Buffer *buf, String *s)
{
  WriteOpenTag(buf, TAG_CacheString);
  uint32_t id = 0;
  if (buf->TestSeen((uint64_t)s, &id)) {
    WriteUInt32(buf, id);
  }
  else {
    Write(buf, s);
    WriteUInt32(buf, id);
  }
  WriteCloseTag(buf, TAG_CacheString);
}
Exemplo n.º 7
0
Arquivo: type.cpp Projeto: wh5a/xgill
void CompositeCSU::Write(Buffer *buf, const CompositeCSU *csu)
{
  Assert(csu->m_begin_location);
  Assert(csu->m_end_location);

  WriteOpenTag(buf, TAG_CompositeCSU);

  String::WriteWithTag(buf, csu->GetName(), TAG_Name);
  WriteTagUInt32(buf, TAG_Kind, csu->Kind());

  if (csu->m_command)
    String::WriteWithTag(buf, csu->m_command, TAG_Command);

  Location::Write(buf, csu->m_begin_location);
  Location::Write(buf, csu->m_end_location);

  WriteTagUInt32(buf, TAG_Width, csu->GetWidth());

  for (size_t ind = 0; ind < csu->GetFieldCount(); ind++) {
    const DataField &df = csu->GetField(ind);
    WriteOpenTag(buf, TAG_DataField);
    Field::Write(buf, df.field);
    WriteTagUInt32(buf, TAG_Offset, df.offset);
    WriteCloseTag(buf, TAG_DataField);
  }

  for (size_t ind = 0; ind < csu->GetFunctionFieldCount(); ind++) {
    const FunctionField &ff = csu->GetFunctionField(ind);
    WriteOpenTag(buf, TAG_FunctionField);
    Field::Write(buf, ff.field);
    if (ff.base)
      Field::Write(buf, ff.base);
    if (ff.function)
      Variable::Write(buf, ff.function);
    WriteCloseTag(buf, TAG_FunctionField);
  }

  WriteCloseTag(buf, TAG_CompositeCSU);
}
Exemplo n.º 8
0
void Variable::Write(Buffer *buf, const Variable *v)
{
  WriteOpenTag(buf, TAG_Variable);
  if (v->GetId())
    BlockId::Write(buf, v->GetId());
  WriteTagUInt32(buf, TAG_Kind, v->Kind());
  if (v->GetName(false) != NULL)
    String::WriteWithTag(buf, v->GetName(), TAG_Name);
  if (v->GetSourceName() != NULL)
    String::WriteWithTag(buf, v->GetSourceName(), TAG_Name);
  if (v->Kind() == VK_Arg)
    WriteTagUInt32(buf, TAG_Index, v->GetIndex());
  WriteCloseTag(buf, TAG_Variable);
}
Exemplo n.º 9
0
void String::WriteCache(Buffer *buf, String *s)
{
  WriteOpenTag(buf, TAG_CacheString);
  uint32_t id = 0;
  s->IncRef(buf);
  if (buf->TestSeen((void*)s, BufferCleanupString, &id)) {
    WriteUInt32(buf, id);
  }
  else {
    Write(buf, s);
    WriteUInt32(buf, id);
  }
  WriteCloseTag(buf, TAG_CacheString);
}
Exemplo n.º 10
0
NAMESPACE_XGILL_BEGIN

/////////////////////////////////////////////////////////////////////
// TOperand static
/////////////////////////////////////////////////////////////////////

void TOperand::Write(Buffer *buf, const TOperand *o)
{
  WriteOpenTag(buf, TAG_TOperand);
  WriteTagUInt32(buf, TAG_Kind, o->Kind());

  switch (o->Kind()) {
  case TO_Variable: {
    const TOperandVariable *no = (const TOperandVariable*)o;
    WriteTagUInt32(buf, TAG_Index, no->GetName());
    break;
  }
  case TO_List: {
    const TOperandList *no = (const TOperandList*)o;
    for (size_t oind = 0; oind < no->GetCount(); oind++)
      TOperand::Write(buf, no->GetOperand(oind));
    break;
  }
  case TO_String: {
    const TOperandString *no = (const TOperandString*)o;
    WriteString(buf, no->GetData(), no->GetDataLength());
    break;
  }
  case TO_Boolean: {
    const TOperandBoolean *no = (const TOperandBoolean*)o;
    WriteTagEmpty(buf, no->IsTrue() ? TAG_True : TAG_False);
    break;
  }
  case TO_Integer: {
    const TOperandInteger *no = (const TOperandInteger*)o;
    WriteTagUInt32(buf, TAG_Index, no->GetValue());
    break;
  }
  default:
    Assert(false);
  }

  WriteCloseTag(buf, TAG_TOperand);
}
Exemplo n.º 11
0
void String::WriteWithTag(Buffer *buf, const String *s, tag_t tag)
{
  WriteOpenTag(buf, tag);
  Write(buf, s);
  WriteCloseTag(buf, tag);
}
Exemplo n.º 12
0
	//!Save the XML Element based with or without formatting
	int HtlXDLWriter::SaveXDLElement(HtlElement * ptrElement, std::string & strOutput, bool blnWithFormatting)
	{	
		/*
		//SAVE ELEMENT
		START THE OPENTAG
		SERIALIZE THE ATTRIBUTES INTO THE OPEN TAG
		CLOSE THE OPEN TAG
		WRITE THE VALUE
		WRITE THE COMMENTS
		WRITE THE PROCESSES
		WRITE THE SUB ELEMENTS
		WRITE THE CLOSE TAG
		*/
		int i,intNumAttributes,intNumComments,intNumProcesses,intNumSubElements;
		int intTemp, intReturn;
		bool blnNullNode = false;
		bool blnRootNode = false;
		bool blnInline = false;
		intReturn = 1;
		blnRootNode = ptrElement->IsRootNode();
		blnNullNode = ptrElement->IsNullNode();
		intNumAttributes = ptrElement->CountAttributes();
		intNumComments = ptrElement->CountComments();
		intNumProcesses = ptrElement->CountProcesses();
		intNumSubElements = ptrElement->CountSubElements();
		if((intNumComments <= 0)&&(intNumProcesses <= 0)&&(intNumSubElements <= 0))
		{
			//then treat as an inline HtlElement
			blnInline = true;
		};
		//if the element is the root node, and an xml processing statement is present, then write that first.
		if((ptrElement->Get_blnRootNode() == true)&&(intNumProcesses > 0))
		{
			//write a carriage return if necessary for formatting
			for(i = 0; i < intNumProcesses;i++)
			{
				intTemp = WriteProcess(ptrElement->GetProcess(i),strOutput,blnWithFormatting);
				if(intTemp < 0){intReturn = -1;};
			};
			//write a carriage return if necessary for formatting
			if(blnWithFormatting){strOutput += '\n';};
		};

		//START THE OPENTAG///////////////////////////////////////////////
		intTemp = WriteOpenTag(ptrElement,strOutput,blnWithFormatting);
		if(intTemp < 0){intReturn = -1;};

		if(blnNullNode)
		{
			return 1;
		};

		if(blnInline)
		{
			//then treat as an inline XML Element
			intTemp = WriteValue(ptrElement,strOutput,false);
			if(intTemp < 0){intReturn = -1;};
			//write the close tag inline
			intTemp = WriteCloseTag(ptrElement,strOutput,false);
			if(intTemp < 0){intReturn = -1;};
			return intReturn;
		}else{
			//WRITE THE VALUE////////////////////////////////////////////////
			intTemp = WriteValue(ptrElement,strOutput,blnWithFormatting);
			if(intTemp < 0){intReturn = -1;};
			//WRITE THE PROCESSES/////////////////////////////////////////////
			if((ptrElement->Get_blnRootNode() == false)&&(intNumProcesses > 0))
			{
				//write a carriage return if necessary for formatting
				for(i = 0; i < intNumProcesses;i++)
				{
					intTemp = WriteProcess(ptrElement->GetProcess(i),strOutput,blnWithFormatting);
					if(intTemp < 0){intReturn = -1;};
				};
			};
			//WRITE THE COMMENTS/////////////////////////////////////////////
			if(intNumComments > 0)
			{
				//write a carriage return if necessary for formatting
				for(i = 0; i < intNumComments;i++)
				{
					intTemp = WriteComment(ptrElement->GetComment(i),strOutput,blnWithFormatting);
					if(intTemp < 0){intReturn = -1;};
				};
			};
			//WRITE THE SUB ELEMENTS/////////////////////////////////////////////
			if(intNumSubElements > 0)
			{
				//write a carriage return if necessary for formatting
				for(i = 0; i < intNumSubElements;i++)
				{
					intTemp = SaveXDLElement(ptrElement->GetSubElement(i),strOutput, blnWithFormatting);
					if(intTemp < 0){intReturn = -1;};
				};
			};
			//WRITE THE CLOSE TAG 
			intTemp = WriteCloseTag(ptrElement,strOutput,blnWithFormatting);
			if(intTemp < 0){intReturn = -1;};
			return intReturn;
		};//end simple inline element check
		return intReturn;
	};