[Mumps2Py:] [126] added translate_indirection to handle atomic indirection. |
[ Thread Index |
Date Index
| More lists.mumps2py.org/discuss Archives
]
Revision: 126
Author: pgallot
Date: 2008-02-22 03:35:45 +0000 (Fri, 22 Feb 2008)
Log Message:
-----------
added translate_indirection to handle atomic indirection.
Modified Paths:
--------------
trunk/mumps2py/tok2python.py
Modified: trunk/mumps2py/tok2python.py
===================================================================
--- trunk/mumps2py/tok2python.py 2008-02-22 03:34:21 UTC (rev 125)
+++ trunk/mumps2py/tok2python.py 2008-02-22 03:35:45 UTC (rev 126)
@@ -60,6 +60,7 @@
def add_frontmatter(self):
"""add in what needs to go at the top of the translated code"""
+ assert(self.mumps_module)
block_str = "# %s \n# translated from %s\n# by Mumps2Py\n\n" % \
(self.mumps_module.output_file,
self.mumps_module.input_file)
@@ -160,6 +161,16 @@
""" translates a Mumps-style newline to Python"""
return r'"\n"'
+ def translate_indirection(translation, token):
+ """translates an atomic indirection expression to Python"""
+ translation.add_cl_import()
+ indr_str = "M_eval(%s, locals())" % \
+ translate_expr(translation, token.expr)
+ if token.is_indexed():
+ indr_str = "%s[%s]" % \
+ (indr_str, tuplify(translation, token.indices))
+ return indr_str
+
def translate_intr_ascii(translation, token):
""" translates the Mumps Intrinsic function ASCII to Python"""
if len(token.params) == 1:
@@ -499,6 +510,7 @@
NUMLITERAL:translate_num,
STRINGLITERAL:translate_str,
LOCALVAR:translate_local_var,
+ INDIRECTION: translate_indirection,
FCC_NEWLINE:translate_fcc_newline,
F_ASCII: translate_intr_ascii,
F_CHAR: translate_intr_char,