Commit Graph

124 Commits

Author SHA1 Message Date
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
Marc Vertes
314ceb15a7 Propagate method receiver info accross assignments 2018-11-05 15:55:14 +01:00
Marc Vertes
20ce2a13dc Improve handling of source file names 2018-11-01 10:05:12 +01:00
Marc Vertes
1592679f36 Rework function calls, in progress 2018-10-31 19:35:26 +01:00
Marc Vertes
8670c41b9e fix call of method 2018-10-26 13:52:25 +02:00
Marc Vertes
12ad6c0be0 improve boostraping execution 2018-10-19 17:31:20 +02:00
Marc Vertes
e9388ba97f Fix allocation of global frame values 2018-10-19 15:40:23 +02:00
Marc Vertes
a17227ade1 Fix argument passing and return values for simple function calls 2018-10-18 14:28:56 +02:00
Marc Vertes
b82c5edc85 Fix IsNil(), IsNotNil(), _make() and _cap() 2018-10-16 14:42:05 +02:00
Marc Vertes
2e4cf6151f builtin generators now update node directly 2018-10-15 17:44:50 +02:00
Marc Vertes
dbe2d3d3bf improve use of genValue() 2018-10-05 15:21:02 +02:00
Marc Vertes
e1221600fd WIP handle runtime values as reflect.Value instead of interface{} 2018-10-04 11:46:07 +02:00
Marc Vertes
773aead09d Call closure generation after all CFGs are processed 2018-10-02 11:29:01 +02:00
Marc Vertes
e8685fffa2 WIP accelerate execution of builtins 2018-09-28 14:53:30 +02:00
Marc Vertes
335373164f get rid of sleep() 2018-09-27 14:00:41 +02:00