Beispiel #1
0
        /** Creates a default getter for use in a field or a guard. */
        private GetStatement CreateDefaultGetter(Cursor cursor, string value)
        {
            // Create profile of the default getter.
            Profile profile = new Profile(
                position,
                new NamedType(position, new SymbolReference(position, PathKind.Instance, value)),
                new Parameter[0]
            );

            // Create sole embedded statement; a return statement that returns the value of the data member.
            Statement statement = new ReturnExpressionStatement(
                position,
                new NamedExpression(position, new SymbolReference(position, PathKind.Instance, value))
            );
            Statement[] statements = new Statement[1]{ statement };
            Block block = new Block(position, statements);

            return new GetStatement(
                position,
                new SymbolDefinition(position, "get", SymbolKind.Getter),
                profile,
                block
            );
        }
Beispiel #2
0
 public override object Visit(ReturnExpressionStatement that, object value)
 {
     _writer.Write("return ");
     that.Expression.Visit(this);
     _writer.WriteLine();
     return null;
 }
        public override object Visit(ReturnExpressionStatement that, object value = null)
        {
            PrintPrologue(that);
            _writer.WriteLine("Expression = {0}", that.Expression.Id);
            PrintEpilogue(that);

            that.Expression.Visit(this);

            return null;
        }
Beispiel #4
0
        public override object Visit(ReturnExpressionStatement that, object value)
        {
            Storage result = (Storage) that.Expression.Visit(this);
            _writer.Write("ret ");
            #if FINISHED
            that.Expression.Type.Visit(this);
            #endif
            _writer.Write(" " + result.ToString());
            _writer.WriteLine();

            return null;
        }
 public override object Visit(ReturnExpressionStatement that, object value = null)
 {
     that.Expression.Visit(this);
     return null;
 }
Beispiel #6
0
        /** Parses a \c return statement. */
        private Statement ParseReturnStatement()
        {
            Token start = _matcher.Match(TokenKind.Keyword_Return);
            Statement result;
            if (_matcher.This.Kind != TokenKind.EndOfLine)
            {
                _matcher.Match(TokenKind.Space);
                var expression = ParseExpression();
                result = new ReturnExpressionStatement(start.Cursor, expression);
            }
            else
                result = new ReturnNothingStatement(start.Cursor);
            _matcher.Match(TokenKind.EndOfLine);

            return result;
        }