@Override public void visitArrayType(ArrayType arrayType) { // Do not generate array info, as this has to come after the associated variable name visit(arrayType.getBaseType()); }
@Override public void visitArrayType(ArrayType arrayType) { visitChildFromParent(arrayType.getBaseType(), arrayType); }
Type dropQualifiersThatCannotBeUsedForLocalVariable(Type type) { if (type instanceof ArrayType) { return new ArrayType( dropQualifiersThatCannotBeUsedForLocalVariable(((ArrayType) type).getBaseType()), ((ArrayType) type).getArrayInfo()); } if (!(type instanceof QualifiedType)) { return type; } List<TypeQualifier> newQualifiers = new ArrayList<>(); for (TypeQualifier q : ((QualifiedType) type).getQualifiers()) { if (Arrays.asList( TypeQualifier.IN_PARAM, TypeQualifier.INOUT_PARAM, TypeQualifier.OUT_PARAM, TypeQualifier.UNIFORM, TypeQualifier.SHADER_INPUT, TypeQualifier.SHADER_OUTPUT).contains(q)) { continue; } // Many of the other qualifiers are probably not allowed; move them up as we discover this newQualifiers.add(q); } return new QualifiedType(((QualifiedType) type).getTargetType(), newQualifiers); }
boolean typeRefersToUniform(Type type) { if (type.hasQualifier(TypeQualifier.UNIFORM)) { return true; } if (!(type.getWithoutQualifiers() instanceof ArrayType)) { return false; } return typeRefersToUniform(((ArrayType) type.getWithoutQualifiers()).getBaseType()); }
private void processArrayInfo(Type type) { if (!(type.getWithoutQualifiers() instanceof ArrayType)) { return; } ArrayType arrayType = (ArrayType) type.getWithoutQualifiers(); while (true) { out.append("[" + (arrayType.getArrayInfo().hasSize() ? arrayType.getArrayInfo().getSize() : "") + "]"); if (!(arrayType.getBaseType().getWithoutQualifiers() instanceof ArrayType)) { break; } arrayType = (ArrayType) arrayType.getBaseType().getWithoutQualifiers(); } }
private Type stripQualifiers(Type type) { // TODO: when implementing this the only compound type I considered was ArrayType. if (type instanceof QualifiedType) { return stripQualifiers(type.getWithoutQualifiers()); } if (type instanceof ArrayType) { return new ArrayType(stripQualifiers(((ArrayType) type).getBaseType()), ((ArrayType) type).getArrayInfo()); } return type; }
@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); }
List<Expr> args = new ArrayList<>(); for (int i = 0; i < arrayType.getArrayInfo().getSize(); i++) { args.add(makeExpr(arrayType.getBaseType(), isLValue, constContext, depth + 1));