Sfoglia il codice sorgente

обработка массива байт, правильное вычисление длины строки

kpmy 10 anni fa
parent
commit
e10b797ce6
3 ha cambiato i file con 6 aggiunte e 2 eliminazioni
  1. 0 0
      XevDemo6.oxf
  2. 3 2
      rt2/rules/op.go
  3. 3 0
      xev/converter.go

File diff suppressed because it is too large
+ 0 - 0
XevDemo6.oxf


+ 3 - 2
rt2/rules/op.go

@@ -10,6 +10,7 @@ import (
 	"fw/rt2/nodeframe"
 	"fw/rt2/scope"
 	"reflect"
+	"unicode/utf8"
 	"ypk/assert"
 )
 
@@ -80,7 +81,7 @@ func length(a object.Object, _a, _b interface{}) (ret int64) {
 		case object.DynArrayType:
 			switch _a.(type) {
 			case string:
-				ret = int64(len(_a.(string)))
+				ret = int64(utf8.RuneCountInString(_a.(string)))
 			default:
 				ret = 0
 				fmt.Sprintln("unsupported", reflect.TypeOf(_a))
@@ -91,7 +92,7 @@ func length(a object.Object, _a, _b interface{}) (ret int64) {
 	} else {
 		switch _a.(type) {
 		case string:
-			ret = int64(len(_a.(string)))
+			ret = int64(utf8.RuneCountInString(_a.(string)))
 		default:
 			panic(fmt.Sprintln("unsupported", reflect.TypeOf(_a)))
 		}

+ 3 - 0
xev/converter.go

@@ -170,6 +170,9 @@ func (r *Result) doType(n *Node) (ret object.ComplexType) {
 		case "CHAR":
 			n := object.NewDynArrayType(object.CHAR)
 			ret = n
+		case "BYTE":
+			n := object.NewDynArrayType(object.BYTE)
+			ret = n
 		default:
 			panic(fmt.Sprintln("unknown type", n.Data.Typ.Typ))
 		}

Some files were not shown because too many files changed in this diff