8 Commits

Author SHA1 Message Date
Johan Fylling a179a24c48 v1 API
All packages, except for `cmd` and `internal`, have been moved into a new `v1` root package.

Old packages are kept for backwards-compatibility reasons. All contained code is replaced with simple type aliases and proxy functions to `v1` implementations.

Old packages default to the Rego v0 syntax, new `v1` packages default to the Rego v1 syntax.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2024-12-12 15:27:34 +01:00
Johan Fylling 7bb6dbe36b Preparing for v1 API
Moving (most) source to v1 root package to prepare for v0/v1 API separation.

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
2024-12-12 15:09:03 +01:00
Anders Eknert a60ef72799 Even less allocs (#7190)
**main**
```
BenchmarkLintAllEnabled-10    1	2640715625 ns/op	6385110200 B/op	116296633 allocs/op
```

**pr**
```
BenchmarkLintAllEnabled-10    1	2597179708 ns/op	6183614112 B/op	108421141 allocs/op
```

(I renamed the benchmark, but this is the same as "regal linting itself"
used in the past)

Another 8 million allocations cut off from `regal lint bundle`,
and a whopping 10% improvements to wall clock time!

The most significant improvement is the Equal implementation for
refs, since that is called all over the place. But there are many
other fixes here, and they all contribute something substantial
(and fixes that only have had marginal impact have been left out).

Signed-off-by: Anders Eknert <anders@styra.com>
2024-11-24 11:24:29 +01:00
Patrick East ffd0036e7c Add debug tracing mode
This adds a new option for eval which will disable indexing so
that variable bindings for rules that would otherwise not evaluate
can be found.

This also adds to (and corrects) the JSON marshalled trace events. We
now have extra metadata about the local variables, a working JSON
marshaller for the `Locals` (which includes type info), and the event
nodes location information.

Fixes: #1697
Signed-off-by: Patrick East <east.patrick@gmail.com>
2019-10-22 10:07:03 -07:00
Matthew Mussomele 3261995cac Refactor ast.Value to use Compare instead of Equal 2017-06-27 09:56:31 -07:00
Torin Sandall 0f90fe9931 Improve trace output
The tracing instrumentation emits redos when evaluation *may* restart. This is
done so that expression redos are emitted before rule/body redos. E.g.,
given the expression p[x] > 1, the event stream should receive
redo(Expr(p[x] > 1)) before redo(Rule(p[x] = y :- ...)). Because redos are
emitted this way, the event stream contains many redos that only indicate that
the search has terminated because no more bindings could be found.

This change adds a stack/buffer to the context which is used to store redos.
When non-redo events are emitted, the buffer is flushed. When adding new redos
to the stack, we discard any that are no longer relevant, i.e., that indicate
that a search terminated because no more bindings could be fine.
2016-10-13 20:51:52 -07:00
Torin Sandall 7bbccdcebc Make ast.ValueMap support nil receiver 2016-10-11 10:32:58 -07:00
Torin Sandall 4ef25a6ad5 Rename storage.Bindings to ast.ValueMap 2016-10-05 09:54:39 -07:00