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
7a44bcaf
Commit
7a44bcaf
authored
May 05, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #48 from undingen/backtick
Implement backtick (repr)
parents
3580fc81
f2d5277e
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
99 additions
and
13 deletions
+99
-13
src/analysis/scoping_analysis.cpp
src/analysis/scoping_analysis.cpp
+1
-0
src/analysis/type_analysis.cpp
src/analysis/type_analysis.cpp
+4
-0
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+18
-1
src/codegen/parser.cpp
src/codegen/parser.cpp
+11
-0
src/codegen/runtime_hooks.cpp
src/codegen/runtime_hooks.cpp
+1
-0
src/codegen/runtime_hooks.h
src/codegen/runtime_hooks.h
+1
-1
src/core/ast.cpp
src/core/ast.cpp
+17
-0
src/core/ast.h
src/core/ast.h
+16
-0
src/core/cfg.cpp
src/core/cfg.cpp
+11
-0
src/runtime/dict.cpp
src/runtime/dict.cpp
+3
-3
src/runtime/inline/link_forcer.cpp
src/runtime/inline/link_forcer.cpp
+1
-0
src/runtime/list.cpp
src/runtime/list.cpp
+1
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+1
-1
src/runtime/objmodel.h
src/runtime/objmodel.h
+1
-1
src/runtime/set.cpp
src/runtime/set.cpp
+1
-1
src/runtime/tuple.cpp
src/runtime/tuple.cpp
+1
-1
src/runtime/types.cpp
src/runtime/types.cpp
+3
-3
test/tests/backtick.py
test/tests/backtick.py
+7
-0
No files found.
src/analysis/scoping_analysis.cpp
View file @
7a44bcaf
...
@@ -189,6 +189,7 @@ class NameCollectorVisitor : public ASTVisitor {
...
@@ -189,6 +189,7 @@ class NameCollectorVisitor : public ASTVisitor {
virtual
bool
visit_num
(
AST_Num
*
node
)
{
return
false
;
}
virtual
bool
visit_num
(
AST_Num
*
node
)
{
return
false
;
}
virtual
bool
visit_pass
(
AST_Pass
*
node
)
{
return
false
;
}
virtual
bool
visit_pass
(
AST_Pass
*
node
)
{
return
false
;
}
virtual
bool
visit_print
(
AST_Print
*
node
)
{
return
false
;
}
virtual
bool
visit_print
(
AST_Print
*
node
)
{
return
false
;
}
virtual
bool
visit_repr
(
AST_Repr
*
node
)
{
return
false
;
}
virtual
bool
visit_return
(
AST_Return
*
node
)
{
return
false
;
}
virtual
bool
visit_return
(
AST_Return
*
node
)
{
return
false
;
}
virtual
bool
visit_slice
(
AST_Slice
*
node
)
{
return
false
;
}
virtual
bool
visit_slice
(
AST_Slice
*
node
)
{
return
false
;
}
virtual
bool
visit_str
(
AST_Str
*
node
)
{
return
false
;
}
virtual
bool
visit_str
(
AST_Str
*
node
)
{
return
false
;
}
...
...
src/analysis/type_analysis.cpp
View file @
7a44bcaf
...
@@ -358,6 +358,10 @@ class BasicBlockTypePropagator : public ExprVisitor, public StmtVisitor {
...
@@ -358,6 +358,10 @@ class BasicBlockTypePropagator : public ExprVisitor, public StmtVisitor {
abort
();
abort
();
}
}
virtual
void
*
visit_repr
(
AST_Repr
*
node
)
{
return
STR
;
}
virtual
void
*
visit_slice
(
AST_Slice
*
node
)
{
virtual
void
*
visit_slice
(
AST_Slice
*
node
)
{
return
SLICE
;
return
SLICE
;
}
}
...
...
src/codegen/irgen/irgenerator.cpp
View file @
7a44bcaf
...
@@ -707,6 +707,20 @@ class IRGeneratorImpl : public IRGenerator {
...
@@ -707,6 +707,20 @@ class IRGeneratorImpl : public IRGenerator {
RELEASE_ASSERT
(
0
,
""
);
RELEASE_ASSERT
(
0
,
""
);
}
}
CompilerVariable
*
evalRepr
(
AST_Repr
*
node
)
{
assert
(
state
!=
PARTIAL
);
CompilerVariable
*
var
=
evalExpr
(
node
->
value
);
ConcreteCompilerVariable
*
cvar
=
var
->
makeConverted
(
emitter
,
var
->
getBoxType
());
var
->
decvref
(
emitter
);
std
::
vector
<
llvm
::
Value
*>
args
{
cvar
->
getValue
()};
llvm
::
Value
*
rtn
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
repr
,
args
);
cvar
->
decvref
(
emitter
);
return
new
ConcreteCompilerVariable
(
STR
,
rtn
,
true
);
}
CompilerVariable
*
evalSlice
(
AST_Slice
*
node
)
{
CompilerVariable
*
evalSlice
(
AST_Slice
*
node
)
{
assert
(
state
!=
PARTIAL
);
assert
(
state
!=
PARTIAL
);
...
@@ -848,6 +862,9 @@ class IRGeneratorImpl : public IRGenerator {
...
@@ -848,6 +862,9 @@ class IRGeneratorImpl : public IRGenerator {
case
AST_TYPE
:
:
Num
:
case
AST_TYPE
:
:
Num
:
rtn
=
evalNum
(
ast_cast
<
AST_Num
>
(
node
));
rtn
=
evalNum
(
ast_cast
<
AST_Num
>
(
node
));
break
;
break
;
case
AST_TYPE
:
:
Repr
:
rtn
=
evalRepr
(
ast_cast
<
AST_Repr
>
(
node
));
break
;
case
AST_TYPE
:
:
Slice
:
case
AST_TYPE
:
:
Slice
:
rtn
=
evalSlice
(
ast_cast
<
AST_Slice
>
(
node
));
rtn
=
evalSlice
(
ast_cast
<
AST_Slice
>
(
node
));
break
;
break
;
...
@@ -867,7 +884,7 @@ class IRGeneratorImpl : public IRGenerator {
...
@@ -867,7 +884,7 @@ class IRGeneratorImpl : public IRGenerator {
rtn
=
evalClsAttribute
(
ast_cast
<
AST_ClsAttribute
>
(
node
));
rtn
=
evalClsAttribute
(
ast_cast
<
AST_ClsAttribute
>
(
node
));
break
;
break
;
default:
default:
printf
(
"Unhandled expr type: %d (irgen.cpp:"
STRINGIFY
(
__LINE__
)
")
\n
"
,
node
->
type
);
printf
(
"Unhandled expr type: %d (irgen
erator
.cpp:"
STRINGIFY
(
__LINE__
)
")
\n
"
,
node
->
type
);
exit
(
1
);
exit
(
1
);
}
}
...
...
src/codegen/parser.cpp
View file @
7a44bcaf
...
@@ -493,6 +493,15 @@ AST_Num* read_num(BufferedReader *reader) {
...
@@ -493,6 +493,15 @@ AST_Num* read_num(BufferedReader *reader) {
return
rtn
;
return
rtn
;
}
}
AST_Repr
*
read_repr
(
BufferedReader
*
reader
)
{
AST_Repr
*
rtn
=
new
AST_Repr
();
rtn
->
col_offset
=
readColOffset
(
reader
);
rtn
->
lineno
=
reader
->
readULL
();
rtn
->
value
=
readASTExpr
(
reader
);
return
rtn
;
}
AST_Pass
*
read_pass
(
BufferedReader
*
reader
)
{
AST_Pass
*
read_pass
(
BufferedReader
*
reader
)
{
AST_Pass
*
rtn
=
new
AST_Pass
();
AST_Pass
*
rtn
=
new
AST_Pass
();
...
@@ -636,6 +645,8 @@ AST_expr* readASTExpr(BufferedReader *reader) {
...
@@ -636,6 +645,8 @@ AST_expr* readASTExpr(BufferedReader *reader) {
return
read_name
(
reader
);
return
read_name
(
reader
);
case
AST_TYPE
:
:
Num
:
case
AST_TYPE
:
:
Num
:
return
read_num
(
reader
);
return
read_num
(
reader
);
case
AST_TYPE
:
:
Repr
:
return
read_repr
(
reader
);
case
AST_TYPE
:
:
Slice
:
case
AST_TYPE
:
:
Slice
:
return
read_slice
(
reader
);
return
read_slice
(
reader
);
case
AST_TYPE
:
:
Str
:
case
AST_TYPE
:
:
Str
:
...
...
src/codegen/runtime_hooks.cpp
View file @
7a44bcaf
...
@@ -159,6 +159,7 @@ void initGlobalFuncs(GlobalState &g) {
...
@@ -159,6 +159,7 @@ void initGlobalFuncs(GlobalState &g) {
GET
(
getclsattr
);
GET
(
getclsattr
);
GET
(
unaryop
);
GET
(
unaryop
);
GET
(
import
);
GET
(
import
);
GET
(
repr
);
GET
(
checkUnpackingLength
);
GET
(
checkUnpackingLength
);
GET
(
raiseAttributeError
);
GET
(
raiseAttributeError
);
...
...
src/codegen/runtime_hooks.h
View file @
7a44bcaf
...
@@ -21,7 +21,7 @@ struct GlobalFuncs {
...
@@ -21,7 +21,7 @@ struct GlobalFuncs {
llvm
::
Value
*
printf
,
*
my_assert
,
*
malloc
,
*
free
;
llvm
::
Value
*
printf
,
*
my_assert
,
*
malloc
,
*
free
;
llvm
::
Value
*
boxInt
,
*
unboxInt
,
*
boxFloat
,
*
unboxFloat
,
*
boxStringPtr
,
*
boxCLFunction
,
*
unboxCLFunction
,
*
boxInstanceMethod
,
*
boxBool
,
*
unboxBool
,
*
createTuple
,
*
createDict
,
*
createList
,
*
createSlice
,
*
createClass
;
llvm
::
Value
*
boxInt
,
*
unboxInt
,
*
boxFloat
,
*
unboxFloat
,
*
boxStringPtr
,
*
boxCLFunction
,
*
unboxCLFunction
,
*
boxInstanceMethod
,
*
boxBool
,
*
unboxBool
,
*
createTuple
,
*
createDict
,
*
createList
,
*
createSlice
,
*
createClass
;
llvm
::
Value
*
getattr
,
*
setattr
,
*
print
,
*
nonzero
,
*
binop
,
*
compare
,
*
augbinop
,
*
unboxedLen
,
*
getitem
,
*
getclsattr
,
*
getGlobal
,
*
setitem
,
*
unaryop
,
*
import
;
llvm
::
Value
*
getattr
,
*
setattr
,
*
print
,
*
nonzero
,
*
binop
,
*
compare
,
*
augbinop
,
*
unboxedLen
,
*
getitem
,
*
getclsattr
,
*
getGlobal
,
*
setitem
,
*
unaryop
,
*
import
,
*
repr
;
llvm
::
Value
*
checkUnpackingLength
,
*
raiseAttributeError
,
*
raiseAttributeErrorStr
,
*
raiseNotIterableError
,
*
assertNameDefined
,
*
assertFail
;
llvm
::
Value
*
checkUnpackingLength
,
*
raiseAttributeError
,
*
raiseAttributeErrorStr
,
*
raiseNotIterableError
,
*
assertNameDefined
,
*
assertFail
;
llvm
::
Value
*
printFloat
,
*
listAppendInternal
;
llvm
::
Value
*
printFloat
,
*
listAppendInternal
;
llvm
::
Value
*
dump
;
llvm
::
Value
*
dump
;
...
...
src/core/ast.cpp
View file @
7a44bcaf
...
@@ -529,6 +529,15 @@ void* AST_Num::accept_expr(ExprVisitor *v) {
...
@@ -529,6 +529,15 @@ void* AST_Num::accept_expr(ExprVisitor *v) {
return
v
->
visit_num
(
this
);
return
v
->
visit_num
(
this
);
}
}
void
AST_Repr
::
accept
(
ASTVisitor
*
v
)
{
bool
skip
=
v
->
visit_repr
(
this
);
}
void
*
AST_Repr
::
accept_expr
(
ExprVisitor
*
v
)
{
return
v
->
visit_repr
(
this
);
}
void
AST_Pass
::
accept
(
ASTVisitor
*
v
)
{
void
AST_Pass
::
accept
(
ASTVisitor
*
v
)
{
bool
skip
=
v
->
visit_pass
(
this
);
bool
skip
=
v
->
visit_pass
(
this
);
}
}
...
@@ -1104,6 +1113,13 @@ bool PrintVisitor::visit_print(AST_Print *node) {
...
@@ -1104,6 +1113,13 @@ bool PrintVisitor::visit_print(AST_Print *node) {
return
true
;
return
true
;
}
}
bool
PrintVisitor
::
visit_repr
(
AST_Repr
*
node
)
{
printf
(
"`"
);
node
->
value
->
accept
(
this
);
printf
(
"`"
);
return
true
;
}
bool
PrintVisitor
::
visit_return
(
AST_Return
*
node
)
{
bool
PrintVisitor
::
visit_return
(
AST_Return
*
node
)
{
printf
(
"return "
);
printf
(
"return "
);
return
false
;
return
false
;
...
@@ -1280,6 +1296,7 @@ class FlattenVisitor : public ASTVisitor {
...
@@ -1280,6 +1296,7 @@ class FlattenVisitor : public ASTVisitor {
virtual
bool
visit_num
(
AST_Num
*
node
)
{
output
->
push_back
(
node
);
return
false
;
}
virtual
bool
visit_num
(
AST_Num
*
node
)
{
output
->
push_back
(
node
);
return
false
;
}
virtual
bool
visit_pass
(
AST_Pass
*
node
)
{
output
->
push_back
(
node
);
return
false
;
}
virtual
bool
visit_pass
(
AST_Pass
*
node
)
{
output
->
push_back
(
node
);
return
false
;
}
virtual
bool
visit_print
(
AST_Print
*
node
)
{
output
->
push_back
(
node
);
return
false
;
}
virtual
bool
visit_print
(
AST_Print
*
node
)
{
output
->
push_back
(
node
);
return
false
;
}
virtual
bool
visit_repr
(
AST_Repr
*
node
)
{
output
->
push_back
(
node
);
return
false
;
}
virtual
bool
visit_return
(
AST_Return
*
node
)
{
output
->
push_back
(
node
);
return
false
;
}
virtual
bool
visit_return
(
AST_Return
*
node
)
{
output
->
push_back
(
node
);
return
false
;
}
virtual
bool
visit_slice
(
AST_Slice
*
node
)
{
output
->
push_back
(
node
);
return
false
;
}
virtual
bool
visit_slice
(
AST_Slice
*
node
)
{
output
->
push_back
(
node
);
return
false
;
}
virtual
bool
visit_str
(
AST_Str
*
node
)
{
output
->
push_back
(
node
);
return
false
;
}
virtual
bool
visit_str
(
AST_Str
*
node
)
{
output
->
push_back
(
node
);
return
false
;
}
...
...
src/core/ast.h
View file @
7a44bcaf
...
@@ -560,6 +560,18 @@ class AST_Num : public AST_expr {
...
@@ -560,6 +560,18 @@ class AST_Num : public AST_expr {
static
const
AST_TYPE
::
AST_TYPE
TYPE
=
AST_TYPE
::
Num
;
static
const
AST_TYPE
::
AST_TYPE
TYPE
=
AST_TYPE
::
Num
;
};
};
class
AST_Repr
:
public
AST_expr
{
public:
AST_expr
*
value
;
virtual
void
accept
(
ASTVisitor
*
v
);
virtual
void
*
accept_expr
(
ExprVisitor
*
v
);
AST_Repr
()
:
AST_expr
(
AST_TYPE
::
Repr
)
{}
static
const
AST_TYPE
::
AST_TYPE
TYPE
=
AST_TYPE
::
Repr
;
};
class
AST_Pass
:
public
AST_stmt
{
class
AST_Pass
:
public
AST_stmt
{
public:
public:
virtual
void
accept
(
ASTVisitor
*
v
);
virtual
void
accept
(
ASTVisitor
*
v
);
...
@@ -776,6 +788,7 @@ class ASTVisitor {
...
@@ -776,6 +788,7 @@ class ASTVisitor {
virtual
bool
visit_num
(
AST_Num
*
node
)
{
assert
(
0
);
abort
();
}
virtual
bool
visit_num
(
AST_Num
*
node
)
{
assert
(
0
);
abort
();
}
virtual
bool
visit_pass
(
AST_Pass
*
node
)
{
assert
(
0
);
abort
();
}
virtual
bool
visit_pass
(
AST_Pass
*
node
)
{
assert
(
0
);
abort
();
}
virtual
bool
visit_print
(
AST_Print
*
node
)
{
assert
(
0
);
abort
();
}
virtual
bool
visit_print
(
AST_Print
*
node
)
{
assert
(
0
);
abort
();
}
virtual
bool
visit_repr
(
AST_Repr
*
node
)
{
assert
(
0
);
abort
();
}
virtual
bool
visit_return
(
AST_Return
*
node
)
{
assert
(
0
);
abort
();
}
virtual
bool
visit_return
(
AST_Return
*
node
)
{
assert
(
0
);
abort
();
}
virtual
bool
visit_slice
(
AST_Slice
*
node
)
{
assert
(
0
);
abort
();
}
virtual
bool
visit_slice
(
AST_Slice
*
node
)
{
assert
(
0
);
abort
();
}
virtual
bool
visit_str
(
AST_Str
*
node
)
{
assert
(
0
);
abort
();
}
virtual
bool
visit_str
(
AST_Str
*
node
)
{
assert
(
0
);
abort
();
}
...
@@ -828,6 +841,7 @@ class NoopASTVisitor : public ASTVisitor {
...
@@ -828,6 +841,7 @@ class NoopASTVisitor : public ASTVisitor {
virtual
bool
visit_num
(
AST_Num
*
node
)
{
return
false
;
}
virtual
bool
visit_num
(
AST_Num
*
node
)
{
return
false
;
}
virtual
bool
visit_pass
(
AST_Pass
*
node
)
{
return
false
;
}
virtual
bool
visit_pass
(
AST_Pass
*
node
)
{
return
false
;
}
virtual
bool
visit_print
(
AST_Print
*
node
)
{
return
false
;
}
virtual
bool
visit_print
(
AST_Print
*
node
)
{
return
false
;
}
virtual
bool
visit_repr
(
AST_Repr
*
node
)
{
return
false
;
}
virtual
bool
visit_return
(
AST_Return
*
node
)
{
return
false
;
}
virtual
bool
visit_return
(
AST_Return
*
node
)
{
return
false
;
}
virtual
bool
visit_slice
(
AST_Slice
*
node
)
{
return
false
;
}
virtual
bool
visit_slice
(
AST_Slice
*
node
)
{
return
false
;
}
virtual
bool
visit_str
(
AST_Str
*
node
)
{
return
false
;
}
virtual
bool
visit_str
(
AST_Str
*
node
)
{
return
false
;
}
...
@@ -860,6 +874,7 @@ class ExprVisitor {
...
@@ -860,6 +874,7 @@ class ExprVisitor {
virtual
void
*
visit_listcomp
(
AST_ListComp
*
node
)
{
assert
(
0
);
abort
();
}
virtual
void
*
visit_listcomp
(
AST_ListComp
*
node
)
{
assert
(
0
);
abort
();
}
virtual
void
*
visit_name
(
AST_Name
*
node
)
{
assert
(
0
);
abort
();
}
virtual
void
*
visit_name
(
AST_Name
*
node
)
{
assert
(
0
);
abort
();
}
virtual
void
*
visit_num
(
AST_Num
*
node
)
{
assert
(
0
);
abort
();
}
virtual
void
*
visit_num
(
AST_Num
*
node
)
{
assert
(
0
);
abort
();
}
virtual
void
*
visit_repr
(
AST_Repr
*
node
)
{
assert
(
0
);
abort
();
}
virtual
void
*
visit_slice
(
AST_Slice
*
node
)
{
assert
(
0
);
abort
();
}
virtual
void
*
visit_slice
(
AST_Slice
*
node
)
{
assert
(
0
);
abort
();
}
virtual
void
*
visit_str
(
AST_Str
*
node
)
{
assert
(
0
);
abort
();
}
virtual
void
*
visit_str
(
AST_Str
*
node
)
{
assert
(
0
);
abort
();
}
virtual
void
*
visit_subscript
(
AST_Subscript
*
node
)
{
assert
(
0
);
abort
();
}
virtual
void
*
visit_subscript
(
AST_Subscript
*
node
)
{
assert
(
0
);
abort
();
}
...
@@ -938,6 +953,7 @@ class PrintVisitor : public ASTVisitor {
...
@@ -938,6 +953,7 @@ class PrintVisitor : public ASTVisitor {
virtual
bool
visit_num
(
AST_Num
*
node
);
virtual
bool
visit_num
(
AST_Num
*
node
);
virtual
bool
visit_pass
(
AST_Pass
*
node
);
virtual
bool
visit_pass
(
AST_Pass
*
node
);
virtual
bool
visit_print
(
AST_Print
*
node
);
virtual
bool
visit_print
(
AST_Print
*
node
);
virtual
bool
visit_repr
(
AST_Repr
*
node
);
virtual
bool
visit_return
(
AST_Return
*
node
);
virtual
bool
visit_return
(
AST_Return
*
node
);
virtual
bool
visit_slice
(
AST_Slice
*
node
);
virtual
bool
visit_slice
(
AST_Slice
*
node
);
virtual
bool
visit_str
(
AST_Str
*
node
);
virtual
bool
visit_str
(
AST_Str
*
node
);
...
...
src/core/cfg.cpp
View file @
7a44bcaf
...
@@ -542,6 +542,14 @@ class CFGVisitor : public ASTVisitor {
...
@@ -542,6 +542,14 @@ class CFGVisitor : public ASTVisitor {
return
makeName
(
rtn_name
,
AST_TYPE
::
Load
);
return
makeName
(
rtn_name
,
AST_TYPE
::
Load
);
};
};
AST_expr
*
remapRepr
(
AST_Repr
*
node
)
{
AST_Repr
*
rtn
=
new
AST_Repr
();
rtn
->
lineno
=
node
->
lineno
;
rtn
->
col_offset
=
node
->
col_offset
;
rtn
->
value
=
remapExpr
(
node
->
value
);
return
rtn
;
}
AST_expr
*
remapSlice
(
AST_Slice
*
node
)
{
AST_expr
*
remapSlice
(
AST_Slice
*
node
)
{
AST_Slice
*
rtn
=
new
AST_Slice
();
AST_Slice
*
rtn
=
new
AST_Slice
();
rtn
->
lineno
=
node
->
lineno
;
rtn
->
lineno
=
node
->
lineno
;
...
@@ -627,6 +635,9 @@ class CFGVisitor : public ASTVisitor {
...
@@ -627,6 +635,9 @@ class CFGVisitor : public ASTVisitor {
return
node
;
return
node
;
case
AST_TYPE
:
:
Num
:
case
AST_TYPE
:
:
Num
:
return
node
;
return
node
;
case
AST_TYPE
:
:
Repr
:
rtn
=
remapRepr
(
ast_cast
<
AST_Repr
>
(
node
));
break
;
case
AST_TYPE
:
:
Slice
:
case
AST_TYPE
:
:
Slice
:
rtn
=
remapSlice
(
ast_cast
<
AST_Slice
>
(
node
));
rtn
=
remapSlice
(
ast_cast
<
AST_Slice
>
(
node
));
break
;
break
;
...
...
src/runtime/dict.cpp
View file @
7a44bcaf
...
@@ -34,8 +34,8 @@ Box* dictRepr(BoxedDict* self) {
...
@@ -34,8 +34,8 @@ Box* dictRepr(BoxedDict* self) {
}
}
first
=
false
;
first
=
false
;
BoxedString
*
k
=
repr
(
p
.
first
);
BoxedString
*
k
=
static_cast
<
BoxedString
*>
(
repr
(
p
.
first
)
);
BoxedString
*
v
=
repr
(
p
.
second
);
BoxedString
*
v
=
static_cast
<
BoxedString
*>
(
repr
(
p
.
second
)
);
chars
.
insert
(
chars
.
end
(),
k
->
s
.
begin
(),
k
->
s
.
end
());
chars
.
insert
(
chars
.
end
(),
k
->
s
.
begin
(),
k
->
s
.
end
());
chars
.
push_back
(
':'
);
chars
.
push_back
(
':'
);
chars
.
push_back
(
' '
);
chars
.
push_back
(
' '
);
...
@@ -79,7 +79,7 @@ Box* dictGetitem(BoxedDict* self, Box* k) {
...
@@ -79,7 +79,7 @@ Box* dictGetitem(BoxedDict* self, Box* k) {
Box
*
&
pos
=
self
->
d
[
k
];
Box
*
&
pos
=
self
->
d
[
k
];
if
(
pos
==
NULL
)
{
if
(
pos
==
NULL
)
{
BoxedString
*
s
=
repr
(
k
);
BoxedString
*
s
=
static_cast
<
BoxedString
*>
(
repr
(
k
)
);
fprintf
(
stderr
,
"KeyError: %s
\n
"
,
s
->
s
.
c_str
());
fprintf
(
stderr
,
"KeyError: %s
\n
"
,
s
->
s
.
c_str
());
raiseExc
();
raiseExc
();
}
}
...
...
src/runtime/inline/link_forcer.cpp
View file @
7a44bcaf
...
@@ -70,6 +70,7 @@ void force() {
...
@@ -70,6 +70,7 @@ void force() {
FORCE
(
setitem
);
FORCE
(
setitem
);
FORCE
(
unaryop
);
FORCE
(
unaryop
);
FORCE
(
import
);
FORCE
(
import
);
FORCE
(
repr
);
FORCE
(
checkUnpackingLength
);
FORCE
(
checkUnpackingLength
);
FORCE
(
raiseAttributeError
);
FORCE
(
raiseAttributeError
);
...
...
src/runtime/list.cpp
View file @
7a44bcaf
...
@@ -41,7 +41,7 @@ extern "C" Box* listRepr(BoxedList* self) {
...
@@ -41,7 +41,7 @@ extern "C" Box* listRepr(BoxedList* self) {
if
(
i
>
0
)
if
(
i
>
0
)
os
<<
", "
;
os
<<
", "
;
BoxedString
*
s
=
repr
(
self
->
elts
->
elts
[
i
]
);
BoxedString
*
s
=
static_cast
<
BoxedString
*>
(
repr
(
self
->
elts
->
elts
[
i
])
);
os
<<
s
->
s
;
os
<<
s
->
s
;
}
}
os
<<
']'
;
os
<<
']'
;
...
...
src/runtime/objmodel.cpp
View file @
7a44bcaf
...
@@ -949,7 +949,7 @@ extern "C" BoxedString* str(Box* obj) {
...
@@ -949,7 +949,7 @@ extern "C" BoxedString* str(Box* obj) {
return
static_cast
<
BoxedString
*>
(
obj
);
return
static_cast
<
BoxedString
*>
(
obj
);
}
}
extern
"C"
Box
edString
*
repr
(
Box
*
obj
)
{
extern
"C"
Box
*
repr
(
Box
*
obj
)
{
static
StatCounter
slowpath_repr
(
"slowpath_repr"
);
static
StatCounter
slowpath_repr
(
"slowpath_repr"
);
slowpath_repr
.
log
();
slowpath_repr
.
log
();
...
...
src/runtime/objmodel.h
View file @
7a44bcaf
...
@@ -39,7 +39,7 @@ extern "C" bool nonzero(Box* obj);
...
@@ -39,7 +39,7 @@ extern "C" bool nonzero(Box* obj);
extern
"C"
Box
*
runtimeCall
(
Box
*
,
int64_t
,
Box
*
,
Box
*
,
Box
*
,
Box
**
);
extern
"C"
Box
*
runtimeCall
(
Box
*
,
int64_t
,
Box
*
,
Box
*
,
Box
*
,
Box
**
);
extern
"C"
Box
*
callattr
(
Box
*
,
std
::
string
*
,
bool
,
int64_t
,
Box
*
,
Box
*
,
Box
*
,
Box
**
);
extern
"C"
Box
*
callattr
(
Box
*
,
std
::
string
*
,
bool
,
int64_t
,
Box
*
,
Box
*
,
Box
*
,
Box
**
);
extern
"C"
BoxedString
*
str
(
Box
*
obj
);
extern
"C"
BoxedString
*
str
(
Box
*
obj
);
extern
"C"
Box
edString
*
repr
(
Box
*
obj
);
extern
"C"
Box
*
repr
(
Box
*
obj
);
extern
"C"
BoxedInt
*
hash
(
Box
*
obj
);
extern
"C"
BoxedInt
*
hash
(
Box
*
obj
);
//extern "C" Box* abs_(Box* obj);
//extern "C" Box* abs_(Box* obj);
//extern "C" Box* min_(Box* o0, Box* o1);
//extern "C" Box* min_(Box* o0, Box* o1);
...
...
src/runtime/set.cpp
View file @
7a44bcaf
...
@@ -107,7 +107,7 @@ Box* setRepr(BoxedSet* self) {
...
@@ -107,7 +107,7 @@ Box* setRepr(BoxedSet* self) {
if
(
!
first
)
{
if
(
!
first
)
{
os
<<
", "
;
os
<<
", "
;
}
}
os
<<
repr
(
elt
)
->
s
;
os
<<
static_cast
<
BoxedString
*>
(
repr
(
elt
)
)
->
s
;
first
=
false
;
first
=
false
;
}
}
os
<<
"])"
;
os
<<
"])"
;
...
...
src/runtime/tuple.cpp
View file @
7a44bcaf
...
@@ -72,7 +72,7 @@ Box* tupleRepr(BoxedTuple *t) {
...
@@ -72,7 +72,7 @@ Box* tupleRepr(BoxedTuple *t) {
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
if
(
i
)
os
<<
", "
;
if
(
i
)
os
<<
", "
;
BoxedString
*
elt_repr
=
repr
(
t
->
elts
[
i
]
);
BoxedString
*
elt_repr
=
static_cast
<
BoxedString
*>
(
repr
(
t
->
elts
[
i
])
);
os
<<
elt_repr
->
s
;
os
<<
elt_repr
->
s
;
}
}
if
(
n
==
1
)
os
<<
","
;
if
(
n
==
1
)
os
<<
","
;
...
...
src/runtime/types.cpp
View file @
7a44bcaf
...
@@ -274,9 +274,9 @@ Box* instancemethodRepr(BoxedInstanceMethod* self) {
...
@@ -274,9 +274,9 @@ Box* instancemethodRepr(BoxedInstanceMethod* self) {
}
}
Box
*
sliceRepr
(
BoxedSlice
*
self
)
{
Box
*
sliceRepr
(
BoxedSlice
*
self
)
{
BoxedString
*
start
=
repr
(
self
->
start
);
BoxedString
*
start
=
static_cast
<
BoxedString
*>
(
repr
(
self
->
start
)
);
BoxedString
*
stop
=
repr
(
self
->
stop
);
BoxedString
*
stop
=
static_cast
<
BoxedString
*>
(
repr
(
self
->
stop
)
);
BoxedString
*
step
=
repr
(
self
->
step
);
BoxedString
*
step
=
static_cast
<
BoxedString
*>
(
repr
(
self
->
step
)
);
std
::
string
s
=
"slice("
+
start
->
s
+
", "
+
stop
->
s
+
", "
+
step
->
s
+
")"
;
std
::
string
s
=
"slice("
+
start
->
s
+
", "
+
stop
->
s
+
", "
+
step
->
s
+
")"
;
return
new
BoxedString
(
s
);
return
new
BoxedString
(
s
);
}
}
...
...
test/tests/backtick.py
0 → 100644
View file @
7a44bcaf
print
`42`
print
`int`
print
`2+3`
i
=
23
print
`i`
s
=
'test'
print
`s`
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