Lichen

Change of encoders.py

623:3bba67784f79
encoders.py
     1.1 --- a/encoders.py	Mon Feb 27 00:55:52 2017 +0100
     1.2 +++ b/encoders.py	Mon Feb 27 11:57:15 2017 +0100
     1.3 @@ -277,21 +277,21 @@
     1.4  
     1.5      if op in attribute_ops:
     1.6          arg = a[1]
     1.7 -        a[1] = encode_symbol("pos", arg)
     1.8 +        a[1] = encode_pos(arg)
     1.9  
    1.10      # Convert attribute name arguments to position and code symbols.
    1.11  
    1.12      elif op in checked_ops:
    1.13          arg = a[1]
    1.14 -        a[1] = encode_symbol("pos", arg)
    1.15 -        a.insert(2, encode_symbol("code", arg))
    1.16 +        a[1] = encode_pos(arg)
    1.17 +        a.insert(2, encode_code(arg))
    1.18  
    1.19      # Convert type name arguments to position and code symbols.
    1.20  
    1.21      elif op in typename_ops:
    1.22          arg = encode_type_attribute(args[1])
    1.23 -        a[1] = encode_symbol("pos", arg)
    1.24 -        a.insert(2, encode_symbol("code", arg))
    1.25 +        a[1] = encode_pos(arg)
    1.26 +        a.insert(2, encode_code(arg))
    1.27  
    1.28      # Obtain addresses of type arguments.
    1.29  
    1.30 @@ -509,6 +509,30 @@
    1.31          all_encoded_paths[encoded] = path
    1.32          return encoded
    1.33  
    1.34 +def encode_code(name):
    1.35 +
    1.36 +    "Encode 'name' as an attribute code indicator."
    1.37 +
    1.38 +    return "__ATTRCODE(%s)" % encode_path(name)
    1.39 +
    1.40 +def encode_pcode(name):
    1.41 +
    1.42 +    "Encode 'name' as an parameter code indicator."
    1.43 +
    1.44 +    return "__PARAMCODE(%s)" % encode_path(name)
    1.45 +
    1.46 +def encode_pos(name):
    1.47 +
    1.48 +    "Encode 'name' as an attribute position indicator."
    1.49 +
    1.50 +    return "__ATTRPOS(%s)" % encode_path(name)
    1.51 +
    1.52 +def encode_ppos(name):
    1.53 +
    1.54 +    "Encode 'name' as an parameter position indicator."
    1.55 +
    1.56 +    return "__PARAMPOS(%s)" % encode_path(name)
    1.57 +
    1.58  def encode_predefined_reference(path):
    1.59  
    1.60      "Encode a reference to a predefined constant value for 'path'."