MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / power

Function power

extern/tinyexpr/tinyexpr.c:395–413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393
394
395static te_expr *power(state *s) {
396 /* <power> = {("-" | "+")} <base> */
397 int sign = 1;
398 while (s->type == TOK_INFIX && (s->function == add || s->function == sub)) {
399 if (s->function == sub) sign = -sign;
400 next_token(s);
401 }
402
403 te_expr *ret;
404
405 if (sign == 1) {
406 ret = base(s);
407 } else {
408 ret = NEW_EXPR(TE_FUNCTION1 | TE_FLAG_PURE, base(s));
409 ret->function = negate;
410 }
411
412 return ret;
413}
414
415#ifdef TE_POW_FROM_RIGHT
416static te_expr *factor(state *s) {

Callers 2

baseFunction · 0.85
factorFunction · 0.85

Calls 2

next_tokenFunction · 0.85
baseFunction · 0.85

Tested by

no test coverage detected