version 1.13, 2004/09/12 02:37:57 |
version 1.14, 2004/09/12 08:55:36 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/primitive.c,v 1.12 2004/09/11 01:00:42 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/primitive.c,v 1.13 2004/09/12 02:37:57 takayama Exp $ */ |
/* primitive.c */ |
/* primitive.c */ |
/* The functions in this module were in stackmachine.c */ |
/* The functions in this module were in stackmachine.c */ |
|
|
Line 744 int executePrimitive(ob) |
|
Line 744 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); |
/***printf("[token %d]%s\n",i,token.token);*/ |
|
i++; |
|
if (i >= size) { |
|
i=0; |
|
} |
|
status = executeToken(token); |
|
if ((status & STATUS_BREAK) || 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 802 int executePrimitive(ob) |
|
Line 784 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); |
size = ob1.rc.ival; |
if ((status & STATUS_BREAK) || GotoP) goto xyz; |
for (j=0; j<size; j++) { |
|
status = executeToken(tokenArray[j]); |
|
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{ |
/* |
/* |
Line 825 int executePrimitive(ob) |
|
Line 793 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); |
size = ob1.rc.ival; |
if ((status & STATUS_BREAK) || GotoP) goto xyz; |
for (j=0; j<size; j++) { |
|
status = executeToken(tokenArray[j]); |
|
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; |
|
} |
|
|
|
} |
|
} |
} |
} |
} |
xyz: ; |
xyz: ; |
Line 871 int executePrimitive(ob) |
|
Line 825 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); |
size = ob2.rc.ival; |
if ((status & STATUS_BREAK) || GotoP) goto foor; |
for (j=0; j<size; j++) { |
|
status = executeToken(tokenArray[j]); |
|
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: ; |
/*KSexecuteString("]");*/ |
/*KSexecuteString("]");*/ |
Line 935 int executePrimitive(ob) |
|
Line 875 int executePrimitive(ob) |
|
ob1 = ob2; |
ob1 = ob2; |
} |
} |
/* execute ob1 */ |
/* execute ob1 */ |
tokenArray = ob1.lc.tokenArray; |
status = executeExecutableArray(ob1,(char *)NULL); |
size = ob1.rc.ival; |
if (status & STATUS_BREAK) return(status); |
for (i=0; i<size; i++) { |
|
token = tokenArray[i]; |
|
status = executeToken(token); |
|
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; |
|
|
case Sexec: |
case Sexec: |
Line 962 int executePrimitive(ob) |
|
Line 887 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); |
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 & 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; |
|
|
/* Postscript primitives :dictionary */ |
/* Postscript primitives :dictionary */ |
Line 1559 int executePrimitive(ob) |
|
Line 1467 int executePrimitive(ob) |
|
} |
} |
/* normal exec. */ |
/* normal exec. */ |
Kpush(ob2); |
Kpush(ob2); |
tokenArray = ob1.lc.tokenArray; |
status = executeExecutableArray(ob1,(char *)NULL); |
size = ob1.rc.ival; |
|
for (i=0; i<size; i++) { |
|
token = tokenArray[i]; |
|
status = executeToken(token); |
|
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. */ |
} |
} |
|
|
break; |
break; |
case Ssendmsg2: |
case Ssendmsg2: |
/* ob2 ob4 { .........} sendmsg2 */ |
/* ob2 ob4 { .........} sendmsg2 */ |
Line 1616 int executePrimitive(ob) |
|
Line 1509 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++) { |
Line 1683 int executePrimitive(ob) |
|
Line 1579 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); |
size = ob1.rc.ival; |
|
for (i=0; i<size; i++) { |
|
token = tokenArray[i]; |
|
status = executeToken(token); |
|
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. */ |
break; |
break; |
|
|
Line 1745 int executePrimitive(ob) |
|
Line 1624 int executePrimitive(ob) |
|
} |
} |
/* normal exec. */ |
/* normal exec. */ |
Kpush(ob2); Kpush(ob4); |
Kpush(ob2); Kpush(ob4); |
tokenArray = ob1.lc.tokenArray; |
status = executeExecutableArray(ob1,(char *)NULL); |
size = ob1.rc.ival; |
|
for (i=0; i<size; i++) { |
|
token = tokenArray[i]; |
|
status = executeToken(token); |
|
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 1829 int executePrimitive(ob) |
|
Line 1692 int executePrimitive(ob) |
|
errorStackmachine("Usage:tlimit"); |
errorStackmachine("Usage:tlimit"); |
break; |
break; |
} |
} |
tokenArray = ob1.lc.tokenArray; |
|
size = ob1.rc.ival; |
|
n = ob2.lc.ival; |
n = ob2.lc.ival; |
i = 0; |
|
if (n > 0) { |
if (n > 0) { |
signal(SIGALRM,ctrlC); alarm((unsigned int) n); |
signal(SIGALRM,ctrlC); alarm((unsigned int) n); |
for (i=0; i<size; i++) { |
status = executeExecutableArray(ob1,(char *)NULL); |
token = tokenArray[i]; |
|
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{ |
before_real = time(&before_real); |
before_real = time(&before_real); |
times(&before); |
times(&before); |
for (i=0; i<size; i++) { |
status = executeExecutableArray(ob1,(char *)NULL); |
token = tokenArray[i]; |
|
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); |
ob1 = newObjectArray(3); |
ob1 = newObjectArray(3); |