本文整理汇总了C++中UlamType类的典型用法代码示例。如果您正苦于以下问题:C++ UlamType类的具体用法?C++ UlamType怎么用?C++ UlamType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UlamType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getValueReadyToPrint
bool SymbolWithValue::getArrayValueAsString(std::string& vstr)
{
BV8K dval;
bool oktoprint = getValueReadyToPrint(dval);
if(!oktoprint) return false;
UTI tuti = getUlamTypeIdx();
UlamType * tut = m_state.getUlamTypeByIndex(tuti);
if(tut->getTotalBitSize() == 0)
{
vstr = "10"; //empty array
return true;
}
//get the number of bits for this type into u64
// convert to a lex-number as a string, applying type specifics
// return the completed string of all the array values in arg vstr.
std::ostringstream tovstr;
s32 bs = tut->getBitSize();
s32 arraysize = tut->getArraySize();
for(s32 i=0; i < arraysize; i++)
{
u64 thisval = dval.ReadLong(i * bs, bs); //pos and len
std::string str;
convertValueToALexString(thisval, tuti, str, m_state);
tovstr << str;
}
vstr = tovstr.str();
return true;
} //getArrayValueAsString
示例2: printTypeAndName
void NodeVarRef::printTypeAndName(File * fp)
{
UTI vuti = m_varSymbol->getUlamTypeIdx();
UlamKeyTypeSignature vkey = m_state.getUlamKeyTypeSignatureByIndex(vuti);
UlamType * vut = m_state.getUlamTypeByIndex(vuti);
if(m_state.isConstantRefType(vuti))
fp->write(" constant"); //t41242,3
fp->write(" ");
if(vut->getUlamTypeEnum() != Class)
{
fp->write(vkey.getUlamKeyTypeSignatureNameAndBitSize(&m_state).c_str());
fp->write("&"); //<--the only difference!!!
}
else
fp->write(vut->getUlamTypeClassNameBrief(vuti).c_str()); //includes any &
fp->write(" ");
fp->write(getName());
s32 arraysize = m_state.getArraySize(vuti);
if(arraysize > NONARRAYSIZE)
{
fp->write("[");
fp->write_decimal(arraysize);
fp->write("]");
}
else if(arraysize == UNKNOWNSIZE)
{
fp->write("[UNKNOWN]");
}
} //printTypeAndName
示例3: assert
// replaced by NodeVarDecl:genCode to leverage the declaration order preserved by the parse tree.
void SymbolVariableDataMember::generateCodedVariableDeclarations(File * fp, ULAMCLASSTYPE classtype)
{
assert(classtype == UC_ELEMENT); //really?
UTI vuti = getUlamTypeIdx();
UlamType * vut = m_state.getUlamTypeByIndex(vuti);
ULAMCLASSTYPE vclasstype = vut->getUlamClassType();
m_state.indentUlamCode(fp);
fp->write(vut->getUlamTypeMangledName().c_str()); //for C++
if(vclasstype == UC_QUARK) //called on classtype elements only
{
fp->write("<");
fp->write_decimal(getPosOffset());
fp->write(">");
}
fp->write(" ");
fp->write(getMangledName().c_str());
#if 0
s32 arraysize = vut->getArraySize();
if(arraysize > NONARRAYSIZE)
{
fp->write("[");
fp->write_decimal(arraysize);
fp->write("]");
}
else if(arraysize == UNKNOWNSIZE)
{
fp->write("[UNKNOWN]");
}
#endif
fp->write(";"); GCNL;
} //generateCodedVariableDeclarations
示例4: explicitlyCastable
FORECAST UlamTypePrimitive::explicitlyCastable(UTI typidx)
{
FORECAST scr = UlamType::safeCast(typidx); //default
if(scr == CAST_CLEAR)
{
// primitives must be the same sizes when casting to a reference type
if(isReference() && !UlamType::checkReferenceCast(typidx))
scr = CAST_BAD;
// strings cannot be cast explicitly to other primitive types, except Void (t3961)
UlamType * vut = m_state.getUlamTypeByIndex(typidx);
ULAMTYPE valtypEnum = vut->getUlamTypeEnum();
if((getUlamTypeEnum() != Void) && ((valtypEnum == String) ^ (getUlamTypeEnum() == String)))
scr = CAST_BAD;
//only quarks may be cast to Ints, explicitly or not; requires toInt method (t3996)
if(valtypEnum == Class)
{
ULAMCLASSTYPE vclasstype = vut->getUlamClassType();
if(vclasstype != UC_QUARK)
scr = CAST_BAD;
}
}
return scr;
} //explicitlyCastable
示例5: assert
//atomic parameter type, not model parameter.
const std::string Symbol::getMangledNameForParameterType()
{
assert(!isModelParameter());
UlamType * sut = m_state.getUlamTypeByIndex(getUlamTypeIdx());
ULAMCLASSTYPE classtype = sut->getUlamClass();
//another way, like this?
if(isModelParameter())
{
std::ostringstream epmangled;
epmangled << sut->getImmediateModelParameterStorageTypeAsString();
//if(classtype == UC_QUARK)
// epmangled << "::Us";
assert(classtype == UC_NOTACLASS);
return epmangled.str();
}
// to distinguish btn an atomic parameter typedef and quark typedef;
// use atomic parameter with array of classes
bool isaclass = (( classtype == UC_QUARK || classtype == UC_ELEMENT || classtype == UC_UNSEEN) && sut->isScalar());
std::ostringstream pmangled;
pmangled << Symbol::getParameterTypePrefix(isaclass).c_str() << getMangledName();
return pmangled.str();
} //getMangledNameForParameterType
示例6: getOfType
UlamValue NodeInstanceof::makeUlamValuePtr()
{
// (from NodeVarDecl's makeUlamValuePtr)
UlamValue ptr;
UlamValue atomuv;
UTI auti = getOfType();
UlamType * aut = m_state.getUlamTypeByIndex(auti);
ULAMCLASSTYPE aclasstype = aut->getUlamClassType();
u32 atop = 1;
atop = m_state.m_funcCallStack.getAbsoluteStackIndexOfSlot(atop);
if(m_state.isAtom(auti))
atomuv = UlamValue::makeAtom(auti);
else if(aclasstype == UC_ELEMENT)
atomuv = UlamValue::makeDefaultAtom(auti, m_state);
else if(aclasstype == UC_QUARK)
{
u32 dq = 0;
AssertBool isDefinedQuark = m_state.getDefaultQuark(auti, dq); //returns scalar dq
assert(isDefinedQuark);
atomuv = UlamValue::makeImmediateClass(auti, dq, aut->getTotalBitSize());
}
else if(aclasstype == UC_TRANSIENT)
atomuv = UlamValue::makeDefaultAtom(auti, m_state); //size limited to atom for eval
else
m_state.abortUndefinedUlamClassType();
m_state.m_funcCallStack.storeUlamValueAtStackIndex(atomuv, atop); //stackframeslotindex ?
ptr = UlamValue::makePtr(atop, STACK, auti, m_state.determinePackable(auti), m_state, 0);
ptr.setUlamValueTypeIdx(PtrAbs);
return ptr;
} //makeUlamValuePtr
示例7: genCodeRefAsSelf
void NodeVarRefAs::genCodeRefAsSelf(File * fp, UVPass& uvpass)
{
//no tmpref needed since 'self' (i.e. ur) is already a C++ reference
//t3821, t3815 (transient), t3828 (quark)
Symbol * stgcos = m_state.m_currentObjSymbolsForCodeGen[0];
UTI vuti = m_varSymbol->getUlamTypeIdx();
UlamType * vut = m_state.getUlamTypeByIndex(vuti);
m_state.indentUlamCode(fp);
fp->write(vut->getLocalStorageTypeAsString().c_str()); //for C++ local vars, ie non-data members
fp->write(" ");
fp->write(m_varSymbol->getMangledName().c_str());
fp->write("(");
fp->write(stgcos->getMangledName().c_str()); //stg
fp->write(", 0u, ");
fp->write(stgcos->getMangledName().c_str()); //stg
fp->write(".GetEffectiveSelf()");
fp->write("); //shadows lhs of 'as'"); GCNL;
m_state.indentUlamCode(fp);
fp->write("UlamRef<EC>& ur = ");
fp->write(m_varSymbol->getMangledName().c_str());
fp->write("; //shadows self"); GCNL;
m_varSymbol->setIsSelf(); //nope
m_state.clearCurrentObjSymbolsForCodeGen(); //clear remnant of lhs
} //genCodeRefAsSelf
示例8: assert
EvalStatus NodeVarRefAs::eval()
{
assert(m_varSymbol);
UTI nuti = getNodeType();
if(nuti == Nav)
return ERROR;
if(nuti == Hzy)
return NOTREADY;
assert(m_varSymbol->getUlamTypeIdx() == nuti);
assert(!m_state.isAtom(nuti)); //rhs type of conditional as/has can't be an atom
UlamValue pluv = m_state.m_currentAutoObjPtr;
((SymbolVariableStack *) m_varSymbol)->setAutoPtrForEval(pluv); //for future ident eval uses
UTI luti = pluv.getPtrTargetType();
assert(m_state.okUTItoContinue(luti));
UlamType * lut = m_state.getUlamTypeByIndex(luti);
ULAMCLASSTYPE lclasstype = lut->getUlamClassType();
UTI autostgtype = m_state.m_currentAutoStorageType;
if((UlamType::compare(autostgtype, UAtom, m_state) == UTIC_SAME) && (lclasstype == UC_ELEMENT))
autostgtype = luti; //e.g. funccall expects a class, not an atom (t3636)
((SymbolVariableStack *) m_varSymbol)->setAutoStorageTypeForEval(autostgtype); //for future virtual function call eval uses
//m_state.m_funcCallStack.storeUlamValueInSlot(pluv, ((SymbolVariableStack *) m_varSymbol)->getStackFrameSlotIndex()); //doesn't seem to matter..
return NORMAL;
} //eval
示例9: switch
const std::string NodeBinaryOpEqualShift::methodNameForCodeGen()
{
std::ostringstream methodname;
//methodname << "_Shift"; determined by each op
UlamType * nut = m_state.getUlamTypeByIndex(getNodeType());
// common part of name
ULAMTYPE etyp = nut->getUlamTypeEnum();
switch(etyp)
{
case Int:
case Unsigned:
case Bool:
case Unary:
case Bits:
methodname << UlamType::getUlamTypeEnumAsString(etyp);
break;
default:
m_state.abortUndefinedUlamPrimitiveType();
break;
};
methodname << nut->getTotalWordSize();
return methodname.str();
} //methodNameForCodeGen
示例10: getTotalWordSize
const std::string UlamType::castMethodForCodeGen(UTI nodetype)
{
std::ostringstream rtnMethod;
UlamType * nut = m_state.getUlamTypeByIndex(nodetype);
//base types e.g. Int, Bool, Unary, Foo, Bar..
u32 sizeByIntBitsToBe = getTotalWordSize();
u32 sizeByIntBits = nut->getTotalWordSize();
if(sizeByIntBitsToBe != sizeByIntBits)
{
std::ostringstream msg;
msg << "Casting different word sizes; " << sizeByIntBits;
msg << ", Value Type and size was: " << nut->getUlamTypeName().c_str();
msg << ", to be: " << sizeByIntBitsToBe << " for type: ";
msg << getUlamTypeName().c_str();
MSG(m_state.getFullLocationAsString(m_state.m_locOfNextLineText).c_str(), msg.str().c_str(), DEBUG);
//use the larger word size
if(sizeByIntBitsToBe < sizeByIntBits) //downcast using larger
sizeByIntBitsToBe = sizeByIntBits;
else
sizeByIntBits = sizeByIntBitsToBe;
}
rtnMethod << "_" << nut->getUlamTypeNameOnly().c_str() << sizeByIntBits << "To";
rtnMethod << getUlamTypeNameOnly().c_str() << sizeByIntBitsToBe;
return rtnMethod.str();
} //castMethodForCodeGen
示例11: getUlamTypeIdx
// replaces NodeTypedef:printPostfix to learn the values of Class' storage in center site
void SymbolTypedef::printPostfixValuesOfVariableDeclarations(File * fp, s32 slot, u32 startpos, ULAMCLASSTYPE classtype)
{
UTI tuti = getUlamTypeIdx();
UlamKeyTypeSignature tkey = m_state.getUlamKeyTypeSignatureByIndex(tuti);
UlamType * tut = m_state.getUlamTypeByIndex(tuti);
fp->write(" typedef");
fp->write(" ");
if(tut->getUlamTypeEnum() != Class)
fp->write(tkey.getUlamKeyTypeSignatureNameAndBitSize(&m_state).c_str());
else
fp->write(tut->getUlamTypeNameBrief().c_str());
fp->write(" ");
fp->write(m_state.m_pool.getDataAsString(getId()).c_str());
s32 arraysize = m_state.getArraySize(tuti);
if(arraysize > NONARRAYSIZE)
{
fp->write("[");
fp->write_decimal(arraysize);
fp->write("]");
}
else if(arraysize == UNKNOWNSIZE)
{
fp->write("[UNKNOWN]");
}
fp->write("; ");
} //printPostfixValuesOfVariableDeclarations
示例12: switch
const std::string NodeBinaryOpEqualArith::methodNameForCodeGen()
{
std::ostringstream methodname;
//methodname << "_BitwiseOr"; determined by each op
UlamType * nut = m_state.getUlamTypeByIndex(getNodeType());
// common part of name
ULAMTYPE etyp = nut->getUlamTypeEnum();
switch(etyp)
{
case Int:
case Unsigned:
case Bool:
case Unary:
methodname << UlamType::getUlamTypeEnumAsString(etyp);
break;
case Bits:
default:
assert(0);
methodname << "NAV";
break;
};
methodname << nut->getTotalWordSize();
return methodname.str();
} //methodNameForCodeGen
示例13: checkAndLabelType
UTI NodeBinaryOpEqualArith::checkAndLabelType()
{
UTI nodeType = NodeBinaryOpEqual::checkAndLabelType();
UlamType * nut = m_state.getUlamTypeByIndex(nodeType);
// common part of name
ULAMTYPE enodetyp = nut->getUlamTypeEnum();
if(enodetyp == Bits)
{
// can happen with op-equal operations when both sides are the same type
MSG(getNodeLocationAsString().c_str(), "Arithmetic Operations are invalid on 'Bits' type", ERR);
nodeType = Nav;
}
if(enodetyp == Bool)
{
// can happen with op-equal operations when both sides are the same type
MSG(getNodeLocationAsString().c_str(), "Arithmetic Operations are invalid on 'Bool' type", ERR);
nodeType = Nav;
}
if((nodeType != Nav) && !nut->isScalar())
{
std::ostringstream msg;
msg << "Non-scalars require a loop for operator" << getName();
MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR);
nodeType = Nav;
}
setNodeType(nodeType);
return nodeType;
} //checkAndLabelType
示例14: assert
void NodeUnaryOp::genCode(File * fp, UVPass& uvpass)
{
assert(m_node);
m_node->genCode(fp, uvpass);
UTI nuti = getNodeType();
UlamType * nut = m_state.getUlamTypeByIndex(nuti);
s32 tmpVarNum = m_state.getNextTmpVarNumber();
m_state.indentUlamCode(fp);
fp->write("const ");
fp->write(nut->getTmpStorageTypeAsString().c_str()); //e.g. u32, s32, u64..
fp->write(" ");
fp->write(m_state.getTmpVarAsString(nuti, tmpVarNum, TMPREGISTER).c_str());
fp->write(" = ");
fp->write(methodNameForCodeGen().c_str());
fp->write("(");
fp->write(uvpass.getTmpVarAsString(m_state).c_str());
fp->write(", ");
fp->write_decimal(nut->getBitSize());
fp->write(");"); GCNL;
uvpass = UVPass::makePass(tmpVarNum, TMPREGISTER, nuti, m_state.determinePackable(nuti), m_state, 0, 0); //POS 0 rightjustified.
} //genCode
示例15: switch
const std::string NodeBinaryOpCompare::methodNameForCodeGen()
{
std::ostringstream methodname;
//methodname << "_BitwiseOr"; determined by each op
UlamType * lut = m_state.getUlamTypeByIndex(m_nodeLeft->getNodeType());
// common part of name
ULAMTYPE etyp = lut->getUlamTypeEnum();
switch(etyp)
{
case Int:
methodname << "Int";
break;
case Unsigned:
methodname << "Unsigned";
break;
case Bits:
methodname << "Bits";
break;
case Bool:
methodname << "Bool";
break;
case String:
methodname << "String";
break;
default:
m_state.abortUndefinedUlamPrimitiveType();
methodname << "NAV";
break;
};
methodname << lut->getTotalWordSize();
return methodname.str();
} // methodNameForCodeGen