use of org.eclipse.titan.designer.AST.IType.ValueCheckingOptions in project titan.EclipsePlug-ins by eclipse.
the class Port_Utility method checkToClause.
/**
* Checks a to clause reference to see if it really references valid
* component type.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param source
* the source statement of this check.
* @param portType
* the type of the port used in the statement. Used to
* find the address type in effect.
* @param toClause
* the to clause to check
*/
public static void checkToClause(final CompilationTimeStamp timestamp, final Statement source, final Port_Type portType, final IValue toClause) {
if (toClause == null) {
return;
}
IType addressType = null;
if (portType != null) {
addressType = portType.getPortBody().getAddressType(timestamp);
} else if (source != null) {
final Module module = source.getMyStatementBlock().getModuleScope();
if (module != null && module_type.TTCN3_MODULE.equals(module.getModuletype())) {
addressType = ((TTCN3Module) module).getAddressType(timestamp);
}
}
if (addressType == null) {
checkComponentReference(timestamp, source, toClause, true, true);
} else {
// detect possible enumerated values (address may be an
// enumerated type)
final IValue temp = addressType.checkThisValueRef(timestamp, toClause);
// try to figure out whether the argument is a component
// reference or an SUT address
boolean isAddress;
final IType governor = temp.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (governor == null) {
isAddress = !Type_type.TYPE_COMPONENT.equals(temp.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE));
} else {
isAddress = addressType.isCompatible(timestamp, governor, null, null, null);
}
if (isAddress) {
addressType.checkThisValue(timestamp, temp, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false, false, true, false, false));
} else {
checkComponentReference(timestamp, source, temp, true, true);
}
}
}
use of org.eclipse.titan.designer.AST.IType.ValueCheckingOptions in project titan.EclipsePlug-ins by eclipse.
the class SelectCase_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
if (expression == null) {
return;
}
IValue temp = expression.setLoweridToReference(timestamp);
final IType governor = temp.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (governor == null) {
if (!temp.getIsErroneous(timestamp)) {
expression.getLocation().reportSemanticError(UNDETERMINABLETYPE);
}
return;
}
temp = governor.checkThisValueRef(timestamp, expression);
governor.checkThisValue(timestamp, temp, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false, false, true, false, false));
selectcases.check(timestamp, governor);
}
use of org.eclipse.titan.designer.AST.IType.ValueCheckingOptions in project titan.EclipsePlug-ins by eclipse.
the class SelectUnionCase_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
if (expression == null) {
return;
}
IValue temp = expression.setLoweridToReference(timestamp);
final IType governor = temp.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (governor == null) {
if (!temp.getIsErroneous(timestamp)) {
expression.getLocation().reportSemanticError(UNDETERMINABLETYPE);
}
return;
}
temp = governor.checkThisValueRef(timestamp, expression);
governor.checkThisValue(timestamp, temp, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false, false, true, false, false));
// referenced type
final IType refd = governor.getTypeRefdLast(timestamp);
if (refd instanceof TTCN3_Choice_Type) {
// referenced union type to check
final TTCN3_Choice_Type unionType = (TTCN3_Choice_Type) refd;
checkUnionType(timestamp, unionType);
} else if (refd instanceof Anytype_Type) {
// referenced anytype type to check
final Anytype_Type anytypeType = (Anytype_Type) refd;
checkAnytypeType(timestamp, anytypeType);
} else {
expression.getLocation().reportSemanticError(TYPE_MUST_BE_UNION_OR_ANYTYPE);
// special operations to check the body of the cases even if the select expression is erroneous
for (int i = 0; i < selectUnionCases.getSize(); i++) {
selectUnionCases.getSelectUnionCase(i).checkStatementBlock(timestamp);
}
return;
}
}
use of org.eclipse.titan.designer.AST.IType.ValueCheckingOptions in project titan.EclipsePlug-ins by eclipse.
the class LogArgument method checkValue.
/**
* Does the semantic checking of the log argument. Once it was
* determined that it is a value.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param value
* the value contained in the log argument.
*/
private void checkValue(final CompilationTimeStamp timestamp, final IValue value) {
final IValue temp = value.setLoweridToReference(timestamp);
switch(temp.getValuetype()) {
case CHARSTRING_VALUE:
internalLogArgument = new String_InternalLogArgument(((Charstring_Value) temp).getValue());
break;
case REFERENCED_VALUE:
final Reference reference = ((Referenced_Value) temp).getReference();
internalLogArgument = new Reference_InternalLogArgument(reference);
checkReference(timestamp, reference);
return;
case EXPRESSION_VALUE:
final Expression_Value castedValue = (Expression_Value) temp;
if (Operation_type.MATCH_OPERATION.equals(castedValue.getOperationType())) {
internalLogArgument = new Match_InternalLogArgument((MatchExpression) castedValue);
} else {
internalLogArgument = new Value_InternalLogArgument(temp);
}
break;
case MACRO_VALUE:
internalLogArgument = new Macro_InternalLogArgument((Macro_Value) temp);
break;
default:
internalLogArgument = new Value_InternalLogArgument(temp);
break;
}
final IType governor = temp.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
if (governor == null) {
getLocation().reportSemanticError("Cannot determine the type of the argument");
isErroneous = true;
return;
}
// TODO: Is the next part necessary ???
temp.setMyGovernor(governor);
// TODO:WHY
governor.checkThisValue(timestamp, temp, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_TEMPLATE, true, true, true, true, false));
final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
if (ArgumentType.Value.equals(internalLogArgument.getArgumentType()) && !temp.isUnfoldable(timestamp)) {
final IValue last = temp.getValueRefdLast(timestamp, chain);
if (Value_type.CHARSTRING_VALUE.equals(last.getValuetype())) {
internalLogArgument = new String_InternalLogArgument(((Charstring_Value) last).getValue());
}
} else if (ArgumentType.Macro.equals(internalLogArgument.getArgumentType())) {
final IValue last = temp.getValueRefdLast(timestamp, chain);
switch(last.getValuetype()) {
case CHARSTRING_VALUE:
internalLogArgument = new String_InternalLogArgument(((Charstring_Value) last).getValue());
break;
case MACRO_VALUE:
break;
default:
internalLogArgument = new Value_InternalLogArgument(temp);
break;
}
}
chain.release();
}
use of org.eclipse.titan.designer.AST.IType.ValueCheckingOptions in project titan.EclipsePlug-ins by eclipse.
the class SpecificValue_Template method checkThisTemplateGeneric.
@Override
public /**
* {@inheritDoc}
*/
boolean checkThisTemplateGeneric(final CompilationTimeStamp timestamp, final IType type, final boolean isModified, final boolean allowOmit, final boolean allowAnyOrOmit, final boolean subCheck, final boolean implicitOmit, final Assignment lhs) {
if (getIsErroneous(timestamp)) {
return false;
}
if (type == null) {
return false;
}
boolean selfReference = false;
type.check(timestamp);
if (specificValue != null) {
specificValue.setMyGovernor(type);
final IValue temporalValue = type.checkThisValueRef(timestamp, specificValue);
selfReference = type.checkThisValue(timestamp, temporalValue, lhs, new ValueCheckingOptions(Expected_Value_type.EXPECTED_TEMPLATE, isModified, allowOmit, true, implicitOmit, false));
}
checkLengthRestriction(timestamp, type);
if (!allowOmit && isIfpresent) {
if (location != null && !(location instanceof NULL_Location)) {
location.reportSemanticError("`ifpresent' is not allowed here");
} else if (specificValue != null && !(specificValue.getLocation() instanceof NULL_Location)) {
specificValue.getLocation().reportSemanticError("`ifpresent' is not allowed here");
}
}
if (subCheck) {
type.checkThisTemplateSubtype(timestamp, this);
}
return selfReference;
}
Aggregations