Commits

Anonymous committed ff3a440

#35: mainlining directly

  • Participants
  • Parent commits 3dde8d1

Comments (0)

Files changed (14)

File src/lib/__bi.py

     ps = NATIVE_GET_LOCAL(0);
 
     /* Get the length of the arg based on its type */
-    switch (ps->od.od_type)
+    switch (OBJ_GET_TYPE(*ps))
     {
         case OBJ_TYPE_STR:
             retval = int_new(((pPmString_t)ps)->length, &pr);
     ps = NATIVE_GET_LOCAL(1);
 
     /* If args are wrong type, raise TypeError */
-    if (pf->od.od_type != OBJ_TYPE_FXN)
+    if (OBJ_GET_TYPE(*pf) != OBJ_TYPE_FXN)
     {
         return PM_RET_EX_TYPE;
     }
 
     /* Get the sequence length based on type */
-    switch (ps->od.od_type)
+    switch (OBJ_GET_TYPE(*ps))
     {
         case OBJ_TYPE_TUP:
             length = ((pPmTuple_t)ps)->length;
     po = NATIVE_GET_LOCAL(0);
 
     /* Create int from type enum */
-    retval = int_new(po->od.od_type, &pr);
+    retval = int_new(OBJ_GET_TYPE(*po), &pr);
     NATIVE_SET_TOS(pr);
     return retval;
     """
     retval = heap_getChunk(sizeof(PmClass_t), &pchunk);
     PM_RETURN_IF_ERROR(retval);
     pexn = (pPmClass_t)pchunk;
-    pexn->od.od_type = OBJ_TYPE_EXN;
+    OBJ_SET_TYPE(*pexn, OBJ_TYPE_EXN);
     retval = dict_new((pPmObj_t *)&pexn->cl_attrs);
 
     NATIVE_SET_TOS((pPmObj_t)pexn);

File src/lib/mmb.py

 
     /* Get arg, throw type exception if it's not an int */
     pc = NATIVE_GET_LOCAL(0);
-    if (pc->od.od_type != OBJ_TYPE_INT)
+    if (OBJ_GET_TYPE(*pc) != OBJ_TYPE_INT)
     {
         return PM_RET_EX_TYPE;
     }
 
     /* Get arg, throw type exception if it's not an int */
     pc = NATIVE_GET_LOCAL(0);
-    if (pc->od.od_type != OBJ_TYPE_INT)
+    if (OBJ_GET_TYPE(*pc) != OBJ_TYPE_INT)
     {
         return PM_RET_EX_TYPE;
     }
     /* Get the args, throw exception if needed */
     pf = NATIVE_GET_LOCAL(0);
     pms = NATIVE_GET_LOCAL(1);
-    if ((pf->od.od_type != OBJ_TYPE_INT) ||
-        (pms->od.od_type != OBJ_TYPE_INT))
+    if ((OBJ_GET_TYPE(*pf) != OBJ_TYPE_INT) ||
+        (OBJ_GET_TYPE(*pms) != OBJ_TYPE_INT))
     {
         return PM_RET_EX_TYPE;
     }
 
     /* Get the arg, throw exception if needed */
     pc = NATIVE_GET_LOCAL(0);
-    if (pc->od.od_type != OBJ_TYPE_INT)
+    if (OBJ_GET_TYPE(*pc) != OBJ_TYPE_INT)
     {
         return PM_RET_EX_TYPE;
     }
 
     /* Get the arg, throw type exception if needed */
     pc = NATIVE_GET_LOCAL(0);
-    if (pc->od.od_type != OBJ_TYPE_INT)
+    if (OBJ_GET_TYPE(*pc) != OBJ_TYPE_INT)
     {
         return PM_RET_EX_TYPE;
     }
 
     /* Get the arg, throw type exception if needed */
     ps = NATIVE_GET_LOCAL(0);
-    if (ps->od.od_type != OBJ_TYPE_STR)
+    if (OBJ_GET_TYPE(*ps) != OBJ_TYPE_STR)
     {
         return PM_RET_EX_TYPE;
     }
 
     /* Get the arg, throw type exception if needed */
     pn = NATIVE_GET_LOCAL(0);
-    if (pn->od.od_type != OBJ_TYPE_INT)
+    if (OBJ_GET_TYPE(*pn) != OBJ_TYPE_INT)
     {
         return PM_RET_EX_TYPE;
     }
 
     /* Get the arg, throw exception if needed */
     ps = NATIVE_GET_LOCAL(0);
-    if (ps->od.od_type != OBJ_TYPE_INT)
+    if (OBJ_GET_TYPE(*ps) != OBJ_TYPE_INT)
     {
         return PM_RET_EX_TYPE;
     }
 
     /* Get the arg, throw type exception if needed */
     ps = NATIVE_GET_LOCAL(0);
-    if (ps->od.od_type != OBJ_TYPE_INT)
+    if (OBJ_GET_TYPE(*ps) != OBJ_TYPE_INT)
     {
         return PM_RET_EX_TYPE;
     }
     pc = NATIVE_GET_LOCAL(0);
 
     /* if arg is a string, write 0th char */
-    if (pc->od.od_type == OBJ_TYPE_STR)
+    if (OBJ_GET_TYPE(*pc) == OBJ_TYPE_STR)
     {
         c = (U8)(((pPmString_t)pc)->val[0]);
         mmb_sciPutByte(c);
     }
     /* if arg is an int, write LSB */
-    else if (pc->od.od_type == OBJ_TYPE_INT)
+    else if (OBJ_GET_TYPE(*pc) == OBJ_TYPE_INT)
     {
         c = (U8)(((pPmInt_t)pc)->val & 0xFF);
         mmb_sciPutByte(c);
 
     /* Get the arg, throw type exception if needed */
     ps = NATIVE_GET_LOCAL(0);
-    if (ps->od.od_type != OBJ_TYPE_STR)
+    if (OBJ_GET_TYPE(*ps) != OBJ_TYPE_STR)
     {
         return PM_RET_EX_TYPE;
     }
 
     /* Get the arg, throw type exception if needed */
     pms = NATIVE_GET_LOCAL(0);
-    if (pms->od.od_type != OBJ_TYPE_INT)
+    if (OBJ_GET_TYPE(*pms) != OBJ_TYPE_INT)
     {
         return PM_RET_EX_TYPE;
     }

File src/tests/ut_dict.c

     pPmObj_t pobj = C_NULL;
 
     dict_new(&pobj);
-    if (pobj->od.od_type != OBJ_TYPE_DIC)
+    if (OBJ_GET_TYPE(*pobj) != OBJ_TYPE_DIC)
     {
         TEST_ERR(__LINE__);
     }
     pPmObj_t pobj = C_NULL;
 
     dict_new(&pobj);
-    if (pobj->od.od_const != 0)
+    if (OBJ_IS_CONST(*pobj))
     {
         TEST_ERR(__LINE__);
     }

File src/tests/ut_list.c

     pPmObj_t pobj = C_NULL;
 
     retval = list_new(&pobj);
-    if (pobj->od.od_type != OBJ_TYPE_LST)
+    if (OBJ_GET_TYPE(*pobj) != OBJ_TYPE_LST)
     {
         TEST_ERR(__LINE__);
     }
     pPmObj_t pobj = C_NULL;
 
     retval = list_new(&pobj);
-    if (pobj->od.od_const != 0)
+    if (OBJ_IS_CONST(pobj))
     {
         TEST_ERR(__LINE__);
     }

File src/vm/heap.c

  */
 #define HEAP_MARK_IF_UNMARKED(pobj, rval)   \
             if (((pobj) != C_NULL) && \
-                (((pPmObj_t)pobj)->od.od_gcval != heap_gcval)) \
+                (OBJ_GET_GCVAL(*pobj) != heap_gcval)) \
                     rval = heap_markObj((pPmObj_t)pobj)
 
 
     PmReturn_t retval = PM_RET_OK;
     S8 i = 0;
 
-    switch (pobj->od.od_type)
+    switch (OBJ_GET_TYPE(*pobj))
     {
         /* objects with no other obj refs */
         case OBJ_TYPE_NON:
         case OBJ_TYPE_FLT:
         case OBJ_TYPE_STR:
         case OBJ_TYPE_NOB:
-            pobj->od.od_gcval = heap_gcval;
+            OBJ_SET_GCVAL(*pobj, heap_gcval);
             break;
 
         case OBJ_TYPE_TUP:
             i = ((pPmTuple_t)pobj)->length;
             /* mark tuple head */
-            pobj->od.od_gcval = heap_gcval;
+            OBJ_SET_GCVAL(*pobj, heap_gcval);
             /* mark each obj in tuple */
             while (--i >= 0)
             {
 
         case OBJ_TYPE_LST:
             /* mark the list */
-            pobj->od.od_gcval = heap_gcval;
+            OBJ_SET_GCVAL(*pobj, heap_gcval);
             /* mark the keys seglist */
             HEAP_MARK_IF_UNMARKED(((pPmList_t)pobj)->val,
                                   retval);
 
         case OBJ_TYPE_DIC:
             /* mark the dict head */
-            pobj->od.od_gcval = heap_gcval;
+            OBJ_SET_GCVAL(*pobj, heap_gcval);
             /* mark the keys seglist */
             HEAP_MARK_IF_UNMARKED(((pPmDict_t)pobj)->d_keys,
                                   retval);
 
         case OBJ_TYPE_COB:
             /* mark the code obj head */
-            pobj->od.od_gcval = heap_gcval;
+            OBJ_SET_GCVAL(*pobj, heap_gcval);
             /* mark the names tuple */
             HEAP_MARK_IF_UNMARKED(((pPmCo_t)pobj)->co_names,
                                   retval);
         case OBJ_TYPE_FXN:
             /* Module and Func objs are implemented via the PmFunc_t */
             /* mark the func obj head */
-            pobj->od.od_gcval = heap_gcval;
+            OBJ_SET_GCVAL(*pobj, heap_gcval);
             /* mark the code obj */
             HEAP_MARK_IF_UNMARKED(((pPmFunc_t)pobj)->f_co, retval);
             PM_RETURN_IF_ERROR(retval);
         case OBJ_TYPE_CLI:
         case OBJ_TYPE_EXN:
             /* mark the obj head */
-            pobj->od.od_gcval = heap_gcval;
+            OBJ_SET_GCVAL(*pobj, heap_gcval);
             /* mark the attrs dict */
             HEAP_MARK_IF_UNMARKED(((pPmClass_t)pobj)->cl_attrs, retval);
             break;
         {
             pPmObj_t pobj2 = C_NULL;
             /* mark the frame obj head */
-            pobj->od.od_gcval = heap_gcval;
+            OBJ_SET_GCVAL(*pobj, heap_gcval);
             /* mark the previous frame */
             HEAP_MARK_IF_UNMARKED(((pPmFrame_t)pobj)->fo_back,
                                   retval);
 
         case OBJ_TYPE_BLK:
             /* mark the block obj head */
-            pobj->od.od_gcval = heap_gcval;
+            OBJ_SET_GCVAL(*pobj, heap_gcval);
             /* mark the previous block */
             HEAP_MARK_IF_UNMARKED(((pPmBlock_t)pobj)->next,
                                   retval);
 
         case OBJ_TYPE_SEG:
             /* mark the segment obj head */
-            pobj->od.od_gcval = heap_gcval;
+            OBJ_SET_GCVAL(*pobj, heap_gcval);
             /* mark each obj in the segment */
             for (i = 0; i < SEGLIST_OBJS_PER_SEG; i++)
             {
 
         case OBJ_TYPE_SGL:
             /* mark the seglist obj head */
-            pobj->od.od_gcval = heap_gcval;
+            OBJ_SET_GCVAL(*pobj, heap_gcval);
             /* mark the root segment */
             HEAP_MARK_IF_UNMARKED(
                 ((pSeglist_t)pobj)->sl_rootseg,
     size = HEAP_SIZE;
     while (size > HEAP_MAX_CHUNK_SIZE)
     {
-        pchunk->od.od_size = HEAP_MAX_CHUNK_SIZE;
+        OBJ_SET_SIZE(*pchunk, HEAP_MAX_CHUNK_SIZE);
         pchunk->next = (pPmHeapDesc_t)((P_U8)pchunk + HEAP_MAX_CHUNK_SIZE);
         size -= HEAP_MAX_CHUNK_SIZE;
         pchunk = pchunk->next;
     }
 
     /* set fields of last fragment */
-    pchunk->od.od_size = size;
+    OBJ_SET_SIZE(*pchunk, size);
     pchunk->next = C_NULL;
 
 #if HEAP_MEASURE
         pchunk1 = pfreelist;
 
         /* if first chunk is best fit */
-        if ((pchunk1->od.od_size >= size) &&
-            (pchunk1->od.od_size <= (size + HEAP_MAX_FRAG_SIZE)))
+        if ((OBJ_GET_SIZE(*pchunk1) >= size) &&
+            (OBJ_GET_SIZE(*pchunk1) <= (size + HEAP_MAX_FRAG_SIZE)))
         {
             /* relink list and return first chunk */
             pfreelist = pfreelist->next;
             /* reduce heap available amount */
-            gVmGlobal.heap.avail -= pchunk1->od.od_size;
+            gVmGlobal.heap.avail -= OBJ_GET_SIZE(*pchunk1);
             *r_pchunk = (P_U8)pchunk1;
             return PM_RET_OK;
         }
 
         /* else search list for proper sized chunk */
         while ((pchunk1->next != C_NULL) &&
-               (pchunk1->next->od.od_size < size))
+               (OBJ_GET_SIZE(*pchunk1->next) < size))
         {
              pchunk1 = pchunk1->next;
         }
          * if not, we might use pchunk1->next later (first fit).
          */
         if ((pchunk1->next != C_NULL) &&
-            (pchunk1->next->od.od_size <=
+            (OBJ_GET_SIZE(*pchunk1->next) <=
              (size + HEAP_MAX_FRAG_SIZE)))
         {
             /* unlink chunk */
             pchunk2 = pchunk1->next;
             pchunk1->next = pchunk1->next->next;
             /* reduce heap available amount */
-            gVmGlobal.heap.avail -= pchunk2->od.od_size;
+            gVmGlobal.heap.avail -= OBJ_GET_SIZE(*pchunk2);
             *r_pchunk = (P_U8)pchunk2;
             return PM_RET_OK;
         }
          * if the clean heap is not large enough
          * put the fragment in the free list
          */
-        if (pcleanheap->od.od_size < size)
+        if (OBJ_GET_SIZE(*pcleanheap) < size)
         {
             pchunk2 = pcleanheap;
             /* try the next clean heap */
          * if there is one and it is large enough
          */
         if ((pcleanheap != C_NULL) &&
-            ((pcleanheap->od.od_size - size) >= 0))
+            ((OBJ_GET_SIZE(*pcleanheap) - size) >= 0))
         {
 
             /*
              * if potential clean heap remnant is too small,
              * use the entire chunk and setup next clean heap
              */
-            if ((pcleanheap->od.od_size - size) < HEAP_MIN_CHUNK_SIZE)
+            if ((OBJ_GET_SIZE(*pcleanheap) - size) < HEAP_MIN_CHUNK_SIZE)
             {
                 pchunk2 = pcleanheap;
                 pcleanheap = pcleanheap->next;
             /* else carve chunk out of clean heap */
             else
             {
-                pcleanheap->od.od_size -= size;
+                OBJ_SET_SIZE(*pcleanheap, OBJ_GET_SIZE(*pcleanheap) - size);
                 pchunk2 = (pPmHeapDesc_t)((P_U8)pcleanheap 
-                                          + pcleanheap->od.od_size);
-                pchunk2->od.od_size = size;
+                                          + OBJ_GET_SIZE(*pcleanheap));
+                OBJ_SET_SIZE(*pchunk2, size);
             }
 
             /* reduce heap available amount */
      */
     if ((pchunk1 != C_NULL)
         && (pchunk1->next != C_NULL)
-        && (pchunk1->next->od.od_size >= size))
+        && (OBJ_GET_SIZE(*pchunk1->next) >= size))
     {
         pchunk2 = pchunk1->next;
         pchunk1->next = pchunk1->next->next;
         /* reduce heap available amount */
-        gVmGlobal.heap.avail -= pchunk2->od.od_size;
+        gVmGlobal.heap.avail -= OBJ_GET_SIZE(*pchunk2);
         *r_pchunk = (P_U8)pchunk2;
         return PM_RET_OK;
     }
 heap_freeChunk(pPmObj_t ptr)
 {
     pPmHeapDesc_t oldchunk = (pPmHeapDesc_t)ptr;
-    U8 size = ptr->od.od_size;
+    U8 size = OBJ_GET_SIZE(*ptr);
     pPmHeapDesc_t pchunk1;
     pPmHeapDesc_t pchunk2;
 
     /* increase heap available amount */
-    gVmGlobal.heap.avail += ptr->od.od_size;
+    gVmGlobal.heap.avail += OBJ_GET_SIZE(*ptr);
 
     /* if freelist is empty or oldchunk is smallest */
     if ((pfreelist == C_NULL) ||
-        (pfreelist->od.od_size >= size))
+        (OBJ_GET_SIZE(*pfreelist) >= size))
     {
         oldchunk->next = pfreelist;
         pfreelist = oldchunk;
 
     /* scan freelist for insertion point */
     while ((pchunk2 != C_NULL) &&
-           (pchunk2->od.od_size < size))
+           (OBJ_GET_SIZE(*pchunk2) < size))
     {
         pchunk1 = pchunk2;
         pchunk2 = pchunk2->next;

File src/vm/int.c

     PM_RETURN_IF_ERROR(retval);
 
     /* copy value */
-    (*r_pint)->od.od_type = OBJ_TYPE_INT;
+    OBJ_SET_TYPE(**r_pint, OBJ_TYPE_INT);
     ((pPmInt_t)*r_pint)->val = ((pPmInt_t)pint)->val;
     return retval;
 }
     /* else create and return new int obj */
     retval = heap_getChunk(sizeof(PmInt_t), (P_U8 *)r_pint);
     PM_RETURN_IF_ERROR(retval);
-    (*r_pint)->od.od_type = OBJ_TYPE_INT;
+    OBJ_SET_TYPE(**r_pint, OBJ_TYPE_INT);
     ((pPmInt_t)*r_pint)->val = n;
     return retval;
 }
 int_positive(pPmObj_t pobj, pPmObj_t * r_pint)
 {    
     /* ensure it's an int */
-    if (pobj->od.od_type != OBJ_TYPE_INT)
+    if (OBJ_GET_TYPE(*pobj) != OBJ_TYPE_INT)
     {
         return PM_RET_EX_TYPE;
     }
 int_negative(pPmObj_t pobj, pPmObj_t * r_pint)
 {
     /* ensure it's an int */
-    if (pobj->od.od_type != OBJ_TYPE_INT)
+    if (OBJ_GET_TYPE(*pobj) != OBJ_TYPE_INT)
     {
         return PM_RET_EX_TYPE;
     }
 int_bitInvert(pPmObj_t pobj, pPmObj_t * r_pint)
 {
     /* ensure it's an int */
-    if (pobj->od.od_type != OBJ_TYPE_INT)
+    if (OBJ_GET_TYPE(*pobj) != OBJ_TYPE_INT)
     {
         return PM_RET_EX_TYPE;
     }

File src/vm/interp.c

 
             case UNARY_POSITIVE:
                 /* TypeError if TOS is not an int */
-                if (TOS->od.od_type != OBJ_TYPE_INT)
+                if (OBJ_GET_TYPE(*TOS) != OBJ_TYPE_INT)
                 {
                     retval = PM_RET_EX_TYPE;
                     break;
 
             case UNARY_INVERT:
                 /* TypeError if it's not an int */
-                if (TOS->od.od_type != OBJ_TYPE_INT)
+                if (OBJ_GET_TYPE(*TOS) != OBJ_TYPE_INT)
                 {
                     retval = PM_RET_EX_TYPE;
                     break;
 
             case BINARY_MULTIPLY:
                 /* if both objs are ints, simple multiply */
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS)  == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     pobj1 = PM_POP();
                     retval = int_new(
                 }
 
                 /* if it's a list replication operation */
-                else if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                         && (TOS1->od.od_type == OBJ_TYPE_LST))
+                else if ((OBJ_GET_TYPE(*TOS)  == OBJ_TYPE_INT)
+                         && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_LST))
                 {
                     /* int number of times to duplicate */
                     pobj1 = PM_POP();
 
             case BINARY_DIVIDE:
                 /* if both objs are ints, simple divide */
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS)  == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     pobj1 = PM_POP();
 
 
             case BINARY_MODULO:
                 /* if both objs are ints, perform modulo */
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS)  == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     pobj1 = PM_POP();
                     /* ZeroDivisionError */
 
             case BINARY_ADD:
                 /* if both objs are ints, perform the op */
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     pobj1 = PM_POP();
                     retval = int_new(
 
             case BINARY_SUBTRACT:
                 /* if both objs are ints, perform the op */
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     pobj1 = PM_POP();
                     retval = int_new(
                 /* XXX index out of range exception? */
 
                 /* if it's a string */
-                if (pobj2->od.od_type == OBJ_TYPE_STR)
+                if (OBJ_GET_TYPE(*pobj2) == OBJ_TYPE_STR)
                 {
                     /* TypeError; sequence index must be int */
-                    if (pobj1->od.od_type != OBJ_TYPE_INT)
+                    if (OBJ_GET_TYPE(*pobj1) != OBJ_TYPE_INT)
                     {
                         retval = PM_RET_EX_TYPE;
                         break;
                 }
 
                 /* if it's a tuple */
-                else if (pobj2->od.od_type == OBJ_TYPE_TUP)
+                else if (OBJ_GET_TYPE(*pobj2) == OBJ_TYPE_TUP)
                 {
                     /* TypeError; sequence index must be int */
-                    if (pobj1->od.od_type != OBJ_TYPE_INT)
+                    if (OBJ_GET_TYPE(*pobj1) != OBJ_TYPE_INT)
                     {
                         retval = PM_RET_EX_TYPE;
                         break;
                 }
 
                 /* if it's a list */
-                else if (pobj2->od.od_type == OBJ_TYPE_LST)
+                else if (OBJ_GET_TYPE(*pobj2) == OBJ_TYPE_LST)
                 {
                     /* TypeError; sequence index must be int */
-                    if (pobj1->od.od_type != OBJ_TYPE_INT)
+                    if (OBJ_GET_TYPE(*pobj1) != OBJ_TYPE_INT)
                     {
                         retval = PM_RET_EX_TYPE;
                         break;
                 }
 
                 /* if it's a dict */
-                else if (pobj2->od.od_type == OBJ_TYPE_DIC)
+                else if (OBJ_GET_TYPE(*pobj2) == OBJ_TYPE_DIC)
                 {
                     /* get the dict item */
                     retval = dict_getItem(pobj2, pobj1, &pobj3);
                 /* get sequence */
                 pobj1 = PM_POP();
 
-                /* XXX if there's an obj_copy(), use here */
+                /* XXX if there's an seq_copy(), use here */
                 /* if it's a string */
-                if (pobj1->od.od_type == OBJ_TYPE_STR)
+                if (OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_STR)
                 {
                     retval = string_copy(pobj1, &pobj2);
+                    PM_BREAK_IF_ERROR(retval);
                 }
 
                 /* if it's a tuple */
-                else if (pobj1->od.od_type == OBJ_TYPE_TUP)
+                else if (OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_TUP)
                 {
                     retval = tuple_copy(pobj1, &pobj2);
                     PM_BREAK_IF_ERROR(retval);
                 }
 
                 /* if it's a list */
-                else if (pobj1->od.od_type == OBJ_TYPE_LST)
+                else if (OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_LST)
                 {
                     retval = list_copy(pobj1, &pobj2);
                     PM_BREAK_IF_ERROR(retval);
                 break;
 
             case INPLACE_ADD:
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS)  == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     /* if int is constant, make new result */
-                    if (TOS1->od.od_const) {
+                    if (OBJ_IS_CONST(*TOS1)) {
                         pobj1 = PM_POP();
                         retval = int_new(
                                     ((pPmInt_t)PM_POP())->val +
                 }
 
             case INPLACE_SUBTRACT:
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     /* if target obj is a constant obj */
-                    if (TOS1->od.od_const) {
+                    if (OBJ_IS_CONST(*TOS1)) {
                         pobj1 = PM_POP();
                         retval = int_new(
                                     ((pPmInt_t)PM_POP())->val -
                 }
 
             case INPLACE_MULTIPLY:
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     /* if target obj is a constant obj */
-                    if (TOS1->od.od_const) {
+                    if (OBJ_IS_CONST(*TOS1)) {
                         pobj1 = PM_POP();
                         retval = int_new(
                                     ((pPmInt_t)PM_POP())->val *
 
             case INPLACE_DIVIDE:
                 /* TypeError; unsupported type */
-                if ((TOS->od.od_type  != OBJ_TYPE_INT)
-                    || (TOS1->od.od_type != OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) != OBJ_TYPE_INT)
+                    || (OBJ_GET_TYPE(*TOS1) != OBJ_TYPE_INT))
                 {
                     retval = PM_RET_EX_TYPE;
                     break;
                 }
 
                 /* if target obj is a constant obj */
-                if (TOS1->od.od_const) {
+                if (OBJ_IS_CONST(*TOS1)) {
                     pobj1 = PM_POP();
                     retval = int_new(
                                 ((pPmInt_t)PM_POP())->val /
 
             case INPLACE_MODULO:
                 /* TypeError; unsupported type */
-                if ((TOS->od.od_type  != OBJ_TYPE_INT)
-                    || (TOS1->od.od_type != OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) != OBJ_TYPE_INT)
+                    || (OBJ_GET_TYPE(*TOS1) != OBJ_TYPE_INT))
                 {
                     retval = PM_RET_EX_TYPE;
                     break;
                 }
 
                 /* if target obj is a constant obj */
-                if (TOS1->od.od_const) {
+                if (OBJ_IS_CONST(*TOS1)) {
                     pobj1 = PM_POP();
                     retval = int_new(
                                 ((pPmInt_t)PM_POP())->val %
                 pobj3 = PM_POP();
 
                 /* if it's a list */
-                if (pobj2->od.od_type == OBJ_TYPE_LST)
+                if (OBJ_GET_TYPE(*pobj2) == OBJ_TYPE_LST)
                 {
                     /* ensure subscr is an int */
-                    if (pobj1->od.od_type != OBJ_TYPE_INT)
+                    if (OBJ_GET_TYPE(*pobj1) != OBJ_TYPE_INT)
                     {
                         PM_ERR(__LINE__);
                     }
                 }
 
                 /* if it's a dict */
-                if (pobj2->od.od_type == OBJ_TYPE_DIC)
+                if (OBJ_GET_TYPE(*pobj2) == OBJ_TYPE_DIC)
                 {
                     /* set the dict item */
                     retval = dict_setItem(pobj2, pobj1, pobj3);
 
             case BINARY_LSHIFT:
                 /* if neither args are ints, TypeError */
-                if ((TOS->od.od_type == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     pobj1 = PM_POP();
                     retval = int_new(
 
             case BINARY_RSHIFT:
                 /* if both objs are ints, perform the op */
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     pobj1 = PM_POP();
                     retval = int_new(
 
             case BINARY_AND:
                 /* if both objs are ints, perform the op */
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     pobj1 = PM_POP();
                     retval = int_new(
 
             case BINARY_XOR:
                 /* if both objs are ints, perform the op */
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     pobj1 = PM_POP();
                     retval = int_new(
 
             case BINARY_OR:
                 /* if both objs are ints, perform the op */
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     pobj1 = PM_POP();
                     retval = int_new(
 
             case INPLACE_LSHIFT:
                 /* if both objs are ints, perform the op */
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     /* if target obj is a constant obj */
-                    if (TOS1->od.od_const) {
+                    if (OBJ_IS_CONST(*TOS1)) {
                         pobj1 = PM_POP();
                         retval = int_new(
                                     ((pPmInt_t)PM_POP())->val <<
 
             case INPLACE_RSHIFT:
                 /* if both objs are ints, perform the op */
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     /* if target obj is a constant obj */
-                    if (TOS1->od.od_const) {
+                    if (OBJ_IS_CONST(*TOS1)) {
                         pobj1 = PM_POP();
                         retval = int_new(
                                     ((pPmInt_t)PM_POP())->val >>
 
             case INPLACE_AND:
                 /* if both objs are ints, perform the op */
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     /* if target obj is a constant obj */
-                    if (TOS1->od.od_const) {
+                    if (OBJ_IS_CONST(*TOS1)) {
                         pobj1 = PM_POP();
                         retval = int_new(
                                     ((pPmInt_t)PM_POP())->val &
 
             case INPLACE_XOR:
                 /* if both objs are ints, perform the op */
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     /* if target obj is a constant obj */
-                    if (TOS1->od.od_const) {
+                    if (OBJ_IS_CONST(*TOS1)) {
                         pobj1 = PM_POP();
                         retval = int_new(
                                     ((pPmInt_t)PM_POP())->val ^
 
             case INPLACE_OR:
                 /* if both objs are ints, perform the op */
-                if ((TOS->od.od_type  == OBJ_TYPE_INT)
-                    && (TOS1->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*TOS) == OBJ_TYPE_INT)
+                    && (OBJ_GET_TYPE(*TOS1) == OBJ_TYPE_INT))
                 {
                     /* if target obj is a constant obj */
-                    if (TOS1->od.od_const) {
+                    if (OBJ_IS_CONST(*TOS1)) {
                         pobj1 = PM_POP();
                         retval = int_new(
                                     ((pPmInt_t)PM_POP())->val |
                 /* get ptr to sequence */
                 pobj1 = PM_POP();
                 /* push objs onto stack based on type */
-                if (pobj1->od.od_type == OBJ_TYPE_TUP)
+                if (OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_TUP)
                 {
                     for (; --t16 >= 0; )
                     {
                         PM_PUSH(((pPmTuple_t)pobj1)->val[t16]);
                     }
                 }
-                else if (pobj1->od.od_type == OBJ_TYPE_LST)
+                else if (OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_LST)
                 {
                     for (; --t16 >= 0; )
                     {
                 /* get obj */
                 pobj1 = PM_POP();
                 /* get attrs dict from obj */
-                if ((pobj1->od.od_type == OBJ_TYPE_FXN)
-                    || (pobj1->od.od_type == OBJ_TYPE_MOD))
+                if ((OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_FXN)
+                    || (OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_MOD))
                 {
                     pobj1 = (pPmObj_t)((pPmFunc_t)pobj1)->
                                     f_attrs;
                 }
-                else if ((pobj1->od.od_type == OBJ_TYPE_CLO)
-                         || (pobj1->od.od_type == OBJ_TYPE_CLI)
-                         || (pobj1->od.od_type == OBJ_TYPE_EXN))
+                else if ((OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_CLO)
+                         || (OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_CLI)
+                         || (OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_EXN))
                 {
                     pobj1 = (pPmObj_t)((pPmClass_t)pobj1)->cl_attrs;
                 }
                     break;
                 }
                 /* if attrs is not a dict, raise SystemError */
-                if (pobj1->od.od_type != OBJ_TYPE_DIC)
+                if (OBJ_GET_TYPE(*pobj1) != OBJ_TYPE_DIC)
                 {
                     retval = PM_RET_EX_SYS;
                     break;
                 /* get obj that has the attrs */
                 pobj1 = PM_POP();
                 /* get attrs dict from obj */
-                if ((pobj1->od.od_type == OBJ_TYPE_FXN) ||
-                    (pobj1->od.od_type == OBJ_TYPE_MOD))
+                if ((OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_FXN) ||
+                    (OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_MOD))
                 {
                     pobj1 = (pPmObj_t)((pPmFunc_t)pobj1)->
                                     f_attrs;
                 }
-                else if ((pobj1->od.od_type == OBJ_TYPE_CLO)
-                         || (pobj1->od.od_type == OBJ_TYPE_CLI)
-                         || (pobj1->od.od_type == OBJ_TYPE_EXN))
+                else if ((OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_CLO)
+                         || (OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_CLI)
+                         || (OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_EXN))
                 {
                     pobj1 = (pPmObj_t)((pPmClass_t)pobj1)->cl_attrs;
                 }
                     break;
                 }
                 /* if attrs is not a dict, raise SystemError */
-                if (pobj1->od.od_type != OBJ_TYPE_DIC)
+                if (OBJ_GET_TYPE(*pobj1) != OBJ_TYPE_DIC)
                 {
                     retval = PM_RET_EX_SYS;
                     break;
                 pobj1 = PM_POP();
                 pobj2 = PM_POP();
                 t16 = GET_ARG();
-                if ((pobj1->od.od_type == OBJ_TYPE_INT) &&
-                    (pobj2->od.od_type == OBJ_TYPE_INT))
+                if ((OBJ_GET_TYPE(*pobj1) == OBJ_TYPE_INT) &&
+                    (OBJ_GET_TYPE(*pobj2) == OBJ_TYPE_INT))
                 {
                     S32 a = ((pPmInt_t)pobj2)->val;
                     S32 b = ((pPmInt_t)pobj1)->val;
                 pobj2 = PM_POP();
 
                 /* ensure index is an int */
-                if (pobj1->od.od_type != OBJ_TYPE_INT)
+                if (OBJ_GET_TYPE(*pobj1) != OBJ_TYPE_INT)
                 {
                     retval = PM_RET_EX_INDX;
                     break;
                 }
                 /* dup a const int to allow it to incr (TRASH)*/
-                if (pobj1->od.od_const != 0)
+                if (OBJ_GET_TYPE(*pobj1) != 0)
                 {
                     retval = int_dup(pobj1, &pobj1);
                     PM_BREAK_IF_ERROR(retval);
                 }
 
                 /* if it's a tuple */
-                if (pobj2->od.od_type == OBJ_TYPE_TUP)
+                if (OBJ_GET_TYPE(*pobj2) == OBJ_TYPE_TUP)
                 {
                     /* if tup is exhausted, incr IP by delta */
                     if (((pPmInt_t)pobj1)->val >=
                 }
 
                 /* if it's a list */
-                else if (pobj2->od.od_type == OBJ_TYPE_LST)
+                else if (OBJ_GET_TYPE(*pobj2) == OBJ_TYPE_LST)
                 {
                     /* if list is exhausted, incr IP by delta */
                     if (((pPmInt_t)pobj1)->val >=
                 retval = heap_getChunk(sizeof(PmBlock_t), &pchunk);
                 PM_BREAK_IF_ERROR(retval);
                 pobj1 = (pPmObj_t)pchunk;
-                ((pPmBlock_t)pobj1)->od.od_type = OBJ_TYPE_BLK;
+                OBJ_SET_TYPE(*pobj1, OBJ_TYPE_BLK);
                 /* store current stack pointer */
                 ((pPmBlock_t)pobj1)->b_sp = SP;
                 /* default handler is to exit block/loop */
 
                 /* Raise type error if TOS is not an exception object */
                 pobj1 = PM_POP();
-                if (pobj1->od.od_type != OBJ_TYPE_EXN)
+                if (OBJ_GET_TYPE(*pobj1) != OBJ_TYPE_EXN)
                 {
                     retval = PM_RET_EX_TYPE;
                     break;
                 pobj1 = STACK(t16);
 
                 /* if it's regular func (not native) */
-                if (((pPmFunc_t)pobj1)->f_co->od.od_type ==
+                if (OBJ_GET_TYPE(*((pPmFunc_t)pobj1)->f_co) ==
                     OBJ_TYPE_COB)
                 {
                     /* make frameObj from pCO */
                 }
 
                 /* if it's native func */
-                else if (((pPmFunc_t)pobj1)->f_co->od.od_type ==
+                else if (OBJ_GET_TYPE(*((pPmFunc_t)pobj1)->f_co) ==
                          OBJ_TYPE_NOB)
                 {
                     /* ensure num args fits in native frame */

File src/vm/list.c

     }
 
     /* if pobj1 is not a list, raise a ValueError exception */
-    if (plist->od.od_type != OBJ_TYPE_LST)
+    if (OBJ_GET_TYPE(*plist) != OBJ_TYPE_LST)
     {
         return PM_RET_EX_VAL;
     }
      * if someone else calls, we'll need to check.
      */
     /*
-    if (plist->od.od_type != OBJ_TYPE_LIST)
+    if (OBJ_GET_TYPE(*plist) != OBJ_TYPE_LIST)
     {
         return PM_RET_EX_TYPE;
     }
 
     /* set list type, empty the contents */
     plist = (pPmList_t)*r_pobj;
-    plist->od.od_type = OBJ_TYPE_LST;
+    OBJ_SET_TYPE(*plist, OBJ_TYPE_LST);
     plist->length = 0;
     /* create empty seglist */
     retval = seglist_new(&plist->val);
     }
 
     /* exception if first arg is not a list */
-    if (psrclist->od.od_type != OBJ_TYPE_LST)
+    if (OBJ_GET_TYPE(*psrclist) != OBJ_TYPE_LST)
     {
         return PM_RET_EX_VAL;
     }
     length = ((pPmList_t)psrclist)->length;
 
     /* exception if second arg is not an int */
-    if (pint->od.od_type != OBJ_TYPE_INT)
+    if (OBJ_GET_TYPE(*pint) != OBJ_TYPE_INT)
     {
         return PM_RET_EX_VAL;
     }

File src/vm/module.c

     P_U8 pchunk;
 
     /* if it's not a code obj, raise TypeError */
-    if (pco->od.od_type != OBJ_TYPE_COB)
+    if (OBJ_GET_TYPE(*pco) != OBJ_TYPE_COB)
     {
         return PM_RET_EX_TYPE;
     }
     retval = heap_getChunk(sizeof(PmFunc_t), &pchunk);
     PM_RETURN_IF_ERROR(retval);
     *pmod = (pPmObj_t)pchunk;
-    (*pmod)->od.od_type = OBJ_TYPE_MOD;
+    OBJ_SET_TYPE(**pmod, OBJ_TYPE_MOD);
     ((pPmFunc_t)*pmod)->f_co = (pPmCo_t)pco;
 
     /* alloc and init attrs dict */
     pPmObj_t pobj;
 
     /* if it's not a string obj, raise SyntaxError */
-    if (pstr->od.od_type != OBJ_TYPE_STR)
+    if (OBJ_GET_TYPE(*pstr) != OBJ_TYPE_STR)
     {
         return PM_RET_EX_SYNTAX;
     }

File src/vm/obj.c

  * Log
  * ---
  *
+ * 2006/09/20   #35: Macroize all operations on object descriptors
  * 2006/08/31   #9: Fix BINARY_SUBSCR for case stringobj[intobj]
  * 2006/08/29   #15 - All mem_*() funcs and pointers in the vm should use
  *              unsigned not signed or void
             PM_RETURN_IF_ERROR(retval);
 
             /* Set the object's type */
-            (*r_pobj)->od.od_type = od.od_type;
+            OBJ_SET_TYPE(**r_pobj, od.od_type);
 
             /* Read in the object's value (little endian) */
             ((pPmInt_t)*r_pobj)->val = mem_getInt(memspace, paddr);
 obj_isType(pPmObj_t pobj, PmType_t type)
 {
     /* if null pointer or wrong type... */
-    if ((pobj == C_NULL) || (pobj->od.od_type != type))
+    if ((pobj == C_NULL) || (OBJ_GET_TYPE(*pobj) != type))
     {
         return C_FALSE;
     }
 {
     /* return true if it's NULL or None */
     if ((pobj == C_NULL) ||
-        (pobj->od.od_type == OBJ_TYPE_NON))
+        (OBJ_GET_TYPE(*pobj) == OBJ_TYPE_NON))
     {
         return C_TRUE;
     }
 
     /* the integer zero is false */
-    if ((pobj->od.od_type == OBJ_TYPE_INT) &&
+    if ((OBJ_GET_TYPE(*pobj) == OBJ_TYPE_INT) &&
         (((pPmInt_t)pobj)->val == 0))
     {
         return C_TRUE;
 
     /* the floating point value of 0.0 is false */
     /*
-    if ((pobj->od.od_type == OBJ_TYPE_FLT) &&
+    if ((OBJ_GET_TYPE(*pobj) == OBJ_TYPE_FLT) &&
         (((pPmFloat)pobj)->val == 0.0))
     {
         retrun C_TRUE;
     */
 
     /* an empty string is false */
-    if (pobj->od.od_type == OBJ_TYPE_STR)
+    if (OBJ_GET_TYPE(*pobj) == OBJ_TYPE_STR)
     {
         /* XXX this is for null-term string */
         return ((pPmString_t)pobj)->val[0] == C_NULL;
     }
 
     /* if types are different, return false */
-    if (pobj1->od.od_type != pobj2->od.od_type)
+    if (OBJ_GET_TYPE(*pobj1) != OBJ_GET_TYPE(*pobj2))
     {
         return C_DIFFER;
     }
 
     /* else handle types individually */
-    switch (pobj1->od.od_type)
+    switch (OBJ_GET_TYPE(*pobj1))
     {
         case OBJ_TYPE_NON:
             return C_SAME;

File src/vm/obj.h

  * Log
  * ---
  *
+ * 2006/09/20   #35: Macroize all operations on object descriptors
  * 2006/08/31   #9: Fix BINARY_SUBSCR for case stringobj[intobj]
  * 2006/08/29   #15 - All mem_*() funcs and pointers in the vm should use
  *              unsigned not signed or void
  * Macros
  **************************************************************/
 
+#define OBJ_IS_CONST(obj) ((obj).od.od_const != (U8)0)
+#define OBJ_SET_CONST(obj, const) (obj).od.od_const = (const)
+#define OBJ_GET_GCVAL(obj) ((obj).od.od_gcval)
+#define OBJ_SET_GCVAL(obj, gcval) (obj).od.od_gcval = (gcval)
+#define OBJ_GET_SIZE(obj) ((obj).od.od_size)
+#define OBJ_SET_SIZE(obj, size) (obj).od.od_size = (size)
+#define OBJ_GET_TYPE(obj) ((obj).od.od_type)
+#define OBJ_SET_TYPE(obj, type) (obj).od.od_type = (type)
+
 /***************************************************************
  * Types
  **************************************************************/

File src/vm/seglist.c

         retval = heap_getChunk(sizeof(Segment_t), &pchunk);
         PM_RETURN_IF_ERROR(retval);
         pseg = (pSegment_t)pchunk;
-        pseg->od.od_type = OBJ_TYPE_SEG;
+        OBJ_SET_TYPE(*pseg, OBJ_TYPE_SEG);
         for (i = 1; i < SEGLIST_OBJS_PER_SEG; i++)
         {
             pseg->s_val[i] = C_NULL;
                                (P_U8 *)&pseglist->sl_rootseg
                               );
         PM_RETURN_IF_ERROR(retval);
-        pseglist->sl_rootseg->od.od_type = OBJ_TYPE_SEG;
+        OBJ_SET_TYPE(*pseglist->sl_rootseg, OBJ_TYPE_SEG);
 
         /* seglist refers to the new segment */
         pseglist->sl_lastseg = pseglist->sl_rootseg;
 
                 /* init segment */
                 pseg = pseg->next;
-                pseg->od.od_type = OBJ_TYPE_SEG;
+                OBJ_SET_TYPE(*pseg, OBJ_TYPE_SEG);
                 for (i = 1; i < SEGLIST_OBJS_PER_SEG; i++)
                 {
                     pseg->s_val[i] = C_NULL;
     retval = heap_getChunk(sizeof(Seglist_t), (P_U8 *)r_pseglist);
     PM_RETURN_IF_ERROR(retval);
 
-    (*r_pseglist)->od.od_type = OBJ_TYPE_SGL;
+    OBJ_SET_TYPE(**r_pseglist, OBJ_TYPE_SGL);
     (*r_pseglist)->sl_rootseg = C_NULL;
     (*r_pseglist)->sl_lastseg = C_NULL;
     (*r_pseglist)->sl_lastindx = 0;

File src/vm/string.c

     pstr = (pPmString_t)pchunk;
 
     /* fill the string obj */
-    pstr->od.od_type = OBJ_TYPE_STR;
+    OBJ_SET_TYPE(*pstr, OBJ_TYPE_STR);
     pstr->length = len;
     /* copy C-string into String obj */
     pdst = (P_U8)&(pstr->val);
     mem_copy(memspace, &pdst, paddr, len);
     /* zero-pad end of string */
-    for ( ; pdst < (P_U8)pstr + pstr->od.od_size; pdst++)
+    for ( ; pdst < (P_U8)pstr + OBJ_GET_SIZE(*pstr); pdst++)
     {
         *pdst = 0;
     }
     pstr = (pPmString_t)pchunk;
 
     /* Fill the string obj */
-    pstr->od.od_type = OBJ_TYPE_STR;
+    OBJ_SET_TYPE(*pstr, OBJ_TYPE_STR);
     pstr->length = 1;
     pstr->val[0] = c;
     pstr->val[1] = '\0';
     P_U8 pchunk;
 
     /* ensure string obj */
-    if (pstr->od.od_type != OBJ_TYPE_STR)
+    if (OBJ_GET_TYPE(*pstr) != OBJ_TYPE_STR)
     {
         return PM_RET_EX_TYPE;
     }
                           );
     PM_RETURN_IF_ERROR(retval);
     pnew = (pPmString_t)pchunk;
-    pnew->od.od_const = 0;
-    pnew->od.od_type = OBJ_TYPE_STR;
+    OBJ_SET_CONST(*pnew, 0);
+    OBJ_SET_TYPE(*pnew, OBJ_TYPE_STR);
 #if USE_STRING_CACHE
     /* insert new string obj into cache */
     pnew->next = pstrcache;

File src/vm/tuple.c

     /* allocate a tuple */
     retval = heap_getChunk(size, (P_U8 *)r_ptuple);
     PM_RETURN_IF_ERROR(retval);
-    (*r_ptuple)->od.od_type = OBJ_TYPE_TUP;
+    OBJ_SET_TYPE(**r_ptuple, OBJ_TYPE_TUP);
     /* set the number of objs in the tuple */
     ((pPmTuple_t)*r_ptuple)->length = n;
     /*
     P_U8 psrc;
 
     /* ensure type */
-    if (ptup->od.od_type != OBJ_TYPE_TUP)
+    if (OBJ_GET_TYPE(*ptup) != OBJ_TYPE_TUP)
     {
         return PM_RET_EX_SYS;
     }
 
     /* duplicate src tuple */
-    retval = heap_getChunk(ptup->od.od_size, &pchunk);
+    retval = heap_getChunk(OBJ_GET_SIZE(*ptup), &pchunk);
     PM_RETURN_IF_ERROR(retval);
     pnew = (pPmTuple_t)pchunk;
 
     pdest = (P_U8)pnew;
     psrc = (P_U8)ptup;
-    mem_copy(MEMSPACE_RAM, &pdest, &psrc, ptup->od.od_size);
+    mem_copy(MEMSPACE_RAM, &pdest, &psrc, OBJ_GET_SIZE(*ptup));
     *r_ptuple = (pPmObj_t)pnew;
     return PM_RET_OK;
 }