Exemplo n.º 1
0
        public ISymbolNode ComputeConstantLookup(ReadyToRunHelperId lookupKind, object targetOfLookup)
        {
            switch (lookupKind)
            {
            case ReadyToRunHelperId.TypeHandle:
                return(NodeFactory.ConstructedTypeSymbol((TypeDesc)targetOfLookup));

            case ReadyToRunHelperId.NecessaryTypeHandle:
                return(NecessaryTypeSymbolIfPossible((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();
            }
        }
Exemplo n.º 2
0
            protected override Helper CreateValueFromKey(ReadyToRunHelper key)
            {
                string     mangledName;
                MethodDesc methodDesc;

                JitHelper.GetEntryPoint(_compilation.TypeSystemContext, key, out mangledName, out methodDesc);
                Debug.Assert(mangledName != null || methodDesc != null);

                ISymbolNode entryPoint;

                if (mangledName != null)
                {
                    entryPoint = _compilation.NodeFactory.ExternSymbol(mangledName);
                }
                else
                {
                    entryPoint = _compilation.NodeFactory.MethodEntrypoint(methodDesc);
                }

                return(new Helper(key, entryPoint));
            }