use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class Raise_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(".raise( new ");
signatureReference.generateCode(aData, expression);
expression.expression.append("_exception(");
final TTCN3Template templateBody = parameter.getTemplateBody();
if (parameter.getDerivedReference() == null && Template_type.SPECIFIC_VALUE.equals(templateBody.getTemplatetype())) {
// the exception is a value: optimization is possible
final IValue value = ((SpecificValue_Template) templateBody).getSpecificValue();
// FIXME implement the case where cast is needed (if really needed)
value.generateCodeExpressionMandatory(aData, expression, true);
} else {
parameter.generateCode(aData, expression, Restriction_type.TR_NONE);
}
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 Referenced_Testcase_Instance_Statement method generateCode.
@Override
public /**
* {@inheritDoc}
*/
void generateCode(final JavaGenData aData, final StringBuilder source) {
aData.addBuiltinTypeImport("TitanFloat");
aData.addBuiltinTypeImport("Ttcn3Float");
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.TESTCASE_REFERENCE_VALUE)) {
// TODO Optimize for easily resolvable value
}
dereferredValue.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".execute(");
actualParameterList2.generateCodeAlias(aData, expression);
if (actualParameterList2.getNofParameters() > 0) {
expression.expression.append(", ");
}
if (timerValue == null) {
expression.expression.append("false, new TitanFloat( new Ttcn3Float( 0.0 ) ))");
} else {
expression.expression.append("true, ");
timerValue.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 All_From_Template method generateCodeInitAllFrom.
public void generateCodeInitAllFrom(final JavaGenData aData, final StringBuilder source, final String name) {
final IValue value = ((SpecificValue_Template) allFrom).getValue();
Reference reference;
if (value.getValuetype() == Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE) {
// value.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), null);
reference = ((Undefined_LowerIdentifier_Value) value).getAsReference();
} else {
reference = ((Referenced_Value) value).getReference();
}
final ExpressionStruct expression = new ExpressionStruct();
reference.generateCode(aData, expression);
final Assignment assignment = reference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
switch(assignment.getAssignmentType()) {
case A_CONST:
case A_EXT_CONST:
case A_MODULEPAR:
case A_VAR:
case A_PAR_VAL:
case A_PAR_VAL_IN:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
case A_FUNCTION_RVAL:
case A_EXT_FUNCTION_RVAL:
if (assignment.getType(CompilationTimeStamp.getBaseTimestamp()).fieldIsOptional(reference.getSubreferences())) {
expression.expression.append(".get()");
}
break;
default:
break;
}
// The caller will have to provide the for cycle with this variable
source.append(MessageFormat.format("{0}.assign({1}.getAt(i_i));\n", name, expression.expression));
}
use of org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct in project titan.EclipsePlug-ins by eclipse.
the class Unmap_Statement method generateCode.
@Override
public /**
* {@inheritDoc}
*/
void generateCode(final JavaGenData aData, final StringBuilder source) {
// FIXME this is actually more complex
final ExpressionStruct expression = new ExpressionStruct();
// FIXME generate code for translation
expression.expression.append("TTCN_Runtime.unmap_port(");
componentReference1.generateCodeExpression(aData, expression, true);
expression.expression.append(", ");
// FIXME actually _portref and based on component type
portReference1.generateCode(aData, expression);
expression.expression.append(".get_name(), ");
componentReference2.generateCodeExpression(aData, expression, true);
expression.expression.append(", ");
// FIXME actually _portref and based on component type
portReference2.generateCode(aData, expression);
expression.expression.append(".get_name()");
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 Deactivate_Statement method generateCode.
@Override
public /**
* {@inheritDoc}
*/
void generateCode(final JavaGenData aData, final StringBuilder source) {
aData.addCommonLibraryImport("TTCN_Default");
if (deactivate == null) {
source.append("TTCN_Default.deactivateAll();\n");
return;
}
final ExpressionStruct expression = new ExpressionStruct();
expression.expression.append("TTCN_Default.deactivate(");
deactivate.generateCodeExpression(aData, expression, true);
expression.expression.append(");\n");
expression.mergeExpression(source);
}
Aggregations