use of org.elasticsearch.painless.Definition.Type in project elasticsearch by elastic.
the class SDeclaration method analyze.
@Override
void analyze(Locals locals) {
final Type type;
try {
type = Definition.getType(this.type);
} catch (IllegalArgumentException exception) {
throw createError(new IllegalArgumentException("Not a type [" + this.type + "]."));
}
if (expression != null) {
expression.expected = type;
expression.analyze(locals);
expression = expression.cast(locals);
}
variable = locals.addVariable(location, type, name, false);
}
use of org.elasticsearch.painless.Definition.Type in project elasticsearch by elastic.
the class EBinary method analyzeUSH.
private void analyzeUSH(Locals variables) {
left.analyze(variables);
right.analyze(variables);
Type lhspromote = AnalyzerCaster.promoteNumeric(left.actual, false);
Type rhspromote = AnalyzerCaster.promoteNumeric(right.actual, false);
actual = promote = lhspromote;
shiftDistance = rhspromote;
if (lhspromote == null || rhspromote == null) {
throw createError(new ClassCastException("Cannot apply unsigned shift [>>>] to types " + "[" + left.actual.name + "] and [" + right.actual.name + "]."));
}
if (lhspromote.sort == Sort.DEF || rhspromote.sort == Sort.DEF) {
left.expected = left.actual;
right.expected = right.actual;
if (expected != null) {
actual = expected;
}
} else {
left.expected = lhspromote;
if (rhspromote.sort == Sort.LONG) {
right.expected = Definition.INT_TYPE;
right.explicit = true;
} else {
right.expected = rhspromote;
}
}
left = left.cast(variables);
right = right.cast(variables);
if (left.constant != null && right.constant != null) {
Sort sort = lhspromote.sort;
if (sort == Sort.INT) {
constant = (int) left.constant >>> (int) right.constant;
} else if (sort == Sort.LONG) {
constant = (long) left.constant >>> (int) right.constant;
} else {
throw createError(new IllegalStateException("Illegal tree structure."));
}
}
}
use of org.elasticsearch.painless.Definition.Type in project elasticsearch by elastic.
the class EConditional method analyze.
@Override
void analyze(Locals locals) {
condition.expected = Definition.BOOLEAN_TYPE;
condition.analyze(locals);
condition = condition.cast(locals);
if (condition.constant != null) {
throw createError(new IllegalArgumentException("Extraneous conditional statement."));
}
left.expected = expected;
left.explicit = explicit;
left.internal = internal;
right.expected = expected;
right.explicit = explicit;
right.internal = internal;
actual = expected;
left.analyze(locals);
right.analyze(locals);
if (expected == null) {
final Type promote = AnalyzerCaster.promoteConditional(left.actual, right.actual, left.constant, right.constant);
left.expected = promote;
right.expected = promote;
actual = promote;
}
left = left.cast(locals);
right = right.cast(locals);
}
Aggregations