Browse Source

подготовка к новому алгоритму IS

kpmy 10 năm trước cách đây
mục cha
commit
3a6e24e03c
3 tập tin đã thay đổi với 44 bổ sung20 xóa
  1. 1 1
      fw.go
  2. 6 6
      rt2/module/ml.go
  3. 37 13
      rt2/rules2/wrap/data/val.go

+ 1 - 1
fw.go

@@ -37,7 +37,7 @@ func main() {
 	flag.Parse()
 	utils.Debug(debug)
 	if name == "" {
-		name = "Start3"
+		name = "XevDemo11"
 	}
 	global := &stdDomain{god: true}
 	global.global = global

+ 6 - 6
rt2/module/ml.go

@@ -211,7 +211,7 @@ type tc struct {
 	TypeCalc
 }
 
-type inherited interface {
+type Inherited interface {
 	Complex(...object.ComplexType) object.ComplexType
 }
 
@@ -261,8 +261,8 @@ func (c *tc) MethodList() (ret map[int][]Method) {
 						} else if t.Equals(pt) {
 							//fmt.Println("double ", pt.Qualident(), po.Name(), po.Adr())
 						}
-						if _, ok := pt.(inherited); ok {
-							pt = pt.(inherited).Complex()
+						if _, ok := pt.(Inherited); ok {
+							pt = pt.(Inherited).Complex()
 						} else {
 							pt = nil
 						}
@@ -292,7 +292,7 @@ func (c *tc) MethodList() (ret map[int][]Method) {
 		tmp = make(map[mid]object.Object, 0)
 		for t := x; t != nil; {
 			list(m, t)
-			z := t.(inherited).Complex()
+			z := t.(Inherited).Complex()
 			if z != nil {
 				t = z
 			} else {
@@ -354,8 +354,8 @@ func (c *tc) String() (ret string) {
 				if po.Link() != nil {
 					pt := po.Link().Complex()
 					var pb object.ComplexType
-					if _, ok := pt.(inherited); ok {
-						pb = pt.(inherited).Complex()
+					if _, ok := pt.(Inherited); ok {
+						pb = pt.(Inherited).Complex()
 					}
 					if t.Equals(pt) || t.Equals(pb) {
 						ret = fmt.Sprintln(ret, po.Name(), local)

+ 37 - 13
rt2/rules2/wrap/data/val.go

@@ -1360,29 +1360,29 @@ func (o *ops) Is(a scope.Value, typ object.ComplexType) scope.Value {
 				tc := o.Domain().Global().Discover(context.MOD).(rtm.List).NewTypeCalc()
 				tc.ConnectTo(a)
 				_, fc := tc.ForeignBase()
-				fmt.Println(a, fc)
+				//fmt.Println(a, fc)
 				switch {
 				case x.Name() == a.Name():
-					fmt.Println("eq")
-					fmt.Println("qid ", x.Qualident(), _a.Qualident(), "names ", x.Name(), a.Name())
+					//fmt.Println("eq")
+					//fmt.Println("qid ", x.Qualident(), _a.Qualident(), "names ", x.Name(), a.Name())
 					return true //опасно сравнивать имена конеш
 				case x.Complex() != nil:
-					fmt.Println("go base")
-					fmt.Println("qid ", x.Complex().Qualident(), a.Qualident())
+					//fmt.Println("go base")
+					//fmt.Println("qid ", x.Complex().Qualident(), a.Qualident())
 					return compare(x.Complex(), a)
 				case fc != nil:
-					fmt.Println("go foreign")
-					fmt.Println("qid ", x.Qualident(), fc.Qualident())
+					//fmt.Println("go foreign")
+					//fmt.Println("qid ", x.Qualident(), fc.Qualident())
 					return compare(x, fc)
 				default:
-					fmt.Println("go here")
+					//fmt.Println("go here")
 					return false
 				}
 			case object.PointerType:
 				if a.Complex() != nil {
 					return compare(x, a.Complex())
 				} else {
-					fmt.Println("to here")
+					//fmt.Println("to here")
 					return false
 				}
 			default:
@@ -1393,10 +1393,10 @@ func (o *ops) Is(a scope.Value, typ object.ComplexType) scope.Value {
 			case object.PointerType:
 				switch {
 				case x.Name() == a.Name():
-					fmt.Println("eq")
+					//fmt.Println("eq")
 					return true //опасно сравнивать имена конеш
 				case x.Complex() != nil:
-					fmt.Println("go base")
+					//fmt.Println("go base")
 					return compare(x.Complex(), a)
 				default:
 					return false
@@ -1409,11 +1409,32 @@ func (o *ops) Is(a scope.Value, typ object.ComplexType) scope.Value {
 		}
 		panic(0)
 	}
+	comp2 := func(this, with object.ComplexType) {
+		fmt.Println("compare")
+		dump := func(this object.ComplexType) {
+			fmt.Println(this.Adr())
+			tc := o.Domain().Global().Discover(context.MOD).(rtm.List).NewTypeCalc()
+			for x := this; x != nil; {
+				tc.ConnectTo(x)
+				fmt.Println(x.Qualident())
+				x = x.(rtm.Inherited).Complex()
+				if x == nil {
+					_, x = tc.ForeignBase()
+				}
+			}
+		}
+		dump(this)
+		dump(with)
+		fmt.Println()
+	}
 	switch x := a.(type) {
 	case *rec:
 		z, a := x.comp.(object.RecordType)
 		y, b := typ.(object.RecordType)
-		fmt.Println("compare rec", x.comp, typ, a, b, a && b && compare(z, y))
+		//fmt.Println("compare rec", x.comp, typ, a, b, a && b && compare(z, y))
+		if a && b {
+			comp2(z, y)
+		}
 		return BOOLEAN(a && b && compare(z, y))
 	case *ptr:
 		z, a := x.comp.(object.PointerType)
@@ -1423,7 +1444,10 @@ func (o *ops) Is(a scope.Value, typ object.ComplexType) scope.Value {
 			z, a = c.(object.RecordType)
 		}
 		y, b := typ.(object.PointerType)
-		fmt.Println("compare ptr", z, typ, a, b, a && b && compare(z, y))
+		//fmt.Println("compare ptr", z, typ, a, b, a && b && compare(z, y))
+		if a && b {
+			comp2(z, y)
+		}
 		return BOOLEAN(a && b && compare(z, y))
 	case *idx:
 		return o.Is(x.Get(), typ)