Changeset 1cf651 in git


Ignore:
Timestamp:
Dec 3, 2016, 4:16:50 PM (7 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '82fc009ea2b0098c1a4896c841bb70860976bdfc')
Children:
87c92569b5cb08198bbc37755a5a4fc03754d205
Parents:
fd0fccec12bd9cbc6bab5e327f811c7de05c61c9
Message:
fix: return in branchTo
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • Singular/ipshell.cc

    rfd0fcc r1cf651  
    11771177  return iiAssign(p,&tmp);
    11781178}
    1179 BOOLEAN iiBranchTo(leftv, leftv args)
    1180 {
     1179BOOLEAN iiBranchTo(leftv res, leftv args)
     1180{
     1181  // must be inside a proc, as we simultae an proc_end at the end
     1182  if (myynest==0)
     1183  {
     1184    WerrorS("branchTo can only occur in a proc");
     1185    return TRUE;
     1186  }
    11811187  // <string1...stringN>,<proc>
    11821188  // known: args!=NULL, l>=1
     
    11861192  if (ll!=(l-1)) return FALSE;
    11871193  leftv h=args;
     1194  // set up the table for type test:
    11881195  short *t=(short*)omAlloc(l*sizeof(short));
    11891196  t[0]=l-1;
     
    12111218  {
    12121219    omFree(t);
    1213     Werror("last arg (%d) is not a proc",i);
     1220    Werror("last arg (%d) is not a proc(%d), nest=%d",i,h->Typ(),myynest);
    12141221    return TRUE;
    12151222  }
     
    12181225  if (b && (h->rtyp==IDHDL) && (h->e==NULL))
    12191226  {
    1220     BOOLEAN err;
    1221     //Print("branchTo: %s\n",h->Name());
     1227    // get the proc:
    12221228    iiCurrProc=(idhdl)h->data;
    12231229    procinfo * pi=IDPROC(iiCurrProc);
     1230    // already loaded ?
    12241231    if( pi->data.s.body==NULL )
    12251232    {
     
    12271234      if (pi->data.s.body==NULL) return TRUE;
    12281235    }
     1236    // set currPackHdl/currPack
    12291237    if ((pi->pack!=NULL)&&(currPack!=pi->pack))
    12301238    {
     
    12341242      //Print("set pack=%s\n",IDID(currPackHdl));
    12351243    }
    1236     err=iiAllStart(pi,pi->data.s.body,BT_proc,pi->data.s.body_lineno-(iiCurrArgs==NULL));
    1237     exitBuffer(BT_proc);
    1238     myynest--;
     1244    // see iiAllStart:
     1245    BITSET save1=si_opt_1;
     1246    BITSET save2=si_opt_2;
     1247    newBuffer( omStrDup(pi->data.s.body), BT_proc,
     1248               pi, pi->data.s.body_lineno-(iiCurrArgs==NULL) );
     1249    BOOLEAN err=yyparse();
     1250    si_opt_1=save1;
     1251    si_opt_2=save2;
     1252    // now save the return-expr.
     1253    memcpy(res,&iiRETURNEXPR,sizeof(sleftv));
     1254    iiRETURNEXPR.Init();
     1255    // warning about args.:
    12391256    if (iiCurrArgs!=NULL)
    12401257    {
     
    12441261      iiCurrArgs=NULL;
    12451262    }
     1263    // similate proc_end:
     1264    // - leave input
     1265    void myychangebuffer();
     1266    myychangebuffer();
     1267    // - set the current buffer to its end (this is a pointer in a buffer,
     1268    //   not a file ptr) "branchTo" is only valid in proc)
     1269    currentVoice->fptr=strlen(currentVoice->buffer);
     1270    // - kill local vars
     1271    killlocals(myynest);
     1272    // - return
     1273    newBuffer(omStrDup("\n;return();\n"),BT_execute);
    12461274    return (err!=0);
    12471275  }
  • Tst/Short/branchTo.res.gz.uu

    rfd0fcc r1cf651  
    11begin 640 branchTo.res.gz
    2 M'XL("+-/-%@``V)R86YC:%1O+G)E<P!UDDUKPS`,AN_Y%<+LX$`(M==U70,^
    3 MC.U0&!NTO8^T=1O#YH18H8RR_SX['ZHO@^#(TO/*DNSM[F7]#@!"P=OZ&1@Z
    4 MS+_,GA7)=HQ(!=[Y::Q!GA9)^(-2L&]+>ZAV=6[U)7=8(@GN%9`]S_W2M/4!
    5 M&L&-13`I7(%Y:\4R4\`OD0^*2"FXP];8,[B>'C9>X&+!(A)($H@,)E/V8KS4
    6 MH\>%#")S,L[R>,O"4_(N0]E7ZI&'@EG6B)3&(F8!@0@9#F$9&;ZLB)?_\;[=
    7 M")L/V.MF\['AS-8(1WTR5A_A5+>`E78:RO;<?6L_3/QIM&.1>A'4U)P8FN.B
    8 MOS9<@:#(<HBPJ@OR<<!0=00\34#I._*+I^))0E7Z;Z+E[';E4N3]>PE/HG/A
    9 -[+LB^0,GDK8@9@(`````
     2M'XL("!3;0E@``V)R86YC:%1O+G)E<P!U4LMJPS`0O.<K%M&##,:)E$?3&'PH
     3M[2%04DAR;G$2.18TLFM)A&+R[Y4L6Q&%@I'7NS/KW='L]B_K#0"0#-[6SX"4
     4M5,D7/Z!TM.LK-`.3_.2"*QRE(_N&+(-#DXMCN:\2P:Z)5+GRA&D&/IXEYJB;
     5MZ@@UP5PHX!&T@$RT0C%/X>:1\\PC*<%2-5R<079H]V$(,B0L`@+U!!+#$-*.
     6MK*Y5GY&V`XDE#;L\WKO@R&>7=NS6[XCMP"BN2>1E(1,+@0#B?H)B'YBQ`CS]
     7M#V_6#6`S!WO=;M^W&(E*P8D57+`3%%4#JF220=Z<]849,=5/S20*V`O+]LL1
     8MMQPFW;6I%1!?6;H**K6E]P)#J3W@:0#D9B-S&%2H))2Y>08TG60P'D/#E&Y$
     9MI[W21;'R99(XB>6WSAO6^Z!U<,P_C$PWOP,U?NO`QG0X:O]<@>L0I8-`FPHN
     10L3)65E4>+DQG3;T^GG7&QO8293\[NYJ3SI'.V-:^65J6'=/0+A@RJBA`#````
    1011`
    1112end
  • Tst/Short/branchTo.stat

    rfd0fcc r1cf651  
    1 1 >> tst_memory_0 :: 1479823283:4100, 64 bit:4.1.0:x86_64-Linux:nepomuck:108424
    2 1 >> tst_memory_1 :: 1479823283:4100, 64 bit:4.1.0:x86_64-Linux:nepomuck:2228224
    3 1 >> tst_memory_2 :: 1479823283:4100, 64 bit:4.1.0:x86_64-Linux:nepomuck:2228224
    4 1 >> tst_timer_1 :: 1479823283:4100, 64 bit:4.1.0:x86_64-Linux:nepomuck:1
     11 >> tst_memory_0 :: 1480776468:4100, 64 bit:4.1.0:x86_64-Linux:nepomuck:108080
     21 >> tst_memory_1 :: 1480776468:4100, 64 bit:4.1.0:x86_64-Linux:nepomuck:2228224
     31 >> tst_memory_2 :: 1480776468:4100, 64 bit:4.1.0:x86_64-Linux:nepomuck:2228224
     41 >> tst_timer_1 :: 1480776468:4100, 64 bit:4.1.0:x86_64-Linux:nepomuck:1
  • Tst/Short/branchTo.tst

    rfd0fcc r1cf651  
    1414  p("hu");
    1515  p("ha","ha");
     16// returning stuff:
     17proc square(int i){return(i^2);};
     18proc tst(){branchTo("int",square); ERROR("No method found");}
     19tst(2);
    1620
    1721tst_status(1);$;
Note: See TracChangeset for help on using the changeset viewer.