Commit Graph

27 Commits

Author SHA1 Message Date
Marc Vertes
24b5375636 interp: fix memory handling of global values
In some cases, the global character of a value was lost, leading to
undefined behaviour. Now a node level field of -1 means that the value
is global, and that it should be accessed from the root data frame.

Fixes #993.
2021-01-05 17:28:03 +01:00
Marc Vertes
d494f9e420 interp: support calling goto from sub-scope
As opposed to other symbols, goto labels must be searched in included
scopes, not upper ones. Implement scope.lookdown to perform this,
to allow calls to goto to be embedded in included scopes where label
is defined.

Fixes #953.
2020-11-19 12:48:03 +01:00
Marc Vertes
38a7331bf9 interp: fix type check on function signature
Perform function declaration type check from the upper level scope (the scope where the
function is declared), to avoid possible collisions of local variables with package names.

Fixes #957.
2020-11-13 18:02:04 +01:00
Nicholas Wiersma
9c4d3d1e5a chore: updated linter 2020-07-30 11:18:04 +02:00
Marc Vertes
39430c34bb fix: untyped constant converson to default type (#729)
* fix: untyped constant cconverson to default type

In definition assign expression, the source type is propagated to
the assigned value. If the source is an untyped constant, the
destination type must be set to the default type of the constant
definition. A fixType function is provided to perform this.

In addition, the type conversion and check of constants is
refactored for simplifications.

Fixes #727.

* test: fix _test/const14.go
2020-07-01 14:39:47 +02:00
Julien Levesy
c11d361953 Handle Receive and Send channels 2020-06-23 09:04:04 +02:00
Ludovic Fernandez
a6c24a0d13 chore: update linter. (#706)
* chore: update linter.

* chore: remove not needed travis env var.
2020-06-22 12:55:42 +02:00
mpl
7323d97023 interp: global scope redeclaration detection 2020-06-18 15:08:04 +02:00
Julien Levesy
6486909921 fix: range over channels returned by binary calls 2020-06-18 14:22:03 +02:00
Nicholas Wiersma
2de0c80d38 fix: handle range on chan function return 2020-06-03 16:30:05 +02:00
Marc Vertes
7070367d21 fix: handle constant declarations inside function scopes 2020-05-03 18:56:04 +02:00
Marc Vertes
e434892b9a fix: import different source packages with same base name 2020-02-03 17:22:04 +01:00
Marc Vertes
5381ee65d1 fix: continue statement was not applied correctly 2020-01-10 17:50:05 +01:00
Dan Kortschak
714253c1e6 interp: add eval cancelation by semaphore 2019-10-29 16:18:04 +01:00
Marc Vertes
9e664ee8dd fix: global variable init from selector expression 2019-09-16 14:30:05 +02:00
Marc Vertes
b0937618b0 fix: improve handling of out of order declarations (#344) 2019-09-05 11:37:34 +02: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
122506cc79 Fix: handle recursive type definition (#239) 2019-07-09 00:08:12 +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
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
8910769b77 feat: functional options to New() (#149) 2019-04-05 21:36:48 +02:00
Marc Vertes
47faed9853 refactor: package is a symbol kind (#142) 2019-03-22 10:44:06 +01:00
Marc Vertes
fa5b30d568 feat: add support for labeled statements (#123) 2019-03-20 10:04:00 +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
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