(constant any)
| 139 | } |
| 140 | |
| 141 | func (c *compiler) addConstant(constant any) int { |
| 142 | indexable := true |
| 143 | hash := constant |
| 144 | switch reflect.TypeOf(constant).Kind() { |
| 145 | case reflect.Slice, reflect.Map, reflect.Struct, reflect.Func: |
| 146 | indexable = false |
| 147 | } |
| 148 | if field, ok := constant.(*runtime.Field); ok { |
| 149 | indexable = true |
| 150 | hash = fmt.Sprintf("%v", field) |
| 151 | } |
| 152 | if method, ok := constant.(*runtime.Method); ok { |
| 153 | indexable = true |
| 154 | hash = fmt.Sprintf("%v", method) |
| 155 | } |
| 156 | if indexable { |
| 157 | if p, ok := c.constantsIndex[hash]; ok { |
| 158 | return p |
| 159 | } |
| 160 | } |
| 161 | c.constants = append(c.constants, constant) |
| 162 | p := len(c.constants) - 1 |
| 163 | if indexable { |
| 164 | c.constantsIndex[hash] = p |
| 165 | } |
| 166 | return p |
| 167 | } |
| 168 | |
| 169 | func (c *compiler) addVariable(name string) int { |
| 170 | c.variables++ |
no test coverage detected