MCPcopy Create free account
hub / github.com/Singular/Singular / iiBranchTo

Function iiBranchTo

Singular/ipshell.cc:1272–1374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1270 return iiAssign(p,&tmp);
1271}
1272BOOLEAN iiBranchTo(leftv, leftv args)
1273{
1274 // must be inside a proc, as we simultae an proc_end at the end
1275 if (myynest==0)
1276 {
1277 WerrorS("branchTo can only occur in a proc");
1278 return TRUE;
1279 }
1280 // <string1...stringN>,<proc>
1281 // known: args!=NULL, l>=1
1282 int l=args->listLength();
1283 int ll=0;
1284 if (iiCurrArgs!=NULL) ll=iiCurrArgs->listLength();
1285 if (ll!=(l-1)) return FALSE;
1286 leftv h=args;
1287 // set up the table for type test:
1288 short *t=(short*)omAlloc(l*sizeof(short));
1289 t[0]=l-1;
1290 int b;
1291 int i;
1292 for(i=1;i<l;i++,h=h->next)
1293 {
1294 if (h->Typ()!=STRING_CMD)
1295 {
1296 omFreeBinAddr(t);
1297 Werror("arg %d is not a string",i);
1298 return TRUE;
1299 }
1300 int tt;
1301 b=IsCmd((char *)h->Data(),tt);
1302 if(b) t[i]=tt;
1303 else
1304 {
1305 omFreeBinAddr(t);
1306 Werror("arg %d is not a type name",i);
1307 return TRUE;
1308 }
1309 }
1310 if (h->Typ()!=PROC_CMD)
1311 {
1312 omFreeBinAddr(t);
1313 Werror("last(%d.) arg.(%s) is not a proc(but %s(%d)), nesting=%d",
1314 i,h->name,Tok2Cmdname(h->Typ()),h->Typ(),myynest);
1315 return TRUE;
1316 }
1317 b=iiCheckTypes(iiCurrArgs,t,0);
1318 omFreeBinAddr(t);
1319 if (b && (h->rtyp==IDHDL) && (h->e==NULL))
1320 {
1321 // get the proc:
1322 iiCurrProc=(idhdl)h->data;
1323 idhdl currProc=iiCurrProc; /*iiCurrProc may be changed after yyparse*/
1324 procinfo * pi=IDPROC(currProc);
1325 // already loaded ?
1326 if( pi->data.s.body==NULL )
1327 {
1328 iiGetLibProcBuffer(pi);
1329 if (pi->data.s.body==NULL) return TRUE;

Callers

nothing calls this directly

Calls 15

WerrorSFunction · 0.85
WerrorFunction · 0.85
IsCmdFunction · 0.85
iiCheckTypesFunction · 0.85
iiGetLibProcBufferFunction · 0.85
iiCheckPackFunction · 0.85
packFindHdlFunction · 0.85
newBufferFunction · 0.85
WarnFunction · 0.85
omFreeBinFunction · 0.85
myychangebufferFunction · 0.85
killlocalsFunction · 0.85

Tested by

no test coverage detected