77
88 "github.com/ncw/gpython/compile"
99 "github.com/ncw/gpython/py"
10- "github.com/ncw/gpython/vm"
1110)
1211
1312const builtin_doc = `Built-in functions, exceptions, and other objects.
@@ -30,8 +29,8 @@ func init() {
3029 // py.MustNewMethod("delattr", builtin_delattr, 0, delattr_doc),
3130 // py.MustNewMethod("dir", builtin_dir, 0, dir_doc),
3231 py .MustNewMethod ("divmod" , builtin_divmod , 0 , divmod_doc ),
33- // py.MustNewMethod("eval", builtin_eval , 0, eval_doc),
34- // py.MustNewMethod("exec", builtin_exec , 0, exec_doc),
32+ py .MustNewMethod ("eval" , py . InternalMethodEval , 0 , eval_doc ),
33+ py .MustNewMethod ("exec" , py . InternalMethodExec , 0 , exec_doc ),
3534 // py.MustNewMethod("format", builtin_format, 0, format_doc),
3635 py .MustNewMethod ("getattr" , builtin_getattr , 0 , getattr_doc ),
3736 py .MustNewMethod ("globals" , py .InternalMethodGlobals , 0 , globals_doc ),
@@ -323,7 +322,7 @@ func builtin___build_class__(self py.Object, args py.Tuple, kwargs py.StringDict
323322 }
324323 // fmt.Printf("Calling %v with %v and %v\n", fn.Name, fn.Globals, ns)
325324 // fmt.Printf("Code = %#v\n", fn.Code)
326- cell , err = vm . Run (fn .Globals , ns , fn .Code , fn .Closure )
325+ cell , err = py . VmRun (fn .Globals , ns , fn .Code , fn .Closure )
327326 if err != nil {
328327 return nil , err
329328 }
@@ -599,6 +598,26 @@ func builtin_divmod(self py.Object, args py.Tuple) (py.Object, error) {
599598 return py.Tuple {q , r }, nil
600599}
601600
601+ const eval_doc = `"eval(source[, globals[, locals]]) -> value
602+
603+ Evaluate the source in the context of globals and locals.
604+ The source may be a string representing a Python expression
605+ or a code object as returned by compile().
606+ The globals must be a dictionary and locals can be any mapping,
607+ defaulting to the current globals and locals.
608+ If only globals is given, locals defaults to it.`
609+
610+ // For code see vm/builtin.go
611+
612+ const exec_doc = `exec(object[, globals[, locals]])
613+
614+ Read and execute code from an object, which can be a string or a code
615+ object.
616+ The globals and locals are dictionaries, defaulting to the current
617+ globals and locals. If only globals is given, locals defaults to it.`
618+
619+ // For code see vm/builtin.go
620+
602621const len_doc = `len(object) -> integer
603622
604623Return the number of items of a sequence or mapping.`
0 commit comments