public override RuntimeValueNode OpGreater(RuntimeValueNode other) { var strValue = (string)Value; switch (other.Value) { case int i: return(Wrap(strValue.Length > i)); case string s: return(Wrap(strValue.Length > s.Length)); } throw new Exceptions.RuntimeException("", DefiningToken); }
public override RuntimeValueNode OpMinus(RuntimeValueNode other) { var strValue = (string)Value; switch (other.Value) { case int i: if (i >= strValue.Length) { return(Wrap(strValue.Substring(0, strValue.Length - i))); } else { return(Wrap("")); } } throw new Exceptions.RuntimeException("", DefiningToken); }
public override RuntimeValueNode OpDivide(RuntimeValueNode other) { var strValue = (string)Value; switch (other.Value) { case int i: { if (i == 0) { throw new Exceptions.RuntimeException("", DefiningToken); } var resultLen = strValue.Length / i; strValue = strValue.Substring(resultLen); if (i < 0) { strValue = strValue.Reverse().ToString(); } return(Wrap(strValue)); } } throw new Exceptions.RuntimeException("", DefiningToken); }
public override RuntimeValueNode OpMultiply(RuntimeValueNode other) { var strValue = (string)Value; switch (other.Value) { case int i: { var res = ""; if (i < 0) { strValue = strValue.Reverse().ToString(); i = -i; } for (int j = 0; j < i; ++j) { res += strValue; } return(Wrap(res)); } } throw new Exceptions.RuntimeException("", DefiningToken); }
public abstract RuntimeValueNode OpEqual(RuntimeValueNode other);
public abstract RuntimeValueNode OpGreater(RuntimeValueNode other);
public abstract RuntimeValueNode OpDivide(RuntimeValueNode other);
public abstract RuntimeValueNode OpMultiply(RuntimeValueNode other);
public abstract RuntimeValueNode OpMinus(RuntimeValueNode other);
public override RuntimeValueNode OpSmaller(RuntimeValueNode other) { return(Wrap((int)Value < (int)other.Value)); }
public override RuntimeValueNode OpGreater(RuntimeValueNode other) { return(Wrap((int)Value > (int)other.Value)); }
public override RuntimeValueNode OpDivide(RuntimeValueNode other) { return(Wrap((int)Value / (int)other.Value)); }
public override RuntimeValueNode OpMultiply(RuntimeValueNode other) { return(Wrap((int)Value * (int)other.Value)); }
public override RuntimeValueNode OpMinus(RuntimeValueNode other) { return(Wrap((int)Value - (int)other.Value)); }
public abstract RuntimeValueNode OpSmaller(RuntimeValueNode other);
public override RuntimeValueNode OpEqual(RuntimeValueNode other) { return(Wrap((int)Value == (int)other.Value)); }
public override RuntimeValueNode OpSmaller(RuntimeValueNode other) { throw new Exceptions.RuntimeException("", DefiningToken); }
public override RuntimeValueNode OpPlus(RuntimeValueNode other) { return(Wrap((string)Value + other.Value.ToString())); }