Rapsodia (generator)
 All Classes Namespaces Files Functions Variables Pages
genOpReal.py
Go to the documentation of this file.
1 ##########################################################
2 # This file is part of Rapsodia released under the LGPL. #
3 # The full COPYRIGHT notice can be found in the top #
4 # level directory of the Rapsodia distribution #
5 ##########################################################
6 import Common.names as names
7 import Common.parameters as parameters
8 import Common.util as util
9 
10 # For FORTRAN only
11 
12 def genReal(sourceList,helper):
13  # the generic bits for cast to real
14  sourceList.append(generateRealBody(helper))
15  # the real intrinsic
16  aSourceNode=helper.generateUnaryOpAll('real',
17  None,
18  names.Fixed.pN+'real',
19  None,
20  'r',
21  'matchKindReturn',
22  [],
23  [],
24  [],
25  [])
26  aSourceNode.fortranOnly=True
27  sourceList.append(aSourceNode)
28 
29 
30 import Common.ast as ast
31 import Common.slice as slice
32 
33 def generateRealBody(helper):
34  aSourceNode=ast.SimpleSource(names.Fixed.pN+'real', helper.p.iE)
35  aSourceNode.fortranOnly=True
36  # this is to get the real part from an active complex
37  aSourceNode.appendChild(ast.Assignment(util.vOf('r'),
38  ast.FuncCall('real',
39  [util.vOf('a')])))
40 
41  s = slice.Slice(aSourceNode)
42  for direct in range(1,parameters.sliceSize+1,1):
43  for deg in range(1,parameters.o+1,1):
44 # s.appendChild(ast.Assignment(util.dOf('r',direct,deg),
45  s.appendChild(ast.Assignment(util.dOf(util.getVarGlobalName('r'),direct,deg),
46  ast.FuncCall('real',[util.dOf('a',direct,deg)])))
47 # s.endSlice()
48  s.endSliceAndSave()
49  return aSourceNode