Commit b0985db9 authored by Farkas Ingrid's avatar Farkas Ingrid

added hasRawAttributes function

Signed-off-by: Farkas Ingrid's avatarFarkas Ingrid <farkas94ingi@gmail.com>
parent 996d919c
...@@ -576,6 +576,8 @@ public interface IType extends IGovernor, IIdentifierContainer, IVisitableNode, ...@@ -576,6 +576,8 @@ public interface IType extends IGovernor, IIdentifierContainer, IVisitableNode,
*/ */
boolean getFieldTypesAsArray(final Reference reference, final int actualSubReference, List<IType> typeArray); boolean getFieldTypesAsArray(final Reference reference, final int actualSubReference, List<IType> typeArray);
boolean hasRawAttributes(final CompilationTimeStamp timestamp);
/** /**
* Checks if there is a variant attribute among the ones reaching to * Checks if there is a variant attribute among the ones reaching to
* this type. * this type.
......
...@@ -529,6 +529,43 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda ...@@ -529,6 +529,43 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda
return 1; return 1;
} }
@Override
/** {@inheritDoc} */
public final boolean hasRawAttributes(final CompilationTimeStamp timestamp) {
if(rawAttribute != null) {
return true;
}
if (withAttributesPath == null) {
return false;
}
if (withAttributesPath.getHadGlobalVariants()) {
return true;
}
final List<SingleWithAttribute> realAttributes = withAttributesPath.getRealAttributes(timestamp);
for (int i = 0; i < realAttributes.size(); i++)
if (SingleWithAttribute.Attribute_Type.Variant_Attribute.equals(realAttributes.get(i).getAttributeType())) {
return true;
}
final MultipleWithAttributes localAttributes = withAttributesPath.getAttributes();
if (localAttributes == null) {
return false;
}
for(int i = 0; i < localAttributes.getNofElements(); i++) {
final SingleWithAttribute tempSingle = localAttributes.getAttribute(i);
if(Attribute_Type.Variant_Attribute.equals(tempSingle.getAttributeType()) && (tempSingle.getQualifiers() == null || tempSingle.getQualifiers().getNofQualifiers() == 0)) {
withAttributesPath.setHadGlobalVariants(true);
return true;
}
}
return false;
}
@Override @Override
/** {@inheritDoc} */ /** {@inheritDoc} */
public final boolean hasVariantAttributes(final CompilationTimeStamp timestamp) { public final boolean hasVariantAttributes(final CompilationTimeStamp timestamp) {
...@@ -536,6 +573,10 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda ...@@ -536,6 +573,10 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda
return false; return false;
} }
if (withAttributesPath.getHadGlobalVariants()) {
return true;
}
final List<SingleWithAttribute> realAttributes = withAttributesPath.getRealAttributes(timestamp); final List<SingleWithAttribute> realAttributes = withAttributesPath.getRealAttributes(timestamp);
for (int i = 0; i < realAttributes.size(); i++) { for (int i = 0; i < realAttributes.size(); i++) {
if (SingleWithAttribute.Attribute_Type.Variant_Attribute.equals(realAttributes.get(i).getAttributeType())) { if (SingleWithAttribute.Attribute_Type.Variant_Attribute.equals(realAttributes.get(i).getAttributeType())) {
...@@ -551,6 +592,7 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda ...@@ -551,6 +592,7 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda
for (int i = 0; i < localAttributes.getNofElements(); i++) { for (int i = 0; i < localAttributes.getNofElements(); i++) {
final SingleWithAttribute tempSingle = localAttributes.getAttribute(i); final SingleWithAttribute tempSingle = localAttributes.getAttribute(i);
if (Attribute_Type.Variant_Attribute.equals(tempSingle.getAttributeType())) { if (Attribute_Type.Variant_Attribute.equals(tempSingle.getAttributeType())) {
withAttributesPath.setHadGlobalVariants(true);
return true; return true;
} }
} }
...@@ -561,7 +603,7 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda ...@@ -561,7 +603,7 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda
@Override @Override
/** {@inheritDoc} */ /** {@inheritDoc} */
public void initAttributes(final CompilationTimeStamp timestamp) { public void initAttributes(final CompilationTimeStamp timestamp) {
// codingTable.clear(); // codingTable.clear();
hasDone = false; hasDone = false;
checkDoneAttribute(timestamp); checkDoneAttribute(timestamp);
...@@ -842,9 +884,9 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda ...@@ -842,9 +884,9 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda
final IType type = getTypeWithCodingTable(timestamp, false); final IType type = getTypeWithCodingTable(timestamp, false);
if (type == null) { if (type == null) {
//FIXME as only RAW is supported for now, we can not report this error //FIXME as only RAW is supported for now, we can not report this error
// if (!global) { // if (!global) {
// singleWithAttribute.getLocation().reportSemanticError(MessageFormat.format("No encoding rules defined for type `{0}''", getTypename())); // singleWithAttribute.getLocation().reportSemanticError(MessageFormat.format("No encoding rules defined for type `{0}''", getTypename()));
// } // }
} else { } else {
final List<String> codingStrings = singleWithAttribute.getAttributeSpecification().getEncodings(); final List<String> codingStrings = singleWithAttribute.getAttributeSpecification().getEncodings();
// gather the built-in codecs referred to by the variant's encoding strings // gather the built-in codecs referred to by the variant's encoding strings
......
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