Commit Graph

138 Commits

Author SHA1 Message Date
Ludovic Fernandez
aa98e2c2a9 feat: support yaegi in go playground 2019-07-24 17:52:03 -07:00
Ludovic Fernandez
dea1f56f38 refactor: use struct to define interpreter Options. (#236) 2019-07-03 19:46:17 +02:00
Marc Vertes
c991e09ca6 fix: correct handling of assign from multiple return func in REPL (#233) 2019-07-01 03:44:13 +02:00
Marc Vertes
274c0fc47a chore: API and code cleanup. Rename stdlib.Value into stdlib.Symbols (#231) 2019-06-27 12:40:04 +02:00
Marc Vertes
cc8e05d61b chore: cleanup API, unexport internal constants, types and variables. (#229) 2019-06-24 16:24:47 +02:00
Marc Vertes
025e4f924a fix: correct handling of equality tests (#205) 2019-06-05 09:50:44 +02:00
Marc Vertes
cc2d122cd3 fix: correct negate operator (#199) 2019-05-31 12:48:46 +02:00
Marc Vertes
557a02d616 perf: better handling of return values in func calls (#193) 2019-05-27 12:21:03 +02:00
Marc Vertes
eb705baa01 fix: implement a single interface wrapper for error type (#190) 2019-05-21 16:49:26 +02:00
Marc Vertes
16690838e3 fix: correct handling of multi-assign operations, including swap (#173) 2019-05-01 16:25:31 +02:00
Marc Vertes
37f93f0392 fix: correct embedded method handling on hybrid struct (#162) 2019-04-19 18:30:04 +02:00
Marc Vertes
8910769b77 feat: functional options to New() (#149) 2019-04-05 21:36:48 +02:00
Marc Vertes
10a8312d2c feat: check build constraints in filenames and comments (#144) 2019-04-02 15:51:44 +02:00
Marc Vertes
cac2a2c547 refactor: define fset in Interpreter rather than Node struct (#141) 2019-03-22 10:34:52 +01:00
Fernandez Ludovic
12b608b625 chore: rename to yaegi. 2019-03-20 10:15:35 +01:00
Marc Vertes
68d7890775 feat: add support for builtins complex, real and imag (#128) 2019-03-19 13:41:34 +01:00
Marc Vertes
8717f1ef4b fix: correct append with variadic parameters and spread array (#124)
* fix: correct append with variadic parameters and spread array
* feat: add print builtin
2019-03-19 12:25:04 +01:00
Marc Vertes
70fab221de feat: add support for builtin delete (#127) 2019-03-19 12:14:44 +01:00
Marc Vertes
b8927e3ca6 feat: add support for builtin copy (#126) 2019-03-19 01:19:43 +01:00
Marc Vertes
a1bfe7c989 feat: add support for builtin new (#125) 2019-03-19 01:12:25 +01:00
Marc Vertes
1ccc36a690 feat: implement support of 'for x := range channel' expression (#119) 2019-03-16 18:36:44 +01:00
Marc Vertes
5a10046944 feat: simplify Use() (#115)
Change API from
func Use(val libValueMap, typ libTypeMap)
to
func Use(val libValueMap)
2019-03-13 12:24:59 +01:00
Marc Vertes
6657e9a18b feat: add support for named output variables (#113)
* feat: add support for named output variables

Function output parameters are located at the start of the function
frame, uninitialized, as they could be only set through return
statements.

Supporting named output variables requires to:

- identify and allocate symbols corresponding to output names:
  done at ident parsing, with the funcRet() helper,

- compute the location of output name in the frame:
  done with retRank() helper,

- initialize the frame entry with the zero value of symbol type,
  as the symbol can be accessed and written at multiple times,
  and return not setting the variable (opposite to unnamed).
  Done with frameType() helper, which now takes into account
  output parameters.

* refactor: simplify memory management

Perform function frame analysis at pre-order, instead of post-order, to
initialize memory frame, and track value types. Remove all operation
involving unitialized types. Frame memory layout is now build
incrementally, instead of having to perform dedicated tree walks on AST.
2019-03-12 19:58:02 +01:00
Marc Vertes
005a3cf93c fix: catch mismatched types in binary operator expressions (#109)
The types of operands are checked prior to generate closures.

- test: improve evalCheck() to check against expected output and/or expected errors.
2019-02-26 11:08:57 +01:00
Marc Vertes
32e0be8b4e fix: improve use of explicit nil (#96)
Type category `UnsetT` is renamed in `NilT`.
Catch invalid use of untyped nil in `:=` expression.
Convert nil to output parameter type when used in `return` expression.
Improve and add relevant unit tests.
2019-02-20 15:44:44 +01:00
Marc Vertes
5677e0501e fix: correct propagation of values during eval (#95)
Eval returns the value of the root node of AST, so ensure
that node values are propagated back to ExprStmt and BlockStmt,
which should be sufficient to handle evaluation of simple
statements.
2019-02-19 14:51:44 +01:00
Marc Vertes
ef83e43bd7 feat: complete handling of switch case statements (#88) 2019-02-11 18:42:00 +01:00
Marc Vertes
6d21cefe75 fix: allow imported binary variables to be set (#85)
Change the way imported binary variables are imported, from
`reflect.ValueOf(val)` to `reflect.ValueOf(&val).Elem()`, to allow these
variables to be set from the interpreter.
Regenerate stdlib packages accordingly.
Ensure that binary value is forwarded if it exists.
Add tests.
2019-02-07 15:41:22 +01:00
Ludovic Fernandez
3f0e693383 refactor: support imports/package/vendor. (#41)
* test: adds tests about package and vendor.

* refactor: support imports/package/vendor.

* review.
2019-01-24 16:16:49 +01:00
Ludovic Fernandez
ed93935c93 refactor: custom GOPATH. (#32) 2019-01-23 13:04:19 +01:00
Ludovic Fernandez
ff4e9b1918 fix: typo. (#31) 2019-01-23 09:50:44 +01:00
Marc Vertes
2ef097e334 feat: better error handling in type parsing (#24)
When parsing types, instead of panic, set proper error and diagnostic with source location.
Propagate errors correctly.
2019-01-21 22:03:40 +01:00
Marc Vertes
015bff1599 feat: handle recover builtin (#13)
The recovered state is stored in `Frame`, and captured in `runCfg()`.
`assign()` has been modified to set handle `interface{}` type (not
possible with `reflect`.
2019-01-17 21:15:10 +01:00
Marc Vertes
098829d316 style: fix warnings from golangci-lint printed by make check (#11)
* style: fix warnings from golangci-lint printed by `make check`
* style: err assign in if block when possible. Better use of switch/case
* style: err assign in if block when possible
2019-01-16 18:59:24 +01:00
Marc Vertes
7987a97847 feat(ast): handle defer statement (#8) 2019-01-15 12:33:02 +01:00
Marc Vertes
bd15f88be6 feat: add support for select statement (#5)
* ast: improve error handling
* ast: handle select
* dyngo: set filename of executed script
* cfg: improve error reporting
* Implement select for receiving channels
* feat(select): add support for sending channels in case clauses
* test: improve tests on select
* feat(select): add support for "default" case
2019-01-09 17:45:38 +01:00
Marc Vertes
9bce65c284 REPL: fix prompt if output is not stdout 2018-12-20 16:39:33 +01:00
Marc Vertes
3c542659cc Make REPL part of interp package 2018-12-20 16:17:46 +01:00
Marc Vertes
13e104156b ast() returns an error instead of panicking 2018-12-19 19:47:17 +01:00
Marc Vertes
f8a4aba39b Add interpreter inception example 2018-12-11 17:23:24 -08:00
Marc Vertes
ba3f015c16 Fix golint warnings 2018-12-11 10:34:21 -08:00
Marc Vertes
b0ef0a00db Interpreter now exports itself, so scripts can do Eval() too 2018-12-11 10:29:43 -08:00
Marc Vertes
480ef53daf Get rid of Export(). Fix golint warnings 2018-12-11 03:38:51 -08:00
Marc Vertes
6a23877ce2 Eval: wrap returned interpreter node into a callable function 2018-12-11 03:12:50 -08:00
Marc Vertes
6a397e2294 Fix golint warnings 2018-12-07 17:37:58 +01:00
Marc Vertes
ea07c12f56 Support incremental parse and eval, and interactive mode 2018-12-07 17:16:11 +01:00
Marc Vertes
befbe23695 Load binary dependencies with Import() 2018-12-06 16:16:54 +01:00
Marc Vertes
6b013ffd35 Simplify export to runtime 2018-12-04 15:14:02 +01:00
Marc Vertes
7ddb593bc2 Interpreter call from runtime: fix node wrapper generation 2018-11-21 15:00:47 +01:00
Marc Vertes
059a071407 Fix calls of functions returning multiple values 2018-11-12 16:00:13 +01:00