예제 #1
0
        [NotNull] protected virtual BaseExpression Visit([NotNull] Increment inc)
        {
            var v = new Variable(inc.Name);
            var r = (Variable)Visit(v);

            return(new Increment(r.Name));
        }
예제 #2
0
 static BaseExpression HandleExpression(BaseExpression right)
 {
     return(right switch {
         Variable v => new Increment(v.Name),
         ConstantNumber n => new ConstantNumber(new Add(n, new ConstantNumber((Number)1)).StaticEvaluate().Number),
         ConstantString s => new ConstantString(s.Value + " "),
         Bracketed b => HandleExpression(b.Parameter),
         _ => throw new InvalidOperationException(right.GetType().Name)
     });
예제 #3
0
        protected override BaseExpression Visit(Variable var)
        {
            if (var.Name.IsExternal)
            {
                return(var);
            }

            if (_assigned.Contains(var.Name))
            {
                return(var);
            }

            return(new ConstantNumber((Number)0));
        }
예제 #4
0
 public virtual BaseExpression Visit(BaseExpression expression)
 {
     return(expression switch {
         Phi a => Visit(a),
         Increment a => Visit(a),
         Decrement a => Visit(a),
         ErrorExpression a => Visit(a),
         Bracketed a => Visit(a),
         Abs a => Visit(a),
         Sqrt a => Visit(a),
         Sine a => Visit(a),
         Cosine a => Visit(a),
         Tangent a => Visit(a),
         ArcSine a => Visit(a),
         ArcCos a => Visit(a),
         ArcTan a => Visit(a),
         PostIncrement a => Visit(a),
         PreIncrement a => Visit(a),
         PostDecrement a => Visit(a),
         PreDecrement a => Visit(a),
         Add a => Visit(a),
         Subtract a => Visit(a),
         Multiply a => Visit(a),
         Divide a => Visit(a),
         Modulo a => Visit(a),
         Negate a => Visit(a),
         Exponent a => Visit(a),
         Or a => Visit(a),
         And a => Visit(a),
         Not a => Visit(a),
         Factorial a => Visit(a),
         Variable a => Visit(a),
         ConstantNumber a => Visit(a),
         ConstantString a => Visit(a),
         EqualTo a => Visit(a),
         NotEqualTo a => Visit(a),
         GreaterThan a => Visit(a),
         GreaterThanEqualTo a => Visit(a),
         LessThan a => Visit(a),
         LessThanEqualTo a => Visit(a),
         _ => VisitUnknown(expression)
     });
예제 #5
0
            protected override IDataFlowGraphExpressionNode Visit(Variable var)
            {
                // If this is an external variable add a new input node
                if (var.Name.IsExternal)
                {
                    var external = new InputVariable(Guid.NewGuid(), var.Name);
                    _dataFlowGraph._inputs.Add(external);
                    return(external);
                }

                // It's not external, try to find an output node which was previously assigned
                var output = _dataFlowGraph._outputs.OfType <AssignmentOutput>().SingleOrDefault(a => a.Name.Equals(var.Name));

                if (output != null)
                {
                    return(output);
                }

                // It wasn't previously assigned, add a new input
                var input = new InputVariable(Guid.NewGuid(), var.Name);

                _dataFlowGraph._inputs.Add(input);
                return(input);
            }
예제 #6
0
 protected override bool Visit(Variable var) => _bools.Contains(var.Name);
예제 #7
0
 protected override Type Visit(Variable var) => VariableRead(var.Name);
예제 #8
0
 [NotNull] protected virtual BaseExpression Visit([NotNull] Variable var)
 {
     return(new Variable(Visit(var.Name)));
 }
예제 #9
0
 protected override IEnumerable <BaseStatement> Visit(Variable var)
 {
     return(new[] { new Assignment(new VariableName(_names.Name()), var) });
 }
예제 #10
0
 protected override IEnumerable <BaseStatement> Visit(Variable var)
 {
     return(new[] { new Assignment(MkTmp(), var) });
 }