Commit Graph

17 Commits

Author SHA1 Message Date
Anand Krishnamoorthi
a381c38a90 Use compact_rc (#139)
There is not much use for weak_counts in Rc for us.

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2024-02-09 23:22:09 -08:00
Anand Krishnamoorthi
84bedda1c6 OPA conformance (#81)
- Switch to scientific crate. Large values are printed in scientific notations.
  Regular values are printed as u64, i64 or f64.
- Skip copying commit hooks in git worktrees
- urlquery.decode, urlquery.encode, urlquery.encode_object
- substring, indexof_n string builtins
- Make sprintf more OPA conformant

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-12-30 08:36:15 -08:00
Burak
1fb144b145 Add tests for builtin string::format_int method (#65) 2023-12-22 09:31:57 -08:00
Anand Krishnamoorthi
577e1aa8db More OPA conformance; in-progress: ability to trace interpreter (#63)
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-12-16 17:50:59 -08:00
Anand Krishnamoorthi
73ee18f002 More OPA conformant semantics (#62)
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-12-11 09:00:06 -08:00
Anand Krishnamoorthi
ed3492fd7b Formalize concept of a Number (#55)
Number is implemented using rust_decimal::Decimal which uses a 96 bit mantissa.
TODO:
  a) Support u64, i64 variants
  b) Determine desired semantics for floating-point
  c) Determine desired big integer length
  d) Explore other big int/big float crates

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-12-01 08:45:59 -08:00
Anand Krishnamoorthi
3514594c56 Use Rc<str> instead of string. (#52)
This reduces std::mem::size_of::<Value>() to 16 bytes.
String values are also efficiently copied like Objects, arrays, sets etc.

When multiple function rules are evaluated, ensure that constant argument values
match before running the rule. If actual parameter does not match the constant parameter,
then the rule is skipped.

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-11-24 17:45:49 -08:00
Anand Krishnamoorthi
72070a7061 Avoid dependency on `source lifetime. (#43)
This allows holding onto objects, caching results etc easily.
However it does introduce the overhead of ref counting.

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-11-15 09:25:12 -08:00
Anand Krishnamoorthi
0af8b6ea12 Ability to run the OPA testsuite (#39)
`OPA_TESTS_DIR=path/to/testsuite cargo test opa -- --shot-output` to run opa tests.
Failing test cases are saved in target/opa/folder for investigation.

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-11-09 15:11:33 -08:00
Anand Krishnamoorthi
800e594d52 Arity for builtins (#28)
Old-style function call

Utility for running opa yaml tests

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-10-24 10:11:50 -07:00
Anand Krishnamoorthi
c5ea737200 Partial sprintf implementation.
This needs to be flushed out to be compatible with https://pkg.go.dev/fmt.
All the features of the go format string don't need to be implemented,
only those that are relevant for Rego.

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-03-04 17:12:18 +05:30
Anand Krishnamoorthi
ea47de919c All string functions except sprintf. TODO: Add tests
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-03-01 22:13:09 +05:30
Anand Krishnamoorthi
f9897085cf More string functions without tests
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-03-01 22:13:09 +05:30
Anand Krishnamoorthi
3c3cd312fc More string functions
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-03-01 22:13:09 +05:30
Anand Krishnamoorthi
27c5afd8ee strings: concat and contains
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-03-01 22:13:09 +05:30
Anand Krishnamoorthi
89e26e37a2 string concat (WIP)
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-03-01 22:13:09 +05:30
Anand Krishnamoorthi
12c3d26476 Lock down numbers
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
2023-02-28 09:38:40 +05:30