Commit 89ecda8a authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #144 from tjhance/operator

parents ca858cc1 00f9ab2d
......@@ -16,7 +16,6 @@
#define PYSTON_EXTINCLUDE_PYTHON_H
#include <assert.h>
#include <ctype.h> // it looks like this gets included via unicodeobject.h in CPython
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
......@@ -39,6 +38,7 @@
#include "pydebug.h"
#include "unicodeobject.h"
#include "intobject.h"
#include "boolobject.h"
#include "longobject.h"
......
......@@ -32,5 +32,7 @@
#define HAVE_ASINH 1
#define HAVE_ATANH 1
#define HAVE_EXPM1 1
#define Py_USING_UNICODE 1
#define Py_UNICODE_SIZE 4
#endif /*Py_PYCONFIG_H*/
This diff is collapsed.
......@@ -268,7 +268,7 @@ SRCS := $(MAIN_SRCS) $(STDLIB_SRCS)
STDLIB_OBJS := stdlib.bc.o stdlib.stripped.bc.o
STDLIB_RELEASE_OBJS := stdlib.release.bc.o
STDMODULE_SRCS := errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _sre.c $(EXTRA_STDMODULE_SRCS)
STDMODULE_SRCS := errnomodule.c shamodule.c sha256module.c sha512module.c _math.c mathmodule.c md5.c md5module.c _sre.c operator.c $(EXTRA_STDMODULE_SRCS)
FROM_CPYTHON_SRCS := $(addprefix ../lib_python/2.7_Modules/,$(STDMODULE_SRCS)) $(wildcard capi/*.c)
# The stdlib objects have slightly longer dependency chains,
......
......@@ -419,7 +419,7 @@ extern "C" {
BoxedClass* BaseException, *Exception, *StandardError, *AssertionError, *AttributeError, *GeneratorExit, *TypeError,
*NameError, *KeyError, *IndexError, *IOError, *OSError, *ZeroDivisionError, *ValueError, *UnboundLocalError,
*RuntimeError, *ImportError, *StopIteration, *Warning, *SyntaxError, *OverflowError, *DeprecationWarning,
*MemoryError, *LookupError, *EnvironmentError, *ArithmeticError;
*MemoryError, *LookupError, *EnvironmentError, *ArithmeticError, *BufferError;
}
Box* exceptionNew1(BoxedClass* cls) {
......@@ -607,6 +607,7 @@ void setupBuiltins() {
DeprecationWarning = makeBuiltinException(Warning, "DeprecationWarning");
/*BytesWarning =*/makeBuiltinException(Warning, "BytesWarning");
MemoryError = makeBuiltinException(StandardError, "MemoryError");
BufferError = makeBuiltinException(StandardError, "BufferError");
repr_obj = new BoxedFunction(boxRTFunction((void*)repr, UNKNOWN, 1));
builtins_module->giveAttr("repr", repr_obj);
......@@ -700,6 +701,7 @@ void setupBuiltins() {
builtins_module->giveAttr("object", object_cls);
builtins_module->giveAttr("str", str_cls);
builtins_module->giveAttr("basestring", basestring_cls);
builtins_module->giveAttr("unicode", unicode_cls);
builtins_module->giveAttr("int", int_cls);
builtins_module->giveAttr("long", long_cls);
builtins_module->giveAttr("float", float_cls);
......
......@@ -72,8 +72,15 @@ MAKE_CHECK(Long, long_cls)
MAKE_CHECK(List, list_cls)
MAKE_CHECK(Tuple, tuple_cls)
MAKE_CHECK(Dict, dict_cls)
#ifdef Py_USING_UNICODE
MAKE_CHECK(Unicode, unicode_cls)
#endif
#undef MAKE_CHECK
extern "C" { int Py_Py3kWarningFlag; }
extern "C" PyObject* PyDict_New() {
return new BoxedDict();
}
......@@ -287,6 +294,25 @@ extern "C" void PyObject_Free(void* p) {
ASSERT(0, "I think this is good enough but I'm not sure; should test");
}
extern "C" PyObject* _PyObject_GC_Malloc(size_t) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* _PyObject_GC_New(PyTypeObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyVarObject* _PyObject_GC_NewVar(PyTypeObject*, Py_ssize_t) {
Py_FatalError("unimplemented");
}
extern "C" void PyObject_GC_Track(void*) {
Py_FatalError("unimplemented");
}
extern "C" void PyObject_GC_UnTrack(void*) {
Py_FatalError("unimplemented");
}
extern "C" void PyObject_GC_Del(void*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyObject_CallObject(PyObject* obj, PyObject* args) {
RELEASE_ASSERT(args, ""); // actually it looks like this is allowed to be NULL
RELEASE_ASSERT(args->cls == tuple_cls, "");
......@@ -335,6 +361,14 @@ extern "C" PyObject* PyObject_GetIter(PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyObject_GetAttr(PyObject* o, PyObject* attr_name) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyObject_GenericGetAttr(PyObject* o, PyObject* name) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyObject_GetItem(PyObject* o, PyObject* key) {
try {
return getitem(o, key);
......@@ -343,10 +377,65 @@ extern "C" PyObject* PyObject_GetItem(PyObject* o, PyObject* key) {
}
}
extern "C" int PyObject_SetItem(PyObject* o, PyObject* key, PyObject* v) {
Py_FatalError("unimplemented");
}
extern "C" int PyObject_DelItem(PyObject* o, PyObject* key) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyObject_RichCompare(PyObject* o1, PyObject* o2, int opid) {
Py_FatalError("unimplemented");
}
extern "C" int PyObject_IsTrue(PyObject* o) {
Py_FatalError("unimplemented");
}
extern "C" int PyObject_Not(PyObject* o) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyObject_Call(PyObject* callable_object, PyObject* args, PyObject* kw) {
Py_FatalError("unimplemented");
}
extern "C" void PyObject_ClearWeakRefs(PyObject* object) {
Py_FatalError("unimplemented");
}
extern "C" int PyObject_GetBuffer(PyObject* exporter, Py_buffer* view, int flags) {
Py_FatalError("unimplemented");
}
extern "C" int _PyArg_NoKeywords(const char* funcname, PyObject* kw) {
Py_FatalError("unimplemented");
}
extern "C" int PySequence_Check(PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" Py_ssize_t PySequence_Size(PyObject* o) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PySequence_Concat(PyObject* o1, PyObject* o2) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PySequence_Repeat(PyObject* o, Py_ssize_t count) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PySequence_InPlaceConcat(PyObject* o1, PyObject* o2) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PySequence_InPlaceRepeat(PyObject* o, Py_ssize_t count) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PySequence_GetItem(PyObject* o, Py_ssize_t i) {
try {
......@@ -366,6 +455,46 @@ extern "C" PyObject* PySequence_GetSlice(PyObject* o, Py_ssize_t i1, Py_ssize_t
}
}
extern "C" int PySequence_SetItem(PyObject* o, Py_ssize_t i, PyObject* v) {
Py_FatalError("unimplemented");
}
extern "C" int PySequence_DelItem(PyObject* o, Py_ssize_t i) {
Py_FatalError("unimplemented");
}
extern "C" int PySequence_SetSlice(PyObject* o, Py_ssize_t i1, Py_ssize_t i2, PyObject* v) {
Py_FatalError("unimplemented");
}
extern "C" int PySequence_DelSlice(PyObject* o, Py_ssize_t i1, Py_ssize_t i2) {
Py_FatalError("unimplemented");
}
extern "C" Py_ssize_t PySequence_Count(PyObject* o, PyObject* value) {
Py_FatalError("unimplemented");
}
extern "C" int PySequence_Contains(PyObject* o, PyObject* value) {
Py_FatalError("unimplemented");
}
extern "C" Py_ssize_t PySequence_Index(PyObject* o, PyObject* value) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PySequence_List(PyObject* o) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PySequence_Tuple(PyObject* o) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PySequence_Fast(PyObject* o, const char* m) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyIter_Next(PyObject*) {
Py_FatalError("unimplemented");
}
......@@ -454,7 +583,15 @@ extern "C" void PyMem_Free(void* ptr) {
gc_compat_free(ptr);
}
extern "C" PyObject* PyNumber_Divide(PyObject*, PyObject*) {
extern "C" int PyNumber_Check(PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Add(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Subtract(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
......@@ -462,6 +599,150 @@ extern "C" PyObject* PyNumber_Multiply(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Divide(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_FloorDivide(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_TrueDivide(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Remainder(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Divmod(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Power(PyObject*, PyObject*, PyObject* o3) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Negative(PyObject* o) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Positive(PyObject* o) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Absolute(PyObject* o) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Invert(PyObject* o) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Lshift(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Rshift(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_And(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Xor(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Or(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_InPlaceAdd(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_InPlaceSubtract(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_InPlaceMultiply(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_InPlaceDivide(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_InPlaceFloorDivide(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_InPlaceTrueDivide(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_InPlaceRemainder(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_InPlacePower(PyObject*, PyObject*, PyObject* o3) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_InPlaceLshift(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_InPlaceRshift(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_InPlaceAnd(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_InPlaceXor(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_InPlaceOr(PyObject*, PyObject*) {
Py_FatalError("unimplemented");
}
extern "C" int PyNumber_Coerce(PyObject**, PyObject**) {
Py_FatalError("unimplemented");
}
extern "C" int PyNumber_CoerceEx(PyObject**, PyObject**) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Int(PyObject* o) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Long(PyObject* o) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Float(PyObject* o) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_Index(PyObject* o) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyNumber_ToBase(PyObject* n, int base) {
Py_FatalError("unimplemented");
}
extern "C" Py_ssize_t PyNumber_AsSsize_t(PyObject* o, PyObject* exc) {
Py_FatalError("unimplemented");
}
BoxedModule* importTestExtension() {
const char* pathname = "../test/test_extension/test.so";
void* handle = dlopen(pathname, RTLD_NOW);
......
......@@ -256,6 +256,30 @@ extern "C" Box* dictInit(BoxedDict* self, BoxedTuple* args, BoxedDict* kwargs) {
return None;
}
extern "C" int PyMapping_Check(PyObject* o) {
Py_FatalError("unimplemented");
}
extern "C" Py_ssize_t PyMapping_Size(PyObject* o) {
Py_FatalError("unimplemented");
}
extern "C" int PyMapping_HasKeyString(PyObject* o, char* key) {
Py_FatalError("unimplemented");
}
extern "C" int PyMapping_HasKey(PyObject* o, PyObject* key) {
Py_FatalError("unimplemented");
}
extern "C" PyObject* PyMapping_GetItemString(PyObject* o, char* key) {
Py_FatalError("unimplemented");
}
extern "C" int PyMapping_SetItemString(PyObject* o, char* key, PyObject* v) {
Py_FatalError("unimplemented");
}
BoxedClass* dict_iterator_cls = NULL;
extern "C" void dictIteratorGCHandler(GCVisitor* v, Box* b) {
boxGCHandler(v, b);
......
......@@ -100,6 +100,10 @@ Box* tupleGetitemSlice(BoxedTuple* self, BoxedSlice* slice) {
return _tupleSlice(self, start, stop, step);
}
extern "C" PyObject* PyTuple_GetSlice(PyObject* p, Py_ssize_t low, Py_ssize_t high) {
Py_FatalError("unimplemented");
}
Box* tupleGetitem(BoxedTuple* self, Box* slice) {
assert(self->cls == tuple_cls);
......
......@@ -41,6 +41,7 @@ extern "C" void init_sha512();
extern "C" void init_md5();
extern "C" void init_sre();
extern "C" void initmath();
extern "C" void initoperator();
namespace pyston {
......@@ -290,7 +291,7 @@ extern "C" void closureGCHandler(GCVisitor* v, Box* b) {
extern "C" {
BoxedClass* object_cls, *type_cls, *none_cls, *bool_cls, *int_cls, *float_cls, *str_cls, *function_cls,
*instancemethod_cls, *list_cls, *slice_cls, *module_cls, *dict_cls, *tuple_cls, *file_cls, *member_cls,
*closure_cls, *generator_cls, *complex_cls, *basestring_cls;
*closure_cls, *generator_cls, *complex_cls, *basestring_cls, *unicode_cls;
BoxedTuple* EmptyTuple;
......@@ -662,6 +663,7 @@ void setupRuntime() {
// TODO we leak all the string data!
str_cls = new BoxedClass(type_cls, basestring_cls, NULL, 0, sizeof(BoxedString), false);
unicode_cls = new BoxedClass(type_cls, basestring_cls, NULL, 0, sizeof(BoxedUnicode), false);
// It wasn't safe to add __base__ attributes until object+type+str are set up, so do that now:
type_cls->giveAttr("__base__", object_cls);
......@@ -821,6 +823,8 @@ void setupRuntime() {
init_md5();
init_sre();
initmath();
// TODO enable this
// initoperator();
setupSysEnd();
......
......@@ -77,7 +77,7 @@ Box* getSysStdout();
extern "C" {
extern BoxedClass* object_cls, *type_cls, *bool_cls, *int_cls, *long_cls, *float_cls, *str_cls, *function_cls,
*none_cls, *instancemethod_cls, *list_cls, *slice_cls, *module_cls, *dict_cls, *tuple_cls, *file_cls, *xrange_cls,
*member_cls, *method_cls, *closure_cls, *generator_cls, *complex_cls, *basestring_cls;
*member_cls, *method_cls, *closure_cls, *generator_cls, *complex_cls, *basestring_cls, *unicode_cls;
}
extern "C" { extern Box* None, *NotImplemented, *True, *False; }
extern "C" {
......@@ -232,6 +232,10 @@ public:
BoxedString(const std::string& s) __attribute__((visibility("default"))) : Box(str_cls), s(s) {}
};
class BoxedUnicode : public Box {
// TODO implementation
};
class BoxedInstanceMethod : public Box {
public:
// obj is NULL for unbound instancemethod
......
This diff is collapsed.
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