Commit Graph

124 Commits

Author SHA1 Message Date
Nicholas Wiersma
9c4d3d1e5a chore: updated linter 2020-07-30 11:18:04 +02:00
Marc Vertes
6f4643ff19 fix: compute numeral constant on typed objects 2020-05-19 14:38:03 +02:00
Marc Vertes
d055747bef chore: run _test/*.go as tests, not examples (#134) 2019-03-28 17:38:51 +01:00
Marc Vertes
3616fb1b82 fix: handle method as function expression (#132) 2019-03-22 10:17:33 +01:00
Fernandez Ludovic
12b608b625 chore: rename to yaegi. 2019-03-20 10:15:35 +01:00
Marc Vertes
fa5b30d568 feat: add support for labeled statements (#123) 2019-03-20 10:04:00 +01:00
Marc Vertes
53cdd0f2b0 fix: support aliased types for composite literal expressions (#129) 2019-03-19 14:57:04 +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
6a546062c1 fix: handle status in chan received when used in select (#122)
Also do not skip related tests
2019-03-17 17:36:58 +01:00
Marc Vertes
c773ad81d0 fix: return values of binary calls were not passed in nested calls (#121) 2019-03-17 15:51:28 +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
2ef6e459e3 feat: support func fields in literal struct (#103)
* test: make select2 deterministic
2019-02-22 15:44:36 +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
Marc Vertes
a99fb98f84 fix: append() was not returning a type (#84)
append() now returns the underlying array type.
Method lookup was skipped for selector expression on arrays.
Pointer expression was incorrectly parsed as a dereference instead of
type expression.
2019-02-06 14:50:37 +01:00
Marc Vertes
17fa77c693 fix: implement handling of interface types (#80)
Methods are now resolved correctly on interface objects.
2019-02-06 10:21:25 +01:00
Marc Vertes
e347d35c24 fix: correct handling of sparse values in struct of implicit types (#73) 2019-02-01 14:51:17 +01:00
Marc Vertes
1245e29a11 fix: handle implicit array types in composite litteral expressions (#66)
At CFG, in pre-order processing, determine the correct type of CompositeLitExpr from its first child (if it's a type) or from the ancestor node.
Make sure The type is propagated to children so the algorithm works recursively.

Fix also the isType() method to handle case of imported types,
either from source or binary packages.
2019-02-01 10:44:18 +01:00
Marc Vertes
83bc9c5f05 fix: correct wireChild() in case of interleaving of var and func declarations (#65) 2019-01-29 20:51:25 +01:00
Marc Vertes
49c8c905d2 fix: ensure type computation in ValueSpec statement (#64)
Use nodeType in global var declaration to infer the type,
otherwise it may not be set properly, and failure will occur at use of variable.
2019-01-29 13:39:34 +01:00
Ludovic Fernandez
2059d58b0e test: add more tests. (#63) 2019-01-29 13:21:47 +01:00
Marc Vertes
0ab97e661f fix: correct type setting for rune characters (#61) 2019-01-28 16:33:48 +01:00
Marc Vertes
63732d4326 fix: set type correctly for variable declaration with assignment (#59)
Do not ignore type node when used in a variable declaration with assign.
The source node in a assign node can be the 2nd or the 3rd (the 2nd being the type).
2019-01-28 16:00:15 +01:00
Ludovic Fernandez
73afc090bb refactor: enhance consistency tests. (#53)
* test: remove limit.

* test: skip btln.go

* test: adds tests on errors.

* feat: add missing output results.

* refactor: time's tests.
2019-01-28 15:19:52 +01:00
Ludovic Fernandez
e78753ffd8 test: add consistency tests. (#46)
* test: add consistency tests.

* skip: cli1 due to bug.

* refactor: rename test.

* refactor: map and for.
2019-01-25 16:41:41 +01:00
Marc Vertes
5c79a97543 feat: add support for comparison of multiple types (#42)
The code for comparison operators is now generated by genop.
The support for multiple type has been added.
Missing operators <= and >= are now implemented.
2019-01-24 19:13:30 +01:00
Ludovic Fernandez
2fe2e8e754 refactor: use test package name. (#38)
* refactor: use test packake name.

* refactor: target and panic.
2019-01-24 11:40:33 +01:00
Ludovic Fernandez
4600a918f1 fix: missing tests. (#37) 2019-01-24 06:15:53 +01:00
Ludovic Fernandez
c09c1869a7 refactor: remove obsolete tests for plugins. (#36) 2019-01-24 06:14:31 +01:00
Marc Vertes
fe8c5191cd fix: implement missing defer of binary method (#33)
If the function to defer is a method of a binary object, the method
function must be resolved during defer. All other cases are already
handled.
2019-01-23 14:30:24 +01:00
Ludovic Fernandez
ed93935c93 refactor: custom GOPATH. (#32) 2019-01-23 13:04:19 +01:00
Ludovic Fernandez
3c674c2cc4 fix: remove hardcoded port. (#27)
* fix: remove hardcoded port.

* fix: genop.
2019-01-22 15:31:28 +01:00
Marc Vertes
08f4aabdc0 feat: generate operator functions (#25)
Add `cmd/genop` program to generate operator functions in `interp/op.go`.

For each operator, determine its type, handle argument types conversion if necessary.

Arithmetic operators are added for now. Assign and comparison operators coming in a next commit.
2019-01-22 14:10:28 +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
f4490ff851 Fix: multi-assign expression panic (#15)
* Fix: multi-assign expression panic

The following corrections are done:
* interp/ast.go: in case of ast.ValueSpec node, fix the decision between
multi-assign or single assign
* interp/cfg.go: in multi-assign parse, skip type symbol if it is
present
2019-01-17 20:59:45 +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
42e891da02 Fix DO NOT EDIT comment on generated files 2018-12-19 11:41:48 +01:00
Marc Vertes
b0ef0a00db Interpreter now exports itself, so scripts can do Eval() too 2018-12-11 10:29:43 -08:00
Marc Vertes
befbe23695 Load binary dependencies with Import() 2018-12-06 16:16:54 +01:00
Marc Vertes
4eab01911e Fix range for slices of binary objects 2018-12-02 17:46:27 +01:00
Marc Vertes
487e24e829 Type assertion: add support for 2nd return value 2018-12-01 17:56:55 +01:00
Marc Vertes
c75807dec9 Fix type assertions for runtime objects. Work in progress.
Function typeAssert() now returns the concrete value of interface{}
object defined in the runtime.

What is missing is actual type checking against provided type, and
support for the variant returning 2 values, the concrete value and
boolean status.
2018-12-01 14:49:56 +01:00