@Override public ArrayConstructorExpr clone() { List<Expr> newArgs = args.stream().map(Expr::clone).collect(Collectors.toList()); return new ArrayConstructorExpr(arrayType.clone(), newArgs); }
@Override public void setChild(int index, Expr expr) { checkBounds(index); args.set(index, expr); }
@Override public void visitArrayConstructorExpr(ArrayConstructorExpr arrayConstructorExpr) { for (Expr e : arrayConstructorExpr.getArgs()) { visitChildFromParent(e, arrayConstructorExpr); } }
@Override public void visitArrayConstructorExpr(ArrayConstructorExpr arrayConstructorExpr) { visit(arrayConstructorExpr.getArrayType()); out.append("[" + arrayConstructorExpr.getArrayType().getArrayInfo().getSize() + "]("); boolean first = true; for (Expr e : arrayConstructorExpr.getArgs()) { if (!first) { out.append(", "); } first = false; visit(e); } out.append(")"); }
private void checkBounds(int index) { if (!(index >= 0 && index < getNumChildren())) { throw new IndexOutOfBoundsException("No child at index " + index); } }
private static Initializer makeInitializer(BasicType baseType, ArrayInfo arrayInfo, List<Number> args) { if (arrayInfo != null) { assert arrayInfo.getSize() * baseType.getNumElements() == args.size(); List<Expr> argExprs = new ArrayList<>(); for (int index = 0; index < arrayInfo.getSize(); index++) { argExprs.add(getBasicTypeLiteralExpr(baseType, args.subList(index * baseType.getNumElements(), (index + 1) * baseType.getNumElements()))); } return new ScalarInitializer(new ArrayConstructorExpr( new ArrayType(baseType.getWithoutQualifiers(), arrayInfo.clone()), argExprs)); } return new ScalarInitializer(getBasicTypeLiteralExpr(baseType, args)); }
@Override public Expr getChild(int index) { checkBounds(index); return args.get(index); }
args.add(makeExpr(arrayType.getBaseType(), isLValue, constContext, depth + 1)); return new ArrayConstructorExpr((ArrayType) stripQualifiers(targetType), args); } else { throw new FuzzedIntoACornerException();
if (isBuiltinTypeConstructor(header.function_identifier())) { if (header.array_specifier() != null) { return new ArrayConstructorExpr( new ArrayType( getBuiltinType(header.function_identifier().builtin_type_specifier_nonarray()), final StructNameType structType = new StructNameType( header.function_identifier().variable_identifier().getText()); return new ArrayConstructorExpr( new ArrayType(structType, getArrayInfo(header.array_specifier())), params);