private void Visit( UnaryOpExpression expression, QualifiedModuleName module, Declaration scope, Declaration parent) { Visit(expression.Expr, module, scope, parent); }
private void Visit( UnaryOpExpression expression, QualifiedModuleName module, Declaration scope, Declaration parent, bool isAssignmentTarget, bool hasExplicitLetStatement) { Visit((dynamic)expression.Expr, module, scope, parent, false, false); }
//static Regex Shift = new Regex(@"(<in1>[a-z]+) (?<binop>(L|R)SHIFT) (<in2>[0-9]+) -> (<out>[a-z]+)"); public static Expression Decode(string wire) { Expression e; Match m; if ((m = OneToOne.Match(wire)).Success) { e = new UnaryOpExpression() { }; } else if ((m = TwoToOne.Match(wire)).Success) { e = new BinaryOpExpression() { }; } else { throw new Exception(); } return(e); }
private static Expression GenerateInverse(Expression exp, Expression var, Dictionary <Expression, bool> hasVar) { var result = var; while (!(exp is VariableExpression)) { Debug.Assert(hasVar[exp]); if (exp is UnaryOpExpression) { var unaryOp = (UnaryOpExpression)exp; result = new UnaryOpExpression { Operation = unaryOp.Operation, Value = result }; exp = unaryOp.Value; } else if (exp is BinOpExpression) { var binOp = (BinOpExpression)exp; var leftHasVar = hasVar[binOp.Left]; var varExp = leftHasVar ? binOp.Left : binOp.Right; var constExp = leftHasVar ? binOp.Right : binOp.Left; if (binOp.Operation == BinOps.Add) { result = new BinOpExpression { Operation = BinOps.Sub, Left = result, Right = constExp }; } else if (binOp.Operation == BinOps.Sub) { if (leftHasVar) { result = new BinOpExpression { Operation = BinOps.Add, Left = result, Right = constExp } } ; else { result = new BinOpExpression { Operation = BinOps.Sub, Left = constExp, Right = result } }; } else if (binOp.Operation == BinOps.Mul) { Debug.Assert(constExp is LiteralExpression); var val = ((LiteralExpression)constExp).Value; val = MathsUtils.modInv(val); result = new BinOpExpression { Operation = BinOps.Mul, Left = result, Right = (LiteralExpression)val }; } else if (binOp.Operation == BinOps.Xor) { result = new BinOpExpression { Operation = BinOps.Xor, Left = result, Right = constExp }; } exp = varExp; } } return(result); }
public override void Visit(UnaryOpExpression expression) { expression.Value.AcceptVisitor(this); }
public abstract void Visit(UnaryOpExpression expression);
private void Visit(UnaryOpExpression expression, Declaration parent, IBoundExpression withExpression) { Visit(expression.Expr, parent, withExpression); }
public override void Visit(UnaryOpExpression expression) { throw new NotImplementedException(); }