* fix: constant definition loop on out of order vars
* fix: do not wire global varDecl
* fix: wire and execute global vars
* chore: add tests
* fix: refactor and lint
* fix: finish support of type assertions which was incomplete
TypeAssert was optimistically returning ok without verifying that
value could be converted to the required interface (in case of
type assert of an interface type), or not checking the type in
all conditions. There is now a working implements method for itype.
Fixes#640.
* style: appease lint
* fix: remove useless code block
* doc: improve comments
* avoid test conflict
Catch illegal combinations for all binary operators.
Memoize type conversion to reflect.type.
Add some unit tests for arithmetic and assign operations.
* 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.
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.
Rename the package scope from internal package name to alias name.
Detect different packages in the same directory (forbidden by spec).
Update example to test named import.
* 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