Commit graph

306 commits

Author SHA1 Message Date
Jacob R. McCollum
adcf05d26f add variadic function parameters (#189)
* parsing variable function types

* finished variadic functions

* fix case where number of passed args to variadic function is 0

* remove extraneous OpVarArgs

* allow multiple variables in variadic function declaration

* fix IdentList string method to print multi-arg variadic functions correctly

* round 2 of fix IdentList string method to print multi-arg variadic functions correctly

round 2 of fix IdentList string method to print multi-arg variadic functions correctly

* clean up tasks in OpCall handling, add tests for variadic closures

* cleanup for pr

- add syntax documentation
- cleanup parseIdentList
- cleanup OpCall handling for functions and closures
- cleanup tests
2019-04-25 21:28:27 -07:00
Daniel
2e0ea3a4c1
update syntax documentation (#186)
* Update tutorial.md

* Update tutorial.md

* Update tutorial.md

* Update tutorial.md

* Update tutorial.md

add logical operators, assignment operators, increment operators

* wip

* wip

* update
2019-04-18 23:33:23 -07:00
earncef
19d2945e1e Used by badge (#188) 2019-04-15 09:30:34 -07:00
earncef
1ca10a7e3f Added formatting docs (#187) 2019-04-14 13:14:44 -07:00
earncef
b2df4f579c Custom formatter based on go's fmt package. (#185)
* Custom formatter based on go's fmt package.

* Cleanup

* Cleanup

* Added tengo.MaxStringLen check

* Cleanup
2019-04-13 11:29:50 -07:00
earncef
bb07fa15b7 text.trim, text.pad_left and text.pad_right (#183)
* Added trim, pad_left and pad_right to text

* Check MaxStringLen

* Added doc

* Fixed doc

* Moved length check
2019-04-11 00:23:30 -07:00
Daniel
719e269cb1
minor lint fixes (#182) 2019-04-10 21:39:19 -07:00
earncef
3eebecb2a4 Fix %v formatting (#181)
* Fix %v formatting

* Added Bytes

* Fixed tests.
2019-04-09 23:15:31 -07:00
earncef
09009d4040 Substring function (#180)
* Substring function

* substring -> substr
2019-04-08 23:32:39 -07:00
earncef
1a0c06b688 Made map IndexSet and IndexGet consistent. (#179) 2019-04-08 19:54:02 -07:00
earncef
8eabc23a45 Fixed runtime error when iterating over undefined. (#177) 2019-04-08 19:52:37 -07:00
earncef
0ae9a66e26 Fixed interoperability doc (#174) 2019-04-08 19:51:26 -07:00
Daniel
2cde0eaeea
json module faster implementation (#173)
* json module faster implementation

* add some decoding error test
2019-04-06 05:25:23 -07:00
Daniel
17a50b7c50
fix #171 (#172) 2019-04-01 08:02:11 -07:00
Daniel
8dc0d7b591
fix script timeout bug (#170)
* fix an edge case where script timeout is too short and set even before VM starts execution

* vm.StackObjects() -> v.IsStackEmpty()
2019-03-31 23:37:30 -07:00
Daniel
1ac4090452
update benchmark (#169) 2019-03-31 22:08:25 -07:00
Daniel
9b6c5e670a
fix a bug in dead code elimination (#168)
* fix a bug in dead code elimination

* add some tests
2019-03-31 12:20:10 -07:00
Daniel
2f86800724
'enum' module (#166)
* 1. adding more methods to enum module
2. added ModuleMap.AddMap()
3. added bytes iterator

* add builtin functions 'is_enumerable' and 'is_array_like'

* builtin function 'is_iterable'

* first iteration on 'enum' module

* fix 'is_iterable' builtin function
2019-03-27 01:27:59 -07:00
Daniel
b9c1c92d2d
Compiler optimization first iteration (#165)
* dead code elimination phase 1

* combine dead code elimination with return fix code

* remove last instruction tracking from compiler code (not needed)

* fix a symbol table block scope bug

* add some more tests
2019-03-24 02:23:38 -07:00
Daniel
01fe30f02a
bug fix for function return and if statement (#160)
* fix a bug where function return instruction is missing with if statement

* remove script cancel context test
2019-03-23 12:59:54 -07:00
Daniel
2b21c29bd3
update builtin function documentation (#159)
* Update builtins.md

* Update builtins.md

* Update builtins.md
2019-03-22 09:27:34 -07:00
Daniel
7e3f3f809e
update benchmark (#158) 2019-03-22 05:27:28 -07:00
earncef
09f3d52265 Opbinaryop and other minor optimizations (#157)
* OpBinaryOp for performance

* Cleanup

* Remove ip limit check in every iteration of the loop.

* Micro optimizations on frequent ops

* Micro optimizations

* Patches

* Removed redundant binaryop operators from compiler

* Merged OpReturn and OpReturnValue

* Cleanup
2019-03-22 04:42:34 -07:00
Daniel
7095b5678b
add ModuleMap.Remove() (#155) 2019-03-20 10:11:14 -07:00
Daniel
3c30109cd0
fix bytecode encoding/decoding of builtin modules (#154)
* fix bytecode encoding/decoding of builtin modules

* Bytecode.Decode() to take map[string]objects.Importable

* add objects.ModuleMap

* update docs

* stdlib.GetModuleMap()
2019-03-20 01:28:40 -07:00
Daniel
e785e38bf8
fix bytecode encoding/decoding (#152)
* register ImmutableMap type to gob

* fix bytecode decoding

* disallow empty module name
2019-03-19 09:43:03 -07:00
Daniel
2520caf581
update README (#151)
* Update README.md

* Update README.md
2019-03-18 22:42:50 -07:00
Daniel
61890b15cb
module refactor (#148)
* wip

* move print and JSON functions to modules

* builtin functions are not replacable now

* builtin functions are added for default nil symbol table

* importables: builtin modules and source modules

* refactoring runtime tests

* fix tests

* update documentation

* cleanup

* clean up cli

* fix REPL prints
2019-03-18 08:15:26 -07:00
earncef
052ae5906b Refactored duplicate REPL code (#145)
* Refactored duplicate REPL code

* Cleanup

* Added comments

* Added repl.Options

* Added comment

* Clenaup

* Cleanup
2019-03-16 13:58:08 -07:00
earncef
ebddfd13a7 Added println (#144)
* Added println

* Fixed tests.

* Updated doc

* Fixed doc

* Cleanup

* Added size limit

* Fixed incorrect type

* Cleanup

* Consistent output for print and println
2019-03-16 00:14:22 -07:00
Daniel
17329aa139
update benchmark result with v1.15.0 (#141) 2019-03-14 01:31:40 -07:00
earncef
5d8457a8f6 Removed double indirection for massive performance gains (#140)
* Removed double indirection for performance gains

* Added missing file

* Cleanup

* Remove pointers patch.

* Cleanup

* Removed redundant parenthesis

* FreeVar changed to ObjectPtr and removed OpSetLocalPtr

* Removed truePtr, falsePtr and undefinedPtr

* Cleanup
2019-03-14 01:07:19 -07:00
Daniel
1921d907a6
fix scipt.Variable.Value() bug (#139) 2019-03-13 03:07:06 -07:00
Daniel
8707fd6e7f
fix to_json builtin function bug (#138) 2019-03-13 02:25:21 -07:00
Daniel
b7977a419b
add Compiled.Clone to make them safe for concurrent execution (#134) 2019-03-08 01:10:49 -08:00
Daniel
e93f6f6325
limit max object allocations (#129)
- add object.NumObjects()
- add object allocation limit in VM
- delete objects.Break, objects.Continue, objects.ReturnValue
- add Script.SetMaxAllocs()
- update sandbox documentation
- add some tests
- remove duplicate values in compiled constants (fixes #96)
- option to limit the maximum number of objects in compiled bytecode constants
2019-03-06 17:20:05 -08:00
earncef
46884c7b25 Removed redundant code in the VM with no performance loss. (#132)
* Removed redundant code in the VM with no performance loss.

* binaryOp is not exported

* minor update
2019-03-05 13:53:14 -08:00
earncef
a3735846a5 Updated docs for SetBuiltinFunctions and SetBuiltinModules (#131)
* Updated docs for SetBuiltinFunctions and SetBuiltinModules

* minor update
2019-03-04 11:53:09 -08:00
earncef
c437def4a0 Decoupled stdlib from vm, script and compiler (#126)
* Decoupled stdlib from script

* Decoupled compiler and vm from stdlib

* cleanup

* Docs and cleanup

* main package with and without stdlib

* cleanup

* Update .goreleaser
2019-03-04 10:21:39 -08:00
Daniel
68cd38e49e
minor doc update
1. composite types -> compound types (#128)
2. composite assignment -> compound assignment
2019-03-03 15:21:28 -08:00
Daniel
53ce12998e
add module-import tests to most of runtime package (#125) 2019-03-01 15:55:29 -08:00
Daniel
0c5e80b057
Limit the maximum size of string/bytes values (#121)
* add tengo.MaxStringLen and tengo.MaxBytesLen to limit the maximum byte-length of string/bytes values

* add couple more tests
2019-03-01 10:48:02 -08:00
earncef
880ee04ffe script.Add accepts a CallableFunc value (#124)
* script.Add accepts a CallableFunc value

* moved to FromInterface
2019-03-01 09:28:41 -08:00
Daniel
306055ad65
add helper functions for builtin functions and builtin modules (#122)
* add helper functions for builtin functions and builtin modules

* fix a builtin function bug for modules
2019-02-28 18:41:29 -08:00
earncef
7cc683e867 SetBuiltinFunctions and SetBuiltinModules (#120)
* `SetBuiltinFunctions` and `SetBuiltinModules`

* nil implies no built in functions.

* Additional tests.

* Cleanup

* Updated SetBuiltinFunctions

* Docs updated.
2019-02-28 08:26:25 -08:00
earncef
39112d226e String keys allowed for map definitions. (#118)
* String keys allowed for map definitions.

* parse error for map key
2019-02-25 22:53:04 -08:00
earncef
5816186821 parser.ParseFile removed (#117)
* parser.ParseFile removed

* return values
2019-02-25 22:52:08 -08:00
earncef
6ec360c8b7 Fixed panic when bailout is triggered in parser.ParseFile() (#113)
* Fixed panic when bailout is triggered in parser.ParseFile()

* Removed redundant "parse error" prefix for parse errors.
2019-02-25 10:22:45 -08:00
earncef
6dd573c3f6 Runtime error trace format (#111)
* Runtime error format

* Parser and Compiler error formats updated
2019-02-22 13:39:07 -08:00
earncef
f265f1702b Stack trace for errors (#108)
* Simple strack trace for runtime errors.

* Module test for runtime error stack trace

* Removed OpExport

* Removed redundant code.

* Removed vm.FrameInfo()
2019-02-21 09:40:17 -08:00