use of org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring in project titan.EclipsePlug-ins by eclipse.
the class Unichar2IntExpression 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);
IValue last;
switch(tempType) {
case TYPE_UCHARSTRING:
case TYPE_CHARSTRING:
last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final Value_type tempType1 = last.getValuetype();
// UniversalCharstring string; // = ((UniversalCharstring_Value) last).getValue();
switch(tempType1) {
case UNIVERSALCHARSTRING_VALUE:
{
final UniversalCharstring string = ((UniversalCharstring_Value) last).getValue();
if (string.isErrorneous()) {
value.getLocation().reportSemanticError(string.getErrorMessage());
setIsErroneous(true);
} else if (string.length() != 1) {
value.getLocation().reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
}
break;
}
case CHARSTRING_VALUE:
{
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);
}
}
}
default:
// error???
break;
}
// switch
}
// if
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.UniversalCharstring in project titan.EclipsePlug-ins by eclipse.
the class Unichar2OctExpression method evaluateValue.
@Override
public /**
* {@inheritDoc}
*/
IValue evaluateValue(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
// TODO: reimplement if needed
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) || isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
final IValue last = value.getValueRefdLast(timestamp, referenceChain);
if (last.getIsErroneous(timestamp)) {
setIsErroneous(true);
return lastValue;
}
switch(last.getValuetype()) {
case UNIVERSALCHARSTRING_VALUE:
{
final UniversalCharstring string = ((UniversalCharstring_Value) last).getValue();
final UniversalChar uchar = string.get(0);
final byte[] bytes = new byte[] { (byte) uchar.cell() };
lastValue = new Octetstring_Value(new String(bytes));
break;
}
default:
return this;
}
lastValue.copyGeneralProperties(this);
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring in project titan.EclipsePlug-ins by eclipse.
the class ReplaceExpression 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 (templateInstance1 == null || value2 == null || value3 == null || templateInstance4 == null) {
setIsErroneous(true);
return lastValue;
}
checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (getIsErroneous(timestamp)) {
return lastValue;
}
if (isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
ITTCN3Template temp = templateInstance1.getTemplateBody();
final IValue value1 = ((SpecificValue_Template) temp).getSpecificValue();
final IValue v1 = value1.getValueRefdLast(timestamp, referenceChain);
final IValue v2 = value2.getValueRefdLast(timestamp, referenceChain);
final IValue v3 = value3.getValueRefdLast(timestamp, referenceChain);
temp = templateInstance4.getTemplateBody();
final IValue value4 = ((SpecificValue_Template) temp).getSpecificValue();
final IValue v4 = value4.getValueRefdLast(timestamp, referenceChain);
final Value_type vt = v1.getValuetype();
final int index = ((Integer_Value) v2).intValue();
final int len = ((Integer_Value) v3).intValue();
switch(vt) {
case BITSTRING_VALUE:
{
final String v1Str = ((Bitstring_Value) v1).getValue();
final String v4Str = ((Bitstring_Value) v4).getValue();
String result = v1Str.substring(0, index);
result = result.concat(v4Str);
result = result.concat(v1Str.substring(index + len));
lastValue = new Bitstring_Value(result);
lastValue.copyGeneralProperties(this);
break;
}
case HEXSTRING_VALUE:
{
final String v1Str = ((Hexstring_Value) v1).getValue();
final String v4Str = ((Hexstring_Value) v4).getValue();
String result = v1Str.substring(0, index);
result = result.concat(v4Str);
result = result.concat(v1Str.substring(index + len));
lastValue = new Hexstring_Value(result);
lastValue.copyGeneralProperties(this);
break;
}
case OCTETSTRING_VALUE:
{
final String v1Str = ((Octetstring_Value) v1).getValue();
final String v4Str = ((Octetstring_Value) v4).getValue();
String result = v1Str.substring(0, index * 2);
result = result.concat(v4Str);
result = result.concat(v1Str.substring((index + len) * 2));
lastValue = new Octetstring_Value(result);
lastValue.copyGeneralProperties(this);
break;
}
case CHARSTRING_VALUE:
{
final String v1Str = ((Charstring_Value) v1).getValue();
final String v4Str = ((Charstring_Value) v4).getValue();
String result = v1Str.substring(0, index);
result = result.concat(v4Str);
result = result.concat(v1Str.substring(index + len));
lastValue = new Charstring_Value(result);
lastValue.copyGeneralProperties(this);
break;
}
case UNIVERSALCHARSTRING_VALUE:
{
final UniversalCharstring v1Str = ((UniversalCharstring_Value) v1).getValue();
final UniversalCharstring v4Str = ((UniversalCharstring_Value) v4).getValue();
final UniversalCharstring result = v1Str.substring(0, index);
// This append() is not like concat().
result.append(v4Str);
result.append(v1Str.substring(index + len));
lastValue = new UniversalCharstring_Value(result);
lastValue.copyGeneralProperties(this);
break;
}
default:
setIsErroneous(true);
break;
}
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring in project titan.EclipsePlug-ins by eclipse.
the class Int2UnicharExpression 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)) {
return lastValue;
}
switch(last.getValuetype()) {
case INTEGER_VALUE:
{
final long i = ((Integer_Value) last).getValue();
final long group = (i >> 24) & 0xFF;
final long plane = (i >> 16) & 0xFF;
final long row = (i >> 8) & 0xFF;
final long cell = i & 0xFF;
lastValue = new UniversalCharstring_Value(new UniversalCharstring(new UniversalChar((int) group, (int) plane, (int) row, (int) cell)));
break;
}
default:
return this;
}
lastValue.copyGeneralProperties(this);
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring in project titan.EclipsePlug-ins by eclipse.
the class Unichar2CharExpression 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) || isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
final IValue last = value.getValueRefdLast(timestamp, referenceChain);
if (last.getIsErroneous(timestamp)) {
setIsErroneous(true);
return lastValue;
}
switch(last.getValuetype()) {
case UNIVERSALCHARSTRING_VALUE:
{
final UniversalCharstring string = ((UniversalCharstring_Value) last).getValue();
final UniversalChar uchar = string.get(0);
final byte[] bytes = new byte[] { (byte) uchar.cell() };
lastValue = new Charstring_Value(new String(bytes));
break;
}
case CHARSTRING_VALUE:
{
lastValue = new Charstring_Value(((Charstring_Value) last).getValue());
break;
}
default:
return this;
}
lastValue.copyGeneralProperties(this);
return lastValue;
}
Aggregations