Esempio n. 1
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        internal HappilProperty(HappilClass happilClass, PropertyInfo declaration)
        {
            m_HappilClass     = happilClass;
            m_Declaration     = declaration;
            m_PropertyBuilder = happilClass.TypeBuilder.DefineProperty(
                happilClass.TakeMemberName(declaration.Name),
                declaration.Attributes,
                declaration.PropertyType,
                declaration.GetIndexParameters().Select(p => p.ParameterType).ToArray());

            var getterDeclaration = declaration.GetGetMethod();

            if (getterDeclaration != null)
            {
                var closedGetterMethodType = typeof(HappilMethod <>).MakeGenericType(getterDeclaration.ReturnType);
                m_GetterMethod = (HappilMethod)Activator.CreateInstance(closedGetterMethodType, happilClass, getterDeclaration);
                m_PropertyBuilder.SetGetMethod(m_GetterMethod.MethodBuilder);
            }

            var setterDeclaration = declaration.GetSetMethod();

            if (setterDeclaration != null)
            {
                m_SetterMethod = new VoidHappilMethod(happilClass, setterDeclaration);
                m_PropertyBuilder.SetSetMethod(m_SetterMethod.MethodBuilder);
            }
        }
Esempio n. 2
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        private void DefineMethodBodyInScope <T>(HappilMethod method, Action <T> userDefinition)
            where T : IHappilMethodBodyBase
        {
            using (method.CreateBodyScope())
            {
                userDefinition((T)(object)method);
            }
        }
Esempio n. 3
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        internal HappilArgument(HappilMethod ownerMethod, byte index)
            : base(ownerMethod)
        {
            var indexBase = (ownerMethod.IsStatic ? 0 : 1);

            if (index < indexBase)
            {
                throw new ArgumentOutOfRangeException("index", string.Format("Argument index must be {0}-based.", indexBase));
            }

            m_Index            = index;
            m_Name             = ownerMethod.GetArgumentNames()[index - indexBase];
            m_IsByRef          = ownerMethod.GetArgumentTypes()[index - indexBase].IsByRef;
            m_IsOut            = ownerMethod.GetArgumentIsOut()[index - indexBase];
            m_ParameterBuilder = ownerMethod.DefineParameter(index - indexBase);
        }
Esempio n. 4
0
 internal HappilThis(HappilMethod ownerMethod)
     : base(ownerMethod)
 {
 }
Esempio n. 5
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        internal HappilOperand(HappilMethod ownerMethod)
        {
            m_OwnerMethod = ownerMethod;
            m_OperandType = TypeTemplate.TryResolve <T>();
        }
Esempio n. 6
0
 internal HappilAssignable(HappilMethod ownerMethod)
     : base(ownerMethod)
 {
 }
Esempio n. 7
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        internal HappilLocal(HappilMethod ownerMethod)
            : base(ownerMethod)
        {
            m_LocalBuilder = ownerMethod.MethodBuilder.GetILGenerator().DeclareLocal(TypeTemplate.Resolve <T>());
        }