Example #1
0
        protected override void OnInvocationExpressionMatched(ILTranslator sender, VisitedEventArgs <InvocationExpression> e)
        {
            if (e.Results.Count() == 1)
            {
                var call = e.Results.Single() as E.CallExpression;
                if (call != null)
                {
                    var pe = call.Target as E.PropertyExpression;

                    if (pe != null)
                    {
                        pe.Property = _ResultMethodName;

                        if (_ResultTypeName != null)
                        {
                            pe.Object = new E.IdentifierExpression()
                            {
                                Name = _ResultTypeName
                            };
                        }
                        e.Handled = true;
                    }
                }
            }
        }
Example #2
0
 public override void ApplyTo(ILTranslator translator)
 {
     foreach (var item in _Items)
     {
         item.ApplyTo(translator);
     }
 }
Example #3
0
        public void MathConventionSet_Test()
        {
            var t = new ILTranslator();
            var r = t.Translate(typeof(MathConventionSetTestClass)).Single();

            Console.WriteLine(r);
        }
Example #4
0
        public void MethodNameConvention_InvocationTest()
        {
            var t = new ILTranslator();
            var r = t.Translate(typeof(MethodNameConventionTestClass)).Single();

            Console.WriteLine(r);
        }
Example #5
0
        public override void ApplyTo(ILTranslator translator)
        {
            translator.VisitedMethodDeclaration -= Translator_VisitedMethodDeclaration;
            translator.VisitedMethodDeclaration += Translator_VisitedMethodDeclaration;

            translator.VisitedInvocationExpression -= Translator_VisitedInvocationExpression;
            translator.VisitedInvocationExpression += Translator_VisitedInvocationExpression;
        }
Example #6
0
        public override void ApplyTo(ILTranslator translator)
        {
            translator.ResolvingClrType -= Translator_ResolvingClrType;
            translator.ResolvingClrType += Translator_ResolvingClrType;

            translator.VisitedAssignmentExpression -= Translator_VisitedAssignmentExpression;
            translator.VisitedAssignmentExpression += Translator_VisitedAssignmentExpression;

            translator.VisitedInvocationExpression -= Translator_VisitedInvocationExpression;
            translator.VisitedInvocationExpression += Translator_VisitedInvocationExpression;
        }
Example #7
0
 protected override void OnMethodDeclarationMatched(ILTranslator sender, VisitedEventArgs <MethodDeclaration> e)
 {
     if (e.Results.Count() == 1)
     {
         var method = e.Results.Single() as D.MethodDeclaration;
         if (method != null)
         {
             method.MethodName = _ResultMethodName;
             e.Handled         = true;
         }
     }
 }
Example #8
0
        public override void ApplyTo(ILTranslator translator)
        {
            translator.VisitingEventDeclaration -= Translator_VisitingEventDeclaration;
            translator.VisitingEventDeclaration += Translator_VisitingEventDeclaration;

            translator.VisitingCustomEventDeclaration -= Translator_VisitingCustomEventDeclaration;
            translator.VisitingCustomEventDeclaration += Translator_VisitingCustomEventDeclaration;

            translator.VisitingMemberReferenceExpression -= Translator_VisitingMemberReferenceExpression;
            translator.VisitingMemberReferenceExpression += Translator_VisitingMemberReferenceExpression;

            translator.VisitedAssignmentExpression -= Translator_VisitedAssignmentExpression;
            translator.VisitedAssignmentExpression += Translator_VisitedAssignmentExpression;
        }
Example #9
0
        private D.MethodDeclaration CreateAddAccessor(ILTranslator translator, VisitingEventArgs <EventDeclaration> e, D.ArrayType arrayType, EventDefinition ed)
        {
            var n  = e.Node.Variables.Single().Name;
            var fn = FIELD_PREFIX + n;

            var union = arrayType.UnionWith(arrayType.ElementType);
            var ad    = new D.MethodDeclaration()
            {
                MethodName = ADD_PREFIX + n,
                Parameters = new Collection <D.Parameter>()
                {
                    new D.Parameter()
                    {
                        ParameterName = "value",
                        ParameterType = union
                    }
                }
            };

            var mre = new MemberReferenceExpression()
            {
                Target     = new ThisReferenceExpression(),
                MemberName = fn
            };
            var ve = new IdentifierExpression("value");

            mre.AddAnnotation(new TypeInformation(ed.EventType, ed.EventType));

            ad.Statements = translator.GetStatements(new ExpressionStatement()
            {
                Expression = new AssignmentExpression()
                {
                    Operator = AssignmentOperatorType.Add,
                    Left     = mre,
                    Right    = ve
                }
            }, e.Context);

            return(ad);
        }
Example #10
0
 internal ILTranslationContext(ILTranslator translator, SyntaxTree syntaxTree)
 {
     _Translator = translator;
     _SyntaxTree = syntaxTree;
 }
Example #11
0
 protected abstract void OnInvocationExpressionMatched(ILTranslator sender, VisitedEventArgs <InvocationExpression> e);
Example #12
0
 protected abstract void OnMethodDeclarationMatched(ILTranslator sender, VisitedEventArgs <MethodDeclaration> e);