use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Choice_Type method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
if (components != null && myScope != null) {
final Module module = myScope.getModuleScope();
if (module != null) {
if (module.getSkippedFromSemanticChecking()) {
return;
}
}
}
isErroneous = false;
if (components == null) {
parseBlockChoice();
}
if (isErroneous || components == null) {
return;
}
components.check(timestamp);
if (components.getNofComps() <= 0 && location != null) {
location.reportSemanticError(MISSINGALTERNATIVE);
setIsErroneous(true);
}
if (constraints != null) {
constraints.check(timestamp);
}
if (myScope != null) {
checkEncode(timestamp);
checkVariants(timestamp);
}
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class Undefined_Assignment method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
return;
}
if (null != myScope && null != lastTimeChecked) {
final Module module = myScope.getModuleScope();
if (null != module) {
if (module.getSkippedFromSemanticChecking()) {
lastTimeChecked = timestamp;
return;
}
}
}
lastTimeChecked = timestamp;
if (null != assPard) {
assPard.check(timestamp);
return;
}
classifyAssignment(timestamp, null);
if (null != realAssignment) {
realAssignment.check(timestamp);
}
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class Export_Debug_AST_Action method run.
@Override
public void run(IAction action) {
if (!(selection instanceof IStructuredSelection)) {
return;
}
IStructuredSelection structSelection = (IStructuredSelection) selection;
List<IProject> projects = new ArrayList<IProject>();
for (Object selected : structSelection.toList()) {
if (!(selected instanceof IProject)) {
continue;
}
projects.add((IProject) selected);
}
for (IProject project : projects) {
Shell shell = Display.getCurrent().getActiveShell();
FileDialog d = new FileDialog(shell, SWT.SAVE);
d.setText("Export debug information of the AST");
d.setFilterExtensions(new String[] { "*.zip" });
d.setFilterPath(project.getLocation().toOSString());
d.setFileName("Debug_AST.zip");
String zipFilename = d.open();
try {
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFilename));
ProjectSourceParser parser = GlobalParser.getProjectSourceParser(project);
Set<String> names = parser.getKnownModuleNames();
for (String name : names) {
Module module = parser.getModuleByName(name);
exportDebugAST(out, module);
}
out.close();
} catch (Exception e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class Parameterised_Reference method getRefDefdSimple.
/**
* Resolve the formal parameters of the referenced assignment with the
* help of the actual parameters. Instantiate a new assignment from it
* and return a reference to this assignment.
*
* @return the reference to the newly instantiated assignment.
*/
public Defined_Reference getRefDefdSimple() {
final Module module = myScope.getModuleScope();
// This is a little trick, but otherwise we would not have the
// true compilation timestamp
final CompilationTimeStamp compilationTimeStamp = module.getLastImportationCheckTimeStamp();
if (compilationTimeStamp == null) {
// compilationTimeStamp = CompilationTimeStamp.getNewCompilationCounter(); //this forces re-check
return null;
}
if (null != lastCheckTimeStamp && !lastCheckTimeStamp.isLess(compilationTimeStamp)) {
if (isErroneous) {
return null;
}
return finalReference;
}
lastCheckTimeStamp = compilationTimeStamp;
final Assignment parass = assignmentReference.getRefdAssignment(compilationTimeStamp, true, null);
if (null == parass) {
isErroneous = true;
return null;
} else if (!(parass instanceof ASN1Assignment)) {
assignmentReference.getLocation().reportSemanticError(ASSIGNMENTEXPECTED);
isErroneous = true;
return null;
}
final Ass_pard assPard = ((ASN1Assignment) parass).getAssPard();
if (null == assPard) {
assignmentReference.getLocation().reportSemanticError(PARAMETERISEDASSIGNMENTEXPECTED);
isErroneous = true;
return assignmentReference;
}
addAssignments(assPard, compilationTimeStamp);
// Add the assignments made from the formal and actual
// parameters to the actual module
assignments.setRightScope(myScope);
assignments.setParentScope(parass.getMyScope());
assignments.setFullNameParent(this);
assignments.check(compilationTimeStamp);
// create a copy of the assignment and add it to the actual
// module
final ASN1Assignment newAssignment = ((ASN1Assignment) parass).newInstance(module);
newAssignmentNameStart = new NameReStarter(new StringBuilder(module.getFullName()).append(INamedNode.DOT).append(newAssignment.getIdentifier().getDisplayName()).toString());
newAssignmentNameStart.setFullNameParent(parass);
newAssignment.setFullNameParent(newAssignmentNameStart);
newAssignment.setLocation(location);
newAssignment.getIdentifier().setLocation(assignmentReference.getLocation());
((ASN1Assignments) module.getAssignments()).addDynamicAssignment(compilationTimeStamp, newAssignment);
newAssignment.setMyScope(assignments);
newAssignment.check(compilationTimeStamp);
final List<ISubReference> subreferences = new ArrayList<ISubReference>(1);
subreferences.add(new FieldSubReference(newAssignment.getIdentifier()));
finalReference = new Defined_Reference(module.getIdentifier(), subreferences);
finalReference.setFullNameParent(this);
finalReference.setMyScope(module);
return finalReference;
}
use of org.eclipse.titan.designer.AST.Module in project titan.EclipsePlug-ins by eclipse.
the class Port_Utility method checkFromClause.
/**
* Checks a from clause reference and a sender redirect to see if they
* really references valid component types.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param source
* the source statement to report errors to.
* @param portType
* the type of the port used in the statement. Used to
* find the address type in effect.
* @param fromClause
* the from clause to check
* @param redirectSender
* the sender redirect to check.
*/
public static void checkFromClause(final CompilationTimeStamp timestamp, final Statement source, final Port_Type portType, final TemplateInstance fromClause, final Reference redirectSender) {
IType addressType = null;
if (portType != null) {
addressType = portType.getPortBody().getAddressType(timestamp);
} else if (source != null && source.getMyStatementBlock() != null) {
final Module module = source.getMyStatementBlock().getModuleScope();
if (module != null && module_type.TTCN3_MODULE.equals(module.getModuletype())) {
addressType = ((TTCN3Module) module).getAddressType(timestamp);
}
}
boolean senderRedirectChecked = false;
IType fromClauseType = null;
if (fromClause != null) {
fromClauseType = fromClause.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
ITTCN3Template templateBody = fromClause.getTemplateBody();
if (fromClauseType == null) {
if (addressType != null) {
templateBody = addressType.checkThisTemplateRef(timestamp, templateBody);
} else {
templateBody = templateBody.setLoweridToReference(timestamp);
}
fromClauseType = templateBody.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
}
if (fromClauseType == null) {
fromClauseType = checkSenderRedirect(timestamp, addressType, redirectSender);
senderRedirectChecked = true;
}
if (fromClauseType == null) {
// trying to figure out whether the template is
// a component reference or an SUT address
boolean isComponentReference;
if (Type_type.TYPE_COMPONENT.equals(templateBody.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_TEMPLATE))) {
isComponentReference = true;
} else {
switch(templateBody.getTemplatetype()) {
case SPECIFIC_VALUE:
// treat 'null' as component
// reference
isComponentReference = Value_type.TTCN3_NULL_VALUE.equals(((SpecificValue_Template) templateBody).getSpecificValue().getValuetype());
break;
case ANY_VALUE:
case ANY_OR_OMIT:
isComponentReference = true;
break;
default:
isComponentReference = false;
break;
}
}
if (isComponentReference) {
// the argument is a component
// reference: get a pool type
fromClauseType = TypeFactory.createType(Type_type.TYPE_COMPONENT);
} else if (addressType != null) {
// the argument is not a component
// reference: try the address type
fromClauseType = addressType;
}
}
if (fromClauseType != null) {
fromClause.check(timestamp, fromClauseType);
if (addressType == null || !addressType.isCompatible(timestamp, fromClauseType, null, null, null)) {
// from_clause_type must be a component
// type
final IType last = fromClauseType.getTypeRefdLast(timestamp);
if (last.getIsErroneous(timestamp)) {
fromClauseType = null;
} else if (Type_type.TYPE_COMPONENT.equals(last.getTypetype())) {
if (Template_type.SPECIFIC_VALUE.equals(templateBody.getTemplatetype())) {
checkComponentReference(timestamp, source, ((SpecificValue_Template) templateBody).getSpecificValue(), true, true);
}
} else {
final String message = MessageFormat.format("The type of the template should be a component type {0} instead of `{1}''", (addressType == null) ? "" : "or the `address' type ", fromClauseType.getTypename());
fromClause.getLocation().reportSemanticError(message);
fromClauseType = null;
}
}
} else {
fromClause.getLocation().reportSemanticError("Cannot determine the type of the template");
}
}
if (!senderRedirectChecked) {
final IType senderRedirectType = checkSenderRedirect(timestamp, addressType, redirectSender);
if (fromClauseType != null && senderRedirectType != null && !fromClauseType.isIdentical(timestamp, senderRedirectType)) {
final String message = MessageFormat.format("The types in `from'' clause and `sender'' redirect are not the same: `{0}'' was expected instead of `{1}''", fromClauseType.getTypename(), senderRedirectType.getTypename());
senderRedirectType.getLocation().reportSemanticError(message);
}
}
}
Aggregations