Commit 559123bd authored by Maxime Perrotin's avatar Maxime Perrotin

Support assignment of raw values to substrings

myVar(4, 5) := { 4, 2 } -- To change two values of the array
parent b4b00bad
......@@ -135,6 +135,9 @@ The background pattern was downloaded from www.subtlepatterns.com
Changelog
=========
2.0.41 (05/2019)
- Fix substring support (can now write var(1,2) := {1,2})
2.0.41 (05/2019)
- Add --taste flag to target taste integration with kazoo
......
......@@ -2079,11 +2079,18 @@ def _assign_expression(expr, **kwargs):
elif isinstance(expr.right, (ogAST.PrimSequenceOf,
ogAST.PrimStringLiteral)):
strings.append(u"{lvar} := {value};"
if not isinstance(expr.left, ogAST.PrimSubstring):
strings.append(u"{lvar} := {value};"
.format(lvar=left_str,
value=array_content(expr.right,
right_str,
basic_left)))
else:
# left is substring: no length, direct assignment
strings.append(u"{lvar} := ({rvar});"
.format(lvar=left_str,
rvar=right_str))
rlen = None
else:
# Right part is a variable
......
......@@ -2189,7 +2189,12 @@ def primary_substring(root, context):
LOG.debug('In primary_substring: ' + str(err))
min1, max1 = 0, 0
node.exprType = type('SubStr', (receiver_bty,),
#node.exprType = type('SubStr', (receiver_bty,),
# The substring has to be subtyping the original type to get its name
# This is needed to support expressions such as "a(1,2) := {1,1}"
# -> assigning a raw expression to a substring requires the type
# of the recipiant to be known
node.exprType = type('SubStr', (receiver.exprType,),
{'Min': str(int(min1) - int(max0) + 1),
'Max': str(int(max1) - int(min0) + 1)})
basic = find_basic_type(node.exprType)
......
......@@ -141,7 +141,7 @@ except ImportError:
__all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse']
__version__ = '2.0.41'
__version__ = '2.0.42'
if hasattr(sys, 'frozen'):
# Detect if we are running on Windows (py2exe-generated)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment