use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Sequence_Type method isPresentAnyvalueEmbeddedField.
@Override
public /**
* {@inheritDoc}
*/
boolean isPresentAnyvalueEmbeddedField(final ExpressionStruct expression, final List<ISubReference> subreferences, final int beginIndex) {
if (subreferences == null || getIsErroneous(CompilationTimeStamp.getBaseTimestamp())) {
return true;
}
if (beginIndex >= subreferences.size()) {
return true;
}
final ISubReference subReference = subreferences.get(beginIndex);
if (!(subReference instanceof FieldSubReference)) {
ErrorReporter.INTERNAL_ERROR("Code generator reached erroneous type reference `" + getFullName() + "''");
expression.expression.append("FATAL_ERROR encountered");
return true;
}
final Identifier fieldId = ((FieldSubReference) subReference).getId();
final CompField compField = getComponentByName(fieldId);
if (compField.isOptional()) {
return false;
}
return compField.getType().isPresentAnyvalueEmbeddedField(expression, subreferences, beginIndex + 1);
}
use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class Invoke_Template method getSingleExpression.
@Override
public /**
* {@inheritDoc}
*/
StringBuilder getSingleExpression(final JavaGenData aData, final boolean castIsNeeded) {
final ExpressionStruct expression = new ExpressionStruct();
generateCodeExpressionInvoke(aData, expression);
return expression.expression;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class Invoke_Template method generateCodeExpression.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeExpression(final JavaGenData aData, final ExpressionStruct expression, final TemplateRestriction.Restriction_type templateRestriction) {
IType governor = myGovernor;
if (governor == null) {
governor = getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
}
if (governor == null) {
return;
}
if (lengthRestriction == null && !isIfpresent && templateRestriction == Restriction_type.TR_NONE) {
// The single expression must be tried first because this rule might cover some referenced templates.
if (hasSingleExpression()) {
final String genName = governor.getGenNameTemplate(aData, expression.expression, myScope);
expression.expression.append(MessageFormat.format("new {0}(", genName));
if (governor.getTypetype() == Type_type.TYPE_ARRAY) {
final Array_Type array_type = (Array_Type) governor;
expression.expression.append(MessageFormat.format(" {0}.class, ", array_type.getElementType().getGenNameTemplate(aData, expression.expression, myScope)));
}
expression.expression.append(getSingleExpression(aData, true));
expression.expression.append(')');
return;
}
generateCodeExpressionInvoke(aData, expression);
return;
}
final String tempId = aData.getTemporaryVariableName();
expression.preamble.append(MessageFormat.format("{0} {1} = new {0}();\n", governor.getGenNameTemplate(aData, expression.expression, myScope), tempId));
generateCodeInit(aData, expression.preamble, tempId);
if (templateRestriction != Restriction_type.TR_NONE) {
TemplateRestriction.generateRestrictionCheckCode(aData, expression.expression, location, tempId, templateRestriction);
}
expression.expression.append(tempId);
}
use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class Invoke_Template method generateCodeInit.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeInit(final JavaGenData aData, final StringBuilder source, final String name) {
if (lastTimeBuilt != null && !lastTimeBuilt.isLess(aData.getBuildTimstamp())) {
return;
}
lastTimeBuilt = aData.getBuildTimstamp();
if (getCodeSection() == CodeSectionType.CS_POST_INIT) {
reArrangeInitCode(aData, source, myScope.getModuleScope());
}
final ExpressionStruct expression = new ExpressionStruct();
expression.expression.append(MessageFormat.format("{0}.assign(", name));
generateCodeExpressionInvoke(aData, expression);
expression.expression.append(')');
if (lengthRestriction != null) {
if (getCodeSection() == CodeSectionType.CS_POST_INIT) {
lengthRestriction.reArrangeInitCode(aData, source, myScope.getModuleScope());
}
lengthRestriction.generateCodeInit(aData, source, name);
}
if (isIfpresent) {
source.append(name);
source.append(".set_ifPresent();\n");
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class Invoke_Template method generateCodeExpressionInvoke.
private void generateCodeExpressionInvoke(final JavaGenData aData, final ExpressionStruct expression) {
if (value == null || actualParameter_list == null) {
return;
}
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = value.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
referenceChain.release();
if (last.getValuetype() == Value_type.FUNCTION_REFERENCE_VALUE) {
final Definition function = ((Function_Reference_Value) last).getReferredFunction();
expression.expression.append(MessageFormat.format("{0}(", function.getGenNameFromScope(aData, expression.expression, myScope, "")));
actualParameter_list.generateCodeAlias(aData, expression);
} else {
value.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".invoke(");
IType governor = value.getMyGovernor();
if (governor == null) {
governor = value.getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
}
if (governor == null) {
return;
}
actualParameter_list.generateCodeAlias(aData, expression);
}
expression.expression.append(')');
}
Aggregations