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
3420ef7e
Commit
3420ef7e
authored
Nov 04, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turn on -Winconsistent-missing-override
parent
923df348
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
359 additions
and
356 deletions
+359
-356
src/Makefile
src/Makefile
+0
-1
src/analysis/scoping_analysis.cpp
src/analysis/scoping_analysis.cpp
+76
-74
src/analysis/type_analysis.cpp
src/analysis/type_analysis.cpp
+48
-47
src/codegen/compvars.cpp
src/codegen/compvars.cpp
+194
-193
src/codegen/compvars.h
src/codegen/compvars.h
+19
-19
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+1
-1
src/codegen/opt/aa.cpp
src/codegen/opt/aa.cpp
+3
-3
src/core/cfg.cpp
src/core/cfg.cpp
+18
-18
No files found.
src/Makefile
View file @
3420ef7e
...
...
@@ -138,7 +138,6 @@ COMMON_CXXFLAGS += -fexceptions -fno-rtti
COMMON_CXXFLAGS
+=
-Wno-invalid-offsetof
# allow the use of "offsetof", and we'll just have to make sure to only use it legally.
COMMON_CXXFLAGS
+=
-DENABLE_INTEL_JIT_EVENTS
=
$(ENABLE_INTEL_JIT_EVENTS)
COMMON_CXXFLAGS
+=
-I
$(DEPS_DIR)
/pypa-install/include
COMMON_CXXFLAGS
+=
-Wno-inconsistent-missing-override
ifeq
($(ENABLE_VALGRIND),0)
COMMON_CXXFLAGS
+=
-DNVALGRIND
...
...
src/analysis/scoping_analysis.cpp
View file @
3420ef7e
...
...
@@ -24,9 +24,9 @@ class YieldVisitor : public NoopASTVisitor {
public:
YieldVisitor
()
:
containsYield
(
false
)
{}
virtual
bool
visit_functiondef
(
AST_FunctionDef
*
)
{
return
true
;
}
bool
visit_functiondef
(
AST_FunctionDef
*
)
override
{
return
true
;
}
virtual
bool
visit_yield
(
AST_Yield
*
)
{
bool
visit_yield
(
AST_Yield
*
)
override
{
containsYield
=
true
;
return
true
;
}
...
...
@@ -55,25 +55,25 @@ static bool isCompilerCreatedName(const std::string& name) {
class
ModuleScopeInfo
:
public
ScopeInfo
{
public:
virtual
ScopeInfo
*
getParent
()
{
return
NULL
;
}
ScopeInfo
*
getParent
()
override
{
return
NULL
;
}
virtual
bool
createsClosure
()
{
return
false
;
}
bool
createsClosure
()
override
{
return
false
;
}
virtual
bool
takesClosure
()
{
return
false
;
}
bool
takesClosure
()
override
{
return
false
;
}
bool
passesThroughClosure
()
override
{
return
false
;
}
virtual
bool
refersToGlobal
(
const
std
::
string
&
name
)
{
bool
refersToGlobal
(
const
std
::
string
&
name
)
override
{
if
(
isCompilerCreatedName
(
name
))
return
false
;
// assert(name[0] != '#' && "should test this");
return
true
;
}
virtual
bool
refersToClosure
(
const
std
::
string
name
)
{
return
false
;
}
virtual
bool
saveInClosure
(
const
std
::
string
name
)
{
return
false
;
}
bool
refersToClosure
(
const
std
::
string
name
)
override
{
return
false
;
}
bool
saveInClosure
(
const
std
::
string
name
)
override
{
return
false
;
}
virtual
const
std
::
unordered_set
<
std
::
string
>&
getClassDefLocalNames
()
{
RELEASE_ASSERT
(
0
,
""
);
}
const
std
::
unordered_set
<
std
::
string
>&
getClassDefLocalNames
()
override
{
RELEASE_ASSERT
(
0
,
""
);
}
};
struct
ScopingAnalysis
::
ScopeNameUsage
{
...
...
@@ -120,17 +120,19 @@ public:
assert
(
usage
);
}
virtual
~
ScopeInfoBase
()
{
delete
this
->
usage
;
}
~
ScopeInfoBase
()
override
{
delete
this
->
usage
;
}
virtual
ScopeInfo
*
getParent
()
{
return
parent
;
}
ScopeInfo
*
getParent
()
override
{
return
parent
;
}
virtual
bool
createsClosure
()
{
return
usage
->
referenced_from_nested
.
size
()
>
0
;
}
bool
createsClosure
()
override
{
return
usage
->
referenced_from_nested
.
size
()
>
0
;
}
virtual
bool
takesClosure
()
{
return
usage
->
got_from_closure
.
size
()
>
0
||
usage
->
passthrough_accesses
.
size
()
>
0
;
}
bool
takesClosure
()
override
{
return
usage
->
got_from_closure
.
size
()
>
0
||
usage
->
passthrough_accesses
.
size
()
>
0
;
}
bool
passesThroughClosure
()
override
{
return
usage
->
passthrough_accesses
.
size
()
>
0
&&
!
createsClosure
();
}
virtual
bool
refersToGlobal
(
const
std
::
string
&
name
)
{
bool
refersToGlobal
(
const
std
::
string
&
name
)
override
{
// HAX
if
(
isCompilerCreatedName
(
name
))
return
false
;
...
...
@@ -139,20 +141,20 @@ public:
return
true
;
return
usage
->
written
.
count
(
name
)
==
0
&&
usage
->
got_from_closure
.
count
(
name
)
==
0
;
}
virtual
bool
refersToClosure
(
const
std
::
string
name
)
{
bool
refersToClosure
(
const
std
::
string
name
)
override
{
// HAX
if
(
isCompilerCreatedName
(
name
))
return
false
;
return
usage
->
got_from_closure
.
count
(
name
)
!=
0
;
}
virtual
bool
saveInClosure
(
const
std
::
string
name
)
{
bool
saveInClosure
(
const
std
::
string
name
)
override
{
// HAX
if
(
isCompilerCreatedName
(
name
))
return
false
;
return
usage
->
referenced_from_nested
.
count
(
name
)
!=
0
;
}
virtual
const
std
::
unordered_set
<
std
::
string
>&
getClassDefLocalNames
()
{
const
std
::
unordered_set
<
std
::
string
>&
getClassDefLocalNames
()
override
{
RELEASE_ASSERT
(
usage
->
node
->
type
==
AST_TYPE
::
ClassDef
,
""
);
return
usage
->
written
;
}
...
...
@@ -177,7 +179,7 @@ public:
void
doRead
(
const
std
::
string
&
name
)
{
cur
->
read
.
insert
(
name
);
}
virtual
bool
visit_name
(
AST_Name
*
node
)
{
bool
visit_name
(
AST_Name
*
node
)
override
{
switch
(
node
->
ctx_type
)
{
case
AST_TYPE
:
:
Load
:
doRead
(
node
->
id
);
...
...
@@ -193,55 +195,55 @@ public:
return
true
;
}
virtual
bool
visit_assert
(
AST_Assert
*
node
)
{
return
false
;
}
virtual
bool
visit_assign
(
AST_Assign
*
node
)
{
return
false
;
}
virtual
bool
visit_augassign
(
AST_AugAssign
*
node
)
{
return
false
;
}
virtual
bool
visit_attribute
(
AST_Attribute
*
node
)
{
return
false
;
}
virtual
bool
visit_binop
(
AST_BinOp
*
node
)
{
return
false
;
}
virtual
bool
visit_boolop
(
AST_BoolOp
*
node
)
{
return
false
;
}
virtual
bool
visit_break
(
AST_Break
*
node
)
{
return
false
;
}
virtual
bool
visit_call
(
AST_Call
*
node
)
{
return
false
;
}
virtual
bool
visit_compare
(
AST_Compare
*
node
)
{
return
false
;
}
virtual
bool
visit_comprehension
(
AST_comprehension
*
node
)
{
return
false
;
}
//
virtual bool visit_classdef(AST_ClassDef *node)
{ return false; }
virtual
bool
visit_continue
(
AST_Continue
*
node
)
{
return
false
;
}
virtual
bool
visit_dict
(
AST_Dict
*
node
)
{
return
false
;
}
virtual
bool
visit_dictcomp
(
AST_DictComp
*
node
)
{
return
false
;
}
virtual
bool
visit_excepthandler
(
AST_ExceptHandler
*
node
)
{
return
false
;
}
virtual
bool
visit_expr
(
AST_Expr
*
node
)
{
return
false
;
}
virtual
bool
visit_for
(
AST_For
*
node
)
{
return
false
;
}
//
virtual bool visit_functiondef(AST_FunctionDef *node)
{ return false; }
//
virtual bool visit_global(AST_Global *node)
{ return false; }
virtual
bool
visit_if
(
AST_If
*
node
)
{
return
false
;
}
virtual
bool
visit_ifexp
(
AST_IfExp
*
node
)
{
return
false
;
}
virtual
bool
visit_index
(
AST_Index
*
node
)
{
return
false
;
}
virtual
bool
visit_keyword
(
AST_keyword
*
node
)
{
return
false
;
}
virtual
bool
visit_list
(
AST_List
*
node
)
{
return
false
;
}
virtual
bool
visit_listcomp
(
AST_ListComp
*
node
)
{
return
false
;
}
//
virtual bool visit_module(AST_Module *node)
{ return false; }
//
virtual bool visit_name(AST_Name *node)
{ return false; }
virtual
bool
visit_num
(
AST_Num
*
node
)
{
return
false
;
}
virtual
bool
visit_pass
(
AST_Pass
*
node
)
{
return
false
;
}
virtual
bool
visit_print
(
AST_Print
*
node
)
{
return
false
;
}
virtual
bool
visit_raise
(
AST_Raise
*
node
)
{
return
false
;
}
virtual
bool
visit_repr
(
AST_Repr
*
node
)
{
return
false
;
}
virtual
bool
visit_return
(
AST_Return
*
node
)
{
return
false
;
}
virtual
bool
visit_slice
(
AST_Slice
*
node
)
{
return
false
;
}
virtual
bool
visit_str
(
AST_Str
*
node
)
{
return
false
;
}
virtual
bool
visit_subscript
(
AST_Subscript
*
node
)
{
return
false
;
}
virtual
bool
visit_tryexcept
(
AST_TryExcept
*
node
)
{
return
false
;
}
virtual
bool
visit_tryfinally
(
AST_TryFinally
*
node
)
{
return
false
;
}
virtual
bool
visit_tuple
(
AST_Tuple
*
node
)
{
return
false
;
}
virtual
bool
visit_unaryop
(
AST_UnaryOp
*
node
)
{
return
false
;
}
virtual
bool
visit_while
(
AST_While
*
node
)
{
return
false
;
}
virtual
bool
visit_with
(
AST_With
*
node
)
{
return
false
;
}
virtual
bool
visit_yield
(
AST_Yield
*
node
)
{
return
false
;
}
virtual
bool
visit_branch
(
AST_Branch
*
node
)
{
return
false
;
}
virtual
bool
visit_jump
(
AST_Jump
*
node
)
{
return
false
;
}
virtual
bool
visit_delete
(
AST_Delete
*
node
)
{
bool
visit_assert
(
AST_Assert
*
node
)
override
{
return
false
;
}
bool
visit_assign
(
AST_Assign
*
node
)
override
{
return
false
;
}
bool
visit_augassign
(
AST_AugAssign
*
node
)
override
{
return
false
;
}
bool
visit_attribute
(
AST_Attribute
*
node
)
override
{
return
false
;
}
bool
visit_binop
(
AST_BinOp
*
node
)
override
{
return
false
;
}
bool
visit_boolop
(
AST_BoolOp
*
node
)
override
{
return
false
;
}
bool
visit_break
(
AST_Break
*
node
)
override
{
return
false
;
}
bool
visit_call
(
AST_Call
*
node
)
override
{
return
false
;
}
bool
visit_compare
(
AST_Compare
*
node
)
override
{
return
false
;
}
bool
visit_comprehension
(
AST_comprehension
*
node
)
override
{
return
false
;
}
//
bool visit_classdef(AST_ClassDef *node) override
{ return false; }
bool
visit_continue
(
AST_Continue
*
node
)
override
{
return
false
;
}
bool
visit_dict
(
AST_Dict
*
node
)
override
{
return
false
;
}
bool
visit_dictcomp
(
AST_DictComp
*
node
)
override
{
return
false
;
}
bool
visit_excepthandler
(
AST_ExceptHandler
*
node
)
override
{
return
false
;
}
bool
visit_expr
(
AST_Expr
*
node
)
override
{
return
false
;
}
bool
visit_for
(
AST_For
*
node
)
override
{
return
false
;
}
//
bool visit_functiondef(AST_FunctionDef *node) override
{ return false; }
//
bool visit_global(AST_Global *node) override
{ return false; }
bool
visit_if
(
AST_If
*
node
)
override
{
return
false
;
}
bool
visit_ifexp
(
AST_IfExp
*
node
)
override
{
return
false
;
}
bool
visit_index
(
AST_Index
*
node
)
override
{
return
false
;
}
bool
visit_keyword
(
AST_keyword
*
node
)
override
{
return
false
;
}
bool
visit_list
(
AST_List
*
node
)
override
{
return
false
;
}
bool
visit_listcomp
(
AST_ListComp
*
node
)
override
{
return
false
;
}
//
bool visit_module(AST_Module *node) override
{ return false; }
//
bool visit_name(AST_Name *node) override
{ return false; }
bool
visit_num
(
AST_Num
*
node
)
override
{
return
false
;
}
bool
visit_pass
(
AST_Pass
*
node
)
override
{
return
false
;
}
bool
visit_print
(
AST_Print
*
node
)
override
{
return
false
;
}
bool
visit_raise
(
AST_Raise
*
node
)
override
{
return
false
;
}
bool
visit_repr
(
AST_Repr
*
node
)
override
{
return
false
;
}
bool
visit_return
(
AST_Return
*
node
)
override
{
return
false
;
}
bool
visit_slice
(
AST_Slice
*
node
)
override
{
return
false
;
}
bool
visit_str
(
AST_Str
*
node
)
override
{
return
false
;
}
bool
visit_subscript
(
AST_Subscript
*
node
)
override
{
return
false
;
}
bool
visit_tryexcept
(
AST_TryExcept
*
node
)
override
{
return
false
;
}
bool
visit_tryfinally
(
AST_TryFinally
*
node
)
override
{
return
false
;
}
bool
visit_tuple
(
AST_Tuple
*
node
)
override
{
return
false
;
}
bool
visit_unaryop
(
AST_UnaryOp
*
node
)
override
{
return
false
;
}
bool
visit_while
(
AST_While
*
node
)
override
{
return
false
;
}
bool
visit_with
(
AST_With
*
node
)
override
{
return
false
;
}
bool
visit_yield
(
AST_Yield
*
node
)
override
{
return
false
;
}
bool
visit_branch
(
AST_Branch
*
node
)
override
{
return
false
;
}
bool
visit_jump
(
AST_Jump
*
node
)
override
{
return
false
;
}
bool
visit_delete
(
AST_Delete
*
node
)
override
{
for
(
auto
t
:
node
->
targets
)
{
if
(
t
->
type
==
AST_TYPE
::
Name
)
{
doWrite
(
ast_cast
<
AST_Name
>
(
t
)
->
id
);
...
...
@@ -250,7 +252,7 @@ public:
return
false
;
}
virtual
bool
visit_global
(
AST_Global
*
node
)
{
bool
visit_global
(
AST_Global
*
node
)
override
{
for
(
int
i
=
0
;
i
<
node
->
names
.
size
();
i
++
)
{
const
std
::
string
&
name
=
node
->
names
[
i
];
cur
->
forced_globals
.
insert
(
name
);
...
...
@@ -258,7 +260,7 @@ public:
return
true
;
}
virtual
bool
visit_classdef
(
AST_ClassDef
*
node
)
{
bool
visit_classdef
(
AST_ClassDef
*
node
)
override
{
if
(
node
==
orig_node
)
{
for
(
AST_stmt
*
s
:
node
->
body
)
s
->
accept
(
this
);
...
...
@@ -276,7 +278,7 @@ public:
}
}
virtual
bool
visit_functiondef
(
AST_FunctionDef
*
node
)
{
bool
visit_functiondef
(
AST_FunctionDef
*
node
)
override
{
if
(
node
==
orig_node
)
{
for
(
AST_expr
*
e
:
node
->
args
->
args
)
e
->
accept
(
this
);
...
...
@@ -300,7 +302,7 @@ public:
}
}
virtual
bool
visit_generatorexp
(
AST_GeneratorExp
*
node
)
{
bool
visit_generatorexp
(
AST_GeneratorExp
*
node
)
override
{
if
(
node
==
orig_node
)
{
bool
first
=
true
;
for
(
AST_comprehension
*
c
:
node
->
generators
)
{
...
...
@@ -320,7 +322,7 @@ public:
return
true
;
}
virtual
bool
visit_lambda
(
AST_Lambda
*
node
)
{
bool
visit_lambda
(
AST_Lambda
*
node
)
override
{
if
(
node
==
orig_node
)
{
for
(
AST_expr
*
e
:
node
->
args
->
args
)
e
->
accept
(
this
);
...
...
@@ -339,7 +341,7 @@ public:
return
true
;
}
virtual
bool
visit_import
(
AST_Import
*
node
)
{
bool
visit_import
(
AST_Import
*
node
)
override
{
for
(
int
i
=
0
;
i
<
node
->
names
.
size
();
i
++
)
{
AST_alias
*
alias
=
node
->
names
[
i
];
if
(
alias
->
asname
.
size
())
...
...
@@ -350,7 +352,7 @@ public:
return
true
;
}
virtual
bool
visit_importfrom
(
AST_ImportFrom
*
node
)
{
bool
visit_importfrom
(
AST_ImportFrom
*
node
)
override
{
for
(
int
i
=
0
;
i
<
node
->
names
.
size
();
i
++
)
{
AST_alias
*
alias
=
node
->
names
[
i
];
if
(
alias
->
asname
.
size
())
...
...
src/analysis/type_analysis.cpp
View file @
3420ef7e
...
...
@@ -36,8 +36,8 @@ namespace pyston {
class
NullTypeAnalysis
:
public
TypeAnalysis
{
public:
virtual
ConcreteCompilerType
*
getTypeAtBlockStart
(
const
std
::
string
&
name
,
CFGBlock
*
block
)
;
virtual
ConcreteCompilerType
*
getTypeAtBlockEnd
(
const
std
::
string
&
name
,
CFGBlock
*
block
)
;
ConcreteCompilerType
*
getTypeAtBlockStart
(
const
std
::
string
&
name
,
CFGBlock
*
block
)
override
;
ConcreteCompilerType
*
getTypeAtBlockEnd
(
const
std
::
string
&
name
,
CFGBlock
*
block
)
override
;
BoxedClass
*
speculatedExprClass
(
AST_expr
*
)
override
{
return
NULL
;
}
};
...
...
@@ -168,7 +168,7 @@ private:
}
}
v
irtual
void
*
visit_attribute
(
AST_Attribute
*
node
)
{
v
oid
*
visit_attribute
(
AST_Attribute
*
node
)
override
{
CompilerType
*
t
=
getType
(
node
->
value
);
CompilerType
*
rtn
=
t
->
getattrType
(
&
node
->
attr
,
false
);
...
...
@@ -190,7 +190,7 @@ private:
return
rtn
;
}
v
irtual
void
*
visit_clsattribute
(
AST_ClsAttribute
*
node
)
{
v
oid
*
visit_clsattribute
(
AST_ClsAttribute
*
node
)
override
{
CompilerType
*
t
=
getType
(
node
->
value
);
CompilerType
*
rtn
=
t
->
getattrType
(
&
node
->
attr
,
true
);
if
(
VERBOSITY
()
>=
2
&&
rtn
==
UNDEF
)
{
...
...
@@ -207,7 +207,7 @@ private:
return
type
==
STR
||
type
==
INT
||
type
==
FLOAT
||
type
==
LIST
||
type
==
DICT
;
}
v
irtual
void
*
visit_augbinop
(
AST_AugBinOp
*
node
)
{
v
oid
*
visit_augbinop
(
AST_AugBinOp
*
node
)
override
{
CompilerType
*
left
=
getType
(
node
->
left
);
CompilerType
*
right
=
getType
(
node
->
right
);
if
(
!
hasFixedBinops
(
left
)
||
!
hasFixedBinops
(
right
))
...
...
@@ -236,7 +236,7 @@ private:
return
rtn
;
}
v
irtual
void
*
visit_binop
(
AST_BinOp
*
node
)
{
v
oid
*
visit_binop
(
AST_BinOp
*
node
)
override
{
CompilerType
*
left
=
getType
(
node
->
left
);
CompilerType
*
right
=
getType
(
node
->
right
);
if
(
!
hasFixedBinops
(
left
)
||
!
hasFixedBinops
(
right
))
...
...
@@ -265,7 +265,7 @@ private:
return
rtn
;
}
v
irtual
void
*
visit_boolop
(
AST_BoolOp
*
node
)
{
v
oid
*
visit_boolop
(
AST_BoolOp
*
node
)
override
{
int
n
=
node
->
values
.
size
();
CompilerType
*
rtn
=
NULL
;
...
...
@@ -280,7 +280,7 @@ private:
return
rtn
;
}
v
irtual
void
*
visit_call
(
AST_Call
*
node
)
{
v
oid
*
visit_call
(
AST_Call
*
node
)
override
{
CompilerType
*
func
=
getType
(
node
->
func
);
std
::
vector
<
CompilerType
*>
arg_types
;
...
...
@@ -316,7 +316,7 @@ private:
return
rtn_type
;
}
v
irtual
void
*
visit_compare
(
AST_Compare
*
node
)
{
v
oid
*
visit_compare
(
AST_Compare
*
node
)
override
{
if
(
node
->
ops
.
size
()
==
1
)
{
CompilerType
*
left
=
getType
(
node
->
left
);
CompilerType
*
right
=
getType
(
node
->
comparators
[
0
]);
...
...
@@ -342,7 +342,7 @@ private:
}
}
v
irtual
void
*
visit_dict
(
AST_Dict
*
node
)
{
v
oid
*
visit_dict
(
AST_Dict
*
node
)
override
{
// Get all the sub-types, even though they're not necessary to
// determine the expression type, so that things like speculations
// can be processed.
...
...
@@ -354,11 +354,11 @@ private:
return
DICT
;
}
v
irtual
void
*
visit_index
(
AST_Index
*
node
)
{
return
getType
(
node
->
value
);
}
v
oid
*
visit_index
(
AST_Index
*
node
)
override
{
return
getType
(
node
->
value
);
}
v
irtual
void
*
visit_lambda
(
AST_Lambda
*
node
)
{
return
typeFromClass
(
function_cls
);
}
v
oid
*
visit_lambda
(
AST_Lambda
*
node
)
override
{
return
typeFromClass
(
function_cls
);
}
v
irtual
void
*
visit_langprimitive
(
AST_LangPrimitive
*
node
)
{
v
oid
*
visit_langprimitive
(
AST_LangPrimitive
*
node
)
override
{
switch
(
node
->
opcode
)
{
case
AST_LangPrimitive
:
:
ISINSTANCE
:
return
BOOL
;
...
...
@@ -377,7 +377,7 @@ private:
}
}
v
irtual
void
*
visit_list
(
AST_List
*
node
)
{
v
oid
*
visit_list
(
AST_List
*
node
)
override
{
// Get all the sub-types, even though they're not necessary to
// determine the expression type, so that things like speculations
// can be processed.
...
...
@@ -388,7 +388,7 @@ private:
return
LIST
;
}
v
irtual
void
*
visit_name
(
AST_Name
*
node
)
{
v
oid
*
visit_name
(
AST_Name
*
node
)
override
{
if
(
scope_info
->
refersToGlobal
(
node
->
id
))
{
if
(
node
->
id
==
"xrange"
)
{
// printf("TODO guard here and return the classobj\n");
...
...
@@ -412,7 +412,7 @@ private:
return
t
;
}
v
irtual
void
*
visit_num
(
AST_Num
*
node
)
{
v
oid
*
visit_num
(
AST_Num
*
node
)
override
{
switch
(
node
->
num_type
)
{
case
AST_Num
:
:
INT
:
return
INT
;
...
...
@@ -426,15 +426,15 @@ private:
abort
();
}
v
irtual
void
*
visit_repr
(
AST_Repr
*
node
)
{
return
STR
;
}
v
oid
*
visit_repr
(
AST_Repr
*
node
)
override
{
return
STR
;
}
v
irtual
void
*
visit_set
(
AST_Set
*
node
)
{
return
SET
;
}
v
oid
*
visit_set
(
AST_Set
*
node
)
override
{
return
SET
;
}
v
irtual
void
*
visit_slice
(
AST_Slice
*
node
)
{
return
SLICE
;
}
v
oid
*
visit_slice
(
AST_Slice
*
node
)
override
{
return
SLICE
;
}
v
irtual
void
*
visit_str
(
AST_Str
*
node
)
{
return
STR
;
}
v
oid
*
visit_str
(
AST_Str
*
node
)
override
{
return
STR
;
}
v
irtual
void
*
visit_subscript
(
AST_Subscript
*
node
)
{
v
oid
*
visit_subscript
(
AST_Subscript
*
node
)
override
{
CompilerType
*
val
=
getType
(
node
->
value
);
CompilerType
*
slice
=
getType
(
node
->
slice
);
static
std
::
string
name
(
"__getitem__"
);
...
...
@@ -444,7 +444,7 @@ private:
return
getitem_type
->
callType
(
ArgPassSpec
(
1
),
args
,
NULL
);
}
v
irtual
void
*
visit_tuple
(
AST_Tuple
*
node
)
{
v
oid
*
visit_tuple
(
AST_Tuple
*
node
)
override
{
std
::
vector
<
CompilerType
*>
elt_types
;
for
(
int
i
=
0
;
i
<
node
->
elts
.
size
();
i
++
)
{
elt_types
.
push_back
(
getType
(
node
->
elts
[
i
]));
...
...
@@ -452,7 +452,7 @@ private:
return
makeTupleType
(
elt_types
);
}
v
irtual
void
*
visit_unaryop
(
AST_UnaryOp
*
node
)
{
v
oid
*
visit_unaryop
(
AST_UnaryOp
*
node
)
override
{
CompilerType
*
operand
=
getType
(
node
->
operand
);
// TODO this isn't the exact behavior
...
...
@@ -462,29 +462,29 @@ private:
return
attr_type
->
callType
(
ArgPassSpec
(
0
),
arg_types
,
NULL
);
}
v
irtual
void
*
visit_yield
(
AST_Yield
*
)
{
return
UNKNOWN
;
}
v
oid
*
visit_yield
(
AST_Yield
*
)
override
{
return
UNKNOWN
;
}
v
irtual
void
visit_assert
(
AST_Assert
*
node
)
{
v
oid
visit_assert
(
AST_Assert
*
node
)
override
{
getType
(
node
->
test
);
if
(
node
->
msg
)
getType
(
node
->
msg
);
}
v
irtual
void
visit_assign
(
AST_Assign
*
node
)
{
v
oid
visit_assign
(
AST_Assign
*
node
)
override
{
CompilerType
*
t
=
getType
(
node
->
value
);
for
(
int
i
=
0
;
i
<
node
->
targets
.
size
();
i
++
)
{
_doSet
(
node
->
targets
[
i
],
t
);
}
}
v
irtual
void
visit_branch
(
AST_Branch
*
node
)
{
v
oid
visit_branch
(
AST_Branch
*
node
)
override
{
if
(
EXPAND_UNNEEDED
)
{
getType
(
node
->
test
);
}
}
v
irtual
void
visit_classdef
(
AST_ClassDef
*
node
)
{
v
oid
visit_classdef
(
AST_ClassDef
*
node
)
override
{
for
(
auto
d
:
node
->
decorator_list
)
{
getType
(
d
);
}
...
...
@@ -499,7 +499,7 @@ private:
_doSet
(
node
->
name
,
t
);
}
v
irtual
void
visit_delete
(
AST_Delete
*
node
)
{
v
oid
visit_delete
(
AST_Delete
*
node
)
override
{
for
(
AST_expr
*
target
:
node
->
targets
)
{
switch
(
target
->
type
)
{
case
AST_TYPE
:
:
Subscript
:
...
...
@@ -517,14 +517,14 @@ private:
}
}
v
irtual
void
visit_expr
(
AST_Expr
*
node
)
{
v
oid
visit_expr
(
AST_Expr
*
node
)
override
{
if
(
EXPAND_UNNEEDED
)
{
if
(
node
->
value
!=
NULL
)
getType
(
node
->
value
);
}
}
v
irtual
void
visit_functiondef
(
AST_FunctionDef
*
node
)
{
v
oid
visit_functiondef
(
AST_FunctionDef
*
node
)
override
{
for
(
auto
d
:
node
->
decorator_list
)
{
getType
(
d
);
}
...
...
@@ -536,9 +536,10 @@ private:
_doSet
(
node
->
name
,
typeFromClass
(
function_cls
));
}
v
irtual
void
visit_global
(
AST_Global
*
node
)
{}
v
oid
visit_global
(
AST_Global
*
node
)
override
{}
virtual
void
visit_alias
(
AST_alias
*
node
)
{
// not part of the visitor api:
void
_visit_alias
(
AST_alias
*
node
)
{
const
std
::
string
*
name
=
&
node
->
name
;
if
(
node
->
asname
.
size
())
name
=
&
node
->
asname
;
...
...
@@ -546,22 +547,22 @@ private:
_doSet
(
*
name
,
UNKNOWN
);
}
v
irtual
void
visit_import
(
AST_Import
*
node
)
{
v
oid
visit_import
(
AST_Import
*
node
)
override
{
for
(
AST_alias
*
alias
:
node
->
names
)
visit_alias
(
alias
);
_
visit_alias
(
alias
);
}
v
irtual
void
visit_importfrom
(
AST_ImportFrom
*
node
)
{
v
oid
visit_importfrom
(
AST_ImportFrom
*
node
)
override
{
for
(
AST_alias
*
alias
:
node
->
names
)
visit_alias
(
alias
);
_
visit_alias
(
alias
);
}
v
irtual
void
visit_invoke
(
AST_Invoke
*
node
)
{
node
->
stmt
->
accept_stmt
(
this
);
}
v
oid
visit_invoke
(
AST_Invoke
*
node
)
override
{
node
->
stmt
->
accept_stmt
(
this
);
}
v
irtual
void
visit_jump
(
AST_Jump
*
node
)
{}
v
irtual
void
visit_pass
(
AST_Pass
*
node
)
{}
v
oid
visit_jump
(
AST_Jump
*
node
)
override
{}
v
oid
visit_pass
(
AST_Pass
*
node
)
override
{}
v
irtual
void
visit_print
(
AST_Print
*
node
)
{
v
oid
visit_print
(
AST_Print
*
node
)
override
{
if
(
node
->
dest
)
getType
(
node
->
dest
);
...
...
@@ -572,7 +573,7 @@ private:
}
}
v
irtual
void
visit_raise
(
AST_Raise
*
node
)
{
v
oid
visit_raise
(
AST_Raise
*
node
)
override
{
if
(
EXPAND_UNNEEDED
)
{
if
(
node
->
arg0
)
getType
(
node
->
arg0
);
...
...
@@ -583,14 +584,14 @@ private:
}
}
v
irtual
void
visit_return
(
AST_Return
*
node
)
{
v
oid
visit_return
(
AST_Return
*
node
)
override
{
if
(
EXPAND_UNNEEDED
)
{
if
(
node
->
value
!=
NULL
)
getType
(
node
->
value
);
}
}
v
irtual
void
visit_unreachable
(
AST_Unreachable
*
node
)
{}
v
oid
visit_unreachable
(
AST_Unreachable
*
node
)
override
{}
public:
static
void
propagate
(
CFGBlock
*
block
,
const
TypeMap
&
starting
,
TypeMap
&
ending
,
ExprTypeMap
&
expr_types
,
...
...
@@ -614,11 +615,11 @@ private:
speculation
(
speculation
)
{}
public:
virtual
ConcreteCompilerType
*
getTypeAtBlockEnd
(
const
std
::
string
&
name
,
CFGBlock
*
block
)
{
ConcreteCompilerType
*
getTypeAtBlockEnd
(
const
std
::
string
&
name
,
CFGBlock
*
block
)
override
{
assert
(
block
->
successors
.
size
()
>
0
);
return
getTypeAtBlockStart
(
name
,
block
->
successors
[
0
]);
}
virtual
ConcreteCompilerType
*
getTypeAtBlockStart
(
const
std
::
string
&
name
,
CFGBlock
*
block
)
{
ConcreteCompilerType
*
getTypeAtBlockStart
(
const
std
::
string
&
name
,
CFGBlock
*
block
)
override
{
CompilerType
*
base
=
starting_types
[
block
][
name
];
ASSERT
(
base
!=
NULL
,
"%s %d"
,
name
.
c_str
(),
block
->
idx
);
...
...
@@ -627,7 +628,7 @@ public:
return
rtn
;
}
virtual
BoxedClass
*
speculatedExprClass
(
AST_expr
*
call
)
{
return
type_speculations
[
call
];
}
BoxedClass
*
speculatedExprClass
(
AST_expr
*
call
)
override
{
return
type_speculations
[
call
];
}
static
bool
merge
(
CompilerType
*
lhs
,
CompilerType
*&
rhs
)
{
assert
(
lhs
);
...
...
src/codegen/compvars.cpp
View file @
3420ef7e
...
...
@@ -93,8 +93,8 @@ public:
return
rtn
;
}
virtual
CompilerType
*
callType
(
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerType
*>&
arg_types
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerType
*
callType
(
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerType
*>&
arg_types
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
std
::
vector
<
CompilerType
*>
new_args
(
arg_types
);
new_args
.
insert
(
new_args
.
begin
(),
obj_type
);
...
...
@@ -102,11 +102,11 @@ public:
return
function_type
->
callType
(
new_argspec
,
new_args
,
keyword_names
);
}
std
::
string
debugName
()
{
std
::
string
debugName
()
override
{
return
"instanceMethod("
+
obj_type
->
debugName
()
+
" ; "
+
function_type
->
debugName
()
+
")"
;
}
v
irtual
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
{
v
oid
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
checkVar
(
var
);
RawInstanceMethod
*
val
=
var
->
getValue
();
val
->
obj
->
decvref
(
emitter
);
...
...
@@ -114,10 +114,9 @@ public:
delete
val
;
}
virtual
CompilerVariable
*
call
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ValuedCompilerVariable
<
RawInstanceMethod
*>*
var
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerVariable
*
call
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ValuedCompilerVariable
<
RawInstanceMethod
*>*
var
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
std
::
vector
<
CompilerVariable
*>
new_args
;
new_args
.
push_back
(
var
->
getValue
()
->
obj
);
new_args
.
insert
(
new_args
.
end
(),
args
.
begin
(),
args
.
end
());
...
...
@@ -126,10 +125,10 @@ public:
return
var
->
getValue
()
->
func
->
call
(
emitter
,
info
,
new_argspec
,
new_args
,
keyword_names
);
}
virtual
bool
canConvertTo
(
ConcreteCompilerType
*
other_type
)
{
return
other_type
==
UNKNOWN
;
}
virtual
ConcreteCompilerType
*
getConcreteType
()
{
return
typeFromClass
(
instancemethod_cls
);
}
virtual
ConcreteCompilerType
*
getBoxType
()
{
return
getConcreteType
();
}
virtual
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
VAR
*
var
,
ConcreteCompilerType
*
other_type
)
{
bool
canConvertTo
(
ConcreteCompilerType
*
other_type
)
override
{
return
other_type
==
UNKNOWN
;
}
ConcreteCompilerType
*
getConcreteType
()
override
{
return
typeFromClass
(
instancemethod_cls
);
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
getConcreteType
();
}
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
VAR
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
checkVar
(
var
);
assert
(
other_type
==
UNKNOWN
||
other_type
==
typeFromClass
(
instancemethod_cls
));
...
...
@@ -147,7 +146,7 @@ public:
return
new
ConcreteCompilerVariable
(
other_type
,
boxed
,
true
);
}
virtual
CompilerVariable
*
dup
(
VAR
*
var
,
DupCache
&
cache
)
{
CompilerVariable
*
dup
(
VAR
*
var
,
DupCache
&
cache
)
override
{
checkVar
(
var
);
CompilerVariable
*
rtn
=
cache
[
var
];
...
...
@@ -196,28 +195,28 @@ CompilerVariable* ConcreteCompilerType::dup(ConcreteCompilerVariable* v, DupCach
class
UnknownType
:
public
ConcreteCompilerType
{
public:
llvm
::
Type
*
llvmType
()
{
return
g
.
llvm_value_type_ptr
;
}
llvm
::
Type
*
llvmType
()
override
{
return
g
.
llvm_value_type_ptr
;
}
virtual
std
::
string
debugName
()
{
return
"AnyBox"
;
}
std
::
string
debugName
()
override
{
return
"AnyBox"
;
}
v
irtual
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
{
emitter
.
getGC
()
->
dropPointer
(
emitter
,
var
->
getValue
());
}
v
irtual
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
{
emitter
.
getGC
()
->
grabPointer
(
emitter
,
var
->
getValue
());
}
v
oid
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
emitter
.
getGC
()
->
dropPointer
(
emitter
,
var
->
getValue
());
}
v
oid
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
emitter
.
getGC
()
->
grabPointer
(
emitter
,
var
->
getValue
());
}
virtual
bool
isFitBy
(
BoxedClass
*
c
)
{
return
true
;
}
bool
isFitBy
(
BoxedClass
*
c
)
override
{
return
true
;
}
virtual
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
cls_only
)
;
virtual
CompilerVariable
*
call
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
;
virtual
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
;
virtual
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
;
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
cls_only
)
override
;
CompilerVariable
*
call
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
;
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
;
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
override
;
void
setattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
CompilerVariable
*
v
)
{
CompilerVariable
*
v
)
override
{
llvm
::
Constant
*
ptr
=
getStringConstantPtr
(
*
attr
+
'\0'
);
ConcreteCompilerVariable
*
converted
=
v
->
makeConverted
(
emitter
,
UNKNOWN
);
// g.funcs.setattr->dump();
...
...
@@ -240,7 +239,8 @@ public:
converted
->
decvref
(
emitter
);
}
void
delattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
)
{
void
delattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
)
override
{
llvm
::
Constant
*
ptr
=
getStringConstantPtr
(
*
attr
+
'\0'
);
// TODO
...
...
@@ -260,7 +260,7 @@ public:
}
}
virtual
llvm
::
Value
*
makeClassCheck
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
BoxedClass
*
cls
)
{
llvm
::
Value
*
makeClassCheck
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
BoxedClass
*
cls
)
override
{
assert
(
var
->
getValue
()
->
getType
()
==
g
.
llvm_value_type_ptr
);
static_assert
(
offsetof
(
Box
,
cls
)
%
sizeof
(
void
*
)
==
0
,
""
);
...
...
@@ -273,15 +273,15 @@ public:
return
rtn
;
}
virtual
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
{
return
UNKNOWN
;
}
virtual
CompilerType
*
callType
(
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerType
*>&
arg_types
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
return
UNKNOWN
;
}
CompilerType
*
callType
(
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerType
*>&
arg_types
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
return
UNKNOWN
;
}
virtual
BoxedClass
*
guaranteedClass
()
{
return
NULL
;
}
virtual
ConcreteCompilerType
*
getBoxType
()
{
return
this
;
}
virtual
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
{
BoxedClass
*
guaranteedClass
()
override
{
return
NULL
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
this
;
}
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
if
(
other_type
==
this
)
{
var
->
incvref
();
return
var
;
...
...
@@ -290,7 +290,7 @@ public:
abort
();
}
virtual
ConcreteCompilerVariable
*
len
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
{
ConcreteCompilerVariable
*
len
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
override
{
bool
do_patchpoint
=
ENABLE_ICGENERICS
&&
!
info
.
isInterpreted
();
llvm
::
Value
*
rtn
;
if
(
do_patchpoint
)
{
...
...
@@ -307,8 +307,8 @@ public:
return
new
ConcreteCompilerVariable
(
INT
,
rtn
,
true
);
}
virtual
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
CompilerVariable
*
slice
)
{
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
CompilerVariable
*
slice
)
override
{
ConcreteCompilerVariable
*
converted_slice
=
slice
->
makeConverted
(
emitter
,
slice
->
getBoxType
());
bool
do_patchpoint
=
ENABLE_ICGETITEMS
&&
!
info
.
isInterpreted
();
...
...
@@ -664,18 +664,18 @@ private:
AbstractFunctionType
(
const
std
::
vector
<
Sig
*>&
sigs
)
:
sigs
(
sigs
)
{}
public:
virtual
std
::
string
debugName
()
{
return
"<AbstractFunctionType>"
;
}
std
::
string
debugName
()
override
{
return
"<AbstractFunctionType>"
;
}
virtual
ConcreteCompilerType
*
getConcreteType
()
{
return
UNKNOWN
;
}
ConcreteCompilerType
*
getConcreteType
()
override
{
return
UNKNOWN
;
}
virtual
ConcreteCompilerType
*
getBoxType
()
{
return
UNKNOWN
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
UNKNOWN
;
}
virtual
bool
canConvertTo
(
ConcreteCompilerType
*
other_type
)
{
return
other_type
==
UNKNOWN
;
}
bool
canConvertTo
(
ConcreteCompilerType
*
other_type
)
override
{
return
other_type
==
UNKNOWN
;
}
virtual
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
{
return
UNDEF
;
}
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
return
UNDEF
;
}
virtual
CompilerType
*
callType
(
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerType
*>&
arg_types
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerType
*
callType
(
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerType
*>&
arg_types
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
RELEASE_ASSERT
(
!
argspec
.
has_starargs
,
""
);
RELEASE_ASSERT
(
!
argspec
.
has_kwargs
,
""
);
RELEASE_ASSERT
(
argspec
.
num_keywords
==
0
,
""
);
...
...
@@ -701,7 +701,7 @@ public:
return
UNDEF
;
}
virtual
BoxedClass
*
guaranteedClass
()
{
return
NULL
;
}
BoxedClass
*
guaranteedClass
()
override
{
return
NULL
;
}
static
CompilerType
*
fromRT
(
BoxedFunction
*
rtfunc
,
bool
stripfirst
)
{
std
::
vector
<
Sig
*>
sigs
;
...
...
@@ -742,18 +742,18 @@ class IntType : public ConcreteCompilerType {
public:
IntType
()
{}
llvm
::
Type
*
llvmType
()
{
return
g
.
i64
;
}
llvm
::
Type
*
llvmType
()
override
{
return
g
.
i64
;
}
virtual
bool
isFitBy
(
BoxedClass
*
c
)
{
return
false
;
}
bool
isFitBy
(
BoxedClass
*
c
)
override
{
return
false
;
}
v
irtual
void
drop
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
)
{
v
oid
drop
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
)
override
{
// pass
}
v
irtual
void
grab
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
)
{
v
oid
grab
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
)
override
{
// pass
}
virtual
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
{
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
/*
static std::vector<AbstractFunctionType::Sig*> sigs;
if (sigs.size() == 0) {
...
...
@@ -784,39 +784,39 @@ public:
return
BOXED_INT
->
getattrType
(
attr
,
cls_only
);
}
virtual
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_INT
);
CompilerVariable
*
rtn
=
converted
->
callattr
(
emitter
,
info
,
attr
,
clsonly
,
argspec
,
args
,
keyword_names
);
converted
->
decvref
(
emitter
);
return
rtn
;
}
virtual
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
cls_only
)
{
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_INT
);
CompilerVariable
*
rtn
=
converted
->
getattr
(
emitter
,
info
,
attr
,
cls_only
);
converted
->
decvref
(
emitter
);
return
rtn
;
}
v
irtual
v
oid
setattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
CompilerVariable
*
v
)
{
void
setattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
CompilerVariable
*
v
)
override
{
llvm
::
CallSite
call
=
emitter
.
createCall2
(
info
.
exc_info
,
g
.
funcs
.
raiseAttributeErrorStr
,
getStringConstantPtr
(
"int
\0
"
),
getStringConstantPtr
(
*
attr
+
'\0'
));
call
.
setDoesNotReturn
();
}
v
irtual
void
delattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
)
{
v
oid
delattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
)
override
{
llvm
::
CallSite
call
=
emitter
.
createCall2
(
info
.
exc_info
,
g
.
funcs
.
raiseAttributeErrorStr
,
getStringConstantPtr
(
"int
\0
"
),
getStringConstantPtr
(
*
attr
+
'\0'
));
call
.
setDoesNotReturn
();
}
virtual
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
{
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
if
(
other_type
==
this
)
{
var
->
incvref
();
return
var
;
...
...
@@ -829,21 +829,21 @@ public:
}
}
virtual
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
slice
)
{
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
slice
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_INT
);
CompilerVariable
*
rtn
=
converted
->
getitem
(
emitter
,
info
,
slice
);
converted
->
decvref
(
emitter
);
return
rtn
;
}
virtual
ConcreteCompilerVariable
*
len
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
{
ConcreteCompilerVariable
*
len
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
override
{
llvm
::
CallSite
call
=
emitter
.
createCall
(
info
.
exc_info
,
g
.
funcs
.
raiseNotIterableError
,
getStringConstantPtr
(
"int"
));
call
.
setDoesNotReturn
();
return
new
ConcreteCompilerVariable
(
INT
,
llvm
::
UndefValue
::
get
(
g
.
i64
),
true
);
}
virtual
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
{
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
override
{
llvm
::
Value
*
cmp
=
emitter
.
getBuilder
()
->
CreateICmpNE
(
var
->
getValue
(),
llvm
::
ConstantInt
::
get
(
g
.
i64
,
0
,
false
));
return
boolFromI1
(
emitter
,
cmp
);
}
...
...
@@ -941,7 +941,7 @@ public:
}
}
virtual
ConcreteCompilerType
*
getBoxType
()
{
return
BOXED_INT
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
BOXED_INT
;
}
Box
*
deserializeFromFrame
(
const
FrameVals
&
vals
)
override
{
assert
(
vals
.
size
()
==
1
);
...
...
@@ -959,18 +959,18 @@ class FloatType : public ConcreteCompilerType {
public:
FloatType
()
{}
llvm
::
Type
*
llvmType
()
{
return
g
.
double_
;
}
llvm
::
Type
*
llvmType
()
override
{
return
g
.
double_
;
}
virtual
bool
isFitBy
(
BoxedClass
*
c
)
{
return
false
;
}
bool
isFitBy
(
BoxedClass
*
c
)
override
{
return
false
;
}
v
irtual
void
drop
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
)
{
v
oid
drop
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
)
override
{
// pass
}
v
irtual
void
grab
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
)
{
v
oid
grab
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
)
override
{
// pass
}
virtual
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
{
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
static
std
::
vector
<
AbstractFunctionType
::
Sig
*>
sigs
;
if
(
sigs
.
size
()
==
0
)
{
AbstractFunctionType
::
Sig
*
float_sig
=
new
AbstractFunctionType
::
Sig
();
...
...
@@ -1002,39 +1002,39 @@ public:
return
BOXED_FLOAT
->
getattrType
(
attr
,
cls_only
);
}
virtual
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
cls_only
)
{
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
CompilerVariable
*
rtn
=
converted
->
getattr
(
emitter
,
info
,
attr
,
cls_only
);
converted
->
decvref
(
emitter
);
return
rtn
;
}
virtual
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_FLOAT
);
CompilerVariable
*
rtn
=
converted
->
callattr
(
emitter
,
info
,
attr
,
clsonly
,
argspec
,
args
,
keyword_names
);
converted
->
decvref
(
emitter
);
return
rtn
;
}
v
irtual
v
oid
setattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
CompilerVariable
*
v
)
{
void
setattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
CompilerVariable
*
v
)
override
{
llvm
::
CallSite
call
=
emitter
.
createCall2
(
info
.
exc_info
,
g
.
funcs
.
raiseAttributeErrorStr
,
getStringConstantPtr
(
"float
\0
"
),
getStringConstantPtr
(
*
attr
+
'\0'
));
call
.
setDoesNotReturn
();
}
v
irtual
void
delattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
)
{
v
oid
delattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
)
override
{
llvm
::
CallSite
call
=
emitter
.
createCall2
(
info
.
exc_info
,
g
.
funcs
.
raiseAttributeErrorStr
,
getStringConstantPtr
(
"float
\0
"
),
getStringConstantPtr
(
*
attr
+
'\0'
));
call
.
setDoesNotReturn
();
}
virtual
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
{
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
if
(
other_type
==
this
)
{
var
->
incvref
();
return
var
;
...
...
@@ -1047,7 +1047,7 @@ public:
}
}
virtual
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
{
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
override
{
llvm
::
Value
*
cmp
=
emitter
.
getBuilder
()
->
CreateFCmpUNE
(
var
->
getValue
(),
llvm
::
ConstantFP
::
get
(
g
.
double_
,
0
));
return
boolFromI1
(
emitter
,
cmp
);
}
...
...
@@ -1161,7 +1161,7 @@ public:
return
rtn
;
}
virtual
ConcreteCompilerType
*
getBoxType
()
{
return
BOXED_FLOAT
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
BOXED_FLOAT
;
}
Box
*
deserializeFromFrame
(
const
FrameVals
&
vals
)
override
{
assert
(
vals
.
size
()
==
1
);
...
...
@@ -1196,7 +1196,7 @@ private:
KnownClassobjType
(
BoxedClass
*
cls
)
:
cls
(
cls
)
{
assert
(
cls
);
}
public:
virtual
std
::
string
debugName
()
{
return
"class '"
+
*
getNameOfClass
(
cls
)
+
"'"
;
}
std
::
string
debugName
()
override
{
return
"class '"
+
*
getNameOfClass
(
cls
)
+
"'"
;
}
void
assertMatches
(
BoxedClass
*
cls
)
override
{
assert
(
cls
==
this
->
cls
);
}
...
...
@@ -1208,8 +1208,8 @@ public:
return
rtn
;
}
virtual
CompilerType
*
callType
(
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerType
*>&
arg_types
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerType
*
callType
(
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerType
*>&
arg_types
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
RELEASE_ASSERT
(
!
argspec
.
has_starargs
,
""
);
RELEASE_ASSERT
(
!
argspec
.
has_kwargs
,
""
);
RELEASE_ASSERT
(
argspec
.
num_keywords
==
0
,
""
);
...
...
@@ -1248,15 +1248,15 @@ private:
}
public:
llvm
::
Type
*
llvmType
()
{
return
g
.
llvm_value_type_ptr
;
}
std
::
string
debugName
()
{
llvm
::
Type
*
llvmType
()
override
{
return
g
.
llvm_value_type_ptr
;
}
std
::
string
debugName
()
override
{
assert
(
cls
);
// TODO add getTypeName
return
"NormalType("
+
*
getNameOfClass
(
cls
)
+
")"
;
}
virtual
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
{
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
if
(
other_type
==
this
)
{
var
->
incvref
();
return
var
;
...
...
@@ -1266,12 +1266,12 @@ public:
// return (new ConcreteCompilerVariable(UNKNOWN, var->getValue(), false))->split(emitter);
}
v
irtual
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
{
emitter
.
getGC
()
->
dropPointer
(
emitter
,
var
->
getValue
());
}
v
irtual
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
{
emitter
.
getGC
()
->
grabPointer
(
emitter
,
var
->
getValue
());
}
v
oid
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
emitter
.
getGC
()
->
dropPointer
(
emitter
,
var
->
getValue
());
}
v
oid
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
emitter
.
getGC
()
->
grabPointer
(
emitter
,
var
->
getValue
());
}
virtual
bool
isFitBy
(
BoxedClass
*
c
)
{
return
c
==
cls
;
}
bool
isFitBy
(
BoxedClass
*
c
)
override
{
return
c
==
cls
;
}
virtual
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
{
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
if
(
cls
->
is_constant
&&
!
cls
->
instancesHaveAttrs
()
&&
cls
->
hasGenericGetattr
())
{
Box
*
rtattr
=
cls
->
getattr
(
*
attr
);
if
(
rtattr
==
NULL
)
...
...
@@ -1289,13 +1289,13 @@ public:
return
UNKNOWN
;
}
virtual
CompilerType
*
callType
(
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerType
*>&
arg_types
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerType
*
callType
(
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerType
*>&
arg_types
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
return
UNKNOWN
;
}
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
cls_only
)
{
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
// printf("%s.getattr %s\n", debugName().c_str(), attr->c_str());
if
(
cls
->
is_constant
&&
!
cls
->
instancesHaveAttrs
()
&&
cls
->
hasGenericGetattr
())
{
Box
*
rtattr
=
cls
->
getattr
(
*
attr
);
...
...
@@ -1320,17 +1320,18 @@ public:
}
void
setattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
CompilerVariable
*
v
)
{
CompilerVariable
*
v
)
override
{
return
UNKNOWN
->
setattr
(
emitter
,
info
,
var
,
attr
,
v
);
}
void
delattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
)
{
void
delattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
)
override
{
return
UNKNOWN
->
delattr
(
emitter
,
info
,
var
,
attr
);
}
virtual
CompilerVariable
*
call
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerVariable
*
call
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
UNKNOWN
);
CompilerVariable
*
rtn
=
converted
->
call
(
emitter
,
info
,
argspec
,
args
,
keyword_names
);
converted
->
decvref
(
emitter
);
...
...
@@ -1456,10 +1457,10 @@ public:
return
rtn
;
}
virtual
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
ConcreteCompilerVariable
*
called_constant
=
tryCallattrConstant
(
emitter
,
info
,
var
,
attr
,
clsonly
,
argspec
,
args
,
keyword_names
);
if
(
called_constant
)
...
...
@@ -1498,7 +1499,7 @@ public:
return
rtn
;
}
virtual
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
slice
)
{
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
slice
)
override
{
static
const
std
::
string
attr
(
"__getitem__"
);
ConcreteCompilerVariable
*
called_constant
=
tryCallattrConstant
(
emitter
,
info
,
var
,
&
attr
,
true
,
ArgPassSpec
(
1
,
0
,
0
,
0
),
{
slice
},
NULL
,
false
);
...
...
@@ -1508,7 +1509,7 @@ public:
return
UNKNOWN
->
getitem
(
emitter
,
info
,
var
,
slice
);
}
virtual
ConcreteCompilerVariable
*
len
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
{
ConcreteCompilerVariable
*
len
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
override
{
static
const
std
::
string
attr
(
"__len__"
);
ConcreteCompilerVariable
*
called_constant
=
tryCallattrConstant
(
emitter
,
info
,
var
,
&
attr
,
true
,
ArgPassSpec
(
0
,
0
,
0
,
0
),
{},
NULL
);
...
...
@@ -1518,7 +1519,7 @@ public:
return
UNKNOWN
->
len
(
emitter
,
info
,
var
);
}
virtual
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
{
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
override
{
static
const
std
::
string
attr
(
"__nonzero__"
);
ConcreteCompilerVariable
*
called_constant
=
tryCallattrConstant
(
emitter
,
info
,
var
,
&
attr
,
true
,
ArgPassSpec
(
0
,
0
,
0
,
0
),
{},
NULL
);
...
...
@@ -1543,9 +1544,9 @@ public:
return
rtn
;
}
virtual
BoxedClass
*
guaranteedClass
()
{
return
cls
;
}
BoxedClass
*
guaranteedClass
()
override
{
return
cls
;
}
virtual
ConcreteCompilerType
*
getBoxType
()
{
return
this
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
this
;
}
Box
*
deserializeFromFrame
(
const
FrameVals
&
vals
)
override
{
assert
(
vals
.
size
()
==
1
);
...
...
@@ -1557,24 +1558,24 @@ ConcreteCompilerType* STR, *BOXED_INT, *BOXED_FLOAT, *BOXED_BOOL, *NONE;
class
ClosureType
:
public
ConcreteCompilerType
{
public:
llvm
::
Type
*
llvmType
()
{
return
g
.
llvm_closure_type_ptr
;
}
std
::
string
debugName
()
{
return
"closure"
;
}
llvm
::
Type
*
llvmType
()
override
{
return
g
.
llvm_closure_type_ptr
;
}
std
::
string
debugName
()
override
{
return
"closure"
;
}
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
cls_only
)
{
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
assert
(
!
cls_only
);
llvm
::
Value
*
bitcast
=
emitter
.
getBuilder
()
->
CreateBitCast
(
var
->
getValue
(),
g
.
llvm_value_type_ptr
);
return
ConcreteCompilerVariable
(
UNKNOWN
,
bitcast
,
true
).
getattr
(
emitter
,
info
,
attr
,
cls_only
);
}
void
setattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
CompilerVariable
*
v
)
{
CompilerVariable
*
v
)
override
{
llvm
::
Value
*
bitcast
=
emitter
.
getBuilder
()
->
CreateBitCast
(
var
->
getValue
(),
g
.
llvm_value_type_ptr
);
ConcreteCompilerVariable
(
UNKNOWN
,
bitcast
,
true
).
setattr
(
emitter
,
info
,
attr
,
v
);
}
virtual
ConcreteCompilerType
*
getConcreteType
()
{
return
this
;
}
virtual
ConcreteCompilerType
*
getBoxType
()
{
return
this
;
}
ConcreteCompilerType
*
getConcreteType
()
override
{
return
this
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
this
;
}
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{}
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{}
...
...
@@ -1588,16 +1589,16 @@ ConcreteCompilerType* CLOSURE = &_CLOSURE;
class
GeneratorType
:
public
ConcreteCompilerType
{
public:
llvm
::
Type
*
llvmType
()
{
return
g
.
llvm_generator_type_ptr
;
}
std
::
string
debugName
()
{
return
"generator"
;
}
llvm
::
Type
*
llvmType
()
override
{
return
g
.
llvm_generator_type_ptr
;
}
std
::
string
debugName
()
override
{
return
"generator"
;
}
virtual
ConcreteCompilerType
*
getConcreteType
()
{
return
this
;
}
virtual
ConcreteCompilerType
*
getBoxType
()
{
return
GENERATOR
;
}
ConcreteCompilerType
*
getConcreteType
()
override
{
return
this
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
GENERATOR
;
}
v
irtual
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
{
v
oid
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
// pass
}
v
irtual
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
{
v
oid
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
// pass
}
...
...
@@ -1610,49 +1611,49 @@ ConcreteCompilerType* GENERATOR = &_GENERATOR;
class
StrConstantType
:
public
ValuedCompilerType
<
const
std
::
string
*>
{
public:
std
::
string
debugName
()
{
return
"str_constant"
;
}
std
::
string
debugName
()
override
{
return
"str_constant"
;
}
void
assertMatches
(
const
std
::
string
*
v
)
override
{}
virtual
ConcreteCompilerType
*
getConcreteType
()
{
return
STR
;
}
ConcreteCompilerType
*
getConcreteType
()
override
{
return
STR
;
}
virtual
ConcreteCompilerType
*
getBoxType
()
{
return
STR
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
STR
;
}
v
irtual
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
{
v
oid
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
// pass
}
v
irtual
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
{
v
oid
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
// pass
}
virtual
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
VAR
*
var
,
ConcreteCompilerType
*
other_type
)
{
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
VAR
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
assert
(
other_type
==
STR
||
other_type
==
UNKNOWN
);
llvm
::
Value
*
boxed
=
emitter
.
getBuilder
()
->
CreateCall
(
g
.
funcs
.
boxStringPtr
,
embedConstantPtr
(
var
->
getValue
(),
g
.
llvm_str_type_ptr
));
return
new
ConcreteCompilerVariable
(
other_type
,
boxed
,
true
);
}
virtual
bool
canConvertTo
(
ConcreteCompilerType
*
other
)
{
return
(
other
==
STR
||
other
==
UNKNOWN
);
}
bool
canConvertTo
(
ConcreteCompilerType
*
other
)
override
{
return
(
other
==
STR
||
other
==
UNKNOWN
);
}
virtual
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
bool
cls_only
)
{
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
STR
);
CompilerVariable
*
rtn
=
converted
->
getattr
(
emitter
,
info
,
attr
,
cls_only
);
converted
->
decvref
(
emitter
);
return
rtn
;
}
virtual
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
STR
);
CompilerVariable
*
rtn
=
converted
->
callattr
(
emitter
,
info
,
attr
,
clsonly
,
argspec
,
args
,
keyword_names
);
converted
->
decvref
(
emitter
);
return
rtn
;
}
virtual
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
slice
)
{
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
slice
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
STR
);
CompilerVariable
*
rtn
=
converted
->
getitem
(
emitter
,
info
,
slice
);
converted
->
decvref
(
emitter
);
...
...
@@ -1671,7 +1672,7 @@ public:
return
makeBool
(
var
->
getValue
()
->
size
()
!=
0
);
}
virtual
CompilerVariable
*
dup
(
VAR
*
var
,
DupCache
&
cache
)
{
CompilerVariable
*
dup
(
VAR
*
var
,
DupCache
&
cache
)
override
{
CompilerVariable
*&
rtn
=
cache
[
var
];
if
(
rtn
==
NULL
)
{
...
...
@@ -1702,7 +1703,7 @@ CompilerVariable* makeStr(const std::string* s) {
class
VoidType
:
public
ConcreteCompilerType
{
public:
llvm
::
Type
*
llvmType
()
{
return
g
.
void_
;
}
llvm
::
Type
*
llvmType
()
override
{
return
g
.
void_
;
}
Box
*
deserializeFromFrame
(
const
FrameVals
&
vals
)
override
{
abort
();
}
};
...
...
@@ -1715,24 +1716,24 @@ ConcreteCompilerType* typeFromClass(BoxedClass* c) {
class
BoolType
:
public
ConcreteCompilerType
{
public:
std
::
string
debugName
()
{
return
"bool"
;
}
llvm
::
Type
*
llvmType
()
{
std
::
string
debugName
()
override
{
return
"bool"
;
}
llvm
::
Type
*
llvmType
()
override
{
if
(
BOOLS_AS_I64
)
return
g
.
i64
;
else
return
g
.
i1
;
}
virtual
bool
isFitBy
(
BoxedClass
*
c
)
{
return
false
;
}
bool
isFitBy
(
BoxedClass
*
c
)
override
{
return
false
;
}
v
irtual
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
{
v
oid
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
// pass
}
v
irtual
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
{
v
oid
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
// pass
}
virtual
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
{
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
)
override
{
var
->
incvref
();
return
var
;
}
...
...
@@ -1741,8 +1742,8 @@ public:
return
(
other_type
==
UNKNOWN
||
other_type
==
BOXED_BOOL
||
other_type
==
BOOL
);
}
virtual
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
{
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
if
(
other_type
==
BOOL
)
{
var
->
incvref
();
return
var
;
...
...
@@ -1753,22 +1754,22 @@ public:
return
new
ConcreteCompilerVariable
(
other_type
,
boxed
,
true
);
}
virtual
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
{
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
return
BOXED_BOOL
->
getattrType
(
attr
,
cls_only
);
}
virtual
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
bool
cls_only
)
{
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_BOOL
);
CompilerVariable
*
rtn
=
converted
->
getattr
(
emitter
,
info
,
attr
,
cls_only
);
converted
->
decvref
(
emitter
);
return
rtn
;
}
virtual
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
ConcreteCompilerVariable
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
ConcreteCompilerVariable
*
converted
=
var
->
makeConverted
(
emitter
,
BOXED_BOOL
);
CompilerVariable
*
rtn
=
converted
->
callattr
(
emitter
,
info
,
attr
,
clsonly
,
argspec
,
args
,
keyword_names
);
converted
->
decvref
(
emitter
);
...
...
@@ -1783,7 +1784,7 @@ public:
return
rtn
;
}
virtual
ConcreteCompilerType
*
getBoxType
()
{
return
BOXED_BOOL
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
BOXED_BOOL
;
}
Box
*
deserializeFromFrame
(
const
FrameVals
&
vals
)
override
{
assert
(
vals
.
size
()
==
1
);
...
...
@@ -1826,18 +1827,18 @@ public:
}
}
std
::
string
debugName
()
{
return
name
;
}
std
::
string
debugName
()
override
{
return
name
;
}
v
irtual
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
{
v
oid
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
const
std
::
vector
<
CompilerVariable
*>*
elts
=
var
->
getValue
();
for
(
int
i
=
0
;
i
<
elts
->
size
();
i
++
)
{
(
*
elts
)[
i
]
->
decvref
(
emitter
);
}
}
v
irtual
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
{
RELEASE_ASSERT
(
0
,
""
);
}
v
oid
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{
RELEASE_ASSERT
(
0
,
""
);
}
virtual
CompilerVariable
*
dup
(
VAR
*
var
,
DupCache
&
cache
)
{
CompilerVariable
*
dup
(
VAR
*
var
,
DupCache
&
cache
)
override
{
CompilerVariable
*&
rtn
=
cache
[
var
];
if
(
rtn
==
NULL
)
{
...
...
@@ -1854,11 +1855,11 @@ public:
return
rtn
;
}
virtual
bool
canConvertTo
(
ConcreteCompilerType
*
other_type
)
{
bool
canConvertTo
(
ConcreteCompilerType
*
other_type
)
override
{
return
(
other_type
==
UNKNOWN
||
other_type
==
BOXED_TUPLE
);
}
virtual
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
VAR
*
var
,
ConcreteCompilerType
*
other_type
)
{
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
VAR
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
assert
(
other_type
==
UNKNOWN
||
other_type
==
BOXED_TUPLE
);
VEC
*
v
=
var
->
getValue
();
...
...
@@ -1894,13 +1895,13 @@ public:
return
new
ConcreteCompilerVariable
(
other_type
,
rtn
,
true
);
}
virtual
ConcreteCompilerType
*
getBoxType
()
{
return
BOXED_TUPLE
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
BOXED_TUPLE
;
}
virtual
ConcreteCompilerType
*
getConcreteType
()
{
return
BOXED_TUPLE
;
}
ConcreteCompilerType
*
getConcreteType
()
override
{
return
BOXED_TUPLE
;
}
static
TupleType
*
make
(
const
std
::
vector
<
CompilerType
*>&
elt_types
)
{
return
new
TupleType
(
elt_types
);
}
virtual
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
slice
)
{
CompilerVariable
*
getitem
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
CompilerVariable
*
slice
)
override
{
if
(
slice
->
getType
()
==
INT
)
{
llvm
::
Value
*
v
=
static_cast
<
ConcreteCompilerVariable
*>
(
slice
)
->
getValue
();
assert
(
v
->
getType
()
==
g
.
i64
);
...
...
@@ -1923,11 +1924,11 @@ public:
// return getConstantInt(var->getValue()->size(), g.i64);
}
virtual
ConcreteCompilerVariable
*
len
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
{
ConcreteCompilerVariable
*
len
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
override
{
return
new
ConcreteCompilerVariable
(
INT
,
getConstantInt
(
var
->
getValue
()
->
size
(),
g
.
i64
),
true
);
}
virtual
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
{
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
return
BOXED_TUPLE
->
getattrType
(
attr
,
cls_only
);
}
...
...
@@ -1939,9 +1940,9 @@ public:
return
rtn
;
}
virtual
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
return
makeConverted
(
emitter
,
var
,
getConcreteType
())
->
callattr
(
emitter
,
info
,
attr
,
clsonly
,
argspec
,
args
,
keyword_names
);
}
...
...
@@ -1997,7 +1998,7 @@ CompilerVariable* makeTuple(const std::vector<CompilerVariable*>& elts) {
class
UndefType
:
public
ConcreteCompilerType
{
public:
std
::
string
debugName
()
{
return
"undefType"
;
}
std
::
string
debugName
()
override
{
return
"undefType"
;
}
llvm
::
Type
*
llvmType
()
override
{
// Something that no one else uses...
...
...
@@ -2005,14 +2006,14 @@ public:
return
llvm
::
Type
::
getInt16Ty
(
g
.
context
);
}
virtual
CompilerVariable
*
call
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerVariable
*
call
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
return
undefVariable
();
}
v
irtual
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
{}
v
irtual
void
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
{}
virtual
CompilerVariable
*
dup
(
VAR
*
v
,
DupCache
&
cache
)
{
v
oid
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{}
v
oid
grab
(
IREmitter
&
emitter
,
VAR
*
var
)
override
{}
CompilerVariable
*
dup
(
VAR
*
v
,
DupCache
&
cache
)
override
{
// TODO copied from UnknownType
auto
&
rtn
=
cache
[
v
];
if
(
rtn
==
NULL
)
{
...
...
@@ -2022,27 +2023,27 @@ public:
}
return
rtn
;
}
virtual
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
VAR
*
var
,
ConcreteCompilerType
*
other_type
)
{
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
VAR
*
var
,
ConcreteCompilerType
*
other_type
)
override
{
llvm
::
Value
*
v
=
llvm
::
UndefValue
::
get
(
other_type
->
llvmType
());
return
new
ConcreteCompilerVariable
(
other_type
,
v
,
true
);
}
virtual
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
bool
cls_only
)
{
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
return
undefVariable
();
}
virtual
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
,
const
std
::
string
*
attr
,
bool
clsonly
,
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
return
undefVariable
();
}
virtual
CompilerType
*
callType
(
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerType
*>&
arg_types
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerType
*
callType
(
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerType
*>&
arg_types
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
return
UNDEF
;
}
virtual
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
{
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
VAR
*
var
)
override
{
return
new
ConcreteCompilerVariable
(
BOOL
,
llvm
::
UndefValue
::
get
(
BOOL
->
llvmType
()),
true
);
}
...
...
@@ -2051,15 +2052,15 @@ public:
return
undefVariable
();
}
virtual
ConcreteCompilerType
*
getBoxType
()
{
return
UNKNOWN
;
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
UNKNOWN
;
}
virtual
ConcreteCompilerType
*
getConcreteType
()
{
return
this
;
}
ConcreteCompilerType
*
getConcreteType
()
override
{
return
this
;
}
virtual
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
{
return
UNDEF
;
}
CompilerType
*
getattrType
(
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
return
UNDEF
;
}
virtual
bool
canConvertTo
(
ConcreteCompilerType
*
other_type
)
{
return
true
;
}
bool
canConvertTo
(
ConcreteCompilerType
*
other_type
)
override
{
return
true
;
}
virtual
BoxedClass
*
guaranteedClass
()
{
return
NULL
;
}
BoxedClass
*
guaranteedClass
()
override
{
return
NULL
;
}
Box
*
deserializeFromFrame
(
const
FrameVals
&
vals
)
override
{
assert
(
vals
.
size
()
==
1
);
...
...
src/codegen/compvars.h
View file @
3420ef7e
...
...
@@ -165,9 +165,9 @@ template <class V> class ValuedCompilerType : public _ValuedCompilerType<V> { pu
template
<
>
class
ValuedCompilerType
<
llvm
::
Value
*>
:
public
_ValuedCompilerType
<
llvm
::
Value
*>
{
public:
virtual
llvm
::
Type
*
llvmType
()
=
0
;
virtual
std
::
string
debugName
()
;
std
::
string
debugName
()
override
;
void
assertMatches
(
llvm
::
Value
*
v
)
override
final
{
void
assertMatches
(
llvm
::
Value
*
v
)
override
{
if
(
v
->
getType
()
!=
llvmType
())
{
v
->
getType
()
->
dump
();
llvmType
()
->
dump
();
...
...
@@ -181,13 +181,13 @@ public:
abort
();
}
virtual
CompilerVariable
*
dup
(
ConcreteCompilerVariable
*
v
,
DupCache
&
cache
)
;
virtual
ConcreteCompilerType
*
getConcreteType
()
{
return
this
;
}
virtual
bool
canConvertTo
(
ConcreteCompilerType
*
other_type
)
{
return
other_type
==
this
||
other_type
==
UNKNOWN
;
}
virtual
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
;
void
serializeToFrame
(
VAR
*
var
,
std
::
vector
<
llvm
::
Value
*>&
stackmap_args
)
override
final
;
int
numFrameArgs
()
override
final
{
return
1
;
}
CompilerVariable
*
dup
(
ConcreteCompilerVariable
*
v
,
DupCache
&
cache
)
override
;
ConcreteCompilerType
*
getConcreteType
()
override
{
return
this
;
}
bool
canConvertTo
(
ConcreteCompilerType
*
other_type
)
override
{
return
other_type
==
this
||
other_type
==
UNKNOWN
;
}
ConcreteCompilerVariable
*
makeConverted
(
IREmitter
&
emitter
,
ConcreteCompilerVariable
*
var
,
ConcreteCompilerType
*
other_type
)
override
;
void
serializeToFrame
(
VAR
*
var
,
std
::
vector
<
llvm
::
Value
*>&
stackmap_args
)
override
;
int
numFrameArgs
()
override
{
return
1
;
}
};
class
CompilerVariable
{
...
...
@@ -273,8 +273,8 @@ private:
V
value
;
protected:
v
irtual
void
drop
(
IREmitter
&
emitter
)
{
type
->
drop
(
emitter
,
this
);
}
v
irtual
void
grab
(
IREmitter
&
emmitter
)
{
type
->
grab
(
emmitter
,
this
);
}
v
oid
drop
(
IREmitter
&
emitter
)
override
{
type
->
drop
(
emitter
,
this
);
}
v
oid
grab
(
IREmitter
&
emmitter
)
override
{
type
->
grab
(
emmitter
,
this
);
}
public:
ValuedCompilerVariable
(
T
*
type
,
V
value
,
bool
grabbed
)
:
CompilerVariable
(
grabbed
),
type
(
type
),
value
(
value
)
{
...
...
@@ -282,8 +282,8 @@ public:
type
->
assertMatches
(
value
);
#endif
}
virtual
T
*
getType
()
{
return
type
;
}
virtual
V
getValue
()
{
return
value
;
}
T
*
getType
()
override
{
return
type
;
}
V
getValue
()
{
return
value
;
}
ConcreteCompilerType
*
getConcreteType
()
override
{
return
type
->
getConcreteType
();
}
ConcreteCompilerType
*
getBoxType
()
override
{
return
type
->
getBoxType
();
}
...
...
@@ -315,20 +315,20 @@ public:
ConcreteCompilerVariable
*
nonzero
(
IREmitter
&
emitter
,
const
OpInfo
&
info
)
override
{
return
type
->
nonzero
(
emitter
,
info
,
this
);
}
virtual
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
const
std
::
string
*
attr
,
bool
cls_only
)
{
CompilerVariable
*
getattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
const
std
::
string
*
attr
,
bool
cls_only
)
override
{
return
type
->
getattr
(
emitter
,
info
,
this
,
attr
,
cls_only
);
}
v
irtual
void
setattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
const
std
::
string
*
attr
,
CompilerVariable
*
v
)
{
v
oid
setattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
const
std
::
string
*
attr
,
CompilerVariable
*
v
)
override
{
type
->
setattr
(
emitter
,
info
,
this
,
attr
,
v
);
}
v
irtual
void
delattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
const
std
::
string
*
attr
)
{
v
oid
delattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
const
std
::
string
*
attr
)
override
{
type
->
delattr
(
emitter
,
info
,
this
,
attr
);
}
virtual
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
const
std
::
string
*
attr
,
bool
clsonly
,
struct
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
{
CompilerVariable
*
callattr
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
const
std
::
string
*
attr
,
bool
clsonly
,
struct
ArgPassSpec
argspec
,
const
std
::
vector
<
CompilerVariable
*>&
args
,
const
std
::
vector
<
const
std
::
string
*>*
keyword_names
)
override
{
return
type
->
callattr
(
emitter
,
info
,
this
,
attr
,
clsonly
,
argspec
,
args
,
keyword_names
);
}
CompilerVariable
*
call
(
IREmitter
&
emitter
,
const
OpInfo
&
info
,
struct
ArgPassSpec
argspec
,
...
...
src/codegen/irgen/irgenerator.cpp
View file @
3420ef7e
...
...
@@ -2244,7 +2244,7 @@ private:
}
public:
void
addFrameStackmapArgs
(
PatchpointInfo
*
pp
,
std
::
vector
<
llvm
::
Value
*>&
stackmap_args
)
{
void
addFrameStackmapArgs
(
PatchpointInfo
*
pp
,
std
::
vector
<
llvm
::
Value
*>&
stackmap_args
)
override
{
int
initial_args
=
stackmap_args
.
size
();
if
(
ENABLE_FRAME_INTROSPECTION
)
{
// TODO: don't need to use a sorted symbol table if we're explicitly recording the names!
...
...
src/codegen/opt/aa.cpp
View file @
3420ef7e
...
...
@@ -221,7 +221,7 @@ public:
return
MayAlias
;
}
virtual
AliasResult
alias
(
const
Location
&
LocA
,
const
Location
&
LocB
)
{
AliasResult
alias
(
const
Location
&
LocA
,
const
Location
&
LocB
)
override
{
if
(
VERBOSITY
(
"opt.aa"
)
>=
2
&&
depth
==
0
)
{
cast
<
Instruction
>
(
LocA
.
Ptr
)
->
getParent
()
->
dump
();
}
...
...
@@ -245,7 +245,7 @@ public:
// There are multiple (overloaded) "getModRefInfo" functions in AliasAnalysis, and apparently
// this means you need to add this line:
using
AliasAnalysis
::
getModRefInfo
;
virtual
ModRefResult
getModRefInfo
(
ImmutableCallSite
CS
,
const
Location
&
Loc
)
{
ModRefResult
getModRefInfo
(
ImmutableCallSite
CS
,
const
Location
&
Loc
)
override
{
ModRefResult
base
=
AliasAnalysis
::
getModRefInfo
(
CS
,
Loc
);
if
(
!
CS
.
getCalledFunction
())
return
base
;
...
...
@@ -308,7 +308,7 @@ public:
return
ModRefResult
(
mask
&
base
);
}
v
irtual
void
*
getAdjustedAnalysisPointer
(
const
void
*
ID
)
{
v
oid
*
getAdjustedAnalysisPointer
(
const
void
*
ID
)
override
{
if
(
ID
==
&
AliasAnalysis
::
ID
)
return
(
AliasAnalysis
*
)
this
;
return
this
;
...
...
src/core/cfg.cpp
View file @
3420ef7e
...
...
@@ -1088,7 +1088,7 @@ public:
curblock
=
normal_dest
;
}
virtual
bool
visit_classdef
(
AST_ClassDef
*
node
)
{
bool
visit_classdef
(
AST_ClassDef
*
node
)
override
{
// Remap in place: see note in visit_functiondef for why.
// Decorators are evaluated before the defaults:
...
...
@@ -1104,7 +1104,7 @@ public:
return
true
;
}
virtual
bool
visit_functiondef
(
AST_FunctionDef
*
node
)
{
bool
visit_functiondef
(
AST_FunctionDef
*
node
)
override
{
// As much as I don't like it, for now we're remapping these in place.
// This is because we do certain analyses pre-remapping, and associate the
// results with the node. We can either do some refactoring and have a way
...
...
@@ -1128,7 +1128,7 @@ public:
return
true
;
}
virtual
bool
visit_global
(
AST_Global
*
node
)
{
bool
visit_global
(
AST_Global
*
node
)
override
{
push_back
(
node
);
return
true
;
}
...
...
@@ -1142,7 +1142,7 @@ public:
}
}
virtual
bool
visit_import
(
AST_Import
*
node
)
{
bool
visit_import
(
AST_Import
*
node
)
override
{
for
(
AST_alias
*
a
:
node
->
names
)
{
AST_LangPrimitive
*
import
=
new
AST_LangPrimitive
(
AST_LangPrimitive
::
IMPORT_NAME
);
import
->
args
.
push_back
(
new
AST_Num
());
...
...
@@ -1182,7 +1182,7 @@ public:
return
true
;
}
virtual
bool
visit_importfrom
(
AST_ImportFrom
*
node
)
{
bool
visit_importfrom
(
AST_ImportFrom
*
node
)
override
{
RELEASE_ASSERT
(
node
->
level
==
0
,
""
);
AST_LangPrimitive
*
import
=
new
AST_LangPrimitive
(
AST_LangPrimitive
::
IMPORT_NAME
);
...
...
@@ -1227,7 +1227,7 @@ public:
return
true
;
}
virtual
bool
visit_pass
(
AST_Pass
*
node
)
{
return
true
;
}
bool
visit_pass
(
AST_Pass
*
node
)
override
{
return
true
;
}
bool
visit_assert
(
AST_Assert
*
node
)
override
{
AST_Branch
*
br
=
new
AST_Branch
();
...
...
@@ -1280,7 +1280,7 @@ public:
return
true
;
}
virtual
bool
visit_assign
(
AST_Assign
*
node
)
{
bool
visit_assign
(
AST_Assign
*
node
)
override
{
AST_expr
*
remapped_value
=
remapExpr
(
node
->
value
);
for
(
AST_expr
*
target
:
node
->
targets
)
{
...
...
@@ -1289,7 +1289,7 @@ public:
return
true
;
}
virtual
bool
visit_augassign
(
AST_AugAssign
*
node
)
{
bool
visit_augassign
(
AST_AugAssign
*
node
)
override
{
// augassign is pretty tricky; "x" += "y" mostly textually maps to
// "x" = "x" =+ "y" (using "=+" to represent an augbinop)
// except that "x" only gets evaluated once. So it's something like
...
...
@@ -1382,7 +1382,7 @@ public:
return
true
;
}
virtual
bool
visit_delete
(
AST_Delete
*
node
)
{
bool
visit_delete
(
AST_Delete
*
node
)
override
{
for
(
auto
t
:
node
->
targets
)
{
AST_Delete
*
astdel
=
new
AST_Delete
();
astdel
->
lineno
=
node
->
lineno
;
...
...
@@ -1418,7 +1418,7 @@ public:
return
true
;
}
virtual
bool
visit_expr
(
AST_Expr
*
node
)
{
bool
visit_expr
(
AST_Expr
*
node
)
override
{
AST_Expr
*
remapped
=
new
AST_Expr
();
remapped
->
lineno
=
node
->
lineno
;
remapped
->
col_offset
=
node
->
col_offset
;
...
...
@@ -1427,7 +1427,7 @@ public:
return
true
;
}
virtual
bool
visit_print
(
AST_Print
*
node
)
{
bool
visit_print
(
AST_Print
*
node
)
override
{
AST_expr
*
dest
=
remapExpr
(
node
->
dest
);
int
i
=
0
;
...
...
@@ -1464,7 +1464,7 @@ public:
return
true
;
}
virtual
bool
visit_return
(
AST_Return
*
node
)
{
bool
visit_return
(
AST_Return
*
node
)
override
{
if
(
root_type
!=
AST_TYPE
::
FunctionDef
&&
root_type
!=
AST_TYPE
::
Lambda
)
{
raiseExcHelper
(
SyntaxError
,
"'return' outside function"
);
}
...
...
@@ -1476,7 +1476,7 @@ public:
return
true
;
}
virtual
bool
visit_if
(
AST_If
*
node
)
{
bool
visit_if
(
AST_If
*
node
)
override
{
if
(
!
curblock
)
return
true
;
...
...
@@ -1531,7 +1531,7 @@ public:
return
true
;
}
virtual
bool
visit_break
(
AST_Break
*
node
)
{
bool
visit_break
(
AST_Break
*
node
)
override
{
if
(
!
curblock
)
return
true
;
...
...
@@ -1549,7 +1549,7 @@ public:
return
true
;
}
virtual
bool
visit_continue
(
AST_Continue
*
node
)
{
bool
visit_continue
(
AST_Continue
*
node
)
override
{
if
(
!
curblock
)
return
true
;
...
...
@@ -1568,7 +1568,7 @@ public:
return
true
;
}
virtual
bool
visit_while
(
AST_While
*
node
)
{
bool
visit_while
(
AST_While
*
node
)
override
{
if
(
!
curblock
)
return
true
;
...
...
@@ -1629,7 +1629,7 @@ public:
return
true
;
}
virtual
bool
visit_for
(
AST_For
*
node
)
{
bool
visit_for
(
AST_For
*
node
)
override
{
if
(
!
curblock
)
return
true
;
...
...
@@ -1867,7 +1867,7 @@ public:
return
true
;
}
virtual
bool
visit_with
(
AST_With
*
node
)
{
bool
visit_with
(
AST_With
*
node
)
override
{
char
ctxmgrname_buf
[
80
];
snprintf
(
ctxmgrname_buf
,
80
,
"#ctxmgr_%p"
,
node
);
char
exitname_buf
[
80
];
...
...
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