Hello,
I'm trying to transform a programming language, given as a model, into another language.
It's working fine except of one problem.
i = alloca i32
store i32 0, i32* i
this code leads me to this xml model-representation.
(All of this is in a context of a function body, function definition and a program. So just a snippet)
<blocks label="entry">
<instructions xsi:type="InstructionUse" reg_or_var="%i">
<instruction xsi:type="Alloc">
<type xsi:type="Predefined" type="i32"/>
</instruction>
</instructions>
<instructions xsi:type="Store">
<newtype xsi:type="Predefined" type="i32"/>
<newvalue xsi:type="Constant"/>
<adresstype xsi:type="Predefined" type="i32*"/>
<adress xsi:type="NonConstantValue" name="%i"/>
</instructions>
</blocks>
It's the representation of an AST I got from a Xtext Parser.
If I use my transformation, I want to get something like this:
<program>
<functions name="@_Z6Memberi">
<instructions xsi:type="MemoryInstruction" instructionType="Alloca">
<instructionResult xsi:type ="Variable" name="i"/>
<parameters>
<Constant>
<SimpleType type="int"/>
</Constant>
</parameters>
</instructions>
<instructions xsi:type="MemoryInstruction" instructionType="Store">
<parameters>
...
</parameters>
</instructions>
</functions>
</program>
That kind of structure would be nice.
But I get this:
<program>
<functions name="@_Z6Memberi"> //this is function.0
<localVariablesOrValues xsi:type="Variable" name="i"/> //this is localVariablesOrValues.2
<instructions xsi:type="MemoryInstruction" instructionResult="/0/@functions.0/@localVariablesOrValues.2" parameters="/89"/>
<instructions xsi:type="MemoryInstruction" parameters="/133 /135" instructionType="Store"/>
</functions>
</program>
<Constant type="/90"/> // this is parameter 89
<SimpleType type="int"/> // this is type 90
<Constant type="/134" value="0"/> // this is parameter 133
<SimpleType type="int"/> // this is type 134
<Variable type="/136" name="i"/> // this is parameter 135
<SimpleType type="pointer"/> // this is type 136
I have only 1 model file for the transformation. So is it avoidable to get these much links in the representation of the model? To be honest I want to avoid all of them.
Is it possible to get the result I want using 1 Transformation?
I hope my request isn't confusing.
Thanks,
Thomas