Commit 1ac82dda authored by Boxiang Sun's avatar Boxiang Sun

apply experimental complex changes

parent 9dbcaa45
......@@ -324,6 +324,7 @@ STDMODULE_SRCS := \
STDOBJECT_SRCS := \
structseq.c \
capsule.c \
complexobject.c \
stringobject.c \
exceptions.c \
floatobject.c \
......
......@@ -86,7 +86,6 @@ add_library(PYSTON_OBJECTS OBJECT ${OPTIONAL_SRCS}
runtime/capi.cpp
runtime/classobj.cpp
runtime/code.cpp
runtime/complex.cpp
runtime/ctxswitching.S
runtime/cxx_unwind.cpp
runtime/descr.cpp
......
......@@ -36,7 +36,7 @@
#include "codegen/irgen/util.h"
#include "core/threading.h"
#include "core/types.h"
#include "runtime/complex.h"
// #include "runtime/complex.h"
#include "runtime/float.h"
#include "runtime/generator.h"
#include "runtime/import.h"
......
......@@ -91,5 +91,6 @@ int Py_NoSiteFlag = 0;
int Py_OptimizeFlag = 0;
int Py_VerboseFlag = 0;
int Py_UnicodeFlag = 0;
int Py_DivisionWarningFlag = 0;
}
}
......@@ -2083,6 +2083,7 @@ void setupBuiltins() {
builtins_module->giveAttr("set", set_cls);
builtins_module->giveAttr("frozenset", frozenset_cls);
builtins_module->giveAttr("tuple", tuple_cls);
assert(complex_cls);
builtins_module->giveAttr("complex", complex_cls);
builtins_module->giveAttr("super", super_cls);
builtins_module->giveAttr("property", property_cls);
......
This diff is collapsed.
// Copyright (c) 2014-2015 Dropbox, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef PYSTON_RUNTIME_COMPLEX_H
#define PYSTON_RUNTIME_COMPLEX_H
#include "core/types.h"
namespace pyston {
extern "C" Box* createPureImaginary(double i);
}
#endif
......@@ -26,10 +26,10 @@ extern "C" inline Box* boxFloat(double d) {
return new BoxedFloat(d);
}
extern "C" inline Box* boxComplex(double r, double i) __attribute__((visibility("default")));
extern "C" inline Box* boxComplex(double r, double i) {
return new BoxedComplex(r, i);
}
// extern "C" inline Box* boxComplex(double r, double i) __attribute__((visibility("default")));
// extern "C" inline Box* boxComplex(double r, double i) {
// return new BoxedComplex(r, i);
// }
extern "C" inline bool unboxBool(Box* b) __attribute__((visibility("default")));
extern "C" inline bool unboxBool(Box* b) {
......
......@@ -20,7 +20,7 @@
#include "core/ast.h"
#include "core/threading.h"
#include "core/types.h"
#include "runtime/complex.h"
// #include "runtime/complex.h"
#include "runtime/float.h"
#include "runtime/generator.h"
#include "runtime/import.h"
......@@ -69,7 +69,7 @@ void force() {
FORCE(createClosure);
FORCE(createGenerator);
FORCE(createLong);
FORCE(createPureImaginary);
// FORCE(createPureImaginary);
FORCE(createSet);
FORCE(decodeUTF8StringPtr);
......
......@@ -35,7 +35,7 @@
#include "core/types.h"
#include "runtime/classobj.h"
#include "runtime/code.h"
#include "runtime/complex.h"
// #include "runtime/complex.h"
#include "runtime/dict.h"
#include "runtime/file.h"
#include "runtime/hiddenclass.h"
......@@ -568,7 +568,7 @@ BoxedFloat* BoxedModule::getFloatConstant(double d) {
Box* BoxedModule::getPureImaginaryConstant(double d) {
Box*& r = imaginary_constants[getDoubleBits(d)];
if (!r)
r = createPureImaginary(d);
r = PyComplex_FromDoubles(0.0, d);
return r;
}
......@@ -1557,9 +1557,9 @@ void BoxedClosure::gcHandler(GCVisitor* v, Box* b) {
extern "C" {
BoxedClass* object_cls, *type_cls, *none_cls, *bool_cls, *int_cls, *float_cls,
* str_cls = NULL, *function_cls, *instancemethod_cls, *list_cls, *slice_cls, *module_cls, *dict_cls, *tuple_cls,
*file_cls, *member_descriptor_cls, *closure_cls, *generator_cls, *null_importer_cls, *complex_cls,
*basestring_cls, *property_cls, *staticmethod_cls, *classmethod_cls, *attrwrapper_cls, *pyston_getset_cls,
*capi_getset_cls, *builtin_function_or_method_cls, *attrwrapperiter_cls, *set_cls, *frozenset_cls;
*file_cls, *member_descriptor_cls, *closure_cls, *generator_cls, *null_importer_cls, *basestring_cls,
*property_cls, *staticmethod_cls, *classmethod_cls, *attrwrapper_cls, *pyston_getset_cls, *capi_getset_cls,
*builtin_function_or_method_cls, *attrwrapperiter_cls, *set_cls, *frozenset_cls;
BoxedTuple* EmptyTuple;
}
......@@ -3689,7 +3689,7 @@ void setupRuntime() {
int_cls = new (0) BoxedClass(object_cls, NULL, 0, 0, sizeof(BoxedInt), false, "int");
int_cls->tp_flags |= Py_TPFLAGS_INT_SUBCLASS;
bool_cls = new (0) BoxedClass(int_cls, NULL, 0, 0, sizeof(BoxedBool), false, "bool");
complex_cls = new (0) BoxedClass(object_cls, NULL, 0, 0, sizeof(BoxedComplex), false, "complex");
// complex_cls = new (0) BoxedClass(object_cls, NULL, 0, 0, sizeof(BoxedComplex), false, "complex");
long_cls = new (0) BoxedClass(object_cls, &BoxedLong::gchandler, 0, 0, sizeof(BoxedLong), false, "long");
long_cls->tp_flags |= Py_TPFLAGS_LONG_SUBCLASS;
float_cls = new (0) BoxedClass(object_cls, NULL, 0, 0, sizeof(BoxedFloat), false, "float");
......@@ -3739,7 +3739,7 @@ void setupRuntime() {
file_cls->tp_mro = BoxedTuple::create({ file_cls, object_cls });
int_cls->tp_mro = BoxedTuple::create({ int_cls, object_cls });
bool_cls->tp_mro = BoxedTuple::create({ bool_cls, object_cls });
complex_cls->tp_mro = BoxedTuple::create({ complex_cls, object_cls });
// complex_cls->tp_mro = BoxedTuple::create({ complex_cls, object_cls });
long_cls->tp_mro = BoxedTuple::create({ long_cls, object_cls });
float_cls->tp_mro = BoxedTuple::create({ float_cls, object_cls });
function_cls->tp_mro = BoxedTuple::create({ function_cls, object_cls });
......@@ -3794,7 +3794,7 @@ void setupRuntime() {
file_cls->finishInitialization();
int_cls->finishInitialization();
bool_cls->finishInitialization();
complex_cls->finishInitialization();
// complex_cls->finishInitialization();
long_cls->finishInitialization();
float_cls->finishInitialization();
function_cls->finishInitialization();
......@@ -3925,7 +3925,6 @@ void setupRuntime() {
setupBool();
setupLong();
setupFloat();
setupComplex();
setupStr();
setupList();
setupDict();
......@@ -4078,6 +4077,7 @@ void setupRuntime() {
attrwrapperiter_cls->tp_iter = PyObject_SelfIter;
attrwrapperiter_cls->tp_iternext = AttrWrapperIter::next_capi;
PyType_Ready(&PyComplex_Type);
setupBuiltins();
_PyExc_Init();
setupThread();
......@@ -4181,7 +4181,7 @@ void teardownRuntime() {
teardownList();
teardownInt();
teardownFloat();
teardownComplex();
// teardownComplex();
teardownStr();
teardownBool();
teardownDict();
......
......@@ -46,8 +46,6 @@ void setupInt();
void teardownInt();
void setupFloat();
void teardownFloat();
void setupComplex();
void teardownComplex();
void setupStr();
void teardownStr();
void setupList();
......@@ -91,13 +89,11 @@ 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,
*enumerate_cls, *xrange_cls, *member_descriptor_cls, *null_importer_cls, *method_cls, *closure_cls, *generator_cls,
*complex_cls, *basestring_cls, *property_cls, *staticmethod_cls, *classmethod_cls, *attrwrapper_cls,
*pyston_getset_cls, *capi_getset_cls, *builtin_function_or_method_cls, *set_cls, *frozenset_cls, *code_cls,
*frame_cls, *capifunc_cls, *wrapperdescr_cls, *wrapperobject_cls;
*basestring_cls, *property_cls, *staticmethod_cls, *classmethod_cls, *attrwrapper_cls, *pyston_getset_cls,
*capi_getset_cls, *builtin_function_or_method_cls, *set_cls, *frozenset_cls, *code_cls, *frame_cls, *capifunc_cls,
*wrapperdescr_cls, *wrapperobject_cls;
}
#define unicode_cls (&PyUnicode_Type)
#define memoryview_cls (&PyMemoryView_Type)
#define complex_cls (&PyComplex_Type)
#define unicode_cls (&PyUnicode_Type)
#define memoryview_cls (&PyMemoryView_Type)
......@@ -380,15 +376,15 @@ public:
static_assert(sizeof(BoxedFloat) == sizeof(PyFloatObject), "");
static_assert(offsetof(BoxedFloat, d) == offsetof(PyFloatObject, ob_fval), "");
class BoxedComplex : public Box {
public:
double real;
double imag;
BoxedComplex(double r, double i) __attribute__((visibility("default"))) : real(r), imag(i) {}
DEFAULT_CLASS_SIMPLE(complex_cls);
};
// class BoxedComplex : public Box {
// public:
// double real;
// double imag;
//
// BoxedComplex(double r, double i) __attribute__((visibility("default"))) : real(r), imag(i) {}
//
// DEFAULT_CLASS_SIMPLE(complex_cls);
// };
class BoxedBool : public BoxedInt {
public:
......
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