Commit graph

62 commits

Author SHA1 Message Date
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
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
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
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
8707fd6e7f
fix to_json builtin function bug (#138) 2019-03-13 02:25:21 -07: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
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
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
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
Daniel
3500c686b3
Improvements on compiler/VM error reporting (filename:line:col)
- add type infos to VM error messages
- add 'Name' to UserFunction objects 
- add 'expectErrorString' to VM tests
- replace vm.expectError() with vm.expectErrorString() to make it more explicit
- add source map info to VM error messages
- optimization in function calls
- add file/line/col info to compiler errors
- change stdlib module to be loaded from VM (instead of compiler) so they can be properly loaded after the source is compiled into binary
- VM can take builtin modules optionally
2019-02-20 16:26:11 -08:00
Daniel
cb1c8a405e
Fix a bug for 'for' loop without condition: "for {}" (#100) 2019-02-12 01:28:23 -08:00
Daniel
fc4e3586c4
Fix a closure-block scope bug (#99)
* fix issue #98

* remove objects.CompiledModule

* remove objects.CompiledModule
2019-02-11 17:34:02 -08:00
Daniel
9ccc6dd901
add Bytecode.FormatInstructions and Bytecode.FormatConstants (#95) 2019-02-10 21:44:22 -08:00
Daniel
9c67444678
Fixes a REPL bug (Issue #91) (#92) 2019-02-10 00:32:37 -08:00
earncef
5e21abfd74 IndexGet of Array, Index, ImmutableIndex, Bytes, String, Undefined 2019-02-09 16:45:21 -08:00
Daniel Kang
90aafc8bb4 Add 'is_function' and 'is_callable' builtin functions 2019-02-03 15:50:40 -08:00
Daniel Kang
5713eb64fe Fix a slicing expression bug: allow low-index == len(a) 2019-02-02 23:11:02 -08:00
Daniel Kang
eda0495f30 Fix several module-related issues 2019-02-02 22:22:40 -08:00
Daniel Kang
9c21c8a804 Fix a bug where user modules couldn't resolve builtin functions 2019-02-01 18:13:29 -08:00
Daniel Kang
c57a7f8f98 Fix a bug where len() builtin does not take immutable array 2019-02-01 17:32:05 -08:00
Daniel Kang
9e73f40485 1. Added documentation on operators. 2. Add (char)-(int) operators 2019-02-01 16:58:44 -08:00
Daniel Kang
6a663c6360 add script.Compiled.Set function so compiled script can replace value of global variables 2019-02-01 11:09:12 -08:00
Daniel Kang
950cb79648 update documentation 2019-01-31 00:39:45 -08:00
Daniel Kang
64d99807d8 remove unused code for tuple value return 2019-01-30 02:01:44 -08:00
Daniel Kang
306fe1b24c clean up stdlib code 2019-01-29 19:52:00 -08:00
Daniel Kang
85da0cdc24 force using TrueValue, FalseValue, UndefinedValue 2019-01-28 13:09:40 -08:00
Chyroc
d413d2ffe7 feat: add builtin function: type 2019-01-28 13:19:03 +08:00
Daniel Kang
cae7b24770 ternary conditional expression implementation 2019-01-27 17:28:30 -08:00
Daniel Kang
85001be9b8 implement immutable array and map 2019-01-25 14:54:58 -08:00
Daniel Kang
19498da491 adding immutable value (incomplete) 2019-01-24 19:31:17 -08:00
Daniel Kang
37016f4e17 add 'printf' and 'sprintf' builtin functions 2019-01-24 16:38:04 -08:00
Daniel Kang
2486457fdf add Iterable interface 2019-01-23 13:36:03 -08:00
Daniel Kang
a562964007
Merge pull request #30 from d5/indexable
Indexable and IndexAssignable
2019-01-23 09:29:19 -08:00
Mike Bazuin
e94b3dab0f Added builtin function from_json
objects/builtin_json.go:
	- Added function builtinFromJSON

objects/builtins.go:
	- Added builtin function from_json

runtim/vm_builtin_test.go:
	- Added tests for builtin function from_json
2019-01-23 17:24:53 +01:00
Mike Bazuin
c4e6e61fb6 Added builtin function to_json
objects/builtin_json.go:
	- Added function builtinToJSON

objects/builtins.go:
	- Added builtin function to_json

runtime/vm_builtin_test.go
	- Added tests for builtin function to_json
2019-01-23 17:24:53 +01:00
Daniel Kang
1045afd5a4 add Indexable / IndexAssignable interface 2019-01-22 15:44:37 -08:00
Daniel Kang
336fbc30e5 some performance optimization in VM 2019-01-20 08:32:12 -08:00
Daniel Kang
88dd0224d5 use atomic.Load/Store to avoid data race 2019-01-20 06:33:22 -08:00
Mike Bazuin
fae85000cf Convert returns second argument Object as it self in case of failure of conversion of first argument
objects/builtin_convert.go
- Changed type check of in case of args[0] failure to always return
  args[1] if set

runtime/vm_builtin_test.go:
- Changed tests according to changes in objects/builtin_convert.go
2019-01-18 23:29:04 +01:00
Mike Bazuin
a747c98fb5 Builtin converts now take default values
objects/builtin_convert.go: Added defaults to all builtin convert functions except
bool as this one returns false for undefined, instead of undefined.

runtime/vm_builtin_test.go: Added tests for checking default value
behaviour for builtin convert funcs
2019-01-18 22:21:42 +01:00
Mike Bazuin
b4a2da8a30 runtime/vm_builtin_test.go: Added builtin bytes convert test 2019-01-18 22:21:35 +01:00
Daniel Kang
5164d1de9f add 'exec' module 2019-01-18 10:17:24 -08:00