public override bool Unify(IRExpression template, Dictionary <IRVariable, IRExpression> varMapping) { if (template is IRVariable templateVar && templateVar.Type == Type) { if (varMapping.ContainsKey(templateVar)) { return(varMapping[templateVar].Equals(this)); } varMapping[templateVar] = this; return(true); } if (!(template is IRCallExpression exp) || exp.TargetName != TargetName || !exp.Type.Equals(Type) || exp.Arguments.Count != Arguments.Count) { return(false); } for (int i = 0; i < Arguments.Count; i++) { if (!Arguments[i].Unify(exp.Arguments[i], varMapping)) { return(false); } } return(true); }
public override void Substitute(IRVariable variable, IRExpression expression) { if (ReferenceEquals(Pointer, variable)) { Pointer = expression.CloneComplete(); } else { Pointer.Substitute(variable, expression); } }
public override bool Unify(IRExpression template, Dictionary <IRVariable, IRExpression> varMapping) { if (!(template is IRVariable exp) || !exp.Type.Equals(Type)) { return(false); } if (varMapping.ContainsKey(exp)) { return(varMapping[exp].Equals(this)); } varMapping[exp] = this; return(true); }
public override void Substitute(IRVariable variable, IRExpression expression) { for (int i = 0; i < Arguments.Count; i++) { if (ReferenceEquals(Arguments[i], variable)) { Arguments[i] = expression.CloneComplete(); } else { Arguments[i].Substitute(variable, expression); } } }
public override bool Unify(IRExpression template, Dictionary <IRVariable, IRExpression> varMapping) { if (template is IRVariable templateVar && templateVar.Type == Type) { if (varMapping.ContainsKey(templateVar)) { return(varMapping[templateVar].Equals(this)); } varMapping[templateVar] = this; return(true); } if (!(template is IRDerefExpression exp) || !exp.Type.Equals(Type)) { return(false); } return(Pointer.Unify(exp.Pointer, varMapping)); }
public override void Substitute(IRExpression template, IRExpression substitution, OnMatchFoundHandler callback) { Pointer.Substitute(template, substitution, callback); var mapping = new Dictionary <IRVariable, IRExpression>(); if (Pointer.Unify(template, mapping) && callback(mapping)) { if (substitution is IRVariable v) { Pointer = mapping[v].CloneComplete(); } else { var newExpr = substitution.CloneComplete(); foreach (var varMap in mapping) { newExpr.Substitute(varMap.Key, varMap.Value); } Pointer = newExpr; } } }
public IRComparisonExpression UnsignedLessThan(IRExpression b) => new IRComparisonExpression(IRComparisonOperator.UnsignedLess, this, b);
public abstract void Substitute(IRExpression template, IRExpression substitution, OnMatchFoundHandler callback);
public void Substitute(IRExpression template, IRExpression substitution) { Substitute(template, substitution, _ => true); }
public abstract bool Unify(IRExpression template, Dictionary <IRVariable, IRExpression> varMapping);
public IRComparisonExpression UnsignedGreaterEqualAs(IRExpression b) => new IRComparisonExpression(IRComparisonOperator.UnsignedGreaterEqual, this, b);
public abstract void Substitute(IRVariable variable, IRExpression expression);
public IRComparisonExpression GreaterThan(IRExpression b) => new IRComparisonExpression(IRComparisonOperator.Greater, this, b);
public IRDerefExpression(IRType type, IRExpression pointer) : base(type) { Pointer = pointer; }
public override void Substitute(IRExpression template, IRExpression substitution, OnMatchFoundHandler callback) { }
public IRBinaryExpression ShiftRightArithmetic(IRExpression amount) => new IRBinaryExpression(Type, IRBinaryOperator.Asr, this, amount.Cast(Type));
public IRBinaryExpression ShiftRightLogical(IRExpression amount) => new IRBinaryExpression(Type, IRBinaryOperator.Lsr, this, amount.Cast(Type));
public IRBinaryExpression ShiftLeft(IRExpression amount) => new IRBinaryExpression(Type, IRBinaryOperator.Lsl, this, amount.Cast(Type));
public override void Substitute(IRVariable variable, IRExpression expression) { }
public IRComparisonExpression LessEqualAs(IRExpression b) => new IRComparisonExpression(IRComparisonOperator.LessEqual, this, b);