Explorar o código

HPCC-9471 Change the parameter to queryAttribute to an enum

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday %!s(int64=12) %!d(string=hai) anos
pai
achega
efafbb19e4

+ 9 - 36
ecl/hql/hqlatoms.cpp

@@ -79,13 +79,6 @@ IAtom * asciiAtom;
 IAtom * assertAtom;
 IAtom * assertConstAtom;
 IAtom * atmostAtom;
-IAtom * _attrAligned_Atom;
-IAtom * _attrDiskSerializedForm_Atom;
-IAtom * _attrInternalSerializedForm_Atom;
-IAtom * _attrLocationIndependent_Atom;
-IAtom * _attrRecordCount_Atom;
-IAtom * _attrSize_Atom;
-IAtom * _attrUnadorned_Atom;
 IAtom * aveAtom;
 IAtom * backupAtom;
 IAtom * bcdAtom;
@@ -304,6 +297,10 @@ IAtom * prefetchAtom;
 IAtom * preloadAtom;
 IAtom * priorityAtom;
 IAtom * privateAtom;
+IAtom * _propAligned_Atom;
+IAtom * _propRecordCount_Atom;
+IAtom * _propSize_Atom;
+IAtom * _propUnadorned_Atom;
 IAtom * pseudoentrypointAtom;
 IAtom * pullAtom;
 IAtom * pulledAtom;
@@ -418,23 +415,7 @@ IAtom * xpathAtom;
 #define MAKEID(x)   x##Id = createIdAtom(#x)
 #define MAKEATOM(x) x##Atom = createLowerCaseAtom(#x)
 
-SysAtom::SysAtom(const void * k) : Atom(k) 
-{ 
-    attrId = EAnone; 
-}
-
-class SysAtomTable : public KeptHashTableOf<SysAtom, 0U>
-{
-  public:
-    SysAtomTable() : KeptHashTableOf<SysAtom, 0U>(false) {};
-    SysAtomTable(bool _nocase) : KeptHashTableOf<SysAtom, 0U>(_nocase) {};
-};
-SysAtomTable * sysAtomTable;
-
-IAtom * createSystemAtom(const char * s) { return sysAtomTable->create(s); }
-
-#define MAKESYSATOM(x)  _##x##_Atom = createSystemAtom("$_" #x "_")
-#define MAKESYSATOMX(x)  static_cast<SysAtom *>(_##x##_Atom = createSystemAtom("$_" #x "_"))
+#define MAKESYSATOM(x)  _##x##_Atom = createLowerCaseAtom("$_" #x "_")
 
 MODULE_INIT(INIT_PRIORITY_HQLATOM)
 {
@@ -480,7 +461,6 @@ MODULE_INIT(INIT_PRIORITY_HQLATOM)
     unnamedId = createIdAtom("<unnamed>");
     MAKEID(value);
 
-    sysAtomTable = new SysAtomTable;
     MAKEATOM(abstract);
     MAKEATOM(access);
     MAKEATOM(action);
@@ -501,13 +481,6 @@ MODULE_INIT(INIT_PRIORITY_HQLATOM)
     MAKEATOM(assert);
     MAKEATOM(assertConst);
     MAKEATOM(atmost);
-    MAKESYSATOMX(attrAligned)->setAttrId(EAaligned);
-    MAKESYSATOMX(attrLocationIndependent)->setAttrId(EAlocationIndependent);
-    MAKESYSATOMX(attrRecordCount)->setAttrId(EArecordCount);
-    MAKESYSATOMX(attrDiskSerializedForm)->setAttrId(EAdiskserializedForm);
-    MAKESYSATOMX(attrInternalSerializedForm)->setAttrId(EAinternalserializedForm);
-    MAKESYSATOMX(attrSize)->setAttrId(EAsize);
-    MAKESYSATOMX(attrUnadorned)->setAttrId(EAunadorned);
     MAKEATOM(ave);
     MAKEATOM(backup);
     MAKEATOM(bcd);
@@ -727,6 +700,10 @@ MODULE_INIT(INIT_PRIORITY_HQLATOM)
     MAKEATOM(preload);
     MAKEATOM(priority);
     MAKEATOM(private);
+    MAKESYSATOM(propAligned);
+    MAKESYSATOM(propRecordCount);
+    MAKESYSATOM(propSize);
+    MAKESYSATOM(propUnadorned);
     MAKEATOM(prototype);
     MAKEATOM(proxyAddress);
     MAKEATOM(pseudoentrypoint);
@@ -839,7 +816,3 @@ MODULE_INIT(INIT_PRIORITY_HQLATOM)
 
     return true;
 }
-MODULE_EXIT()
-{
-    delete sysAtomTable;
-}

+ 4 - 37
ecl/hql/hqlatoms.hpp

@@ -81,13 +81,6 @@ extern HQL_API IAtom * asciiAtom;
 extern HQL_API IAtom * assertAtom;
 extern HQL_API IAtom * assertConstAtom;
 extern HQL_API IAtom * atmostAtom;
