//-------------------------------------------------------------------------- // // Description: // // Create a fully qualified name for this type. // // Arguments: // // type - type of interest // asLeafType - true if referring to leaf type object // //-------------------------------------------------------------------------- string FullyQualifiedTypeName ( Phx.Types.Type type, bool asLeafType ) { string typeName; Phx.Types.Table typeTable = type.TypeTable; // We should handle the prim types here too, so that we get // int32 instead of i32. if (asLeafType && type == typeTable.SystemStringAggrType) { return "String"; } else if (asLeafType && type == typeTable.SystemObjectAggrType) { return "Object"; } else if (type.IsMgdArrayType) { Phx.Types.Type elemType = type.AsMgdArrayType.ElemType; typeName = FullyQualifiedTypeName(elemType, true) + "[]"; } else if (type.IsAggrType) { Phx.Types.AggrType aggrType = type.AsAggrType; Phx.Syms.TypeSym aggrTypeSym = aggrType.TypeSym; if (aggrTypeSym != null) { typeName = type.TypeSym.NameString; } else { typeName = type.ToString(); } Phx.Types.AggrType enclosingType = aggrType.EnclosingAggrType; if (enclosingType != null) { typeName = FullyQualifiedTypeName(enclosingType, false) + "." + typeName; } if (aggrTypeSym != null) { Phx.Syms.Sym refSym = aggrTypeSym.LexicalParentSym; if (refSym != null) { if (refSym.IsTypeSym) { typeName = FullyQualifiedTypeName(refSym.AsTypeSym.Type, false) + "." + typeName; } else if (refSym.IsAssemblySym) { typeName = "[" + refSym.AsAssemblySym.NameString + "]" + typeName; } else if (refSym.IsImportModuleSym) { // current assembly reference // typeName = "[" + refSym.AsImportModuleSym.NameString + "]" + typeName; } else { typeName = "[???]" + typeName; } } } } else if (type.IsObjPtr) { Phx.Types.Type refType = type.AsPtrType.ReferentType; typeName = FullyQualifiedTypeName(refType, true); } else if (type.IsMgdPtr) { Phx.Types.Type refType = type.AsPtrType.ReferentType; typeName = FullyQualifiedTypeName(refType, true) + "&"; } else if (type.IsUnmgdPtr) { Phx.Types.Type refType = type.AsPtrType.ReferentType; typeName = FullyQualifiedTypeName(refType, true) + "*"; } else { typeName = type.ToString(); } return typeName; } //-------------------------------------------------------------------------- // // Description: // // Create a fully qualified name for this function. // // Remarks: // // Attempts to imitate the type descriptions dumped by ildasm. // //-------------------------------------------------------------------------- string FullyQualifiedFuncName ( Phx.Syms.FuncSym funcSym ) { string funcName = funcSym.NameString; if (funcSym.EnclosingAggrType != null) { Phx.Types.Type classType = funcSym.EnclosingAggrType; funcName = FullyQualifiedTypeName(classType, false) + "::" + funcName; } // Fill in arguments.... Phx.Types.FuncType funcType = funcSym.FuncType; Phx.Types.FuncArg arg = funcType.ArgFuncArgList; funcName += "("; bool isFirst = true; while (arg != null) { if (!arg.IsThisPtr && !arg.IsRetPtr) { if (isFirst) { isFirst = false; } else { funcName += ", "; } if (arg.IsEllipsis) { funcName += "..."; } else { funcName += FullyQualifiedTypeName(arg.Type, true); } } arg = arg.Next; } funcName += ")"; return funcName; }