use of org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value in project titan.EclipsePlug-ins by eclipse.
the class ComponentCreateExpression method generateCodeExpressionExpression.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeExpressionExpression(final JavaGenData aData, final ExpressionStruct expression) {
aData.addCommonLibraryImport("TTCN_Runtime");
expression.expression.append("TTCN_Runtime.create_component(");
// the type of the component (module name and identifier)
final Assignment assignment = componentReference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
if (assignment == null || !Assignment_type.A_TYPE.equals(assignment.getAssignmentType())) {
ErrorReporter.INTERNAL_ERROR("FATAL ERROR while generating code for expression `" + getFullName() + "''");
return;
}
IType componentType = assignment.getType(CompilationTimeStamp.getBaseTimestamp()).getFieldType(CompilationTimeStamp.getBaseTimestamp(), componentReference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
if (componentType == null) {
ErrorReporter.INTERNAL_ERROR("FATAL ERROR while generating code for expression `" + getFullName() + "''");
return;
}
componentType = componentType.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
if (!Type_type.TYPE_COMPONENT.equals(componentType.getTypetype())) {
ErrorReporter.INTERNAL_ERROR("FATAL ERROR while generating code for expression `" + getFullName() + "''");
return;
}
((Component_Type) componentType).getComponentBody().generateCodeComponentTypeName(expression);
expression.expression.append(", ");
// third argument: component name
if (name != null) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = name.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
referenceChain.release();
if (Value_type.CHARSTRING_VALUE.equals(last.getValuetype())) {
// TODO check why translate
expression.expression.append(MessageFormat.format("\"{0}\"", ((Charstring_Value) last).getValue()));
} else {
name.generateCodeExpressionMandatory(aData, expression, false);
}
} else {
expression.expression.append("null");
}
expression.expression.append(", ");
// fourth argument location
if (location != null) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = location.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
referenceChain.release();
if (Value_type.CHARSTRING_VALUE.equals(last.getValuetype())) {
// TODO check why translate
expression.expression.append(MessageFormat.format("\"{0}\"", ((Charstring_Value) last).getValue()));
} else {
location.generateCodeExpressionMandatory(aData, expression, false);
}
} else {
expression.expression.append("null");
}
// fifth argument: alive flag
expression.expression.append(MessageFormat.format(", {0})", isAlive ? "true" : "false"));
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value in project titan.EclipsePlug-ins by eclipse.
the class DecodeBase64Expression method evaluateValue.
@Override
public /**
* {@inheritDoc}
*/
IValue evaluateValue(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return lastValue;
}
isErroneous = false;
lastTimeChecked = timestamp;
lastValue = this;
if (value == null) {
return lastValue;
}
checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (getIsErroneous(timestamp)) {
return lastValue;
}
if (isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
final IValue last = value.getValueRefdLast(timestamp, referenceChain);
if (last.getIsErroneous(timestamp)) {
setIsErroneous(true);
return lastValue;
}
switch(last.getValuetype()) {
case CHARSTRING_VALUE:
final String tempBitstring = ((Charstring_Value) last).getValue();
lastValue = new Octetstring_Value(calculateValue(tempBitstring));
lastValue.copyGeneralProperties(this);
break;
default:
setIsErroneous(true);
break;
}
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value in project titan.EclipsePlug-ins by eclipse.
the class AnyPortCheckStateExpression method checkExpressionOperand1.
/**
* Checks the operand
* in charstring (mandatory)
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expectedValue
* the kind of value expected.
* @param referenceChain
* a reference chain to detect cyclic references.
*/
private void checkExpressionOperand1(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (value == null) {
setIsErroneous(true);
return;
}
value.setLoweridToReference(timestamp);
final Type_type tempType = value.getExpressionReturntype(timestamp, expectedValue);
switch(tempType) {
case TYPE_CHARSTRING:
final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final String originalString = ((Charstring_Value) last).getValue();
final CharstringExtractor cs = new CharstringExtractor(originalString);
if (cs.isErrorneous()) {
value.getLocation().reportSemanticError(cs.getErrorMessage());
setIsErroneous(true);
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
if (!isErroneous) {
location.reportSemanticError(OPERAND1_ERROR1);
setIsErroneous(true);
}
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value in project titan.EclipsePlug-ins by eclipse.
the class Char2IntExpression method checkExpressionOperands.
/**
* Checks the parameters of the expression and if they are valid in
* their position in the expression or not.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expectedValue
* the kind of value expected.
* @param referenceChain
* a reference chain to detect cyclic references.
*/
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (value == null) {
return;
}
value.setLoweridToReference(timestamp);
final Type_type tempType = value.getExpressionReturntype(timestamp, expectedValue);
switch(tempType) {
case TYPE_CHARSTRING:
final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final String originalString = ((Charstring_Value) last).getValue();
final CharstringExtractor cs = new CharstringExtractor(originalString);
if (cs.isErrorneous()) {
value.getLocation().reportSemanticError(cs.getErrorMessage());
setIsErroneous(true);
} else {
final String string = cs.getExtractedString();
if (string != null && string.length() != 1) {
value.getLocation().reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
}
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
}
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value in project titan.EclipsePlug-ins by eclipse.
the class Char2OctExpression method evaluateValue.
@Override
public /**
* {@inheritDoc}
*/
IValue evaluateValue(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return lastValue;
}
isErroneous = false;
lastTimeChecked = timestamp;
lastValue = this;
if (value == null) {
return lastValue;
}
checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (getIsErroneous(timestamp)) {
return lastValue;
}
if (isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
final IValue last = value.getValueRefdLast(timestamp, referenceChain);
if (last.getIsErroneous(timestamp)) {
setIsErroneous(true);
return lastValue;
}
switch(last.getValuetype()) {
case CHARSTRING_VALUE:
final String string = ((Charstring_Value) last).getValue();
final CharstringExtractor cs = new CharstringExtractor(string);
lastValue = new Octetstring_Value(char2oct(cs.getExtractedString()));
lastValue.copyGeneralProperties(this);
break;
default:
setIsErroneous(true);
break;
}
return lastValue;
}
Aggregations