use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class Stop_Component_Statement method generateCode.
@Override
public /**
* {@inheritDoc}
*/
void generateCode(final JavaGenData aData, final StringBuilder source) {
aData.addCommonLibraryImport("TTCN_Runtime");
final ExpressionStruct expression = new ExpressionStruct();
if (componentReference == null) {
aData.addBuiltinTypeImport("TitanComponent");
expression.expression.append("TTCN_Runtime.stop_component(TitanComponent.ALL_COMPREF)");
} else {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = componentReference.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
referenceChain.release();
if (last.getValuetype() == Value_type.REFERENCED_VALUE) {
// the argument is a simple component reference
last.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".stop()");
} else {
boolean refers_to_self = false;
if (last.getValuetype() == Value_type.EXPRESSION_VALUE) {
// the argument is a special component reference (mtc, self, etc.)
switch(((Expression_Value) last).getOperationType()) {
case MTC_COMPONENT_OPERATION:
{
Definition myDefinition = myStatementBlock.getMyDefinition();
if (myDefinition != null && myDefinition.getAssignmentType() == Assignment_type.A_TESTCASE) {
refers_to_self = true;
}
break;
}
case SELF_COMPONENT_OPERATION:
refers_to_self = true;
default:
break;
}
}
if (refers_to_self) {
expression.expression.append("TTCN_Runtime.stop_execution()");
} else {
expression.expression.append("TTCN_Runtime.stop_component(");
last.generateCodeExpression(aData, expression, false);
expression.expression.append(')');
}
}
}
expression.mergeExpression(source);
}
use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class Reply_Statement method generateCode.
@Override
public /**
* {@inheritDoc}
*/
void generateCode(final JavaGenData aData, final StringBuilder source) {
final ExpressionStruct expression = new ExpressionStruct();
portReference.generateCode(aData, expression);
expression.expression.append(".reply(");
parameter.generateCode(aData, expression, Restriction_type.TR_NONE);
if (replyValue != null) {
expression.expression.append(".set_value_template(");
replyValue.generateCodeExpression(aData, expression, true);
expression.expression.append(')');
}
if (toClause != null) {
expression.expression.append(", ");
toClause.generateCodeExpression(aData, expression, true);
}
expression.expression.append(" )");
expression.mergeExpression(source);
}
use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class Return_Statement method generateCode.
@Override
public /**
* {@inheritDoc}
*/
void generateCode(final JavaGenData aData, final StringBuilder source) {
// TODO more nuanced code generation
getLocation().release_location_object(aData, source);
final ExpressionStruct expression = new ExpressionStruct();
expression.expression.append("return ");
// No return value:
if (template == null) {
expression.mergeExpression(source);
return;
}
final Definition definition = myStatementBlock.getMyDefinition();
if (definition.getAssignmentType() == Assignment_type.A_FUNCTION_RVAL && template.getTemplatetype() == Template_type.SPECIFIC_VALUE) {
final IValue value = ((SpecificValue_Template) template).getValue();
value.generateCodeExpressionMandatory(aData, expression, true);
} else {
final Definition myDefinition = myStatementBlock.getMyDefinition();
if (myDefinition.getTemplateRestriction() != TemplateRestriction.Restriction_type.TR_NONE && genRestrictionCheck) {
template.generateCodeExpression(aData, expression, myDefinition.getTemplateRestriction());
} else {
template.generateCodeExpression(aData, expression, Restriction_type.TR_NONE);
}
}
expression.mergeExpression(source);
}
use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class Killed_Statement method generateCode.
@Override
public /**
* {@inheritDoc}
*/
void generateCode(final JavaGenData aData, final StringBuilder source) {
final ExpressionStruct expression = new ExpressionStruct();
generateCodeExpression(aData, expression);
PortGenerator.generateCodeStandalone(aData, source, expression.expression.toString(), getLocation());
}
use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class LogArgument method generateCode.
/**
* Add generated java code on this level.
* @param aData the structure to put imports into and get temporal variable names from.
* @param source the source code generated
*/
public void generateCode(final JavaGenData aData, final StringBuilder source) {
final ExpressionStruct expression = new ExpressionStruct();
if (internalLogArgument != null) {
internalLogArgument.generateCode(aData, expression);
}
source.append(expression.preamble);
source.append(expression.expression);
source.append(";\n");
}
Aggregations