Commit ecd8d028 authored by Miklos Magyari's avatar Miklos Magyari
Browse files

OOP: improvements for 'value' support in properties


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 45f80db8
......@@ -79,7 +79,8 @@ public class Reference extends ASTNode implements ILocateableNode, IIncrementall
public enum Ref_Type {
REF_BASIC,
REF_THIS,
REF_SUPER
REF_SUPER,
REF_VALUE
}
/**
......
......@@ -6,19 +6,13 @@
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
******************************************************************************/
/**
* property type (TTCN-3 OOP extension)
*
* @author Miklos Magyari
*/
package org.eclipse.titan.designer.AST.TTCN3.types;
import org.eclipse.titan.designer.AST.Assignment;
import org.eclipse.titan.designer.AST.IReferenceChain;
import org.eclipse.titan.designer.AST.IType;
import org.eclipse.titan.designer.AST.ITypeWithComponents;
import org.eclipse.titan.designer.AST.Identifier;
import org.eclipse.titan.designer.AST.Reference;
import org.eclipse.titan.designer.AST.Scope;
import org.eclipse.titan.designer.AST.Type;
import org.eclipse.titan.designer.AST.TypeCompatibilityInfo;
import org.eclipse.titan.designer.AST.TypeCompatibilityInfo.Chain;
......@@ -74,10 +68,10 @@ public final class Property_Type extends Type {
/** {@inheritDoc} */
public void check(final CompilationTimeStamp timestamp) {
if (getStatementBlock != null) {
// getStatementBlock.check(timestamp);
getStatementBlock.check(timestamp);
}
if (setStatementBlock != null) {
// setStatementBlock.check(timestamp);
setStatementBlock.check(timestamp);
}
}
......@@ -90,6 +84,23 @@ public final class Property_Type extends Type {
public String getTypename() {
return "property";
}
@Override
public Type_type getTypetypeTtcn3() {
return myType.getTypetype();
}
@Override
/** {@inheritDoc} */
public void setMyScope(final Scope scope) {
super.setMyScope(scope);
if (getStatementBlock != null) {
getStatementBlock.setMyScope(scope);
}
if (setStatementBlock != null) {
setStatementBlock.setMyScope(scope);
}
}
@Override
public String getOutlineIcon() {
......@@ -100,8 +111,7 @@ public final class Property_Type extends Type {
@Override
public IType getFieldType(CompilationTimeStamp timestamp, Reference reference, int actualSubReference,
Expected_Value_type expectedIndex, IReferenceChain refChain, boolean interruptIfOptional) {
// TODO Auto-generated method stub
return null;
return myType;
}
@Override
......@@ -118,12 +128,6 @@ public final class Property_Type extends Type {
return false;
}
@Override
public Type_type getTypetypeTtcn3() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean generatesOwnClass(JavaGenData aData, StringBuilder source) {
// TODO Auto-generated method stub
......
......@@ -6287,7 +6287,10 @@ pr_Value returns[Value value]
}:
( v1 = pr_PredefinedValue { $value = $v1.value; }
| v2 = pr_ReferencedValue { $value = $v2.value; }
| VALUE { $value = null; }
| VALUE {
Reference valueRef = new Reference(null, Reference.Ref_Type.REF_VALUE);
$value = new Referenced_Value(valueRef);
}
);
pr_PredefinedValue returns [Value value]
......@@ -6468,10 +6471,12 @@ pr_ValueReference returns[Reference reference]
$reference = null;
boolean isThisRef = false;
boolean isSuperRef = false;
boolean isValueRef = false;
}:
( ( ( r = pr_GlobalModuleId { $reference = $r.reference; }
| THIS { isThisRef = true; }
| SUPER { isSuperRef = true; }
| VALUE { isValueRef = true; }
)
pr_Dot
)?
......@@ -6482,6 +6487,9 @@ pr_ValueReference returns[Reference reference]
if (isSuperRef == true) {
$reference = new Reference(null, Reference.Ref_Type.REF_SUPER);
}
if (isValueRef == true) {
$reference = new Reference(null, Reference.Ref_Type.REF_VALUE);
}
if ( $id.identifier != null ) {
if ( $reference == null ) {
$reference = new Reference(null);
......@@ -9432,7 +9440,7 @@ pr_PropertyGetter returns[StatementBlock statementblock]:
(
CLASSCASTING
pr_TemplateBody
| sb = pr_StatementBlock { $statementblock = $sb.statementblock; }
| sb = pr_StatementBlock { $statementblock = $sb.statementblock; $statementblock.setLocation(getLocation($sb.start, $sb.stop)); }
)
)?
SEMICOLON?
......@@ -9447,7 +9455,7 @@ pr_PropertySetter returns[StatementBlock statementblock]:
(
( CLASSCASTING
pr_TemplateBody
| sb = pr_StatementBlock { $statementblock = $sb.statementblock; }
| sb = pr_StatementBlock { $statementblock = $sb.statementblock; $statementblock.setLocation(getLocation($sb.start, $sb.stop)); }
)
)?
SEMICOLON?
......
......@@ -65,9 +65,9 @@ public class Syntactical_errors_tests {
//ReturnValueTest.ttcn
ArrayList<MarkerToCheck> markersToCheck = new ArrayList<MarkerToCheck>(5);
int lineNum = 37;
markersToCheck.add(new MarkerToCheck("mismatched input '..' expecting {'action', 'activate', 'all', 'alt', 'and', 'and4b', 'any', 'break', 'connect', 'const', 'continue', 'deactivate', 'disconnect', 'do', 'execute', 'for', 'goto', 'if', 'ifpresent', 'interleave', 'kill', 'label', 'length', 'log', 'map', 'mod', 'mtc', 'or', 'or4b', 'port', 'rem', 'repeat', 'return', 'select', 'self', 'setverdict', 'stop', 'super', 'template', 'testcase', 'this', 'timer', 'unmap', 'var', 'while', 'xor', 'xor4b', 'int2enum', 'string2ttcn', IDENTIFIER, '@try', '@update', ';', '{', '}', '<', '>', '!=', '>=', '<=', '==', '+', '-', '*', '/', '<<', '>>', '<@', '@>', '&'}", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("mismatched input '..' expecting {'action', 'activate', 'all', 'alt', 'and', 'and4b', 'any', 'break', 'connect', 'const', 'continue', 'deactivate', 'disconnect', 'do', 'execute', 'for', 'goto', 'if', 'ifpresent', 'interleave', 'kill', 'label', 'length', 'log', 'map', 'mod', 'mtc', 'or', 'or4b', 'port', 'rem', 'repeat', 'return', 'select', 'self', 'setverdict', 'stop', 'super', 'template', 'testcase', 'this', 'timer', 'unmap', 'value', 'var', 'while', 'xor', 'xor4b', 'int2enum', 'string2ttcn', IDENTIFIER, '@try', '@update', ';', '{', '}', '<', '>', '!=', '>=', '<=', '==', '+', '-', '*', '/', '<<', '>>', '<@', '@>', '&'}", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 39;
markersToCheck.add(new MarkerToCheck("mismatched input '..' expecting {'action', 'activate', 'all', 'alt', 'and', 'and4b', 'any', 'break', 'connect', 'const', 'continue', 'deactivate', 'disconnect', 'do', 'execute', 'for', 'goto', 'if', 'ifpresent', 'interleave', 'kill', 'label', 'length', 'log', 'map', 'mod', 'mtc', 'or', 'or4b', 'port', 'rem', 'repeat', 'return', 'select', 'self', 'setverdict', 'stop', 'super', 'template', 'testcase', 'this', 'timer', 'unmap', 'var', 'while', 'xor', 'xor4b', 'int2enum', 'string2ttcn', IDENTIFIER, '@try', '@update', ';', '{', '}', '<', '>', '!=', '>=', '<=', '==', '+', '-', '*', '/', '<<', '>>', '<@', '@>', '&'}", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("mismatched input '..' expecting {'action', 'activate', 'all', 'alt', 'and', 'and4b', 'any', 'break', 'connect', 'const', 'continue', 'deactivate', 'disconnect', 'do', 'execute', 'for', 'goto', 'if', 'ifpresent', 'interleave', 'kill', 'label', 'length', 'log', 'map', 'mod', 'mtc', 'or', 'or4b', 'port', 'rem', 'repeat', 'return', 'select', 'self', 'setverdict', 'stop', 'super', 'template', 'testcase', 'this', 'timer', 'unmap', 'value', 'var', 'while', 'xor', 'xor4b', 'int2enum', 'string2ttcn', IDENTIFIER, '@try', '@update', ';', '{', '}', '<', '>', '!=', '>=', '<=', '==', '+', '-', '*', '/', '<<', '>>', '<@', '@>', '&'}", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 9;
markersToCheck.add(new MarkerToCheck("mismatched input '..' expecting {'and', 'and4b', 'ifpresent', 'length', 'mod', 'or', 'or4b', 'rem', 'xor', 'xor4b', ',', ')', '<', '>', '!=', '>=', '<=', '==', '+', '-', '*', '/', '<<', '>>', '<@', '@>', '&'}", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 145;
......
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