The R Project SVN R

Rev

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

Rev 24734 Rev 25087
Line 724... Line 724...
724
	ap = CDR(ap);
724
	ap = CDR(ap);
725
    }
725
    }
726
    return attrs;
726
    return attrs;
727
}
727
}
728
 
728
 
729
#ifdef NOTYET
-
 
730
/* It may be that there are LISTXP hiding in closures. */
-
 
731
/* This will convert them. */
-
 
732
 
-
 
733
static SEXP ConvertEnvironment(SEXP env)
-
 
734
{
-
 
735
    SEXP frame = FRAME(env);
-
 
736
    while (frame != R_NilValue) {
-
 
737
	if (TYPEOF(CAR(frame)) == LISTSXP)
-
 
738
	    CAR(frame) = ConvertPairToVector(CAR(frame));
-
 
739
	frame = CDR(frame);
-
 
740
    }
-
 
741
    return env;
-
 
742
}
-
 
743
#endif /* NOTYET */
-
 
744
 
-
 
745
static SEXP ConvertPairToVector(SEXP obj)
729
static SEXP ConvertPairToVector(SEXP obj)
746
{
730
{
747
    int i, n;
731
    int i, n;
748
    switch (TYPEOF(obj)) {
732
    switch (TYPEOF(obj)) {
749
    case LISTSXP:
733
    case LISTSXP:
Line 1094... Line 1078...
1094
	case VECSXP:
1078
	case VECSXP:
1095
	case EXPRSXP:
1079
	case EXPRSXP:
1096
	    /* Vector Objects */
1080
	    /* Vector Objects */
1097
	    NewWriteVec(s, sym_list, env_list, fp, m, d);
1081
	    NewWriteVec(s, sym_list, env_list, fp, m, d);
1098
	    break;
1082
	    break;
-
 
1083
	case BCODESXP:
-
 
1084
	    error("cannot save byte code objects in version 1 workspaces");
1099
	default:
1085
	default:
1100
	    error("NewWriteItem: unknown type %i", TYPEOF(s));
1086
	    error("NewWriteItem: unknown type %i", TYPEOF(s));
1101
	}
1087
	}
1102
	NewWriteItem(ATTRIB(s), sym_list, env_list, fp, m, d);
1088
	NewWriteItem(ATTRIB(s), sym_list, env_list, fp, m, d);
1103
    }
1089
    }
Line 1290... Line 1276...
1290
    case VECSXP:
1276
    case VECSXP:
1291
    case EXPRSXP:
1277
    case EXPRSXP:
1292
	PROTECT(s = NewReadVec(type, sym_table, env_table, fp, m, d));
1278
	PROTECT(s = NewReadVec(type, sym_table, env_table, fp, m, d));
1293
	break;
1279
	break;
1294
    case BCODESXP:
1280
    case BCODESXP:
1295
	error("this version of R cannot read byte code objects");
1281
	error("cannot read byte code objects from version 1 workspaces");
1296
    default:
1282
    default:
1297
	error("NewReadItem: unknown type %i", type);
1283
	error("NewReadItem: unknown type %i", type);
1298
    }
1284
    }
1299
    SETLEVELS(s, levs);
1285
    SETLEVELS(s, levs);
1300
    SET_OBJECT(s, objf);
1286
    SET_OBJECT(s, objf);
Line 1817... Line 1803...
1817
    return d1 + 10 * d2 + 100 * d3 + 1000 * d4;
1803
    return d1 + 10 * d2 + 100 * d3 + 1000 * d4;
1818
}
1804
}
1819
 
1805
 
1820
static int R_DefaultSaveFormatVersion = 2;
1806
static int R_DefaultSaveFormatVersion = 2;
1821
 
1807
 
-
 
1808
/* ----- E x t e r n a l -- I n t e r f a c e s ----- */
-
 
1809
 
1822
static void R_SaveToFileV(SEXP obj, FILE *fp, int ascii, int version)
1810
void R_SaveToFileV(SEXP obj, FILE *fp, int ascii, int version)
1823
{
1811
{
1824
    SaveLoadData data = {{NULL, 0, MAXELTSIZE}};
1812
    SaveLoadData data = {{NULL, 0, MAXELTSIZE}};
1825
 
1813
 
1826
    if (version == 1) {
1814
    if (version == 1) {
1827
	if (ascii) {
1815
	if (ascii) {
Line 1848... Line 1836...
1848
	R_InitFileOutPStream(&out, fp, type, version, NULL, NULL);
1836
	R_InitFileOutPStream(&out, fp, type, version, NULL, NULL);
1849
	R_Serialize(obj, &out);
1837
	R_Serialize(obj, &out);
1850
    }
1838
    }
1851
}
1839
}
1852
 
1840
 
1853
/* ----- E x t e r n a l -- I n t e r f a c e s ----- */
-
 
1854
 
-
 
1855
void R_SaveToFile(SEXP obj, FILE *fp, int ascii)
1841
void R_SaveToFile(SEXP obj, FILE *fp, int ascii)
1856
{
1842
{
1857
    R_SaveToFileV(obj, fp, ascii, R_DefaultSaveFormatVersion);
1843
    R_SaveToFileV(obj, fp, ascii, R_DefaultSaveFormatVersion);
1858
}
1844
}
1859
 
1845