Esempio n. 1
0
        public override object Visit(CallExpression that, object value)
        {
            that.Callee.Visit(this);
            _writer.Write('(');
            foreach (Expression argument in that.Arguments)
            {
                if (argument != that.Arguments[0])
                    _writer.Write(", ");

                argument.Visit(this);
            }
            _writer.Write(')');
            return null;
        }
        public override object Visit(CallExpression that, object value)
        {
            var result = new System.Text.StringBuilder(256);

            // Output the signature of Braceless v0.x encoded/mangled names.
            result.Append(marker + "b0" + marker);

            that.Callee.Visit(this, (object) result);
            result.Append(marker);

            /** \note Don't encode the return type as we do like C++ and C#: Overloads cannot differ only in return type. */

            // Encode number of parameters.
            result.Append(that.Arguments.Length.ToString());
            result.Append(marker);

            foreach (Expression argument in that.Arguments)
            {
                argument.Visit(this, (object) result);
                result.Append(marker);
            }

            that.Encoded = result.ToString();

            return null;
        }
        public override object Visit(CallExpression that, object value = null)
        {
            PrintPrologue(that);
            PrintNodeId("Callee", that.Callee);
            PrintSequence("Arguments", that.Arguments);
            _writer.WriteLine("Encoded = {0}", (that.Encoded != null) ? that.Encoded : "(none)");
            PrintNodeId("Target", that.Target);
            PrintEpilogue(that);

            that.Callee.Visit(this);
            foreach (Expression argument in that.Arguments)
                argument.Visit(this);

            return null;
        }
Esempio n. 4
0
        public override object Visit(CallExpression that, object value)
        {
            Storage index = (Storage) value;
            if (index == null)
                index = new TemporaryStorage(CreateTemporary());

            _writer.Write("call ");
            _writer.Write(index.ToString());
            #if FINISHED
            that.Callee.Type.Visit(this);
            #endif
            _writer.Write(" @");
            _writer.Write(EncodeEncoded(that.Encoded));
            _writer.Write('(');
            foreach (Expression argument in that.Arguments)
            {
                argument.Visit(this);
                if (argument != that.Arguments[that.Arguments.Length - 1])
                    _writer.Write(", ");
            }
            _writer.Write(')');

            return (object) index;
        }
 public override object Visit(CallExpression that, object value = null)
 {
     /** \note Don't visit the \c Callee yet as this is done in \c ResolveRoutinesWalker. */
     foreach (Expression argument in that.Arguments)
         argument.Visit(this);
     return null;
 }
Esempio n. 6
0
        /** Parses an expression. */
        private Expression ParseExpression()
        {
            Expression result;

            /** Parse the expression prefix. */
            switch (_matcher.This.Kind)
            {
            #if DONE
                case TokenKind.Keyword_Base:
                    result = (Expression) ParseParentReference();
                    break;
            #endif
                case TokenKind.Dot:
                    result = (Expression) ParseMemberReference();
                    break;

                case TokenKind.Exclamation:
                    result = (Expression) ParseGlobalReference();
                    break;

            #if DONE
                case TokenKind.Keyword_False:
                case TokenKind.Keyword_True:
                    result = (Expression) ParseBooleanLiteral();
                    break;
            #endif

                case TokenKind.Name:
                    result = (Expression) ParseSymbolReference();
                    break;

                case TokenKind.Literal_Cardinal:
                    result = (Expression) ParseCardinalLiteral();
                    break;
            #if DONE
                case TokenKind.Literal_Character:
                    result = (Expression) ParseCharacterLiteral();
                    break;
            #endif
                case TokenKind.Literal_Text:
                    result = (Expression) ParseTextLiteral();
                    break;
            #if DONE
                case TokenKind.Keyword_New:
                    result = (Expression) ParseNewExpression();
                    break;

                case TokenKind.Keyword_None:
                    result = (Expression) ParseNoneExpression();
                    break;

                case TokenKind.Keyword_This:
                {
                    _matcher.Match(TokenKind.Keyword_This);
                    result = (Expression) ParseMemberReference();
                    break;
                }

                case TokenKind.BracketBegin:
                    result = (Expression) ParseBracketExpression();
                    break;
            #endif
                default:
                    /** \todo The \c ToString() invokation does not call our \c ToString() - why? */
                    throw new ParserError(_matcher.This.Cursor, "Expression expected, found " + _matcher.This.Kind.ToString());
            }

            bool done = false;
            while (!done)
            {
                switch (_matcher.This.Kind)
                {
                    case TokenKind.Dot:
                    {
                        Token start = _matcher.Match(TokenKind.Dot);
                        Token label = _matcher.Match(TokenKind.Name);
                        result = new PrefixReference(start.Cursor, result, label.Text);
                        break;
                    }

            #if DONE
                    case TokenKind.BracketBegin:
                    {
                        Token start = _matcher.Match(TokenKind.BracketBegin);
                        Expression other = ParseExpression();
                        _matcher.Match(TokenKind.BracketClose);
                        result = new ArrayExpression(start.Cursor, result, other);
                        break;
                    }
            #endif

                    case TokenKind.ParenthesisBegin:
                    {
                        Token start = _matcher.This;
                        Expression[] arguments = ParseArguments();
                        result = new CallExpression(start.Cursor, result, arguments);
                        break;
                    }

                    default:
                        done = true;
                        break;
                }
            }

            return result;
        }