Esempio n. 1
0
 public Block(Cursor cursor, Statement[] statements)
     : base(NodeKind.Block, cursor)
 {
     _statements = statements;
     foreach (Statement statement in _statements)
         statement.Above = this;
 }
Esempio n. 2
0
        public override Node Clone()
        {
            Statement[] statements = new Statement[_statements.Length];
            for (int i = 0; i < statements.Length; i++)
                statements[i] = (Statement) _statements[i].Clone();

            return new Block(this.Cursor, statements);
        }
Esempio n. 3
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
            );
        }
Esempio n. 4
0
        /** Creates a default setter for use in a field or a guard. */
        private SetStatement CreateDefaultSetter(Cursor cursor, string value)
        {
            /** Create the \c value parameter. */
            /** \todo Move creation of the \c value parameter to a suitable pass. */
            Parameter parameter = new Parameter(
                position,
                new SymbolDefinition(position, "value", SymbolKind.Parameter),
                DirectionKind.In,
                new UnknownType(position)
            );

            /** Create the profile of the setter. */
            Profile profile = new Profile(position, new NoneType(position), new Parameter[1]{ parameter });

            /** Create the body of the setter: let .value := value. */
            Statement statement = new LetStatement(
                position,
                AssignmentKind.Identity,
                new NamedExpression(position, new SymbolReference(position, PathKind.Instance, value)),
                new NamedExpression(position, new SymbolReference(position, PathKind.Relative, "value"))
            );
            Statement[] statements = new Statement[1]{ statement };
            Block block = new Block(position, statements);

            return new SetStatement(
                position,
                new SymbolDefinition(position, "set", SymbolKind.Setter),
                profile,
                block
            );
        }