()
| 53 | } |
| 54 | |
| 55 | func (o *OpOutput) String() string { |
| 56 | ret := fmt.Sprintf("%*c", o.CodeDepth, ' ') |
| 57 | if o.Code != "" { |
| 58 | ret += fmt.Sprintf("[%s]", o.Code) |
| 59 | } |
| 60 | |
| 61 | ret += " " |
| 62 | |
| 63 | switch { |
| 64 | case o.BlockStart: |
| 65 | ret = fmt.Sprintf("%*cBLOCK_START [%s]", o.CodeDepth-IndentStep, ' ', o.Code) |
| 66 | return ret |
| 67 | case o.BlockEnd: |
| 68 | indent := max(o.CodeDepth-(IndentStep*2), 0) |
| 69 | |
| 70 | ret = fmt.Sprintf("%*cBLOCK_END [%s]", indent, ' ', o.Code) |
| 71 | |
| 72 | if o.StrConditionResult != "" { |
| 73 | ret += fmt.Sprintf(" -> %s", o.StrConditionResult) |
| 74 | } |
| 75 | |
| 76 | return ret |
| 77 | // A block end can carry a value, for example if it's a count, any, all etc. XXX |
| 78 | case o.Func: |
| 79 | return ret + fmt.Sprintf("%s(%s) = %s", o.FuncName, strings.Join(o.Args, ", "), strings.Join(o.FuncResults, ", ")) |
| 80 | case o.Comparison: |
| 81 | if o.Negated { |
| 82 | ret += "NOT " |
| 83 | } |
| 84 | |
| 85 | ret += fmt.Sprintf("%s == %s -> %s", o.Left, o.Right, o.StrConditionResult) |
| 86 | |
| 87 | return ret |
| 88 | case o.ConditionIn: |
| 89 | return ret + fmt.Sprintf("%s in %s -> %s", o.Args[0], o.Args[1], o.StrConditionResult) |
| 90 | case o.ConditionContains: |
| 91 | return ret + fmt.Sprintf("%s contains %s -> %s", o.Args[0], o.Args[1], o.StrConditionResult) |
| 92 | case o.JumpIf && o.IfTrue: |
| 93 | if o.ConditionResult != nil { |
| 94 | if *o.ConditionResult { |
| 95 | return ret + "OR -> false" |
| 96 | } |
| 97 | |
| 98 | return ret + "OR -> true" |
| 99 | } |
| 100 | |
| 101 | return ret + "OR(?)" |
| 102 | case o.JumpIf && o.IfFalse: |
| 103 | if o.ConditionResult != nil { |
| 104 | if *o.ConditionResult { |
| 105 | return ret + "AND -> true" |
| 106 | } |
| 107 | |
| 108 | return ret + "AND -> false" |
| 109 | } |
| 110 | |
| 111 | return ret + "AND(?)" |
| 112 | } |
no outgoing calls