• Home
  • Raw
  • Download

Lines Matching refs:state

45 bool Evaluate(State* state, const std::unique_ptr<Expr>& expr, std::string* result) {  in Evaluate()  argument
50 std::unique_ptr<Value> v(expr->fn(expr->name.c_str(), state, expr->argv)); in Evaluate()
55 ErrorAbort(state, kArgsParsingFailure, "expecting string, got value type %d", v->type); in Evaluate()
63 Value* EvaluateValue(State* state, const std::unique_ptr<Expr>& expr) { in EvaluateValue() argument
64 return expr->fn(expr->name.c_str(), state, expr->argv); in EvaluateValue()
78 Value* ConcatFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) { in ConcatFn() argument
85 if (!Evaluate(state, argv[i], &str)) { in ConcatFn()
94 Value* IfElseFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) { in IfElseFn() argument
96 state->errmsg = "ifelse expects 2 or 3 arguments"; in IfElseFn()
101 if (!Evaluate(state, argv[0], &cond)) { in IfElseFn()
106 return EvaluateValue(state, argv[1]); in IfElseFn()
108 return EvaluateValue(state, argv[2]); in IfElseFn()
114 Value* AbortFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) { in AbortFn() argument
116 if (!argv.empty() && Evaluate(state, argv[0], &msg)) { in AbortFn()
117 state->errmsg += msg; in AbortFn()
119 state->errmsg += "called abort()"; in AbortFn()
124 Value* AssertFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) { in AssertFn() argument
127 if (!Evaluate(state, argv[i], &result)) { in AssertFn()
132 state->errmsg = "assert failed: " + state->script.substr(argv[i]->start, len); in AssertFn()
139 Value* SleepFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) { in SleepFn() argument
141 if (!Evaluate(state, argv[0], &val)) { in SleepFn()
154 Value* StdoutFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) { in StdoutFn() argument
157 if (!Evaluate(state, argv[i], &v)) { in StdoutFn()
165 Value* LogicalAndFn(const char* name, State* state, in LogicalAndFn() argument
168 if (!Evaluate(state, argv[0], &left)) { in LogicalAndFn()
172 return EvaluateValue(state, argv[1]); in LogicalAndFn()
178 Value* LogicalOrFn(const char* name, State* state, in LogicalOrFn() argument
181 if (!Evaluate(state, argv[0], &left)) { in LogicalOrFn()
185 return EvaluateValue(state, argv[1]); in LogicalOrFn()
191 Value* LogicalNotFn(const char* name, State* state, in LogicalNotFn() argument
194 if (!Evaluate(state, argv[0], &val)) { in LogicalNotFn()
201 Value* SubstringFn(const char* name, State* state, in SubstringFn() argument
204 if (!Evaluate(state, argv[0], &needle)) { in SubstringFn()
209 if (!Evaluate(state, argv[1], &haystack)) { in SubstringFn()
217 Value* EqualityFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) { in EqualityFn() argument
219 if (!Evaluate(state, argv[0], &left)) { in EqualityFn()
223 if (!Evaluate(state, argv[1], &right)) { in EqualityFn()
231 Value* InequalityFn(const char* name, State* state, in InequalityFn() argument
234 if (!Evaluate(state, argv[0], &left)) { in InequalityFn()
238 if (!Evaluate(state, argv[1], &right)) { in InequalityFn()
246 Value* SequenceFn(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) { in SequenceFn() argument
247 std::unique_ptr<Value> left(EvaluateValue(state, argv[0])); in SequenceFn()
251 return EvaluateValue(state, argv[1]); in SequenceFn()
254 Value* LessThanIntFn(const char* name, State* state, in LessThanIntFn() argument
257 state->errmsg = "less_than_int expects 2 arguments"; in LessThanIntFn()
262 if (!ReadArgs(state, argv, &args)) { in LessThanIntFn()
269 state->errmsg = "failed to parse int in " + args[0]; in LessThanIntFn()
275 state->errmsg = "failed to parse int in " + args[1]; in LessThanIntFn()
282 Value* GreaterThanIntFn(const char* name, State* state, in GreaterThanIntFn() argument
285 state->errmsg = "greater_than_int expects 2 arguments"; in GreaterThanIntFn()
290 if (!ReadArgs(state, argv, &args)) { in GreaterThanIntFn()
297 state->errmsg = "failed to parse int in " + args[0]; in GreaterThanIntFn()
303 state->errmsg = "failed to parse int in " + args[1]; in GreaterThanIntFn()
310 Value* Literal(const char* name, State* state, const std::vector<std::unique_ptr<Expr>>& argv) { in Literal() argument
352 bool ReadArgs(State* state, const std::vector<std::unique_ptr<Expr>>& argv, in ReadArgs() argument
354 return ReadArgs(state, argv, args, 0, argv.size()); in ReadArgs()
357 bool ReadArgs(State* state, const std::vector<std::unique_ptr<Expr>>& argv, in ReadArgs() argument
367 if (!Evaluate(state, argv[i], &var)) { in ReadArgs()
378 bool ReadValueArgs(State* state, const std::vector<std::unique_ptr<Expr>>& argv, in ReadValueArgs() argument
380 return ReadValueArgs(state, argv, args, 0, argv.size()); in ReadValueArgs()
383 bool ReadValueArgs(State* state, const std::vector<std::unique_ptr<Expr>>& argv, in ReadValueArgs() argument
392 std::unique_ptr<Value> v(EvaluateValue(state, argv[i])); in ReadValueArgs()
404 Value* ErrorAbort(State* state, const char* format, ...) { in ErrorAbort() argument
407 android::base::StringAppendV(&state->errmsg, format, ap); in ErrorAbort()
412 Value* ErrorAbort(State* state, CauseCode cause_code, const char* format, ...) { in ErrorAbort() argument
419 state->errmsg = android::base::Trim(err_message) + "\n"; in ErrorAbort()
420 state->cause_code = cause_code; in ErrorAbort()