public override void LeaveMethodInvocationExpression(Boo.Lang.Compiler.Ast.MethodInvocationExpression node)
        {
            ICallableType callable = node.Target.ExpressionType as ICallableType;

            if (callable != null)
            {
                CallableSignature signature = callable.GetSignature();
                if (!signature.AcceptVarArgs)
                {
                    return;
                }

                ExpandInvocation(node, signature.Parameters);
                return;
            }

            IMethod method = TypeSystemServices.GetOptionalEntity(node.Target) as IMethod;

            if (null == method || !method.AcceptVarArgs)
            {
                return;
            }

            ExpandInvocation(node, method.GetParameters());
        }
Beispiel #2
0
        private object GetLiteral(Expression expression)
        {
            switch (expression.NodeType)
            {
            case NodeType.CastExpression:
                return(GetLiteral(((CastExpression)expression).Target));

            case NodeType.IntegerLiteralExpression:
                return(((IntegerLiteralExpression)expression).Value);
            }
            IField field = TypeSystemServices.GetOptionalEntity(expression) as IField;

            if (field == null)
            {
                return(null);
            }
            if (!field.IsLiteral)
            {
                return(null);
            }
            return(field.StaticValue);
        }
Beispiel #3
0
        private bool IsLastArgumentOfVarArgInvocation(UnaryExpression node)
        {
            MethodInvocationExpression parent = node.ParentNode as MethodInvocationExpression;

            if (null == parent)
            {
                return(false);
            }
            if (parent.Arguments.Count == 0 || node != parent.Arguments[-1])
            {
                return(false);
            }
            ICallableType type = parent.Target.ExpressionType as ICallableType;

            if (null != type)
            {
                return(type.GetSignature().AcceptVarArgs);
            }

            IMethod method = TypeSystemServices.GetOptionalEntity(parent.Target) as IMethod;

            return(null != method && method.AcceptVarArgs);
        }
Beispiel #4
0
        override public void OnReferenceExpression(ReferenceExpression node)
        {
            IExternalEntity member = TypeSystemServices.GetOptionalEntity(node) as IExternalEntity;

            if (member == null)
            {
                return;
            }

            System.Attribute[] attributes = System.Attribute.GetCustomAttributes(member.MemberInfo, typeof(ObsoleteAttribute));
            foreach (ObsoleteAttribute attr in attributes)
            {
                if (attr.IsError)
                {
                    Errors.Add(
                        CompilerErrorFactory.Obsolete(node, member.ToString(), attr.Message));
                }
                else
                {
                    Warnings.Add(
                        CompilerWarningFactory.Obsolete(node, member.ToString(), attr.Message));
                }
            }
        }
Beispiel #5
0
 public bool Matches(Node node)
 {
     return(_entity == TypeSystemServices.GetOptionalEntity(node));
 }