summaryrefslogtreecommitdiffstats
path: root/Objects/funcobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1990-11-18 17:44:06 (GMT)
committerGuido van Rossum <guido@python.org>1990-11-18 17:44:06 (GMT)
commit846e431372fecea5b5c92414d1a0e2cfccd7efc3 (patch)
tree1da794febc2695123f41854040fb84bd71edff75 /Objects/funcobject.c
parent5b3138bec047cfe9d284516be3958680f4fcf4ab (diff)
downloadcpython-846e431372fecea5b5c92414d1a0e2cfccd7efc3.zip
cpython-846e431372fecea5b5c92414d1a0e2cfccd7efc3.tar.gz
cpython-846e431372fecea5b5c92414d1a0e2cfccd7efc3.tar.bz2
Function objects no longer contain a parse tree node, but intermediate
code.
Diffstat (limited to 'Objects/funcobject.c')
-rw-r--r--Objects/funcobject.c51
1 files changed, 13 insertions, 38 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 1adc3bc..8850872 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -4,42 +4,39 @@
#include "PROTO.h"
#include "object.h"
-#include "node.h"
-#include "stringobject.h"
#include "funcobject.h"
#include "objimpl.h"
-#include "token.h"
typedef struct {
OB_HEAD
- node *func_node;
+ object *func_code;
object *func_globals;
} funcobject;
object *
-newfuncobject(n, globals)
- node *n;
+newfuncobject(code, globals)
+ object *code;
object *globals;
{
funcobject *op = NEWOBJ(funcobject, &Functype);
if (op != NULL) {
- op->func_node = n;
- if (globals != NULL)
- INCREF(globals);
+ INCREF(code);
+ op->func_code = code;
+ INCREF(globals);
op->func_globals = globals;
}
return (object *)op;
}
-node *
-getfuncnode(op)
+object *
+getfunccode(op)
object *op;
{
if (!is_funcobject(op)) {
err_badcall();
return NULL;
}
- return ((funcobject *) op) -> func_node;
+ return ((funcobject *) op) -> func_code;
}
object *
@@ -59,31 +56,9 @@ static void
funcdealloc(op)
funcobject *op;
{
- /* XXX free node? */
+ DECREF(op->func_code);
DECREF(op->func_globals);
- free((char *)op);
-}
-
-static void
-funcprint(op, fp, flags)
- funcobject *op;
- FILE *fp;
- int flags;
-{
- node *n = op->func_node;
- n = CHILD(n, 1);
- fprintf(fp, "<user function %s>", STR(n));
-}
-
-static object *
-funcrepr(op)
- funcobject *op;
-{
- char buf[100];
- node *n = op->func_node;
- n = CHILD(n, 1);
- sprintf(buf, "<user function %.80s>", STR(n));
- return newstringobject(buf);
+ DEL(op);
}
typeobject Functype = {
@@ -93,9 +68,9 @@ typeobject Functype = {
sizeof(funcobject),
0,
funcdealloc, /*tp_dealloc*/
- funcprint, /*tp_print*/
+ 0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
- funcrepr, /*tp_repr*/
+ 0, /*tp_repr*/
};