Commit e8363907 authored by Kristof Szabados's avatar Kristof Szabados Committed by GitHub
Browse files

Merge pull request #252 from GergoUjhelyi/master

added new code generator to template arrays
parents e958b1a3 672427e9
......@@ -50,6 +50,7 @@ import org.eclipse.titan.designer.productUtilities.ProductConstants;
*
* @author Kristof Szabados
* @author Arpad Lovassy
* @author Gergo Ujhelyi
*/
public final class Def_Var_Template extends Definition {
private static final String FULLNAMEPART1 = ".<type>";
......@@ -525,10 +526,8 @@ public final class Def_Var_Template extends Definition {
final String typeGeneratedName = type.getGenNameTemplate( aData, source, getMyScope() );
if (type.getTypetype().equals(Type_type.TYPE_ARRAY)) {
Array_Type arrayType = (Array_Type) type;
String elementType = arrayType.getElementType().getGenNameValue(aData, source, myScope);
source.append(MessageFormat.format("{0} {1} = new {0}({2}.class, {2}_template.class);\n", typeGeneratedName, genName, elementType));
source.append(MessageFormat.format("{0}.setSize({1});\n",genName,(int)arrayType.getDimension().getSize()));
source.append(MessageFormat.format("{0}.setOffset({1});\n",genName,(int)arrayType.getDimension().getOffset()));
StringBuilder sb = aData.getCodeForType(arrayType.getGenNameOwn());
source.append(MessageFormat.format("{0} {1} = new {0}();\n",arrayType.generateCodeTemplate(aData, source, arrayType, sb), genName));
} else {
source.append(MessageFormat.format("{0} {1} = new {0}();\n", typeGeneratedName, genName));
}
......
......@@ -1268,16 +1268,10 @@ public abstract class TTCN3Template extends GovernedSimple implements IReference
}
public void generateCodeInitSeofElement(final JavaGenData aData, final StringBuilder source, final String name, final String index, final String elementTypeGenname) {
if (needsTemporaryReference()) {
String tempId = aData.getTemporaryVariableName();
source.append("{\n");
source.append(MessageFormat.format("{0} {1} = {2}.getAt({3});\n", elementTypeGenname, tempId, name, index));
generateCodeInit(aData, source, tempId);
source.append("}\n");
} else {
String embeddedName = MessageFormat.format("{0}.getAt({1})", name, index);
generateCodeInit(aData, source, embeddedName);
}
source.append("}\n");
}
/**
......
......@@ -651,7 +651,7 @@ public final class Template_List extends CompositeTemplate {
source.append(");\n");
source.append(body);
} else {
source.append(MessageFormat.format("{0}.setSize({1});\n", name, getNofTemplates()));
//source.append(MessageFormat.format("{0}.setSize({1});\n", name, getNofTemplates()));
int index = 0;
for (int i = 0, size = templates.getNofTemplates(); i < size; i++) {
......
......@@ -271,6 +271,14 @@ public class TitanTemplateArray<Tvalue extends Base_Type,Ttemplate extends Base_
copy_template(otherValue);
}
public TitanTemplateArray(final Class<Tvalue> classValue, final Class<Ttemplate> classTemplate , final int size, final int offset) {
this.classValue = classValue;
this.classTemplate = classTemplate;
indexOffset = offset;
setSize(size);
}
//TODO: TEMPLATE_ARRAY(const OPTIONAL< VALUE_ARRAY<T_value...>)
......
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