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
d3657206
Commit
d3657206
authored
Oct 16, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some extra error checking during irgen
parent
204b1da6
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
5 deletions
+66
-5
.gitignore
.gitignore
+2
-0
src/Makefile
src/Makefile
+1
-2
src/codegen/compvars.cpp
src/codegen/compvars.cpp
+16
-0
src/codegen/compvars.h
src/codegen/compvars.h
+19
-1
test/tests/locals_test.py
test/tests/locals_test.py
+28
-2
No files found.
.gitignore
View file @
d3657206
...
@@ -50,3 +50,5 @@ compile.log
...
@@ -50,3 +50,5 @@ compile.log
*.swp
*.swp
*.swo
*.swo
*.out
src/Makefile
View file @
d3657206
...
@@ -528,8 +528,7 @@ llvm_install: llvm_release
...
@@ -528,8 +528,7 @@ llvm_install: llvm_release
# Clear OPTIONAL_DIRS and OPTIONAL_PARALLEL_DIRS to make sure that clang doesn't get built+tested
# Clear OPTIONAL_DIRS and OPTIONAL_PARALLEL_DIRS to make sure that clang doesn't get built+tested
llvm_test
:
llvm_test_quick
llvm_test
:
llvm_test_quick
$(MAKE)
llvm_test_release
llvm_test_quick
:
llvm_quick llvm/quick/tools/opt
llvm_test_quick
:
llvm_test_quick
$(MAKE)
-C
$(LLVM_BUILD)
OPTIONAL_DIRS
=
OPTIONAL_PARALLEL_DIRS
=
ENABLE_OPTIMIZED
=
1 check
$(MAKE)
-C
$(LLVM_BUILD)
OPTIONAL_DIRS
=
OPTIONAL_PARALLEL_DIRS
=
ENABLE_OPTIMIZED
=
1 check
llvm_test_release
:
llvm_release
llvm_test_release
:
llvm_release
$(MAKE)
-C
$(LLVM_BUILD)
OPTIONAL_DIRS
=
OPTIONAL_PARALLEL_DIRS
=
ENABLE_OPTIMIZED
=
1
DISABLE_ASSERTIONS
=
1 check
$(MAKE)
-C
$(LLVM_BUILD)
OPTIONAL_DIRS
=
OPTIONAL_PARALLEL_DIRS
=
ENABLE_OPTIMIZED
=
1
DISABLE_ASSERTIONS
=
1 check
...
...
src/codegen/compvars.cpp
View file @
d3657206
...
@@ -64,6 +64,10 @@ private:
...
@@ -64,6 +64,10 @@ private:
}
}
public:
public:
void
assertMatches
(
RawInstanceMethod
*
im
)
override
{
assert
(
obj_type
==
im
->
obj
->
getType
()
&&
function_type
==
im
->
func
->
getType
());
}
static
InstanceMethodType
*
get
(
CompilerType
*
obj_type
,
CompilerType
*
function_type
)
{
static
InstanceMethodType
*
get
(
CompilerType
*
obj_type
,
CompilerType
*
function_type
)
{
InstanceMethodType
*
rtn
=
made
[
std
::
make_pair
(
obj_type
,
function_type
)];
InstanceMethodType
*
rtn
=
made
[
std
::
make_pair
(
obj_type
,
function_type
)];
if
(
rtn
==
NULL
)
if
(
rtn
==
NULL
)
...
@@ -1154,6 +1158,8 @@ private:
...
@@ -1154,6 +1158,8 @@ private:
public:
public:
virtual
std
::
string
debugName
()
{
return
"class '"
+
*
getNameOfClass
(
cls
)
+
"'"
;
}
virtual
std
::
string
debugName
()
{
return
"class '"
+
*
getNameOfClass
(
cls
)
+
"'"
;
}
void
assertMatches
(
BoxedClass
*
cls
)
override
{
assert
(
cls
==
this
->
cls
);
}
static
KnownClassobjType
*
fromClass
(
BoxedClass
*
cls
)
{
static
KnownClassobjType
*
fromClass
(
BoxedClass
*
cls
)
{
KnownClassobjType
*&
rtn
=
made
[
cls
];
KnownClassobjType
*&
rtn
=
made
[
cls
];
if
(
rtn
==
NULL
)
{
if
(
rtn
==
NULL
)
{
...
@@ -1544,6 +1550,8 @@ class StrConstantType : public ValuedCompilerType<const std::string*> {
...
@@ -1544,6 +1550,8 @@ class StrConstantType : public ValuedCompilerType<const std::string*> {
public:
public:
std
::
string
debugName
()
{
return
"str_constant"
;
}
std
::
string
debugName
()
{
return
"str_constant"
;
}
void
assertMatches
(
const
std
::
string
*
v
)
override
{}
virtual
ConcreteCompilerType
*
getConcreteType
()
{
return
STR
;
}
virtual
ConcreteCompilerType
*
getConcreteType
()
{
return
STR
;
}
virtual
ConcreteCompilerType
*
getBoxType
()
{
return
STR
;
}
virtual
ConcreteCompilerType
*
getBoxType
()
{
return
STR
;
}
...
@@ -1721,6 +1729,14 @@ private:
...
@@ -1721,6 +1729,14 @@ private:
public:
public:
typedef
const
std
::
vector
<
CompilerVariable
*>
VEC
;
typedef
const
std
::
vector
<
CompilerVariable
*>
VEC
;
void
assertMatches
(
const
std
::
vector
<
CompilerVariable
*>*
v
)
override
{
assert
(
v
->
size
()
==
elt_types
.
size
());
for
(
int
i
=
0
;
i
<
v
->
size
();
i
++
)
{
assert
((
*
v
)[
i
]
->
getType
()
==
elt_types
[
i
]);
}
}
std
::
string
debugName
()
{
return
name
;
}
std
::
string
debugName
()
{
return
name
;
}
virtual
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
{
virtual
void
drop
(
IREmitter
&
emitter
,
VAR
*
var
)
{
...
...
src/codegen/compvars.h
View file @
d3657206
...
@@ -18,6 +18,9 @@
...
@@ -18,6 +18,9 @@
#include <stdint.h>
#include <stdint.h>
#include <vector>
#include <vector>
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "core/ast.h"
#include "core/ast.h"
#include "core/types.h"
#include "core/types.h"
...
@@ -53,6 +56,8 @@ template <class V> class _ValuedCompilerType : public CompilerType {
...
@@ -53,6 +56,8 @@ template <class V> class _ValuedCompilerType : public CompilerType {
public:
public:
typedef
ValuedCompilerVariable
<
V
>
VAR
;
typedef
ValuedCompilerVariable
<
V
>
VAR
;
virtual
void
assertMatches
(
V
v
)
=
0
;
virtual
CompilerVariable
*
dup
(
VAR
*
v
,
DupCache
&
cache
)
{
virtual
CompilerVariable
*
dup
(
VAR
*
v
,
DupCache
&
cache
)
{
printf
(
"dup not defined for %s
\n
"
,
debugName
().
c_str
());
printf
(
"dup not defined for %s
\n
"
,
debugName
().
c_str
());
abort
();
abort
();
...
@@ -156,6 +161,15 @@ public:
...
@@ -156,6 +161,15 @@ public:
virtual
llvm
::
Type
*
llvmType
()
=
0
;
virtual
llvm
::
Type
*
llvmType
()
=
0
;
virtual
std
::
string
debugName
();
virtual
std
::
string
debugName
();
void
assertMatches
(
llvm
::
Value
*
v
)
override
final
{
if
(
v
->
getType
()
!=
llvmType
())
{
v
->
getType
()
->
dump
();
llvmType
()
->
dump
();
fprintf
(
stderr
,
"
\n
"
);
}
assert
(
v
->
getType
()
==
llvmType
());
}
virtual
bool
isFitBy
(
BoxedClass
*
)
{
virtual
bool
isFitBy
(
BoxedClass
*
)
{
printf
(
"isFitBy not defined for %s
\n
"
,
debugName
().
c_str
());
printf
(
"isFitBy not defined for %s
\n
"
,
debugName
().
c_str
());
abort
();
abort
();
...
@@ -253,7 +267,11 @@ protected:
...
@@ -253,7 +267,11 @@ protected:
virtual
void
grab
(
IREmitter
&
emmitter
)
{
type
->
grab
(
emmitter
,
this
);
}
virtual
void
grab
(
IREmitter
&
emmitter
)
{
type
->
grab
(
emmitter
,
this
);
}
public:
public:
ValuedCompilerVariable
(
T
*
type
,
V
value
,
bool
grabbed
)
:
CompilerVariable
(
grabbed
),
type
(
type
),
value
(
value
)
{}
ValuedCompilerVariable
(
T
*
type
,
V
value
,
bool
grabbed
)
:
CompilerVariable
(
grabbed
),
type
(
type
),
value
(
value
)
{
#ifndef NDEBUG
type
->
assertMatches
(
value
);
#endif
}
virtual
T
*
getType
()
{
return
type
;
}
virtual
T
*
getType
()
{
return
type
;
}
virtual
V
getValue
()
{
return
value
;
}
virtual
V
getValue
()
{
return
value
;
}
...
...
test/tests/locals_test.py
View file @
d3657206
# expected: fail
# expected: fail
# - locals not supported
# - locals not supported
def
f1
():
l
=
[]
for
i
in
xrange
(
5
):
l
.
append
(
i
**
2
)
print
sorted
(
locals
().
items
())
f1
()
def
f
():
def
f
():
total
=
0
total
=
0
i
=
1
or
''
i
=
1
or
''
while
i
<
20
0
:
while
i
<
20
:
i
=
i
+
1
i
=
i
+
1
j
=
2
j
=
2
while
j
*
j
<=
i
:
while
j
*
j
<=
i
:
if
i
%
j
==
0
:
if
i
%
j
==
0
:
break
break
j
=
j
+
1
j
=
j
+
1
print
locals
(
)
print
sorted
(
locals
().
items
()
)
else
:
else
:
total
=
total
+
i
total
=
total
+
i
print
total
print
total
f
()
f
()
def
f3
():
"""Testing unboxed values"""
x
=
1.0
y
=
1
z
=
123456789123456789
s
=
"hello world"
t
=
(
1.0
,
"asdf"
)
print
sorted
(
locals
().
items
())
f3
()
def
f4
():
"""testing synthetic 'is_defined' variables"""
if
0
:
x
=
1
else
:
y
=
2
print
sorted
(
locals
().
items
())
# f4()
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