Commit graph

74 commits

Author SHA1 Message Date
Daniel
719e269cb1
minor lint fixes (#182) 2019-04-10 21:39:19 -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
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
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
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
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
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
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
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
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
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
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
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
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
Daniel
2b517f376e
add 'rand' module (#90) 2019-02-09 12:33:35 -08:00
Daniel Kang
a9f9ba4592 minor cleanups for 'os' module tests 2019-02-07 15:18:49 -08:00
R.I.Pienaar
06c7e7df61 add os.readfile() 2019-02-07 21:58:47 +01:00
R.I.Pienaar
69961de7de add os.stat() and file.stat() 2019-02-06 15:20:41 +01: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
061d800cf8 removed 'case', 'default', 'switch', 'var' keywords 2019-01-31 12:40:14 -08:00
Daniel Kang
64d99807d8 remove unused code for tuple value return 2019-01-30 02:01:44 -08:00
Daniel Kang
0e9c5231a5 1. fix bytecode compile bug 2. update CLI 2019-01-30 01:21:26 -08:00
Daniel Kang
49b2b5f75f add documentation for text module 2019-01-29 21:08:21 -08:00
Daniel Kang
591d745ef7 updating documents for stdlib 2019-01-29 20:46:30 -08:00
Daniel Kang
306fe1b24c clean up stdlib code 2019-01-29 19:52:00 -08:00
Daniel Kang
a9a93801b7 add 'times' module 2019-01-29 17:39:25 -08:00
Daniel Kang
378bf510d3 add Time type; add is_array, is_immutable_array, is_map, is_immutable_map, is_time, time builtin function 2019-01-29 16:01:14 -08:00
Daniel Kang
f752601ff2 add strconv functions 2019-01-29 15:05:03 -08:00
Daniel Kang
309b03bb30 add more strings functions to text module 2019-01-28 19:30:32 -08:00
Daniel Kang
69a703bea2 text module: regex functions (re_match, re_find, re_split, re_replace) 2019-01-28 18:30:26 -08:00
Daniel Kang
85da0cdc24 force using TrueValue, FalseValue, UndefinedValue 2019-01-28 13:09:40 -08:00
Daniel Kang
cae7b24770 ternary conditional expression implementation 2019-01-27 17:28:30 -08:00
Daniel Kang
69eb7da51e parser implementation for conditional expression 2019-01-27 16:25:12 -08:00
Daniel Kang
4fac7b4013 register immutable array to gob 2019-01-25 15:08:17 -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
011833b95b fix test fail 2019-01-24 17:11:51 -08:00
Daniel Kang
a562964007
Merge pull request #30 from d5/indexable
Indexable and IndexAssignable
2019-01-23 09:29:19 -08:00
Daniel Kang
1045afd5a4 add Indexable / IndexAssignable interface 2019-01-22 15:44:37 -08:00