public boolean isBoolean() { return getElementType() == BOOL; }
private static String get(BasicType type, boolean isArray) { String result = "glUniform"; if (type.isMatrix()) { throw new RuntimeException("Not dealing with matrices yet."); } result += type.getNumElements(); if (type.getElementType() == BasicType.FLOAT) { result += "f"; } else if (type.getElementType() == BasicType.INT) { result += "i"; } else if (type.getElementType() == BasicType.UINT) { result += "ui"; } else { assert type.getElementType() == BasicType.BOOL; result += "i"; } if (isArray) { result += "v"; } return result; }
public MergeSet(ScopeEntry entry) { this.elementType = ((BasicType) entry.getType().getWithoutQualifiers()).getElementType(); this.entries = new ArrayList<>(); entries.add(entry); }
public static Expr getBasicTypeLiteralExpr(BasicType baseType, List<Number> args) { List<Expr> argExprs; if (baseType.getElementType() == BasicType.FLOAT) { argExprs = args.stream().map(item -> new FloatConstantExpr(item.toString())) .collect(Collectors.toList()); } else if (baseType.getElementType() == BasicType.UINT) { argExprs = args.stream().map(item -> new UIntConstantExpr(item.toString() + "u")) .collect(Collectors.toList()); } else { argExprs = args.stream().map(item -> new IntConstantExpr(item.toString())) .collect(Collectors.toList()); } if (argExprs.size() == 1) { return argExprs.get(0); } return new TypeConstructorExpr(baseType.toString(), argExprs); }
@Override public Expr apply(Expr expr, BasicType type, boolean constContext, int depth, Fuzzer fuzzer) { // expr * 1 // or // 1 * expr // or // expr / 1 assert type.getElementType() != BasicType.BOOL; final BinOp operator = generator.nextBoolean() ? BinOp.MUL : BinOp.DIV; return applyBinaryIdentityFunction(expr, makeOpaqueOne(type, constContext, depth, fuzzer), operator, operator == BinOp.MUL, type, constContext, depth, fuzzer); }
private Expr makeRegularIntegerValuedLiteral(BasicType type, String integerPart) { assert type.getElementType() != BasicType.BOOL; if (type == BasicType.FLOAT) { return new FloatConstantExpr(integerPart + ".0"); } if (type == BasicType.INT) { return new IntConstantExpr(integerPart); } if (type == BasicType.UINT) { return new UIntConstantExpr(integerPart + "u"); } List<Expr> args = new ArrayList<>(); for (int i = 0; i < type.getNumElements(); i++) { assert type.getElementType() != type; args.add(makeRegularIntegerValuedLiteral(type.getElementType(), integerPart)); } return new TypeConstructorExpr(type.toString(), args); }
public boolean canAccept(ScopeEntry entry) { BasicType basicType = (BasicType) entry.getType().getWithoutQualifiers(); if (!(basicType.getElementType().equals(elementType))) { return false; } if (entries.stream() .anyMatch(x -> x.getVariablesDeclaration() == entry.getVariablesDeclaration())) { return false; } return currentWidth() + basicType.getNumElements() <= MAX_WIDTH; }
if (basicType.getElementType() == BasicType.FLOAT) { values.add(floatSupplier.get()); } else if (basicType.getElementType() == BasicType.INT) { values.add(intSupplier.get()); } else if (basicType.getElementType() == BasicType.UINT) { values.add(uintSupplier.get()); } else { assert basicType.getElementType() == BasicType.BOOL; values.add(boolSupplier.get());
/** * Yields the basic type that the component we are pulling out should have. * @return The basic type of the component. */ public BasicType getComponentType() { return BasicType.makeVectorType( ((BasicType) vectorVariablesDeclaration.getBaseType().getWithoutQualifiers()) .getElementType(), componentData.getWidth()); }
@Override public void visitArrayIndexExpr(ArrayIndexExpr arrayIndexExpr) { super.visitArrayIndexExpr(arrayIndexExpr); Type arrayType = lookupType(arrayIndexExpr.getArray()); if (arrayType == null) { return; } arrayType = arrayType.getWithoutQualifiers(); Type elementType; if (BasicType.allVectorTypes().contains(arrayType)) { elementType = ((BasicType) arrayType).getElementType(); } else if (BasicType.allMatrixTypes().contains(arrayType)) { elementType = ((BasicType) arrayType).getColumnType(); } else { assert arrayType instanceof ArrayType; elementType = ((ArrayType) arrayType).getBaseType(); } types.put(arrayIndexExpr, elementType); }
@Override public Expr getCanonicalConstant() { if (this == FLOAT) { return new FloatConstantExpr("1.0"); } if (this == INT) { return new IntConstantExpr("1"); } if (this == UINT) { return new UIntConstantExpr("1u"); } if (this == BOOL) { return BoolConstantExpr.TRUE; } return new TypeConstructorExpr(toString().toString(), getElementType().getCanonicalConstant()); }
.makeVectorType(vecType.getElementType(), memberLookupExpr.getMember().length())); final BasicType v = BasicType.makeVectorType(vecType.getElementType(), memberLookupExpr.getMember().length()); types.put(memberLookupExpr, v);
final Expr something = fuzzedConstructor(fuzzer.fuzzExpr(type.getElementType(), false, true, depth)); Expr index = type.isVector() index = applyIdentityFunction(index, type.getElementType(), constContext, depth, fuzzer);