MCPcopy Create free account
hub / github.com/crownengine/crown / power

Function power

3rdparty/tinyexpr/tinyexpr.c:422–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420
421
422static te_expr *power(state *s) {
423 /* <power> = {("-" | "+")} <base> */
424 int sign = 1;
425 while (s->type == TOK_INFIX && (s->function == add || s->function == sub)) {
426 if (s->function == sub) sign = -sign;
427 next_token(s);
428 }
429
430 te_expr *ret;
431
432 if (sign == 1) {
433 ret = base(s);
434 } else {
435 te_expr *b = base(s);
436 CHECK_NULL(b);
437
438 ret = NEW_EXPR(TE_FUNCTION1 | TE_FLAG_PURE, b);
439 CHECK_NULL(ret, te_free(b));
440
441 ret->function = negate;
442 }
443
444 return ret;
445}
446
447#ifdef TE_POW_FROM_RIGHT
448static te_expr *factor(state *s) {

Callers 3

baseFunction · 0.85
factorFunction · 0.85
load_apiFunction · 0.85

Calls 3

next_tokenFunction · 0.85
baseFunction · 0.85
te_freeFunction · 0.85

Tested by

no test coverage detected