Commit 152a00a4 authored by Etienne Renault's avatar Etienne Renault
Browse files

Blackbox and global variables are not supported.

If a Blackbox (BB) function modifies variable that is also used inside
of a non-blackbox function the following problem occurs: the variable
cannot be neither in the blackbox package neither in the normal

We should try to resolve this problem by :
   (1) analysis wether variables are exclusively used by BB-fun
   (2) pass setter as additionnal argument to BB-functions

Still for now it is preferable to forbbids BB and globals.

* main.go, transform/checktype.go: Here.
parent 50468710
......@@ -72,7 +72,7 @@ func compileTo(path string, src []byte, file *os.File,
// Apply all transformations.
meta := transform.NewMeta(fset, info)
res := transform.Apply(f, meta, &transform.TypeChecker{})
res := transform.Apply(f, meta, &transform.TypeChecker{Blackbox: (*ignorefunc != "")})
if *ignorefunc != "" || len(goroutines) != 0 {
newsrc, blackbox := tools.Isolate(flag.Args()[0], *output, toIgnore)
......@@ -22,6 +22,7 @@ The TypeChecker triggers errors for uses of :
type TypeChecker struct {
currentFunction *ast.Object
Blackbox bool
// Pre traversal check if there is use of variable other than integers.
......@@ -85,6 +86,9 @@ func (t *TypeChecker) Pre(meta *Meta, v *Visitor) bool {
case *ast.SwitchStmt:
panic("Switch are not supported.")
case *ast.ValueSpec:
if t.Blackbox && t.currentFunction == nil {
panic("No support for Blackbox and global variables.")
for i := 0; i < len(node.Values); i++ {
switch value := node.Values[i].(type) {
case *ast.BasicLit:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment