Changeset ea947e in git


Ignore:
Timestamp:
Jul 1, 2010, 11:44:31 AM (14 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
b157872a7e82b6661c4a809febe9ccf834773646
Parents:
5dfa8c02eb88c8d20f6bba3eef61f4d4a24718ee
Message:
alias, variant 1

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

Legend:

Unmodified
Added
Removed
  • Singular/grammar.cc

    r5dfa8c rea947e  
    38683868#line 1595 "grammar.y"
    38693869    {
    3870             //Print("par:%s, %d\n",$2.Name(),$2.Typ());
    3871             //yylineno--;
    3872             if (iiParameter(&(yyvsp[(2) - (2)].lv))) YYERROR;
     3870            // decl. of type proc p(int i)
     3871            if ((yyvsp[(1) - (2)].i)==PARAMETER)  { if (iiParameter(&(yyvsp[(2) - (2)].lv))) YYERROR; }
     3872            else                { if (iiAlias(&(yyvsp[(2) - (2)].lv))) YYERROR; }
    38733873          ;}
    38743874    break;
     
    38773877#line 1601 "grammar.y"
    38783878    {
    3879             //Print("par:%s, %d\n",$2.Name(),$2.Typ());
     3879            // decl. of type proc p(i)
    38803880            sleftv tmp_expr;
    3881             //yylineno--;
     3881            if ((yyvsp[(1) - (2)].i)==ALIAS_CMD) MYYERROR("alias requires a type");
    38823882            if ((iiDeclCommand(&tmp_expr,&(yyvsp[(2) - (2)].lv),myynest,DEF_CMD,&IDROOT))
    38833883            || (iiParameter(&tmp_expr)))
  • Singular/grammar.y

    r5dfa8c rea947e  
    15941594        PARAMETER declare_ip_variable
    15951595          {
    1596             //Print("par:%s, %d\n",$2.Name(),$2.Typ());
    1597             //yylineno--;
    1598             if (iiParameter(&$2)) YYERROR;
     1596            // decl. of type proc p(int i)
     1597            if ($1==PARAMETER)  { if (iiParameter(&$2)) YYERROR; }
     1598            else                { if (iiAlias(&$2)) YYERROR; }
    15991599          }
    16001600        | PARAMETER expr
    16011601          {
    1602             //Print("par:%s, %d\n",$2.Name(),$2.Typ());
     1602            // decl. of type proc p(i)
    16031603            sleftv tmp_expr;
    1604             //yylineno--;
     1604            if ($1==ALIAS_CMD) MYYERROR("alias requires a type");
    16051605            if ((iiDeclCommand(&tmp_expr,&$2,myynest,DEF_CMD,&IDROOT))
    16061606            || (iiParameter(&tmp_expr)))
  • Singular/ipassign.cc

    r5dfa8c rea947e  
    13231323  int rt=NONE;
    13241324  BOOLEAN b;
     1325  if (l->rtyp==ALIAS_CMD)
     1326  {
     1327    Werror("`%s` is read-only",l->Name());
     1328  }
    13251329
    13261330  if(l->attribute!=NULL)
  • Singular/ipid.cc

    r5dfa8c rea947e  
    152152        break;
    153153      case STRING_CMD:
    154         IDSTRING(h) = omStrDup("");
     154        len=1;
    155155        break;
    156156      case LIST_CMD:
     
    465465  }
    466466#ifdef TEST
    467   else if ((IDTYP(h)!= INT_CMD)&&(IDTYP(h)!=DEF_CMD) && (IDTYP(h)!=NONE))
     467  else if ((IDTYP(h)!= INT_CMD)
     468  &&(IDTYP(h)!=DEF_CMD)
     469  &&(IDTYP(h)!=ALIAS_CMD)
     470  &&(IDTYP(h)!=NONE))
    468471    Warn("unknown type to kill: %s(%d)",Tok2Cmdname(IDTYP(h)),IDTYP(h));
    469472#endif
  • Singular/iplib.cc

    r5dfa8c rea947e  
    162162      }
    163163      // copy the result to argstr
    164       strcat(argstr,"parameter ");
     164      if(strncmp(s,"alias ",6)!=0)
     165      {
     166        strcat(argstr,"parameter ");
     167      }
    165168      strcat(argstr,s);
    166169      strcat(argstr,"; ");
  • Singular/ipshell.cc

    r5dfa8c rea947e  
    383383      {
    384384        if (iterate) list1(prefix,h,TRUE,fullname);
     385        if (IDTYP(h)==ALIAS_CMD) PrintS("A");
    385386        if ((IDTYP(h)==RING_CMD)
    386387            || (IDTYP(h)==QRING_CMD)
     
    11431144  omFreeBin((ADDRESS)h, sleftv_bin);
    11441145  return res;
     1146}
     1147BOOLEAN iiAlias(leftv p)
     1148{
     1149  if (iiCurrArgs==NULL)
     1150  {
     1151    Werror("not enough arguments for proc %s",VoiceName());
     1152    p->CleanUp();
     1153    return TRUE;
     1154  }
     1155  leftv h=iiCurrArgs;
     1156  iiCurrArgs=h->next;
     1157  h->next=NULL;
     1158  if (h->rtyp!=IDHDL)
     1159  {
     1160    WerrorS("identifier required");
     1161    return TRUE;
     1162  }
     1163  if (h->Typ()!=p->Typ())
     1164  {
     1165    WerrorS("type mismatch");
     1166    return TRUE;
     1167  }
     1168  idhdl pp=(idhdl)p->data;
     1169  switch(pp->typ)
     1170  {
     1171      case INT_CMD:
     1172        break;
     1173      case INTVEC_CMD:
     1174      case INTMAT_CMD:
     1175         delete IDINTVEC(pp);
     1176         break;
     1177      case NUMBER_CMD:
     1178         nDelete(&IDNUMBER(pp));
     1179         break;
     1180      case BIGINT_CMD:
     1181         nlDelete(&IDNUMBER(pp),currRing);
     1182         break;
     1183      case MAP_CMD:
     1184         {
     1185           map im = IDMAP(pp);
     1186           omFree((ADDRESS)im->preimage);
     1187         }
     1188         // continue as ideal:
     1189      case IDEAL_CMD:
     1190      case MODUL_CMD:
     1191      case MATRIX_CMD:
     1192          idDelete(&IDIDEAL(pp));
     1193         break;
     1194      case PROC_CMD:
     1195      case RESOLUTION_CMD:
     1196      case STRING_CMD:
     1197         omFree((ADDRESS)IDSTRING(pp));
     1198         break;
     1199      case LIST_CMD:
     1200         IDLIST(pp)->Clean();
     1201         break;
     1202      case LINK_CMD:
     1203         omFreeBin(IDLINK(pp),sip_link_bin);
     1204         break;
     1205       // case ring: cannot happen
     1206       default:
     1207         Werror("unknown type %d",p->Typ());
     1208         return TRUE;
     1209  }
     1210  pp->typ=ALIAS_CMD;
     1211  IDDATA(pp)=(char*)h->data;
     1212  h->CleanUp();
     1213  omFreeBin((ADDRESS)h, sleftv_bin);
     1214  return FALSE;
    11451215}
    11461216
     
    44204490            R->block1[n] = last;
    44214491            //if ((R->block0[n]>R->block1[n])
    4422             //|| (R->block1[n]>rVar(R)))
    4423             //{
    4424             //  R->block1[n]=rVar(R);
    4425             //  //WerrorS("ordering larger than number of variables");
    4426             //  break;
    4427             //}
     4492            //|| (R->block1[n]>rVar(R)))
     4493            //{
     4494            //  R->block1[n]=rVar(R);
     4495            //  //WerrorS("ordering larger than number of variables");
     4496            //  break;
     4497            //}
    44284498            if (rCheckIV(iv)) return TRUE;
    44294499            for(i=si_min(rVar(R),R->block1[n]);i>=R->block0[n];i--)
  • Singular/ipshell.h

    r5dfa8c rea947e  
    168168
    169169BOOLEAN iiParameter(leftv p);
     170BOOLEAN iiAlias(leftv p);
    170171/* ================================================================== */
    171172int     iiDeclCommand(leftv sy, leftv name, int lev, int t, idhdl* root,
  • Singular/subexpr.cc

    r5dfa8c rea947e  
    281281void sleftv::CleanUp(ring r)
    282282{
    283   if ((name!=NULL) && (name!=sNoName) && (rtyp!=IDHDL))
     283  if ((name!=NULL) && (name!=sNoName) && (rtyp!=IDHDL) && (rtyp!=ALIAS_CMD))
    284284  {
    285285    //::Print("free %x (%s)\n",name,name);
     
    830830    switch (rtyp)
    831831    {
     832      case ALIAS_CMD:
     833         {
     834           idhdl h=(idhdl)data;
     835           return  ((idhdl)h->data.ustring)->typ;
     836         }
    832837      case IDHDL:
    833838        return IDTYP((idhdl)data);
     
    860865  int r=0;
    861866  int t=rtyp;
    862   if (t==IDHDL) t=IDTYP((idhdl)data);
     867  if (t==ALIAS_CMD) { idhdl h=(idhdl)IDDATA((idhdl)data); t=IDTYP(h); }
     868  else if (t==IDHDL) t=IDTYP((idhdl)data);
    863869  switch (t)
    864870  {
     
    950956void * sleftv::Data()
    951957{
     958  if(rtyp==ALIAS_CMD)
     959  {
     960    idhdl h=(idhdl)data;
     961    return  ((idhdl)h->data.ustring)->data.ustring;
     962  }
    952963  if ((rtyp!=IDHDL) && iiCheckRing(rtyp))
    953964     return NULL;
     
    14531464  return;
    14541465id_found: // we have an id (in h) found, to set the data in from h
    1455   v->rtyp = IDHDL;
     1466  if (IDTYP(h)!=ALIAS_CMD)
     1467  {
     1468    v->rtyp = IDHDL;
     1469    v->flag = IDFLAG(h);
     1470    v->attribute=IDATTR(h);
     1471  }
     1472  else
     1473  {
     1474    v->rtyp = ALIAS_CMD;
     1475  }
     1476  v->name = IDID(h);
    14561477  v->data = (char *)h;
    1457   v->flag = IDFLAG(h);
    1458   v->name = IDID(h);
    1459   v->attribute=IDATTR(h);
    14601478  currRingHdl=save_ring;
    14611479}
Note: See TracChangeset for help on using the changeset viewer.