The R Project SVN R

Rev

Rev 88148 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 88148 Rev 89986
Line 1... Line 1...
1
/*
1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
2
 *  R : A Computer Language for Statistical Data Analysis
3
 *  Copyright (C) 1997-2025  The R Core Team
3
 *  Copyright (C) 1997-2026  The R Core Team
4
 *  Copyright (C) 2003-2023  The R Foundation
4
 *  Copyright (C) 2003-2023  The R Foundation
5
 *  Copyright (C) 1995,1996  Robert Gentleman, Ross Ihaka
5
 *  Copyright (C) 1995,1996  Robert Gentleman, Ross Ihaka
6
 *
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
8
 *  it under the terms of the GNU General Public License as published by
Line 1163... Line 1163...
1163
    } else if (type == CHARSXP)
1163
    } else if (type == CHARSXP)
1164
	rval = PRINTNAME(v);
1164
	rval = PRINTNAME(v);
1165
    else if (type == STRSXP)
1165
    else if (type == STRSXP)
1166
	rval = ScalarString(PRINTNAME(v));
1166
	rval = ScalarString(PRINTNAME(v));
1167
    else
1167
    else
1168
	warning(_("'%s' object cannot be coerced to type '%s'"),
1168
	error(_("'%s' object cannot be coerced to type '%s'"),
1169
		"symbol", type2char(type));
1169
		"symbol", type2char(type));
1170
    return rval;
1170
    return rval;
1171
}
1171
}
1172
 
1172
 
1173
SEXP coerceVector(SEXP v, SEXPTYPE type)
1173
SEXP coerceVector(SEXP v, SEXPTYPE type)
Line 1446... Line 1446...
1446
}
1446
}
1447
 
1447
 
1448
 
1448
 
1449
attribute_hidden SEXP do_asatomic(SEXP call, SEXP op, SEXP args, SEXP rho)
1449
attribute_hidden SEXP do_asatomic(SEXP call, SEXP op, SEXP args, SEXP rho)
1450
{
1450
{
1451
    SEXP ans, x;
1451
    check1arg(args, call, "x");
1452
 
1452
 
1453
    int type = STRSXP, op0 = PRIMVAL(op);
-
 
1454
    char *name = NULL /* -Wall */;
1453
    char *name = NULL /* -Wall */;
1455
 
-
 
1456
    check1arg(args, call, "x");
1454
    int type = STRSXP;
1457
    switch(op0) {
1455
    switch(PRIMVAL(op)) {
1458
    case 0:
1456
    case 0:
1459
	name = "as.character"; break;
1457
	name = "as.character"; break;
1460
    case 1:
1458
    case 1:
1461
	name = "as.integer"; type = INTSXP; break;
1459
	name = "as.integer"; type = INTSXP; break;
1462
    case 2:
1460
    case 2:
Line 1472... Line 1470...
1472
    /* DispatchOrEval internal generic: as.integer */
1470
    /* DispatchOrEval internal generic: as.integer */
1473
    /* DispatchOrEval internal generic: as.double */
1471
    /* DispatchOrEval internal generic: as.double */
1474
    /* DispatchOrEval internal generic: as.complex */
1472
    /* DispatchOrEval internal generic: as.complex */
1475
    /* DispatchOrEval internal generic: as.logical */
1473
    /* DispatchOrEval internal generic: as.logical */
1476
    /* DispatchOrEval internal generic: as.raw */
1474
    /* DispatchOrEval internal generic: as.raw */
-
 
1475
    SEXP ans;
1477
    if (DispatchOrEval(call, op, name, args, rho, &ans, 0, 1))
1476
    if (DispatchOrEval(call, op, name, args, rho, &ans, 0, 1))
1478
	return(ans);
1477
	return(ans);
1479
 
1478
 
1480
    /* Method dispatch has failed, we now just */
1479
    /* Method dispatch has failed, we now just */
1481
    /* run the generic internal code */
1480
    /* run the generic internal code */
1482
 
1481
 
1483
    checkArity(op, args);
1482
    checkArity(op, args);
1484
    x = CAR(args);
1483
    SEXP x = CAR(args);
1485
    if(TYPEOF(x) == type) {
1484
    if(TYPEOF(x) == type) {
1486
	if(ATTRIB(x) == R_NilValue) return x;
1485
	if(ATTRIB(x) == R_NilValue) return x;
1487
	ans = MAYBE_REFERENCED(x) ? duplicate(x) : x;
1486
	ans = MAYBE_REFERENCED(x) ? duplicate(x) : x;
1488
	CLEAR_ATTRIB(ans);
1487
	CLEAR_ATTRIB(ans);
1489
	return ans;
1488
	return ans;