Commit Graph

43 Commits

Author SHA1 Message Date
Stanisław Barzowski
c1743b9a2a Add std.encodeUTF8 and std.decodeUTF8 2019-03-04 09:41:01 -05:00
Stanisław Barzowski
767f100fd6 std.parseJson - a builtin for parsing json 2018-12-13 13:45:39 -05:00
Dave Cunningham
b4603b0c32 match change to cpp version re: unrecognized native returning null 2018-07-19 14:32:32 -04:00
Dave Cunningham
2973e24152
Internal refactor to improve performance (#225)
* Internal refactor to improve performance
2018-06-01 10:52:20 -04:00
Stanisław Barzowski
530cf7b07c Implement operators == and != as builtins (#221)
People use these operators in tight loops, without even
thinking about it, and it's previous implementation required
multiple object lookups (std.), string comparisons (for types)
and multiple jsonnet function calls.

This change introduces builtin, efficient implementation.
It results in ~3x speedup in strContains benchmark that
Angus provided on Slack.

Additional benefit is that equals/primitiveEquals distinction
is now obsolete, which made things simpler for everyone.
2018-05-23 22:26:30 -04:00
Dave Cunningham
d9b833b8a0
Bump C++ version, implement std.trace, fix parsing of -$, update std (#224) 2018-05-23 22:24:12 -04:00
Marcelo Cantos
ed5f280c59 Apply golint recommendations (#196)
* Apply golint recommendations
2018-02-26 14:12:25 -05:00
Stanisław Barzowski
61b33d1a2a Fast, native implementation of strReplace 2018-01-31 15:27:59 -05:00
Stanisław Barzowski
d6623a98cb Oldest version known to work = Go 1.8, closes #177
It seems like it was broken on older compilers
since pregenerated stdlib AST.

It adds go 1.8.x to travis, so that we have a chance
of catching when our "known to work" no longer holds.
2018-01-18 12:48:20 -05:00
Dave Cunningham
7d821fde83 std.join silently steps over null (match std.jsonnet version) 2018-01-11 09:37:26 -05:00
Stanisław Barzowski
8ade994928 Efficient native implementation of std.join
It changes the behavior slightly - mixing strings
and arrays in join is no longer allowed.
2017-12-13 18:09:56 -05:00
Stanisław Barzowski
f7eea3b545 Native implementation of std.range 2017-12-08 17:17:17 -05:00
Liang Mingqiang
8f568c1115 remove escLocalFS (#150)
* remove escLocalFS

* update README
2017-11-10 09:55:22 -05:00
Liang Mingqiang
aeda6138e5 experiment dump ast to source code (#101)
* Add facility to dump part of Go heap as Go code.

* Generate stdlib AST as Go code

* Use hardcoded stdlib AST instead of parsing it
2017-11-07 23:31:11 -05:00
Dave Cunningham
f965f9ee04
For compatability, emit the \n within the library, not the cmd (#137)
* For compatability, emit the \n within the library, not the commandline tool
* Also add manifestString to library
2017-10-29 21:41:01 -04:00
Dave Cunningham
3eaf189897 Allow bitwise operations on floats, according to Spec (and Javascript behavior) 2017-10-26 20:26:16 -04:00
Stanisław Barzowski
10d377f068 [WIP] Disallow floating point indexing (waiting for #116) 2017-10-14 00:49:04 -04:00
Stanisław Barzowski
ed281bc563 Support for native callbacks 2017-10-13 15:49:06 -04:00
Stanisław Barzowski
5c946dfb76 Eliminate duplication in builtin names
Actually there was one (objectFieldEx) that was inconsistent, i.e.
it was available by a different name from what appeared in the stack
trace. This is now fixed.
2017-10-13 15:33:34 -04:00
Stanisław Barzowski
4b0735826d Rename valueSimpleObjectField -> simpleObjectField
A field on it's own is not a value
2017-10-10 00:31:49 -04:00
Stanisław Barzowski
5b1798233c Represent types as Go objects, not strings (give them pointer identity) (#119)
Faster comparisons and IMO cleaner feeling overall.
It doesn't affect behaviour in any way.
2017-10-10 00:11:36 -04:00
Stanisław Barzowski
ba0f236b14 Optional eval (#92)
* Optional arguments
2017-10-10 00:06:14 -04:00
Stanisław Barzowski
c3459153df Location, error formatting and stack trace improvements (#59)
* Location, error formatting and stack trace improvements

* Static context for AST nodes
* Thunks no longer need `name`
* Prototype for showing snippets in error messages (old format still
available)
* Use ast.Function to represent methods and local function sugar.
* Change tests so that the error output is pretty
2017-10-03 14:27:44 -04:00
Stanisław Barzowski
e7249a1131 Separate manifestation from serialization to string
This is necessary for example for native functions
(which take json as arguments).

Standard "encoding/json" representation is used, but I have
mixed feeling about it. Not sure if treating json values as interface{}
is the right trade-off in our case.
2017-09-29 12:36:29 -04:00
mqliang
c2229ed262 eliminate ununsed code 2017-09-29 12:35:37 -04:00
Stanisław Barzowski
b1a9c0bd6d ExtVar support 2017-09-28 23:14:53 -04:00
Stanisław Barzowski
0c86c9e109 Support of +:, in, in super
Also profiling
2017-09-28 22:21:46 -04:00
Stanisław Barzowski
78b4794523 Object comprehensions 2017-09-27 18:00:30 -04:00
Stanisław Barzowski
9047718ad0 Add std.filter 2017-09-22 13:45:52 -04:00
Stanisław Barzowski
2cf7443b91 Add support for % operator 2017-09-22 13:26:04 -04:00
Stanisław Barzowski
cab0cc887e std.codepoint, std.char + a bunch of tests 2017-09-22 11:53:25 -04:00
Stanisław Barzowski
8a80309137 std.md5 2017-09-14 17:09:57 -04:00
Stanisław Barzowski
a94b877d4b Add std.exponent and std.mantissa 2017-09-12 17:10:21 -04:00
Stanisław Barzowski
4d5365f5e2 Add a bunch of tests for fundamental builtins
Support std.length on objects
2017-09-11 16:35:59 -04:00
Stanisław Barzowski
1e4797071f Even more builtins
Fix a bunch of bugs:
- Reverse meaning of boolean argument to objectFieldsEx and objectHasEx
- Slice desugaring using `std.slice` instead of `slice` as a field name.

Support + on string and something else.
Support + on arrays

assertEqual should now work properly
2017-09-08 14:19:19 -04:00
Stanisław Barzowski
860c3e6e70 Add more builtins 2017-09-07 15:41:41 -04:00
Stanisław Barzowski
3c94bde4dc String indexing, change of string representation (#34)
* String indexing, change of string representation

Also std.pow
2017-09-07 11:56:11 -04:00
Stanisław Barzowski
c26c50c04b Array comprehensions (#35)
* Array comprehensions

Implemented using flatMap.

The representation in AST was changed - now it expresses
the semantic structure better.

Ifs in comprehensions are not supported yet, but easy.
2017-09-07 11:55:33 -04:00
Stanisław Barzowski
c9e23d4ff3 Merge pull request #36 from sbarzowski/toString
Add toString builtin
2017-09-06 18:39:19 -04:00
Stanisław Barzowski
5cd467fd18 More builtins 2017-08-30 01:38:36 -04:00
Alex Clemmer
ad56a074aa Move AST to its own package 2017-08-25 00:30:56 -04:00
Alex Clemmer
c610dec2ef Make AST data structures public 2017-08-25 00:30:56 -04:00
Stanisław Barzowski
5da57ac417 Interpreter & runtime - minimal usable version (#24)
* Interpreter & runtime - minimal usable version

Accomplishments in this commit:
* Majority of language features implemented:
	* Unary operators
	* Binary operators
	* Conditionals
	* Errors
	* Indexing arrays
	* Indexing objects
	* Object inheritance
	* Imports
	* Functions
	* Function calls
* There is a quite nice way for creating builtins
* Static analyzer is there with most of the functionality
* Standard library is included and parts unaffected by missing features
work
* Some bugs in existing parts fixed
* Most positive tests from C++ version pass, the rest is failing mostly
due to missing builtins and comprehensions.
* Some initial structure was created that should allow more incremental
  and focused changes in the future PRs.
* Some comments/explanations added
* Panics translated to a little bit more gentle internal errors (with a
  link to issues on github).

What still sucks:
* Stack traces & error messages (there's some stuff in place)
* Almost everything is in the same package
* Stuff is exported or unexporeted randomly (see above)
* Missing a few lexing/parsing features
* Missing builtins
* Missing support for extvars and top-level-args
* Checking function arguments is missing
* No clean Go API that commandline and compatibility layer to C can use
* No compatibility layer to C
* Assertions don't work (desugaring level, assertEquals works).
* Manifestation stack traces (and generally it could use some work).
* The way environments are constructed is sometimes suboptimal/clumsy.
2017-08-24 20:09:10 -04:00