[BACK]Return to option.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / Kan

Annotation of OpenXM/src/kan96xx/Kan/option.c, Revision 1.3

1.3     ! takayama    1: /* $OpenXM: OpenXM/src/kan96xx/Kan/option.c,v 1.2 1999/11/07 13:24:19 takayama Exp $ */
1.1       maekawa     2: #include <stdio.h>
                      3: #include "datatype.h"
                      4: #include "stackm.h"
                      5: #include "extern.h"
                      6: #include "gradedset.h"
                      7: #include "kclass.h"
                      8: #include "lookup.h"
                      9: #include <signal.h>
                     10:
                     11: extern void ctrlC();
                     12:
                     13:
                     14: struct object KsystemVariable(ob)
                     15: struct object ob; /* Sarray */
                     16: {
                     17:   /* Don't forget to write the keys in usage.c */
                     18:   extern int PrintDollar;
                     19:   extern int Wrap;
                     20:   extern struct ring *CurrentRingp;
                     21:   extern int Verbose;
                     22:   extern int UseCriterion1;
                     23:   extern int UseCriterion2B;
                     24:   extern int ReduceLowerTerms;
                     25:   extern int CheckHomogenization;
                     26:   extern int Homogenize;
                     27:   extern int Statistics;
1.3     ! takayama   28:   extern int AutoReduce;
1.1       maekawa    29:   extern int Osp;
                     30:   extern struct operandStack StandardStack;
                     31:   extern struct operandStack ErrorStack;
                     32:   extern int ErrorMessageMode;
                     33:   extern int WarningMessageMode;
                     34:   extern int CatchCtrlC;
                     35:   extern int Strict;
                     36:   extern struct context *CurrentContextp;
                     37:   extern struct context *PrimitiveContextp;
                     38:   extern int Strict2;
                     39:   extern int SigIgn;
                     40:   extern int KSPushEnvMode;
                     41:   extern int KanGBmessage;
                     42:   extern int TimerOn;
                     43:   extern int OutputStyle;
                     44:   extern int Sugar;
                     45:   extern int Homogenize_vec;
                     46:   extern int CmoDMSOutputOption;
                     47:   extern int DebugReductionRed; /* hidden option */
                     48:   extern char *VersionString;
                     49:   extern int AvoidTheSameRing;
1.2       takayama   50:   extern char *LeftBracket;
                     51:   extern char *RightBracket;
1.1       maekawa    52:
                     53:   int n,i;
                     54:   struct object ob1,ob2,ob3,ob4;
                     55:   struct object rob = NullObject;
                     56:   switch (getoaSize(ob)) {
                     57:   case 1:   /* get the value */
                     58:     ob1 = getoa(ob,0);
                     59:     switch(ob1.tag) {
                     60:     case Sdollar:
                     61:       if (strcmp(ob1.lc.str,"PrintDollar") == 0) {
                     62:        rob = KpoInteger(PrintDollar);
                     63:       }else if (strcmp(ob1.lc.str,"Wrap") == 0) {
                     64:        rob = KpoInteger(Wrap);
                     65:       }else if (strcmp(ob1.lc.str,"P") == 0) {
                     66:        rob = KpoInteger(CurrentRingp->p);
                     67:       }else if (strcmp(ob1.lc.str,"N") == 0) {
                     68:        rob = KpoInteger(CurrentRingp->n);
                     69:       }else if (strcmp(ob1.lc.str,"NN") == 0) {
                     70:        rob = KpoInteger(CurrentRingp->nn);
                     71:       }else if (strcmp(ob1.lc.str,"M") == 0) {
                     72:        rob = KpoInteger(CurrentRingp->m);
                     73:       }else if (strcmp(ob1.lc.str,"MM") == 0) {
                     74:        rob = KpoInteger(CurrentRingp->mm);
                     75:       }else if (strcmp(ob1.lc.str,"L") == 0) {
                     76:        rob = KpoInteger(CurrentRingp->l);
                     77:       }else if (strcmp(ob1.lc.str,"LL") == 0) {
                     78:        rob = KpoInteger(CurrentRingp->ll);
                     79:       }else if (strcmp(ob1.lc.str,"C") == 0) {
                     80:        rob = KpoInteger(CurrentRingp->c);
                     81:       }else if (strcmp(ob1.lc.str,"CC") == 0) {
                     82:        rob = KpoInteger(CurrentRingp->cc);
                     83:       }else if (strcmp(ob1.lc.str,"CurrentRingp") == 0) {
                     84:        rob = KpoRingp(CurrentRingp);
                     85:       }else if (strcmp(ob1.lc.str,"Verbose") == 0) {
                     86:        rob = KpoInteger(Verbose);
                     87:       }else if (strcmp(ob1.lc.str,"UseCriterion1") == 0) {
                     88:        rob = KpoInteger(UseCriterion1);
                     89:       }else if (strcmp(ob1.lc.str,"UseCriterion2B") == 0) {
                     90:        rob = KpoInteger(UseCriterion2B);
                     91:       }else if (strcmp(ob1.lc.str,"ReduceLowerTerms") == 0) {
                     92:        rob = KpoInteger(ReduceLowerTerms);
                     93:       }else if (strcmp(ob1.lc.str,"CheckHomogenization") == 0) {
                     94:        rob = KpoInteger(CheckHomogenization);
                     95:       }else if (strcmp(ob1.lc.str,"Homogenize") == 0) {
                     96:        rob = KpoInteger(Homogenize);
                     97:       }else if (strcmp(ob1.lc.str,"Statistics") == 0) {
                     98:        rob = KpoInteger(Statistics);
1.3     ! takayama   99:       }else if (strcmp(ob1.lc.str,"AutoReduce") == 0) {
        !           100:        rob = KpoInteger(AutoReduce);
1.1       maekawa   101:       }else if (strcmp(ob1.lc.str,"StackPointer") == 0) {
                    102:        rob = KpoInteger(Osp);
                    103:       }else if (strcmp(ob1.lc.str,"StandardOperandStack") == 0) {
                    104:        rob.tag = Sclass;
                    105:        rob.lc.ival = CLASSNAME_OPERANDSTACK;
                    106:        rob.rc.voidp = &StandardStack;
                    107:       }else if (strcmp(ob1.lc.str,"ErrorStack") == 0) {
                    108:        rob.tag = Sclass;
                    109:        rob.lc.ival = CLASSNAME_OPERANDSTACK;
                    110:        rob.rc.voidp = &ErrorStack;
                    111:       }else if (strcmp(ob1.lc.str,"ErrorMessageMode") == 0) {
                    112:        rob = KpoInteger(ErrorMessageMode);
                    113:       }else if (strcmp(ob1.lc.str,"WarningMessageMode") == 0) {
                    114:        rob = KpoInteger(WarningMessageMode);
                    115:       }else if (strcmp(ob1.lc.str,"CatchCtrlC") == 0) {
                    116:        rob = KpoInteger(CatchCtrlC);
                    117:        /* If you catch ctrlc in KSexecuteString. */
                    118:       }else if (strcmp(ob1.lc.str,"Strict") == 0) {
                    119:        rob = KpoInteger(Strict);
                    120:       }else if (strcmp(ob1.lc.str,"CurrentContextp") == 0) {
                    121:        rob.tag = Sclass;
                    122:        rob.lc.ival = CLASSNAME_CONTEXT;
                    123:        rob.rc.voidp = CurrentContextp;
                    124:       }else if (strcmp(ob1.lc.str,"PrimitiveContextp") == 0) {
                    125:        rob.tag = Sclass;
                    126:        rob.lc.ival = CLASSNAME_CONTEXT;
                    127:        rob.rc.voidp = PrimitiveContextp;
                    128:       }else if (strcmp(ob1.lc.str,"NullContextp") == 0) {
                    129:        rob.tag = Sclass;
                    130:        rob.lc.ival = CLASSNAME_CONTEXT;
                    131:        rob.rc.voidp = (struct context *)NULL;
                    132:       }else if (strcmp(ob1.lc.str,"Strict2") == 0) {
                    133:        rob = KpoInteger(Strict2);
                    134:       }else if (strcmp(ob1.lc.str,"SigIgn") == 0) {
                    135:        rob = KpoInteger(SigIgn);
                    136:       }else if (strcmp(ob1.lc.str,"KSPushEnvMode") == 0) {
                    137:        rob = KpoInteger(KSPushEnvMode);
                    138:       }else if (strcmp(ob1.lc.str,"KanGBmessage") == 0) {
                    139:        rob = KpoInteger(KanGBmessage);
                    140:       }else if (strcmp(ob1.lc.str,"TimerOn") == 0) {
                    141:        rob = KpoInteger(TimerOn);
                    142:       }else if (strcmp(ob1.lc.str,"orderMatrix") == 0) {
                    143:        rob = KgetOrderMatrixOfCurrentRing();
                    144:       }else if (strcmp(ob1.lc.str,"gbListTower") == 0) {
                    145:        if (CurrentRingp->gbListTower == NULL) rob = NullObject;
                    146:        else rob = *((struct object *)(CurrentRingp->gbListTower));
                    147:       }else if (strcmp(ob1.lc.str,"outputOrder") == 0) {
                    148:        n = CurrentRingp->n;
                    149:        ob1 = newObjectArray(n*2);
                    150:        for (i=0; i<2*n; i++) {
                    151:          putoa(ob1,i,KpoInteger(CurrentRingp->outputOrder[i]));
                    152:        }
                    153:        rob = ob1;
                    154:       }else if (strcmp(ob1.lc.str,"multSymbol") == 0) {
                    155:        rob = KpoInteger(OutputStyle);
                    156:       }else if (strcmp(ob1.lc.str,"Sugar") == 0) {
                    157:        rob = KpoInteger(Sugar);
                    158:       }else if (strcmp(ob1.lc.str,"Homogenize_vec") == 0) {
                    159:        rob = KpoInteger(Homogenize_vec);
                    160:       }else if (strcmp(ob1.lc.str,"Schreyer")==0) {
                    161:        rob = KpoInteger( CurrentRingp->schreyer );
                    162:       }else if (strcmp(ob1.lc.str,"ringName")==0) {
                    163:        rob = KpoString( CurrentRingp->name );
                    164:       }else if (strcmp(ob1.lc.str,"CmoDMSOutputOption")==0) {
                    165:        rob = KpoInteger( CmoDMSOutputOption );
                    166:       }else if (strcmp(ob1.lc.str,"Version")==0) {
                    167:        rob = KpoString(VersionString);
                    168:       }else if (strcmp(ob1.lc.str,"RingStack")==0) {
                    169:        KsetUpRing(NullObject,NullObject,NullObject,NullObject,NullObject);
                    170:        rob = KSpop(); /* This is exceptional style */
                    171:       }else if (strcmp(ob1.lc.str,"AvoidTheSameRing")==0) {
                    172:        rob = KpoInteger(AvoidTheSameRing);
1.2       takayama  173:       }else if (strcmp(ob1.lc.str,"LeftBracket")==0) {
                    174:        rob = KpoString(LeftBracket);
                    175:       }else if (strcmp(ob1.lc.str,"RightBracket")==0) {
                    176:        rob = KpoString(RightBracket);
1.1       maekawa   177:       }else{
                    178:        warningKan("KsystemVariable():Unknown key word.\n");
                    179:       }
                    180:       break;
                    181:     default:
                    182:       warningKan("KsystemVariable():Invalid argument\n");
                    183:       break;
                    184:     }
                    185:     break;
                    186:   case 2: /* set value */
                    187:     ob1 = getoa(ob,0);
                    188:     ob2 = getoa(ob,1);
                    189:     switch (Lookup[ob1.tag][ob2.tag]) {
                    190:     case SdollarSinteger:
                    191:       if (strcmp(ob1.lc.str,"PrintDollar") == 0) {
                    192:        PrintDollar = ob2.lc.ival;
                    193:        rob = KpoInteger(PrintDollar);
                    194:       }else if (strcmp(ob1.lc.str,"Wrap") == 0) {
                    195:        Wrap = ob2.lc.ival;
                    196:        rob = KpoInteger(Wrap);
                    197:       /*}else if (strcmp(ob1.lc.str,"P") == 0) {
                    198:        P = ob2.lc.ival;  Q should be set here too.
                    199:        CurrentRingp->p = P;
                    200:        rob = KpoInteger(P); */
                    201:       }else if (strcmp(ob1.lc.str,"NN") == 0) {
                    202:        if (ob2.lc.ival <= CurrentRingp->n && ob2.lc.ival >= CurrentRingp->m) {
                    203:          CurrentRingp->nn = ob2.lc.ival;
                    204:        }else{
                    205:          warningKan("New value of NN is out of bound.");
                    206:        }
                    207:        rob = KpoInteger(ob1.lc.ival);
                    208:       }else if (strcmp(ob1.lc.str,"Verbose") == 0) {
                    209:        Verbose = ob2.lc.ival;
                    210:        rob = KpoInteger(Verbose);
                    211:       }else if (strcmp(ob1.lc.str,"UseCriterion1") == 0) {
                    212:        UseCriterion1 = ob2.lc.ival;
                    213:        rob = KpoInteger(UseCriterion1);
                    214:       }else if (strcmp(ob1.lc.str,"UseCriterion2B") == 0) {
                    215:        UseCriterion2B = ob2.lc.ival;
                    216:        rob = KpoInteger(UseCriterion2B);
                    217:       }else if (strcmp(ob1.lc.str,"ReduceLowerTerms") == 0) {
                    218:        ReduceLowerTerms = ob2.lc.ival;
                    219:        rob = KpoInteger(ReduceLowerTerms);
                    220:       }else if (strcmp(ob1.lc.str,"CheckHomogenization") == 0) {
                    221:        CheckHomogenization = ob2.lc.ival;
                    222:        rob = KpoInteger(CheckHomogenization);
                    223:       }else if (strcmp(ob1.lc.str,"Homogenize") == 0) {
                    224:        Homogenize = ob2.lc.ival;
                    225:        rob = KpoInteger(Homogenize);
                    226:       }else if (strcmp(ob1.lc.str,"Statistics") == 0) {
                    227:        Statistics = ob2.lc.ival;
                    228:        rob = KpoInteger(Statistics);
1.3     ! takayama  229:       }else if (strcmp(ob1.lc.str,"AutoReduce") == 0) {
        !           230:        AutoReduce = ob2.lc.ival;
        !           231:        rob = KpoInteger(AutoReduce);
1.1       maekawa   232:       }else if (strcmp(ob1.lc.str,"ErrorMessageMode") == 0) {
                    233:        ErrorMessageMode = ob2.lc.ival;
                    234:        rob = KpoInteger(ErrorMessageMode);
                    235:       }else if (strcmp(ob1.lc.str,"WarningMessageMode") == 0) {
                    236:        WarningMessageMode = ob2.lc.ival;
                    237:        rob = KpoInteger(WarningMessageMode);
                    238:       }else if (strcmp(ob1.lc.str,"CatchCtrlC") == 0) {
                    239:        CatchCtrlC = ob2.lc.ival;
                    240:        rob = KpoInteger(CatchCtrlC);
                    241:       }else if (strcmp(ob1.lc.str,"Strict") == 0) {
                    242:        Strict = ob2.lc.ival;
                    243:        rob = KpoInteger(Strict);
                    244:       }else if (strcmp(ob1.lc.str,"Strict2") == 0) {
                    245:        Strict2 = ob2.lc.ival;
                    246:        rob = KpoInteger(Strict2);
                    247:       }else if (strcmp(ob1.lc.str,"SigIgn") == 0) {
                    248:        SigIgn = ob2.lc.ival;
                    249:        if (SigIgn) signal(SIGINT,SIG_IGN);
                    250:        else signal(SIGINT,ctrlC);
                    251:        rob = KpoInteger(SigIgn);
                    252:       }else if (strcmp(ob1.lc.str,"KSPushEnvMode") == 0) {
                    253:        KSPushEnvMode = ob2.lc.ival;
                    254:        rob = KpoInteger(KSPushEnvMode);
                    255:       }else if (strcmp(ob1.lc.str,"KanGBmessage") == 0) {
                    256:        KanGBmessage = ob2.lc.ival;
                    257:        rob = KpoInteger(KanGBmessage);
                    258:       }else if (strcmp(ob1.lc.str,"TimerOn") == 0) {
                    259:        TimerOn = ob2.lc.ival;
                    260:        rob = KpoInteger(TimerOn);
                    261:       }else if (strcmp(ob1.lc.str,"multSymbol") == 0) {
                    262:        OutputStyle = KopInteger(ob2);
                    263:        rob = KpoInteger(OutputStyle);
                    264:       }else if (strcmp(ob1.lc.str,"Sugar") == 0) {
                    265:        Sugar = KopInteger(ob2);
                    266:        if (Sugar && ReduceLowerTerms) {
                    267:          ReduceLowerTerms = 0;
                    268:          warningKan("ReduceLowerTerms is automatically set to 0, because Sugar = 1.");
                    269:          /* You cannot use both ReduceLowerTerms and sugar.
                    270:             See gb.c, reduction_sugar. */
                    271:        }
                    272:        rob = KpoInteger(Sugar);
                    273:       }else if (strcmp(ob1.lc.str,"Homogenize_vec") == 0) {
                    274:        Homogenize_vec = KopInteger(ob2);
                    275:        rob = KpoInteger(Homogenize_vec);
                    276:       }else if (strcmp(ob1.lc.str,"CmoDMSOutputOption") == 0) {
                    277:        CmoDMSOutputOption = KopInteger(ob2);
                    278:        rob = KpoInteger(CmoDMSOutputOption);
                    279:       }else if (strcmp(ob1.lc.str,"DebugReductionRed") == 0) {
                    280:        DebugReductionRed = KopInteger(ob2);
                    281:        rob = KpoInteger(DebugReductionRed);
                    282:       }else if (strcmp(ob1.lc.str,"AvoidTheSameRing") == 0) {
                    283:        AvoidTheSameRing = KopInteger(ob2);
                    284:        rob = KpoInteger(AvoidTheSameRing);
                    285:       }else{
                    286:        warningKan("KsystemVariable():Unknown key word.\n");
                    287:       }
                    288:       break;
                    289:     case SdollarSdollar:
                    290:       if (strcmp(ob1.lc.str,"ringName") == 0) {
                    291:        CurrentRingp->name = KopString(ob2);
                    292:        rob = KpoString(CurrentRingp->name);
1.2       takayama  293:       }else if (strcmp(ob1.lc.str,"LeftBracket") == 0) {
                    294:        LeftBracket = KopString(ob2);
                    295:        rob = KpoString(LeftBracket);
                    296:       }else if (strcmp(ob1.lc.str,"RightBracket") == 0) {
                    297:        RightBracket = KopString(ob2);
                    298:        rob = KpoString(RightBracket);
1.1       maekawa   299:       }else{
                    300:        warningKan("KsystemVariable():Unknown key word.\n");
                    301:       }
                    302:       break;
                    303:     case SdollarSring:
                    304:       if (strcmp(ob1.lc.str,"CurrentRingp") == 0) {
                    305:        CurrentRingp = ob2.lc.ringp;
                    306:        rob = KpoRingp(CurrentRingp);
                    307:       }else{
                    308:        warningKan("KsystemVariable():Unknown key word.\n");
                    309:       }
                    310:       break;
                    311:     case SdollarSclass:
                    312:       if (strcmp(ob1.lc.str,"PrimitiveContextp") == 0) {
                    313:        if (ectag(ob2) == CLASSNAME_CONTEXT) {
                    314:          PrimitiveContextp = (struct context *)ob2.rc.voidp;
                    315:          rob = ob2;
                    316:        }else{
                    317:          warningKan("The second argument must be class.context.\n");
                    318:          rob = NullObject;
                    319:        }
                    320:       }else {
                    321:        warningKan("KsystemVariable():Unknown key word.\n");
                    322:       }
                    323:       break;
                    324:     case SdollarSlist:
                    325:       if (strcmp(ob1.lc.str,"gbListTower") == 0) {
                    326:        if (AvoidTheSameRing)
                    327:          warningKan("Changing gbListTower may cause a trouble under AvoidTheSameRing == 1.");
                    328:        CurrentRingp->gbListTower = newObject();
                    329:        *((struct object *)(CurrentRingp->gbListTower)) = ob2;
                    330:        rob = *((struct object *)(CurrentRingp->gbListTower));
                    331:       }else {
                    332:        warningKan("KsystemVariable(): Unknown key word to set value.\n");
                    333:       }
                    334:       break;
                    335:     case SdollarSarray:
                    336:       if (strcmp(ob1.lc.str,"outputOrder") == 0) {
                    337:        rob = KsetOutputOrder(ob2,CurrentRingp);
                    338:       }else if (strcmp(ob1.lc.str,"variableNames") == 0) {
                    339:        rob = KsetVariableNames(ob2,CurrentRingp);
                    340:       }else {
                    341:        warningKan("KsystemVariable(): Unknown key word to set value.\n");
                    342:       }
                    343:       break;
                    344:     default:
                    345:       warningKan("KsystemVariable():Invalid argument.\n");
                    346:     }
                    347:     break;
                    348:   case 3:
                    349:     ob1 = getoa(ob,0); ob2 = getoa(ob,1); ob3 = getoa(ob,2);
                    350:     switch(Lookup[ob1.tag][ob2.tag]) {
                    351:     case SdollarSdollar:
                    352:       if (strcmp(ob2.lc.str,"var") == 0) {
                    353:        if (strcmp(ob1.lc.str,"x")==0) {
                    354:          if (ob3.tag != Sinteger) {
                    355:            warningKan("[$x$ $var$ ? ] The 3rd argument must be integer.");
                    356:            break;
                    357:          }
                    358:          if (ob3.lc.ival >= 0 && ob3.lc.ival < CurrentRingp->n) {
                    359:            rob = KpoString(CurrentRingp->x[ob3.lc.ival]);
                    360:          }else{
                    361:            warningKan("[$x$ $var$ ? ] The 3rd argument is out of range.");
                    362:            break;
                    363:          }
                    364:        }else if (strcmp(ob1.lc.str,"D")==0) {
                    365:          if (ob3.tag != Sinteger) {
                    366:            warningKan("[$D$ $var$ ? ] The 3rd argument must be integer.");
                    367:            break;
                    368:          }
                    369:          if (ob3.lc.ival >= 0 && ob3.lc.ival < CurrentRingp->n) {
                    370:            rob = KpoString(CurrentRingp->D[ob3.lc.ival]);
                    371:          }else{
                    372:            warningKan("[$D$ $var$ ? ] The 3rd argument is out of range.");
                    373:            break;
                    374:          }
                    375:        }
                    376:       }else{
                    377:        warningKan("KsystemVariable(): Invalid argument.\n");
                    378:       }
                    379:       break;
                    380:     default:
                    381:       warningKan("KsystemVariable(): Invalid argument.\n");
                    382:       break;
                    383:     }
                    384:     break;
                    385:   default:
                    386:     warningKan("KsystemVariable():Invalid argument.\n");
                    387:     break;
                    388:   }
                    389:   return(rob);
                    390: }
                    391:
                    392: warningOption(str)
                    393: char *str;
                    394: {
                    395:   fprintf(stderr,"Warning(option.c): %s\n",str);
                    396: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>