예제 #1
0
        public override Node Clone()
        {
            Parameter[] parameters = new Parameter[_parameters.Length];
            for (int i = 0; i < parameters.Length; i++)
                parameters[i] = (Parameter) _parameters[i].Clone();

            return new Profile(this.Cursor, (Type) this.Type.Clone(), parameters);
        }
예제 #2
0
        public Profile(Cursor cursor, Type type, Parameter[] parameters)
            : base(NodeKind.Profile, cursor)
        {
            _type = type;
            _type.Above = this;

            _parameters = parameters;
            foreach (Parameter parameter in _parameters)
                parameter.Above = this;
        }
예제 #3
0
 public override object Visit(Parameter that, object value)
 {
     that.Type.Visit(this, value);
     return null;
 }
예제 #4
0
        public override object Visit(Parameter that, object value)
        {
            _writer.Write(BackquoteNameOpt(that.Name.Symbol));
            _writer.Write(" is ");
            switch (that.Direction)
            {
                case DirectionKind.In:
                    break;

                case DirectionKind.InOut:
                    _writer.Write("io ");
                    break;

                case DirectionKind.Out:
                    _writer.Write("out ");
                    break;

                default:
                    throw new System.NotImplementedException("that.Direction");
            }
            that.Type.Visit(this);
            return null;
        }
        public override object Visit(Parameter that, object value = null)
        {
            PrintPrologue(that);
            PrintDefinition(that);
            _writer.WriteLine("Direction = {0}", that.Direction.ToString());
            PrintNodeId("Type", that.Type);
            PrintEpilogue(that);

            that.Name.Visit(this);
            that.Type.Visit(this);

            return null;
        }
예제 #6
0
 public override object Visit(Parameter that, object value)
 {
     /** \todo Mark read-only parameters. */
     that.Type.Visit(this);
     _writer.Write(" %");
     that.Name.Visit(this);
     return null;
 }
예제 #7
0
 public override object Visit(Parameter that, object value = null)
 {
     that.Name.Visit(this);
     that.Type.Visit(this);
     return null;
 }
예제 #8
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
            );
        }