Rapsodia (generator)
 All Classes Namespaces Files Functions Variables Pages
genOpInt.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 genInt(sourceList,helper):
13  # the generic bits for cast to int
14  sourceList.append(generateIntBody(helper))
15  # the int intrinsic
16  aSourceNode=helper.generatePassivatingOp('int','integerReturn')
17  aSourceNode.fortranOnly=True
18  sourceList.append(aSourceNode)
19 
20 import Common.ast as ast
21 
22 def generateIntBody(helper):
23  aSourceNode=ast.SimpleSource(names.Fixed.pN+'int',
24  helper.p.iE)
25  aSourceNode.fortranOnly=True
26  # do cast
27  aSourceNode.appendChild(ast.Assignment(ast.Variable('r'),
28  ast.FuncCall('int',[util.vOf('a')])))
29  return aSourceNode
30 
31 
32 
33 
34 def genIntReverse(sourceList,helper):
35  aSourceNode=helper.generateUnaryIntrinsicReverse('int',None,names.Fixed.pN+'int',None,'r','integerReturn',[],[],[],[],getStatementA)
36  aSourceNode.fortranOnly=True
37  sourceList.append(aSourceNode)
38 
39 import Common.ast as ast
40 
41 def getStatementA(helper,aSource,name,k,resultTypes):
42  # do cast
43  aSource.appendChild(ast.Assignment(ast.Variable('r'),
44  ast.FuncCall('int',[util.vOf('a')])))
45  return aSource