The R Project SVN R

Rev

Rev 6113 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6113 Rev 6188
Line 125... Line 125...
125
    RCNTXT *cptr;
125
    RCNTXT *cptr;
126
 
126
 
127
    /* Get the context which UseMethod was called from. */
127
    /* Get the context which UseMethod was called from. */
128
 
128
 
129
    cptr = R_GlobalContext;
129
    cptr = R_GlobalContext;
130
    if (cptr->callflag != CTXT_RETURN || cptr->cloenv != rho)
130
    if ( !(cptr->callflag & CTXT_FUNCTION) || cptr->cloenv != rho)
131
	error("UseMethod used in an inappropriate fashion");
131
	error("UseMethod used in an inappropriate fashion");
132
 
132
 
133
    /* Create a new environment without any */
133
    /* Create a new environment without any */
134
    /* of the formals to the generic in it. */
134
    /* of the formals to the generic in it. */
135
 
135
 
Line 228... Line 228...
228
    if (nargs >= 2)
228
    if (nargs >= 2)
229
	PROTECT(obj = eval(CADR(args), env));
229
	PROTECT(obj = eval(CADR(args), env));
230
    else {
230
    else {
231
	cptr = R_GlobalContext;
231
	cptr = R_GlobalContext;
232
	while (cptr != NULL) {
232
	while (cptr != NULL) {
233
	    if (cptr->callflag == CTXT_RETURN && cptr->cloenv == env)
233
	    if ( (cptr->callflag & CTXT_FUNCTION) && cptr->cloenv == env)
234
		break;
234
		break;
235
	    cptr = cptr->nextcontext;
235
	    cptr = cptr->nextcontext;
236
	}
236
	}
237
	if (cptr == NULL)
237
	if (cptr == NULL)
238
	    error("UseMethod called from outside a closure");
238
	    error("UseMethod called from outside a closure");
Line 306... Line 306...
306
    cptr->callflag = CTXT_GENERIC;
306
    cptr->callflag = CTXT_GENERIC;
307
 
307
 
308
    /* get the env NextMethod was called from */
308
    /* get the env NextMethod was called from */
309
    sysp = R_GlobalContext->sysparent;
309
    sysp = R_GlobalContext->sysparent;
310
    while (cptr != NULL) {
310
    while (cptr != NULL) {
311
	if (cptr->callflag == CTXT_RETURN && cptr->cloenv == sysp)
311
	if (cptr->callflag & CTXT_FUNCTION && cptr->cloenv == sysp)
312
	    break;
312
	    break;
313
	cptr = cptr->nextcontext;
313
	cptr = cptr->nextcontext;
314
    }
314
    }
315
    if (cptr == NULL)
315
    if (cptr == NULL)
316
	error("NextMethod called from outside a closure");
316
	error("NextMethod called from outside a closure");