-extern HQL_API IAtom * _attrAligned_Atom;
-extern HQL_API IAtom * _attrDiskSerializedForm_Atom;
-extern HQL_API IAtom * _attrInternalSerializedForm_Atom;
-extern HQL_API IAtom * _attrLocationIndependent_Atom;
-extern HQL_API IAtom * _attrRecordCount_Atom;
-extern HQL_API IAtom * _attrSize_Atom;
-extern HQL_API IAtom * _attrUnadorned_Atom;
 extern HQL_API IAtom * aveAtom;
 extern HQL_API IAtom * backupAtom;
 extern HQL_API IAtom * bcdAtom;
@@ -308,6 +301,10 @@ extern HQL_API IAtom * prefetchAtom;
 extern HQL_API IAtom * preloadAtom;
 extern HQL_API IAtom * priorityAtom;
 extern HQL_API IAtom * privateAtom;
+extern HQL_API IAtom * _propAligned_Atom;
+extern HQL_API IAtom * _propRecordCount_Atom;
+extern HQL_API IAtom * _propSize_Atom;
+extern HQL_API IAtom * _propUnadorned_Atom;
 extern HQL_API IAtom * pseudoentrypointAtom;
 extern HQL_API IAtom * pullAtom;
 extern HQL_API IAtom * pulledAtom;
@@ -421,36 +418,6 @@ extern HQL_API IAtom * xpathAtom;
 
 inline bool isInternalAttributeName(IAtom * name) { return (name->str()[0] == '$'); }
 
