Commit b0cf2322 authored by Kevin Modzelewski's avatar Kevin Modzelewski Committed by Kevin Modzelewski

Get the imported files to compile (but not link)

parent 3fa45d83
...@@ -100,8 +100,10 @@ file(GLOB_RECURSE STDPYTHON_SRCS Python ...@@ -100,8 +100,10 @@ file(GLOB_RECURSE STDPYTHON_SRCS Python
formatter_string.c formatter_string.c
formatter_unicode.c formatter_unicode.c
getargs.c getargs.c
graminit.c
marshal.c marshal.c
mystrtoul.c mystrtoul.c
pyarena.c
pyctype.c pyctype.c
pystrtod.c pystrtod.c
Python-ast.c Python-ast.c
...@@ -111,7 +113,13 @@ file(GLOB_RECURSE STDPYTHON_SRCS Python ...@@ -111,7 +113,13 @@ file(GLOB_RECURSE STDPYTHON_SRCS Python
# compile specified files in from_cpython/Python # compile specified files in from_cpython/Python
file(GLOB_RECURSE STDPARSER_SRCS Parser file(GLOB_RECURSE STDPARSER_SRCS Parser
acceler.c
grammar1.c
myreadline.c myreadline.c
node.c
parser.c
parsetok.c
tokenizer.c
) )
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers -Wno-tautological-compare -Wno-type-limits -Wno-unused-result -Wno-strict-aliasing -DPy_BUILD_CORE") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-field-initializers -Wno-tautological-compare -Wno-type-limits -Wno-unused-result -Wno-strict-aliasing -DPy_BUILD_CORE")
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
#include "asdl.h" #include "asdl.h"
// Pyston addition:
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _mod *mod_ty; typedef struct _mod *mod_ty;
typedef struct _stmt *stmt_ty; typedef struct _stmt *stmt_ty;
...@@ -373,163 +378,167 @@ struct _alias { ...@@ -373,163 +378,167 @@ struct _alias {
#define Module(a0, a1) _Py_Module(a0, a1) #define Module(a0, a1) _Py_Module(a0, a1)
mod_ty _Py_Module(asdl_seq * body, PyArena *arena); mod_ty _Py_Module(asdl_seq * body, PyArena *arena) PYSTON_NOEXCEPT;
#define Interactive(a0, a1) _Py_Interactive(a0, a1) #define Interactive(a0, a1) _Py_Interactive(a0, a1)
mod_ty _Py_Interactive(asdl_seq * body, PyArena *arena); mod_ty _Py_Interactive(asdl_seq * body, PyArena *arena) PYSTON_NOEXCEPT;
#define Expression(a0, a1) _Py_Expression(a0, a1) #define Expression(a0, a1) _Py_Expression(a0, a1)
mod_ty _Py_Expression(expr_ty body, PyArena *arena); mod_ty _Py_Expression(expr_ty body, PyArena *arena) PYSTON_NOEXCEPT;
#define Suite(a0, a1) _Py_Suite(a0, a1) #define Suite(a0, a1) _Py_Suite(a0, a1)
mod_ty _Py_Suite(asdl_seq * body, PyArena *arena); mod_ty _Py_Suite(asdl_seq * body, PyArena *arena) PYSTON_NOEXCEPT;
#define FunctionDef(a0, a1, a2, a3, a4, a5, a6) _Py_FunctionDef(a0, a1, a2, a3, a4, a5, a6) #define FunctionDef(a0, a1, a2, a3, a4, a5, a6) _Py_FunctionDef(a0, a1, a2, a3, a4, a5, a6)
stmt_ty _Py_FunctionDef(identifier name, arguments_ty args, asdl_seq * body, stmt_ty _Py_FunctionDef(identifier name, arguments_ty args, asdl_seq * body,
asdl_seq * decorator_list, int lineno, int col_offset, asdl_seq * decorator_list, int lineno, int col_offset,
PyArena *arena); PyArena *arena) PYSTON_NOEXCEPT;
#define ClassDef(a0, a1, a2, a3, a4, a5, a6) _Py_ClassDef(a0, a1, a2, a3, a4, a5, a6) #define ClassDef(a0, a1, a2, a3, a4, a5, a6) _Py_ClassDef(a0, a1, a2, a3, a4, a5, a6)
stmt_ty _Py_ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, stmt_ty _Py_ClassDef(identifier name, asdl_seq * bases, asdl_seq * body,
asdl_seq * decorator_list, int lineno, int col_offset, asdl_seq * decorator_list, int lineno, int col_offset,
PyArena *arena); PyArena *arena) PYSTON_NOEXCEPT;
#define Return(a0, a1, a2, a3) _Py_Return(a0, a1, a2, a3) #define Return(a0, a1, a2, a3) _Py_Return(a0, a1, a2, a3)
stmt_ty _Py_Return(expr_ty value, int lineno, int col_offset, PyArena *arena); stmt_ty _Py_Return(expr_ty value, int lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Delete(a0, a1, a2, a3) _Py_Delete(a0, a1, a2, a3) #define Delete(a0, a1, a2, a3) _Py_Delete(a0, a1, a2, a3)
stmt_ty _Py_Delete(asdl_seq * targets, int lineno, int col_offset, PyArena stmt_ty _Py_Delete(asdl_seq * targets, int lineno, int col_offset, PyArena
*arena); *arena) PYSTON_NOEXCEPT;
#define Assign(a0, a1, a2, a3, a4) _Py_Assign(a0, a1, a2, a3, a4) #define Assign(a0, a1, a2, a3, a4) _Py_Assign(a0, a1, a2, a3, a4)
stmt_ty _Py_Assign(asdl_seq * targets, expr_ty value, int lineno, int stmt_ty _Py_Assign(asdl_seq * targets, expr_ty value, int lineno, int
col_offset, PyArena *arena); col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define AugAssign(a0, a1, a2, a3, a4, a5) _Py_AugAssign(a0, a1, a2, a3, a4, a5) #define AugAssign(a0, a1, a2, a3, a4, a5) _Py_AugAssign(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_AugAssign(expr_ty target, operator_ty op, expr_ty value, int stmt_ty _Py_AugAssign(expr_ty target, operator_ty op, expr_ty value, int
lineno, int col_offset, PyArena *arena); lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Print(a0, a1, a2, a3, a4, a5) _Py_Print(a0, a1, a2, a3, a4, a5) #define Print(a0, a1, a2, a3, a4, a5) _Py_Print(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_Print(expr_ty dest, asdl_seq * values, bool nl, int lineno, int stmt_ty _Py_Print(expr_ty dest, asdl_seq * values, bool nl, int lineno, int
col_offset, PyArena *arena); col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define For(a0, a1, a2, a3, a4, a5, a6) _Py_For(a0, a1, a2, a3, a4, a5, a6) #define For(a0, a1, a2, a3, a4, a5, a6) _Py_For(a0, a1, a2, a3, a4, a5, a6)
stmt_ty _Py_For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * stmt_ty _Py_For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq *
orelse, int lineno, int col_offset, PyArena *arena); orelse, int lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define While(a0, a1, a2, a3, a4, a5) _Py_While(a0, a1, a2, a3, a4, a5) #define While(a0, a1, a2, a3, a4, a5) _Py_While(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, stmt_ty _Py_While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno,
int col_offset, PyArena *arena); int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define If(a0, a1, a2, a3, a4, a5) _Py_If(a0, a1, a2, a3, a4, a5) #define If(a0, a1, a2, a3, a4, a5) _Py_If(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, stmt_ty _Py_If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno,
int col_offset, PyArena *arena); int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define With(a0, a1, a2, a3, a4, a5) _Py_With(a0, a1, a2, a3, a4, a5) #define With(a0, a1, a2, a3, a4, a5) _Py_With(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body, stmt_ty _Py_With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body,
int lineno, int col_offset, PyArena *arena); int lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Raise(a0, a1, a2, a3, a4, a5) _Py_Raise(a0, a1, a2, a3, a4, a5) #define Raise(a0, a1, a2, a3, a4, a5) _Py_Raise(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int stmt_ty _Py_Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int
col_offset, PyArena *arena); col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define TryExcept(a0, a1, a2, a3, a4, a5) _Py_TryExcept(a0, a1, a2, a3, a4, a5) #define TryExcept(a0, a1, a2, a3, a4, a5) _Py_TryExcept(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, stmt_ty _Py_TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse,
int lineno, int col_offset, PyArena *arena); int lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define TryFinally(a0, a1, a2, a3, a4) _Py_TryFinally(a0, a1, a2, a3, a4) #define TryFinally(a0, a1, a2, a3, a4) _Py_TryFinally(a0, a1, a2, a3, a4)
stmt_ty _Py_TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, int stmt_ty _Py_TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, int
col_offset, PyArena *arena); col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Assert(a0, a1, a2, a3, a4) _Py_Assert(a0, a1, a2, a3, a4) #define Assert(a0, a1, a2, a3, a4) _Py_Assert(a0, a1, a2, a3, a4)
stmt_ty _Py_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, stmt_ty _Py_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset,
PyArena *arena); PyArena *arena) PYSTON_NOEXCEPT;
#define Import(a0, a1, a2, a3) _Py_Import(a0, a1, a2, a3) #define Import(a0, a1, a2, a3) _Py_Import(a0, a1, a2, a3)
stmt_ty _Py_Import(asdl_seq * names, int lineno, int col_offset, PyArena stmt_ty _Py_Import(asdl_seq * names, int lineno, int col_offset, PyArena
*arena); *arena) PYSTON_NOEXCEPT;
#define ImportFrom(a0, a1, a2, a3, a4, a5) _Py_ImportFrom(a0, a1, a2, a3, a4, a5) #define ImportFrom(a0, a1, a2, a3, a4, a5) _Py_ImportFrom(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_ImportFrom(identifier module, asdl_seq * names, int level, int stmt_ty _Py_ImportFrom(identifier module, asdl_seq * names, int level, int
lineno, int col_offset, PyArena *arena); lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Exec(a0, a1, a2, a3, a4, a5) _Py_Exec(a0, a1, a2, a3, a4, a5) #define Exec(a0, a1, a2, a3, a4, a5) _Py_Exec(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, int stmt_ty _Py_Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, int
col_offset, PyArena *arena); col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Global(a0, a1, a2, a3) _Py_Global(a0, a1, a2, a3) #define Global(a0, a1, a2, a3) _Py_Global(a0, a1, a2, a3)
stmt_ty _Py_Global(asdl_seq * names, int lineno, int col_offset, PyArena stmt_ty _Py_Global(asdl_seq * names, int lineno, int col_offset, PyArena
*arena); *arena) PYSTON_NOEXCEPT;
#define Expr(a0, a1, a2, a3) _Py_Expr(a0, a1, a2, a3) #define Expr(a0, a1, a2, a3) _Py_Expr(a0, a1, a2, a3)
stmt_ty _Py_Expr(expr_ty value, int lineno, int col_offset, PyArena *arena); stmt_ty _Py_Expr(expr_ty value, int lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Pass(a0, a1, a2) _Py_Pass(a0, a1, a2) #define Pass(a0, a1, a2) _Py_Pass(a0, a1, a2)
stmt_ty _Py_Pass(int lineno, int col_offset, PyArena *arena); stmt_ty _Py_Pass(int lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Break(a0, a1, a2) _Py_Break(a0, a1, a2) #define Break(a0, a1, a2) _Py_Break(a0, a1, a2)
stmt_ty _Py_Break(int lineno, int col_offset, PyArena *arena); stmt_ty _Py_Break(int lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Continue(a0, a1, a2) _Py_Continue(a0, a1, a2) #define Continue(a0, a1, a2) _Py_Continue(a0, a1, a2)
stmt_ty _Py_Continue(int lineno, int col_offset, PyArena *arena); stmt_ty _Py_Continue(int lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define BoolOp(a0, a1, a2, a3, a4) _Py_BoolOp(a0, a1, a2, a3, a4) #define BoolOp(a0, a1, a2, a3, a4) _Py_BoolOp(a0, a1, a2, a3, a4)
expr_ty _Py_BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, expr_ty _Py_BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset,
PyArena *arena); PyArena *arena) PYSTON_NOEXCEPT;
#define BinOp(a0, a1, a2, a3, a4, a5) _Py_BinOp(a0, a1, a2, a3, a4, a5) #define BinOp(a0, a1, a2, a3, a4, a5) _Py_BinOp(a0, a1, a2, a3, a4, a5)
expr_ty _Py_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int expr_ty _Py_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
col_offset, PyArena *arena); col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define UnaryOp(a0, a1, a2, a3, a4) _Py_UnaryOp(a0, a1, a2, a3, a4) #define UnaryOp(a0, a1, a2, a3, a4) _Py_UnaryOp(a0, a1, a2, a3, a4)
expr_ty _Py_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, expr_ty _Py_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset,
PyArena *arena); PyArena *arena) PYSTON_NOEXCEPT;
#define Lambda(a0, a1, a2, a3, a4) _Py_Lambda(a0, a1, a2, a3, a4) #define Lambda(a0, a1, a2, a3, a4) _Py_Lambda(a0, a1, a2, a3, a4)
expr_ty _Py_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, expr_ty _Py_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset,
PyArena *arena); PyArena *arena) PYSTON_NOEXCEPT;
#define IfExp(a0, a1, a2, a3, a4, a5) _Py_IfExp(a0, a1, a2, a3, a4, a5) #define IfExp(a0, a1, a2, a3, a4, a5) _Py_IfExp(a0, a1, a2, a3, a4, a5)
expr_ty _Py_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int expr_ty _Py_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
col_offset, PyArena *arena); col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Dict(a0, a1, a2, a3, a4) _Py_Dict(a0, a1, a2, a3, a4) #define Dict(a0, a1, a2, a3, a4) _Py_Dict(a0, a1, a2, a3, a4)
expr_ty _Py_Dict(asdl_seq * keys, asdl_seq * values, int lineno, int expr_ty _Py_Dict(asdl_seq * keys, asdl_seq * values, int lineno, int
col_offset, PyArena *arena); col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Set(a0, a1, a2, a3) _Py_Set(a0, a1, a2, a3) #define Set(a0, a1, a2, a3) _Py_Set(a0, a1, a2, a3)
expr_ty _Py_Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena); expr_ty _Py_Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define ListComp(a0, a1, a2, a3, a4) _Py_ListComp(a0, a1, a2, a3, a4) #define ListComp(a0, a1, a2, a3, a4) _Py_ListComp(a0, a1, a2, a3, a4)
expr_ty _Py_ListComp(expr_ty elt, asdl_seq * generators, int lineno, int expr_ty _Py_ListComp(expr_ty elt, asdl_seq * generators, int lineno, int
col_offset, PyArena *arena); col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define SetComp(a0, a1, a2, a3, a4) _Py_SetComp(a0, a1, a2, a3, a4) #define SetComp(a0, a1, a2, a3, a4) _Py_SetComp(a0, a1, a2, a3, a4)
expr_ty _Py_SetComp(expr_ty elt, asdl_seq * generators, int lineno, int expr_ty _Py_SetComp(expr_ty elt, asdl_seq * generators, int lineno, int
col_offset, PyArena *arena); col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define DictComp(a0, a1, a2, a3, a4, a5) _Py_DictComp(a0, a1, a2, a3, a4, a5) #define DictComp(a0, a1, a2, a3, a4, a5) _Py_DictComp(a0, a1, a2, a3, a4, a5)
expr_ty _Py_DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int expr_ty _Py_DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int
lineno, int col_offset, PyArena *arena); lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define GeneratorExp(a0, a1, a2, a3, a4) _Py_GeneratorExp(a0, a1, a2, a3, a4) #define GeneratorExp(a0, a1, a2, a3, a4) _Py_GeneratorExp(a0, a1, a2, a3, a4)
expr_ty _Py_GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int expr_ty _Py_GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int
col_offset, PyArena *arena); col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Yield(a0, a1, a2, a3) _Py_Yield(a0, a1, a2, a3) #define Yield(a0, a1, a2, a3) _Py_Yield(a0, a1, a2, a3)
expr_ty _Py_Yield(expr_ty value, int lineno, int col_offset, PyArena *arena); expr_ty _Py_Yield(expr_ty value, int lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Compare(a0, a1, a2, a3, a4, a5) _Py_Compare(a0, a1, a2, a3, a4, a5) #define Compare(a0, a1, a2, a3, a4, a5) _Py_Compare(a0, a1, a2, a3, a4, a5)
expr_ty _Py_Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, expr_ty _Py_Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators,
int lineno, int col_offset, PyArena *arena); int lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Call(a0, a1, a2, a3, a4, a5, a6, a7) _Py_Call(a0, a1, a2, a3, a4, a5, a6, a7) #define Call(a0, a1, a2, a3, a4, a5, a6, a7) _Py_Call(a0, a1, a2, a3, a4, a5, a6, a7)
expr_ty _Py_Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty expr_ty _Py_Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty
starargs, expr_ty kwargs, int lineno, int col_offset, PyArena starargs, expr_ty kwargs, int lineno, int col_offset, PyArena
*arena); *arena) PYSTON_NOEXCEPT;
#define Repr(a0, a1, a2, a3) _Py_Repr(a0, a1, a2, a3) #define Repr(a0, a1, a2, a3) _Py_Repr(a0, a1, a2, a3)
expr_ty _Py_Repr(expr_ty value, int lineno, int col_offset, PyArena *arena); expr_ty _Py_Repr(expr_ty value, int lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Num(a0, a1, a2, a3) _Py_Num(a0, a1, a2, a3) #define Num(a0, a1, a2, a3) _Py_Num(a0, a1, a2, a3)
expr_ty _Py_Num(object n, int lineno, int col_offset, PyArena *arena); expr_ty _Py_Num(object n, int lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Str(a0, a1, a2, a3) _Py_Str(a0, a1, a2, a3) #define Str(a0, a1, a2, a3) _Py_Str(a0, a1, a2, a3)
expr_ty _Py_Str(string s, int lineno, int col_offset, PyArena *arena); expr_ty _Py_Str(string s, int lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Attribute(a0, a1, a2, a3, a4, a5) _Py_Attribute(a0, a1, a2, a3, a4, a5) #define Attribute(a0, a1, a2, a3, a4, a5) _Py_Attribute(a0, a1, a2, a3, a4, a5)
expr_ty _Py_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int expr_ty _Py_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
lineno, int col_offset, PyArena *arena); lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Subscript(a0, a1, a2, a3, a4, a5) _Py_Subscript(a0, a1, a2, a3, a4, a5) #define Subscript(a0, a1, a2, a3, a4, a5) _Py_Subscript(a0, a1, a2, a3, a4, a5)
expr_ty _Py_Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int expr_ty _Py_Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int
lineno, int col_offset, PyArena *arena); lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Name(a0, a1, a2, a3, a4) _Py_Name(a0, a1, a2, a3, a4) #define Name(a0, a1, a2, a3, a4) _Py_Name(a0, a1, a2, a3, a4)
expr_ty _Py_Name(identifier id, expr_context_ty ctx, int lineno, int expr_ty _Py_Name(identifier id, expr_context_ty ctx, int lineno, int
col_offset, PyArena *arena); col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define List(a0, a1, a2, a3, a4) _Py_List(a0, a1, a2, a3, a4) #define List(a0, a1, a2, a3, a4) _Py_List(a0, a1, a2, a3, a4)
expr_ty _Py_List(asdl_seq * elts, expr_context_ty ctx, int lineno, int expr_ty _Py_List(asdl_seq * elts, expr_context_ty ctx, int lineno, int
col_offset, PyArena *arena); col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Tuple(a0, a1, a2, a3, a4) _Py_Tuple(a0, a1, a2, a3, a4) #define Tuple(a0, a1, a2, a3, a4) _Py_Tuple(a0, a1, a2, a3, a4)
expr_ty _Py_Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int expr_ty _Py_Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int
col_offset, PyArena *arena); col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define Ellipsis(a0) _Py_Ellipsis(a0) #define Ellipsis(a0) _Py_Ellipsis(a0)
slice_ty _Py_Ellipsis(PyArena *arena); slice_ty _Py_Ellipsis(PyArena *arena) PYSTON_NOEXCEPT;
#define Slice(a0, a1, a2, a3) _Py_Slice(a0, a1, a2, a3) #define Slice(a0, a1, a2, a3) _Py_Slice(a0, a1, a2, a3)
slice_ty _Py_Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena); slice_ty _Py_Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena) PYSTON_NOEXCEPT;
#define ExtSlice(a0, a1) _Py_ExtSlice(a0, a1) #define ExtSlice(a0, a1) _Py_ExtSlice(a0, a1)
slice_ty _Py_ExtSlice(asdl_seq * dims, PyArena *arena); slice_ty _Py_ExtSlice(asdl_seq * dims, PyArena *arena) PYSTON_NOEXCEPT;
#define Index(a0, a1) _Py_Index(a0, a1) #define Index(a0, a1) _Py_Index(a0, a1)
slice_ty _Py_Index(expr_ty value, PyArena *arena); slice_ty _Py_Index(expr_ty value, PyArena *arena) PYSTON_NOEXCEPT;
#define comprehension(a0, a1, a2, a3) _Py_comprehension(a0, a1, a2, a3) #define comprehension(a0, a1, a2, a3) _Py_comprehension(a0, a1, a2, a3)
comprehension_ty _Py_comprehension(expr_ty target, expr_ty iter, asdl_seq * comprehension_ty _Py_comprehension(expr_ty target, expr_ty iter, asdl_seq *
ifs, PyArena *arena); ifs, PyArena *arena) PYSTON_NOEXCEPT;
#define ExceptHandler(a0, a1, a2, a3, a4, a5) _Py_ExceptHandler(a0, a1, a2, a3, a4, a5) #define ExceptHandler(a0, a1, a2, a3, a4, a5) _Py_ExceptHandler(a0, a1, a2, a3, a4, a5)
excepthandler_ty _Py_ExceptHandler(expr_ty type, expr_ty name, asdl_seq * body, excepthandler_ty _Py_ExceptHandler(expr_ty type, expr_ty name, asdl_seq * body,
int lineno, int col_offset, PyArena *arena); int lineno, int col_offset, PyArena *arena) PYSTON_NOEXCEPT;
#define arguments(a0, a1, a2, a3, a4) _Py_arguments(a0, a1, a2, a3, a4) #define arguments(a0, a1, a2, a3, a4) _Py_arguments(a0, a1, a2, a3, a4)
arguments_ty _Py_arguments(asdl_seq * args, identifier vararg, identifier arguments_ty _Py_arguments(asdl_seq * args, identifier vararg, identifier
kwarg, asdl_seq * defaults, PyArena *arena); kwarg, asdl_seq * defaults, PyArena *arena) PYSTON_NOEXCEPT;
#define keyword(a0, a1, a2) _Py_keyword(a0, a1, a2) #define keyword(a0, a1, a2) _Py_keyword(a0, a1, a2)
keyword_ty _Py_keyword(identifier arg, expr_ty value, PyArena *arena); keyword_ty _Py_keyword(identifier arg, expr_ty value, PyArena *arena) PYSTON_NOEXCEPT;
#define alias(a0, a1, a2) _Py_alias(a0, a1, a2) #define alias(a0, a1, a2) _Py_alias(a0, a1, a2)
alias_ty _Py_alias(identifier name, identifier asname, PyArena *arena); alias_ty _Py_alias(identifier name, identifier asname, PyArena *arena) PYSTON_NOEXCEPT;
PyObject* PyAST_mod2obj(mod_ty t) PYSTON_NOEXCEPT;
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode) PYSTON_NOEXCEPT;
int PyAST_Check(PyObject* obj) PYSTON_NOEXCEPT;
PyObject* PyAST_mod2obj(mod_ty t); #ifdef __cplusplus
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode); }
int PyAST_Check(PyObject* obj); #endif
...@@ -41,9 +41,6 @@ ...@@ -41,9 +41,6 @@
#include <assert.h> #include <assert.h>
// CPython doesn't seem to include this but I'm not sure how they get the definition of 'bool':
#include <stdbool.h>
#include "pyport.h" #include "pyport.h"
#include "pymath.h" #include "pymath.h"
...@@ -133,8 +130,11 @@ PyAPI_FUNC(void) PyType_SetDict(PyTypeObject*, PyObject*) PYSTON_NOEXCEPT; ...@@ -133,8 +130,11 @@ PyAPI_FUNC(void) PyType_SetDict(PyTypeObject*, PyObject*) PYSTON_NOEXCEPT;
#include "abstract.h" #include "abstract.h"
#include "compile.h"
#include "pyctype.h" #include "pyctype.h"
#include "pystrtod.h" #include "pystrtod.h"
#include "pystrcmp.h"
#include "dtoa.h" #include "dtoa.h"
// directly from CPython: // directly from CPython:
...@@ -185,9 +185,6 @@ extern PyTypeObject* Itertool_SafeDealloc_Types[]; ...@@ -185,9 +185,6 @@ extern PyTypeObject* Itertool_SafeDealloc_Types[];
#define PyDoc_STRVAR(name, str) PyDoc_VAR(name) = PyDoc_STR(str) #define PyDoc_STRVAR(name, str) PyDoc_VAR(name) = PyDoc_STR(str)
#define PyDoc_STR(str) str #define PyDoc_STR(str) str
// This is in Python-ast.h in CPython, which we don't yet have:
int PyAST_Check(PyObject* obj) PYSTON_NOEXCEPT;
#ifdef __cplusplus #ifdef __cplusplus
#define PyMODINIT_FUNC extern "C" void #define PyMODINIT_FUNC extern "C" void
#else #else
......
...@@ -534,7 +534,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ ...@@ -534,7 +534,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
/* new buffer API */ /* new buffer API */
// Pyston change: made this a function // Pyston change: made this a function
bool _PyObject_CheckBuffer(PyObject* obj) PYSTON_NOEXCEPT; int _PyObject_CheckBuffer(PyObject* obj) PYSTON_NOEXCEPT;
#define PyObject_CheckBuffer(obj) _PyObject_CheckBuffer((PyObject*)(obj)) #define PyObject_CheckBuffer(obj) _PyObject_CheckBuffer((PyObject*)(obj))
/* Return 1 if the getbuffer function is available, otherwise /* Return 1 if the getbuffer function is available, otherwise
...@@ -847,7 +847,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ ...@@ -847,7 +847,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
*/ */
// Pyston change: made this a function: // Pyston change: made this a function:
PyAPI_FUNC(bool) _PyIndex_Check(PyObject* o) PYSTON_NOEXCEPT; PyAPI_FUNC(int) _PyIndex_Check(PyObject* o) PYSTON_NOEXCEPT;
#define PyIndex_Check(obj) _PyIndex_Check((PyObject*)(obj)) #define PyIndex_Check(obj) _PyIndex_Check((PyObject*)(obj))
#if 0 #if 0
#define PyIndex_Check(obj) \ #define PyIndex_Check(obj) \
......
...@@ -5,7 +5,7 @@ extern "C" { ...@@ -5,7 +5,7 @@ extern "C" {
#endif #endif
PyAPI_FUNC(mod_ty) PyAST_FromNode(const node *, PyCompilerFlags *flags, PyAPI_FUNC(mod_ty) PyAST_FromNode(const node *, PyCompilerFlags *flags,
const char *, PyArena *); const char *, PyArena *) PYSTON_NOEXCEPT;
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -63,6 +63,9 @@ PyAPI_FUNC(int) PyFile_SoftSpace(PyObject *, int) PYSTON_NOEXCEPT; ...@@ -63,6 +63,9 @@ PyAPI_FUNC(int) PyFile_SoftSpace(PyObject *, int) PYSTON_NOEXCEPT;
PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *) PYSTON_NOEXCEPT; PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *) PYSTON_NOEXCEPT;
PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *) PYSTON_NOEXCEPT; PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *) PYSTON_NOEXCEPT;
// Pyston temporary addition:
PyAPI_FUNC(PyObject *) PyFile_GetEncoding(PyObject *) PYSTON_NOEXCEPT;
/* The default encoding used by the platform file system APIs /* The default encoding used by the platform file system APIs
If non-NULL, this is different than the default encoding for strings If non-NULL, this is different than the default encoding for strings
*/ */
......
...@@ -459,7 +459,7 @@ struct _typeobject { ...@@ -459,7 +459,7 @@ struct _typeobject {
char _ics[32]; char _ics[32];
void* _gcvisit_func; void* _gcvisit_func;
int _attrs_offset; int _attrs_offset;
bool _flags[7]; char _flags[7]; // These are bools in C++
void* _tpp_descr_get; void* _tpp_descr_get;
void* _tpp_hasnext; void* _tpp_hasnext;
void* _tpp_call_capi; void* _tpp_call_capi;
......
...@@ -33,30 +33,30 @@ typedef struct { ...@@ -33,30 +33,30 @@ typedef struct {
PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int, PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int,
perrdetail *); perrdetail *) PYSTON_NOEXCEPT;
PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int, PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int,
char *, char *, perrdetail *); char *, char *, perrdetail *) PYSTON_NOEXCEPT;
PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int, PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int,
perrdetail *, int); perrdetail *, int) PYSTON_NOEXCEPT;
PyAPI_FUNC(node *) PyParser_ParseFileFlags(FILE *, const char *, grammar *, PyAPI_FUNC(node *) PyParser_ParseFileFlags(FILE *, const char *, grammar *,
int, char *, char *, int, char *, char *,
perrdetail *, int); perrdetail *, int) PYSTON_NOEXCEPT;
PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(FILE *, const char *, grammar *, PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(FILE *, const char *, grammar *,
int, char *, char *, int, char *, char *,
perrdetail *, int *); perrdetail *, int *) PYSTON_NOEXCEPT;
PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(const char *, PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(const char *,
const char *, const char *,
grammar *, int, grammar *, int,
perrdetail *, int); perrdetail *, int) PYSTON_NOEXCEPT;
PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(const char *, PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(const char *,
const char *, const char *,
grammar *, int, grammar *, int,
perrdetail *, int *); perrdetail *, int *) PYSTON_NOEXCEPT;
/* Note that he following function is defined in pythonrun.c not parsetok.c. */ /* Note that he following function is defined in pythonrun.c not parsetok.c. */
PyAPI_FUNC(void) PyParser_SetError(perrdetail *); PyAPI_FUNC(void) PyParser_SetError(perrdetail *) PYSTON_NOEXCEPT;
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -1293,7 +1293,7 @@ s_get(void *ptr, Py_ssize_t size) ...@@ -1293,7 +1293,7 @@ s_get(void *ptr, Py_ssize_t size)
size = min(size, (Py_ssize_t)slen); size = min(size, (Py_ssize_t)slen);
// Pyston change: no ob_refcnt // Pyston change: no ob_refcnt
if (false /*result->ob_refcnt == 1*/) { if (0 /*result->ob_refcnt == 1*/) {
/* shorten the result */ /* shorten the result */
_PyString_Resize(&result, size); _PyString_Resize(&result, size);
return result; return result;
......
...@@ -951,7 +951,7 @@ PyObject_ClearWeakRefs(PyObject *object) ...@@ -951,7 +951,7 @@ PyObject_ClearWeakRefs(PyObject *object)
// Pyston change: // Pyston change:
// current is a stack reference to a GC allocated object. If it wasn't null when we fetched it from *list, it won't // current is a stack reference to a GC allocated object. If it wasn't null when we fetched it from *list, it won't
// be collected, and we can trust that it's still valid here. // be collected, and we can trust that it's still valid here.
if (true /*current->ob_refcnt > 0*/) if (1 /*current->ob_refcnt > 0*/)
handle_callback(current, callback); handle_callback(current, callback);
Py_DECREF(callback); Py_DECREF(callback);
} }
...@@ -973,7 +973,7 @@ PyObject_ClearWeakRefs(PyObject *object) ...@@ -973,7 +973,7 @@ PyObject_ClearWeakRefs(PyObject *object)
// Pyston change: // Pyston change:
// current is a stack reference to a GC allocated object. If it wasn't null when we fetched it from *list, it won't // current is a stack reference to a GC allocated object. If it wasn't null when we fetched it from *list, it won't
// be collected, and we can trust that it's still valid here. // be collected, and we can trust that it's still valid here.
if (true /*current->ob_refcnt > 0*/) if (1 /*current->ob_refcnt > 0*/)
{ {
Py_INCREF(current); Py_INCREF(current);
PyTuple_SET_ITEM(tuple, i * 2, (PyObject *) current); PyTuple_SET_ITEM(tuple, i * 2, (PyObject *) current);
......
...@@ -111,7 +111,8 @@ fixstate(grammar *g, state *s) ...@@ -111,7 +111,8 @@ fixstate(grammar *g, state *s)
k++; k++;
if (k < nl) { if (k < nl) {
int i; int i;
s->s_accel = (int *) PyObject_MALLOC((nl-k) * sizeof(int)); // Pyston change:
s->s_accel = (int *) PyGC_AddRoot(PyObject_MALLOC((nl-k) * sizeof(int)));
if (s->s_accel == NULL) { if (s->s_accel == NULL) {
fprintf(stderr, "no mem to add parser accelerators\n"); fprintf(stderr, "no mem to add parser accelerators\n");
exit(1); exit(1);
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "pydebug.h" #include "pydebug.h"
#endif /* PGEN */ #endif /* PGEN */
extern char *PyOS_Readline(FILE *, FILE *, char *); extern char *PyOS_Readline(FILE *, FILE *, const char *);
/* Return malloc'ed string including trailing \n; /* Return malloc'ed string including trailing \n;
empty malloc'ed string for EOF; empty malloc'ed string for EOF;
NULL if interrupted */ NULL if interrupted */
...@@ -783,7 +783,7 @@ tok_stdin_decode(struct tok_state *tok, char **inp) ...@@ -783,7 +783,7 @@ tok_stdin_decode(struct tok_state *tok, char **inp)
if (sysstdin == NULL || !PyFile_Check(sysstdin)) if (sysstdin == NULL || !PyFile_Check(sysstdin))
return 0; return 0;
enc = ((PyFileObject *)sysstdin)->f_encoding; enc = PyFile_GetEncoding(sysstdin);
if (enc == NULL || !PyString_Check(enc)) if (enc == NULL || !PyString_Check(enc))
return 0; return 0;
Py_INCREF(enc); Py_INCREF(enc);
......
...@@ -461,7 +461,7 @@ static PyMethodDef ast_type_methods[] = { ...@@ -461,7 +461,7 @@ static PyMethodDef ast_type_methods[] = {
}; };
static PyTypeObject AST_type = { static PyTypeObject AST_type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0) PyVarObject_HEAD_INIT(/* Pyston change: &PyType_Type */ NULL, 0)
"_ast.AST", "_ast.AST",
sizeof(PyObject), sizeof(PyObject),
0, 0,
...@@ -6779,10 +6779,13 @@ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode) ...@@ -6779,10 +6779,13 @@ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
return res; return res;
} }
// Pyston temporary change: we're not using this file for the python module, at least not yet.
#if 0
int PyAST_Check(PyObject* obj) int PyAST_Check(PyObject* obj)
{ {
init_types(); init_types();
return PyObject_IsInstance(obj, (PyObject*)&AST_type); return PyObject_IsInstance(obj, (PyObject*)&AST_type);
} }
#endif
...@@ -22,8 +22,10 @@ ...@@ -22,8 +22,10 @@
namespace pyston { namespace pyston {
AST_Module* cpythonToPystonAst(mod_ty mod); // Convert a CPython ast object to a Pyston ast object.
// This will also check for certain kinds of "syntax errors" (ex continue not in loop) and will
// throw them as C++ exceptions.
AST_Module* cpythonToPystonAST(mod_ty mod, llvm::StringRef fn);
} }
#endif #endif
...@@ -14,6 +14,16 @@ ...@@ -14,6 +14,16 @@
#include "codegen/irgen/hooks.h" #include "codegen/irgen/hooks.h"
#include "codegen/cpython_ast.h"
// These #defines in Python-ast.h conflict with llvm:
#undef Pass
#undef Module
#undef alias
#undef Option
#undef Name
#undef Attribute
#undef Set
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
......
...@@ -39,12 +39,12 @@ namespace pyston { ...@@ -39,12 +39,12 @@ namespace pyston {
BoxedClass* method_cls; BoxedClass* method_cls;
extern "C" bool _PyIndex_Check(PyObject* obj) noexcept { extern "C" int _PyIndex_Check(PyObject* obj) noexcept {
return (Py_TYPE(obj)->tp_as_number != NULL && PyType_HasFeature(Py_TYPE(obj), Py_TPFLAGS_HAVE_INDEX) return (Py_TYPE(obj)->tp_as_number != NULL && PyType_HasFeature(Py_TYPE(obj), Py_TPFLAGS_HAVE_INDEX)
&& Py_TYPE(obj)->tp_as_number->nb_index != NULL); && Py_TYPE(obj)->tp_as_number->nb_index != NULL);
} }
extern "C" bool _PyObject_CheckBuffer(PyObject* obj) noexcept { extern "C" int _PyObject_CheckBuffer(PyObject* obj) noexcept {
return ((Py_TYPE(obj)->tp_as_buffer != NULL) && (PyType_HasFeature(Py_TYPE(obj), Py_TPFLAGS_HAVE_NEWBUFFER)) return ((Py_TYPE(obj)->tp_as_buffer != NULL) && (PyType_HasFeature(Py_TYPE(obj), Py_TPFLAGS_HAVE_NEWBUFFER))
&& (Py_TYPE(obj)->tp_as_buffer->bf_getbuffer != NULL)); && (Py_TYPE(obj)->tp_as_buffer->bf_getbuffer != NULL));
} }
......
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