Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
1a01b710
Commit
1a01b710
authored
Sep 29, 2015
by
Dong-hee Na
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ellipsis implementation
parent
ac69cfef
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
37 additions
and
5 deletions
+37
-5
src/analysis/type_analysis.cpp
src/analysis/type_analysis.cpp
+2
-0
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+6
-1
src/codegen/compvars.cpp
src/codegen/compvars.cpp
+1
-1
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+8
-0
src/core/types.h
src/core/types.h
+1
-1
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+4
-0
src/runtime/types.h
src/runtime/types.h
+1
-1
test/tests/ellipsis.py
test/tests/ellipsis.py
+0
-1
test/tests/ellipsis_more_test.py
test/tests/ellipsis_more_test.py
+14
-0
No files found.
src/analysis/type_analysis.cpp
View file @
1a01b710
...
...
@@ -196,6 +196,8 @@ private:
}
}
void
*
visit_ellipsis
(
AST_Ellipsis
*
node
)
override
{
return
ELLIPSIS
;
}
void
*
visit_attribute
(
AST_Attribute
*
node
)
override
{
CompilerType
*
t
=
getType
(
node
->
value
);
CompilerType
*
rtn
=
t
->
getattrType
(
node
->
attr
,
false
);
...
...
src/codegen/ast_interpreter.cpp
View file @
1a01b710
...
...
@@ -99,6 +99,7 @@ private:
Value
visit_attribute
(
AST_Attribute
*
node
);
Value
visit_dict
(
AST_Dict
*
node
);
Value
visit_ellipsis
(
AST_Ellipsis
*
node
);
Value
visit_expr
(
AST_expr
*
node
);
Value
visit_expr
(
AST_Expr
*
node
);
Value
visit_extslice
(
AST_ExtSlice
*
node
);
...
...
@@ -549,7 +550,7 @@ Value ASTInterpreter::visit_slice(AST_slice* node) {
case
AST_TYPE
:
:
ExtSlice
:
return
visit_extslice
(
static_cast
<
AST_ExtSlice
*>
(
node
));
case
AST_TYPE
:
:
Ellipsis
:
RELEASE_ASSERT
(
0
,
"not implemented"
);
return
visit_ellipsis
(
static_cast
<
AST_Ellipsis
*>
(
node
)
);
break
;
case
AST_TYPE
:
:
Index
:
return
visit_index
(
static_cast
<
AST_Index
*>
(
node
));
...
...
@@ -561,6 +562,10 @@ Value ASTInterpreter::visit_slice(AST_slice* node) {
return
Value
();
}
Value
ASTInterpreter
::
visit_ellipsis
(
AST_Ellipsis
*
node
)
{
return
Value
(
Ellipsis
,
jit
?
jit
->
imm
(
Ellipsis
)
:
NULL
);
}
Value
ASTInterpreter
::
visit_slice
(
AST_Slice
*
node
)
{
Value
lower
=
node
->
lower
?
visit_expr
(
node
->
lower
)
:
getNone
();
Value
upper
=
node
->
upper
?
visit_expr
(
node
->
upper
)
:
getNone
();
...
...
src/codegen/compvars.cpp
View file @
1a01b710
...
...
@@ -1966,7 +1966,7 @@ public:
}
};
std
::
unordered_map
<
BoxedClass
*
,
NormalObjectType
*>
NormalObjectType
::
made
;
ConcreteCompilerType
*
STR
,
*
BOXED_INT
,
*
BOXED_FLOAT
,
*
BOXED_BOOL
,
*
NONE
;
ConcreteCompilerType
*
STR
,
*
BOXED_INT
,
*
BOXED_FLOAT
,
*
BOXED_BOOL
,
*
NONE
,
*
ELLIPSIS
;
class
ClosureType
:
public
ConcreteCompilerType
{
public:
...
...
src/codegen/irgen/irgenerator.cpp
View file @
1a01b710
...
...
@@ -1073,6 +1073,11 @@ private:
return
rtn
;
}
ConcreteCompilerVariable
*
getEllipsis
()
{
llvm
::
Constant
*
ellipsis
=
embedRelocatablePtr
(
Ellipsis
,
g
.
llvm_value_type_ptr
,
"cEllipsis"
);
auto
ellipsis_cls
=
Ellipsis
->
cls
;
return
new
ConcreteCompilerVariable
(
typeFromClass
(
ellipsis_cls
),
ellipsis
,
false
);
}
ConcreteCompilerVariable
*
getNone
()
{
llvm
::
Constant
*
none
=
embedRelocatablePtr
(
None
,
g
.
llvm_value_type_ptr
,
"cNone"
);
return
new
ConcreteCompilerVariable
(
typeFromClass
(
none_cls
),
none
,
false
);
...
...
@@ -1591,6 +1596,9 @@ private:
case
AST_TYPE
:
:
ExtSlice
:
rtn
=
evalExtSlice
(
ast_cast
<
AST_ExtSlice
>
(
node
),
unw_info
);
break
;
case
AST_TYPE
:
:
Ellipsis
:
rtn
=
getEllipsis
();
break
;
case
AST_TYPE
:
:
Index
:
rtn
=
evalIndex
(
ast_cast
<
AST_Index
>
(
node
),
unw_info
);
break
;
...
...
src/core/types.h
View file @
1a01b710
...
...
@@ -88,7 +88,7 @@ template <class V> class ValuedCompilerType;
typedef
ValuedCompilerType
<
llvm
::
Value
*>
ConcreteCompilerType
;
ConcreteCompilerType
*
typeFromClass
(
BoxedClass
*
);
extern
ConcreteCompilerType
*
INT
,
*
BOXED_INT
,
*
LONG
,
*
FLOAT
,
*
BOXED_FLOAT
,
*
UNKNOWN
,
*
BOOL
,
*
STR
,
*
NONE
,
*
LIST
,
*
SLICE
,
extern
ConcreteCompilerType
*
INT
,
*
BOXED_INT
,
*
LONG
,
*
FLOAT
,
*
BOXED_FLOAT
,
*
UNKNOWN
,
*
BOOL
,
*
STR
,
*
NONE
,
*
LIST
,
*
SLICE
,
*
ELLIPSIS
,
*
MODULE
,
*
DICT
,
*
BOOL
,
*
BOXED_BOOL
,
*
BOXED_TUPLE
,
*
SET
,
*
FROZENSET
,
*
CLOSURE
,
*
GENERATOR
,
*
BOXED_COMPLEX
,
*
FRAME_INFO
;
extern
CompilerType
*
UNDEF
;
...
...
src/runtime/builtin_modules/builtins.cpp
View file @
1a01b710
...
...
@@ -1250,6 +1250,9 @@ extern "C" PyObject* PyEval_GetBuiltins(void) noexcept {
return
builtins_module
;
}
Box
*
ellipsisRepr
(
Box
*
self
)
{
return
boxString
(
"Ellipsis"
);
}
Box
*
divmod
(
Box
*
lhs
,
Box
*
rhs
)
{
return
binopInternal
(
lhs
,
rhs
,
AST_TYPE
::
DivMod
,
false
,
NULL
);
}
...
...
@@ -1529,6 +1532,7 @@ void setupBuiltins() {
"the `nil' object; Ellipsis represents `...' in slices."
);
BoxedClass
*
ellipsis_cls
=
BoxedClass
::
create
(
type_cls
,
object_cls
,
NULL
,
0
,
0
,
sizeof
(
Box
),
false
,
"ellipsis"
);
ellipsis_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
ellipsisRepr
,
STR
,
1
)));
Ellipsis
=
new
(
ellipsis_cls
)
Box
();
assert
(
Ellipsis
->
cls
);
gc
::
registerPermanentRoot
(
Ellipsis
);
...
...
src/runtime/types.h
View file @
1a01b710
...
...
@@ -128,7 +128,7 @@ extern BoxedClass* object_cls, *type_cls, *bool_cls, *int_cls, *long_cls, *float
extern
std
::
vector
<
BoxedClass
*>
exception_types
;
extern
"C"
{
extern
Box
*
None
,
*
NotImplemented
,
*
True
,
*
False
;
extern
Box
*
None
,
*
NotImplemented
,
*
True
,
*
False
,
*
Ellipsis
;
}
extern
"C"
{
extern
Box
*
repr_obj
,
*
len_obj
,
*
hash_obj
,
*
range_obj
,
*
abs_obj
,
*
min_obj
,
*
max_obj
,
*
open_obj
,
*
id_obj
,
*
chr_obj
,
...
...
test/tests/ellipsis.py
View file @
1a01b710
print
type
(
Ellipsis
)
print
type
(
Ellipsis
).
__base__
test/tests/ellipsis_more_test.py
0 → 100644
View file @
1a01b710
class
TestEllipsis
(
object
):
def
__getitem__
(
self
,
item
):
if
item
is
Ellipsis
:
return
"Ellipsis"
else
:
return
"return %r items"
%
item
print
Ellipsis
v
=
Ellipsis
print
v
print
type
(
v
)
x
=
TestEllipsis
()
print
x
[
2
]
print
x
[...]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment