Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Aleksandr Chmil
lo3
Commits
e54ea404
Commit
e54ea404
authored
Jan 14, 2020
by
Vladislav Perepelkin
Browse files
python 2 to 3 migration
parent
53017b58
Changes
13
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
e54ea404
...
@@ -24,7 +24,7 @@ CXX_WARN ?= \
...
@@ -24,7 +24,7 @@ CXX_WARN ?= \
-Wall
-Werror
-Wpedantic
-Wno-vla
-Wno-sign-compare
\
-Wall
-Werror
-Wpedantic
-Wno-vla
-Wno-sign-compare
\
-Wno-unused-but-set-variable
-Wno-unused-variable
\
-Wno-unused-but-set-variable
-Wno-unused-variable
\
-Wno-unused-function
-Wno-unused-function
PYTHON
?=
python
2
PYTHON
?=
python
3
MPICXX
?=
mpicxx
MPICXX
?=
mpicxx
MPICH_CXX
?=
${CXX}
MPICH_CXX
?=
${CXX}
CXX_FLAGS
+=
\
CXX_FLAGS
+=
\
...
...
scripts/common.py
View file @
e54ea404
#!/usr/bin/python
#!/usr/bin/python
3
class
FatalError
(
Exception
):
class
FatalError
(
Exception
):
def
__init__
(
self
,
message
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
message
,
*
args
,
**
kwargs
):
...
...
scripts/explore_log_cfs.py
View file @
e54ea404
...
@@ -58,7 +58,7 @@ def read_cfs(filename):
...
@@ -58,7 +58,7 @@ def read_cfs(filename):
for
i
,
s
in
read_file_lines
(
filename
):
for
i
,
s
in
read_file_lines
(
filename
):
rank
,
time
,
event
,
description
=
get_rank_time_event_description
(
s
)
rank
,
time
,
event
,
description
=
get_rank_time_event_description
(
s
)
if
event
==
None
:
if
event
==
None
:
print
(
i
,
s
)
print
(
(
i
,
s
)
)
if
event
in
events_cf
:
if
event
in
events_cf
:
cfname
=
get_cf_name
(
s
)[
0
]
cfname
=
get_cf_name
(
s
)[
0
]
key
=
(
cfname
,
rank
)
key
=
(
cfname
,
rank
)
...
@@ -95,7 +95,7 @@ def output_cfs(filename,cfs):
...
@@ -95,7 +95,7 @@ def output_cfs(filename,cfs):
#------------------------------------------------------------------
#------------------------------------------------------------------
if
len
(
sys
.
argv
)
==
1
:
if
len
(
sys
.
argv
)
==
1
:
print
(
"Usage:"
,
sys
.
argv
[
0
],
"<filename>"
)
print
(
(
"Usage:"
,
sys
.
argv
[
0
],
"<filename>"
)
)
sys
.
exit
()
sys
.
exit
()
logfilename
=
sys
.
argv
[
1
]
logfilename
=
sys
.
argv
[
1
]
...
...
scripts/explore_log_dfs.py
View file @
e54ea404
...
@@ -58,7 +58,7 @@ def read_dfs(filename):
...
@@ -58,7 +58,7 @@ def read_dfs(filename):
for
i
,
s
in
read_file_lines
(
filename
):
for
i
,
s
in
read_file_lines
(
filename
):
rank
,
time
,
event
,
description
=
get_rank_time_event_description
(
s
)
rank
,
time
,
event
,
description
=
get_rank_time_event_description
(
s
)
if
event
==
None
:
if
event
==
None
:
print
(
i
,
s
)
print
(
(
i
,
s
)
)
if
event
in
events_df
:
if
event
in
events_df
:
dfname
=
get_df_name
(
s
)[
0
]
dfname
=
get_df_name
(
s
)[
0
]
key
=
(
dfname
,
rank
)
key
=
(
dfname
,
rank
)
...
@@ -93,7 +93,7 @@ def split_dfs_resp_unresp(dfs):
...
@@ -93,7 +93,7 @@ def split_dfs_resp_unresp(dfs):
newdf
=
[
df
[
IDFNAME
],
df
[
IRANK
],
[],
len
(
reqs
)
]
newdf
=
[
df
[
IDFNAME
],
df
[
IRANK
],
[],
len
(
reqs
)
]
n
=
0
n
=
0
for
event
in
df
[
IEVENTS
]:
for
event
in
df
[
IEVENTS
]:
if
n
in
reqs
.
values
():
if
n
in
list
(
reqs
.
values
()
)
:
newevent
=
(
event
[
0
],
event
[
1
],
event
[
2
],
1
)
newevent
=
(
event
[
0
],
event
[
1
],
event
[
2
],
1
)
else
:
else
:
newevent
=
(
event
[
0
],
event
[
1
],
event
[
2
],
0
)
newevent
=
(
event
[
0
],
event
[
1
],
event
[
2
],
0
)
...
@@ -124,7 +124,7 @@ def output_dfs_unresp(filename,dfs):
...
@@ -124,7 +124,7 @@ def output_dfs_unresp(filename,dfs):
#------------------------------------------------------------------
#------------------------------------------------------------------
if
len
(
sys
.
argv
)
==
1
:
if
len
(
sys
.
argv
)
==
1
:
print
(
"Usage:"
,
sys
.
argv
[
0
],
"<filename>"
)
print
(
(
"Usage:"
,
sys
.
argv
[
0
],
"<filename>"
)
)
sys
.
exit
()
sys
.
exit
()
logfilename
=
sys
.
argv
[
1
]
logfilename
=
sys
.
argv
[
1
]
...
...
scripts/fcmp
View file @
e54ea404
#!/usr/bin/python
#!/usr/bin/python
3
# COMPILATION OPTIONS
# COMPILATION OPTIONS
...
@@ -342,12 +342,12 @@ class RegFile:
...
@@ -342,12 +342,12 @@ class RegFile:
def
name_info
(
self
,
name
):
def
name_info
(
self
,
name
):
res
=
'%s:'
%
name
res
=
'%s:'
%
name
for
kind
,
spec
in
self
.
_names
[
name
].
iter
items
():
for
kind
,
spec
in
self
.
_names
[
name
].
items
():
if
spec
is
None
:
if
spec
is
None
:
res
+=
' %s'
%
kind
res
+=
' %s'
%
kind
else
:
else
:
res
+=
' %s{'
%
kind
+
' '
.
join
([
'%s=%s'
%
(
k
,
repr
(
v
))
\
res
+=
' %s{'
%
kind
+
' '
.
join
([
'%s=%s'
%
(
k
,
repr
(
v
))
\
for
k
,
v
in
spec
.
iter
items
()])
+
'}'
for
k
,
v
in
spec
.
items
()])
+
'}'
return
res
return
res
def
alloc
(
self
,
comment
):
def
alloc
(
self
,
comment
):
...
@@ -410,7 +410,7 @@ class RegFile:
...
@@ -410,7 +410,7 @@ class RegFile:
elif
type
(
val
)
==
list
:
elif
type
(
val
)
==
list
:
val_class
=
'symbolic'
val_class
=
'symbolic'
val
=
{
'type'
:
'id'
,
'ref'
:
val
}
val
=
{
'type'
:
'id'
,
'ref'
:
val
}
elif
type
(
val
)
in
[
str
,
unicode
]:
elif
type
(
val
)
in
[
str
,
str
]:
val_class
=
'generated'
val_class
=
'generated'
else
:
else
:
raise
Exception
(
val
,
val
.
__class__
)
raise
Exception
(
val
,
val
.
__class__
)
...
@@ -448,7 +448,7 @@ class RegFile:
...
@@ -448,7 +448,7 @@ class RegFile:
if
id
.
Name
in
self
.
Locators
:
if
id
.
Name
in
self
.
Locators
:
l
=
self
.
Locators
[
id
.
Name
]
l
=
self
.
Locators
[
id
.
Name
]
if
len
(
id
.
Indices
)
!=
len
(
l
[
'vars'
]):
if
len
(
id
.
Indices
)
!=
len
(
l
[
'vars'
]):
print
id
,
l
[
'vars'
]
print
(
id
,
l
[
'vars'
]
)
raise
Exception
(
'idx length missmatch'
)
raise
Exception
(
'idx length missmatch'
)
params
=
{}
params
=
{}
...
@@ -462,7 +462,7 @@ class RegFile:
...
@@ -462,7 +462,7 @@ class RegFile:
res
=
json
.
loads
(
json
.
dumps
(
l
[
'expr'
]))
res
=
json
.
loads
(
json
.
dumps
(
l
[
'expr'
]))
for
k
,
v
in
params
.
iter
items
():
for
k
,
v
in
params
.
items
():
regs
.
set_param
(
k
,
v
)
regs
.
set_param
(
k
,
v
)
return
res
,
params
return
res
,
params
elif
self
.
Parent
is
not
None
:
elif
self
.
Parent
is
not
None
:
...
@@ -480,7 +480,7 @@ class RegFile:
...
@@ -480,7 +480,7 @@ class RegFile:
if
id
.
Name
in
self
.
Locators
:
if
id
.
Name
in
self
.
Locators
:
l
=
self
.
Locators
[
id
.
Name
]
l
=
self
.
Locators
[
id
.
Name
]
if
len
(
id
.
Indices
)
!=
len
(
l
[
'vars'
]):
if
len
(
id
.
Indices
)
!=
len
(
l
[
'vars'
]):
print
id
,
l
[
'vars'
]
print
(
id
,
l
[
'vars'
]
)
sys
.
stderr
.
write
(
'%s %s
\n
'
%
(
repr
(
id
),
repr
(
l
[
'vars'
])))
sys
.
stderr
.
write
(
'%s %s
\n
'
%
(
repr
(
id
),
repr
(
l
[
'vars'
])))
raise
Exception
(
'idx length missmatch'
)
raise
Exception
(
'idx length missmatch'
)
...
@@ -492,7 +492,7 @@ class RegFile:
...
@@ -492,7 +492,7 @@ class RegFile:
params
[
key
]
=
regs
.
set_param
(
key
,
expr
.
gen
(
regs
))
params
[
key
]
=
regs
.
set_param
(
key
,
expr
.
gen
(
regs
))
res
=
LocatorCyclicExpr
(
create_expr
(
l
[
'expr'
],
regs
)).
gen
(
regs
)
res
=
LocatorCyclicExpr
(
create_expr
(
l
[
'expr'
],
regs
)).
gen
(
regs
)
for
k
,
v
in
params
.
iter
items
():
for
k
,
v
in
params
.
items
():
regs
.
set_param
(
k
,
v
)
regs
.
set_param
(
k
,
v
)
return
res
return
res
elif
self
.
Parent
is
not
None
:
elif
self
.
Parent
is
not
None
:
...
@@ -523,7 +523,7 @@ class RegFile:
...
@@ -523,7 +523,7 @@ class RegFile:
res
=
self
.
get_name_reg
(
name
)
res
=
self
.
get_name_reg
(
name
)
return
res
return
res
else
:
else
:
print
self
print
(
self
)
raise
Exception
(
'Name not recognized'
,
name
)
raise
Exception
(
'Name not recognized'
,
name
)
else
:
else
:
# According to name lookup priority:
# According to name lookup priority:
...
@@ -575,13 +575,13 @@ class RegFile:
...
@@ -575,13 +575,13 @@ class RegFile:
else
:
else
:
return
spec
[
'sub_param'
][
'reg'
]
return
spec
[
'sub_param'
][
'reg'
]
else
:
else
:
print
self
.
_names
[
name
]
print
(
self
.
_names
[
name
]
)
print
self
.
name_info
(
name
)
print
(
self
.
name_info
(
name
)
)
R
(
name
)
R
(
name
)
R
()
R
()
def
imported
(
self
,
parent_reg
):
def
imported
(
self
,
parent_reg
):
for
reg
,
spec
in
self
.
_regs
.
iter
items
():
for
reg
,
spec
in
self
.
_regs
.
items
():
if
spec
[
'type'
]
==
'import'
and
spec
[
'parent_reg'
]
==
parent_reg
:
if
spec
[
'type'
]
==
'import'
and
spec
[
'parent_reg'
]
==
parent_reg
:
return
reg
return
reg
# not imported, import
# not imported, import
...
@@ -593,7 +593,7 @@ class RegFile:
...
@@ -593,7 +593,7 @@ class RegFile:
return
self
.
imported
(
parent_reg
)
return
self
.
imported
(
parent_reg
)
def
imported_lc
(
self
,
ctr_name
):
def
imported_lc
(
self
,
ctr_name
):
for
reg
,
spec
in
self
.
_regs
.
iter
items
():
for
reg
,
spec
in
self
.
_regs
.
items
():
if
spec
[
'type'
]
==
'import_lc'
:
if
spec
[
'type'
]
==
'import_lc'
:
return
reg
return
reg
# not imported, import
# not imported, import
...
@@ -605,7 +605,7 @@ class RegFile:
...
@@ -605,7 +605,7 @@ class RegFile:
return
self
.
imported_lc
(
ctr_name
)
return
self
.
imported_lc
(
ctr_name
)
def
arg_reg
(
self
,
arg_num
,
comment
=
None
):
def
arg_reg
(
self
,
arg_num
,
comment
=
None
):
for
reg
,
spec
in
self
.
_regs
.
iter
items
():
for
reg
,
spec
in
self
.
_regs
.
items
():
if
spec
[
'type'
]
==
'arg'
:
if
spec
[
'type'
]
==
'arg'
:
return
reg
return
reg
# no such arg, alloc
# no such arg, alloc
...
@@ -633,7 +633,7 @@ class RegFile:
...
@@ -633,7 +633,7 @@ class RegFile:
elif
pv
[
0
]
==
'parent_while_counter'
:
elif
pv
[
0
]
==
'parent_while_counter'
:
return
(
'reg'
,
self
.
arg_reg
(
0
))
return
(
'reg'
,
self
.
arg_reg
(
0
))
else
:
else
:
print
pv
print
(
pv
)
raise
Exception
(
pv
)
raise
Exception
(
pv
)
def
get_value
(
self
,
id
):
def
get_value
(
self
,
id
):
...
@@ -641,8 +641,8 @@ class RegFile:
...
@@ -641,8 +641,8 @@ class RegFile:
if
self
.
Parent
is
not
None
:
if
self
.
Parent
is
not
None
:
return
self
.
get_parent_value
(
id
)
return
self
.
get_parent_value
(
id
)
else
:
else
:
print
"-------------------"
print
(
"-------------------"
)
print
self
print
(
self
)
raise
NameNotRecognized
(
id
.
Name
)
raise
NameNotRecognized
(
id
.
Name
)
spec
=
self
.
_names
[
id
.
Name
]
spec
=
self
.
_names
[
id
.
Name
]
...
@@ -714,14 +714,14 @@ class RegFile:
...
@@ -714,14 +714,14 @@ class RegFile:
return
(
'name_reg'
,
spec
[
'cf'
][
'reg'
],
id
)
return
(
'name_reg'
,
spec
[
'cf'
][
'reg'
],
id
)
else
:
else
:
print
"NAME >> "
,
id
print
(
"NAME >> "
,
id
)
print
self
print
(
self
)
raise
Exception
(
'add according to priority'
,
spec
)
raise
Exception
(
'add according to priority'
,
spec
)
R
(
self
.
name_info
(
id
.
Name
))
R
(
self
.
name_info
(
id
.
Name
))
vt
=
self
.
_get_value_type
(
id
)
vt
=
self
.
_get_value_type
(
id
)
print
vt
print
(
vt
)
print
self
print
(
self
)
R
(
repr
(
id
))
R
(
repr
(
id
))
def
reg_info
(
self
,
reg
):
def
reg_info
(
self
,
reg
):
...
@@ -1524,7 +1524,7 @@ class Sub(Scope):
...
@@ -1524,7 +1524,7 @@ class Sub(Scope):
and
id
.
Name
==
rule
[
'id'
][
0
]:
and
id
.
Name
==
rule
[
'id'
][
0
]:
if
id
.
Indices
or
rule
[
'id'
][
1
:]:
if
id
.
Indices
or
rule
[
'id'
][
1
:]:
if
len
(
id
.
Indices
)
!=
len
(
rule
[
'id'
][
1
:]):
if
len
(
id
.
Indices
)
!=
len
(
rule
[
'id'
][
1
:]):
print
id
print
(
id
)
R
(
rule
[
'id'
])
R
(
rule
[
'id'
])
params
=
kwargs
.
get
(
'subst'
,
{})
params
=
kwargs
.
get
(
'subst'
,
{})
for
i
in
range
(
len
(
rule
[
'id'
][
1
:])):
for
i
in
range
(
len
(
rule
[
'id'
][
1
:])):
...
@@ -1653,13 +1653,13 @@ class Fa:
...
@@ -1653,13 +1653,13 @@ class Fa:
return
asm
return
asm
def
show_help
():
def
show_help
():
print
'''
\
print
(
'''
\
Usage:
Usage:
python %s input.ja output.fasm [--cpp-codes cpp_codes] [--only-requests]
python
3
%s input.ja output.fasm [--cpp-codes cpp_codes] [--only-requests]
(will generate cpp_codes.h and cpp_codes.cpp if --cpp-codes is set)
(will generate cpp_codes.h and cpp_codes.cpp if --cpp-codes is set)
With --only-requests nothing will happen except writing a modified
With --only-requests nothing will happen except writing a modified
json with additional rules (posts/requests unlimited)
json with additional rules (posts/requests unlimited)
'''
%
sys
.
argv
[
0
]
'''
%
sys
.
argv
[
0
]
)
if
'--help'
in
sys
.
argv
[
1
:]:
if
'--help'
in
sys
.
argv
[
1
:]:
show_help
()
show_help
()
...
...
scripts/fcmp2
View file @
e54ea404
#!/usr/bin/python
#!/usr/bin/python
3
DEFAULT_LOCATOR_0
=
True
# Set locator 0 if unset
DEFAULT_LOCATOR_0
=
True
# Set locator 0 if unset
ADD_DEBUG_INFO
=
False
ADD_DEBUG_INFO
=
False
...
@@ -98,10 +98,10 @@ def create_scope(j, parent):
...
@@ -98,10 +98,10 @@ def create_scope(j, parent):
return
scope
return
scope
def
ps
(
scope
):
def
ps
(
scope
):
for
k
,
v
in
scope
.
iter
items
():
for
k
,
v
in
scope
.
items
():
if
k
in
[
'j'
,
'parent'
,
'children'
]:
if
k
in
[
'j'
,
'parent'
,
'children'
]:
continue
continue
print
'%s=%s'
%
(
k
,
repr
(
v
))
print
(
'%s=%s'
%
(
k
,
repr
(
v
))
)
class
UnresolvedName
(
Exception
):
class
UnresolvedName
(
Exception
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
@@ -1102,7 +1102,7 @@ def parse_import(ja):
...
@@ -1102,7 +1102,7 @@ def parse_import(ja):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
if
'--help'
in
sys
.
argv
[
1
:]:
if
'--help'
in
sys
.
argv
[
1
:]:
print
HELP_MESSAGE
print
(
HELP_MESSAGE
)
sys
.
exit
(
0
)
sys
.
exit
(
0
)
if
len
(
sys
.
argv
[
1
:])
<
3
:
if
len
(
sys
.
argv
[
1
:])
<
3
:
sys
.
stderr
.
write
(
'%s: invalid arguments count, see --help
\n
'
\
sys
.
stderr
.
write
(
'%s: invalid arguments count, see --help
\n
'
\
...
@@ -1131,7 +1131,7 @@ if __name__=='__main__':
...
@@ -1131,7 +1131,7 @@ if __name__=='__main__':
mid
+=
BLOCKH
%
(
'MAIN'
,
main_id
)
mid
+=
BLOCKH
%
(
'MAIN'
,
main_id
)
for
name
,
sub
in
gja
.
iter
items
():
for
name
,
sub
in
gja
.
items
():
assert
'name'
not
in
sub
assert
'name'
not
in
sub
sub
[
'name'
]
=
name
sub
[
'name'
]
=
name
...
...
scripts/luna
View file @
e54ea404
#!/usr/bin/python
#!/usr/bin/python
3
# TODO add ability to use some other temporary directory for building
# TODO add ability to use some other temporary directory for building
# tests, not .luna subdirectory, and allow setup via environment var.
# tests, not .luna subdirectory, and allow setup via environment var.
...
@@ -172,7 +172,7 @@ def parse_env(conf):
...
@@ -172,7 +172,7 @@ def parse_env(conf):
os
.
pardir
))
os
.
pardir
))
if
'PYTHON'
not
in
conf
:
if
'PYTHON'
not
in
conf
:
conf
[
'PYTHON'
]
=
os
.
environ
.
get
(
'PYTHON'
,
'python'
)
conf
[
'PYTHON'
]
=
os
.
environ
.
get
(
'PYTHON'
,
'python
3
'
)
if
'CXX_FLAGS'
not
in
conf
and
'CXX_FLAGS'
in
os
.
environ
:
if
'CXX_FLAGS'
not
in
conf
and
'CXX_FLAGS'
in
os
.
environ
:
conf
[
'CXX_FLAGS'
]
=
os
.
environ
[
'CXX_FLAGS'
]
conf
[
'CXX_FLAGS'
]
=
os
.
environ
[
'CXX_FLAGS'
]
...
@@ -231,7 +231,7 @@ def generate_cpp_blocks(ja_in_path, headers_in_path, ja_ti_path, b_in_path,
...
@@ -231,7 +231,7 @@ def generate_cpp_blocks(ja_in_path, headers_in_path, ja_ti_path, b_in_path,
else
:
else
:
raise
NotImplementedError
(
header
[
0
],
header
)
raise
NotImplementedError
(
header
[
0
],
header
)
for
name
,
sub
in
ja
.
iter
items
():
for
name
,
sub
in
ja
.
items
():
if
sub
[
'type'
]
==
'foreign_cpp'
:
if
sub
[
'type'
]
==
'foreign_cpp'
:
block_id
=
sub
[
'block_id'
]
block_id
=
sub
[
'block_id'
]
...
@@ -274,7 +274,7 @@ def info(msg):
...
@@ -274,7 +274,7 @@ def info(msg):
if
msg
is
None
:
if
msg
is
None
:
return
return
else
:
else
:
print
msg
print
(
msg
)
else
:
else
:
if
msg
is
None
:
if
msg
is
None
:
sys
.
stdout
.
write
(
'
\033
[2K
\r
'
)
sys
.
stdout
.
write
(
'
\033
[2K
\r
'
)
...
@@ -296,7 +296,7 @@ def error_block_message(block_id, blocks_info, pp_ti):
...
@@ -296,7 +296,7 @@ def error_block_message(block_id, blocks_info, pp_ti):
mark
(
line
,
pos
))
mark
(
line
,
pos
))
def
so_build_message
(
eln
,
epos
,
emsg
):
def
so_build_message
(
eln
,
epos
,
emsg
):
emsg
=
emsg
.
decode
(
'utf-8'
)
#
emsg=emsg.decode('utf-8')
ln
=
1
ln
=
1
cur
=
1
cur
=
1
for
i
in
range
(
len
(
conf
[
'fb.ti'
][
'text'
])):
for
i
in
range
(
len
(
conf
[
'fb.ti'
][
'text'
])):
...
@@ -305,7 +305,7 @@ def so_build_message(eln, epos, emsg):
...
@@ -305,7 +305,7 @@ def so_build_message(eln, epos, emsg):
if
ln
==
eln
and
cur
==
epos
:
if
ln
==
eln
and
cur
==
epos
:
C
=
conf
[
'fb.ti'
][
'text'
][
i
]
C
=
conf
[
'fb.ti'
][
'text'
][
i
]
mrk
=
mark
(
conf
[
'fb.cpp'
][
ln
-
1
],
cur
-
1
)
mrk
=
mark
(
conf
[
'fb.cpp'
][
ln
-
1
],
cur
-
1
)
return
u
'compile: at %s:%d:%d: %s
\n
%s'
%
(
return
'compile: at %s:%d:%d: %s
\n
%s'
%
(
conf
[
'fb.ti'
][
'paths'
][
str
(
C
[
0
])],
C
[
1
],
C
[
2
],
conf
[
'fb.ti'
][
'paths'
][
str
(
C
[
0
])],
C
[
1
],
C
[
2
],
emsg
,
mrk
)
emsg
,
mrk
)
if
conf
[
'fb.ti'
][
'text'
][
i
][
3
]
==
'
\n
'
:
if
conf
[
'fb.ti'
][
'text'
][
i
][
3
]
==
'
\n
'
:
...
@@ -338,17 +338,17 @@ def translate_so_build_err(err):
...
@@ -338,17 +338,17 @@ def translate_so_build_err(err):
elif
m2
is
not
None
:
elif
m2
is
not
None
:
bid
=
int
(
m2
.
groups
()[
0
])
bid
=
int
(
m2
.
groups
()[
0
])
C
=
conf
[
'blocks.ti'
][
'text'
][
bid
][
0
]
C
=
conf
[
'blocks.ti'
][
'text'
][
bid
][
0
]
res
.
append
(
u
'in foreign block at %s:%d:%d:
\n
%s'
%
(
res
.
append
(
'in foreign block at %s:%d:%d:
\n
%s'
%
(
conf
[
'blocks.ti'
][
'paths'
][
str
(
C
[
0
])],
C
[
1
],
C
[
2
],
conf
[
'blocks.ti'
][
'paths'
][
str
(
C
[
0
])],
C
[
1
],
C
[
2
],
mark
(
get_src
(
conf
[
'blocks.ti'
][
'paths'
][
str
(
C
[
0
])])[
C
[
1
]],
C
[
2
])))
mark
(
get_src
(
conf
[
'blocks.ti'
][
'paths'
][
str
(
C
[
0
])])[
C
[
1
]],
C
[
2
])))
else
:
else
:
res
.
append
(
ln
.
decode
(
'utf-8'
))
res
.
append
(
ln
)
#
.decode('utf-8'))
else
:
else
:
res
.
append
(
ln
.
decode
(
'utf-8'
))
res
.
append
(
ln
)
#
.decode('utf-8'))
cur
+=
1
cur
+=
1
return
u
'
\n
'
.
join
(
res
)
return
'
\n
'
.
join
(
res
)
def
translate_fcmp2_err
(
err
):
def
translate_fcmp2_err
(
err
):
...
@@ -374,7 +374,7 @@ def translate_fcmp2_err(err):
...
@@ -374,7 +374,7 @@ def translate_fcmp2_err(err):
def
main
():
def
main
():
global
conf
,
ti
global
conf
,
ti
if
'--help'
in
sys
.
argv
[
1
:]:
if
'--help'
in
sys
.
argv
[
1
:]:
print
HELP_MESSAGE
print
(
HELP_MESSAGE
)
sys
.
exit
(
0
)
sys
.
exit
(
0
)
conf
=
parse_args
(
sys
.
argv
[
1
:])
conf
=
parse_args
(
sys
.
argv
[
1
:])
...
@@ -390,7 +390,7 @@ def main():
...
@@ -390,7 +390,7 @@ def main():
conf
[
'BUILD_DIR'
]
=
os
.
path
.
join
(
conf
[
'LUNA_HOME'
],
'build'
,
'programs'
,
*
dirs
)
conf
[
'BUILD_DIR'
]
=
os
.
path
.
join
(
conf
[
'LUNA_HOME'
],
'build'
,
'programs'
,
*
dirs
)
if
'PYTHON'
not
in
conf
:
if
'PYTHON'
not
in
conf
:
conf
[
'PYTHON'
]
=
'python'
conf
[
'PYTHON'
]
=
'python
3
'
conf
[
'CXX_FLAGS'
]
=
conf
.
get
(
'CXX_FLAGS'
,
''
)
\
conf
[
'CXX_FLAGS'
]
=
conf
.
get
(
'CXX_FLAGS'
,
''
)
\
+
' -I %s'
%
os
.
path
.
join
(
conf
[
'LUNA_HOME'
],
'include'
)
\
+
' -I %s'
%
os
.
path
.
join
(
conf
[
'LUNA_HOME'
],
'include'
)
\
...
@@ -443,13 +443,15 @@ def main():
...
@@ -443,13 +443,15 @@ def main():
'blocks.ti'
)]
'blocks.ti'
)]
if
VERBOSE_FLAG
:
if
VERBOSE_FLAG
:
print
' '
.
join
(
cmd
)
print
(
' '
.
join
(
cmd
)
)
p
=
subprocess
.
Popen
(
cmd
,
stderr
=
subprocess
.
PIPE
,
p
=
subprocess
.
Popen
(
cmd
,
stderr
=
subprocess
.
PIPE
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
)
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
)
out
,
err
=
p
.
communicate
()
out
,
err
=
p
.
communicate
()
out
=
out
.
decode
(
'utf-8'
)
err
=
err
.
decode
(
'utf-8'
)
if
VERBOSE_FLAG
:
if
VERBOSE_FLAG
:
print
out
print
(
out
)
if
p
.
returncode
!=
0
:
if
p
.
returncode
!=
0
:
raise
FatalError
(
'preprocessing failed (see error messages '
\
raise
FatalError
(
'preprocessing failed (see error messages '
\
...
@@ -468,9 +470,11 @@ def main():
...
@@ -468,9 +470,11 @@ def main():
cmd
+=
[
'-o'
,
os
.
path
.
join
(
conf
[
'BUILD_DIR'
],
'program.ja'
)]
cmd
+=
[
'-o'
,
os
.
path
.
join
(
conf
[
'BUILD_DIR'
],
'program.ja'
)]
cmd
+=
[
'-h'
,
os
.
path
.
join
(
conf
[
'BUILD_DIR'
],
'headers.ja'
)]
cmd
+=
[
'-h'
,
os
.
path
.
join
(
conf
[
'BUILD_DIR'
],
'headers.ja'
)]
if
VERBOSE_FLAG
:
if
VERBOSE_FLAG
:
print
' '
.
join
(
cmd
)
print
(
' '
.
join
(
cmd
)
)
p
=
subprocess
.
Popen
(
cmd
,
stderr
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
)
p
=
subprocess
.
Popen
(
cmd
,
stderr
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
)
out
,
err
=
p
.
communicate
()
out
,
err
=
p
.
communicate
()
out
=
out
.
decode
(
'utf-8'
)
err
=
err
.
decode
(
'utf-8'
)
if
p
.
returncode
!=
0
:
if
p
.
returncode
!=
0
:
for
ln
in
err
.
split
(
'
\n
'
):
for
ln
in
err
.
split
(
'
\n
'
):
...
@@ -483,7 +487,7 @@ def main():
...
@@ -483,7 +487,7 @@ def main():
+
'see error messages below:
\n
%s'
%
err
)
+
'see error messages below:
\n
%s'
%
err
)
if
VERBOSE_FLAG
:
if
VERBOSE_FLAG
:
print
out
print
(
out
)
# ================
# ================
# let substitution
# let substitution
...
@@ -495,17 +499,19 @@ def main():
...
@@ -495,17 +499,19 @@ def main():
'substitution_let.py'
)]
'substitution_let.py'
)]
cmd
+=
[
os
.
path
.
join
(
conf
[
'BUILD_DIR'
],
'program.ja'
)]
cmd
+=
[
os
.
path
.
join
(
conf
[
'BUILD_DIR'
],
'program.ja'
)]
if
VERBOSE_FLAG
:
if
VERBOSE_FLAG
:
print
' '
.
join
(
cmd
)
print
(
' '
.
join
(
cmd
)
)
p
=
subprocess
.
Popen
(
cmd
,
stderr
=
subprocess
.
PIPE
,
p
=
subprocess
.
Popen
(
cmd
,
stderr
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
)
stdout
=
subprocess
.
PIPE
)
out
,
err
=
p
.
communicate
()
out
,
err
=
p
.
communicate
()
out
=
out
.
decode
(
'utf-8'
)
err
=
err
.
decode
(
'utf-8'
)
if
p
.
returncode
!=
0
:
if
p
.
returncode
!=
0
:
raise
FatalError
(
'compilation failed: '
\
raise
FatalError
(
'compilation failed: '
\
+
'see error messages below:
\n
%s'
%
err
)
+
'see error messages below:
\n
%s'
%
err
)
if
VERBOSE_FLAG
:
if
VERBOSE_FLAG
:
print
out
print
(
out
)