Commit Graph

383 Commits

Author SHA1 Message Date
Marc Vertes
9abaeeb729 fix: binary method lookup works for struct field pointer receiver 2019-09-19 14:02:06 +02:00
Marc Vertes
ec1ee5f5b6 fix: support array operations on array pointers 2019-09-18 23:32:04 +02:00
Marc Vertes
f7810d9761 fix: init global var from builtin 2019-09-16 16:50:06 +02:00
Marc Vertes
82dd3f2953 fix: implement variadic using a type category to avoid corruption 2019-09-10 13:12:03 +02:00
Marc Vertes
b0937618b0 fix: improve handling of out of order declarations (#344) 2019-09-05 11:37:34 +02:00
Marc Vertes
d23a7e1d8b fix: assign a function value to a pre-declared variable 2019-08-29 05:16:04 -07:00
Marc Vertes
71fd938040 fix: improve handling of global declarations, possibly out of order (#336) 2019-08-28 16:59:46 +02:00
Marc Vertes
4c877cc348 fix: correct assign to binary interface value (#291) 2019-07-26 10:59:16 -07:00
Marc Vertes
122506cc79 Fix: handle recursive type definition (#239) 2019-07-09 00:08:12 +02:00
Ludovic Fernandez
470960aa93 chore: Move commands (#235)
* chore: move genop to internal.

* chore: move yaegi command.
2019-07-03 17:57:46 +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
84ab137ab6 fix: correct assignment of result of map lookup and check expression (#227) 2019-06-17 14:51:34 +02:00
Marc Vertes
25ddbbad03 fix: correct handling of function in struct field (#226) 2019-06-17 14:40:55 +02:00
Marc Vertes
cd12274ec6 fix: index expression on binary map (#223) 2019-06-13 17:35:52 +02:00
Ludovic Fernandez
146cac6a0f chore: enhance logs when panic. (#221) 2019-06-13 13:34:13 +02:00
Marc Vertes
f5353e55c8 fix: correct handling of methods on binary interface types (#218) 2019-06-13 12:49:26 +02:00
Marc Vertes
67ba2888d7 fix: lookup embedded binary fields in struct (#207) 2019-06-11 09:17:51 +02:00
Marc Vertes
264782408a fix: add method lookup on pointer to binary type (#206) 2019-06-05 14:31:40 +02:00
Marc Vertes
025e4f924a fix: correct handling of equality tests (#205) 2019-06-05 09:50:44 +02:00
Marc Vertes
455a37e678 fix: correct handling of constant expressions in type declarations (#204) 2019-06-04 16:50:32 +02:00
Marc Vertes
ad009959af fix: correct new() when using in indirect assign (#202) 2019-05-31 19:49:40 +02:00
Marc Vertes
cc2d122cd3 fix: correct negate operator (#199) 2019-05-31 12:48:46 +02:00
Marc Vertes
873df6b445 fix: correct handling of logical expression involving parenthesis block (#194) 2019-05-29 15:51:41 +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
4d8e990ff3 fix: several bug fixes so bcrypt and blowfish work in yaegi (#182)
* convert type of nil value
* range staement with key and no value
* assign operators misbehave
* reset to zero in value spec statements
2019-05-07 14:01:55 +02:00
Marc Vertes
1eb950f9b9 fix: correct type conversion for unsigned array index (#179) 2019-05-01 19:12:52 +02:00
Marc Vertes
c6c7f8cea6 fix: automatic type conversion for untyped arg of append (#177) 2019-05-01 16:49:57 +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
0bbdd37e55 fix: correct var creation from type convert (#172) 2019-04-25 10:56:55 +02:00
Marc Vertes
e8dfded66b fix: correct convert nil to type pointer (#166) 2019-04-23 11:04:47 +02:00
Marc Vertes
37f93f0392 fix: correct embedded method handling on hybrid struct (#162) 2019-04-19 18:30:04 +02:00
Marc Vertes
800ad0e557 fix: correct assign nil value to a variable (#164) 2019-04-19 18:15:02 +02:00
Marc Vertes
378252166b fix: correct assign from function call (#155)
The following changes should fix real and potential  problems
regarding how variables are set from function return values.

In assign from call expressions, Values in caller frame are now
directly assigned from function calls (call(), binCall() or builtins).
The assignement is performed with reflect Set methods or variants,
instead of "=" operator, to enforce runtime type checks.

The assignX() and assignX2() builtins are now removed in favor of
above method.

The representation of nil for pointer on struct has been fixed.

The identification of channel is fixed in for-range channel expression.
2019-04-16 15:22:17 +02:00
Marc Vertes
68e25cf68e fix: wrong returned type in define from function call in global context (#148) 2019-04-02 16:05:39 +02:00
Marc Vertes
e766c272ed fix: handle append a string to a byte array (#133) 2019-03-22 10:27:02 +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
839987c4cf feat: add support for 'msg, ok := <-channel' expression (#117) 2019-03-16 17:50:23 +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
22a6d011f4 fix: handle method on interface type objects (#112)
Define a new Method action to detect method calls on interface types.
In this case the receiver is resolved from a dynamic type rather than a static one.

Handle method calls where receiver is a pointer.

In typeAssert, always return an interface value with the concrete type, to fix method lookup on interface objects.

Add relevant tests.
2019-03-04 18:51:48 +01:00
Marc Vertes
f60fe68471 feat: wrapper to allow interpreter values to satisfy Go interfaces (#107)
A Wrap represents the wrapper which allows objects created by the
interpreter to satify Go interfaces (despite limitations in reflect
which forbid dynamic method creation).

All the struct fields are functions, where the fied name corresponds
to the method name prefixed by "Do". The function signature must
be the same as the interface one.

A corresponding Wrap method Xyz which satisfies the interface must
exist and must invoke the DoXyz function.

To be usable, the interpreter should return a Wrap instance with
the relevant function fields filled. The application can then invoke
methods on it.  The method calls will be forwarded to the interpreter.

Only the Wrap type definition needs to be exported to the interpreter
(not the interfaces and methods definitions)

A complete working example test is provided, and necessary corrections
in binary struct fields as functions.
2019-02-26 14:31:59 +01:00
Marc Vertes
c8693ba672 fix: handle interspersed key-value expressions in literal array (#105) 2019-02-25 15:28:34 +01:00