From 97b80cb930a21ed062b81e0bc5706559286e0f16 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Sat, 1 May 2021 22:01:05 -0400 Subject: [PATCH] lang: unification: Move the InvariantSolution struct We are just relocating this in the file for consistency. --- lang/unification/unification.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lang/unification/unification.go b/lang/unification/unification.go index cec3e402..261ab4b1 100644 --- a/lang/unification/unification.go +++ b/lang/unification/unification.go @@ -143,6 +143,22 @@ func (obj *Unifier) Unify() error { return nil } +// InvariantSolution lists a trivial set of EqualsInvariant mappings so that you +// can populate your AST with SetType calls in a simple loop. +type InvariantSolution struct { + Solutions []*interfaces.EqualsInvariant // list of trivial solutions for each node +} + +// ExprList returns the list of valid expressions. This struct is not part of +// the invariant interface, but it implements this anyways. +func (obj *InvariantSolution) ExprList() []interfaces.Expr { + exprs := []interfaces.Expr{} + for _, x := range obj.Solutions { + exprs = append(exprs, x.ExprList()...) + } + return exprs +} + // exclusivesProduct returns a list of different products produced from the // combinatorial product of the list of exclusives. Each ExclusiveInvariant must // contain between one and more Invariants. This takes every combination of @@ -181,19 +197,3 @@ func exclusivesProduct(exclusives []*interfaces.ExclusiveInvariant) [][]interfac return results } - -// InvariantSolution lists a trivial set of EqualsInvariant mappings so that you -// can populate your AST with SetType calls in a simple loop. -type InvariantSolution struct { - Solutions []*interfaces.EqualsInvariant // list of trivial solutions for each node -} - -// ExprList returns the list of valid expressions. This struct is not part of -// the invariant interface, but it implements this anyways. -func (obj *InvariantSolution) ExprList() []interfaces.Expr { - exprs := []interfaces.Expr{} - for _, x := range obj.Solutions { - exprs = append(exprs, x.ExprList()...) - } - return exprs -}