当前位置: 首页>>代码示例>>C++>>正文


C++ UlamType::getTotalBitSize方法代码示例

本文整理汇总了C++中UlamType::getTotalBitSize方法的典型用法代码示例。如果您正苦于以下问题:C++ UlamType::getTotalBitSize方法的具体用法?C++ UlamType::getTotalBitSize怎么用?C++ UlamType::getTotalBitSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UlamType的用法示例。


在下文中一共展示了UlamType::getTotalBitSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getArrayValueAsString

  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
开发者ID:DaveAckley,项目名称:ULAM,代码行数:32,代码来源:SymbolWithValue.cpp

示例2: makeUlamValuePtr

  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
开发者ID:DaveAckley,项目名称:ULAM,代码行数:34,代码来源:NodeInstanceof.cpp

示例3: printPostfixValueArray

  void SymbolWithValue::printPostfixValueArray(File * fp)
  {
    BV8K dval;
    bool oktoprint = getValueReadyToPrint(dval);

    if(!oktoprint)
      {
	fp->write("NONREADYCONSTARRAY");
	return;
      }

    UTI tuti = getUlamTypeIdx();
    UlamType * tut = m_state.getUlamTypeByIndex(tuti);
    s32 tbs = tut->getTotalBitSize();
    if(tbs == 0)
      {
	fp->write("{ }");
	return; //nothing to do
      }

    //required as hex for String arrays too (needed for initialization) (t3974)
    //like the code generated in CS::genCodeClassDefaultConstantArray
    std::string dhex;
    bool nonZero = SymbolWithValue::getHexValueAsString(tbs, dval, dhex);

    //short-circuit if all zeros
    if(!nonZero)
      {
	if(tut->getUlamTypeEnum() == String) //t3953
	  m_state.abortShouldntGetHere();

	fp->write("{ 0 }");
	return; //nothing else to do
      }

    fp->write("{ ");
    fp->write(dhex.c_str());
    fp->write(" }");
  } //printPostfixValueArray
开发者ID:DaveAckley,项目名称:ULAM,代码行数:39,代码来源:SymbolWithValue.cpp

示例4: getValueAsHexString

 bool SymbolWithValue::getValueAsHexString(std::string& vstr)
  {
    BV8K dval;
    bool oktoprint = getValueReadyToPrint(dval);

    if(!oktoprint) return false;

    UTI tuti = getUlamTypeIdx();
    UlamType * tut = m_state.getUlamTypeByIndex(tuti);
    s32 tbs = tut->getTotalBitSize();

    if(tbs == 0)
      {
	vstr = "0"; //no "0x" hex indicates empty array
	return true;
      }

    s32 tnybbles = int(tbs/4); //4 bits per nybble (one Hex digit)

    std::ostringstream ostream;
    //ostream << "0x"; //no "0x"

    for(s32 i = 0; i < tnybbles; i++)
      {
	ostream << std::hex << dval.Read(i, 4); //per bit?
      }

    s32 remainder = tbs - tnybbles*4;
    if(remainder > 0)
      {
	//shift left for continguous bits
	ostream << std::hex << ((dval.Read(tnybbles*4, remainder)) << (4 - remainder));
      }

    vstr = ostream.str();
    return true;
  } //getValueAsHexString
开发者ID:DaveAckley,项目名称:ULAM,代码行数:37,代码来源:SymbolWithValue.cpp


注:本文中的UlamType::getTotalBitSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。