//----------------------------------------------------------------------------------------------------------------------------------------------------- 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); } }
//----------------------------------------------------------------------------------------------------------------------------------------------------- private void DefineMethodBodyInScope <T>(HappilMethod method, Action <T> userDefinition) where T : IHappilMethodBodyBase { using (method.CreateBodyScope()) { userDefinition((T)(object)method); } }
//----------------------------------------------------------------------------------------------------------------------------------------------------- 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); }
internal HappilThis(HappilMethod ownerMethod) : base(ownerMethod) { }
//----------------------------------------------------------------------------------------------------------------------------------------------------- internal HappilOperand(HappilMethod ownerMethod) { m_OwnerMethod = ownerMethod; m_OperandType = TypeTemplate.TryResolve <T>(); }
internal HappilAssignable(HappilMethod ownerMethod) : base(ownerMethod) { }
//----------------------------------------------------------------------------------------------------------------------------------------------------- internal HappilLocal(HappilMethod ownerMethod) : base(ownerMethod) { m_LocalBuilder = ownerMethod.MethodBuilder.GetILGenerator().DeclareLocal(TypeTemplate.Resolve <T>()); }