|
6 | 6 | "reflect" |
7 | 7 | "strconv" |
8 | 8 | "strings" |
| 9 | + "unicode/utf8" |
9 | 10 | ) |
10 | 11 |
|
11 | 12 | // ConstVariable a model to record a const variable |
@@ -60,7 +61,7 @@ func EvaluateEscapedString(text string) string { |
60 | 61 | i++ |
61 | 62 | char, err := strconv.ParseInt(text[i:i+4], 16, 32) |
62 | 63 | if err == nil { |
63 | | - result = AppendUtf8Rune(result, rune(char)) |
| 64 | + result = utf8.AppendRune(result, rune(char)) |
64 | 65 | } |
65 | 66 | i += 3 |
66 | 67 | } else if c, ok := escapedChars[text[i]]; ok { |
@@ -404,7 +405,7 @@ func EvaluateUnary(x interface{}, operator token.Token, xtype ast.Expr) (interfa |
404 | 405 | func EvaluateBinary(x, y interface{}, operator token.Token, xtype, ytype ast.Expr) (interface{}, ast.Expr) { |
405 | 406 | if operator == token.SHR || operator == token.SHL { |
406 | 407 | var rightOperand uint64 |
407 | | - yValue := CanIntegerValue{reflect.ValueOf(y)} |
| 408 | + yValue := reflect.ValueOf(y) |
408 | 409 | if yValue.CanUint() { |
409 | 410 | rightOperand = yValue.Uint() |
410 | 411 | } else if yValue.CanInt() { |
@@ -467,8 +468,8 @@ func EvaluateBinary(x, y interface{}, operator token.Token, xtype, ytype ast.Exp |
467 | 468 | evalType = ytype |
468 | 469 | } |
469 | 470 |
|
470 | | - xValue := CanIntegerValue{reflect.ValueOf(x)} |
471 | | - yValue := CanIntegerValue{reflect.ValueOf(y)} |
| 471 | + xValue := reflect.ValueOf(x) |
| 472 | + yValue := reflect.ValueOf(y) |
472 | 473 | if xValue.Kind() == reflect.String && yValue.Kind() == reflect.String { |
473 | 474 | return xValue.String() + yValue.String(), evalType |
474 | 475 | } |
|
0 commit comments