The R Project SVN R

Rev

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

Rev 35450 Rev 36174
Line 171... Line 171...
171
SEXP R_LookupMethod(SEXP method, SEXP rho, SEXP callrho, SEXP defrho)
171
SEXP R_LookupMethod(SEXP method, SEXP rho, SEXP callrho, SEXP defrho)
172
{
172
{
173
    SEXP val;
173
    SEXP val;
174
 
174
 
175
    if (R_UseNamespaceDispatch) {
175
    if (R_UseNamespaceDispatch) {
-
 
176
	if (TYPEOF(callrho) == NILSXP) {
-
 
177
	    warning(_("use of NULL environment is deprecated"));
-
 
178
	    callrho = R_BaseEnv;
-
 
179
	} else
176
	if (TYPEOF(callrho) != ENVSXP && callrho != R_BaseEnv)
180
	if (TYPEOF(callrho) != ENVSXP)
177
	    error(_("bad generic call environment"));
181
	    error(_("bad generic call environment"));
-
 
182
	if (TYPEOF(defrho) == NILSXP) {
-
 
183
	    warning(_("use of NULL environment is deprecated"));
-
 
184
	    defrho = R_BaseEnv;
-
 
185
	} else
178
	if (TYPEOF(defrho) != ENVSXP && defrho != R_BaseEnv)
186
	if (TYPEOF(defrho) != ENVSXP)
179
	    error(_("bad generic definition environment"));
187
	    error(_("bad generic definition environment"));
180
	if (defrho == R_BaseEnv)
188
	if (defrho == R_BaseEnv)
181
	    defrho = R_BaseNamespace;
189
	    defrho = R_BaseNamespace;
182
 
190
 
183
	val = findVar(method, callrho);
191
	val = findVar(method, callrho);
Line 356... Line 364...
356
       defenv = environment where the generic was defined */
364
       defenv = environment where the generic was defined */
357
    cptr = R_GlobalContext;
365
    cptr = R_GlobalContext;
358
    if ( !(cptr->callflag & CTXT_FUNCTION) || cptr->cloenv != env)
366
    if ( !(cptr->callflag & CTXT_FUNCTION) || cptr->cloenv != env)
359
	error(_("'UseMethod' used in an inappropriate fashion"));
367
	error(_("'UseMethod' used in an inappropriate fashion"));
360
    callenv = cptr->sysparent;
368
    callenv = cptr->sysparent;
361
    defenv = TYPEOF(env) == ENVSXP ? ENCLOS(env) : R_BaseEnv;
369
    defenv = ENCLOS(env);
362
 
370
 
363
    if (nargs)
371
    if (nargs)
364
	PROTECT(generic = eval(CAR(args), env));
372
	PROTECT(generic = eval(CAR(args), env));
365
    else 
373
    else 
366
	errorcall(call, _("there must be a first argument"));
374
	errorcall(call, _("there must be a first argument"));
Line 927... Line 935...
927
    SEXP e, value, rho, fun, symbol, dot_Generic;
935
    SEXP e, value, rho, fun, symbol, dot_Generic;
928
    RCNTXT *cptr;
936
    RCNTXT *cptr;
929
    /* find a non-generic function */
937
    /* find a non-generic function */
930
    symbol = install(CHAR(asChar(name)));
938
    symbol = install(CHAR(asChar(name)));
931
    dot_Generic = install(".Generic");
939
    dot_Generic = install(".Generic");
932
    for(rho = ENCLOS(env); rho != R_BaseEnv && isEnvironment(rho);
940
    for(rho = ENCLOS(env); rho != R_EmptyEnv;
933
	rho = ENCLOS(rho)) {
941
	rho = ENCLOS(rho)) {
934
	fun = findVarInFrame3(rho, symbol, TRUE);
942
	fun = findVarInFrame3(rho, symbol, TRUE);
935
	if(fun == R_UnboundValue) continue;
943
	if(fun == R_UnboundValue) continue;
936
	switch(TYPEOF(fun)) {
944
	switch(TYPEOF(fun)) {
937
	case CLOSXP:
945
	case CLOSXP: