public ISymbolNode ComputeConstantLookup(ReadyToRunHelperId lookupKind, object targetOfLookup) { switch (lookupKind) { case ReadyToRunHelperId.TypeHandle: return(NodeFactory.ConstructedTypeSymbol((TypeDesc)targetOfLookup)); case ReadyToRunHelperId.NecessaryTypeHandle: return(NodeFactory.NecessaryTypeSymbol((TypeDesc)targetOfLookup)); case ReadyToRunHelperId.TypeHandleForCasting: { var type = (TypeDesc)targetOfLookup; if (type.IsNullable) { targetOfLookup = type.Instantiation[0]; } return(NodeFactory.NecessaryTypeSymbol((TypeDesc)targetOfLookup)); } case ReadyToRunHelperId.MethodDictionary: return(NodeFactory.MethodGenericDictionary((MethodDesc)targetOfLookup)); case ReadyToRunHelperId.MethodEntry: return(NodeFactory.FatFunctionPointer((MethodDesc)targetOfLookup)); case ReadyToRunHelperId.MethodHandle: return(NodeFactory.RuntimeMethodHandle((MethodDesc)targetOfLookup)); case ReadyToRunHelperId.FieldHandle: return(NodeFactory.RuntimeFieldHandle((FieldDesc)targetOfLookup)); case ReadyToRunHelperId.DefaultConstructor: { var type = (TypeDesc)targetOfLookup; MethodDesc ctor = type.GetDefaultConstructor(); if (ctor == null) { MetadataType activatorType = TypeSystemContext.SystemModule.GetKnownType("System", "Activator"); MetadataType classWithMissingCtor = activatorType.GetKnownNestedType("ClassWithMissingConstructor"); ctor = classWithMissingCtor.GetParameterlessConstructor(); } return(NodeFactory.CanonicalEntrypoint(ctor)); } case ReadyToRunHelperId.ObjectAllocator: { var type = (TypeDesc)targetOfLookup; return(NodeFactory.ExternSymbol(JitHelper.GetNewObjectHelperForType(type))); } default: throw new NotImplementedException(); } }
public ISymbolNode ComputeConstantLookup(ReadyToRunHelperId lookupKind, object targetOfLookup) { switch (lookupKind) { case ReadyToRunHelperId.TypeHandle: return(NodeFactory.ConstructedTypeSymbol(WithoutFunctionPointerType((TypeDesc)targetOfLookup))); case ReadyToRunHelperId.NecessaryTypeHandle: return(NecessaryTypeSymbolIfPossible(WithoutFunctionPointerType((TypeDesc)targetOfLookup))); case ReadyToRunHelperId.TypeHandleForCasting: { var type = (TypeDesc)targetOfLookup; if (type.IsNullable) { targetOfLookup = type.Instantiation[0]; } return(NecessaryTypeSymbolIfPossible((TypeDesc)targetOfLookup)); } case ReadyToRunHelperId.MethodDictionary: return(NodeFactory.MethodGenericDictionary((MethodDesc)targetOfLookup)); case ReadyToRunHelperId.MethodEntry: return(NodeFactory.FatFunctionPointer((MethodDesc)targetOfLookup)); case ReadyToRunHelperId.MethodHandle: return(NodeFactory.RuntimeMethodHandle((MethodDesc)targetOfLookup)); case ReadyToRunHelperId.FieldHandle: return(NodeFactory.RuntimeFieldHandle((FieldDesc)targetOfLookup)); case ReadyToRunHelperId.DefaultConstructor: { var type = (TypeDesc)targetOfLookup; MethodDesc ctor = GetConstructorForCreateInstanceIntrinsic(type); return(NodeFactory.CanonicalEntrypoint(ctor)); } case ReadyToRunHelperId.ObjectAllocator: { var type = (TypeDesc)targetOfLookup; return(NodeFactory.ExternSymbol(JitHelper.GetNewObjectHelperForType(type))); } default: throw new NotImplementedException(); } }