Skip to content

Commit

Permalink
Merge pull request #367 from Consensys/366-reset-constraint-assignmen…
Browse files Browse the repository at this point in the history
…t-lisp

Reset internal primitive naming
  • Loading branch information
DavePearce authored Oct 24, 2024
2 parents 16b4c37 + 74942ae commit 266c677
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/schema/assignment/data_column.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (p *DataColumn) IsComputed() bool {
// Lisp converts this schema element into a simple S-Expression, for example
// so it can be printed.
func (p *DataColumn) Lisp(schema sc.Schema) sexp.SExp {
col := sexp.NewSymbol("defcolumns")
col := sexp.NewSymbol("column")
name := sexp.NewSymbol(p.Columns().Next().QualifiedName(schema))
//
if p.datatype.AsField() != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/schema/assignment/sorted_permutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (p *SortedPermutation) Lisp(schema sc.Schema) sexp.SExp {
}

return sexp.NewList([]sexp.SExp{
sexp.NewSymbol("defpermutation"),
sexp.NewSymbol("sort"),
targets,
sources,
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/schema/constraint/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (p *LookupConstraint[E]) Lisp(schema sc.Schema) sexp.SExp {
}
// Done
return sexp.NewList([]sexp.SExp{
sexp.NewSymbol("deflookup"),
sexp.NewSymbol("lookup"),
sexp.NewSymbol(p.handle),
targets,
sources,
Expand Down
2 changes: 1 addition & 1 deletion pkg/schema/constraint/permutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (p *PermutationConstraint) Lisp(schema sc.Schema) sexp.SExp {
}

return sexp.NewList([]sexp.SExp{
sexp.NewSymbol("defpermutation"),
sexp.NewSymbol("permutation"),
targets,
sources,
})
Expand Down
13 changes: 7 additions & 6 deletions pkg/schema/constraint/vanishing.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,20 +215,21 @@ func HoldsLocally[T sc.Testable](k uint, handle string, constraint T, tr tr.Trac
//
//nolint:revive
func (p *VanishingConstraint[T]) Lisp(schema sc.Schema) sexp.SExp {
attributes := sexp.EmptyList()
name := p.handle
// Handle attributes
if p.domain == nil {
// Skip
} else if *p.domain == 0 {
attributes.Append(sexp.NewSymbol(":first"))
name = fmt.Sprintf("%s:first", name)
} else if *p.domain == -1 {
name = fmt.Sprintf("%s:last", name)
} else {
attributes.Append(sexp.NewSymbol(":last"))
panic(fmt.Sprintf("domain value %d not supported for local constraint", p.domain))
}
// Construct the list
return sexp.NewList([]sexp.SExp{
sexp.NewSymbol("defconstraint"),
sexp.NewSymbol(p.handle),
attributes,
sexp.NewSymbol("vanish"),
sexp.NewSymbol(name),
p.constraint.Lisp(schema),
})
}

0 comments on commit 266c677

Please sign in to comment.