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
2019-01-25 12:25:57 +01:00
2019-01-30 22:00:02 +01:00
2019-01-07 11:34:04 +01:00
2018-03-20 14:53:37 +01:00
2019-01-22 18:12:08 +01:00
2019-02-17 01:50:34 +01:00

Go interpreter

Build Status

A Go interpreter in go

Tests

Tests are simple standalone go programs to be run by gi executable.

Scripts are converted to go test examples for execution by go test as well. To create a new test, simply add a new .gi file, specifying expected output at end of program in a // Output: comment block like in the following example:

package main

func main() {
	println("Hello")
}

// Output:
// Hello

Then in _test/, run make to re-generate interp/eval_test.go

When developing/debugging, I'm running gi on a single script, using -a and -c options to display AST and CFG graphs, and instrumenting code with temporary println statements to diagnose problems.

Description
Yaegi is Another Elegant Go Interpreter
Readme Apache-2.0 38 MiB
Languages
Go 98.4%
Shell 1.2%
GAP 0.2%
Makefile 0.2%