version 1.4, 2001/05/04 01:06:25 |
version 1.26, 2020/10/06 11:33:46 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/primitive.c,v 1.3 2000/02/24 12:33:47 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/primitive.c,v 1.25 2018/09/07 00:15:44 takayama Exp $ */ |
/* primitive.c */ |
/* primitive.c */ |
/* The functions in this module were in stackmachine.c */ |
/* The functions in this module were in stackmachine.c */ |
|
|
#include <stdio.h> |
#include <stdio.h> |
|
#include <stdlib.h> |
|
#include <string.h> |
|
#include <signal.h> |
|
#include <time.h> |
|
#include <unistd.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "stackm.h" |
#include "stackm.h" |
#include "extern.h" |
#include "extern.h" |
|
#include "extern2.h" |
#include "gradedset.h" |
#include "gradedset.h" |
#include "kclass.h" |
#include "kclass.h" |
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/times.h> |
#include <sys/times.h> |
|
#include "mysig.h" |
|
|
int PrintDollar = 1; /* flag for printObject() */ |
int PrintDollar = 1; /* flag for printObject() */ |
int PrintComma = 1; /* flag for printObject() */ |
int PrintComma = 1; /* flag for printObject() */ |
|
int InSendmsg2 = 0; |
#define OB_ARRAY_MAX (AGLIMIT+100) |
#define OB_ARRAY_MAX (AGLIMIT+100) |
|
|
extern int GotoP; |
extern int GotoP; |
Line 23 extern int ClassTypes[]; /* kclass.c */ |
|
Line 31 extern int ClassTypes[]; /* kclass.c */ |
|
extern struct context *PrimitiveContextp; |
extern struct context *PrimitiveContextp; |
extern struct context *CurrentContextp; |
extern struct context *CurrentContextp; |
extern struct dictionary *SystemDictionary; |
extern struct dictionary *SystemDictionary; |
|
extern int QuoteMode; |
|
|
static char *operatorType(int i); |
static char *operatorType(int i); |
|
|
Line 37 static char *operatorType(type) |
|
Line 46 static char *operatorType(type) |
|
return("Unknown operator"); |
return("Unknown operator"); |
} |
} |
|
|
|
#define evalEA(ob1) if (ob1.tag == SexecutableArray) {\ |
|
executeExecutableArray(ob1,(char *)NULL,0); ob1 = Kpop();} |
|
|
/****** primitive functions ***************************************** |
/****** primitive functions ***************************************** |
the values must be greater than 1. 0 is used for special purposes.*/ |
the values must be greater than 1. 0 is used for special purposes.*/ |
#define Sadd 1 |
#define Sadd 1 |
Line 120 static char *operatorType(type) |
|
Line 132 static char *operatorType(type) |
|
#define Ssupmsg2 98 |
#define Ssupmsg2 98 |
#define Scclass 99 |
#define Scclass 99 |
#define Scoeff2 100 |
#define Scoeff2 100 |
|
#define Stlimit 101 |
|
#define Soxshell 102 |
/***********************************************/ |
/***********************************************/ |
void printObject(ob,nl,fp) |
void printObject(ob,nl,fp) |
struct object ob; |
struct object ob; |
Line 192 void printObject(ob,nl,fp) |
|
Line 206 void printObject(ob,nl,fp) |
|
case Sdouble: |
case Sdouble: |
fprintf(fp,"<double> "); |
fprintf(fp,"<double> "); |
break; |
break; |
|
case SbyteArray: |
|
fprintf(fp,"<byteArray> "); |
|
break; |
default: |
default: |
fprintf(fp,"<Unknown object tag. %d >",ob.tag); |
fprintf(fp,"<Unknown object tag. %d >",ob.tag); |
break; |
break; |
Line 266 void printObject(ob,nl,fp) |
|
Line 283 void printObject(ob,nl,fp) |
|
printObjectList(&ob); |
printObjectList(&ob); |
break; |
break; |
case Sfile: |
case Sfile: |
fprintf(fp,"Name=%s, FILE *=%x ",ob.lc.str,(int) ob.rc.file); |
fprintf(fp,"Name=%s, FILE *=%p ",ob.lc.str,ob.rc.file); |
break; |
break; |
case Sring: |
case Sring: |
fprintf(fp,"Ring."); KshowRing(KopRingp(ob)); |
fprintf(fp,"Ring."); KshowRing(KopRingp(ob)); |
Line 286 void printObject(ob,nl,fp) |
|
Line 303 void printObject(ob,nl,fp) |
|
case Sdouble: |
case Sdouble: |
fprintf(fp,"%f",KopDouble(ob)); |
fprintf(fp,"%f",KopDouble(ob)); |
break; |
break; |
|
case SbyteArray: |
|
printObject(byteArrayToArray(ob),nl,fp); /* Todo: I should save memory.*/ |
|
break; |
default: |
default: |
fprintf(fp,"[Unknown object tag.]"); |
fprintf(fp,"[Unknown object tag.]"); |
break; |
break; |
Line 372 void KdefinePrimitiveFunctions() { |
|
Line 392 void KdefinePrimitiveFunctions() { |
|
putPrimitiveFunction("system",Ssystem); |
putPrimitiveFunction("system",Ssystem); |
putPrimitiveFunction("system_variable",Ssystem_variable); |
putPrimitiveFunction("system_variable",Ssystem_variable); |
putPrimitiveFunction("test",Stest); |
putPrimitiveFunction("test",Stest); |
|
putPrimitiveFunction("tlimit",Stlimit); |
|
putPrimitiveFunction("oxshell",Soxshell); |
putPrimitiveFunction("map",Smap); |
putPrimitiveFunction("map",Smap); |
putPrimitiveFunction("to_records",Sto_records); |
putPrimitiveFunction("to_records",Sto_records); |
putPrimitiveFunction("Usage",Susage); |
putPrimitiveFunction("Usage",Susage); |
Line 406 void KdefinePrimitiveFunctions() { |
|
Line 428 void KdefinePrimitiveFunctions() { |
|
int executePrimitive(ob) |
int executePrimitive(ob) |
struct object ob; |
struct object ob; |
{ |
{ |
struct object ob1; |
struct object ob1 = OINIT; |
struct object ob2; |
struct object ob2 = OINIT; |
struct object ob3; |
struct object ob3 = OINIT; |
struct object ob4; |
struct object ob4 = OINIT; |
struct object ob5; |
struct object ob5 = OINIT; |
struct object rob; |
struct object rob = OINIT; |
struct object obArray[OB_ARRAY_MAX]; |
struct object obArray[OB_ARRAY_MAX]; |
struct object obArray2[OB_ARRAY_MAX]; |
struct object obArray2[OB_ARRAY_MAX]; |
int size; |
int size; |
int i,j,k,n; |
int i,j,k,n; |
int status; |
int status; |
|
int infixOn; |
|
struct tokens infixToken; |
struct tokens *tokenArray; |
struct tokens *tokenArray; |
struct tokens token; |
struct tokens token; |
FILE *fp; |
FILE *fp; |
char *fname; |
char *fname; |
int rank; |
int rank; |
struct object oMat; |
struct object oMat = OINIT; |
static int timerStart = 1; |
static int timerStart = 1; |
static struct tms before, after; |
static struct tms before, after; |
static time_t before_real, after_real; |
static time_t before_real, after_real; |
struct object oInput; |
struct object oInput = OINIT; |
char *str; |
char *str; |
int ccflag = 0; |
int ccflag = 0; |
extern int KeepInput; |
extern int KeepInput; |
extern int History; |
extern int History; |
extern struct ring *CurrentRingp; |
extern struct ring *CurrentRingp; |
extern TimerOn; |
extern int TimerOn; |
extern SecureMode; |
extern int SecureMode; |
|
extern int RestrictedMode; |
|
|
|
infixOn = 0; |
|
|
if (DebugStack >= 2) { |
if (DebugStack >= 2) { |
fprintf(Fstack,"In execute %d\n",ob.lc.ival); printOperandStack(); |
fprintf(Fstack,"In execute %d\n",ob.lc.ival); printOperandStack(); |
} |
} |
|
|
|
if (RestrictedMode) { |
|
switch(ob.lc.ival) { |
|
case SleftBrace: |
|
case SrightBrace: |
|
case Sexec: |
|
break; |
|
default: |
|
fprintf(stderr,"primitive No = %d : ", ob.lc.ival); |
|
errorStackmachine("You cannot use this primitive in the RestrictedMode.\n"); |
|
} |
|
} |
|
|
if (GotoP) return(0); |
if (GotoP) return(0); |
switch (ob.lc.ival) { |
switch (ob.lc.ival) { |
/* Postscript primitives :stack */ |
/* Postscript primitives :stack */ |
Line 487 int executePrimitive(ob) |
|
Line 526 int executePrimitive(ob) |
|
} |
} |
Kpush(ob3); |
Kpush(ob3); |
break; |
break; |
|
case SbyteArray: |
|
n = getByteArraySize(ob2); |
|
ob3 = newByteArray(n,ob2); |
|
Kpush(ob3); |
|
break; |
default: |
default: |
Kpush(ob2); |
Kpush(ob2); |
break; |
break; |
Line 529 int executePrimitive(ob) |
|
Line 573 int executePrimitive(ob) |
|
|
|
/* Postscript primitives :arithmetic */ |
/* Postscript primitives :arithmetic */ |
case Sadd: |
case Sadd: |
ob1 = Kpop(); |
ob1 = Kpop(); |
ob2 = Kpop(); |
ob2 = Kpop(); |
|
evalEA(ob1); evalEA(ob2); |
rob = KooAdd(ob1,ob2); |
rob = KooAdd(ob1,ob2); |
Kpush(rob); |
Kpush(rob); |
break; |
break; |
case Ssub: |
case Ssub: |
ob2 = Kpop(); |
ob2 = Kpop(); |
ob1 = Kpop(); |
ob1 = Kpop(); |
|
evalEA(ob1); evalEA(ob2); |
rob = KooSub(ob1,ob2); |
rob = KooSub(ob1,ob2); |
Kpush(rob); |
Kpush(rob); |
break; |
break; |
case Smult: |
case Smult: |
ob2 = Kpop(); |
ob2 = Kpop(); |
ob1 = Kpop(); |
ob1 = Kpop(); |
|
evalEA(ob1); evalEA(ob2); |
rob = KooMult(ob1,ob2); |
rob = KooMult(ob1,ob2); |
Kpush(rob); |
Kpush(rob); |
break; |
break; |
case Sidiv: |
case Sidiv: |
ob2 = Kpop(); ob1 = Kpop(); |
ob2 = Kpop(); ob1 = Kpop(); |
|
evalEA(ob1); evalEA(ob2); |
rob = KooDiv(ob1,ob2); |
rob = KooDiv(ob1,ob2); |
Kpush(rob); |
Kpush(rob); |
break; |
break; |
|
|
case Sdiv: |
case Sdiv: |
ob2 = Kpop(); ob1 = Kpop(); |
ob2 = Kpop(); ob1 = Kpop(); |
|
evalEA(ob1); evalEA(ob2); |
rob = KooDiv2(ob1,ob2); |
rob = KooDiv2(ob1,ob2); |
Kpush(rob); |
Kpush(rob); |
break; |
break; |
Line 589 int executePrimitive(ob) |
|
Line 638 int executePrimitive(ob) |
|
/* ob2 ob1 get */ |
/* ob2 ob1 get */ |
ob1 = Kpop(); |
ob1 = Kpop(); |
ob2 = Kpop(); |
ob2 = Kpop(); |
switch(ob2.tag) { |
Kpush(Kget(ob2,ob1)); |
case Sarray: break; |
|
default: errorStackmachine("Usage:get"); |
|
} |
|
switch(ob1.tag) { |
|
case Sinteger: break; |
|
default: errorStackmachine("Usage:get"); |
|
} |
|
i =ob1.lc.ival; |
|
size = getoaSize(ob2); |
|
if ((0 <= i) && (i<size)) { |
|
Kpush(getoa(ob2,i)); |
|
}else{ |
|
errorStackmachine("Index is out of bound. (get)\n"); |
|
} |
|
break; |
break; |
|
|
case Sput: |
case Sput: |
Line 612 int executePrimitive(ob) |
|
Line 647 int executePrimitive(ob) |
|
/* Or; [[a_00 ....] [a_10 ....] ....] [1 0] any put. MultiIndex. */ |
/* Or; [[a_00 ....] [a_10 ....] ....] [1 0] any put. MultiIndex. */ |
ob1 = Kpop(); ob2 = Kpop(); ob3 = Kpop(); |
ob1 = Kpop(); ob2 = Kpop(); ob3 = Kpop(); |
switch(ob2.tag) { |
switch(ob2.tag) { |
|
case SuniversalNumber: |
|
ob2 = Kto_int32(ob2); /* do not break and go to Sinteger */ |
case Sinteger: |
case Sinteger: |
switch(ob3.tag) { |
switch(ob3.tag) { |
case Sarray: |
case Sarray: |
Line 636 int executePrimitive(ob) |
|
Line 673 int executePrimitive(ob) |
|
errorStackmachine("Index is out of bound. (put)\n"); |
errorStackmachine("Index is out of bound. (put)\n"); |
} |
} |
break; |
break; |
|
case SbyteArray: |
|
i = ob2.lc.ival; |
|
size = getByteArraySize(ob3); |
|
if ((0 <= i) && (i<size)) { |
|
if (ob1.tag != Sinteger) ob1 = Kto_int32(ob1); |
|
if (ob1.tag != Sinteger) errorStackmachine("One can put only integer.\n"); |
|
KopByteArray(ob3)[i] = KopInteger(ob1); |
|
}else{ |
|
errorStackmachine("Index is out of bound. (put)\n"); |
|
} |
|
break; |
default: errorStackmachine("Usage:put"); |
default: errorStackmachine("Usage:put"); |
} |
} |
break; |
break; |
Line 646 int executePrimitive(ob) |
|
Line 694 int executePrimitive(ob) |
|
if (ob5.tag != Sarray) |
if (ob5.tag != Sarray) |
errorStackmachine("Object pointed by the multi-index is not array (put)\n"); |
errorStackmachine("Object pointed by the multi-index is not array (put)\n"); |
ob4 = getoa(ob2,i); |
ob4 = getoa(ob2,i); |
|
if (ob4.tag == SuniversalNumber) ob4 = Kto_int32(ob4); |
if (ob4.tag != Sinteger) |
if (ob4.tag != Sinteger) |
errorStackmachine("Index has to be an integer. (put)\n"); |
errorStackmachine("Index has to be an integer. (put)\n"); |
k = ob4.lc.ival; |
k = ob4.lc.ival; |
Line 706 int executePrimitive(ob) |
|
Line 755 int executePrimitive(ob) |
|
case Spoly: |
case Spoly: |
Kpush(KpoInteger(KpolyLength(KopPOLY(ob1)))); |
Kpush(KpoInteger(KpolyLength(KopPOLY(ob1)))); |
break; |
break; |
|
case SbyteArray: |
|
Kpush(KpoInteger(getByteArraySize(ob1))); |
|
break; |
default: errorStackmachine("Usage:length"); |
default: errorStackmachine("Usage:length"); |
} |
} |
break; |
break; |
Line 747 int executePrimitive(ob) |
|
Line 799 int executePrimitive(ob) |
|
errorStackmachine("Usage:loop"); |
errorStackmachine("Usage:loop"); |
break; |
break; |
} |
} |
tokenArray = ob1.lc.tokenArray; |
|
size = ob1.rc.ival; |
|
i = 0; |
|
while (1) { |
while (1) { |
token = tokenArray[i]; |
status = executeExecutableArray(ob1,(char *)NULL,1); |
/***printf("[token %d]%s\n",i,token.token);*/ |
if ((status & STATUS_BREAK) || GotoP) break; |
i++; |
|
if (i >= size) { |
|
i=0; |
|
} |
|
status = executeToken(token); |
|
if (status || GotoP) break; |
|
/* here, do not return 1. Do not propagate exit signal outside of the |
/* here, do not return 1. Do not propagate exit signal outside of the |
loop. */ |
loop. */ |
} |
} |
Line 796 int executePrimitive(ob) |
|
Line 839 int executePrimitive(ob) |
|
*/ |
*/ |
for ( ; i<=lim; i += inc) { |
for ( ; i<=lim; i += inc) { |
Kpush(KpoInteger(i)); |
Kpush(KpoInteger(i)); |
tokenArray = ob1.lc.tokenArray; |
status = executeExecutableArray(ob1,(char *)NULL,1); |
size = ob1.rc.ival; |
if ((status & STATUS_BREAK) || GotoP) goto xyz; |
for (j=0; j<size; j++) { |
} |
status = executeToken(tokenArray[j]); |
|
if (status || GotoP) goto xyz; |
|
} |
|
} |
|
}else{ |
}else{ |
/* |
/* |
if (lim > i) errorStackmachine("The initial value must not be less than limit value (for).\n"); |
if (lim > i) errorStackmachine("The initial value must not be less than limit value (for).\n"); |
*/ |
*/ |
for ( ; i>=lim; i += inc) { |
for ( ; i>=lim; i += inc) { |
Kpush(KpoInteger(i)); |
Kpush(KpoInteger(i)); |
tokenArray = ob1.lc.tokenArray; |
status = executeExecutableArray(ob1,(char *)NULL,1); |
size = ob1.rc.ival; |
if ((status & STATUS_BREAK) || GotoP) goto xyz; |
for (j=0; j<size; j++) { |
|
status = executeToken(tokenArray[j]); |
|
if (status || GotoP) goto xyz; |
|
} |
|
} |
} |
} |
} |
xyz: ; |
xyz: ; |
Line 845 int executePrimitive(ob) |
|
Line 880 int executePrimitive(ob) |
|
|
|
for (i=0; i<osize; i++) { |
for (i=0; i<osize; i++) { |
Kpush(getoa(ob1,i)); |
Kpush(getoa(ob1,i)); |
tokenArray = ob2.lc.tokenArray; |
status = executeExecutableArray(ob2,(char *)NULL,0); |
size = ob2.rc.ival; |
if (status & STATUS_BREAK) goto foor; |
for (j=0; j<size; j++) { |
|
status = executeToken(tokenArray[j]); |
|
if (status) goto foor; |
|
} |
|
} |
} |
foor: ; |
foor: ; |
/*KSexecuteString("]");*/ |
/*KSexecuteString("]");*/ |
Line 899 int executePrimitive(ob) |
|
Line 930 int executePrimitive(ob) |
|
ob1 = ob2; |
ob1 = ob2; |
} |
} |
/* execute ob1 */ |
/* execute ob1 */ |
tokenArray = ob1.lc.tokenArray; |
status = executeExecutableArray(ob1,(char *)NULL,0); |
size = ob1.rc.ival; |
if (status & STATUS_BREAK) return(status); |
for (i=0; i<size; i++) { |
|
token = tokenArray[i]; |
|
status = executeToken(token); |
|
if (status != 0) return(status); |
|
} |
|
|
|
break; |
break; |
|
|
case Sexec: |
case Sexec: |
Line 916 int executePrimitive(ob) |
|
Line 942 int executePrimitive(ob) |
|
case SexecutableArray: break; |
case SexecutableArray: break; |
default: errorStackmachine("Usage:exec"); |
default: errorStackmachine("Usage:exec"); |
} |
} |
tokenArray = ob1.lc.tokenArray; |
status = executeExecutableArray(ob1,(char *)NULL,0); |
size = ob1.rc.ival; |
|
for (i=0; i<size; i++) { |
|
token = tokenArray[i]; |
|
/***printf("[token %d]%s\n",i,token.token);*/ |
|
status = executeToken(token); |
|
if (status != 0) break; |
|
} |
|
break; |
break; |
|
|
/* Postscript primitives :dictionary */ |
/* Postscript primitives :dictionary */ |
Line 1184 int executePrimitive(ob) |
|
Line 1203 int executePrimitive(ob) |
|
default: errorStackmachine("Usage:system"); |
default: errorStackmachine("Usage:system"); |
} |
} |
if (SecureMode) errorStackmachine("Security violation."); |
if (SecureMode) errorStackmachine("Security violation."); |
system( ob1.lc.str ); |
{int rr; rr=system( ob1.lc.str );} |
break; |
break; |
|
|
case Scat_n: |
case Scat_n: |
Line 1280 int executePrimitive(ob) |
|
Line 1299 int executePrimitive(ob) |
|
KsetOrderByObjArray(ob1); |
KsetOrderByObjArray(ob1); |
break; |
break; |
case Sset_up_ring: |
case Sset_up_ring: |
|
KresetDegreeShift(); |
ob5 = Kpop(); ob4=Kpop(); ob3=Kpop(); ob2=Kpop(); ob1=Kpop(); |
ob5 = Kpop(); ob4=Kpop(); ob3=Kpop(); ob2=Kpop(); ob1=Kpop(); |
KsetUpRing(ob1,ob2,ob3,ob4,ob5); |
KsetUpRing(ob1,ob2,ob3,ob4,ob5); |
break; |
break; |
Line 1357 int executePrimitive(ob) |
|
Line 1377 int executePrimitive(ob) |
|
if (ob2.tag != Sarray) { |
if (ob2.tag != Sarray) { |
Kpush(Khead(ob2)); |
Kpush(Khead(ob2)); |
}else{ |
}else{ |
ob1 = Kpop(); |
if (getoaSize(ob2) > 0) { |
Kpush(oInitW(ob1,ob2)); |
if (getoa(ob2,getoaSize(ob2)-1).tag == Spoly) { |
|
Kpush(oInitW(ob2,newObjectArray(0))); |
|
}else{ |
|
ob1 = Kpop(); |
|
Kpush(oInitW(ob1,ob2)); |
|
} |
|
}else{ |
|
ob1 = Kpop(); |
|
Kpush(oInitW(ob1,ob2)); |
|
} |
} |
} |
break; |
break; |
|
|
Line 1493 int executePrimitive(ob) |
|
Line 1522 int executePrimitive(ob) |
|
} |
} |
/* normal exec. */ |
/* normal exec. */ |
Kpush(ob2); |
Kpush(ob2); |
tokenArray = ob1.lc.tokenArray; |
status = executeExecutableArray(ob1,(char *)NULL,0); |
size = ob1.rc.ival; |
|
for (i=0; i<size; i++) { |
|
token = tokenArray[i]; |
|
status = executeToken(token); |
|
if (status != 0) break; |
|
} |
|
if (ccflag) { |
if (ccflag) { |
contextControl(CCPOP); ccflag = 0; /* recover the Current context. */ |
contextControl(CCPOP); ccflag = 0; /* recover the Current context. */ |
} |
} |
|
|
break; |
break; |
case Ssendmsg2: |
case Ssendmsg2: |
/* ob2 ob4 { .........} sendmsg2 */ |
/* ob2 ob4 { .........} sendmsg2 */ |
Line 1540 int executePrimitive(ob) |
|
Line 1564 int executePrimitive(ob) |
|
} |
} |
/* normal exec. */ |
/* normal exec. */ |
Kpush(ob2); Kpush(ob4); |
Kpush(ob2); Kpush(ob4); |
|
|
|
/* We cannot use executeExecutableArray(ob1,(char *)NULL) because of |
|
the quote mode. Think about it later. */ |
tokenArray = ob1.lc.tokenArray; |
tokenArray = ob1.lc.tokenArray; |
size = ob1.rc.ival; |
size = ob1.rc.ival; |
for (i=0; i<size; i++) { |
for (i=0; i<size; i++) { |
token = tokenArray[i]; |
token = tokenArray[i]; |
|
InSendmsg2 = 1; |
status = executeToken(token); |
status = executeToken(token); |
if (status != 0) break; |
InSendmsg2 = 0; |
|
|
|
if (status & STATUS_INFIX) { |
|
if (status & DO_QUOTE) errorStackmachine("infix op with DO_QUOTE\n"); |
|
if (i == size-1) errorStackmachine("infix operator at the end(sendmsg2).\n"); |
|
infixOn = 1; infixToken = tokenArray[i]; |
|
infixToken.tflag |= NO_DELAY; continue; |
|
}else if (infixOn) { |
|
infixOn = 0; status = executeToken(infixToken); |
|
if (status & STATUS_BREAK) break; |
|
} |
|
|
|
if (QuoteMode && (status & DO_QUOTE)) { |
|
/* generate tree object, for kan/k0 */ |
|
struct object qob = OINIT; |
|
struct object qattr = OINIT; |
|
struct object qattr2 = OINIT; |
|
if (i==0) { Kpop(); Kpop();} |
|
qob = newObjectArray(3); |
|
qattr = newObjectArray(1); |
|
qattr2 = newObjectArray(2); |
|
/* Set the node name of the tree. */ |
|
if (token.kind == ID) { |
|
putoa(qob,0,KpoString(token.token)); |
|
}else{ |
|
putoa(qob,0,KpoString("unknown")); |
|
} |
|
/* Set the attibute list; class=className */ |
|
if (ob2.tag == Sdollar) { |
|
putoa(qattr2,0,KpoString("cd")); |
|
putoa(qattr2,1,ob2); |
|
}else{ |
|
putoa(qattr2,0,KpoString("class")); |
|
putoa(qattr2,1,KpoString(CurrentContextp->contextName)); |
|
} |
|
putoa(qattr,0,qattr2); |
|
putoa(qob,1,qattr); |
|
putoa(qob,2,ob4); /* Argument */ |
|
qob = KpoTree(qob); |
|
Kpush(qob); |
|
} else if (status & STATUS_BREAK) break; |
|
|
} |
} |
if (ccflag) { |
if (ccflag) { |
contextControl(CCPOP); ccflag = 0; |
contextControl(CCPOP); ccflag = 0; |
Line 1565 int executePrimitive(ob) |
|
Line 1634 int executePrimitive(ob) |
|
contextControl(CCPUSH); ccflag = 1; |
contextControl(CCPUSH); ccflag = 1; |
CurrentContextp = PrimitiveContextp; |
CurrentContextp = PrimitiveContextp; |
/* normal exec. */ |
/* normal exec. */ |
tokenArray = ob1.lc.tokenArray; |
status = executeExecutableArray(ob1,(char *)NULL,0); |
size = ob1.rc.ival; |
|
for (i=0; i<size; i++) { |
|
token = tokenArray[i]; |
|
status = executeToken(token); |
|
if (status != 0) break; |
|
} |
|
|
|
contextControl(CCPOP); /* recover the Current context. */ |
contextControl(CCPOP); /* recover the Current context. */ |
break; |
break; |
|
|
Line 1617 int executePrimitive(ob) |
|
Line 1679 int executePrimitive(ob) |
|
} |
} |
/* normal exec. */ |
/* normal exec. */ |
Kpush(ob2); Kpush(ob4); |
Kpush(ob2); Kpush(ob4); |
tokenArray = ob1.lc.tokenArray; |
status = executeExecutableArray(ob1,(char *)NULL,0); |
size = ob1.rc.ival; |
|
for (i=0; i<size; i++) { |
|
token = tokenArray[i]; |
|
status = executeToken(token); |
|
if (status != 0) break; |
|
} |
|
if (ccflag) { |
if (ccflag) { |
contextControl(CCPOP); ccflag = 0; /* recover the Current context. */ |
contextControl(CCPOP); ccflag = 0; /* recover the Current context. */ |
} |
} |
Line 1671 int executePrimitive(ob) |
|
Line 1727 int executePrimitive(ob) |
|
} |
} |
*/ |
*/ |
break; |
break; |
|
|
|
case Soxshell: |
|
ob1 = Kpop(); |
|
Kpush(KoxShell(ob1)); |
|
break; |
|
|
|
case Stlimit: |
|
/* { } time tlimit */ |
|
ob2 = Kpop(); |
|
ob1 = Kpop(); |
|
switch(ob2.tag) { |
|
case Sinteger: break; |
|
default: errorStackmachine("Usage:tlimit"); break; |
|
} |
|
switch(ob1.tag) { |
|
case SexecutableArray: break; |
|
default: |
|
errorStackmachine("Usage:tlimit"); |
|
break; |
|
} |
|
n = ob2.lc.ival; |
|
if (n > 0) { |
|
mysignal(SIGALRM,ctrlC); alarm((unsigned int) n); |
|
status = executeExecutableArray(ob1,(char *)NULL,0); |
|
cancelAlarm(); |
|
}else{ |
|
before_real = time(&before_real); |
|
times(&before); |
|
status = executeExecutableArray(ob1,(char *)NULL,0); |
|
times(&after); |
|
after_real = time(&after_real); |
|
ob1 = newObjectArray(3); |
|
putoa(ob1,0,KpoInteger((int) after.tms_utime - before.tms_utime)); |
|
putoa(ob1,1,KpoInteger((int) after.tms_stime - before.tms_stime)); |
|
putoa(ob1,2,KpoInteger((int) (after_real-before_real))); |
|
Kpush(ob1); |
|
} |
|
break; |
|
|
|
|
default: |
default: |