-//Information which is associated with system attributes.
-enum
-{
-    EAnone,
-    EArecordCount,
-    EAdiskserializedForm,
-    EAinternalserializedForm,
-    EAsize,
-    EAaligned,
-    EAunadorned,
-    EAlocationIndependent,
-    EAmax
-};
-
-//Use a different class implementation for system attributes, so I can associate extra internal information with them
-//e.g., an efficient way of mapping from an internal id to an attribute enumeration, so the switch statements are efficient
-class HQL_API SysAtom : public Atom
-{
-public:
-    SysAtom(const void * k);
-
-    inline SysAtom & setAttrId(byte _attrId) { attrId = _attrId; return *this; }
-public:
-    byte attrId;
-};
-
-extern HQL_API IAtom * createSystemAtom(const char * s);
-
-inline byte getAttributeId(IAtom * x) { return static_cast<SysAtom *>(x)->attrId; }
-
 /*
  * This is part of an experiment to make identifiers in the language case sensitive - at least optionally, possibly only for syntax checking.
  * It would require

+ 79 - 83
ecl/hql/hqlattr.cpp

@@ -771,15 +771,15 @@ static IHqlExpression * querySerializedForm(IHqlExpression * expr, IAtom * varia
 {
     if (expr)
     {
-        IAtom * attrName;
+        ExprPropKind kind;
         if (variation == diskAtom)
-            attrName = _attrDiskSerializedForm_Atom;
+            kind = EPdiskserializedForm;
         else if (variation == internalAtom)
-            attrName = _attrInternalSerializedForm_Atom;
+            kind = EPinternalserializedForm;
         else
             throwUnexpected();
 
-        IHqlExpression * attr = expr->queryAttribute(attrName);
+        IHqlExpression * attr = expr->queryAttribute(kind);
         if (attr)
             return attr;
     }
@@ -831,22 +831,22 @@ static IHqlExpression * evaluateSerializedRecord(IHqlExpression * expr, IAtom *
 class CHqlExprMeta
 {
 public:
-    static inline IHqlExpression * addAttribute(IHqlExpression * expr, IAtom * name, IHqlExpression * value)
+    static inline IHqlExpression * addAttribute(IHqlExpression * expr, ExprPropKind kind, IHqlExpression * value)
     {
         CHqlExpression * cexpr = static_cast<CHqlExpression *>(expr);
-        cexpr->addAttribute(name, value);
+        cexpr->addAttribute(kind, value);
         return value;
     }
-    static inline IHqlExpression * queryExistingAttribute(IHqlExpression * expr, IAtom * name)
+    static inline IHqlExpression * queryExistingAttribute(IHqlExpression * expr, ExprPropKind kind)
     {
         CHqlExpression * cexpr = static_cast<CHqlExpression *>(expr);
-        return cexpr->queryExistingAttribute(name);
+        return cexpr->queryExistingAttribute(kind);
     }
 } meta;
 
 //-- Attribute: serialized form -------------------------------------------------------------------------------
 
-static IHqlExpression * evaluateAttrSerializedForm(IHqlExpression * expr, IAtom * attr, IAtom * variation)
+static IHqlExpression * evaluateAttrSerializedForm(IHqlExpression * expr, ExprPropKind kind, IAtom * variation)
 {
     if (expr->getOperator() == no_record || expr->getOperator() == no_field)
     {
@@ -854,9 +854,9 @@ static IHqlExpression * evaluateAttrSerializedForm(IHqlExpression * expr, IAtom
         if (serialized != expr)
         {
             //Tag serialized form so don't re-evaluated
-            meta.addAttribute(serialized, attr, serialized);
+            meta.addAttribute(serialized, kind, serialized);
         }
-        return meta.addAttribute(expr, attr, serialized);
+        return meta.addAttribute(expr, kind, serialized);
     }
     return NULL;
 }
@@ -892,8 +892,8 @@ static IHqlExpression * evaluateFieldAttrSize(IHqlExpression * expr)
                     thisSize = sizeof(void *);
                 else
                 {
-                    IHqlExpression * ret = expr->queryRecord()->queryAttribute(_attrSize_Atom);
-                    return meta.addAttribute(expr, _attrSize_Atom, ret);
+                    IHqlExpression * ret = expr->queryRecord()->queryAttribute(EPsize);
+                    return meta.addAttribute(expr, EPsize, ret);
                 }
                 break;
             }
@@ -933,7 +933,7 @@ static IHqlExpression * evaluateFieldAttrSize(IHqlExpression * expr)
                 }
 
                 IHqlExpression * record = expr->queryRecord();
-                IHqlExpression * childRecordSizeExpr = record->queryAttribute(_attrSize_Atom);
+                IHqlExpression * childRecordSizeExpr = record->queryAttribute(EPsize);
                 unsigned childExpectedSize = (unsigned)getIntValue(childRecordSizeExpr->queryChild(0));
                 unsigned childMinimumSize = (unsigned)getIntValue(childRecordSizeExpr->queryChild(1));
                 IHqlExpression * childMaximumSizeExpr = childRecordSizeExpr->queryChild(2);
@@ -1077,22 +1077,22 @@ static IHqlExpression * evaluateFieldAttrSize(IHqlExpression * expr)
     if ((thisSize == minSize) && (minSize == maxSize))
     {
         OwnedHqlExpr attr = getFixedSizeAttr(thisSize);
-        return meta.addAttribute(expr, _attrSize_Atom, attr);
+        return meta.addAttribute(expr, EPsize, attr);
     }
 
     if (!thisMaxSizeExpr)
         thisMaxSizeExpr.setown((maxSize == UNKNOWN_LENGTH) ? createAttribute(unknownSizeFieldAtom) : getSizetConstant(maxSize));
-    OwnedHqlExpr attr = createExprAttribute(_attrSize_Atom, getSizetConstant(thisSize), getSizetConstant(minSize), thisMaxSizeExpr.getClear());
-    return meta.addAttribute(expr, _attrSize_Atom, attr);
+    OwnedHqlExpr attr = createExprAttribute(_propSize_Atom, getSizetConstant(thisSize), getSizetConstant(minSize), thisMaxSizeExpr.getClear());
+    return meta.addAttribute(expr, EPsize, attr);
 }
 
 //no_ifblock
 static IHqlExpression * evaluateIfBlockAttrSize(IHqlExpression * expr) 
 { 
-    IHqlExpression * size = expr->queryChild(1)->queryAttribute(_attrSize_Atom);
+    IHqlExpression * size = expr->queryChild(1)->queryAttribute(EPsize);
     unsigned averageSize = (unsigned)getIntValue(size->queryChild(0), 0)/2;
-    OwnedHqlExpr attr = createExprAttribute(_attrSize_Atom, getSizetConstant(averageSize), getSizetConstant(0), LINK(size->queryChild(2)));
-    return meta.addAttribute(expr, _attrSize_Atom, attr);
+    OwnedHqlExpr attr = createExprAttribute(_propSize_Atom, getSizetConstant(averageSize), getSizetConstant(0), LINK(size->queryChild(2)));
+    return meta.addAttribute(expr, EPsize, attr);
 }
 
 //no_record
@@ -1124,7 +1124,7 @@ static IHqlExpression * evaluateRecordAttrSize(IHqlExpression * expr)
         else
         {
             packer.reset();
-            IHqlExpression * size = cur->queryAttribute(_attrSize_Atom);
+            IHqlExpression * size = cur->queryAttribute(EPsize);
             if (size)
             {
                 expectedSize += (size32_t)getIntValue(size->queryChild(0));
@@ -1211,8 +1211,8 @@ static IHqlExpression * evaluateRecordAttrSize(IHqlExpression * expr)
     if (derivedSizeExpr)
         args.append(*LINK(derivedSizeExpr));
 
-    OwnedHqlExpr sizeAttr = createExprAttribute(_attrSize_Atom, args);
-    return meta.addAttribute(expr, _attrSize_Atom, sizeAttr);
+    OwnedHqlExpr sizeAttr = createExprAttribute(_propSize_Atom, args);
+    return meta.addAttribute(expr, EPsize, sizeAttr);
 }
 
 
@@ -1231,13 +1231,13 @@ static IHqlExpression * evaluateAttrSize(IHqlExpression * expr)
         {
             //MORE: This could calculate a better estimate for the size of the record by taking into account any constant values or datasets that are assigned.
             IHqlExpression * record = expr->queryRecord();
-            IHqlExpression * recordSize = record->queryAttribute(_attrSize_Atom);
-            return meta.addAttribute(expr, _attrSize_Atom, recordSize);
+            IHqlExpression * recordSize = record->queryAttribute(EPsize);
+            return meta.addAttribute(expr, EPsize, recordSize);
         }
     }
     IHqlExpression * record = expr->queryRecord();
     if (record)
-        return record->queryAttribute(_attrSize_Atom);
+        return record->queryAttribute(EPsize);
     return NULL;
 }
 
@@ -1295,23 +1295,23 @@ ITypeInfo * getSerializedForm(ITypeInfo * type, IAtom * variation)
 class HqlCachedAttributeTransformer : public QuickHqlTransformer
 {
 public:
-    HqlCachedAttributeTransformer(HqlTransformerInfo & _transformInfo, IAtom * _attrName);
+    HqlCachedAttributeTransformer(HqlTransformerInfo & _transformInfo, ExprPropKind _propKind);
 
     virtual IHqlExpression * transform(IHqlExpression * expr);
 
 protected:
-    IAtom * attrName;
+    ExprPropKind propKind;
 };
 
-HqlCachedAttributeTransformer::HqlCachedAttributeTransformer(HqlTransformerInfo & _transformInfo, IAtom * _attrName)
-: QuickHqlTransformer(_transformInfo, NULL), attrName(_attrName)
+HqlCachedAttributeTransformer::HqlCachedAttributeTransformer(HqlTransformerInfo & _transformInfo, ExprPropKind _propKind)
+: QuickHqlTransformer(_transformInfo, NULL), propKind(_propKind)
 {
 }
 
 
 IHqlExpression * HqlCachedAttributeTransformer::transform(IHqlExpression * expr)
 {
-    IHqlExpression * match = meta.queryExistingAttribute(expr, attrName);
+    IHqlExpression * match = meta.queryExistingAttribute(expr, propKind);
     if (match)
         return LINK(match);
 
@@ -1320,10 +1320,10 @@ IHqlExpression * HqlCachedAttributeTransformer::transform(IHqlExpression * expr)
     if (transformed != expr)
     {
         //Tag serialized form so don't re-evaluate
-        meta.addAttribute(transformed, attrName, transformed);
+        meta.addAttribute(transformed, propKind, transformed);
     }
 
-    meta.addAttribute(expr, attrName, transformed);
+    meta.addAttribute(expr, propKind, transformed);
 
     return transformed.getClear();
 }
@@ -1339,7 +1339,7 @@ public:
 };
 
 static HqlTransformerInfo hqlUnadornedInfo("HqlUnadornedNormalizer");
-HqlUnadornedNormalizer::HqlUnadornedNormalizer() : HqlCachedAttributeTransformer(hqlUnadornedInfo, _attrUnadorned_Atom)
+HqlUnadornedNormalizer::HqlUnadornedNormalizer() : HqlCachedAttributeTransformer(hqlUnadornedInfo, EPunadorned)
 {
 }
 
@@ -1407,7 +1407,7 @@ static IHqlExpression * evaluateAttrUnadorned(IHqlExpression * expr)
     HqlUnadornedNormalizer normalizer;
     //NB: Also has the side-effect of adding any missing attributes
     OwnedHqlExpr dummy = normalizer.transform(expr);
-    return meta.queryExistingAttribute(expr, _attrUnadorned_Atom);
+    return meta.queryExistingAttribute(expr, EPunadorned);
 }
 
 //---------------------------------------------------------------------------------
@@ -1484,8 +1484,8 @@ public:
         IInterface * pright = (IInterface *)(inright);
         IHqlExpression * left = static_cast<IHqlExpression *>(pleft);
         IHqlExpression * right = static_cast<IHqlExpression *>(pright);
-        IHqlExpression * leftSizeAttr = left->queryAttribute(_attrSize_Atom);
-        IHqlExpression * rightSizeAttr = right->queryAttribute(_attrSize_Atom);
+        IHqlExpression * leftSizeAttr = left->queryAttribute(EPsize);
+        IHqlExpression * rightSizeAttr = right->queryAttribute(EPsize);
 
         bool leftIsFixedSize = leftSizeAttr->queryChild(1) == leftSizeAttr->queryChild(2);
         bool rightIsFixedSize = rightSizeAttr->queryChild(1) == rightSizeAttr->queryChild(2);
@@ -1577,11 +1577,11 @@ static IHqlExpression * evaluateAttrAligned(IHqlExpression * expr)
         same = false;
     OwnedHqlExpr newRecord = same ? LINK(expr) : expr->clone(result);
     if (expr == newRecord)
-        return meta.addAttribute(expr, _attrAligned_Atom, queryAlignedAttr());
-    meta.addAttribute(newRecord, _attrAligned_Atom, queryAlignedAttr());
+        return meta.addAttribute(expr, EPaligned, queryAlignedAttr());
+    meta.addAttribute(newRecord, EPaligned, queryAlignedAttr());
     
-    OwnedHqlExpr alignAttr = createExprAttribute(_attrAligned_Atom, newRecord.getClear());
-    return meta.addAttribute(expr, _attrAligned_Atom, alignAttr);
+    OwnedHqlExpr alignAttr = createExprAttribute(_propAligned_Atom, newRecord.getClear());
+    return meta.addAttribute(expr, EPaligned, alignAttr);
 }
 
 //---------------------------------------------------------------------------------
@@ -2003,7 +2003,7 @@ bool isTrivialDataset(IHqlExpression * expr)
 
 static unsigned estimateRowSize(IHqlExpression * record)
 {
-    IHqlExpression * size = record->queryAttribute(_attrSize_Atom);
+    IHqlExpression * size = record->queryAttribute(EPsize);
     if (!size || !size->queryChild(2)->queryValue())
         return UNKNOWN_LENGTH;
     return (unsigned)getIntValue(size->queryChild(0));
@@ -2211,12 +2211,12 @@ public:
 
     IHqlExpression * createRecordCountAttr()
     {
-        return createExprAttribute(_attrRecordCount_Atom, makeConstant(magnitude), LINK(min), LINK(max));//  , LINK(estimate));
+        return createExprAttribute(_propRecordCount_Atom, makeConstant(magnitude), LINK(min), LINK(max));//  , LINK(estimate));
     }
 
     void extract(IHqlExpression * attr)
     {
-        assertex(attr->queryName() == _attrRecordCount_Atom);
+        assertex(attr->queryName() == _propRecordCount_Atom);
         magnitude = (RowCountMagnitude)getIntValue(attr->queryChild(0));
         min.set(attr->queryChild(1));
         max.set(attr->queryChild(2));
@@ -2407,7 +2407,7 @@ void HqlRowCountInfo::setUnknown(RowCountMagnitude _magnitude)
 //MORE: This information should be cached in an attribute, once it is working, and used in more than one place.
 void retrieveRowInformation(HqlRowCountInfo & info, IHqlExpression * expr)
 {
-    IHqlExpression * attr = expr->queryAttribute(_attrRecordCount_Atom);
+    IHqlExpression * attr = expr->queryAttribute(EPrecordCount);
     info.extract(attr);
 }
 
@@ -2612,7 +2612,7 @@ IHqlExpression * calcRowInformation(IHqlExpression * expr)
     case no_getgraphloopresult:
     case no_getresult:
         {
-            IHqlExpression * attr = expr->queryProperty(_attrRecordCount_Atom);
+            IHqlExpression * attr = expr->queryProperty(_propRecordCount_Atom);
             if (attr)
                 return LINK(attr);
             if (expr->isDatarow() || expr->hasProperty(rowAtom))
@@ -2632,7 +2632,7 @@ IHqlExpression * calcRowInformation(IHqlExpression * expr)
     case no_keyindex:
     case no_newkeyindex:
         {
-            IHqlExpression * attr = expr->queryProperty(_attrRecordCount_Atom);
+            IHqlExpression * attr = expr->queryProperty(_propRecordCount_Atom);
             if (attr)
                 return LINK(attr);
             if (expr->isDatarow() || expr->hasProperty(rowAtom))
@@ -2968,7 +2968,7 @@ IHqlExpression * calcRowInformation(IHqlExpression * expr)
 static IHqlExpression * evaluateAttrRecordCount(IHqlExpression * expr) 
 {
     OwnedHqlExpr info = calcRowInformation(expr);
-    return meta.addAttribute(expr, _attrRecordCount_Atom, info);
+    return meta.addAttribute(expr, EPrecordCount, info);
 }
 
 
@@ -3171,7 +3171,7 @@ ITypeInfo * getPromotedECLCompareType(ITypeInfo * lType, ITypeInfo * rType)
 
 unsigned getMaxRecordSize(IHqlExpression * record, unsigned defaultMaxRecordSize, bool & hasKnownSize, bool & usedDefault)
 {
-    IHqlExpression * size = record->queryAttribute(_attrSize_Atom);
+    IHqlExpression * size = record->queryAttribute(EPsize);
     IHqlExpression * minSizeExpr = size->queryChild(1);
     IHqlExpression * maxSizeExpr = size->queryChild(2);
     unsigned maxSize = (unsigned)getIntValue(maxSizeExpr, UNKNOWN_LENGTH);
@@ -3195,13 +3195,13 @@ unsigned getMaxRecordSize(IHqlExpression * record, unsigned defaultMaxRecordSize
 
 size32_t getExpectedRecordSize(IHqlExpression * record)
 {
-    IHqlExpression * size = record->queryAttribute(_attrSize_Atom);
+    IHqlExpression * size = record->queryAttribute(EPsize);
     return size ? (size32_t)getIntValue(size->queryChild(0)) : 0;
 }
 
 size32_t getMinRecordSize(IHqlExpression * record)
 {
-    IHqlExpression * size = record->queryAttribute(_attrSize_Atom);
+    IHqlExpression * size = record->queryAttribute(EPsize);
     return size ? (size32_t)getIntValue(size->queryChild(1)) : 0;
 }
 
@@ -3213,19 +3213,19 @@ unsigned getMaxRecordSize(IHqlExpression * record, unsigned defaultMaxRecordSize
 
 bool maxRecordSizeUsesDefault(IHqlExpression * record)
 {
-    IHqlExpression * maxSize = record->queryAttribute(_attrSize_Atom)->queryChild(2);
+    IHqlExpression * maxSize = record->queryAttribute(EPsize)->queryChild(2);
     return (maxSize->queryValue() == NULL);
 }
 
 bool isVariableSizeRecord(IHqlExpression * record)
 {
-    IHqlExpression * sizeAttr = record->queryAttribute(_attrSize_Atom);
+    IHqlExpression * sizeAttr = record->queryAttribute(EPsize);
     return sizeAttr->queryChild(1) != sizeAttr->queryChild(2);
 }
 
 bool maxRecordSizeIsAmbiguous(IHqlExpression * record, size32_t & specifiedSize, size32_t & derivedSize)
 {
-    IHqlExpression * sizeAttr = record->queryAttribute(_attrSize_Atom);
+    IHqlExpression * sizeAttr = record->queryAttribute(EPsize);
     IHqlExpression * derivedSizeExpr = sizeAttr->queryChild(3);
     if (!derivedSizeExpr || !derivedSizeExpr->isConstant())
         return false;
@@ -3249,7 +3249,7 @@ bool maxRecordSizeCanBeDerived(IHqlExpression * record)
         return true;
     if (record->hasProperty(maxLengthAtom))
     {
-        IHqlExpression * sizeAttr = record->queryAttribute(_attrSize_Atom);
+        IHqlExpression * sizeAttr = record->queryAttribute(EPsize);
         IHqlExpression * derivedSizeExpr = sizeAttr->queryChild(3);
         return (derivedSizeExpr != NULL);
     }
@@ -3320,23 +3320,23 @@ extern HQL_API bool typeRequiresDeserialization(ITypeInfo * type, IAtom * serial
 
 IHqlExpression * queryRecordCountInfo(IHqlExpression * expr)
 {
-    return expr->queryAttribute(_attrRecordCount_Atom);
+    return expr->queryAttribute(EPrecordCount);
 }
 
 IHqlExpression * getRecordCountInfo(IHqlExpression * expr)
 {
-    return LINK(expr->queryAttribute(_attrRecordCount_Atom));
+    return LINK(expr->queryAttribute(EPrecordCount));
 }
 
 IHqlExpression * queryExpectedRecordCount(IHqlExpression * expr)
 {
-    IHqlExpression * attr = expr->queryAttribute(_attrRecordCount_Atom);
+    IHqlExpression * attr = expr->queryAttribute(EPrecordCount);
     return attr ? attr->queryChild(0) : NULL;
 }
 
 IHqlExpression * getPackedRecord(IHqlExpression * expr)
 {
-    IHqlExpression * attr = expr->queryAttribute(_attrAligned_Atom);
+    IHqlExpression * attr = expr->queryAttribute(EPaligned);
     IHqlExpression * packed = attr->queryChild(0);
     if (!packed) packed = expr;
     return LINK(packed);
@@ -3351,7 +3351,7 @@ IHqlExpression * getUnadornedRecordOrField(IHqlExpression * expr)
 {
     if (!expr)
         return NULL;
-    IHqlExpression * attr = expr->queryAttribute(_attrUnadorned_Atom);
+    IHqlExpression * attr = expr->queryAttribute(EPunadorned);
     return LINK(attr);
 }
 
@@ -3470,13 +3470,13 @@ IHqlExpression * HqlLocationIndependentNormalizer::createTransformed(IHqlExpress
     if (isAlwaysLocationIndependent(expr))
         return LINK(expr);
 
-    IHqlExpression * match = meta.queryExistingAttribute(expr, _attrLocationIndependent_Atom);
+    IHqlExpression * match = meta.queryExistingAttribute(expr, EPlocationIndependent);
     if (match)
         return LINK(match);
 
     OwnedHqlExpr transformed = doCreateTransformed(expr);
 
-    meta.addAttribute(expr, _attrLocationIndependent_Atom, transformed);
+    meta.addAttribute(expr, EPlocationIndependent, transformed);
 
     return transformed.getClear();
 }
@@ -3496,7 +3496,7 @@ IHqlExpression * evaluateAttrLocationIndependent(IHqlExpression * expr)
 
 IHqlExpression * queryLocationIndependent(IHqlExpression * expr)
 {
-    IHqlExpression * match = expr->queryAttribute(_attrLocationIndependent_Atom);
+    IHqlExpression * match = expr->queryAttribute(EPlocationIndependent);
     if (match)
         return match;
     return expr;
@@ -3693,13 +3693,13 @@ ITypeInfo * setStreamedAttr(ITypeInfo * _type, bool setValue)
 
 //---------------------------------------------------------------------------------------------------------------------
 
-IHqlExpression * CHqlExpression::queryExistingAttribute(IAtom * propName) const
+IHqlExpression * CHqlExpression::queryExistingAttribute(ExprPropKind propKind) const
 {
     CriticalBlock block(*attributeCS);
     CHqlDynamicAttribute * cur = attributes;
     while (cur)
     {
-        if (cur->name == propName)
+        if (cur->kind == propKind)
         {
             IHqlExpression * value = cur->value;
             if (value)
@@ -3711,7 +3711,7 @@ IHqlExpression * CHqlExpression::queryExistingAttribute(IAtom * propName) const
     return NULL;
 }
 
-void CHqlExpression::addAttribute(IAtom * name, IHqlExpression * value)
+void CHqlExpression::addAttribute(ExprPropKind kind, IHqlExpression * value)
 {
     if (value == this)
         value = NULL;
@@ -3719,37 +3719,33 @@ void CHqlExpression::addAttribute(IAtom * name, IHqlExpression * value)
     CriticalBlock block(*attributeCS);
     //theoretically we should test if the attribute has already been added by another thread, but in practice there is no
     //problem if the attribute is present twice.
-    CHqlDynamicAttribute * attr = new CHqlDynamicAttribute(name, value);
+    CHqlDynamicAttribute * attr = new CHqlDynamicAttribute(kind, value);
     attr->next = attributes;
     attributes = attr;
 }
 
 
-IHqlExpression * CHqlExpression::queryAttribute(IAtom * propName)
+IHqlExpression * CHqlExpression::queryAttribute(ExprPropKind kind)
 {
-#ifdef _DEBUG
-    assertex(isInternalAttributeName(propName));
-#endif
-
-    IHqlExpression * match = queryExistingAttribute(propName);
+    IHqlExpression * match = queryExistingAttribute(kind);
     if (match)
         return match;
 
-    switch (getAttributeId(propName))
+    switch (kind)
     {
-    case EArecordCount:
+    case EPrecordCount:
         return evaluateAttrRecordCount(this);
-    case EAdiskserializedForm:
-        return evaluateAttrSerializedForm(this, _attrDiskSerializedForm_Atom, diskAtom);
-    case EAinternalserializedForm:
-        return evaluateAttrSerializedForm(this, _attrInternalSerializedForm_Atom, internalAtom);
-    case EAsize:
+    case EPdiskserializedForm:
+        return evaluateAttrSerializedForm(this, kind, diskAtom);
+    case EPinternalserializedForm:
+        return evaluateAttrSerializedForm(this, kind, internalAtom);
+    case EPsize:
         return evaluateAttrSize(this);
-    case EAaligned:
+    case EPaligned:
         return evaluateAttrAligned(this);
-    case EAunadorned:
+    case EPunadorned:
         return evaluateAttrUnadorned(this);
-    case EAlocationIndependent:
+    case EPlocationIndependent:
         return evaluateAttrLocationIndependent(this);
     }
     return NULL;

+ 2 - 2
ecl/hql/hqlexpr.cpp

@@ -6484,9 +6484,9 @@ IIdAtom * CHqlAnnotation::queryFullModuleId() const
     return body->queryFullModuleId();
 }
 
-IHqlExpression * CHqlAnnotation::queryAttribute(IAtom * name)
+IHqlExpression * CHqlAnnotation::queryAttribute(ExprPropKind kind)
 {
-    return body->queryAttribute(name);
+    return body->queryAttribute(kind);
 }
 
 IHqlExpression * CHqlAnnotation::queryNormalizedSelector(bool skipIndex)

+ 16 - 1
ecl/hql/hqlexpr.hpp

@@ -783,6 +783,21 @@ enum annotate_kind
     annotate_max
 };
 
+//An enumeration of all the possible derived properties implemented by functions in hqlattr.hpp
+enum ExprPropKind
+{
+    EPnone,
+    EPrecordCount,
+    EPdiskserializedForm,
+    EPinternalserializedForm,
+    EPsize,
+    EPaligned,
+    EPunadorned,
+    EPlocationIndependent,
+    EPmax
+};
+
+
 #ifdef ENABLE_ENUM_TYPE
     typedef enum _node_operator node_operator;
 #else
@@ -1117,7 +1132,7 @@ interface IHqlExpression : public IInterface
     virtual IHqlExpression *queryNormalizedSelector(bool skipIndex=false) = 0;
 
     virtual IHqlExpression *queryProperty(IAtom * propName) const = 0;
-    virtual IHqlExpression *queryAttribute(IAtom * propName) = 0;
+    virtual IHqlExpression *queryAttribute(ExprPropKind kind) = 0;
 
     virtual ITypeInfo *queryRecordType() = 0;
     virtual IHqlExpression *queryRecord() = 0;

+ 7 - 8
ecl/hql/hqlexpr.ipp

@@ -43,22 +43,21 @@ typedef byte transformdepth_t;
 
 class CHqlExprMeta;
 
-//class HQL_API CHqlExpression : implements IHqlExpression, public CInterface
 class HQL_API CHqlDynamicAttribute
 {
     friend class CHqlExpression;
 public:
-    inline CHqlDynamicAttribute(IAtom * _name, IHqlExpression *_value)
-        : name(_name), value(_value)
+    inline CHqlDynamicAttribute(ExprPropKind _kind, IHqlExpression *_value)
+        : kind(_kind), value(_value)
     {
         next = NULL;
     }
     ~CHqlDynamicAttribute() { delete next; }
 
 protected:
-    IAtom * name;
     CHqlDynamicAttribute * next;
     LinkedHqlExpr value;
+    ExprPropKind kind;
 };
 
 class CUsedTablesBuilder;
@@ -167,7 +166,7 @@ protected:
         operands.append(child);
         onAppendOperand(child, which);
     }
-    IHqlExpression * queryExistingAttribute(IAtom * propName) const;
+    IHqlExpression * queryExistingAttribute(ExprPropKind kind) const;
 
     void initFlagsBeforeOperands();
     void updateFlagsAfterOperands();
@@ -177,7 +176,7 @@ protected:
     virtual unsigned getCachedEclCRC();
     void setInitialHash(unsigned typeHash);
 
-    void addAttribute(IAtom * name, IHqlExpression * value);
+    void addAttribute(ExprPropKind kind, IHqlExpression * value);
 
 public:
     virtual void Link(void) const;
@@ -194,7 +193,7 @@ public:
     virtual IHqlScope *queryScope();
     virtual IHqlSimpleScope *querySimpleScope();
     virtual IHqlExpression *queryProperty(IAtom * propName) const;
-    virtual IHqlExpression *queryAttribute(IAtom * propName);
+    virtual IHqlExpression *queryAttribute(ExprPropKind kind);
     virtual IHqlExpression *queryFunctionDefinition() const { return NULL; };
     virtual IHqlExpression *queryExternalDefinition() const { return NULL; };
     virtual unsigned getInfoFlags() const { return infoFlags; }
@@ -504,7 +503,7 @@ public:
     virtual IHqlExpression *queryExternalDefinition() const;
     virtual IHqlExpression *queryNormalizedSelector(bool skipIndex=false);
     virtual IHqlExpression *queryProperty(IAtom * propName) const;
-    virtual IHqlExpression *queryAttribute(IAtom * propName);
+    virtual IHqlExpression *queryAttribute(ExprPropKind kind);
     virtual IHqlExpression * clone(HqlExprArray &);
     virtual IHqlExpression * cloneAnnotation(IHqlExpression * body) = 0;
     virtual IHqlExpression * cloneAllAnnotations(IHqlExpression * body);

+ 4 - 4
ecl/hql/hqlutil.cpp

@@ -77,13 +77,13 @@ MODULE_INIT(INIT_PRIORITY_STANDARD)
     sizetCacheCs = new CriticalSection;
     constUnknownVarStringType = makeConstantModifier(makeVarStringType(UNKNOWN_LENGTH));
     defaultMaxRecordLengthExpr = createQuoted("<default-max-length>", makeIntType(sizeof(size32_t), false));
-    cacheAlignedAttr = createAttribute(_attrAligned_Atom);
+    cacheAlignedAttr = createAttribute(_propAligned_Atom);
     cacheEmbeddedAttr = createAttribute(embeddedAtom);
     cacheInlineAttr = createAttribute(inlineAtom);
     cacheLinkCountedAttr = createAttribute(_linkCounted_Atom);
     cacheReferenceAttr = createAttribute(referenceAtom);
     cacheStreamedAttr = createAttribute(streamedAtom);
-    cacheUnadornedAttr = createAttribute(_attrUnadorned_Atom);
+    cacheUnadornedAttr = createAttribute(_propUnadorned_Atom);
     matchxxxPseudoFile = createDataset(no_pseudods, createRecord()->closeExpr(), createAttribute(matchxxxPseudoFileAtom));
     cachedQuotedNullExpr = createValue(no_nullptr, makeBoolType());
     cachedOmittedValueExpr = createValue(no_omitted, makeAnyType());
@@ -162,7 +162,7 @@ HQL_API IHqlExpression * getFixedSizeAttr(unsigned size)
     if (size >= FIXEDATTR_CACHE_SIZE)
     {
         OwnedHqlExpr sizeExpr = getSizetConstant(size);
-        return createExprAttribute(_attrSize_Atom, LINK(sizeExpr), LINK(sizeExpr), LINK(sizeExpr));
+        return createExprAttribute(_propSize_Atom, LINK(sizeExpr), LINK(sizeExpr), LINK(sizeExpr));
     }
 
     CriticalBlock block(*sizetCacheCs);     // reuse the critical section
@@ -170,7 +170,7 @@ HQL_API IHqlExpression * getFixedSizeAttr(unsigned size)
     if (!match)
     {
         OwnedHqlExpr sizeExpr = getSizetConstant(size);
-        match = fixedAttrSizeCache[size] = createExprAttribute(_attrSize_Atom, LINK(sizeExpr), LINK(sizeExpr), LINK(sizeExpr));
+        match = fixedAttrSizeCache[size] = createExprAttribute(_propSize_Atom, LINK(sizeExpr), LINK(sizeExpr), LINK(sizeExpr));
     }
     return LINK(match);
 }

+ 1 - 1
ecl/hqlcpp/hqlcatom.cpp

@@ -732,7 +732,7 @@ IIdAtom * xmlEncodeUStrId;
 
 #define MAKEID(x)   x##Id = createIdAtom(#x)
 #define MAKEATOM(x) x##Atom = createLowerCaseAtom(#x)
-#define MAKESYSATOM(x)  _##x##_Atom = createSystemAtom("$_" #x "_")
+#define MAKESYSATOM(x)  _##x##_Atom = createLowerCaseAtom("$_" #x "_")
 
 MODULE_INIT(INIT_PRIORITY_HQLATOM-1)
 {

+ 1 - 1
ecl/hqlcpp/hqltcppc.cpp

@@ -533,7 +533,7 @@ void CMemberInfo::doBuildSkipInput(HqlCppTranslator & translator, BuildCtx & ctx
 
 IHqlExpression * CMemberInfo::createSelfPeekDeserializer(HqlCppTranslator & translator, IHqlExpression * helper)
 {
-    IHqlExpression * size = column->queryAttribute(_attrSize_Atom);
+    IHqlExpression * size = column->queryAttribute(EPsize);
     LinkedHqlExpr maxSize = size->queryChild(2);
     if (!maxSize || maxSize->isAttribute())
         maxSize.setown(getSizetConstant(MAX_RECORD_SIZE));