-
Notifications
You must be signed in to change notification settings - Fork 227
Open
Description
I'm implementing a stardoc-like program (extracting docs from bzl files). In such a program, we don't really need to know the concrete types of foreign symbols. For now, the Thread.Load returns a StringDict, which means I need to resolve the loading bzl path, and exec that file just to make the Exec work.
I'm proposing that let Thread.Load returns a StringDict-like interface with Get and Keys methods instead. Which will allow users to mock a load.
The Thread.Load is used as follow:
starlark-go/starlark/interp.go
Lines 566 to 587 in 4b1e35f
| dict, err2 := thread.Load(thread, module) | |
| thread.beginProfSpan() | |
| if err2 != nil { | |
| err = wrappedError{ | |
| msg: fmt.Sprintf("cannot load %s: %v", module, err2), | |
| cause: err2, | |
| } | |
| break loop | |
| } | |
| for i := 0; i < n; i++ { | |
| from := string(stack[sp-1-i].(String)) | |
| v, ok := dict[from] | |
| if !ok { | |
| err = fmt.Errorf("load: name %s not found in module %s", from, module) | |
| if n := spell.Nearest(from, dict.Keys()); n != "" { | |
| err = fmt.Errorf("%s (did you mean %s?)", err, n) | |
| } | |
| break loop | |
| } | |
| stack[sp-1-i] = v | |
| } |
Metadata
Metadata
Assignees
Labels
No labels