Changeset 8db6c3 in git


Ignore:
Timestamp:
Feb 16, 2011, 2:27:50 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
74a04c7beedec063e096ede7db7df150693f87b2
Parents:
f2df0c30be0677407fbe248dc749715bf5ec0e7f
Message:
blackbox: properties for newstruct

git-svn-id: file:///usr/local/Singular/svn/trunk@13846 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Singular/blackbox.h

    rf2df0c3 r8db6c3  
    3838  void *data;
    3939  /// addtinional gneral properties
    40   char like_lists; // 1:blackbox is only a wrapper for lists
     40  int properties; // bit 0:blackbox is only a wrapper for lists
     41#define  BB_LIKE_LIST(B) ((B)->properties &1)
    4142} ;
    4243/// default procedure blackboxDefaultOp1, to be called as "default:" branch
  • Singular/ipassign.cc

    rf2df0c3 r8db6c3  
    14331433  {
    14341434    /* l[..] = ... */
    1435     if((l->e!=NULL)
    1436     && (((l->rtyp==IDHDL) && (IDTYP((idhdl)l->data)==LIST_CMD))
    1437       || (l->rtyp==LIST_CMD)))
    1438     {
    1439        if (TEST_V_ALLWARN) PrintS("assign list[..]=...\n");
    1440        b=jiAssign_list(l,r);
    1441        if(!b)
    1442        {
    1443          //Print("jjA_L_LIST: - 2 \n");
    1444          if((l->rtyp==IDHDL) && (l->data!=NULL))
    1445          {
    1446            ipMoveId((idhdl)l->data);
    1447            l->attribute=IDATTR((idhdl)l->data);
    1448            l->flag=IDFLAG((idhdl)l->data);
    1449          }
    1450        }
    1451        r->CleanUp();
    1452        Subexpr h;
    1453        while (l->e!=NULL)
    1454        {
    1455          h=l->e->next;
    1456          omFreeBin((ADDRESS)l->e, sSubexpr_bin);
    1457          l->e=h;
    1458        }
    1459        return b;
    1460     }
     1435    if(l->e!=NULL)
     1436    {
     1437      BOOLEAN like_lists=0;
     1438      blackbox *bb=NULL;
     1439      int bt;
     1440      if (((bt=l->rtyp)>MAX_TOK)
     1441      || ((l->rtyp==IDHDL) && ((bt=IDTYP((idhdl)l->data))>MAX_TOK)))
     1442      {
     1443        bb=getBlackboxStuff(bt);
     1444        like_lists=BB_LIKE_LIST(bb);
     1445      }
     1446      else if (((l->rtyp==IDHDL) && (IDTYP((idhdl)l->data)==LIST_CMD))
     1447        || (l->rtyp==LIST_CMD))
     1448      {
     1449        like_lists=2;
     1450      }
     1451      if(like_lists)
     1452      {
     1453        if (TEST_V_ALLWARN) PrintS("assign list[..]=...or similiar\n");
     1454        b=jiAssign_list(l,r);
     1455        if((!b) && (like_lists==2))
     1456        {
     1457          //Print("jjA_L_LIST: - 2 \n");
     1458          if((l->rtyp==IDHDL) && (l->data!=NULL))
     1459          {
     1460            ipMoveId((idhdl)l->data);
     1461            l->attribute=IDATTR((idhdl)l->data);
     1462            l->flag=IDFLAG((idhdl)l->data);
     1463          }
     1464        }
     1465        r->CleanUp();
     1466        Subexpr h;
     1467        while (l->e!=NULL)
     1468        {
     1469          h=l->e->next;
     1470          omFreeBin((ADDRESS)l->e, sSubexpr_bin);
     1471          l->e=h;
     1472        }
     1473        if ((!b) && (like_lists==1))
     1474        {
     1475          // check blackbox/newtype type:
     1476          if(bb->blackbox_Check(bb,l->Data())) return TRUE;
     1477        }
     1478        return b;
     1479      }
     1480    }
     1481    // end of handling elems of list and similiar
    14611482    rl=r->listLength();
    14621483    if (rl==1)
  • Singular/subexpr.cc

    rf2df0c3 r8db6c3  
    10301030      r=STRING_CMD;
    10311031      break;
    1032     case LIST_CMD:
    1033     {
    1034       lists l;
    1035       if (rtyp==IDHDL) l=IDLIST((idhdl)data);
    1036       else             l=(lists)data;
    1037       if ((0<e->start)&&(e->start<=l->nr+1))
    1038       {
    1039         Subexpr tmp=l->m[e->start-1].e;
    1040         l->m[e->start-1].e=e->next;
    1041         r=l->m[e->start-1].Typ();
    1042         e->next=l->m[e->start-1].e;
    1043         l->m[e->start-1].e=tmp;
     1032    default:
     1033    {
     1034      blackbox *b=NULL;
     1035      if (t>MAX_TOK)
     1036      {
     1037        b=getBlackboxStuff(t);
     1038      }
     1039      if ((t==LIST_CMD)||((b!=NULL)&&BB_LIKE_LIST(b)))
     1040      {
     1041        lists l;
     1042        if (rtyp==IDHDL) l=IDLIST((idhdl)data);
     1043        else             l=(lists)data;
     1044        if ((0<e->start)&&(e->start<=l->nr+1))
     1045        {
     1046          Subexpr tmp=l->m[e->start-1].e;
     1047          l->m[e->start-1].e=e->next;
     1048          r=l->m[e->start-1].Typ();
     1049          e->next=l->m[e->start-1].e;
     1050          l->m[e->start-1].e=tmp;
     1051        }
     1052        else
     1053        {
     1054          //Warn("out of range: %d not in 1..%d",e->start,l->nr+1);
     1055          r=NONE;
     1056        }
    10441057      }
    10451058      else
    1046       {
    1047         //Warn("out of range: %d not in 1..%d",e->start,l->nr+1);
    1048         r=NONE;
    1049       }
     1059        Werror("cannot index type %s(%d)",Tok2Cmdname(t),t);
    10501060      break;
    10511061    }
    1052     default:
    1053       Werror("cannot index type %d",t);
    10541062  }
    10551063  return r;
     
    12481256      break;
    12491257    }
    1250     case LIST_CMD:
    1251     {
    1252       lists l=(lists)d;
    1253       if ((0<index)&&(index<=l->nr+1))
    1254       {
    1255         if ((e->next!=NULL)
    1256         && (l->m[index-1].rtyp==STRING_CMD))
    1257         // string[..].Data() modifies sleftv, so let's do it ourself
    1258         {
    1259           char *dd=(char *)l->m[index-1].data;
    1260           int j=e->next->start-1;
    1261           r=(char *)omAllocBin(size_two_bin);
    1262           if ((j>=0) && (j<(int)strlen(dd)))
    1263           {
    1264             r[0]=*(dd+j);
    1265             r[1]='\0';
     1258    default:
     1259    {
     1260      blackbox *b=NULL;
     1261      if (t>MAX_TOK)
     1262      {
     1263        b=getBlackboxStuff(t);
     1264      }
     1265      if ((t==LIST_CMD)||((b!=NULL)&&(BB_LIKE_LIST(b))))
     1266      {
     1267        lists l=(lists)d;
     1268        if ((0<index)&&(index<=l->nr+1))
     1269        {
     1270          if ((e->next!=NULL)
     1271          && (l->m[index-1].rtyp==STRING_CMD))
     1272          // string[..].Data() modifies sleftv, so let's do it ourself
     1273          {
     1274            char *dd=(char *)l->m[index-1].data;
     1275            int j=e->next->start-1;
     1276            r=(char *)omAllocBin(size_two_bin);
     1277            if ((j>=0) && (j<(int)strlen(dd)))
     1278            {
     1279              r[0]=*(dd+j);
     1280              r[1]='\0';
     1281            }
     1282            else
     1283            {
     1284              r[0]='\0';
     1285            }
    12661286          }
    12671287          else
    12681288          {
    1269             r[0]='\0';
    1270           }
    1271         }
    1272         else
    1273         {
    1274           Subexpr tmp=l->m[index-1].e;
    1275           l->m[index-1].e=e->next;
    1276           r=(char *)l->m[index-1].Data();
    1277           e->next=l->m[index-1].e;
    1278           l->m[index-1].e=tmp;
    1279         }
    1280       }
    1281       else //if (!errorreported)
    1282         Werror("wrong range[%d] in list(%d)",index,l->nr+1);
     1289            Subexpr tmp=l->m[index-1].e;
     1290            l->m[index-1].e=e->next;
     1291            r=(char *)l->m[index-1].Data();
     1292            e->next=l->m[index-1].e;
     1293            l->m[index-1].e=tmp;
     1294          }
     1295        }
     1296        else //if (!errorreported)
     1297          Werror("wrong range[%d] in list(%d)",index,l->nr+1);
     1298      }
     1299      else
     1300        Werror("cannot index type %s(%d)",Tok2Cmdname(t),t);
    12831301      break;
    12841302    }
    1285 #ifdef TEST
    1286     default:
    1287       Werror("cannot index type %s(%d)",Tok2Cmdname(t),t);
    1288 #endif
    12891303  }
    12901304  return r;
Note: See TracChangeset for help on using the changeset viewer.