version 1.9, 2003/12/03 01:21:43 |
version 1.13, 2004/09/12 02:37:57 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/primitive.c,v 1.8 2003/11/20 09:20:36 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/primitive.c,v 1.12 2004/09/11 01:00:42 takayama Exp $ */ |
/* primitive.c */ |
/* primitive.c */ |
/* The functions in this module were in stackmachine.c */ |
/* The functions in this module were in stackmachine.c */ |
|
|
|
|
|
|
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 423 int executePrimitive(ob) |
|
Line 424 int executePrimitive(ob) |
|
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; |
Line 441 int executePrimitive(ob) |
|
Line 444 int executePrimitive(ob) |
|
extern TimerOn; |
extern TimerOn; |
extern SecureMode; |
extern SecureMode; |
|
|
|
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(); |
} |
} |
Line 595 int executePrimitive(ob) |
|
Line 600 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 764 int executePrimitive(ob) |
|
Line 755 int executePrimitive(ob) |
|
i=0; |
i=0; |
} |
} |
status = executeToken(token); |
status = executeToken(token); |
if (status || GotoP) break; |
if ((status & STATUS_BREAK) || 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. */ |
|
|
|
if (status & STATUS_INFIX) { |
|
infixOn = 1; infixToken = token; |
|
infixToken.tflag |= NO_DELAY; continue; |
|
}else if (infixOn) { |
|
infixOn = 0; status = executeToken(infixToken); |
|
if ((status & STATUS_BREAK) || GotoP) break; |
|
} |
|
|
} |
} |
break; |
break; |
|
|
Line 806 int executePrimitive(ob) |
|
Line 806 int executePrimitive(ob) |
|
size = ob1.rc.ival; |
size = ob1.rc.ival; |
for (j=0; j<size; j++) { |
for (j=0; j<size; j++) { |
status = executeToken(tokenArray[j]); |
status = executeToken(tokenArray[j]); |
if (status || GotoP) goto xyz; |
if ((status & STATUS_BREAK) || GotoP) goto xyz; |
} |
|
} |
if (status & STATUS_INFIX) { |
|
if (j == size-1) errorStackmachine("infix operator at the end.\n"); |
|
infixOn = 1; infixToken = tokenArray[j]; |
|
infixToken.tflag |= NO_DELAY; continue; |
|
}else if (infixOn) { |
|
infixOn = 0; status = executeToken(infixToken); |
|
if ((status & STATUS_BREAK) || 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"); |
Line 819 int executePrimitive(ob) |
|
Line 829 int executePrimitive(ob) |
|
size = ob1.rc.ival; |
size = ob1.rc.ival; |
for (j=0; j<size; j++) { |
for (j=0; j<size; j++) { |
status = executeToken(tokenArray[j]); |
status = executeToken(tokenArray[j]); |
if (status || GotoP) goto xyz; |
if ((status & STATUS_BREAK) || GotoP) goto xyz; |
|
|
|
if (status & STATUS_INFIX) { |
|
if (j == size-1) errorStackmachine("infix operator at the end.\n"); |
|
infixOn = 1; infixToken = tokenArray[j]; |
|
infixToken.tflag |= NO_DELAY; continue; |
|
}else if (infixOn) { |
|
infixOn = 0; status = executeToken(infixToken); |
|
if ((status & STATUS_BREAK) || GotoP) goto xyz; |
|
} |
|
|
} |
} |
} |
} |
} |
} |
Line 855 int executePrimitive(ob) |
|
Line 875 int executePrimitive(ob) |
|
size = ob2.rc.ival; |
size = ob2.rc.ival; |
for (j=0; j<size; j++) { |
for (j=0; j<size; j++) { |
status = executeToken(tokenArray[j]); |
status = executeToken(tokenArray[j]); |
if (status) goto foor; |
if (status & STATUS_BREAK) goto foor; |
|
|
|
if (status & STATUS_INFIX) { |
|
if (j == size-1) errorStackmachine("infix operator at the end(map).\n"); |
|
infixOn = 1; infixToken = tokenArray[j]; |
|
infixToken.tflag |= NO_DELAY; continue; |
|
}else if (infixOn) { |
|
infixOn = 0; status = executeToken(infixToken); |
|
if ((status & STATUS_BREAK) || GotoP) goto foor; |
|
} |
|
|
} |
} |
} |
} |
foor: ; |
foor: ; |
Line 910 int executePrimitive(ob) |
|
Line 940 int executePrimitive(ob) |
|
for (i=0; i<size; i++) { |
for (i=0; i<size; i++) { |
token = tokenArray[i]; |
token = tokenArray[i]; |
status = executeToken(token); |
status = executeToken(token); |
if (status != 0) return(status); |
if (status & STATUS_BREAK) return(status); |
|
|
|
if (status & STATUS_INFIX) { |
|
if (i == size-1) errorStackmachine("infix operator at the end(if).\n"); |
|
infixOn = 1; infixToken = tokenArray[i]; |
|
infixToken.tflag |= NO_DELAY; continue; |
|
}else if (infixOn) { |
|
infixOn = 0; status = executeToken(infixToken); |
|
if (status & STATUS_BREAK) return(status); |
|
} |
|
|
} |
} |
|
|
break; |
break; |
Line 928 int executePrimitive(ob) |
|
Line 968 int executePrimitive(ob) |
|
token = tokenArray[i]; |
token = tokenArray[i]; |
/***printf("[token %d]%s\n",i,token.token);*/ |
/***printf("[token %d]%s\n",i,token.token);*/ |
status = executeToken(token); |
status = executeToken(token); |
if (status != 0) break; |
if (status & STATUS_BREAK) break; |
|
|
|
if (status & STATUS_INFIX) { |
|
if (i == size-1) errorStackmachine("infix operator at the end(exec).\n"); |
|
infixOn = 1; infixToken = tokenArray[i]; |
|
infixToken.tflag |= NO_DELAY; continue; |
|
}else if (infixOn) { |
|
infixOn = 0; status = executeToken(infixToken); |
|
if (status & STATUS_BREAK) break; |
|
} |
|
|
} |
} |
break; |
break; |
|
|
Line 1514 int executePrimitive(ob) |
|
Line 1564 int executePrimitive(ob) |
|
for (i=0; i<size; i++) { |
for (i=0; i<size; i++) { |
token = tokenArray[i]; |
token = tokenArray[i]; |
status = executeToken(token); |
status = executeToken(token); |
if (status != 0) break; |
if (status & STATUS_BREAK) break; |
|
|
|
if (status & STATUS_INFIX) { |
|
if (i == size-1) errorStackmachine("infix operator at the end(sendmsg).\n"); |
|
infixOn = 1; infixToken = token; |
|
infixToken.tflag |= NO_DELAY; continue; |
|
}else if (infixOn) { |
|
infixOn = 0; status = executeToken(infixToken); |
|
if (status & STATUS_BREAK) break; |
|
} |
|
|
} |
} |
if (ccflag) { |
if (ccflag) { |
contextControl(CCPOP); ccflag = 0; /* recover the Current context. */ |
contextControl(CCPOP); ccflag = 0; /* recover the Current context. */ |
Line 1560 int executePrimitive(ob) |
|
Line 1620 int executePrimitive(ob) |
|
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 (QuoteMode && (status==DO_QUOTE)) { |
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 */ |
/* generate tree object, for kan/k0 */ |
struct object qob; |
struct object qob; |
struct object qattr; |
struct object qattr; |
Line 1577 int executePrimitive(ob) |
|
Line 1650 int executePrimitive(ob) |
|
putoa(qob,0,KpoString("unknown")); |
putoa(qob,0,KpoString("unknown")); |
} |
} |
/* Set the attibute list; class=className */ |
/* Set the attibute list; class=className */ |
putoa(qattr2,0,KpoString("class")); |
|
if (ob2.tag == Sdollar) { |
if (ob2.tag == Sdollar) { |
|
putoa(qattr2,0,KpoString("cd")); |
putoa(qattr2,1,ob2); |
putoa(qattr2,1,ob2); |
}else{ |
}else{ |
|
putoa(qattr2,0,KpoString("class")); |
putoa(qattr2,1,KpoString(CurrentContextp->contextName)); |
putoa(qattr2,1,KpoString(CurrentContextp->contextName)); |
} |
} |
putoa(qattr,0,qattr2); |
putoa(qattr,0,qattr2); |
Line 1588 int executePrimitive(ob) |
|
Line 1662 int executePrimitive(ob) |
|
putoa(qob,2,ob4); /* Argument */ |
putoa(qob,2,ob4); /* Argument */ |
qob = KpoTree(qob); |
qob = KpoTree(qob); |
Kpush(qob); |
Kpush(qob); |
} else if (status != 0) break; |
} else if (status & STATUS_BREAK) break; |
|
|
} |
} |
if (ccflag) { |
if (ccflag) { |
contextControl(CCPOP); ccflag = 0; |
contextControl(CCPOP); ccflag = 0; |
Line 1613 int executePrimitive(ob) |
|
Line 1688 int executePrimitive(ob) |
|
for (i=0; i<size; i++) { |
for (i=0; i<size; i++) { |
token = tokenArray[i]; |
token = tokenArray[i]; |
status = executeToken(token); |
status = executeToken(token); |
if (status != 0) break; |
if (status & STATUS_BREAK) break; |
|
|
|
if (status & STATUS_INFIX) { |
|
if (i == size-1) errorStackmachine("infix operator at the end(primmsg).\n"); |
|
infixOn = 1; infixToken = tokenArray[i]; |
|
infixToken.tflag |= NO_DELAY; continue; |
|
}else if (infixOn) { |
|
infixOn = 0; status = executeToken(infixToken); |
|
if (status & STATUS_BREAK) break; |
|
} |
|
|
} |
} |
|
|
contextControl(CCPOP); /* recover the Current context. */ |
contextControl(CCPOP); /* recover the Current context. */ |
Line 1665 int executePrimitive(ob) |
|
Line 1750 int executePrimitive(ob) |
|
for (i=0; i<size; i++) { |
for (i=0; i<size; i++) { |
token = tokenArray[i]; |
token = tokenArray[i]; |
status = executeToken(token); |
status = executeToken(token); |
if (status != 0) break; |
if (status & STATUS_BREAK) break; |
|
|
|
if (status & STATUS_INFIX) { |
|
if (i == size-1) errorStackmachine("infix operator at the end(supmsg).\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 (ccflag) { |
if (ccflag) { |
contextControl(CCPOP); ccflag = 0; /* recover the Current context. */ |
contextControl(CCPOP); ccflag = 0; /* recover the Current context. */ |
Line 1743 int executePrimitive(ob) |
|
Line 1838 int executePrimitive(ob) |
|
for (i=0; i<size; i++) { |
for (i=0; i<size; i++) { |
token = tokenArray[i]; |
token = tokenArray[i]; |
status = executeToken(token); |
status = executeToken(token); |
|
if (status & STATUS_BREAK) break; |
|
|
|
if (status & STATUS_INFIX) { |
|
if (i == size-1) errorStackmachine("infix operator at the end(tlimit).\n"); |
|
infixOn = 1; infixToken = tokenArray[i]; |
|
infixToken.tflag |= NO_DELAY; continue; |
|
}else if (infixOn) { |
|
infixOn = 0; status = executeToken(infixToken); |
|
if (status & STATUS_BREAK) break; |
|
} |
|
|
} |
} |
cancelAlarm(); |
cancelAlarm(); |
}else{ |
}else{ |
Line 1751 int executePrimitive(ob) |
|
Line 1857 int executePrimitive(ob) |
|
for (i=0; i<size; i++) { |
for (i=0; i<size; i++) { |
token = tokenArray[i]; |
token = tokenArray[i]; |
status = executeToken(token); |
status = executeToken(token); |
|
if (status & STATUS_BREAK) break; |
|
|
|
if (status & STATUS_INFIX) { |
|
if (i == size-1) errorStackmachine("infix operator at the end(tlimit).\n"); |
|
infixOn = 1; infixToken = tokenArray[i]; |
|
infixToken.tflag |= NO_DELAY; continue; |
|
}else if (infixOn) { |
|
infixOn = 0; status = executeToken(infixToken); |
|
if (status & STATUS_BREAK) break; |
|
} |
|
|
} |
} |
times(&after); |
times(&after); |
after_real = time(&after_real); |
after_real = time(&after_real); |