Esempio n. 1
0
int CConfiguration::VarIndex(const CString& Name) const
{
 for (size_t i = 0; i < m_Variables.size(); i++)
 {
  CVariable *variable = m_Variables[i];
  if (variable->GetName()==Name) return i;
 }
 return INVALID_INDEX;
}
Esempio n. 2
0
void CAddressGenerationVisitor::Visit(CVariable &AStmt)
{
	if (AStmt.GetSymbol()->GetGlobal()) {
		Asm.Add(PUSH, "$" + AStmt.GetName());
	} else {
		Asm.Add(LEA, mem(AStmt.GetSymbol()->GetOffset(), EBP), EAX);
		Asm.Add(PUSH, EAX);
	}
}
Esempio n. 3
0
void CConfiguration::SaveToFile(const CString& FileName)
{
 FILE *stream = fopen(FileName.GetCString(),"wt");
 for (size_t i = 0; i < m_Variables.size(); i++)
 {
  CVariable *variable = m_Variables[i];
  CString string = variable->GetName()+"=";
  if ((variable->GetType()==VARIABLE_TYPE_STRING)||
      (variable->GetType()==VARIABLE_TYPE_CHAR))
  { string+="\""+variable->GetString()+"\""; }
  else
  { string+=variable->GetString(); }
  string.Append(';').AppendEOL();
  fwrite(string.GetCString(),string.GetLength(),1,stream);
 }
 fclose(stream);
}
Esempio n. 4
0
void CConfiguration::Print(std::ostream& out)
{
 for (size_t i = 0; i < m_Variables.size(); i++)
 {
  CVariable *variable = m_Variables[i];
  out<<variable->GetTypeName().GetCString()<<" "<<variable->GetName().GetCString()<<"=";
  if (VARIABLE_TYPE_STRING == variable->GetType())
  {
   out<<"\""<<variable->GetString().GetCString()<<"\";"<<std::endl;
  }
  else if (VARIABLE_TYPE_CHAR == variable->GetType())
  {
   out<<"'"<<variable->GetString().GetCString()<<"';"<<std::endl;
  }
  else
  {
   out<<variable->GetString().GetCString()<<";"<<std::endl;
 }}
}