7
7
8
8
"github.com/ncw/gpython/compile"
9
9
"github.com/ncw/gpython/py"
10
- "github.com/ncw/gpython/vm"
11
10
)
12
11
13
12
const builtin_doc = `Built-in functions, exceptions, and other objects.
@@ -30,8 +29,8 @@ func init() {
30
29
// py.MustNewMethod("delattr", builtin_delattr, 0, delattr_doc),
31
30
// py.MustNewMethod("dir", builtin_dir, 0, dir_doc),
32
31
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 ),
35
34
// py.MustNewMethod("format", builtin_format, 0, format_doc),
36
35
py .MustNewMethod ("getattr" , builtin_getattr , 0 , getattr_doc ),
37
36
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
323
322
}
324
323
// fmt.Printf("Calling %v with %v and %v\n", fn.Name, fn.Globals, ns)
325
324
// 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 )
327
326
if err != nil {
328
327
return nil , err
329
328
}
@@ -599,6 +598,26 @@ func builtin_divmod(self py.Object, args py.Tuple) (py.Object, error) {
599
598
return py.Tuple {q , r }, nil
600
599
}
601
600
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
+
602
621
const len_doc = `len(object) -> integer
603
622
604
623
Return the number of items of a sequence or mapping.`
0 commit comments