[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.1

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

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