Esempio n. 1
0
  FORECAST UlamType::safeCast(UTI typidx)
  {
    // initial tests for completeness and scalars
    if(!isComplete() || !m_state.isComplete(typidx))
      {
	std::ostringstream msg;
	msg << "Casting UNKNOWN sizes; " << getBitSize();
	msg << ", Value Type and size was: " << typidx << "," << m_state.getBitSize(typidx);
	MSG(m_state.getFullLocationAsString(m_state.m_locOfNextLineText).c_str(), msg.str().c_str(), DEBUG);
	return CAST_HAZY;  //includes Navs & Hzy's
      }

    //let packable arrays of same size pass...
    if(!checkArrayCast(typidx))
      return CAST_BAD;

    if((m_state.getReferenceType(typidx)==ALT_CONSTREF) && (getReferenceType()==ALT_REF))
      return CAST_BAD; //bad cast from const ref to non-const ref

    return CAST_CLEAR;
  } //safeCast
Esempio n. 2
0
QString Reference::getSQLDefinition(unsigned sql_type)
{
	QString sql_def, tab_name;
	unsigned refer_type;

	refer_type=getReferenceType();

	//Case the reference is between the SELECT-FROM keywords
	if(sql_type==SQL_REFER_SELECT)
	{
		//Case the reference is linked to a column
		if(refer_type==REFER_COLUMN)
		{
			/* Generated SQL definition:
			[TABLE_ALIAS.]{COLUMN_NAME | *} [AS COLUMN_ALIAS] */

			if(!alias.isEmpty())
				tab_name=BaseObject::formatName(alias) + ".";

			/* Case there is no column definede the default behavior is consider
			all the table columns (e.g. table.*) */
			if(!column)
				sql_def=tab_name + "*";
			else
			{
				//Case there is an column concatenates its name to the code definition
				sql_def=tab_name + column->getName(true);

				//Case there is a column alias concatenate it to the definition
				if(column_alias!="")
					sql_def+=" AS " + BaseObject::formatName(column_alias);
			}
		}
		//Case the reference is linked to an expression
		else
		{
			/* Generated SQL definition:
			{expression} [AS ALIAS] */
			sql_def=expression;
			if(alias!="")
				sql_def+=" AS " + BaseObject::formatName(alias);
		}
		sql_def+=", ";
	}
	//Case the reference is between the FROM-[JOIN | WHERE] keywords
	else if(sql_type==SQL_REFER_FROM)
	{
		/* Case the reference is linked to a column only the table name is used.
		 For expression the complete code is used thus the generated code is:

		 ... FROM {TABLE_NAME} [AS ALIAS] or
		 ... FROM {EXPRESSION} */
		if(refer_type==REFER_COLUMN)
		{
			sql_def+=table->getName(true);

			if(alias!="")
				sql_def+=" AS " + BaseObject::formatName(alias);
			sql_def+=", ";
		}
		else
			sql_def=expression;
	}
	//Case the reference is after [JOIN | WHERE] keywords
	else
	{
		//Case the column is allocated
		if(refer_type==REFER_COLUMN && column)
		{
			/* Generated SQL definition:
			... WHERE {TABLE_NAME | ALIAS}.{COLUMN_NAME} */

			if(alias=="")
				sql_def=table->getName(true);
			else
				sql_def=BaseObject::formatName(alias);

			sql_def+=".";

			if(column)
				sql_def+=column->getName(true);
		}
		else if(refer_type==REFER_EXPRESSION)
			sql_def=expression;
	}

	return(sql_def);
}