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
// 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
const std::string UlamKeyTypeSignature::getUlamKeyTypeSignatureAsString(UlamKeyTypeSignature utk, CompilerState* state) { std::ostringstream key; key << utk.getUlamKeyTypeSignatureName(state); if(utk.m_bits >= 0) key << "(" << utk.m_bits << ")"; else if(utk.m_bits == UNKNOWNSIZE) key << "(" << "UNKNOWN" << ")"; else if(utk.m_bits == CYCLEFLAG) key << "(" << "CYCLE" << ")"; else key << "(" << utk.m_bits << "?)"; //arraysize if(utk.m_arraySize >= 0) key << "[" << utk.m_arraySize << "]"; else if(utk.m_arraySize == UNKNOWNSIZE) key << "[" << "UNKNOWN" << "]"; else if(utk.m_arraySize != NONARRAYSIZE) key << "[" << utk.m_arraySize << "?]"; //key << "[" << "]"; if(utk.m_classInstanceIdx != Nouti) key << "<" << utk.m_classInstanceIdx << ">"; if(utk.m_referenceType != ALT_NOT) key << "<" << utk.m_referenceType << ">"; return key.str(); } //getUlamKeyTypeSignatureAsString
void NodeTypedef::printPostfix(File * fp) { assert(m_typedefSymbol); if(m_typedefSymbol->getId() == m_state.m_pool.getIndexForDataString("Self")) return; if(m_typedefSymbol->getId() == m_state.m_pool.getIndexForDataString("Super")) return; UTI tuti = m_typedefSymbol->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()); if(tut->isReference()) fp->write(" &"); //an array of refs as written, should be ref to an array. } else fp->write(tut->getUlamTypeNameBrief().c_str()); fp->write(" "); fp->write(getName()); 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("; "); } //printPostfix
// replaces NodeVarDecl:printPostfix to learn the values of Class' storage in center site void SymbolVariableDataMember::printPostfixValuesOfVariableDeclarations(File * fp, s32 slot, u32 startpos, ULAMCLASSTYPE classtype) { UTI vuti = getUlamTypeIdx(); UlamKeyTypeSignature vkey = m_state.getUlamKeyTypeSignatureByIndex(vuti); UlamType * vut = m_state.getUlamTypeByIndex(vuti); ULAMCLASSTYPE vclasstype = vut->getUlamClassType(); ULAMTYPE vetyp = vut->getUlamTypeEnum(); fp->write(" "); if(vclasstype == UC_NOTACLASS) fp->write(vkey.getUlamKeyTypeSignatureNameAndBitSize(&m_state).c_str()); else fp->write(vut->getUlamTypeNameBrief().c_str()); fp->write(" "); fp->write(m_state.m_pool.getDataAsString(getId()).c_str()); s32 arraysize = m_state.getArraySize(vuti); //scalar has 'size=1'; empty array [0] is still '0'. s32 size = (arraysize > NONARRAYSIZE ? arraysize : 1); //output the arraysize (optional), and open paren if(arraysize > NONARRAYSIZE) { fp->write("["); fp->write_decimal(arraysize); fp->write("]"); } else if(arraysize == UNKNOWNSIZE) { fp->write("[UNKNOWN]"); } fp->write("("); if(vclasstype == UC_QUARK) { //outputs the data members, not just the lump value (e.g. SWV::printPostfixValue()) UTI scalarquark = m_state.getUlamTypeAsScalar(vuti); //printPostfixValuesForClass: SymbolClass * csym = NULL; AssertBool isDefined = m_state.alreadyDefinedSymbolClass(scalarquark, csym); assert(isDefined); NodeBlockClass * classNode = csym->getClassBlockNode(); assert(classNode); u32 newstartpos = startpos + getPosOffset(); s32 len = vut->getBitSize(); for(s32 i = 0; i < size; i++) classNode->printPostfixDataMembersSymbols(fp, slot, newstartpos + len * i, vclasstype); } else { PACKFIT packFit = m_state.determinePackable(vuti); assert(WritePacked(packFit)); //has to be to fit in an atom/site; char * valstr = new char[size * 8 + MAXBITSPERLONG]; //was 32 if(size > 0) { //build the string of values (for both scalar and packed array) UlamValue arrayPtr = UlamValue::makePtr(slot, EVENTWINDOW, vuti, packFit, m_state, startpos + getPosOffset(), getId()); UlamValue nextPtr = UlamValue::makeScalarPtr(arrayPtr, m_state); UlamValue atval = m_state.getPtrTarget(nextPtr); s32 len = m_state.getBitSize(vuti); if(len == UNKNOWNSIZE) { sprintf(valstr,"unknown"); for(s32 i = 1; i < size; i++) { strcat(valstr,", unknown"); } } else if(len <= MAXBITSPERINT) { u32 data = atval.getDataFromAtom(nextPtr, m_state); vut->getDataAsString(data, valstr, 'z'); //'z' -> no preceeding ',' if(vetyp == Unsigned || vetyp == Unary) strcat(valstr, "u"); for(s32 i = 1; i < size; i++) { char tmpstr[8]; AssertBool isNext = nextPtr.incrementPtr(m_state); assert(isNext); atval = m_state.getPtrTarget(nextPtr); data = atval.getDataFromAtom(nextPtr, m_state); vut->getDataAsString(data, tmpstr, ','); if(vetyp == Unsigned || vetyp == Unary) strcat(tmpstr, "u"); strcat(valstr,tmpstr); } } else if(len <= MAXBITSPERLONG) { u64 data = atval.getDataLongFromAtom(nextPtr, m_state); vut->getDataLongAsString(data, valstr, 'z'); //'z' -> no preceeding ',' if(vetyp == Unsigned || vetyp == Unary) strcat(valstr, "u"); for(s32 i = 1; i < size; i++) { char tmpstr[8]; AssertBool isNext = nextPtr.incrementPtr(m_state); assert(isNext); atval = m_state.getPtrTarget(nextPtr); data = atval.getDataLongFromAtom(nextPtr, m_state); vut->getDataLongAsString(data, tmpstr, ','); if(vetyp == Unsigned || vetyp == Unary) strcat(tmpstr, "u"); strcat(valstr,tmpstr); } } else assert(0); } //end arrays > 0, and scalar else { sprintf(valstr," "); } fp->write(valstr); //results out here! delete [] valstr; } //not a quark fp->write("); "); } //printPostfixValuesOfVariableDeclarations
// replaces NodeVarDecl:printPostfix to learn the values of Class' storage in center site void SymbolVariableDataMember::printPostfixValuesOfVariableDeclarations(File * fp, s32 slot, u32 startpos, ULAMCLASSTYPE classtype) { UTI vuti = getUlamTypeIdx(); UlamKeyTypeSignature vkey = m_state.getUlamKeyTypeSignatureByIndex(vuti); UlamType * vut = m_state.getUlamTypeByIndex(vuti); ULAMCLASSTYPE vclasstype = vut->getUlamClass(); fp->write(" "); if(vclasstype == UC_NOTACLASS) fp->write(vkey.getUlamKeyTypeSignatureNameAndBitSize(&m_state).c_str()); else fp->write(vut->getUlamTypeNameBrief().c_str()); fp->write(" "); fp->write(m_state.m_pool.getDataAsString(getId()).c_str()); s32 arraysize = m_state.getArraySize(vuti); //scalar has 'size=1'; empty array [0] is still '0'. s32 size = (arraysize > NONARRAYSIZE ? arraysize : 1); //output the arraysize (optional), and open paren if(arraysize > NONARRAYSIZE) { fp->write("["); fp->write_decimal(arraysize); fp->write("]"); } else if(arraysize == UNKNOWNSIZE) { fp->write("[UNKNOWN]"); } fp->write("("); if(vclasstype == UC_QUARK) { //printPostfixValuesForClass: SymbolClass * csym = NULL; if(m_state.alreadyDefinedSymbolClass(vuti, csym)) { NodeBlockClass * classNode = csym->getClassBlockNode(); assert(classNode); SymbolTable * stptr = classNode->getSymbolTablePtr(); //ST of data members u32 newstartpos = startpos + getPosOffset(); s32 len = vut->getBitSize(); for(s32 i = 0; i < size; i++) stptr->printPostfixValuesForTableOfVariableDataMembers(fp, slot, newstartpos + len * i, vclasstype); } else { assert(0); //error! } } else { PACKFIT packFit = m_state.determinePackable(vuti); assert(WritePacked(packFit)); //has to be to fit in an atom/site; char * valstr = new char[size * 8 + MAXBITSPERLONG]; //was 32 if(size > 0) { //simplifying assumption for testing purposes: center site //Coord c0(0,0); //u32 slot = c0.convertCoordToIndex(); //build the string of values (for both scalar and packed array) UlamValue arrayPtr = UlamValue::makePtr(slot, EVENTWINDOW, vuti, packFit, m_state, startpos + getPosOffset(), getId()); UlamValue nextPtr = UlamValue::makeScalarPtr(arrayPtr, m_state); UlamValue atval = m_state.getPtrTarget(nextPtr); s32 len = nextPtr.getPtrLen(); assert(len != UNKNOWNSIZE); if(len <= MAXBITSPERINT) { u32 data = atval.getDataFromAtom(nextPtr, m_state); vut->getDataAsString(data, valstr, 'z'); //'z' -> no preceeding ',' for(s32 i = 1; i < size; i++) { char tmpstr[8]; assert(nextPtr.incrementPtr(m_state)); atval = m_state.getPtrTarget(nextPtr); data = atval.getDataFromAtom(nextPtr, m_state); vut->getDataAsString(data, tmpstr, ','); strcat(valstr,tmpstr); } } else if(len <= MAXBITSPERLONG) { u64 data = atval.getDataLongFromAtom(nextPtr, m_state); vut->getDataLongAsString(data, valstr, 'z'); //'z' -> no preceeding ',' for(s32 i = 1; i < size; i++) { char tmpstr[8]; assert(nextPtr.incrementPtr(m_state)); atval = m_state.getPtrTarget(nextPtr); data = atval.getDataLongFromAtom(nextPtr, m_state); vut->getDataLongAsString(data, tmpstr, ','); strcat(valstr,tmpstr); } } else assert(0); } //end arrays > 0, and scalar else { sprintf(valstr," "); } fp->write(valstr); //results out here! delete [] valstr; } //not a quark fp->write("); "); } //printPostfixValuesOfVariableDeclarations