Пример #1
0
        public override object Visit(Block that, object value)
        {
            foreach (Statement statement in that.Statements)
            {
                switch (statement.Kind)
                {
                    case NodeKind.BlockStatement:
                    case NodeKind.CallStatement:
                    case NodeKind.DelegateStatement:
                    case NodeKind.EntryStatement:
                    case NodeKind.FunctionStatement:
                        /**
                         *  \note We need special handling of delegates and entries as they can be created outside of classes and
                         *  therefore the \c ClassStatement code for computing the encoded/mangled name entry is not invoked.
                         */
                        statement.Visit(this);
                        break;

                    case NodeKind.ClassStatement:
                    case NodeKind.InterfaceStatement:
                    case NodeKind.ScopeStatement:
                        statement.Visit(this);
                        break;

                    default:
                        continue;
                }
            }

            return null;
        }
        /** Process statements in \b any block whatsoever. */
        public override object Visit(Block that, object value)
        {
            foreach (Statement statement in that.Statements)
            {
                switch (statement.Kind)
                {
            #if DONE
                    case NodeKind.ClassStatement:
                    case NodeKind.EnumerationStatement:
                    case NodeKind.InterfaceStatement:
            #endif
                    case NodeKind.ScopeStatement:
                        statement.Visit(this);
                        break;
            #if DONE
                    case NodeKind.TypeStatement:
                        throw new System.NotImplementedException("Type definitions are not supported yet");
            #endif
                    default:
                        continue;
                }
            }

            return null;
        }
        public override object Visit(Block that, object value = null)
        {
            PrintPrologue(that);
            PrintSequence("Statements", that.Statements);
            PrintEpilogue(that);

            foreach (Statement statement in that.Statements)
                statement.Visit(this);

            return null;
        }
Пример #4
0
        public override object Visit(Block that, object value)
        {
            if (that.Above.Kind != NodeKind.Module)
                _writer.Indent();

            foreach (Statement statement in that.Statements)
                statement.Visit(this);

            if (that.Above.Kind != NodeKind.Module)
                _writer.Dedent();

            return null;
        }
Пример #5
0
        public Routine(
            NodeKind kind,
            Cursor cursor,
            SymbolDefinition name,
            Profile profile,
            Block block
        )
            : base(kind, cursor, name)
        {
            _profile = profile;
            _profile.Above = this;

            _block = block;
            _block.Above = this;
        }
Пример #6
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
            );
        }
Пример #7
0
 public ScopeStatement(Cursor cursor, SymbolDefinition name, Block block)
     : base(NodeKind.ScopeStatement, cursor, name)
 {
     _block = block;
     _block.Above = this;
 }
Пример #8
0
        public override object Visit(Block that, object value)
        {
            bool reset = (bool) value;
            if (reset)
                ResetTemporaries();

            foreach (Statement statement in that.Statements)
                statement.Visit(this);

            return null;
        }
Пример #9
0
 public BlockStatement(Cursor cursor, Block block)
     : base(NodeKind.BlockStatement, cursor)
 {
     _block = block;
     _block.Above = this;
 }
Пример #10
0
 public Module(Cursor cursor, Block block)
     : base(NodeKind.Module, cursor)
 {
     _block = block;
     _block.Above = this;
 }
Пример #11
0
 public EntryStatement(Cursor cursor, SymbolDefinition name, Profile profile, Block block)
     : base(NodeKind.EntryStatement, cursor, name, profile, block)
 {
 }
Пример #12
0
 public override object Visit(Block that, object value = null)
 {
     foreach (Statement statement in that.Statements)
         statement.Visit(this);
     return null;
 }
Пример #13
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
            );
        }