use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class Getreply_Statement method generateCodeExpression.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeExpression(final JavaGenData aData, final ExpressionStruct expression) {
if (portReference != null) {
portReference.generateCode(aData, expression);
expression.expression.append(".getreply(");
if (parameter != null) {
// FIXME handle redirect
parameter.generateCode(aData, expression, Restriction_type.TR_NONE);
final IType signature = parameter.getTemplateBody().getMyGovernor();
final IType signatureType = signature.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
final IType returnType = ((Signature_Type) signatureType).getSignatureReturnType();
if (returnType != null) {
expression.expression.append(".set_value_template(");
if (valueMatch != null) {
valueMatch.generateCode(aData, expression, Restriction_type.TR_NONE);
} else {
// the value match is not present
// we must substitute it with ? in the signature template
expression.expression.append(MessageFormat.format("new {0}(template_sel.ANY_VALUE)", returnType.getGenNameTemplate(aData, expression.expression, myScope)));
}
expression.expression.append(')');
}
expression.expression.append(", ");
generateCodeExprFromclause(aData, expression);
// FIXME handle redirections
expression.expression.append(", ");
if (redirectSender == null) {
expression.expression.append("null");
} else {
redirectSender.generateCode(aData, expression);
}
} else {
// the signature template is not present
generateCodeExprFromclause(aData, expression);
expression.expression.append(", ");
if (redirectSender == null) {
expression.expression.append("null");
} else {
redirectSender.generateCode(aData, expression);
}
}
// FIXME handle index redirection
expression.expression.append(", null");
} else {
// the operation refers to any port
expression.expression.append("TitanPort.any_getreply(");
generateCodeExprFromclause(aData, expression);
expression.expression.append(", ");
if (redirectSender == null) {
expression.expression.append("null");
} else {
redirectSender.generateCode(aData, expression);
}
}
expression.expression.append(')');
}
use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class Invoke_Altguard method generateCodeInvokeInstance.
/**
* Generate code for an alt guard
*
* @param aData the structure to put imports into and get temporal variable names from.
* @param expression the expression to generate the source to
*/
public void generateCodeInvokeInstance(final JavaGenData aData, final ExpressionStruct expression) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = value.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
referenceChain.release();
if (last.getValuetype() == Value_type.ALTSTEP_REFERENCE_VALUE) {
Def_Altstep altstep = ((Altstep_Reference_Value) last).getReferredAltstep();
expression.expression.append(MessageFormat.format("{0}_instance(", altstep.getGenNameFromScope(aData, expression.expression, myScope, "")));
actualParameterList.generateCodeAlias(aData, expression);
} else {
value.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".invoke(");
IType governor = value.getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
governor = governor.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
actualParameterList.generateCodeAlias(aData, expression);
}
expression.expression.append(')');
}
use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class Done_Statement method generateCodeExpression.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeExpression(final JavaGenData aData, final ExpressionStruct expression) {
aData.addCommonLibraryImport("TTCN_Runtime");
aData.addBuiltinTypeImport("TitanComponent");
if (componentreference != null) {
if (doneMatch != null) {
// value returning done
// figure out what type the done() function belongs to
IType t = doneMatch.getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
if (t == null) {
ErrorReporter.INTERNAL_ERROR("Encountered a done with unknown governor `" + getFullName() + "''");
return;
}
while (t instanceof Referenced_Type && !t.hasDoneAttribute()) {
final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
t = ((IReferencingType) t).getTypeRefd(CompilationTimeStamp.getBaseTimestamp(), refChain);
refChain.release();
}
if (!t.hasDoneAttribute()) {
ErrorReporter.INTERNAL_ERROR("Encountered a done return type without done attribute `" + getFullName() + "''");
return;
}
// determine whether the done() function is in the same module
final Module t_module = t.getMyScope().getModuleScope();
if (t_module != myStatementBlock.getModuleScope()) {
expression.expression.append(MessageFormat.format("{0}.", t_module.getIdentifier().getName()));
}
expression.expression.append("done(");
componentreference.generateCodeExpression(aData, expression, true);
expression.expression.append(", ");
// FIXME handle decoded match
doneMatch.generateCode(aData, expression, Restriction_type.TR_NONE);
// expression.expression.append(", ");
// FIXME handle value redirection
} else {
// simple done
componentreference.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".done(");
}
// FIXME handle index redirection
expression.expression.append(')');
} else if (isAny) {
// any component.done
expression.expression.append("TTCN_Runtime.component_done(TitanComponent.ANY_COMPREF)");
} else {
// all component.done
expression.expression.append("TTCN_Runtime.component_done(TitanComponent.ALL_COMPREF)");
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class Function_Applied_Statement method generateCode.
@Override
public /**
* {@inheritDoc}
*/
void generateCode(final JavaGenData aData, final StringBuilder source) {
final ExpressionStruct expression = new ExpressionStruct();
final IValue last = dereferredValue.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
if (last.getValuetype().equals(Value_type.ALTSTEP_REFERENCE_VALUE)) {
// TODO Optimize for easily resolvable value
}
dereferredValue.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".invoke(");
if (actualParameterList2 != null && actualParameterList2.getNofParameters() > 0) {
actualParameterList2.generateCodeAlias(aData, expression);
}
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 Getcall_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());
}
Aggregations