Пример #1
0
        override public void LeaveBinaryExpression(BinaryExpression node)
        {
            if (BinaryOperatorType.Assign == node.Operator)
            {
                if (TypeSystemServices.IsQuackBuiltin(node.Left))
                {
                    ProcessQuackPropertySet(node);
                }
                return;
            }

            if (!AstUtil.IsOverloadableOperator(node.Operator))
            {
                return;
            }
            if (!IsDuckTyped(node.Left) && !IsDuckTyped(node.Right))
            {
                return;
            }

            MethodInvocationExpression mie = CodeBuilder.CreateMethodInvocation(
                RuntimeServices_InvokeBinaryOperator,
                CodeBuilder.CreateStringLiteral(
                    AstUtil.GetMethodNameForOperator(node.Operator)),
                node.Left, node.Right);

            Replace(mie);
        }
Пример #2
0
 protected override void CheckBuiltinUsage(ReferenceExpression node, IEntity entity)
 {
     if (TypeSystemServices.IsQuackBuiltin(entity))
     {
         return;
     }
     base.CheckBuiltinUsage(node, entity);
 }
Пример #3
0
 override protected void ProcessAssignment(BinaryExpression node)
 {
     if (TypeSystemServices.IsQuackBuiltin(node.Left.Entity))
     {
         BindDuck(node);
     }
     else
     {
         ProcessStaticallyTypedAssignment(node);
     }
 }
Пример #4
0
 override protected void ProcessBuiltinInvocation(BuiltinFunction function, MethodInvocationExpression node)
 {
     if (TypeSystemServices.IsQuackBuiltin(function))
     {
         BindDuck(node);
     }
     else
     {
         base.ProcessBuiltinInvocation(function, node);
     }
 }
Пример #5
0
 private void ProcessAssignment(BinaryExpression node)
 {
     if (NodeType.SlicingExpression == node.Left.NodeType)
     {
         SlicingExpression slice = (SlicingExpression)node.Left;
         if (IsDuckTyped(slice.Target))
         {
             ProcessDuckSlicingPropertySet(node);
         }
     }
     else if (TypeSystemServices.IsQuackBuiltin(node.Left))
     {
         ProcessQuackPropertySet(node);
     }
 }
Пример #6
0
        private void ProcessAssignment(BinaryExpression node)
        {
            var slice = node.Left as SlicingExpression;

            if (slice != null)
            {
                if (IsDuckTyped(slice.Target))
                {
                    ProcessDuckSlicingPropertySet(node);
                }
                return;
            }
            if (TypeSystemServices.IsQuackBuiltin(node.Left))
            {
                ProcessQuackPropertySet(node);
            }
        }
Пример #7
0
        override public void OnMethodInvocationExpression(MethodInvocationExpression node)
        {
            if (!IsDuckTyped(node.Target))
            {
                base.OnMethodInvocationExpression(node);
                return;
            }

            if (TypeSystemServices.IsQuackBuiltin(node.Target))
            {
                ExpandQuackInvocation(node);
                return;
            }

            base.OnMethodInvocationExpression(node);
            ExpandCallableInvocation(node);
        }
Пример #8
0
        override public void LeaveMemberReferenceExpression(MemberReferenceExpression node)
        {
            if (!TypeSystemServices.IsQuackBuiltin(node))
            {
                return;
            }

            if (AstUtil.IsLhsOfAssignment(node) ||
                AstUtil.IsTargetOfSlicing(node))
            {
                return;
            }

            MethodInvocationExpression mie = CodeBuilder.CreateMethodInvocation(
                RuntimeServices_GetProperty,
                node.Target,
                CodeBuilder.CreateStringLiteral(node.Name));

            Replace(mie);
        }
Пример #9
0
        protected override void AddResolvedNamedArgumentToEval(MethodInvocationExpression eval, ExpressionPair pair, ReferenceExpression instance)
        {
            if (!TypeSystemServices.IsQuackBuiltin(pair.First))
            {
                base.AddResolvedNamedArgumentToEval(eval, pair, instance);
                return;
            }

            MemberReferenceExpression memberRef = new MemberReferenceExpression(
                pair.First.LexicalInfo,
                instance.CloneNode(),
                ((ReferenceExpression)pair.First).Name);

            BindQuack(memberRef);

            eval.Arguments.Add(
                CodeBuilder.CreateAssignment(
                    pair.First.LexicalInfo,
                    memberRef,
                    pair.Second));
        }
Пример #10
0
        override public void OnMethodInvocationExpression(MethodInvocationExpression node)
        {
            if (TypeSystemServices.IsQuackBuiltin(node.Target))
            {
                ExpandQuackInvocation(node);
                return;
            }

            base.OnMethodInvocationExpression(node);
            if (!IsDuckTyped(node.Target))
            {
                return;
            }

            MethodInvocationExpression invoke = CodeBuilder.CreateMethodInvocation(
                RuntimeServices_InvokeCallable,
                node.Target,
                CodeBuilder.CreateObjectArray(node.Arguments));

            Replace(invoke);
        }
Пример #11
0
        override public void OnMethodInvocationExpression(MethodInvocationExpression node)
        {
            if (!TypeSystemServices.IsDuckTyped(node.Target))
            {
                base.OnMethodInvocationExpression(node);
                return;
            }

            if (TypeSystemServices.IsQuackBuiltin(node.Target))
            {
                ExpandQuackInvocation(node);
                return;
            }

            base.OnMethodInvocationExpression(node);

            if (node.GetAncestor(NodeType.Constructor) == null ||
                (node.Target.NodeType != NodeType.SelfLiteralExpression &&
                 node.Target.NodeType != NodeType.SuperLiteralExpression) ||
                node.Target.Entity as IConstructor == null)
            {
                ExpandCallableInvocation(node);
            }
        }
Пример #12
0
 protected override bool ShouldRebindMember(IEntity entity)
 {
     // always rebind quack builtins (InPlace operators)
     return(null == entity || TypeSystemServices.IsQuackBuiltin(entity));
 }