Creates a dice operand from the parsed context data.
<p>
If the dice is being subtracted then the sign of the dice set is
reversed.

@param ctx
parsed context
@return a dice operand
17724
private final DiceOperand getDiceOperand(final DiceContext ctx) {
        final Dice dice;                     // Parsed dice
        final Integer quantity;              // Number of dice
        final Integer sides;                 // Number of sides
        final Iterator<TerminalNode> digits; // Parsed digits

        // Parses the dice data
        digits = ctx.DIGIT().iterator();

        if (Iterables.size(ctx.DIGIT()) > 1) {
            if ((ctx.ADDOPERATOR() != null) && (SUBTRACTION_OPERATOR
                    .equals(ctx.ADDOPERATOR().getText()))) {
                LOGGER.debug("This is part of a subtraction. Reversing sign.");
                quantity = 0 - Integer.parseInt(digits.next().getText());
            } else {
                quantity = Integer.parseInt(digits.next().getText());
            }
        } else {
            // No quantity of dice defined
            // Defaults to 1
            quantity = 1;
        }
        sides = Integer.parseInt(digits.next().getText());

        // Creates the dice
        dice = new DefaultDice(quantity, sides);

        return new DefaultDiceOperand(dice);
    }
504897
public PackedDecimal subtract(PackedDecimal operand) {
        if (this.isBruch() || operand.isBruch()) {
            return subtract(operand.toBruch());
        } else {
            return subtract(operand.toBigDecimal());
        }
    }
1052986
public static BigDecimal exp(EvaluationContext ctx, Object number) {
        BigDecimal _number = Conversions.toDecimal(number, ctx);
        return ExpressionUtils.decimalPow(E, _number);
    }
881296
public static int trunc(EvaluationContext ctx, Object number) {
        return Conversions.toDecimal(number, ctx).setScale(0, RoundingMode.DOWN).intValue();
    }
441805
@Override
    public VariableExpression visitVariableDeclaratorId(VariableDeclaratorIdContext ctx) {
        return configureAST(new VariableExpression(this.visitIdentifier(ctx.identifier())), ctx);
    }
386759
private Comparison buildComparison(GDLParser.ComparisonExpressionContext ctx) {
    ComparableExpression lhs = extractComparableExpression(ctx.comparisonElement(0));
    ComparableExpression rhs = extractComparableExpression(ctx.comparisonElement(1));
    Comparator comp = Comparator.fromString(ctx .ComparisonOP().getText());

    return new Comparison(lhs, comp, rhs);
  }
881867
@Autowired
    public void setCtx(ApplicationContext _ctx) {
        // in lambda we need to start up the CTX ourselves
        // for unit tests and REST, all the autowiring should happen automatically
        if (LambdaSpringUtil.ctx == null) {
            LambdaSpringUtil.ctx = _ctx;
        }
    }
340076
public static BigDecimal power(EvaluationContext ctx, Object number, Object power) {
        BigDecimal _number = Conversions.toDecimal(number, ctx);
        BigDecimal _power = Conversions.toDecimal(power, ctx);
        return ExpressionUtils.decimalPow(_number, _power);
    }
791041
@Override
    public Object visitNegation(ExcellentParser.NegationContext ctx) {
        return Conversions.toDecimal(visit(ctx.expression()), m_evalContext).negate();
    }
23364
function ctx() {
    return function context(req, res, next) {
        var data = {};

        req.set = function set(key, value) {
            assert.string(key, 'key must be string');

            if (key === '') {
                assert.fail('key must not be empty string');
            }
            data[key] = value;
        };

        req.get = function get(key) {
            assert.string(key, 'key must be string');

            if (key === '') {
                assert.fail('key must not be empty string');
            }
            return data[key];
        };

        // private method which returns the entire context object
        req._getAllContext = function _getAllContext() {
            return data;
        };

        return next();
    };
}
31196
public static BigDecimal mod(EvaluationContext ctx, Object number, Object divisor) {
        BigDecimal _number = Conversions.toDecimal(number, ctx);
        BigDecimal _divisor = Conversions.toDecimal(divisor, ctx);
        return _number.subtract(_divisor.multiply(new BigDecimal(_int(ctx, _number.divide(_divisor, 10, RoundingMode.HALF_UP)))));
    }
1069563
public static BigDecimal abs(EvaluationContext ctx, Object number) {
        return Conversions.toDecimal(number, ctx).abs();
    }
834859
function(ctx) {
    assert(this.args.length >= 1);
    var c = this.args[0].evaluate(ctx).numberValue();
    var ret = [];
    for (var i = 0; i < c; ++i) {
      ret.push(ctx.node);
    }
    return new NodeSetValue(ret);
  }
53478
def base_ctx(ctx):
    """"""

    result = None

    if isclass(ctx):
        result = getattr(ctx, '__base__', None)
        if result is None:
            mro = getmro(ctx)
            if len(mro) > 1:
                result = mro[1]
    else:
        result = ctx.__class__

    return result
1048362
static String toStringIdOrIndex(Context cx, Object id)
    {
        if (id instanceof Number) {
            double d = ((Number)id).doubleValue();
            int index = (int)d;
            if (index == d) {
                storeIndexResult(cx, index);
                return null;
            }
            return toString(id);
        }
        String s;
        if (id instanceof String) {
            s = (String)id;
        } else {
            s = toString(id);
        }
        long indexTest = indexFromString(s);
        if (indexTest >= 0) {
            storeIndexResult(cx, (int)indexTest);
            return null;
        }
        return s;
    }
521448
public static String createSubsetPrefix() {
    	StringBuilder sb = new StringBuilder(8);
        
        for (int k = 0; k < 6; ++k) {
            sb.append( (char)(Math.random() * 26 + 'A') );
        }
        sb.append("+");
        return sb.toString();
    }
270862
function factory(ctx) {
  decoder.raw = decodeRaw

  return decoder

  // Normalize `position` to add an `indent`.
  function normalize(position) {
    var offsets = ctx.offset
    var line = position.line
    var result = []

    while (++line) {
      if (!(line in offsets)) {
        break
      }

      result.push((offsets[line] || 0) + 1)
    }

    return {start: position, indent: result}
  }

  // Decode `value` (at `position`) into text-nodes.
  function decoder(value, position, handler) {
    entities(value, {
      position: normalize(position),
      warning: handleWarning,
      text: handler,
      reference: handler,
      textContext: ctx,
      referenceContext: ctx
    })
  }

  // Decode `value` (at `position`) into a string.
  function decodeRaw(value, position, options) {
    return entities(
      value,
      xtend(options, {position: normalize(position), warning: handleWarning})
    )
  }

  // Handle a warning.
  // See <https://github.com/wooorm/parse-entities> for the warnings.
  function handleWarning(reason, position, code) {
    if (code !== 3) {
      ctx.file.message(reason, position)
    }
  }
}