use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class Export_Debug_AST method run.
@Override
public void run(IAction action) {
if (targetEditor == null)
return;
IFile file = (IFile) targetEditor.getEditorInput().getAdapter(IFile.class);
ProjectSourceParser parser = GlobalParser.getProjectSourceParser(file.getProject());
Module module = parser.containedModule(file);
if (module == null) {
TITANDebugConsole.getConsole().newMessageStream().println("No module was found");
}
TITANDebugConsole.getConsole().newMessageStream().println("*************************");
TITANDebugConsole.getConsole().newMessageStream().println("Printing DEBUG information for module `" + module.getName() + "':");
TITANDebugConsole.getConsole().newMessageStream().println("*************************");
module.accept(new ASTVisitor() {
private int padding = 0;
@Override
public int visit(IVisitableNode node) {
if (node instanceof Assignment) {
Assignment assignment = (Assignment) node;
printInfoln(padding, assignment.getAssignmentName(), assignment.getFullName(), assignment.getLastTimeChecked(), assignment.getLocation());
} else if (node instanceof Identifier) {
printInfoln(padding, "identifier", ((Identifier) node).getDisplayName(), null, ((Identifier) node).getLocation());
} else if (node instanceof Statement) {
Statement statement = (Statement) node;
printInfoln(padding, "statement", statement.getFullName(), statement.getLastTimeChecked(), statement.getLocation());
} else if (node instanceof Reference) {
Reference ref = (Reference) node;
printInfoln(padding, "reference", ref.getFullName(), ref.getLastTimeChecked(), ref.getLocation());
Assignment old = ref.getAssOld();
if (old != null) {
printInfoln(padding + 1, "This reference was last pointing to " + old.getFullName() + " analyzed at " + old.getLastTimeChecked());
}
} else if (node instanceof ComponentTypeBody) {
ComponentTypeBody body = (ComponentTypeBody) node;
Map<String, Definition> map = body.getDefinitionMap();
printInfoln(padding + 1, " contains definitions:");
for (Map.Entry<String, Definition> entry : map.entrySet()) {
printInfoln(padding + 2, entry.getKey() + " was last checked at " + entry.getValue().getLastTimeChecked());
}
}
if (node instanceof StatementBlock || node instanceof Definition) {
padding++;
}
return super.visit(node);
}
@Override
public int leave(IVisitableNode node) {
if (node instanceof StatementBlock || node instanceof Definition) {
padding--;
}
return super.leave(node);
}
});
TITANDebugConsole.getConsole().newMessageStream().println("*************************");
TITANDebugConsole.getConsole().newMessageStream().println("Printing DEBUG information for module `" + module.getName() + "' finished");
TITANDebugConsole.getConsole().newMessageStream().println("*************************");
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class Start_Component_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
final Component_Type componentType = Port_Utility.checkComponentReference(timestamp, this, componentReference, false, false);
final Assignment assignment = functionInstanceReference.getRefdAssignment(timestamp, true);
if (assignment == null) {
return;
}
switch(assignment.getAssignmentType()) {
case A_FUNCTION:
case A_FUNCTION_RTEMP:
case A_FUNCTION_RVAL:
break;
default:
functionInstanceReference.getLocation().reportSemanticError(MessageFormat.format(REFERENCETOFUNCTIONWASEXPECTED, assignment.getDescription()));
return;
}
final Def_Function function = (Def_Function) assignment;
if (!function.checkStartable(timestamp, getLocation())) {
return;
}
final IType runsOnType = function.getRunsOnType(timestamp);
if (componentType == null || runsOnType == null) {
return;
}
if (!runsOnType.isCompatible(timestamp, componentType, null, null, null)) {
componentReference.getLocation().reportSemanticError(MessageFormat.format(COMPONENTTYPEMISMATCH, componentType.getTypename(), function.getDescription(), runsOnType.getTypename()));
}
switch(function.getAssignmentType()) {
case A_FUNCTION_RTEMP:
functionInstanceReference.getLocation().reportSemanticWarning(MessageFormat.format(TEMPLATERETURN, function.getFullName(), function.getType(timestamp).getTypename()));
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 message = MessageFormat.format(RETURNWITHOUTDONE, function.getDescription(), function.getType(timestamp).getTypename());
functionInstanceReference.getLocation().reportSemanticWarning(message);
}
break;
}
default:
break;
}
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class Parameter_Redirect method checkVariableReference.
/**
* Check whether the reference points to a variable of the provided
* type.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param reference
* the reference to check
* @param type
* the type the parameter is expected to have.
*/
public final void checkVariableReference(final CompilationTimeStamp timestamp, final Reference reference, final IType type) {
if (reference == null) {
return;
}
final IType variableType = reference.checkVariableReference(timestamp);
if (type != null && variableType != null && !type.isIdentical(timestamp, variableType)) {
final String message = MessageFormat.format("Type mismatch in parameter redirect: A variable of type `{0}'' was expected instead of `{1}''", type.getTypename(), variableType.getTypename());
reference.getLocation().reportSemanticError(message);
return;
}
final Assignment assignment = reference.getRefdAssignment(timestamp, true);
if (assignment != null) {
switch(assignment.getAssignmentType()) {
case A_PAR_VAL:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
((FormalParameter) assignment).setWritten();
break;
case A_VAR:
((Def_Var) assignment).setWritten();
break;
case A_PAR_TEMP_OUT:
case A_PAR_TEMP_INOUT:
((FormalParameter) assignment).setWritten();
break;
case A_VAR_TEMPLATE:
((Def_Var_Template) assignment).setWritten();
break;
default:
break;
}
}
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class Port_Utility method checkPortReference.
/**
* Checks a port reference.
* Statement independent version.
*
* @param timestamp
* the timestamp of the actual build cycle.
* @param portReference
* the port reference to be checked
*
* @return the port type of the reference if it is a correct port
* reference, or null otherwise
*/
public static Port_Type checkPortReference(final CompilationTimeStamp timestamp, final Reference portReference) {
if (portReference == null) {
return null;
}
final Assignment assignment = portReference.getRefdAssignment(timestamp, true);
if (assignment == null || assignment.getIsErroneous()) {
return null;
}
IType result = null;
switch(assignment.getAssignmentType()) {
case A_PORT:
final ArrayDimensions dimensions = ((Def_Port) assignment).getDimensions();
if (dimensions != null) {
dimensions.checkIndices(timestamp, portReference, "port", false, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
} else if (portReference.getSubreferences().size() > 1) {
portReference.getLocation().reportSemanticError(MessageFormat.format("Reference to single {0} cannot have field or array sub-references", assignment.getDescription()));
}
result = ((Def_Port) assignment).getType(timestamp);
break;
case A_PAR_PORT:
if (portReference.getSubreferences().size() > 1) {
portReference.getLocation().reportSemanticError(MessageFormat.format("Reference to {0} cannot have field or array sub-references", assignment.getDescription()));
}
result = ((FormalParameter) assignment).getType(timestamp);
break;
default:
portReference.getLocation().reportSemanticError(MessageFormat.format(PORTREFERENCEEXPECTED, assignment.getAssignmentName()));
break;
}
if (result == null) {
return null;
}
result = result.getTypeRefdLast(timestamp);
if (Type_type.TYPE_PORT.equals(result.getTypetype())) {
return (Port_Type) result;
}
return null;
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class Port_Utility method checkValueRedirect.
/**
* Calculates the type of a variable when it was to be used as a value
* redirect target.
*
* @param timestamp
* the timestamp of the actual build cycle.
* @param redirectValue
* the reference to which the redirection is targeted
* @param type
* the expected type of the value redirection.
*
* @return the the type of a variable referenced when it was to be used
* as a value redirection target.
*/
public static IType checkValueRedirect(final CompilationTimeStamp timestamp, final Reference redirectValue, final IType type) {
if (redirectValue == null) {
return null;
}
final IType variableType = redirectValue.checkVariableReference(timestamp);
if (type != null && variableType != null && !type.isCompatible(timestamp, variableType, null, null, null)) {
redirectValue.getLocation().reportSemanticError(MessageFormat.format(VALUEREDIRECTTYPEMISSMATCH, type.getTypename(), variableType.getTypename()));
}
final Assignment assignment = redirectValue.getRefdAssignment(timestamp, true);
if (assignment != null) {
switch(assignment.getAssignmentType()) {
case A_PAR_VAL:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
((FormalParameter) assignment).setWritten();
break;
case A_VAR:
((Def_Var) assignment).setWritten();
break;
case A_PAR_TEMP_OUT:
case A_PAR_TEMP_INOUT:
((FormalParameter) assignment).setWritten();
break;
case A_VAR_TEMPLATE:
((Def_Var_Template) assignment).setWritten();
break;
default:
break;
}
}
return variableType;
}
Aggregations