use of org.eclipse.titan.designer.AST.TTCN3.types.Component_Type in project titan.EclipsePlug-ins by eclipse.
the class UnusedStartedFuncRetVal method process.
@Override
public void process(final IVisitableNode node, final Problems problems) {
if (node instanceof Start_Component_Statement) {
final CompilationTimeStamp timestamp = CompilationTimeStamp.getBaseTimestamp();
final Start_Component_Statement s = (Start_Component_Statement) node;
final Component_Type compType = Port_Utility.checkComponentReference(timestamp, s, s.getComponent(), false, false);
final Assignment assignment = s.getFunctionInstanceReference().getRefdAssignment(timestamp, false);
if (assignment == null) {
return;
}
switch(assignment.getAssignmentType()) {
case A_FUNCTION:
case A_FUNCTION_RTEMP:
case A_FUNCTION_RVAL:
break;
default:
return;
}
final Def_Function function = (Def_Function) assignment;
final IType runsOnType = function.getRunsOnType(timestamp);
if (compType == null || runsOnType == null || !function.isStartable()) {
return;
}
switch(function.getAssignmentType()) {
case A_FUNCTION_RTEMP:
break;
case A_FUNCTION_RVAL:
IType type = function.getType(timestamp);
boolean returnTypeCorrect = false;
while (!returnTypeCorrect) {
if (type.hasDoneAttribute()) {
returnTypeCorrect = true;
break;
}
if (type instanceof IReferencingType) {
final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IType refd = ((IReferencingType) type).getTypeRefd(timestamp, refChain);
refChain.release();
if (type != refd) {
type = refd;
} else {
break;
}
} else {
break;
}
}
if (!returnTypeCorrect) {
final String msg = MessageFormat.format(PROBLEM, function.getDescription(), function.getType(timestamp).getTypename());
problems.report(s.getFunctionInstanceReference().getLocation(), msg);
}
break;
default:
break;
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Component_Type in project titan.EclipsePlug-ins by eclipse.
the class Altstep_Type method checkThisValue.
@Override
public /**
* {@inheritDoc}
*/
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
final boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
final IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
if (last == null || last.getIsErroneous(timestamp)) {
return selfReference;
}
last.setMyGovernor(this);
// already handled ones
switch(value.getValuetype()) {
case OMIT_VALUE:
case REFERENCED_VALUE:
return selfReference;
case UNDEFINED_LOWERIDENTIFIER_VALUE:
if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
return selfReference;
}
break;
default:
break;
}
Def_Altstep altstep = null;
switch(last.getValuetype()) {
case ALTSTEP_REFERENCE_VALUE:
altstep = ((Altstep_Reference_Value) last).getReferredAltstep();
if (altstep == null) {
setIsErroneous(true);
return selfReference;
}
altstep.check(timestamp);
break;
case TTCN3_NULL_VALUE:
value.setValuetype(timestamp, Value_type.FAT_NULL_VALUE);
return selfReference;
case EXPRESSION_VALUE:
case MACRO_VALUE:
// already checked
return selfReference;
default:
value.getLocation().reportSemanticError(ALTSTEPREFERENCEVALUEEXPECTED);
value.setIsErroneous(true);
return selfReference;
}
formalParList.checkCompatibility(timestamp, altstep.getFormalParameterList(), value.getLocation());
final IType temporalRunsOnType = altstep.getRunsOnType(timestamp);
if (temporalRunsOnType != null) {
if (runsOnSelf) {
// check against the runs on component type of the scope of the value
final Scope valueScope = value.getMyScope();
if (valueScope == null) {
value.setIsErroneous(true);
return selfReference;
}
final RunsOnScope runsOnScope = valueScope.getScopeRunsOn();
if (runsOnScope != null) {
final Component_Type componentType = runsOnScope.getComponentType();
if (!runsOnType.isCompatible(timestamp, componentType, null, null, null)) {
value.getLocation().reportSemanticError(MessageFormat.format("Runs on clause mismatch: type `{0}'' has a `runs on self'' clause and the current scope " + "expects component type `{1}'', but {2} runs on `{3}''", getTypename(), componentType.getTypename(), altstep.getDescription(), temporalRunsOnType.getTypename()));
}
} else {
// compatibility using this component type as the scope
if (valueScope instanceof ComponentTypeBody) {
final ComponentTypeBody body = (ComponentTypeBody) valueScope;
if (!runsOnType.isCompatible(timestamp, body.getMyType(), null, null, null)) {
value.getLocation().reportSemanticError(MessageFormat.format("Runs on clause mismatch: type `{0}'' has a `runs on self'' " + "clause and the current component definition is of type `{1}'', but {2} runs on `{3}''", getTypename(), body.getMyType().getTypename(), altstep.getDescription(), temporalRunsOnType.getTypename()));
}
} else {
value.getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' has a `runs on self'' clause and the current scope does not have a `runs on'' clause," + " but {1} runs on `{2}''", getTypename(), altstep.getDescription(), temporalRunsOnType.getTypename()));
}
}
} else {
if (runsOnRef == null) {
value.getLocation().reportSemanticError(MessageFormat.format(RUNSONLESSEXPECTED, getTypename(), altstep.getAssignmentName(), temporalRunsOnType.getTypename()));
value.setIsErroneous(true);
} else {
if (runsOnType != null && !temporalRunsOnType.isCompatible(timestamp, runsOnType, null, null, null)) {
value.getLocation().reportSemanticError(MessageFormat.format(INCOMPATIBLERUNSONTYPESERROR, getTypename(), runsOnType.getTypename(), altstep.getAssignmentName(), temporalRunsOnType.getTypename()));
value.setIsErroneous(true);
}
}
}
}
if (valueCheckingOptions.sub_check) {
// there is no parent type to check
if (subType != null) {
subType.checkThisValue(timestamp, value);
}
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Component_Type in project titan.EclipsePlug-ins by eclipse.
the class Testcase_Type method checkThisValue.
@Override
public /**
* {@inheritDoc}
*/
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
final boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
final IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
if (last == null || last.getIsErroneous(timestamp)) {
return selfReference;
}
last.setMyGovernor(this);
// already handled ones
switch(value.getValuetype()) {
case OMIT_VALUE:
case REFERENCED_VALUE:
return selfReference;
case UNDEFINED_LOWERIDENTIFIER_VALUE:
if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
return selfReference;
}
break;
default:
break;
}
Def_Testcase testcase = null;
switch(last.getValuetype()) {
case TESTCASE_REFERENCE_VALUE:
testcase = ((Testcase_Reference_Value) last).getReferredTestcase();
if (testcase == null) {
setIsErroneous(true);
return selfReference;
}
testcase.check(timestamp);
break;
case TTCN3_NULL_VALUE:
value.setValuetype(timestamp, Value_type.FAT_NULL_VALUE);
return selfReference;
case EXPRESSION_VALUE:
case MACRO_VALUE:
// already checked
return selfReference;
default:
value.getLocation().reportSemanticError(TESTCASEREFERENCEVALUEEXPECTED);
value.setIsErroneous(true);
return selfReference;
}
final Component_Type temporalRunsOnType = testcase.getRunsOnType(timestamp);
if (temporalRunsOnType != null) {
if (runsOnType != null && !temporalRunsOnType.isCompatible(timestamp, runsOnType, null, null, null)) {
value.getLocation().reportSemanticError(MessageFormat.format(INCOMPATIBLERUNSONTYPESERROR, getTypename(), runsOnType.getTypename(), testcase.getAssignmentName(), temporalRunsOnType.getTypename()));
value.setIsErroneous(true);
}
}
formalParList.checkCompatibility(timestamp, testcase.getFormalParameterList(), value.getLocation());
Component_Type temporalSystemType = testcase.getSystemType(timestamp);
if (temporalSystemType == null) {
temporalSystemType = temporalRunsOnType;
}
if (systemRef == null) {
if (temporalSystemType != null && runsOnType != null && !temporalSystemType.isCompatible(timestamp, runsOnType, null, null, null)) {
value.getLocation().reportSemanticError(MessageFormat.format(SYSTEMCLAUSEMISMATCHERROR, getTypename(), runsOnType.getTypename(), testcase.getAssignmentName(), temporalSystemType.getTypename()));
value.setIsErroneous(true);
}
} else {
if (temporalSystemType != null && systemType != null && !temporalSystemType.isCompatible(timestamp, systemType, null, null, null)) {
value.getLocation().reportSemanticError(MessageFormat.format(SYSTEMCLAUSEMISMATCHERROR, getTypename(), systemType.getTypename(), testcase.getAssignmentName(), temporalSystemType.getTypename()));
value.setIsErroneous(true);
}
}
if (valueCheckingOptions.sub_check) {
// there is no parent type to check
if (subType != null) {
subType.checkThisValue(timestamp, value);
}
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Component_Type in project titan.EclipsePlug-ins by eclipse.
the class ComponentTypeBody method generateCode.
/**
* Add generated java code on this level.
*
* @param aData only used to update imports if needed
* @param source the source code generated
*/
public void generateCode(final JavaGenData aData, final StringBuilder source) {
final StringBuilder init_comp = aData.getInitComp();
init_comp.append("if(\"").append(identifier.getDisplayName()).append("\".equals(component_type)) {\n");
if (extendsReferences != null) {
boolean hasBaseComponents = false;
for (final ComponentTypeBody cb : compatibleBodies) {
if (cb.definitions.size() > 0) {
if (!hasBaseComponents) {
init_comp.append("if(init_base_comps) {\n");
hasBaseComponents = true;
}
// TODO get_scope_mod_gen
if (getModuleScope().equals(cb.getModuleScope())) {
init_comp.append("init_comp_type(\"");
init_comp.append(cb.getIdentifier().getDisplayName());
init_comp.append("\", false);\n");
} else {
init_comp.append("//TODO implement Module_List");
init_comp.append("Module_List::initialize_component(\"");
init_comp.append(cb.getModuleScope().getIdentifier().getDisplayName());
init_comp.append("\", \"");
init_comp.append(cb.getIdentifier().getDisplayName());
init_comp.append("\", false);\n");
}
}
}
if (hasBaseComponents) {
init_comp.append("}\n");
}
}
for (final Definition def : definitions) {
if (extendsGainedDefinitions.containsKey(def.getIdentifier().getName())) {
def.generateCodeInitComp(aData, init_comp, extendsGainedDefinitions.get(def.getIdentifier().getName()));
} else {
def.generateCode(aData, true);
}
}
init_comp.append("return true;\n");
init_comp.append("} else ");
}
Aggregations