use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.
the class Deprecation method getReplacements.
private static String[] getReplacements(ArgumentList arguments) {
IValue value = arguments.get(DEP_REPLACE_PARAM);
if (value == null) {
return null;
}
assert value.valueTag() == IValue.ARRAY;
final ArrayExpr array = (ArrayExpr) value;
final ArgumentList values = array.getValues();
final int size = values.size();
if (size == 0) {
return null;
}
String[] replacements = new String[size];
for (int i = 0; i < size; i++) {
IValue element = values.get(i);
assert element.valueTag() == IValue.STRING;
replacements[i] = element.stringValue();
}
return replacements;
}
use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.
the class TypeChecker method convertValue.
public static IValue convertValue(IValue value, IType type, ITypeContext typeContext, MarkerList markers, IContext context, MarkerSupplier markerSupplier) {
final IType concreteType = type.getConcreteType(typeContext);
final IValue newValue = convertValueDirect(value, concreteType, typeContext, markers, context);
if (newValue != null) {
if (typeContext != null && !typeContext.isReadonly() && type.hasTypeVariables()) {
type.inferTypes(newValue.getType(), typeContext);
}
return newValue;
}
if (value.isResolved()) {
markers.add(markerSupplier.createMarker(value.getPosition(), concreteType, value.getType()));
}
return value;
}
use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.
the class FieldAccess method toCompoundAssignment.
@Override
public IValue toCompoundAssignment(IValue rhs, SourcePosition position, MarkerList markers, IContext context, SideEffectHelper helper) {
// x (op)= z
// -> x = x (op) z
// note that x is only evaluated once
final IValue fieldReceiver = helper.processValue(this.receiver);
this.receiver = fieldReceiver;
return new FieldAssignment(position, fieldReceiver, this.field, rhs);
}
use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.
the class FieldAssignment method withType.
@Override
public IValue withType(IType type, ITypeContext typeContext, MarkerList markers, IContext context) {
if (Types.isVoid(type)) {
return this;
}
final IValue typedValue = this.value.withType(type, typeContext, markers, context);
if (typedValue == null) {
return null;
}
this.value = typedValue;
return this;
}
use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.
the class ICall method wildcardCount.
default int wildcardCount() {
int count = 0;
IValue receiver = this.getReceiver();
if (receiver != null && receiver.isPartialWildcard()) {
count = 1;
}
for (IValue value : this.getArguments()) {
if (value.isPartialWildcard()) {
count++;
}
}
return count;
}
Aggregations