Calc expression value
428839
function _execute($vm, $scope/*, expression, [label], [target]*/) {
    /**
     *  $scope is passed when call instance method $compile, 
     *  Each "scope" object maybe include "$parent, data, methods" properties
     */
    // var $parent = $scope && $scope.$parent ? util.extend({}, $scope.$parent.methods, $scope.$parent.data) : {}
    if ($scope && $scope.$parent) {
        $scope.data.$parent = $scope.$parent.data
    }
    var __$expression__ = arguments[2]
    var __$fn__ = __$compiledExprs___[__$expression__]
    $scope = $scope || {}
    $scope = util.extend({}, $vm.$methods, $vm.$data, $scope.methods, $scope.data)
    try {
        if (!__$fn__) {
            __$fn__ = __$compiledExprs___[__$expression__] = __$compile__(__$expression__)
        }
        return util.immutable(__$fn__($scope))
    } catch (e) {
        __$expression__ = /^\{/.test(__$expression__) 
                        ? '. ' + __$expression__
                        : '. {' + __$expression__ + '}' // expr
        // arguments[3] // label
        // arguments[4] // target
        switch (e.name) {
            case 'ReferenceError':
                console.warn(e.message + __$expression__)
                break
            default:
                console.error(
                     (arguments[3] ? '\'' + arguments[3] + '\': ' : ''),
                    e.message + __$expression__,
                    arguments[4] || ''
                )
        }
        return ''
    }
}
1137209
def expr(obj, simplify=True):
    """"""
    if isinstance(obj, Expression):
        return obj
    # False, True, 0, 1
    elif isinstance(obj, int) and obj in {0, 1}:
        return _CONSTS[obj]
    elif isinstance(obj, str):
        ast = pyeda.parsing.boolexpr.parse(obj)
        ex = ast2expr(ast)
        if simplify:
            ex = ex.simplify()
        return ex
    else:
        return One if bool(obj) else Zero
192048
function (item, expression) {
            var ret = 1,
                operator = expression.operator;

            if (expression instanceof Query.Where) {
                if (operator === "or") {
                    ret = 0;
                }
                var tmp;
                for (var i = 0; i < expression.expressions.length; i++) {
                    tmp = this._filterItem(item, expression.expressions[i]);
                    if (operator === "and") {
                        ret = ret * tmp;
                    } else if (operator === "or" && tmp) {
                        return 1;
                    } else if (operator === "not") {
                        return tmp ? 0 : 1;
                    }
                }
            } else if (expression instanceof Query.Comparator) {
                // TODO: add type check
                var value = expression.value,
                    field = expression.field,
                    itemValue = this._getValueForItemField(item, field);

                if (typeof(itemValue) === "undefined") {
                    return 0;
                }

                switch (operator) {
                    case "eql":
                        return itemValue == value;
                    case "gt":
                        return itemValue > value;
                    case "lt":
                        return itemValue < value;
                    case "gte":
                        return itemValue >= value;
                    case "lte":
                        return itemValue <= value;
                    case "in":
                        if (!(itemValue instanceof Array)) {
                            itemValue = [itemValue];
                        }
                        for (var j = 0; j < itemValue.length; j++) {
                            for (var k in value) {
                                if (value.hasOwnProperty(k)) {
                                    if (itemValue[j] == value[k]) {
                                        return 1;
                                    }
                                }
                            }
                        }
                        return 0;
                    case "between":
                        return itemValue >= value[0] && itemValue <= value[1];
                    case "like":
                        return new RegExp(value, "i").test(itemValue);
                    case "ne":
                        return itemValue != value;
                    default :
                        return 1;
                }

            }

            return ret;
        }
976482
@Override
    public Object getValueAt(int row, int column) {
        switch (column) {
        case 0:
            return expressions.get(row);
        case 1:
            return values.get(row);
        }
        return "";
    }
1123261
function computeValue(valueStr) {
    var resultStr = '';
    // length data unit
    var unit = ['%', 'in', 'cm', 'mm', 'em', 'ex', 'pt', 'pc', 'px', 'rem', 'vh', 'vw', 'vmin', 'vmax', 'ch'];
    var unitStr = unit.join('|');
    var unitRE = new RegExp(unitStr, 'g');
    var tempStr = valueStr.match(unitRE)[0];
    if(tempStr) {
        valueStr = valueStr.replace(tempStr, '');
        valueStr = eval(valueStr);
        resultStr = valueStr + tempStr;
    }
    return resultStr;
}
52976
static double getPercent( Expression expression, CssFormatter formatter ) {
        double d = expression.doubleValue( formatter );
        if( expression.getDataType( formatter ) == Expression.PERCENT ) {
            d /= 100;
        } else if( d > 1.0 && d == (int)d ) {
            d /= 100;
        }
        return d;
    }
53471
function parseValue(expr) {
  switch(expr.kind) {
    case 'array':
      if (expr.items.length === 0) {
        return [];
      }
      var isKeyed = expr.items.every((item) => item.key !== null)
      var items = expr.items.map(parseValue)
      if (isKeyed) {
        items = items.reduce((acc, val) => Object.assign({}, acc, val), {})
      }
      return items
    case 'entry':
      if (expr.key) {
        return { [parseKey(expr.key)]: parseValue(expr.value) }
      }
      return parseValue(expr.value)
    case 'string':
      return expr.value
    case 'number':
      return parseInt(expr.value, 10)
    case 'boolean':
      return expr.value
    default:
      throw new Error(`Unexpected PHP value: "${expr.kind}", details: ${JSON.stringify(expr)}`)
  }
}
999751
def in_global_expression(self):
        """"""
        return (self.parenthesis_count == 0 and self.curly_bracket_count == 0
                and self.square_bracket_count == 0
                and not self.in_single_quote and not self.in_double_quote)
391916
function parseAnimationValue(value) {
  value = value.toString();

  if (value === 'initial') {
    value = 0;
  } else if (/ms$/.test(value)) {
    value = parseFloat(value);
  } else {
    value = parseFloat(value) * 1000;
  }

  return value;
}
594317
function getExpressionValue (varName, scssExpression) {
    if (is.undef(scssExpression) || is.args.empty(arguments)) {
        message('Error: Missing arguments');
        return undefined;
    }

    if (!is.string(varName) || !is.string(scssExpression)) {
        message('Error: Check arguments type');
        return undefined;
    }

    if (!~scssExpression.indexOf('$')) {
        message('Warning: Check scssExpression to contain valid code')
    }

    // print the interpolated value in comment string
    // /*#{$varName}*/ --> /*varValue*/
    const scssContent = `${scssExpression}/*#{$${varName}}*/`;

    const sassResult = sass.renderSync({
        data: scssContent
    });

    const cssResult = sassResult.css.toString();

    return extractExpressionValue(cssResult);
}
574673
def _get_val(self, soln, r, c):
        """"""
        for v in range(1, 10):
            if soln[self.X[r, c, v]]:
                return DIGITS[v-1]
        return "X"
866300
public void calc() {
    if (null != functionOccurences) {
      Iterator iterator = functionOccurences.iterator();
      while (iterator.hasNext()) {
        int[] position = (int[]) iterator.next();
        String functionString = ((String) getXY(position[0], position[1])).trim();
        // better use RegEx
        String name = functionString.substring(1, functionString.indexOf("(")).trim().toLowerCase();

        String range = functionString.substring(functionString.indexOf("(") + 1, functionString.indexOf(")"));
        int colon = range.indexOf(":");
        String start = range.substring(0, colon).trim();
        String end = range.substring(colon + 1).trim();

        int startX = start.charAt(0) - 'A';
        int startY = Integer.parseInt(start.substring(1)) - 1;
        int endX = end.charAt(0) - 'A';
        int endY = Integer.parseInt(end.substring(1)) - 1;

        // normalize range, start is left top, end is bottom right
        if (startX > endX) {
          int tmp = startX;
          startX = endX;
          endX = tmp;
        }

        if (startY > endY) {
          int tmp = startY;
          startY = endY;
          endY = tmp;
        }

        //Logger.debug("Calc: " + position[0] + " " + position[1] + " " + function + " " + start + " " + end);
        //Logger.debug("Calc: " + startX+","+startY+" - "+endX+","+endY);

        if (functions.containsKey(name)) {
          Function function = (Function) functions.get(name);
          function.execute(this, position[0], position[1], startX,startY,endX,endY);
        }
      }
    }
    return;

  }
1029211
def value(self):
        '''
        
        '''
        (counter_type, value) = win32pdh.GetFormattedCounterValue(
            self.handle, win32pdh.PDH_FMT_DOUBLE)
        self.type = counter_type
        return value
942004
function processValue(value) {
    if (isNaN(value)) return 0;

    value = Math.max(MIN_VALUE, Math.min(value, MAX_VALUE));

    //value is between 0 and 1, thus is interpreted as percentage
    if (value < 1) value = value * MAX_VALUE;

    value = parseInt(value, 10);

    return value;
}
962193
@SuppressWarnings("squid:S1698")
    private Expression literalAtom() {
        if (tokenizer.current().isSymbol("+") && tokenizer.next().isNumber()) {
            // Parse numbers with a leading + sign like +2.02 by simply ignoring the +
            tokenizer.consume();
        }
        if (tokenizer.current().isNumber()) {
            double value = Double.parseDouble(tokenizer.consume().getContents());
            if (tokenizer.current().is(Token.TokenType.ID)) {
                String quantifier = tokenizer.current().getContents().intern();
                if ("n" == quantifier) {
                    value /= 1000000000d;
                    tokenizer.consume();
                } else if ("u" == quantifier) {
                    value /= 1000000d;
                    tokenizer.consume();
                } else if ("m" == quantifier) {
                    value /= 1000d;
                    tokenizer.consume();
                } else if ("K" == quantifier || "k" == quantifier) {
                    value *= 1000d;
                    tokenizer.consume();
                } else if ("M" == quantifier) {
                    value *= 1000000d;
                    tokenizer.consume();
                } else if ("G" == quantifier) {
                    value *= 1000000000d;
                    tokenizer.consume();
                } else {
                    Token token = tokenizer.consume();
                    errors.add(ParseError.error(token,
                                                String.format("Unexpected token: '%s'. Expected a valid quantifier.",
                                                              token.getSource())));
                }
            }
            return new Constant(value);
        }
        Token token = tokenizer.consume();
        errors.add(ParseError.error(token,
                                    String.format("Unexpected token: '%s'. Expected an expression.",
                                                  token.getSource())));
        return Constant.EMPTY;
    }
718547
function calcValueInfo(valueToken) {
    const text = valueToken.htmlValue
    const firstChar = text[0]
    const quote = firstChar === "'" || firstChar === '"' ? firstChar : undefined
    const content = quote ? text.slice(1, -1) : text
    return {
        quote,
        content,
    }
}
11944
public double calculateValue(double value) {
		JexlContext context = new MapContext();
		context.set(getArg(), value);
		return (double) expression.evaluate(context);
	}