Locale(const char* language, const char* region) { language = isLanguage(language) ? language : DEFAULT_LANGUAGE; region = isRegion(region) ? region : DEFAULT_REGION; memcpy(this->language, language, FIELDSIZE); memcpy(this->region, region, FIELDSIZE); }
static char kindEnabled (const verilogKind kind) { if (isLanguage (Lang_systemverilog)) return SystemVerilogKinds[kind].enabled; else /* isLanguage (Lang_verilog) */ return VerilogKinds[kind].enabled; }
static const kindOption *kindFromKind (const verilogKind kind) { if (isLanguage (Lang_systemverilog)) return &(SystemVerilogKinds[kind]); else /* isLanguage (Lang_verilog) */ return &(VerilogKinds[kind]); }
static char kindLetter (const verilogKind kind) { if (isLanguage (Lang_systemverilog)) return SystemVerilogKinds[kind].letter; else /* isLanguage (Lang_verilog) */ return VerilogKinds[kind].letter; }
static const char *kindName (const verilogKind kind) { if (isLanguage (Lang_systemverilog)) return SystemVerilogKinds[kind].name; else /* isLanguage (Lang_verilog) */ return VerilogKinds[kind].name; }
static void checkNames(SEXP x, SEXP s) { if (isVector(x) || isList(x) || isLanguage(x)) { if (!isVector(s) && !isList(s)) error(_("invalid type (%s) for 'names': must be vector"), type2char(TYPEOF(s))); if (xlength(x) != xlength(s)) error(_("'names' attribute [%d] must be the same length as the vector [%d]"), length(s), length(x)); } else if(IS_S4_OBJECT(x)) { /* leave validity checks to S4 code */ } else error(_("names() applied to a non-vector")); }
SEXP makeSubscript(SEXP x, SEXP s, int *stretch) { int nx; SEXP ans; ans = R_NilValue; if (isVector(x) || isList(x) || isLanguage(x)) { nx = length(x); ans = vectorSubscript(nx, s, stretch, getAttrib, (STRING_ELT), x); } else error(_("subscripting on non-vector")); return ans; }
static void processFunction (tokenInfo *const token) { int c; tokenInfo *classType; /* Search for function name * Last identifier found before a '(' or a ';' is the function name */ c = skipWhite (vGetc ()); do { readIdentifier (token, c); c = skipWhite (vGetc ()); /* Identify class type prefixes and create respective context*/ if (isLanguage (Lang_systemverilog) && c == ':') { c = vGetc (); if (c == ':') { verbose ("Found function declaration with class type %s\n", vStringValue (token->name)); classType = newToken (); vStringCopy (classType->name, token->name); classType->kind = K_CLASS; createContext (classType); currentContext->classScope = TRUE; } else { vUngetc (c); } } } while (c != '(' && c != ';' && c != EOF); if ( vStringLength (token->name) > 0 ) { verbose ("Found function: %s\n", vStringValue (token->name)); /* Create tag */ createTag (token); /* Get port list from function */ processPortList (c); } }
SEXP doD(SEXP args) { SEXP expr, var; args = CDR(args); if (isExpression(CAR(args))) expr = VECTOR_ELT(CAR(args), 0); else expr = CAR(args); if (!(isLanguage(expr) || isSymbol(expr) || isNumeric(expr) || isComplex(expr))) error(_("'expr' must be an expression or call")); var = CADR(args); if (!isString(var) || length(var) < 1) error(_("variable must be a character string")); if (length(var) > 1) warning(_("only the first element is used as variable name")); var = installTrChar(STRING_ELT(var, 0)); InitDerivSymbols(); PROTECT(expr = D(expr, var)); expr = AddParens(expr); UNPROTECT(1); return expr; }
SEXP dotTclcallback(SEXP args) { SEXP ans, callback = CADR(args), env; char buff[BUFFLEN]; char *s; Tcl_DString s_ds; if (isFunction(callback)) callback_closure(buff, BUFFLEN, callback); else if (isLanguage(callback)) { env = CADDR(args); callback_lang(buff, BUFFLEN, callback, env); } else error(_("argument is not of correct type")); Tcl_DStringInit(&s_ds); s = Tcl_UtfToExternalDString(NULL, buff, -1, &s_ds); ans = mkString(s); Tcl_DStringFree(&s_ds); return ans; }
SEXP attribute_hidden do_subset2_dflt(SEXP call, SEXP op, SEXP args, SEXP rho) { SEXP ans, dims, dimnames, indx, subs, x; int i, ndims, nsubs; int drop = 1, pok, exact = -1; int named_x; R_xlen_t offset = 0; PROTECT(args); ExtractDropArg(args, &drop); /* Is partial matching ok? When the exact arg is NA, a warning is issued if partial matching occurs. */ exact = ExtractExactArg(args); if (exact == -1) pok = exact; else pok = !exact; x = CAR(args); /* This code was intended for compatibility with S, */ /* but in fact S does not do this. Will anyone notice? */ if (x == R_NilValue) { UNPROTECT(1); /* args */ return x; } /* Get the subscripting and dimensioning information */ /* and check that any array subscripting is compatible. */ subs = CDR(args); if(0 == (nsubs = length(subs))) errorcall(call, _("no index specified")); dims = getAttrib(x, R_DimSymbol); ndims = length(dims); if(nsubs > 1 && nsubs != ndims) errorcall(call, _("incorrect number of subscripts")); /* code to allow classes to extend environment */ if(TYPEOF(x) == S4SXP) { x = R_getS4DataSlot(x, ANYSXP); if(x == R_NilValue) errorcall(call, _("this S4 class is not subsettable")); } PROTECT(x); /* split out ENVSXP for now */ if( TYPEOF(x) == ENVSXP ) { if( nsubs != 1 || !isString(CAR(subs)) || length(CAR(subs)) != 1 ) errorcall(call, _("wrong arguments for subsetting an environment")); ans = findVarInFrame(x, installTrChar(STRING_ELT(CAR(subs), 0))); if( TYPEOF(ans) == PROMSXP ) { PROTECT(ans); ans = eval(ans, R_GlobalEnv); UNPROTECT(1); /* ans */ } else SET_NAMED(ans, 2); UNPROTECT(2); /* args, x */ if(ans == R_UnboundValue) return(R_NilValue); if (NAMED(ans)) SET_NAMED(ans, 2); return ans; } /* back to the regular program */ if (!(isVector(x) || isList(x) || isLanguage(x))) errorcall(call, R_MSG_ob_nonsub, type2char(TYPEOF(x))); named_x = NAMED(x); /* x may change below; save this now. See PR#13411 */ if(nsubs == 1) { /* vector indexing */ SEXP thesub = CAR(subs); int len = length(thesub); if (len > 1) { #ifdef SWITCH_TO_REFCNT if (IS_GETTER_CALL(call)) { /* this is (most likely) a getter call in a complex assighment so we duplicate as needed. The original x should have been duplicated if it might be shared */ if (MAYBE_SHARED(x)) error("getter call used outside of a complex assignment."); x = vectorIndex(x, thesub, 0, len-1, pok, call, TRUE); } else x = vectorIndex(x, thesub, 0, len-1, pok, call, FALSE); #else x = vectorIndex(x, thesub, 0, len-1, pok, call, FALSE); #endif named_x = NAMED(x); UNPROTECT(1); /* x */ PROTECT(x); } SEXP xnames = PROTECT(getAttrib(x, R_NamesSymbol)); offset = get1index(thesub, xnames, xlength(x), pok, len > 1 ? len-1 : -1, call); UNPROTECT(1); /* xnames */ if (offset < 0 || offset >= xlength(x)) { /* a bold attempt to get the same behaviour for $ and [[ */ if (offset < 0 && (isNewList(x) || isExpression(x) || isList(x) || isLanguage(x))) { UNPROTECT(2); /* args, x */ return R_NilValue; } else errorcall(call, R_MSG_subs_o_b); } } else { /* matrix indexing */ /* Here we use the fact that: */ /* CAR(R_NilValue) = R_NilValue */ /* CDR(R_NilValue) = R_NilValue */ int ndn; /* Number of dimnames. Unlikely to be anything but 0 or nsubs, but just in case... */ PROTECT(indx = allocVector(INTSXP, nsubs)); dimnames = getAttrib(x, R_DimNamesSymbol); ndn = length(dimnames); for (i = 0; i < nsubs; i++) { INTEGER(indx)[i] = (int) get1index(CAR(subs), (i < ndn) ? VECTOR_ELT(dimnames, i) : R_NilValue, INTEGER(indx)[i], pok, -1, call); subs = CDR(subs); if (INTEGER(indx)[i] < 0 || INTEGER(indx)[i] >= INTEGER(dims)[i]) errorcall(call, R_MSG_subs_o_b); } offset = 0; for (i = (nsubs - 1); i > 0; i--) offset = (offset + INTEGER(indx)[i]) * INTEGER(dims)[i - 1]; offset += INTEGER(indx)[0]; UNPROTECT(1); /* indx */ } if(isPairList(x)) { #ifdef LONG_VECTOR_SUPPORT if (offset > R_SHORT_LEN_MAX) error("invalid subscript for pairlist"); #endif ans = CAR(nthcdr(x, (int) offset)); if (named_x > NAMED(ans)) SET_NAMED(ans, named_x); } else if(isVectorList(x)) { /* did unconditional duplication before 2.4.0 */ ans = VECTOR_ELT(x, offset); if (named_x > NAMED(ans)) SET_NAMED(ans, named_x); } else { ans = allocVector(TYPEOF(x), 1); switch (TYPEOF(x)) { case LGLSXP: case INTSXP: INTEGER(ans)[0] = INTEGER(x)[offset]; break; case REALSXP: REAL(ans)[0] = REAL(x)[offset]; break; case CPLXSXP: COMPLEX(ans)[0] = COMPLEX(x)[offset]; break; case STRSXP: SET_STRING_ELT(ans, 0, STRING_ELT(x, offset)); break; case RAWSXP: RAW(ans)[0] = RAW(x)[offset]; break; default: UNIMPLEMENTED_TYPE("do_subset2", x); } } UNPROTECT(2); /* args, x */ return ans; }
/* NOTE: For environments serialize.c calls this function to find if there is a class attribute in order to reconstruct the object bit if needed. This means the function cannot use OBJECT(vec) == 0 to conclude that the class attribute is R_NilValue. If you want to rewrite this function to use such a pre-test, be sure to adjust serialize.c accordingly. LT */ SEXP attribute_hidden getAttrib0(SEXP vec, SEXP name) { SEXP s; int len, i, any; if (name == R_NamesSymbol) { if(isVector(vec) || isList(vec) || isLanguage(vec)) { s = getAttrib(vec, R_DimSymbol); if(TYPEOF(s) == INTSXP && length(s) == 1) { s = getAttrib(vec, R_DimNamesSymbol); if(!isNull(s)) { SET_NAMED(VECTOR_ELT(s, 0), 2); return VECTOR_ELT(s, 0); } } } if (isList(vec) || isLanguage(vec)) { len = length(vec); PROTECT(s = allocVector(STRSXP, len)); i = 0; any = 0; for ( ; vec != R_NilValue; vec = CDR(vec), i++) { if (TAG(vec) == R_NilValue) SET_STRING_ELT(s, i, R_BlankString); else if (isSymbol(TAG(vec))) { any = 1; SET_STRING_ELT(s, i, PRINTNAME(TAG(vec))); } else error(_("getAttrib: invalid type (%s) for TAG"), type2char(TYPEOF(TAG(vec)))); } UNPROTECT(1); if (any) { if (!isNull(s)) SET_NAMED(s, 2); return (s); } return R_NilValue; } } /* This is where the old/new list adjustment happens. */ for (s = ATTRIB(vec); s != R_NilValue; s = CDR(s)) if (TAG(s) == name) { if (name == R_DimNamesSymbol && TYPEOF(CAR(s)) == LISTSXP) { SEXP _new, old; int i; _new = allocVector(VECSXP, length(CAR(s))); old = CAR(s); i = 0; while (old != R_NilValue) { SET_VECTOR_ELT(_new, i++, CAR(old)); old = CDR(old); } SET_NAMED(_new, 2); return _new; } SET_NAMED(CAR(s), 2); return CAR(s); } return R_NilValue; }