Commit 65e6d53a authored by Miklos Magyari's avatar Miklos Magyari Committed by Adam Knapp
Browse files

OOP: setting properties' definition


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent ac7bcd4c
......@@ -129,33 +129,7 @@ public final class Return_Statement extends Statement {
location.reportSemanticError(RETURNINDESTRUCTOR);
return;
}
if (definition == null) {
if (getMyScope() instanceof StatementBlock) {
final StatementBlock block = (StatementBlock)getMyScope();
if (block.ownerIsProperty() == true) {
if (block.isPropertyGetter()) {
final INamedNode node = block.getNameParent();
if (node instanceof Property_Type) {
final Property_Type property = (Property_Type)node;
if (template == null) {
final IType propType = property.getFieldType(timestamp, null, 0, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
location.reportSemanticError(MessageFormat.format(MISSINGTEMPLATE, propType.getTypename()));
} else {
final Type_type templateType = template.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (templateType != property.getTypetypeTtcn3()) {
final IType propType = property.getFieldType(timestamp, null, 0, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
location.reportSemanticError(MessageFormat.format(RETURNTYPEEXPECTED, propType.getTypename()));
}
}
return;
}
}
if (block.isPropertySetter()) {
location.reportSemanticError(INVALIDSETTERRETURN);
return;
}
}
}
if (definition == null) {
location.reportSemanticError(USAGEINCONTROLPART);
return;
}
......@@ -209,6 +183,34 @@ public final class Return_Statement extends Statement {
template.getLocation().reportSemanticError(ALTSTEPRETURNINGVALUE);
}
break;
case A_VAR:
if (getMyScope() instanceof StatementBlock) {
final StatementBlock block = (StatementBlock)getMyScope();
if (block.ownerIsProperty() == true) {
if (block.isPropertyGetter()) {
final INamedNode node = block.getNameParent();
if (node instanceof Property_Type) {
final Property_Type property = (Property_Type)node;
if (template == null) {
final IType propType = property.getFieldType(timestamp, null, 0, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
location.reportSemanticError(MessageFormat.format(MISSINGTEMPLATE, propType.getTypename()));
} else {
final Type_type templateType = template.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (templateType != property.getTypetypeTtcn3()) {
final IType propType = property.getFieldType(timestamp, null, 0, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
location.reportSemanticError(MessageFormat.format(RETURNTYPEEXPECTED, propType.getTypename()));
}
}
return;
}
}
if (block.isPropertySetter()) {
location.reportSemanticError(INVALIDSETTERRETURN);
return;
}
}
}
break;
default:
location.reportSemanticError(MessageFormat.format(UNEXPETEDRETURNSTATEMENT, definition.getAssignmentName()));
break;
......
......@@ -26,6 +26,7 @@ import org.eclipse.titan.designer.AST.Type;
import org.eclipse.titan.designer.AST.TypeCompatibilityInfo;
import org.eclipse.titan.designer.AST.TypeCompatibilityInfo.Chain;
import org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type;
import org.eclipse.titan.designer.AST.TTCN3.definitions.Definition;
import org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter;
import org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList;
import org.eclipse.titan.designer.AST.TTCN3.definitions.VisibilityModifier;
......@@ -373,4 +374,16 @@ public final class Property_Type extends Type {
return null;
}
/** Sets the definition of the getter/setter statement blocks. It should point to a Def_Var instance.
*
* @param definition
*/
public void setDefinitions(Definition definition ) {
if (getterStatementBlock != null) {
getterStatementBlock.setMyDefinition(definition);
}
if (setterStatementBlock != null) {
setterStatementBlock.setMyDefinition(definition);
}
}
}
......@@ -4626,6 +4626,9 @@ pr_SingleVarInstance[Type type, parameterEvaluationType eval, boolean isAbstract
}
$definition = new Def_Var( $i.identifier, type2, value, $eval );
$definition.setLocation(getLocation( $start, getLastVisibleToken()));
if (isProperty) {
((Property_Type)type2).setDefinitions($definition);
}
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment