/* print a type to a stream without using printf/sprintf */ void PrintType(struct ValueType *Typ, Picoc* pc) { switch (Typ->Base) { case TypeVoid: PlatformPrintf(pc, "void"); break; case TypeInt: PlatformPrintf(pc, "int"); break; case TypeShort: PlatformPrintf(pc, "short"); break; case TypeChar: PlatformPrintf(pc, "char"); break; case TypeLong: PlatformPrintf(pc, "long"); break; case TypeUnsignedInt: PlatformPrintf(pc, "unsigned int"); break; case TypeUnsignedShort: PlatformPrintf(pc, "unsigned short"); break; case TypeUnsignedLong: PlatformPrintf(pc, "unsigned long"); break; case TypeUnsignedChar: PlatformPrintf(pc, "unsigned char"); break; #ifndef NO_FP case TypeFP: PlatformPrintf(pc, "double"); break; #endif case TypeFunction: PlatformPrintf(pc, "function"); break; case TypeMacro: PlatformPrintf(pc, "macro"); break; case TypePointer: if (Typ->FromType) PrintType(Typ->FromType, pc); PlatformPrintf(pc, "*"); break; case TypeArray: PrintType(Typ->FromType, pc); PlatformPrintf(pc, "["); if (Typ->ArraySize != 0) PlatformPrintf(pc, "%d", Typ->ArraySize); PlatformPrintf(pc, "]"); break; case TypeStruct: PlatformPrintf(pc, "struct "); PlatformPrintf(pc, Typ->Identifier); break; case TypeUnion: PlatformPrintf(pc, "union "); PlatformPrintf(pc, Typ->Identifier); break; case TypeEnum: PlatformPrintf(pc, "enum "); PlatformPrintf(pc, Typ->Identifier); break; case TypeGotoLabel: PlatformPrintf(pc, "goto label "); break; case Type_Type: PlatformPrintf(pc, "type "); break; } }
/* print a type to a stream without using printf/sprintf */ void PrintType(struct ValueType *Typ, IOFILE *Stream) { switch (Typ->Base) { case TypeVoid: PrintStr("void", Stream); break; case TypeInt: PrintStr("int", Stream); break; case TypeShort: PrintStr("short", Stream); break; case TypeChar: PrintStr("char", Stream); break; case TypeLong: PrintStr("long", Stream); break; case TypeUnsignedInt: PrintStr("unsigned int", Stream); break; case TypeUnsignedShort: PrintStr("unsigned short", Stream); break; case TypeUnsignedLong: PrintStr("unsigned long", Stream); break; #ifndef NO_FP case TypeFP: PrintStr("double", Stream); break; #endif case TypeFunction: PrintStr("function", Stream); break; case TypeMacro: PrintStr("macro", Stream); break; case TypePointer: if (Typ->FromType) PrintType(Typ->FromType, Stream); PrintCh('*', Stream); break; case TypeArray: PrintType(Typ->FromType, Stream); PrintCh('[', Stream); if (Typ->ArraySize != 0) PrintSimpleInt(Typ->ArraySize, Stream); PrintCh(']', Stream); break; case TypeStruct: PrintStr("struct ", Stream); PrintStr(Typ->Identifier, Stream); break; case TypeUnion: PrintStr("union ", Stream); PrintStr(Typ->Identifier, Stream); break; case TypeEnum: PrintStr("enum ", Stream); PrintStr(Typ->Identifier, Stream); break; case TypeGotoLabel: PrintStr("goto label ", Stream); break; case Type_Type: PrintStr("type ", Stream); break; } }
void PrintCompact(dev_t device, bool showBlocks, bool all) { fs_info info; if (fs_stat_dev(device, &info) != B_OK) return; if (!all && (info.flags & B_FS_IS_PERSISTENT) == 0) return; PrintMountPoint(info.dev, false); PrintType(info.fsh_name); PrintBlocks(info.total_blocks, info.block_size, showBlocks); PrintBlocks(info.free_blocks, info.block_size, showBlocks); printf(" "); PrintFlag(info.flags, B_FS_HAS_QUERY, "Q", "-"); PrintFlag(info.flags, B_FS_HAS_ATTR, "A", "-"); PrintFlag(info.flags, B_FS_HAS_MIME, "M", "-"); PrintFlag(info.flags, B_FS_IS_SHARED, "S", "-"); PrintFlag(info.flags, B_FS_IS_PERSISTENT, "P", "-"); PrintFlag(info.flags, B_FS_IS_REMOVABLE, "R", "-"); PrintFlag(info.flags, B_FS_IS_READONLY, "-", "W"); printf(" %s\n", info.device_name); }
void PrintTypesString( void *theEnv, const char *logicalName, unsigned expectedType, bool printCRLF) { int typeCount, typesPrinted; typeCount = 0; if (expectedType & INTEGER_TYPE) typeCount++; if (expectedType & FLOAT_TYPE) typeCount++; if (expectedType & SYMBOL_TYPE) typeCount++; if (expectedType & STRING_TYPE) typeCount++; if (expectedType & INSTANCE_NAME_TYPE) typeCount++; if (expectedType & INSTANCE_ADDRESS_TYPE) typeCount++; if (expectedType & FACT_ADDRESS_TYPE) typeCount++; if (expectedType & EXTERNAL_ADDRESS_TYPE) typeCount++; if (expectedType & MULTIFIELD_TYPE) typeCount++; typesPrinted = 0; if (expectedType & INTEGER_TYPE) { PrintType(theEnv,logicalName,typeCount,&typesPrinted,"integer"); } if (expectedType & FLOAT_TYPE) { PrintType(theEnv,logicalName,typeCount,&typesPrinted,"float"); } if (expectedType & SYMBOL_TYPE) { PrintType(theEnv,logicalName,typeCount,&typesPrinted,"symbol"); } if (expectedType & STRING_TYPE) { PrintType(theEnv,logicalName,typeCount,&typesPrinted,"string"); } if (expectedType & INSTANCE_NAME_TYPE) { PrintType(theEnv,logicalName,typeCount,&typesPrinted,"instance name"); } if (expectedType & INSTANCE_ADDRESS_TYPE) { PrintType(theEnv,logicalName,typeCount,&typesPrinted,"instance address"); } if (expectedType & FACT_ADDRESS_TYPE) { PrintType(theEnv,logicalName,typeCount,&typesPrinted,"fact address"); } if (expectedType & EXTERNAL_ADDRESS_TYPE) { PrintType(theEnv,logicalName,typeCount,&typesPrinted,"external address"); } if (expectedType & MULTIFIELD_TYPE) { PrintType(theEnv,logicalName,typeCount,&typesPrinted,"multifield"); } if (printCRLF) { EnvPrintRouter(theEnv,logicalName,"\n"); } }
void PrintFuncSig (FILE* F, const char* Name, Type* T) /* Print a function signature. */ { /* Get the function descriptor */ const FuncDesc* D = GetFuncDesc (T); /* Print a comment with the function signature */ PrintType (F, GetFuncReturn (T)); if (IsQualNear (T)) { fprintf (F, " __near__"); } if (IsQualFar (T)) { fprintf (F, " __far__"); } if (IsQualFastcall (T)) { fprintf (F, " __fastcall__"); } if (IsQualCDecl (T)) { fprintf (F, " __cdecl__"); } fprintf (F, " %s (", Name); /* Parameters */ if (D->Flags & FD_VOID_PARAM) { fprintf (F, "void"); } else { unsigned I; SymEntry* E = D->SymTab->SymHead; for (I = 0; I < D->ParamCount; ++I) { if (I > 0) { fprintf (F, ", "); } if (SymIsRegVar (E)) { fprintf (F, "register "); } PrintType (F, E->Type); E = E->NextSym; } } /* End of parameter list */ fprintf (F, ")"); }
void PrintTypeForValue(ParsingDefinitionType* _type, ParsingSymbol* _scope, ParsingSymbolManager* _manager, const WString& _codeClassPrefix, TextWriter& _writer) { List<Ptr<ParsingError>> errors; ParsingSymbol* type=FindType(_type, _manager, _scope, errors); if(type->GetType()==ParsingSymbol::EnumType) { PrintType(_type, _scope, _manager, _codeClassPrefix, _writer); } else if(type->GetType()==ParsingSymbol::ClassType) { _writer.WriteString(L"vl::Ptr<"); PrintType(_type, _scope, _manager, _codeClassPrefix, _writer); _writer.WriteString(L">"); } else { PrintType(_type, _scope, _manager, _codeClassPrefix, _writer); } }
/*! \fn void RoutingNode::Print() * \brief to write the RoutingNode features */ void RoutingNode::Print() { std::cerr << "The routing node has the following features \n"; PrintId(); PrintHost(); PrintSource(); PrintPrevious(); PrintType(); PrintFull(); }
void DeclarationNode::PrintMemory(ostream &out) const { switch (subKind) { case FuncK: out << '\n' << name << " Func returns " << PrintType(type) << "[size: " << size << "]\n"; break; case VarK: out << ((theScope == TreeNode::Global)?"\n":"") << name << ' ' << PrintType(type) << " Var "; if (isArray) out << "is array of size " << size << ' '; out << "[offset: " << offset << " type: " << ((theScope == TreeNode::Global)?"global":"local") << "]\n"; break; case ParamK: out << name << ' ' << PrintType(type) << " Param "; if (isArray) out << "is array "; out << "[offset: " << offset << " type: parameter]\n"; break; } TreeNode::PrintMemory(out); }
VECGEOM_CUDA_HEADER_BOTH void VPlacedVolume::Print(const int indent) const { for (int i = 0; i < indent; ++i) printf(" "); PrintType(); printf(" [%i]", id_); #ifndef VECGEOM_NVCC if (label_->size()) { printf(" \"%s\"", label_->c_str()); } #endif printf(": \n"); for (int i = 0; i <= indent; ++i) printf(" "); transformation_->Print(); printf("\n"); logical_volume_->Print(indent+1); }
string Node::PrintEverything() { string output; output += "\t<NODE>\n"; output += PrintName(); output += PrintDefault(); output += PrintNodeNum(); output += PrintIPAddress(); output += PrintLocation(); output += PrintType(); output += PrintZone(); output += PrintParentNodeNum(); output += PrintParentDistance(); output += PrintStateChangeTime(); output += PrintChildren(); output += "\t</NODE>\n"; return output; }
void DeclarationNode::GenCode(CodeEmitter &e, bool travSib, int virtualRegister, int toff) { DeclarationNode *dPtr; // Assign virtual register to 'real' register int actualRegister = virtualRegister%MAX_EXP_REGISTERS+FIRST_REG_OFFSET; // Don't generate code for IO functions if (subKind == FuncK && name != "input" && name != "output" && name != "inputb" && name != "outputb") { // Lookup in symbol table - we'll need to set the "offset" variable dPtr = (DeclarationNode *)this; dPtr->offset = e.emitSkip(0); // save the current location for calls later // If this function is main, we need to backpatch in the jump from the prolog if (name == "main") { e.emitBackup(jumpMain); e.emitRMAbs("LDA", pc, dPtr->offset, "jump to main"); e.emitRestore(); } e.emitComment("Function " + name + " returns " + PrintType(type)); e.emitRM("ST", FIRST_REG_OFFSET, -1, fp, "store return address"); // return address is always -1 away from current frame // Load up the foff variable with the function size foff = size; // Function Body if (child[1] != NULL) { child[1]->GenCode(e, true, virtualRegister, foff); } // Add Return Statement if the function doesn't return from all branches if (!allPathsReturn) { e.emitComment("This function requires a catch all return"); e.emitRM("LDC", rt, 0, 0, "Set return value to 0"); e.emitRM("LD", actualRegister, -1, fp, "Load return address"); e.emitRM("LD", fp, 0, fp, "Adjust fp"); e.emitRM("LDA", pc, 0, actualRegister, "Return"); } else e.emitComment("This function returns from all paths, no catch all return required"); e.emitComment("End Function " + name); } if (sibling != NULL) sibling->GenCode(e, true, virtualRegister, toff); }
/* Outputs the contents of a NeXus group */ int NXBdir(NXhandle fileId) { int status, dataType, dataRank, dataDimensions[NX_MAXRANK], length; NXname name, nxclass, nxurl; if (NXinitgroupdir(fileId) != NX_OK) return NX_ERROR; do { status = NXgetnextentry(fileId, name, nxclass, &dataType); if (status == NX_ERROR) break; if (status == NX_OK) { if (strncmp(nxclass, "CDF", 3) == 0) { ; } else if (strcmp(nxclass, "SDS") == 0) { printf(" NX Data : %s", name); if (NXopendata(fileId, name) != NX_OK) return NX_ERROR; if (NXgetinfo (fileId, &dataRank, dataDimensions, &dataType) != NX_OK) return NX_ERROR; if (NXclosedata(fileId) != NX_OK) return NX_ERROR; PrintDimensions(dataRank, dataDimensions); printf(" "); PrintType(dataType); printf("\n"); } else { length = sizeof(nxurl); if (NXisexternalgroup(fileId, name, nxclass, nxurl, length) == NX_OK) { printf(" NX external Group: %s (%s), linked to: %s \n", name, nxclass, nxurl); } else { printf(" NX Group : %s (%s)\n", name, nxclass); if ((status = NXopengroup(fileId, name, nxclass)) != NX_OK) { return status; } PrintGroupAttributes(fileId, name); if ((status = NXclosegroup(fileId)) != NX_OK) { return status; } } } } } while (status == NX_OK); return status; }
static TRI_aql_node_t* DumpNode (TRI_aql_statement_walker_t* const walker, TRI_aql_node_t* const node) { TRI_aql_dump_t* state = (TRI_aql_dump_t*) walker->_data; if (node == NULL) { return node; } assert(state); PrintType(state, node->_type); Indent(state); switch (node->_type) { case TRI_AQL_NODE_VALUE: DumpValue(state, node); break; case TRI_AQL_NODE_VARIABLE: case TRI_AQL_NODE_ATTRIBUTE: case TRI_AQL_NODE_REFERENCE: case TRI_AQL_NODE_PARAMETER: case TRI_AQL_NODE_ARRAY_ELEMENT: case TRI_AQL_NODE_ATTRIBUTE_ACCESS: DumpString(state, node); break; case TRI_AQL_NODE_FCALL: printf("name: %s\n", TRI_GetInternalNameFunctionAql((TRI_aql_function_t*) TRI_AQL_NODE_DATA(node))); break; case TRI_AQL_NODE_SORT_ELEMENT: PrintIndent(state); printf("asc/desc: %lu\n", (unsigned long) TRI_AQL_NODE_BOOL(node)); break; default: { // nada } } Outdent(state); return node; }
void Node::Print(int indent) { for (int i = 0; i < indent; i++) printf("\t"); printf("Node "); PrintType(); if (next.size() == 0) { printf("\n"); } else { printf(" --> (\n"); for (auto &n : next) n->Print(indent+1); for (int i = 0; i < indent; i++) printf("\t"); printf(")\n"); } }
void Dump2(FILE *fp) { size_t i; for(i = 0; i < globalTypeDeclList.size(); i++) { TypeDecl *typeDecl = globalTypeDeclList[i]; for(size_t x = 0; x < typeDecl->declList.size(); x++) { Type *t = typeDecl->declList[x]; PrintType(t); printf(";\n"); } } printf("\n\n"); }
/** main function. * * man Function * * @param argc : 파라미터 개수 * @param *argv[] : 파라미터 * * @return S32 * @see msrp_main.c * * @exception . * @note . **/ S32 main(S32 argc, S8 *argv[]) { S32 dRet; /**< 함수 Return 값 */ OFFSET offset; U8 *pNode; U8 *pNextNode; U8 *p, *data; S32 type, len, ismalloc; TEXT_INFO *pstTEXTINFO; U8 *pDATA; char vERSION[7] = "R3.0.0"; /* log_print 초기화 */ log_init(S_SSHM_LOG_LEVEL, getpid(), SEQ_PROC_A_MSRPT, LOG_PATH"/A_MSRPT", "A_MSRPT"); /* A_HTTP 초기화 */ if((dRet = dInitMSRPT(&pstMEMSINFO, &pstMSRPTHASH, &pstTIMERNINFO)) < 0) { log_print(LOGN_CRI, "F=%s:%s.%d dInitMSRPT dRet=%d", __FILE__, __FUNCTION__, __LINE__, dRet); exit(0); } if((dRet = set_version(S_SSHM_VERSION, SEQ_PROC_A_MSRPT, vERSION)) < 0 ) { log_print(LOGN_CRI, "SET_VERSION ERROR(RET=%d,IDX=%d,VER=%s)", dRet, SEQ_PROC_A_MSRPT, vERSION); } guiTimerValue = flt_info->stTimerInfo.usTimerInfo[PI_MSRP_TIMEOUT]; log_print(LOGN_CRI, "START MSRPT VER[%s] TRANSCNT[%d] TIMER[%d]", vERSION, MSRPT_TRANS_CNT, guiTimerValue); /* MAIN LOOP */ while(giStopFlag) { timerN_invoke(pstTIMERNINFO); if((offset = gifo_read(pstMEMSINFO, gpCIFO, SEQ_PROC_A_MSRPM)) > 0) { log_print(LOGN_INFO, "======================================================================"); /* DB LOG 전송을 목적으로 하는 NODE (삭제 하지 않고 전송하기 위함 )*/ pNode = nifo_ptr(pstMEMSINFO, offset); pNextNode = pNode; pstTEXTINFO = NULL; pDATA = NULL; do { p = pNextNode; while(p != NULL) { if((dRet = nifo_read_tlv_cont(pstMEMSINFO, pNextNode, (U32*)&type, (U32*)&len, &data, &ismalloc, &p)) < 0) break; log_print(LOGN_INFO, "####################################################################"); log_print(LOGN_INFO, "TYPE[%d][%s] LEN[%d] ISMALLOC[%s]", type, PrintType(type), len, (ismalloc == DEF_READ_MALLOC) ? "MALLOC MEM" : "ORIGIN MEM"); switch(type) { case ETH_DATA_NUM: if(pstTEXTINFO != NULL) { pDATA = &data[pstTEXTINFO->offset]; log_print(LOGN_INFO, "PACKET TYPE[%d]", type); log_print(LOGN_INFO, "DATA[%.*s]", pstTEXTINFO->len, pDATA); } else { log_print(LOGN_CRI, "RCV PACKET_DATA BUT NOT RCV TEXT_INFO"); } break; case TEXT_INFO_DEF_NUM: pstTEXTINFO = (TEXT_INFO *)data; log_print(LOGN_INFO, "TEXT_INFO TYPE[%d]", type); log_print(LOGN_INFO, "TEXT_INFO OFFSET[%ld]LEN[%d]S[%u.%u]U[%u.%u]A[%u.%u]", pstTEXTINFO->offset, pstTEXTINFO->len, pstTEXTINFO->uiStartTime, pstTEXTINFO->uiStartMTime, pstTEXTINFO->uiLastUpdateTime, pstTEXTINFO->uiLastUpdateMTime, pstTEXTINFO->uiAckTime, pstTEXTINFO->uiAckMTime); break; /* Ignore Case */ default: log_print(LOGN_INFO, "????? UNKNOWN TYPE[%d]", type); break; } if(ismalloc == DEF_READ_MALLOC){ free(data); } } pNextNode = (U8 *)nifo_entry(nifo_ptr(pstMEMSINFO, ((NIFO *)pNextNode)->nont.offset_next), NIFO, nont); } while(pNode != pNextNode); if((pstTEXTINFO != NULL) && (pDATA != NULL)) { if(dProcMSRPTTrans(pstMEMSINFO, pstMSRPTHASH, pstTIMERNINFO, pstTEXTINFO, pDATA) < 0) { } } nifo_node_delete(pstMEMSINFO, pNode); } else { usleep(0); } } FinishProgram(); return 0; }
void DumpSymEntry (FILE* F, const SymEntry* E) /* Dump the given symbol table entry to the file in readable form */ { static const struct { const char* Name; unsigned Val; } Flags [] = { /* Beware: Order is important! */ { "SC_TYPEDEF", SC_TYPEDEF }, { "SC_BITFIELD", SC_BITFIELD }, { "SC_STRUCTFIELD", SC_STRUCTFIELD }, { "SC_STRUCT", SC_STRUCT }, { "SC_AUTO", SC_AUTO }, { "SC_REGISTER", SC_REGISTER }, { "SC_STATIC", SC_STATIC }, { "SC_EXTERN", SC_EXTERN }, { "SC_ENUM", SC_ENUM }, { "SC_CONST", SC_CONST }, { "SC_LABEL", SC_LABEL }, { "SC_PARAM", SC_PARAM }, { "SC_FUNC", SC_FUNC }, { "SC_STORAGE", SC_STORAGE }, { "SC_DEF", SC_DEF }, { "SC_REF", SC_REF }, { "SC_ZEROPAGE", SC_ZEROPAGE }, }; unsigned I; unsigned SymFlags; /* Print the name */ fprintf (F, "%s:\n", E->Name); /* Print the assembler name if we have one */ if (E->AsmName) { fprintf (F, " AsmName: %s\n", E->AsmName); } /* Print the flags */ SymFlags = E->Flags; fprintf (F, " Flags: "); for (I = 0; I < sizeof (Flags) / sizeof (Flags[0]) && SymFlags != 0; ++I) { if ((SymFlags & Flags[I].Val) == Flags[I].Val) { SymFlags &= ~Flags[I].Val; fprintf (F, "%s ", Flags[I].Name); } } if (SymFlags != 0) { fprintf (F, "%04X", SymFlags); } fprintf (F, "\n"); /* Print the type */ fprintf (F, " Type: "); if (E->Type) { PrintType (F, E->Type); } else { fprintf (F, "(none)"); } fprintf (F, "\n"); }
static void printObjAsNumber(CFNumberRef obj) { CFNumberType numType = CFNumberGetType(obj); union { #define DefineValue(type) type type##Value DefineValue(SInt8); DefineValue(SInt16); DefineValue(SInt32); DefineValue(SInt64); DefineValue(Float32); DefineValue(Float64); char CharValue; short ShortValue; int IntValue; long LongValue; long long LongLongValue; float FloatValue; double DoubleValue; DefineValue(CFIndex); int NSIntegerValue; float CGFloatValue; #undef DefineValue } res; CFNumberGetValue(obj, numType, &res); #define PrintType(formatStr, t1, dummy) \ case kCFNumber##t1##Type: \ printf(formatStr, res.t1##Value); \ break switch (numType) { PrintType("%d", SInt8, SInt8); PrintType("%d", SInt16, SInt16); PrintType("%ld", SInt32, SInt32); PrintType("%lld", SInt64, SInt64); PrintType("%g", Float32, Float32); PrintType("%lg", Float64, Float64); case kCFNumberCharType: if (res.CharValue >= ' ' && res.CharValue < '\x7F') { if (res.CharValue == '\'' || res.CharValue == '\\') printf("'\\%c'", res.CharValue); else printf("'%c'", res.CharValue); } else if (res.CharValue == '\t') printf("'\\t'"); else if (res.CharValue == '\n') printf("'\\n'"); else printf("'\\U%04x'", res.CharValue); break; PrintType("%d", Short, short); PrintType("%d", Int, int); PrintType("%ld", Long, long); PrintType("%lld", LongLong, long long); PrintType("%f", Float, float); PrintType("%lg", Double, double); PrintType("%ld", CFIndex, CFIndex); PrintType("%d", NSInteger, int); PrintType("%g", CGFloat, float); // PrintType("%f", Max, float); default: break; } #undef PrintType }
void ExpressionNode::ScopeAndType(ostream &out, int &numErrors) { DeclarationNode *dPtr, *paramPtr, *tempdPtr; ExpressionNode *argPtr; int argCounter; Types lhs_type, rhs_type, lhs_decl, rhs_decl, returnType; bool isUnary, lhs_isArray, rhs_isArray, foundError; lhs_type = rhs_type = lhs_decl = rhs_decl = returnType = Undefined; // initialize types to undefined lhs_isArray = rhs_isArray = foundError = false; // initialize booleans to false isUnary = true; string nameToLookup; switch (subKind) { case AssignK: op = "="; // populate the op for assignments with "=" to make Op logic work properly // intentionally drop through to OpK case... case OpK: if (child[0] != NULL) { child[0]->ScopeAndType(out, numErrors); lhs_type = ((ExpressionNode *)child[0])->type; // grab lhs type lhs_isArray = child[0]->getIsArray(); } if (child[1] != NULL) { isUnary = false; child[1]->ScopeAndType(out, numErrors); rhs_type = ((ExpressionNode *)child[1])->type; // grab lhs type rhs_isArray = child[1]->getIsArray(); } lookupTypes(op, lhs_decl, rhs_decl, returnType); // populate the last three variable from the function //DEBUG /*if (lineNumber == 26) { cerr << "op: " << op << "\nlhs_decl: " << PrintType(lhs_decl) << " lhs_type: " << PrintType(lhs_type) << "\nrhs_decl: " << PrintType(rhs_decl) << " rhs_type: " << PrintType(rhs_type) << "\nlhs_isArray: " << boolalpha << lhs_isArray << "\nrhs_isArray: " << rhs_isArray << noboolalpha << endl; }*/ //DEBUG // unary ops if (isUnary && lhs_type != Error) { //check for arrays if (lhs_isArray) { ++numErrors; foundError = true; // Unary operator array check error PrintError(out, 16, lineNumber, op, "", "", 0, 0); } else if (lhs_type != lhs_decl) { // do type check on unary op ++numErrors; foundError = true; // Unary operator type check error PrintError(out, 17, lineNumber, op, PrintType(lhs_decl), PrintType(lhs_type), 0, 0); } } // binary ops else if (!isUnary) { // check for arrays if (lhs_type != Error && rhs_type != Error && (lhs_isArray || rhs_isArray)) { ++numErrors; foundError = true; // binary operator array check error PrintError(out, 16, lineNumber, op, "", "", 0, 0); } // check for binary ops that can process different types as long as they are the same else if (lhs_type != Error && rhs_type != Error && lhs_decl == Undefined && rhs_decl == Undefined && lhs_type != rhs_type) { ++numErrors; foundError = true; // same type required check error PrintError(out, 1, lineNumber, op, PrintType(lhs_type), PrintType(rhs_type), 0, 0); } // do type check for strict binary operators /*else { if (lhs_type != Error && lhs_decl != Undefined && lhs_decl != lhs_type) { ++numErrors; foundError = true; // binary lhs type check error PrintError(out, 2, lineNumber, op, PrintType(lhs_decl), PrintType(lhs_type), 0, 0); } if (rhs_type != Error && rhs_decl != Undefined && rhs_decl != rhs_type) { ++numErrors; foundError = true; // binary rhs type check error PrintError(out, 3, lineNumber, op, PrintType(rhs_decl), PrintType(rhs_type), 0, 0); } }*/ else if (lhs_type != Error && rhs_type != Error) { if (lhs_decl != Undefined && lhs_decl != lhs_type) { ++numErrors; foundError = true; // binary lhs type check error PrintError(out, 2, lineNumber, op, PrintType(lhs_decl), PrintType(lhs_type), 0, 0); } if (rhs_decl != Undefined && rhs_decl != rhs_type) { ++numErrors; foundError = true; // binary rhs type check error PrintError(out, 3, lineNumber, op, PrintType(rhs_decl), PrintType(rhs_type), 0, 0); } } } // set the type for this node if (foundError || lhs_type == Error || rhs_type == Error) // propagate the error type to avoid cascading errors this->type = Error; else { if (returnType == Undefined) this->type = lhs_type; // if returnType is undefined return the lhs (used for ops that can process multiple types) else this->type = returnType; } break; case IdK: // make sure symbol exists dPtr = (DeclarationNode *)symtab->lookup(name.c_str()); if (dPtr != NULL) { // populate this ID node with the type from the symbol table if (dPtr->subKind == FuncK) { ++numErrors; // Cannot use functions like simple variables PrintError(out, 21, lineNumber, name, "", "", 0, 0); this->type = Error; // don't bother trying to check type if expression } else this->type = dPtr->type; this->dPtr = dPtr; // save this link for later in Code Generation } else if (dPtr == NULL) { ++numErrors; // this symbol has not been declared error PrintError(out, 15, lineNumber, name, "", "", 0, 0); this->type = Error; // set the type to error to avoid cascading errors } if (child[0] != NULL) { // this ID has an indexer child[0]->ScopeAndType(out, numErrors); if (!(dPtr->isArray)) { // if the symbol table record does show this ID as an array ... ++numErrors; // can't index nonarray error PrintError(out, 4, lineNumber, name, "", "", 0, 0); } else if (((ExpressionNode *)child[0])->type != Error && ((ExpressionNode *)child[0])->type != Int) { // index need to be type int ++numErrors; // array index type check error PrintError(out, 10, lineNumber, PrintType(((ExpressionNode *)child[0])->type), "", "", 0, 0); } } break; case CallK: // make sure symbol exists dPtr = (DeclarationNode *)symtab->lookup(name.c_str()); this->dPtr = dPtr; // save this link for later in Code Generation if (dPtr == NULL) { ++numErrors; // this symbol has not been declared PrintError(out, 15, lineNumber, name, "", "", 0, 0); this->type = Error; // set the type to error to avoid cascading errors } else if (dPtr->subKind != FuncK) { ++numErrors; // variables cannot be called like functions PrintError(out, 20, lineNumber, name, "", "", 0, 0); } else { // Process the properly declared functions this->type = dPtr->type; // the type of this node is the return type of the function paramPtr = (DeclarationNode *)dPtr->child[0]; // set the parameter pointer to the function declaration parameters argPtr = (ExpressionNode *)this->child[0]; // set the argument pointer to the call arguments argCounter = 1; // step through the param and argument lists together while (paramPtr != NULL && argPtr != NULL) { argPtr->ScopeAndType(out, numErrors); // process expression in call // do type checks first if (paramPtr->type != Error && argPtr->type != Error && paramPtr->type != argPtr->type) { ++numErrors; // type in param list differs from type in argument list error PrintError(out, 7, lineNumber, PrintType(paramPtr->type), dPtr->name, "", argCounter, dPtr->lineNumber); } // now check to see if array params are handled correctly if (paramPtr->isArray && !(argPtr->getIsArray())) { // expecting an array type in call ++numErrors; // Expecting array in current parameter error PrintError(out, 9, lineNumber, dPtr->name, "", "", argCounter, dPtr->lineNumber); } else if (!paramPtr->isArray && argPtr->getIsArray()) { // not expecting an array type ++numErrors; // Not Expecting array in current parameter error PrintError(out, 13, lineNumber, dPtr->name, "", "", argCounter, dPtr->lineNumber); } // advanced both pointers to next item in list paramPtr = (DeclarationNode *)paramPtr->sibling; argPtr = (ExpressionNode *)argPtr->sibling; ++argCounter; // increment argument counter } // check to make sure that both lists are finished - no more params to process if (paramPtr != NULL || argPtr != NULL) { ++numErrors; // one list was shorter then the other // Wrong number of params error PrintError(out, 18, lineNumber, dPtr->name, "", "", dPtr->lineNumber); } } break; // we already know the type of a constant - handled in Bison code - no need to process here } // now traverse any sibling nodes if (sibling != NULL) sibling->ScopeAndType(out, numErrors); return; }
void StatementNode::ScopeAndType(ostream &out, int &numErrors) { Types tempType; string tempName; DeclarationNode *dPtr; bool tempNewScope; switch (subKind) { case IfK: case WhileK: // check Expression Type if (child[0] != NULL) { child[0]->ScopeAndType(out, numErrors); if (((ExpressionNode *)child[0])->type != Error) { if (((ExpressionNode *)child[0])->type != Bool) { // statements need boolean test ++numErrors; // Boolean test error PrintError(out, 11, lineNumber, "", "", "", 0, 0); } if (((ExpressionNode *)child[0])->subKind == IdK) { // only ID kinds can be arrays dPtr = (DeclarationNode *)symtab->lookup(((ExpressionNode *)child[0])->name.c_str()); if (dPtr != NULL && dPtr->isArray && ((ExpressionNode *)child[0])->child[0] == NULL) { // if the array is indexed then it is really not a type array // test expressions cannot be an array ++numErrors; // Test expression array error PrintError(out, 6, lineNumber, "", "", "", 0, 0); } } } } // Do Scope and Type Checking on the remainder if (child[1] != NULL) child[1]->ScopeAndType(out, numErrors); if (child[2] != NULL) child[2]->ScopeAndType(out, numErrors); break; case ReturnK: if (child[0] != NULL) { child[0]->ScopeAndType(out, numErrors); if (((ExpressionNode *)child[0])->type != Error && ((ExpressionNode *)child[0])->type != funcReturnType) { ++numErrors; // Return type mismatch error PrintError(out, 12, lineNumber, PrintType(funcReturnType), PrintType(((ExpressionNode *)child[0])->type), "", 0, 0); } if (((ExpressionNode *)child[0])->subKind == IdK) { // cast this node to DeclarationNode and lookup tempName = ((ExpressionNode *)child[0])->name; dPtr = (DeclarationNode *)symtab->lookup(tempName.c_str()); if (dPtr != NULL && dPtr->isArray && ((ExpressionNode *)child[0])->child[0] == NULL) { // can't return an array ++numErrors; // Illegal return type of array error PrintError(out, 5, lineNumber, "", "", "", 0, 0); } } } else if (funcReturnType != Void) { // no return value when there should have been ++numErrors; // Missing return expression error PrintError(out, 8, lineNumber, PrintType(funcReturnType), "", "", 0, 0); } break; case CompK: tempNewScope = newScope; if (tempNewScope) symtab->enter("CompK"); else newScope = true; // reset the new scope for the next nesting if (child[0] != NULL) child[0]->ScopeAndType(out, numErrors); if (child[1] != NULL) child[1]->ScopeAndType(out, numErrors); if (tempNewScope) // don't test the global variable here... symtab->leave(); break; } // now traverse any sibling nodes if (sibling != NULL) sibling->ScopeAndType(out, numErrors); return; }
LOCAL ushort DumpTypRecC7 ( ushort usIndex, ushort cbLen, uchar *pRec) { ushort usOff; printf ("0x%04x: Length = %u, Leaf = 0x%04x ", usIndex, cbLen, *((ushort *)pRec)); switch (*((ushort *)pRec)) { case LF_POINTER : { plfPointer plf = (plfPointer)pRec; PrintType ("LF_POINTER"); printf ("\t"); if (plf->attr.isconst) { printf ("CONST "); } if (plf->attr.isvolatile) { printf ("VOLATILE "); } printf ("%s (%s)", XlateC7PtrMode[plf->attr.ptrmode], XlateC7PtrType[plf->attr.ptrtype]); if (plf->attr.isflat32) { printf (" 16:32"); } printf ("\n\tElement type: %s", SzNameC7Type(plf->utype)); switch (plf->attr.ptrmode) { case CV_PTR_MODE_PTR: switch (plf->attr.ptrtype) { case CV_PTR_BASE_SEG: printf (", Segment#: 0x%04x", plf->pbase.bseg ); break; case CV_PTR_BASE_TYPE: printf (", base symbol type = %s", SzNameC7Type( plf->pbase.btype.index )); ShowStr (", name = '", plf->pbase.btype.name); printf ("'"); case CV_PTR_BASE_SELF: printf (", Based on self" ); break; case CV_PTR_BASE_VAL: printf (", Based on value in symbol:\n\t" ); DumpOneSymC7 ((uchar *)&(plf->pbase.Sym[0])); break; case CV_PTR_BASE_SEGVAL: printf (", Based on segment in symbol:\n\t" ); DumpOneSymC7 ((uchar *)&(plf->pbase.Sym[0])); break; case CV_PTR_BASE_ADDR: printf (", Based on address of symbol:\n\t" ); DumpOneSymC7 ((uchar *)&(plf->pbase.Sym[0])); break; case CV_PTR_BASE_SEGADDR: printf (", Based on segment of symbol:\n\t" ); DumpOneSymC7 ((uchar *)&(plf->pbase.Sym[0])); break; } break; case CV_PTR_MODE_PMFUNC: case CV_PTR_MODE_PMEM: printf (", Containing class = %s,\n", SzNameC7Type( plf->pbase.pm.pmclass )); printf ("\tType of pointer to member = %s", SzNameC7Type( plf->pbase.pm.pmenum)); break; } printf ("\n" ); break; } case LF_MODIFIER: { plfModifier plf = (plfModifier)pRec; PrintType ("LF_MODIFIER"); if ((plf->attr.MOD_const == TRUE) && (plf->attr.MOD_volatile)) { printf ("\tCONST VOLATILE, "); } else if (plf->attr.MOD_const == TRUE) { printf ("\tCONST, "); } else if (plf->attr.MOD_volatile) { printf ("\tVOLATILE, "); } else { printf ("\tNONE, "); } printf ("\tmodifies type %s\n", SzNameC7Type(plf->type)); break; } case LF_CLASS: case LF_STRUCTURE: { plfStructure plf = (plfStructure)pRec; ushort cbNumeric; uchar *pName; if (*((ushort *)pRec) == LF_CLASS ) { PrintType ("LF_CLASS"); } else { PrintType ("LF_STRUCTURE"); } printf ("\t# members = %d, ", plf->count); printf (" field list type 0x%04x, ", plf->field); PrintProp( plf->property ); printf ("\n"); printf ("\tDerivation list type 0x%04x, ", plf->derived); printf ("VT shape type 0x%04x\n", plf->vshape); printf ("\tSize = "); cbNumeric = PrintNumeric (plf->data); pName = plf->data + cbNumeric; ShowStr (", class name = ", pName); printf("\n"); break; } case LF_UNION: { plfUnion plf = (plfUnion)pRec; ushort cbNumeric; uchar *pName; PrintType ("LF_UNION"); printf ("\t# members = %d, ", plf->count); printf (" field list type 0x%04x, ", plf->field); PrintProp( plf->property ); printf ("Size = "); cbNumeric = PrintNumeric (plf->data); pName = plf->data + cbNumeric; ShowStr ("\t,class name = ", pName); printf("\n"); break; } case LF_ENUM: { plfEnum plf = (plfEnum)pRec; PrintType ("LF_ENUM"); printf ("\t# members = %d, ", plf->count); printf (" type = %s", SzNameC7Type(plf->utype)); printf (" field list type 0x%04x\n", plf->field); PrintProp (plf->property); ShowStr ("\tenum name = ", plf->Name); printf("\n"); break; } case LF_VTSHAPE: { plfVTShape plf = (plfVTShape)pRec; ushort j; uchar * pDesc; uchar ch; ushort usCount; PrintType ("LF_VTSHAPE"); printf("\tNumber of entries: %u\n", usCount = plf->count); pDesc = plf->desc; for( j = 0; j < usCount; j++) { if (j & 1) { ch = (*pDesc++) >> 4; } else { ch = *pDesc; } printf("\t\t[%u]: %s\n", j, C7VtsStrings[ch & 0xf]); } break; }
void PrintExprDesc (FILE* F, ExprDesc* E) /* Print an ExprDesc */ { unsigned Flags; char Sep; fprintf (F, "Symbol: %s\n", E->Sym? E->Sym->Name : "(none)"); if (E->Type) { fprintf (F, "Type: "); PrintType (F, E->Type); fprintf (F, "\nRaw type: "); PrintRawType (F, E->Type); } else { fprintf (F, "Type: (unknown)\n" "Raw type: (unknown)\n"); } fprintf (F, "IVal: 0x%08lX\n", E->IVal); fprintf (F, "FVal: %f\n", FP_D_ToFloat (E->FVal)); Flags = E->Flags; Sep = '('; fprintf (F, "Flags: 0x%04X ", Flags); if (Flags & E_LOC_ABS) { fprintf (F, "%cE_LOC_ABS", Sep); Flags &= ~E_LOC_ABS; Sep = ','; } if (Flags & E_LOC_GLOBAL) { fprintf (F, "%cE_LOC_GLOBAL", Sep); Flags &= ~E_LOC_GLOBAL; Sep = ','; } if (Flags & E_LOC_STATIC) { fprintf (F, "%cE_LOC_STATIC", Sep); Flags &= ~E_LOC_STATIC; Sep = ','; } if (Flags & E_LOC_REGISTER) { fprintf (F, "%cE_LOC_REGISTER", Sep); Flags &= ~E_LOC_REGISTER; Sep = ','; } if (Flags & E_LOC_STACK) { fprintf (F, "%cE_LOC_STACK", Sep); Flags &= ~E_LOC_STACK; Sep = ','; } if (Flags & E_LOC_PRIMARY) { fprintf (F, "%cE_LOC_PRIMARY", Sep); Flags &= ~E_LOC_PRIMARY; Sep = ','; } if (Flags & E_LOC_EXPR) { fprintf (F, "%cE_LOC_EXPR", Sep); Flags &= ~E_LOC_EXPR; Sep = ','; } if (Flags & E_LOC_LITERAL) { fprintf (F, "%cE_LOC_LITERAL", Sep); Flags &= ~E_LOC_LITERAL; Sep = ','; } if (Flags & E_RTYPE_LVAL) { fprintf (F, "%cE_RTYPE_LVAL", Sep); Flags &= ~E_RTYPE_LVAL; Sep = ','; } if (Flags & E_BITFIELD) { fprintf (F, "%cE_BITFIELD", Sep); Flags &= ~E_BITFIELD; Sep = ','; } if (Flags & E_NEED_TEST) { fprintf (F, "%cE_NEED_TEST", Sep); Flags &= ~E_NEED_TEST; Sep = ','; } if (Flags & E_CC_SET) { fprintf (F, "%cE_CC_SET", Sep); Flags &= ~E_CC_SET; Sep = ','; } if (Flags) { fprintf (F, "%c,0x%04X", Sep, Flags); Sep = ','; } if (Sep != '(') { fputc (')', F); } fprintf (F, "\nName: 0x%08lX\n", E->Name); }
void PrintType (FILE* F, const Type* T) /* Output translation of type array. */ { /* Walk over the type string */ while (T->C != T_END) { /* Get the type code */ TypeCode C = T->C; /* Print any qualifiers */ C = PrintTypeComp (F, C, T_QUAL_CONST, "const"); C = PrintTypeComp (F, C, T_QUAL_VOLATILE, "volatile"); C = PrintTypeComp (F, C, T_QUAL_RESTRICT, "restrict"); C = PrintTypeComp (F, C, T_QUAL_NEAR, "__near__"); C = PrintTypeComp (F, C, T_QUAL_FAR, "__far__"); C = PrintTypeComp (F, C, T_QUAL_FASTCALL, "__fastcall__"); C = PrintTypeComp (F, C, T_QUAL_CDECL, "__cdecl__"); /* Signedness. Omit the signedness specifier for long and int */ if ((C & T_MASK_TYPE) != T_TYPE_INT && (C & T_MASK_TYPE) != T_TYPE_LONG) { C = PrintTypeComp (F, C, T_SIGN_SIGNED, "signed"); } C = PrintTypeComp (F, C, T_SIGN_UNSIGNED, "unsigned"); /* Now check the real type */ switch (C & T_MASK_TYPE) { case T_TYPE_CHAR: fprintf (F, "char"); break; case T_TYPE_SHORT: fprintf (F, "short"); break; case T_TYPE_INT: fprintf (F, "int"); break; case T_TYPE_LONG: fprintf (F, "long"); break; case T_TYPE_LONGLONG: fprintf (F, "long long"); break; case T_TYPE_FLOAT: fprintf (F, "float"); break; case T_TYPE_DOUBLE: fprintf (F, "double"); break; case T_TYPE_VOID: fprintf (F, "void"); break; case T_TYPE_STRUCT: fprintf (F, "struct %s", ((SymEntry*) T->A.P)->Name); break; case T_TYPE_UNION: fprintf (F, "union %s", ((SymEntry*) T->A.P)->Name); break; case T_TYPE_ARRAY: /* Recursive call */ PrintType (F, T + 1); if (T->A.L == UNSPECIFIED) { fprintf (F, " []"); } else { fprintf (F, " [%ld]", T->A.L); } return; case T_TYPE_PTR: /* Recursive call */ PrintType (F, T + 1); fprintf (F, " *"); return; case T_TYPE_FUNC: fprintf (F, "function returning "); break; default: fprintf (F, "unknown type: %04lX", T->C); } /* Next element */ ++T; } }
explicit PrintRangeDelim(const PrintType& p = PrintType(), const std::string& delim = ";") : Base(delim), pt_(p) { /* */ }
void ssl_DumpMsg(sslSocket *ss, unsigned char *bp, unsigned len) { switch (bp[0]) { case SSL_MT_ERROR: PrintType(ss, "Error"); PrintInt(ss, "error", LEN(bp+1)); break; case SSL_MT_CLIENT_HELLO: { unsigned lcs = LEN(bp+3); unsigned ls = LEN(bp+5); unsigned lc = LEN(bp+7); PrintType(ss, "Client-Hello"); PrintInt(ss, "version (Major)", bp[1]); PrintInt(ss, "version (minor)", bp[2]); PrintBuf(ss, "cipher-specs", bp+9, lcs); PrintBuf(ss, "session-id", bp+9+lcs, ls); PrintBuf(ss, "challenge", bp+9+lcs+ls, lc); } break; case SSL_MT_CLIENT_MASTER_KEY: { unsigned lck = LEN(bp+4); unsigned lek = LEN(bp+6); unsigned lka = LEN(bp+8); PrintType(ss, "Client-Master-Key"); PrintInt(ss, "cipher-choice", bp[1]); PrintInt(ss, "key-length", LEN(bp+2)); PrintBuf(ss, "clear-key", bp+10, lck); PrintBuf(ss, "encrypted-key", bp+10+lck, lek); PrintBuf(ss, "key-arg", bp+10+lck+lek, lka); } break; case SSL_MT_CLIENT_FINISHED: PrintType(ss, "Client-Finished"); PrintBuf(ss, "connection-id", bp+1, len-1); break; case SSL_MT_SERVER_HELLO: { unsigned lc = LEN(bp+5); unsigned lcs = LEN(bp+7); unsigned lci = LEN(bp+9); PrintType(ss, "Server-Hello"); PrintInt(ss, "session-id-hit", bp[1]); PrintInt(ss, "certificate-type", bp[2]); PrintInt(ss, "version (Major)", bp[3]); PrintInt(ss, "version (minor)", bp[3]); PrintBuf(ss, "certificate", bp+11, lc); PrintBuf(ss, "cipher-specs", bp+11+lc, lcs); PrintBuf(ss, "connection-id", bp+11+lc+lcs, lci); } break; case SSL_MT_SERVER_VERIFY: PrintType(ss, "Server-Verify"); PrintBuf(ss, "challenge", bp+1, len-1); break; case SSL_MT_SERVER_FINISHED: PrintType(ss, "Server-Finished"); PrintBuf(ss, "session-id", bp+1, len-1); break; case SSL_MT_REQUEST_CERTIFICATE: PrintType(ss, "Request-Certificate"); PrintInt(ss, "authentication-type", bp[1]); PrintBuf(ss, "certificate-challenge", bp+2, len-2); break; case SSL_MT_CLIENT_CERTIFICATE: { unsigned lc = LEN(bp+2); unsigned lr = LEN(bp+4); PrintType(ss, "Client-Certificate"); PrintInt(ss, "certificate-type", bp[1]); PrintBuf(ss, "certificate", bp+6, lc); PrintBuf(ss, "response", bp+6+lc, lr); } break; default: ssl_PrintBuf(ss, "sending *unknown* message type", bp, len); return; } }
//-------------------------------------------------------------------------- // Name PrintType // // //-------------------------------------------------------------------------- void PrintType ( TYPE * type ) { TTypeNode * tnode; ASSERT( type ); ASSERT( type->tnode ); // Print the qualifier // if (type->isConst) printf( "const " ); if (type->isVolatile) printf( "volatile " ); if (type->isRestrict) printf( "__restrict " ); if (type->attr) printf( "__attr(0x%x) ", type->attr ); // Print the tnode // tnode = type->tnode; // print common flags // putchar( '<' ); if (tnode->isIntegral) putchar( 'I' ); if (tnode->isFloat) putchar( 'F' ); if (tnode->isArith) putchar( 'A' ); if (tnode->isScalar) putchar( 'S' ); putchar( '>' ); putchar( ' ' ); switch (tnode->node) { case NODE_BASIC: if (tnode->isSigned) printf( "signed " ); else printf( "unsigned " ); if (tnode->isShort) printf( "short " ); if (tnode->isLong) printf( "long " ); printf( "%s", BtName[tnode->info.basic] ); break; case NODE_POINTER: printf( "ptr to " ); PrintType( tnode->of ); break; case NODE_STRUCT: case NODE_UNION: case NODE_ENUM: printf( "%s %s", NodeName[tnode->node ], Struct_Name( tnode->info.structDef ) ); break; case NODE_FUNCTION: printf( "Function ( " ); // print the parameters ASSERT( tnode->info.funcParams ); if (tnode->info.funcParams) { TSymbol * param; // Check and print the explicit (void) parameter if (tnode->info.funcParams->locSymbols.first == NULL && !tnode->isImplicit) printf( "void" ); // iterate through all parameters declared in the parameter scope // for ( param = ID_GET_SYMBOL( tnode->info.funcParams->locSymbols.first ); param != NULL; param = ID_GET_SYMBOL( param->id.nextLocal ) ) { // print the name (which is optional) if (param->id.strName != NULL) printf( "%s", C_STR(param->id.strName) ); else if (param == EllipsisSym) printf( "..." ); printf( ":" ); if (param->type) PrintType( param->type ); // if this is not the last symbol, print a comma if (param != ID_GET_SYMBOL(tnode->info.funcParams->locSymbols.last)) printf( ", " ); } } printf( " ) returning " ); PrintType( tnode->of ); break; case NODE_ARRAY: printf( "array[" ); if (TGT_INT_NE_0( tnode->info.arrayLen )) printf( "%lu", (long unsigned)TGT_UINT_2_HOST_INT(tnode->info.arrayLen) ); printf( "] of " ); PrintType( tnode->of ); break; default: ASSERT( 0 ); } };
/* * Read the next TIFF directory from a file * and convert it to the internal format. * We read directories sequentially. */ static uint32 ReadDirectory(int fd, unsigned ix, uint32 off) { register TIFFDirEntry *dp; register int n; TIFFDirEntry *dir = 0; uint16 dircount; int space; uint32 nextdiroff = 0; if (off == 0) /* no more directories */ goto done; if (lseek(fd, (off_t) off, 0) != off) { Fatal("Seek error accessing TIFF directory"); goto done; } if (read(fd, (char*) &dircount, sizeof (uint16)) != sizeof (uint16)) { ReadError("directory count"); goto done; } if (swabflag) TIFFSwabShort(&dircount); dir = (TIFFDirEntry *)_TIFFmalloc(dircount * sizeof (TIFFDirEntry)); if (dir == NULL) { Fatal("No space for TIFF directory"); goto done; } n = read(fd, (char*) dir, dircount*sizeof (*dp)); if (n != dircount*sizeof (*dp)) { n /= sizeof (*dp); Error( "Could only read %u of %u entries in directory at offset %#lx", n, dircount, (unsigned long) off); dircount = n; } if (read(fd, (char*) &nextdiroff, sizeof (uint32)) != sizeof (uint32)) nextdiroff = 0; if (swabflag) TIFFSwabLong(&nextdiroff); printf("Directory %u: offset %lu (%#lx) next %lu (%#lx)\n", ix, (unsigned long) off, (unsigned long) off, (unsigned long) nextdiroff, (unsigned long) nextdiroff); for (dp = dir, n = dircount; n > 0; n--, dp++) { if (swabflag) { TIFFSwabArrayOfShort(&dp->tdir_tag, 2); TIFFSwabArrayOfLong(&dp->tdir_count, 2); } PrintTag(stdout, dp->tdir_tag); putchar(' '); PrintType(stdout, dp->tdir_type); putchar(' '); printf("%lu<", (unsigned long) dp->tdir_count); if (dp->tdir_type >= NWIDTHS) { printf(">\n"); continue; } space = dp->tdir_count * datawidth[dp->tdir_type]; if (space <= 4) { switch (dp->tdir_type) { case TIFF_FLOAT: case TIFF_UNDEFINED: case TIFF_ASCII: { unsigned char data[4]; _TIFFmemcpy(data, &dp->tdir_offset, 4); if (swabflag) TIFFSwabLong((uint32*) data); PrintData(stdout, dp->tdir_type, dp->tdir_count, data); break; } case TIFF_BYTE: PrintByte(stdout, bytefmt, dp); break; case TIFF_SBYTE: PrintByte(stdout, sbytefmt, dp); break; case TIFF_SHORT: PrintShort(stdout, shortfmt, dp); break; case TIFF_SSHORT: PrintShort(stdout, sshortfmt, dp); break; case TIFF_LONG: PrintLong(stdout, longfmt, dp); break; case TIFF_SLONG: PrintLong(stdout, slongfmt, dp); break; } } else { unsigned char *data = (unsigned char *)_TIFFmalloc(space); if (data) { if (TIFFFetchData(fd, dp, data)) if (dp->tdir_count > maxitems) { PrintData(stdout, dp->tdir_type, maxitems, data); printf(" ..."); } else PrintData(stdout, dp->tdir_type, dp->tdir_count, data); _TIFFfree(data); } else Error("No space for data for tag %u", dp->tdir_tag); } printf(">\n"); } done: if (dir) _TIFFfree((char *)dir); return (nextdiroff); }
static bool DumpSpecificMsgInfo(plMessage* msg, plString& info) { #ifndef PLASMA_EXTERNAL_RELEASE // Don't bloat up the external release with all these strings pfKIMsg* kiMsg = pfKIMsg::ConvertNoRef(msg); if (kiMsg) { const char* typeName = "(unknown)"; #define PrintKIType(type) if (kiMsg->GetCommand() == pfKIMsg::type) typeName = #type; PrintKIType(kHACKChatMsg); // send chat message via pfKIMsg PrintKIType(kEnterChatMode); // toggle chat mode PrintKIType(kSetChatFadeDelay); // set the chat delay PrintKIType(kSetTextChatAdminMode); // set the chat admin mode... not used (see CCR) PrintKIType(kDisableKIandBB); // disable KI and blackbar (for things like AvaCusta) PrintKIType(kEnableKIandBB); // re-enable the KI and blackbar PrintKIType(kYesNoDialog); // display a Yes/No dialog PrintKIType(kAddPlayerDevice); // add a device player list); such as imager PrintKIType(kRemovePlayerDevice); // remove a device from player list PrintKIType(kUpgradeKILevel); // upgrade the KI to higher level PrintKIType(kDowngradeKILevel); // downgrade KI to next lower level PrintKIType(kRateIt); // display the "RateIt"(tm) dialog PrintKIType(kSetPrivateChatChannel); // set the private chat channel (for private rooms) PrintKIType(kUnsetPrivateChatChannel); // unset private chat channel PrintKIType(kStartBookAlert); // blink the book image on the blackbar PrintKIType(kMiniBigKIToggle); // shortcut to toggling the miniKI/bigKI PrintKIType(kKIPutAway); // shortcut to hiding all of the KI PrintKIType(kChatAreaPageUp); // shortcut to paging up the chat area PrintKIType(kChatAreaPageDown); // shortcut to paging down the chat area PrintKIType(kChatAreaGoToBegin); // shortcut to going to the beginning of the chat area PrintKIType(kChatAreaGoToEnd); // shortcut to going to the end of the chat area PrintKIType(kKITakePicture); // shortcut to taking a picture in the KI PrintKIType(kKICreateJournalNote); // shortcut to creating a journal note in the KI PrintKIType(kKIToggleFade); // shortcut to toggle fade mode PrintKIType(kKIToggleFadeEnable); // shortcut to toggling fade enabled PrintKIType(kKIChatStatusMsg); // display status message in chat window PrintKIType(kKILocalChatStatusMsg); // display status message in chat window PrintKIType(kKIUpSizeFont); // bump up the size of the chat area font PrintKIType(kKIDownSizeFont); // down size the font of the chat area PrintKIType(kKIOpenYeehsaBook); // open the playerbook if not already open PrintKIType(kKIOpenKI); // open up in degrees the KI PrintKIType(kKIShowCCRHelp); // show the CCR help dialog PrintKIType(kKICreateMarker); // create a marker PrintKIType(kKICreateMarkerFolder); // create a marker folder in the current Age's journal folder PrintKIType(kKILocalChatErrorMsg); // display error message in chat window PrintKIType(kKIPhasedAllOn); // turn on all the phased KI functionality PrintKIType(kKIPhasedAllOff); // turn off all the phased KI functionality PrintKIType(kKIOKDialog); // display an OK dialog box (localized) PrintKIType(kDisableYeeshaBook); // don't allow linking with the Yeesha book (gameplay) PrintKIType(kEnableYeeshaBook); // re-allow linking with the Yeesha book PrintKIType(kQuitDialog); // put up quit dialog PrintKIType(kTempDisableKIandBB); // temp disable KI and blackbar (done by av system) PrintKIType(kTempEnableKIandBB); // temp re-enable the KI and blackbar (done by av system) PrintKIType(kDisableEntireYeeshaBook); // disable the entire Yeeshabook); not for gameplay); but prevent linking PrintKIType(kEnableEntireYeeshaBook); PrintKIType(kKIOKDialogNoQuit); // display OK dialog in the KI without quiting afterwards PrintKIType(kGZUpdated); // the GZ game was updated PrintKIType(kGZInRange); // a GZ marker is in range PrintKIType(kGZOutRange); // GZ markers are out of range PrintKIType(kUpgradeKIMarkerLevel); // upgrade the KI Marker level (current 0 and 1) PrintKIType(kKIShowMiniKI); // force the miniKI up PrintKIType(kGZFlashUpdate); // flash an update without saving (for animation of GZFill in) PrintKIType(kNoCommand); info = plString::Format("Type: %s Str: %s User: %s(%d) Delay: %f Int: %d", typeName, kiMsg->GetString() != "" ? kiMsg->GetString().c_str() : "(nil)", kiMsg->GetUser() ? kiMsg->GetUser() : "(nil)", kiMsg->GetPlayerID(), kiMsg->GetDelay(), kiMsg->GetIntValue()); return true; } plClientMsg* clientMsg = plClientMsg::ConvertNoRef(msg); if (clientMsg) { #define PrintType(type) if (clientMsg->GetClientMsgFlag() == plClientMsg::type) info = #type; PrintType(kLoadRoom); PrintType(kLoadRoomHold); PrintType(kUnloadRoom); PrintType(kLoadNextRoom); PrintType(kInitComplete); PrintType(kDisableRenderScene); PrintType(kEnableRenderScene); PrintType(kQuit); PrintType(kLoadAgeKeys); PrintType(kReleaseAgeKeys); switch (clientMsg->GetClientMsgFlag()) { case plClientMsg::kLoadRoom: case plClientMsg::kLoadRoomHold: case plClientMsg::kUnloadRoom: { info += " - Pages: "; const std::vector<plLocation>& locs = clientMsg->GetRoomLocs(); for (int i = 0; i < locs.size(); i++) { const plLocation& loc = locs[i]; const plPageInfo* pageInfo = plKeyFinder::Instance().GetLocationInfo(loc); if (pageInfo) info += plString::Format("%s-%s ", pageInfo->GetAge(), pageInfo->GetPage()); } } break; case plClientMsg::kLoadAgeKeys: case plClientMsg::kReleaseAgeKeys: info += plString::Format(" - Age: %s", clientMsg->GetAgeName()); break; } return true; } plRefMsg* refMsg = plRefMsg::ConvertNoRef(msg); if (refMsg) { const char* typeName = nil; #define GetType(type) if (refMsg->GetContext() == plRefMsg::type) typeName = #type; GetType(kOnCreate); GetType(kOnDestroy); GetType(kOnRequest); GetType(kOnRemove); GetType(kOnReplace); info = plString::Format("Obj: %s RefType: %s", refMsg->GetRef()->GetKeyName().c_str(), typeName); return true; } #endif // PLASMA_EXTERNAL_RELEASE return false; }
/* Outputs requested data */ int NXBread(NXhandle fileId, NXname dataName, char *dimensions) { int dataRank, dataDimensions[NX_MAXRANK], dataType, start[NX_MAXRANK], size[NX_MAXRANK], i, j, total_size; char dimString[80], *subString; void *dataBuffer; /* Check the specified data item exists */ if (FindData(fileId, dataName) != NX_OK) return NX_ERROR; /* Open the data and obtain its type and rank details */ if (NXopendata(fileId, dataName) != NX_OK) return NX_ERROR; if (NXgetinfo(fileId, &dataRank, dataDimensions, &dataType) != NX_OK) return NX_ERROR; /* Check if a single element has been specified */ /* If so, read in the indices */ if (dimensions != NULL) { strcpy(dimString, dimensions); subString = strtok(dimString, ","); for (i = 0; subString != NULL && i < NX_MAXRANK; i++) { if (i >= dataRank) { printf("NX_ERROR: Data rank = %d\n", dataRank); return NX_ERROR; } sscanf(subString, "%d", &j); if (j > dataDimensions[i] || j < 1) { printf("NX_ERROR: Data dimension %d = %d\n", (i + 1), dataDimensions[i]); return NX_ERROR; } start[i] = j - 1; size[i] = 1; subString = strtok(NULL, ","); } if (i != dataRank) { printf("NX_ERROR: Data rank = %d\n", dataRank); return NX_ERROR; } } else { /* Otherwise, allocate enough space for the first 3 elements of each dimension */ for (i = 0; i < dataRank; i++) { if (dataDimensions[i] > 3 && dataType != NX_CHAR) { start[i] = 0; size[i] = 3; } /* unless it's a character string */ else { start[i] = 0; size[i] = dataDimensions[i]; } } } total_size = 1; for (i = 0; i < dataRank; i++) { total_size *= dataDimensions[i]; } if (NXmalloc((void **)&dataBuffer, dataRank, size, dataType) != NX_OK) return NX_ERROR; /* Read in the data with NXgetslab */ if (dataType == NX_CHAR) { if (NXgetdata(fileId, dataBuffer) != NX_OK) return NX_ERROR; } else { if (NXgetslab(fileId, dataBuffer, start, size) != NX_OK) return NX_ERROR; } /* Output data name, dimensions and type */ printf(" %s", dataName); if (dimensions == NULL) PrintDimensions(dataRank, dataDimensions); else printf("[%s]", dimensions); printf(" "); PrintType(dataType); printf(" = "); /* Output the data according to data type */ if (dimensions == NULL) { /* Print the first few values (max 3) */ if (dataType == NX_CHAR) { /* If the data is a string, output the whole buffer */ /* this prints the first line of an array; could print more */ for (i = 0; i < total_size / dataDimensions[dataRank - 1]; i++) { PrintData((char *)dataBuffer + i * dataDimensions[dataRank - 1], dataType, dataDimensions[dataRank - 1]); PrintData("\n", NX_CHAR, 1); } } else { if (dataRank == 1 && dataDimensions[0] == 1) { /* It's a scalar */ PrintData(dataBuffer, dataType, 1); } else { /* It's an array */ printf("[ "); /* Determine total size of input buffer */ for (i = 0, j = 0; i < dataRank; i++) j += dataDimensions[i]; /* Output at least 3 values */ if (j > 3) { PrintData(dataBuffer, dataType, 3); printf("..."); } /* unless the total size is smaller */ else { PrintData(dataBuffer, dataType, j); } printf("]"); } } } else { /* Print the requested item */ PrintData(dataBuffer, dataType, 1); } printf("\n"); if (NXfree((void **)&dataBuffer) != NX_OK) return NX_ERROR; /* Check for attributes unless a single element is specified */ if (dimensions == NULL) PrintAttributes(fileId); /* Close data set */ if (NXclosedata(fileId) != NX_OK) return NX_ERROR; return NX_OK; }
void PrintReject(Record* rd, FILE* fp) { PrintTime(rd, fp); PrintType(rd, fp); PrintDevice(rd, 0, fp); }