Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
`R'的nmcnt`和'type';s`sxpinfo`header_C_R_Struct_Internals - Fatal编程技术网

`R'的nmcnt`和'type';s`sxpinfo`header

`R'的nmcnt`和'type';s`sxpinfo`header,c,r,struct,internals,C,R,Struct,Internals,R手册第1.1.2条规定: “sxpinfo”头定义为以下64位C结构: struct sxpinfo_struct { /* Type and namedcnt in first byte */ unsigned int nmcnt : 3; /* count of "names" referring to object */ unsigned int type : 5; /* discussed above */ /* Garbage co

R手册第1.1.2条规定:

“sxpinfo”头定义为以下64位C结构:

 struct sxpinfo_struct {
     /* Type and namedcnt in first byte */
     unsigned int nmcnt : 3;   /* count of "names" referring to object */
     unsigned int type : 5;    /* discussed above */
     /* Garbage collector stuff - keep in one byte to maybe speed up access */
     unsigned int gccls : 3;   /* node class for garbage collector */
     unsigned int gcgen : 1;   /* old generation number - may be best first */
     unsigned int mark : 1;    /* marks object as in use in garbage collector */
     /* Object flag */
     unsigned int obj : 1;     /* set if this is an S3 or S4 object */
     /* Flags to synchronize with helper threads */
     unsigned int in_use: 1;   /* whether contents may be in use by a helper */
     unsigned int being_computed : 1;  /* whether helper may be computing this */
     /* "general purpose" field, used for miscellaneous purposes */
     unsigned int gp : 16;     /* The "general purpose" field */
     union {
       struct {                /* field below is for vectors only */
         R_len_t truelength;   /* for old stuff - may someday be defunct... */
       } vec;
       struct {                /* fields below are for non-vectors only */
         /* Debugging */
         unsigned int debug : 1;  /* function/environment is being debugged */
         unsigned int rstep : 1;  /* function is to be debugged, but only once */
         unsigned int trace : 1;  /* function is being traced */
         /* Symbol binding */
         unsigned int basec : 1;       /* sym has base binding in global cache */
         unsigned int spec_sym : 1;    /* this is a "special" symbol */
         unsigned int no_spec_sym : 1; /* environment has no special symbols */
         unsigned int unused : 2; /* not yet used */
         /* Primitive operations */
         unsigned char var1, var2;/* variants for evals of fast primitive args */
         unsigned char pending_ok;/* whether args can have computation pending */
       } nonvec;                  /*  - only one bit, but maybe faster as byte */
     } u;
 };
这就给我留下了两个问题,关于
nmcnt
type
字段(第一个字节):

  • 为什么你是25岁−2
    SEXPTYPEs
    当2⁵=64≫25岁
  • 是否有2³=8个可引用给定(如S4)对象的名称的限制

  • 提前感谢。

    关于1:如果手册中没有提到这一点,您必须询问作者(开发人员)。我的猜测是:5位(而不是4位)为将来的扩展留出了空间(即39个进一步的值,可以在不破坏数据兼容性的情况下进行分配)。在其他合理的地方,似乎不需要额外的位。(顺便说一句。我不觉得64>>25。我首先对移位运算符
    >
    感到困惑,直到我想起非C程序员可能会将其用于“远大于”…)顺便说一句。链接中的
    结构spxinfo_struct
    与您问题中的示例代码相比有些不同。我会认为这是危险的,因为这意味着错误的比特可以在你的身边访问。@谢夫我粘贴了<代码>信息-R -iTS(我的副本),这可以解释不同之处。(答案也是可怕的)