use of org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value in project titan.EclipsePlug-ins by eclipse.
the class Unichar2CharExpression 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_UCHARSTRING:
final IValue last = value.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
UniversalCharstring string;
if (last instanceof Charstring_Value) {
// check not necessary, trivial case
return;
} else if (last instanceof UniversalCharstring_Value) {
string = ((UniversalCharstring_Value) last).getValue();
if (string == null) {
setIsErroneous(true);
return;
}
} else {
value.getLocation().reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
return;
}
for (int i = 0; i < string.length(); i++) {
final UniversalChar uchar = string.get(i);
if (uchar.group() != 0 || uchar.plane() != 0 || uchar.row() != 0 || uchar.cell() > 127) {
value.getLocation().reportSemanticError(OPERANDERROR2);
setIsErroneous(true);
return;
}
}
}
return;
case TYPE_CHARSTRING:
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
if (!isErroneous) {
location.reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
}
return;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value in project titan.EclipsePlug-ins by eclipse.
the class Oct2CharExpression 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 OCTETSTRING_VALUE:
{
final String octetString = ((Octetstring_Value) last).getValue();
lastValue = new Charstring_Value(oct2char(octetString));
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 Oct2StrExpression 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 OCTETSTRING_VALUE:
final String octetString = ((Octetstring_Value) last).getValue();
lastValue = new Charstring_Value(octetString);
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 Macro_Value method evaluateMacro.
/**
* Evaluates the value of the macro.
*
* @param expectedValue the kind of the value to be expected
*
* @return the actual or the evaluated value
*/
private IValue evaluateMacro(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return lastValue;
}
lastTimeChecked = timestamp;
lastValue = this;
switch(value) {
case MODULEID:
if (myScope != null && myScope.getModuleScope() != null) {
final Module module = myScope.getModuleScope();
if (module.getIdentifier() != null) {
lastValue = new Charstring_Value(module.getIdentifier().getDisplayName());
lastValue.copyGeneralProperties(this);
}
}
break;
case DEFINITIONID:
if (myScope != null) {
final StatementBlock block = myScope.getStatementBlockScope();
if (block != null) {
final Definition definition = block.getMyDefinition();
if (definition != null) {
lastValue = new Charstring_Value(definition.getIdentifier().getDisplayName());
lastValue.copyGeneralProperties(this);
}
}
} else {
setIsErroneous(true);
}
break;
case TESTCASEID:
if (myScope != null) {
final StatementBlock block = myScope.getStatementBlockScope();
if (block != null) {
final Definition definition = block.getMyDefinition();
if (definition == null) {
location.reportSemanticError(TESCASEIDINCONTROLPART);
setIsErroneous(true);
} else {
if (Assignment_type.A_TESTCASE.semanticallyEquals(definition.getAssignmentType())) {
// folding is possible in testcases only
lastValue = new Charstring_Value(definition.getIdentifier().getDisplayName());
lastValue.copyGeneralProperties(this);
}
}
} else {
location.reportSemanticError(TESTCASEIDNOTALLOWED);
setIsErroneous(true);
}
} else {
setIsErroneous(true);
}
break;
case FILENAME:
case BFILENAME:
if (NULL_Location.INSTANCE.equals(location)) {
setIsErroneous(true);
} else {
lastValue = new Charstring_Value(location.getFile().getName());
lastValue.copyGeneralProperties(this);
}
break;
case FILEPATH:
if (NULL_Location.INSTANCE.equals(location)) {
setIsErroneous(true);
} else {
String canonicalPath;
final IPath absolutePath = location.getFile().getLocation();
if (absolutePath == null) {
location.reportSemanticError(UNDETERMINABLEPATH);
canonicalPath = location.getFile().getName();
setIsErroneous(true);
} else {
final File file = absolutePath.toFile();
try {
canonicalPath = file.getCanonicalPath();
} catch (IOException e) {
location.reportSemanticError(UNDETERMINABLEPATH);
canonicalPath = location.getFile().getName();
setIsErroneous(true);
}
}
lastValue = new Charstring_Value(canonicalPath);
lastValue.copyGeneralProperties(this);
}
break;
case LINENUMBER:
if (NULL_Location.INSTANCE.equals(location)) {
setIsErroneous(true);
} else {
lastValue = new Charstring_Value(Long.toString(location.getLine()));
lastValue.copyGeneralProperties(this);
}
break;
case LINENUMBER_C:
if (NULL_Location.INSTANCE.equals(location)) {
setIsErroneous(true);
} else {
lastValue = new Integer_Value(location.getLine());
lastValue.copyGeneralProperties(this);
}
break;
case SCOPE:
if (myScope != null) {
lastValue = new Charstring_Value(myScope.getScopeMacroName());
lastValue.copyGeneralProperties(this);
} else {
location.reportSemanticError(UNDETERMINABLESCOPE);
setIsErroneous(true);
}
break;
default:
setIsErroneous(true);
}
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value in project titan.EclipsePlug-ins by eclipse.
the class DecvalueUnicharExpression method checkExpressionOperand3.
/**
* Checks the 3rd operand
* in charstring (optional)
* @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 checkExpressionOperand3(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (value3 == null) {
return;
}
value3.setLoweridToReference(timestamp);
final Type_type tempType = value3.getExpressionReturntype(timestamp, expectedValue);
switch(tempType) {
case TYPE_CHARSTRING:
final IValue last = value3.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final String originalString = ((Charstring_Value) last).getValue();
final CharstringExtractor cs = new CharstringExtractor(originalString);
if (cs.isErrorneous()) {
value3.getLocation().reportSemanticError(cs.getErrorMessage());
setIsErroneous(true);
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
if (!isErroneous) {
location.reportSemanticError(OPERAND3_ERROR1);
setIsErroneous(true);
}
break;
}
}
Aggregations