Exemple #1
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public HappilLocal <T> Local <T>(IHappilOperand <T> initialValue)
        {
            var local = new HappilLocal <T>(m_OwnerMethod);

            local.Assign(initialValue);
            return(local);
        }
Exemple #2
0
            //-----------------------------------------------------------------------------------------------------------------------------------------------------

            private static void EmitPropertyComparison(
                IHappilMethodBody <int> m,
                PropertyInfo prop,
                HappilLocal <TypeTemplate.TPrimary> otherTuple,
                HappilLocal <int> compareResult)
            {
                var backingField = m.This <TT.TPrimary>().BackingFieldOf <TT.TProperty>(prop);
                var otherValue   = m.Local(initialValue: otherTuple.Prop <TT.TProperty>(prop));

                if (backingField.OperandType.IsValueType)
                {
                    m.If(backingField > otherValue).Then(() => {
                        m.ReturnConst(1);
                    })
                    .ElseIf(backingField < otherValue).Then(() => {
                        m.ReturnConst(-1);
                    })
                    .ElseIf(backingField != otherValue).Then(() => {
                        m.ReturnConst(1);
                    });
                }
                else if (typeof(IComparable).IsAssignableFrom(backingField.OperandType))
                {
                    compareResult.Assign(backingField.CastTo <IComparable>().Func <object, int>(x => x.CompareTo, otherValue));
                    m.If(compareResult != 0).Then(() => m.Return(compareResult));
                }
                else
                {
                    throw new NotSupportedException("Cannot compare values of type: " + backingField.OperandType.FullName);
                }
            }
Exemple #3
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public IHappilForeachInSyntax <T> Foreach <T>(HappilLocal <T> element)
        {
            return(m_OwnerMethod.AddStatement(new ForeachStatement <T>(element)));
        }