Commit 18741a0c authored by Kevin Modzelewski's avatar Kevin Modzelewski

Fixes to get self-hosting working

parent 13800032
# TODO: we will have to figure out a better way of generating this file # TODO: we will have to figure out a better way of generating this file
build_time_vars = {} build_time_vars = {
"CC": "gcc -pthread",
"CXX": "g++ -pthread",
"OPT": "-DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes",
"CFLAGS": "-fno-strict-aliasing -g -O3 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes",
"CCSHARED": "-fPIC",
"LDSHARED": "gcc -pthread -shared",
"SO": ".pyston.so",
"AR": "ar",
"ARFLAGS": "rc",
}
# This file is originally from CPython 2.7, with modifications for Pyston
# We should probably create a pyston-specific version instead of modifying the
# CPython one.
"""Provide access to Python's configuration information. The specific """Provide access to Python's configuration information. The specific
configuration variables available depend heavily on the platform and configuration variables available depend heavily on the platform and
configuration. The values may be retrieved using configuration. The values may be retrieved using
...@@ -64,6 +68,9 @@ def get_python_version(): ...@@ -64,6 +68,9 @@ def get_python_version():
def get_python_inc(plat_specific=0, prefix=None): def get_python_inc(plat_specific=0, prefix=None):
# Pyston change: this is the way we layout things internally:
return os.path.join(os.path.dirname(sys.executable), "include")
"""Return the directory containing installed Python header files. """Return the directory containing installed Python header files.
If 'plat_specific' is false (the default), this is the path to the If 'plat_specific' is false (the default), this is the path to the
......
...@@ -852,6 +852,20 @@ public: ...@@ -852,6 +852,20 @@ public:
return rtnval; return rtnval;
} }
static void gcHandler(GCVisitor* v, Box* _b) {
assert(isSubclass(_b->cls, EnvironmentError));
boxGCHandler(v, _b);
BoxedEnvironmentError* ee = static_cast<BoxedEnvironmentError*>(_b);
if (ee->myerrno)
v->visit(ee->myerrno);
if (ee->strerror)
v->visit(ee->strerror);
if (ee->filename)
v->visit(ee->filename);
}
}; };
void setupBuiltins() { void setupBuiltins() {
...@@ -909,6 +923,7 @@ void setupBuiltins() { ...@@ -909,6 +923,7 @@ void setupBuiltins() {
NotImplementedError = makeBuiltinException(RuntimeError, "NotImplementedError"); NotImplementedError = makeBuiltinException(RuntimeError, "NotImplementedError");
PendingDeprecationWarning = makeBuiltinException(Warning, "PendingDeprecationWarning"); PendingDeprecationWarning = makeBuiltinException(Warning, "PendingDeprecationWarning");
EnvironmentError->gc_visit = BoxedEnvironmentError::gcHandler;
EnvironmentError->giveAttr( EnvironmentError->giveAttr(
"__init__", "__init__",
new BoxedFunction(boxRTFunction((void*)BoxedEnvironmentError::__init__, NONE, 4, 1, false, false), { NULL })); new BoxedFunction(boxRTFunction((void*)BoxedEnvironmentError::__init__, NONE, 4, 1, false, false), { NULL }));
......
...@@ -686,6 +686,18 @@ public: ...@@ -686,6 +686,18 @@ public:
return None; return None;
} }
static Box* get(Box* _self, Box* _key, Box* def) {
RELEASE_ASSERT(_self->cls == attrwrapper_cls, "");
AttrWrapper* self = static_cast<AttrWrapper*>(_self);
RELEASE_ASSERT(_key->cls == str_cls, "");
BoxedString* key = static_cast<BoxedString*>(_key);
Box* r = self->b->getattr(key->s);
if (!r)
return def;
return r;
}
static Box* getitem(Box* _self, Box* _key) { static Box* getitem(Box* _self, Box* _key) {
RELEASE_ASSERT(_self->cls == attrwrapper_cls, ""); RELEASE_ASSERT(_self->cls == attrwrapper_cls, "");
AttrWrapper* self = static_cast<AttrWrapper*>(_self); AttrWrapper* self = static_cast<AttrWrapper*>(_self);
...@@ -951,6 +963,8 @@ void setupRuntime() { ...@@ -951,6 +963,8 @@ void setupRuntime() {
attrwrapper_cls->giveAttr("__name__", boxStrConstant("attrwrapper")); attrwrapper_cls->giveAttr("__name__", boxStrConstant("attrwrapper"));
attrwrapper_cls->giveAttr("__setitem__", new BoxedFunction(boxRTFunction((void*)AttrWrapper::setitem, UNKNOWN, 3))); attrwrapper_cls->giveAttr("__setitem__", new BoxedFunction(boxRTFunction((void*)AttrWrapper::setitem, UNKNOWN, 3)));
attrwrapper_cls->giveAttr("__getitem__", new BoxedFunction(boxRTFunction((void*)AttrWrapper::getitem, UNKNOWN, 2))); attrwrapper_cls->giveAttr("__getitem__", new BoxedFunction(boxRTFunction((void*)AttrWrapper::getitem, UNKNOWN, 2)));
attrwrapper_cls->giveAttr(
"get", new BoxedFunction(boxRTFunction((void*)AttrWrapper::get, UNKNOWN, 3, 1, false, false), { None }));
attrwrapper_cls->giveAttr("__str__", new BoxedFunction(boxRTFunction((void*)AttrWrapper::str, UNKNOWN, 1))); attrwrapper_cls->giveAttr("__str__", new BoxedFunction(boxRTFunction((void*)AttrWrapper::str, UNKNOWN, 1)));
attrwrapper_cls->giveAttr("__contains__", attrwrapper_cls->giveAttr("__contains__",
new BoxedFunction(boxRTFunction((void*)AttrWrapper::contains, UNKNOWN, 2))); new BoxedFunction(boxRTFunction((void*)AttrWrapper::contains, UNKNOWN, 2)));
......
...@@ -55,3 +55,6 @@ class C(object): ...@@ -55,3 +55,6 @@ class C(object):
def __init__(self): def __init__(self):
self.a = 1 self.a = 1
print vars(C()).items() print vars(C()).items()
print globals().get("not a real variable")
print globals().get("not a real variable", 1)
Markdown is supported
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