Commit 7bf59432 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Format src/core/ again

I don't quite remember this but I think the goal was to ignore core/from_llvm, not all of core/
parent b701479b
......@@ -34,123 +34,121 @@ namespace pyston {
namespace AST_TYPE {
// These are in a pretty random order (started off alphabetical but then I had to add more).
// These can be changed freely as long as parse_ast.py is also updated
#define FOREACH_TYPE(X) \
X(alias, 1) \
X(arguments, 2) \
X(Assert, 3) \
X(Assign, 4) \
X(Attribute, 5) \
X(AugAssign, 6) \
X(BinOp, 7) \
X(BoolOp, 8) \
X(Call, 9) \
X(ClassDef, 10) \
X(Compare, 11) \
X(comprehension, 12) \
X(Delete, 13) \
X(Dict, 14) \
X(Exec, 16) \
X(ExceptHandler, 17) \
X(ExtSlice, 18) \
X(Expr, 19) \
X(For, 20) \
X(FunctionDef, 21) \
X(GeneratorExp, 22) \
X(Global, 23) \
X(If, 24) \
X(IfExp, 25) \
X(Import, 26) \
X(ImportFrom, 27) \
X(Index, 28) \
X(keyword, 29) \
X(Lambda, 30) \
X(List, 31) \
X(ListComp, 32) \
X(Module, 33) \
X(Num, 34) \
X(Name, 35) \
X(Pass, 37) \
X(Pow, 38) \
X(Print, 39) \
X(Raise, 40) \
X(Repr, 41) \
X(Return, 42) \
X(Slice, 44) \
X(Str, 45) \
X(Subscript, 46) \
X(TryExcept, 47) \
X(TryFinally, 48) \
X(Tuple, 49) \
X(UnaryOp, 50) \
X(With, 51) \
X(While, 52) \
X(Yield, 53) \
X(Store, 54) \
X(Load, 55) \
X(Param, 56) \
X(Not, 57) \
X(In, 58) \
X(Is, 59) \
X(IsNot, 60) \
X(Or, 61) \
X(And, 62) \
X(Eq, 63) \
X(NotEq, 64) \
X(NotIn, 65) \
X(GtE, 66) \
X(Gt, 67) \
X(Mod, 68) \
X(Add, 69) \
X(Continue, 70) \
X(Lt, 71) \
X(LtE, 72) \
X(Break, 73) \
X(Sub, 74) \
X(Del, 75) \
X(Mult, 76) \
X(Div, 77) \
X(USub, 78) \
X(BitAnd, 79) \
X(BitOr, 80) \
X(BitXor, 81) \
X(RShift, 82) \
X(LShift, 83) \
X(Invert, 84) \
X(UAdd, 85) \
X(FloorDiv, 86) \
X(DictComp, 15) \
X(Set, 43) \
X(Ellipsis, 87) \
/* like Module, but used for eval. */ \
X(Expression, 88) \
X(SetComp, 89) \
X(Suite, 90) \
\
/* Pseudo-nodes that are specific to this compiler: */ \
X(Branch, 200) \
X(Jump, 201) \
X(ClsAttribute, 202) \
X(AugBinOp, 203) \
X(Invoke, 204) \
X(LangPrimitive, 205) \
/* wraps a ClassDef to make it an expr */ \
X(MakeClass, 206) \
/* wraps a FunctionDef to make it an expr */ \
X(MakeFunction, 207) \
\
/* These aren't real AST types, but since we use AST types to represent binexp types */ \
/* and divmod+truediv are essentially types of binops, we add them here (at least for now): */ \
X(DivMod, 250) \
X(TrueDiv, 251) \
#define FOREACH_TYPE(X) \
X(alias, 1) \
X(arguments, 2) \
X(Assert, 3) \
X(Assign, 4) \
X(Attribute, 5) \
X(AugAssign, 6) \
X(BinOp, 7) \
X(BoolOp, 8) \
X(Call, 9) \
X(ClassDef, 10) \
X(Compare, 11) \
X(comprehension, 12) \
X(Delete, 13) \
X(Dict, 14) \
X(Exec, 16) \
X(ExceptHandler, 17) \
X(ExtSlice, 18) \
X(Expr, 19) \
X(For, 20) \
X(FunctionDef, 21) \
X(GeneratorExp, 22) \
X(Global, 23) \
X(If, 24) \
X(IfExp, 25) \
X(Import, 26) \
X(ImportFrom, 27) \
X(Index, 28) \
X(keyword, 29) \
X(Lambda, 30) \
X(List, 31) \
X(ListComp, 32) \
X(Module, 33) \
X(Num, 34) \
X(Name, 35) \
X(Pass, 37) \
X(Pow, 38) \
X(Print, 39) \
X(Raise, 40) \
X(Repr, 41) \
X(Return, 42) \
X(Slice, 44) \
X(Str, 45) \
X(Subscript, 46) \
X(TryExcept, 47) \
X(TryFinally, 48) \
X(Tuple, 49) \
X(UnaryOp, 50) \
X(With, 51) \
X(While, 52) \
X(Yield, 53) \
X(Store, 54) \
X(Load, 55) \
X(Param, 56) \
X(Not, 57) \
X(In, 58) \
X(Is, 59) \
X(IsNot, 60) \
X(Or, 61) \
X(And, 62) \
X(Eq, 63) \
X(NotEq, 64) \
X(NotIn, 65) \
X(GtE, 66) \
X(Gt, 67) \
X(Mod, 68) \
X(Add, 69) \
X(Continue, 70) \
X(Lt, 71) \
X(LtE, 72) \
X(Break, 73) \
X(Sub, 74) \
X(Del, 75) \
X(Mult, 76) \
X(Div, 77) \
X(USub, 78) \
X(BitAnd, 79) \
X(BitOr, 80) \
X(BitXor, 81) \
X(RShift, 82) \
X(LShift, 83) \
X(Invert, 84) \
X(UAdd, 85) \
X(FloorDiv, 86) \
X(DictComp, 15) \
X(Set, 43) \
X(Ellipsis, 87) \
/* like Module, but used for eval. */ \
X(Expression, 88) \
X(SetComp, 89) \
X(Suite, 90) \
\
/* Pseudo-nodes that are specific to this compiler: */ \
X(Branch, 200) \
X(Jump, 201) \
X(ClsAttribute, 202) \
X(AugBinOp, 203) \
X(Invoke, 204) \
X(LangPrimitive, 205) \
/* wraps a ClassDef to make it an expr */ \
X(MakeClass, 206) \
/* wraps a FunctionDef to make it an expr */ \
X(MakeFunction, 207) \
\
/* These aren't real AST types, but since we use AST types to represent binexp types */ \
/* and divmod+truediv are essentially types of binops, we add them here (at least for now): */ \
X(DivMod, 250) \
X(TrueDiv, 251)
#define GENERATE_ENUM(ENUM, N) ENUM = N,
#define GENERATE_STRING(STRING, N) m[N] = #STRING;
enum AST_TYPE {
FOREACH_TYPE(GENERATE_ENUM)
};
enum AST_TYPE { FOREACH_TYPE(GENERATE_ENUM) };
static const char *stringify(int n) {
static const char* stringify(int n) {
static std::map<int, const char*> m;
FOREACH_TYPE(GENERATE_STRING)
return m[n];
......@@ -159,7 +157,6 @@ static const char *stringify(int n) {
#undef FOREACH_TYPE
#undef GENERATE_ENUM
#undef GENERATE_STRING
};
class ASTVisitor;
......@@ -1360,9 +1357,7 @@ private:
public:
PrintVisitor(int indent = 0, llvm::raw_ostream& stream = llvm::outs()) : stream(stream), indent(indent) {}
virtual ~PrintVisitor() {}
void flush() {
stream.flush();
}
void flush() { stream.flush(); }
virtual bool visit_alias(AST_alias* node);
virtual bool visit_arguments(AST_arguments* node);
......
......@@ -271,7 +271,8 @@ private:
}
}
raiseSyntaxError("'continue' not properly in loop", value->lineno, value->col_offset, source->getFn()->s(), "", true);
raiseSyntaxError("'continue' not properly in loop", value->lineno, value->col_offset, source->getFn()->s(), "",
true);
}
void doBreak(AST* value) {
......@@ -2527,7 +2528,8 @@ public:
llvm::DenseMap<InternedString, int> sym_vreg_map;
ScopeInfo* scope_info;
AssignVRegsVisitor(ScopeInfo* scope_info, bool only_user_visible) : only_user_visible(only_user_visible), scope_info(scope_info) {}
AssignVRegsVisitor(ScopeInfo* scope_info, bool only_user_visible)
: only_user_visible(only_user_visible), scope_info(scope_info) {}
bool visit_arguments(AST_arguments* node) override {
for (AST_expr* d : node->defaults)
......@@ -2586,8 +2588,9 @@ void CFG::assignVRegs(const ParamNames& param_names, ScopeInfo* scope_info) {
AssignVRegsVisitor visitor(scope_info, true);
// we need todo two passes: first we assign the user visible vars a vreg and then the compiler created get there value.
for (int i=0; i<2; ++i) {
// we need todo two passes: first we assign the user visible vars a vreg and then the compiler created get there
// value.
for (int i = 0; i < 2; ++i) {
for (CFGBlock* b : blocks) {
for (AST_stmt* stmt : b->body) {
stmt->accept(&visitor);
......
......@@ -67,9 +67,7 @@ public:
void push_back(AST_stmt* node) { body.push_back(node); }
void print(llvm::raw_ostream& stream = llvm::outs());
void _print() {
print();
}
void _print() { print(); }
};
// Control Flow Graph
......
......@@ -84,8 +84,7 @@ template <typename T1, typename T2, typename T3> struct hash<tuple<T1, T2, T3>>
}
namespace pyston {
template <typename T>
constexpr bool fitsInto(int64_t x) {
template <typename T> constexpr bool fitsInto(int64_t x) {
return std::numeric_limits<T>::min() <= x && x <= std::numeric_limits<T>::max();
}
}
......
......@@ -50,7 +50,7 @@ bool ENABLE_TRACEBACKS = true;
bool FORCE_LLVM_CAPI_CALLS = false;
bool FORCE_LLVM_CAPI_THROWS = false;
int OSR_THRESHOLD_INTERPRETER = 5; // XXX
int OSR_THRESHOLD_INTERPRETER = 5; // XXX
int REOPT_THRESHOLD_INTERPRETER = 1; // XXX
int OSR_THRESHOLD_BASELINE = 2500;
int REOPT_THRESHOLD_BASELINE = 1500;
......
......@@ -42,5 +42,4 @@ bool InternedString::isCompilerCreatedName() const {
char c = _str->s()[0];
return c == '!' || c == '#';
}
}
......@@ -460,7 +460,6 @@ extern "C" void PyEval_ReInitThreads() noexcept {
else
Py_DECREF(result);
Py_DECREF(threading);
}
void acquireGLWrite() {
......@@ -599,7 +598,7 @@ extern "C" void PyThread_delete_key_value(int key) noexcept {
}
extern "C" PyObject *_PyThread_CurrentFrames(void) noexcept {
extern "C" PyObject* _PyThread_CurrentFrames(void) noexcept {
assert(0 && "check refcounting");
try {
LOCK_REGION(&threading_lock);
......@@ -611,9 +610,9 @@ extern "C" PyObject *_PyThread_CurrentFrames(void) noexcept {
result->d[boxInt(pair.first)] = frame;
}
return result;
} catch (ExcInfo) {
} catch (ExcInfo) {
RELEASE_ASSERT(0, "not implemented");
}
}
}
......
......@@ -78,10 +78,10 @@ enum Rewritable {
enum class RefType {
UNKNOWN
#ifndef NDEBUG
// Set this to non-zero to make it possible for the debugger to
= 1
// Set this to non-zero to make it possible for the debugger to
= 1
#endif
,
,
OWNED,
BORROWED,
};
......@@ -314,7 +314,8 @@ class JitCodeBlock;
extern std::vector<Box*> constants;
extern std::vector<Box*> late_constants; // constants that should be freed after normal constants
// A specific compilation of a FunctionMetadata. Usually these will be created by the LLVM JIT, which will take a FunctionMetadata
// A specific compilation of a FunctionMetadata. Usually these will be created by the LLVM JIT, which will take a
// FunctionMetadata
// and some compilation settings, and produce a CompiledFunction
// CompiledFunctions can also be created from raw function pointers, using FunctionMetadata::create.
// A single FunctionMetadata can have multiple CompiledFunctions associated with it, if they have different settings.
......@@ -655,10 +656,10 @@ public:
int traverse(visitproc visit, void* arg) noexcept;
void _clearRaw() noexcept; // Raw clear -- clears out and decrefs all the attrs.
// Meant for implementing other clear-like functions
void clearForDealloc() noexcept; // meant for normal object deallocation. converts the attrwrapper
void moduleClear() noexcept; // Meant for _PyModule_Clear. doesn't clear all attributes.
void _clearRaw() noexcept; // Raw clear -- clears out and decrefs all the attrs.
// Meant for implementing other clear-like functions
void clearForDealloc() noexcept; // meant for normal object deallocation. converts the attrwrapper
void moduleClear() noexcept; // Meant for _PyModule_Clear. doesn't clear all attributes.
};
static_assert(sizeof(HCAttrs) == sizeof(struct _hcattrs), "");
......@@ -694,7 +695,7 @@ public:
_PyObject_HEAD_EXTRA
Py_ssize_t ob_refcnt;
Py_ssize_t ob_refcnt;
// Note: cls gets initialized in the new() function.
BoxedClass* cls;
......@@ -898,13 +899,13 @@ static_assert(offsetof(BoxVar, ob_size) == offsetof(struct _varobject, ob_size),
} \
void* operator new(size_t size, size_t nitems) __attribute__((visibility("default"))) { \
ALLOC_STATS_VAR(default_cls) \
assert(default_cls->tp_alloc == PyType_GenericAlloc); \
assert(default_cls->tp_alloc == PyType_GenericAlloc); \
assert(default_cls->tp_itemsize == itemsize); \
assert(default_cls->tp_basicsize == size); \
assert(default_cls->is_pyston_class); \
assert(default_cls->attrs_offset == 0); \
\
void* mem = PyObject_MALLOC(size + nitems * itemsize); \
void* mem = PyObject_MALLOC(size + nitems * itemsize); \
assert(mem); \
\
BoxVar* rtn = static_cast<BoxVar*>(mem); \
......
#!/usr/bin/env bash
set -eu
failed=0
for fn in $(find . -path ./core -prune -o -name '*.cpp' -print -o -name '*.h' -print); do
for fn in $(find . -path ./core/from_llvm -prune -o -name '*.cpp' -print -o -name '*.h' -print); do
diff -u $fn <($1 -style=file $fn) || failed=1
done
......
#!/usr/bin/env bash
set -eu
for fn in $(find . -path ./core -prune -o -name '*.cpp' -print -o -name '*.h' -print); do
for fn in $(find . -path ./core/from_llvm -prune -o -name '*.cpp' -print -o -name '*.h' -print); do
$1 -i --style=file $fn
done
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