Lines Matching defs:scope

114  *	Var_Dump	Print out all variables defined in the given scope.
138 * There are 3 kinds of variables: scope variables, environment variables,
142 * a scope variable is using the .undef directive. In particular, it must
145 * unintended way to undefine a scope variable, see varmod-loop-delete.mk.)
156 * For scope variables, it aliases the corresponding HashEntry name.
176 * Appending to its value depends on the scope, see var-op-append.mk.
312 * A scope collects variable names and their values.
314 * The main scope is SCOPE_GLOBAL, which contains the variables that are set
323 * There is no scope for environment variables, these are generated on-the-fly
326 * Each target has its own scope, containing the 7 target-local variables
328 * this scope.
449 GNode_FindVar(GNode *scope, Substring varname, unsigned int hash)
451 return HashTable_FindValueBySubstringHash(&scope->vars, varname, hash);
455 * Find the variable in the scope, and maybe in other scopes as well.
459 * scope scope in which to look first
468 VarFindSubstring(Substring name, GNode *scope, bool elsewhere)
477 var = GNode_FindVar(scope, name, nameHash);
481 if (var == NULL && scope != SCOPE_CMDLINE)
484 if (!opts.checkEnvFirst && var == NULL && scope != SCOPE_GLOBAL) {
486 if (var == NULL && scope != SCOPE_INTERNAL) {
499 if (opts.checkEnvFirst && scope != SCOPE_GLOBAL) {
501 if (var == NULL && scope != SCOPE_INTERNAL)
514 VarFind(const char *name, GNode *scope, bool elsewhere)
516 return VarFindSubstring(Substring_InitStr(name), scope, elsewhere);
541 /* Add a new variable of the given name and value to the given scope. */
543 VarAdd(const char *name, const char *value, GNode *scope, VarSetFlags flags)
545 HashEntry *he = HashTable_CreateEntry(&scope->vars, name, NULL);
550 scope->name, name, value, ValueDescription(value));
555 * Remove a variable from a scope, freeing all related memory as well.
559 Var_Delete(GNode *scope, const char *varname)
561 HashEntry *he = HashTable_FindEntry(&scope->vars, varname);
566 scope->name, varname);
579 scope->name, varname);
589 DEBUG2(VAR, "%s: delete %s\n", scope->name, varname);
596 HashTable_DeleteEntry(&scope->vars, he);
603 Var_DeleteAll(GNode *scope)
606 HashIter_Init(&hi, &scope->vars);
616 * Undefine one or more variables from the global scope.
664 * local scope, skip it, else we can get Var_Subst
679 ExportVarEnv(Var *v, GNode *scope)
699 val = Var_Subst(expr, scope, VARE_EVAL);
700 if (scope != SCOPE_GLOBAL) {
752 ExportVar(const char *name, GNode *scope, VarExportMode mode)
759 v = VarFind(name, scope, false);
760 if (v == NULL && scope != SCOPE_GLOBAL)
766 return ExportVarEnv(v, scope);
778 Var_ReexportVars(GNode *scope)
802 ExportVar(var->name.str, scope, VEM_ENV);
815 ExportVar(varnames.words[i], scope, VEM_ENV);
997 Var_SetWithFlags(GNode *scope, const char *name, const char *val,
1006 scope->name, name, val);
1010 if (scope == SCOPE_GLOBAL
1019 scope->name, name, val);
1024 * Only look for a variable in the given scope since anything set
1025 * here will override anything in a lower scope, so there's not much
1028 v = VarFind(name, scope, false);
1030 if (scope == SCOPE_CMDLINE && !(flags & VAR_SET_NO_EXPORT)) {
1052 scope->name, name, val);
1055 v = VarAdd(name, val, scope, flags);
1066 scope->name, name, val);
1073 scope->name, name, val, ValueDescription(val));
1075 ExportVar(name, scope, VEM_PLAIN);
1078 if (scope == SCOPE_CMDLINE) {
1111 Var_Set(GNode *scope, const char *name, const char *val)
1113 Var_SetWithFlags(scope, name, val, VAR_SET_NONE);
1117 * In the scope, expand the variable name once, then create the variable or
1121 Var_SetExpand(GNode *scope, const char *name, const char *val)
1127 Var_Expand(&varname, scope, VARE_EVAL);
1133 scope->name, varname.str, val, name);
1135 Var_SetWithFlags(scope, varname.str, val, VAR_SET_NONE);
1166 Var_Append(GNode *scope, const char *name, const char *val)
1170 v = VarFind(name, scope, scope == SCOPE_GLOBAL);
1173 Var_SetWithFlags(scope, name, val, VAR_SET_NONE);
1180 scope->name, name, val);
1181 } else if (scope == SCOPE_CMDLINE || !v->fromCmd) {
1185 DEBUG3(VAR, "%s: %s = %s\n", scope->name, name, v->val.data);
1190 HashTable_CreateEntry(&scope->vars, name, NULL);
1201 * In the scope, expand the variable name once. If the variable exists in the
1202 * scope, add a space and the value, otherwise set the variable to the value.
1204 * Appending to an environment variable only works in the global scope, that
1209 Var_AppendExpand(GNode *scope, const char *name, const char *val)
1215 Var_Expand(&xname, scope, VARE_EVAL);
1220 scope->name, xname.str, val, name);
1222 Var_Append(scope, xname.str, val);
1234 Var_Exists(GNode *scope, const char *name)
1236 Var *v = VarFind(name, scope, true);
1245 * See if the given variable exists, in the given scope or in other
1249 * scope scope in which to start search
1253 Var_ExistsExpand(GNode *scope, const char *name)
1258 Var_Expand(&varname, scope, VARE_EVAL);
1259 exists = Var_Exists(scope, varname.str);
1265 * Return the unexpanded value of the given variable in the given scope,
1277 Var_Value(GNode *scope, const char *name)
1279 Var *v = VarFind(name, scope, true);
1312 * up the variable in any other scope.
1445 GNode *scope;
1469 Var_Expand(&rhs, args->scope, VARE_EVAL);
1670 GNode *scope;
1687 Var_SetWithFlags(args->scope, args->var, word.start,
1689 s = Var_Subst(args->body, args->scope, args->emode);
1996 GNode *const_member scope;
2124 FStr nested_val = Var_Parse(&p, ch->expr->scope,
2385 args.scope = expr->scope;
2416 Var_Delete(expr->scope, args.var);
2457 FStr val = Var_Parse(&p, ch->expr->scope,
2774 pattern = Var_Subst(pattern, expr->scope, expr->emode);
3546 GNode *scope;
3577 scope = expr->scope; /* scope where v belongs */
3578 if (expr->defined == DEF_REGULAR && expr->scope != SCOPE_GLOBAL
3579 && VarFind(expr->name, expr->scope, false) == NULL)
3580 scope = SCOPE_GLOBAL;
3583 Var_Append(scope, expr->name, val.str);
3591 Var_Set(scope, expr->name, output);
3596 Var_Set(scope, expr->name, val.str);
3747 args.scope = expr->scope;
3942 FStr mods = Var_Parse(&p, expr->scope, expr->emode);
4163 UndefinedShortVarValue(char varname, const GNode *scope)
4165 if (scope == SCOPE_CMDLINE || scope == SCOPE_GLOBAL) {
4167 * If substituting a local variable in a non-local scope,
4195 GNode *scope, VarEvalMode emode,
4212 FStr nested_val = Var_Parse(&p, scope, emode);
4251 ParseVarnameShort(char varname, const char **pp, GNode *scope,
4268 v = VarFind(name, scope, true);
4277 val = UndefinedShortVarValue(varname, scope);
4295 FindLocalLegacyVar(Substring varname, GNode *scope,
4300 /* Only resolve these variables if scope is a "real" target. */
4301 if (scope == SCOPE_CMDLINE || scope == SCOPE_GLOBAL)
4312 scope, false);
4350 GNode *scope,
4376 ParseVarname(&p, startc, endc, scope, nested_emode, &varname);
4392 v = VarFindSubstring(name, scope, true);
4405 v = FindLocalLegacyVar(name, scope, out_true_extraModifiers);
4410 * non-local scope since they are not defined there.
4413 (scope == SCOPE_CMDLINE || scope == SCOPE_GLOBAL);
4453 #define Expr_Init(name, value, emode, scope, defined) \
4454 (Expr) { name, value, emode, scope, defined }
4458 VarEvalMode emode, GNode *scope, ExprDefined defined)
4465 expr.scope = scope;
4507 * scope The scope for finding variables.
4531 Var_Parse(const char **pp, GNode *scope, VarEvalMode emode)
4540 * expanded in a non-local scope. The result is the text of the
4549 scope, DEF_REGULAR);
4567 if (!ParseVarnameShort(startc, pp, scope, emode, &val.str, &v))
4572 if (!ParseVarnameLong(&p, startc, scope, emode, expr.emode,
4625 expanded = Var_Subst(Expr_Str(&expr), scope, expr.emode);
4681 VarSubstExpr(const char **pp, Buffer *buf, GNode *scope, VarEvalMode emode)
4685 FStr val = Var_Parse(&nested_p, scope, emode);
4734 * scope The scope in which to start searching for variables.
4739 Var_Subst(const char *str, GNode *scope, VarEvalMode emode)
4750 VarSubstExpr(&p, &res, scope, emode);
4759 Var_SubstInTarget(const char *str, GNode *scope)
4762 EvalStack_Push(VSK_TARGET, scope->name, NULL);
4763 res = Var_Subst(str, scope, VARE_EVAL);
4769 Var_Expand(FStr *str, GNode *scope, VarEvalMode emode)
4775 expanded = Var_Subst(str->str, scope, emode);
4795 /* Print all variables in a scope, sorted by name. */
4797 Var_Dump(GNode *scope)
4806 HashIter_Init(&hi, &scope->vars);
4815 const Var *var = HashTable_FindValue(&scope->vars, varname);