public final MutableByDeclarator mutateTypeKeepingParent(MutableByDeclarator type) { if (type == null) return null; MutableByDeclarator mutated = mutateType(type); if (mutated == null) throw new RuntimeException("Mutation of " + type + " yielded NULL!"); ((Element)mutated).setParentElement(((Element)type).getParentElement()); return mutated; } public static class DirectDeclarator extends Declarator {
public TypeRef createMutatedType() { TypeRef vt = getValueType(); if (vt == null) return null; if (getDeclarator() != null) { MutableByDeclarator type = getDeclarator().mutateType(vt); if (type instanceof TypeRef) return (TypeRef)getDeclarator().mutateType(vt); else { assert false; return null; } } return vt; }
Declarator.MutableByDeclarator mt = p.getValue().mutateType(p.getFirst().getValueType()); return mt instanceof TypeRef ? (TypeRef) mt : null;
Declarator.MutableByDeclarator mt = p.getValue().mutateType(p.getFirst().getValueType()); return mt instanceof TypeRef ? (TypeRef) mt : null;
@Override public MutableByDeclarator mutateType(MutableByDeclarator type) { if (type == null) return null; type = type.clone(); if (type instanceof Function) { TypeRef fs = new TypeRef.FunctionSignature((Function)type).importDetails((Element)type, true); type = (MutableByDeclarator) new TypeRef.Pointer(fs, getPointerStyle()); } else if (type instanceof TypeRef) { type = (MutableByDeclarator) new TypeRef.Pointer((TypeRef)type, getPointerStyle()).importDetails((Element)type, true); } else throw new IllegalArgumentException(type.getClass().getName() + " cannot be mutated by pointer"); ((Element)type).importDetails(this, false); return getTarget() == null ? type : getTarget().mutateType(type); } public Declarator.PointerStyle getPointerStyle() {
f.setArgs(getArgs()); return getTarget().mutateType(f); } else if (type instanceof Function) { Function ff = (Function)type; f.setArgs(getArgs()); return getTarget().mutateType(f); } else { throw new IllegalArgumentException("Function declarator can only mutate type references ! (mutating \"" + type + "\" by \"" + this + "\")");
public MutableByDeclarator mutateType(MutableByDeclarator type) { if (type == null) return null; type = type.clone(); if (type instanceof TypeRef) type = new TypeRef.ArrayRef((TypeRef)type, deepClone(getDimensions())); else if (type instanceof Function) { Function f = (Function)type; f.setValueType(new TypeRef.ArrayRef(f.getValueType(), deepClone(getDimensions()))); type = f; } ((Element)type).importDetails(this, false); return target.mutateType(type); }
Declarator.MutableByDeclarator type = vs.mutateType(v.getValueType()); if (type instanceof TypeRef) { TypeRef tr = (TypeRef) type;
Declarator.MutableByDeclarator type = vs.mutateType(v.getValueType()); if (type instanceof TypeRef) { TypeRef tr = (TypeRef) type;
@Override public void visitArg(Arg arg) { Declarator d = arg.getDeclarator(); if (d == null) { TypeRef tr = arg.getValueType(); if (tr instanceof TypeRef.Pointer) { TypeRef target = ((TypeRef.Pointer)tr).getTarget(); if (target instanceof TypeRef.FunctionSignature) { TypeRef.FunctionSignature fs = (TypeRef.FunctionSignature) target; Identifier name = fs.getFunction() == null ? null : fs.getFunction().getName(); if (name != null) { arg.setDeclarator(new DirectDeclarator(name.toString())); fs.getFunction().setName(null); } } } } else if (!(d instanceof DirectDeclarator)) { MutableByDeclarator type = d.mutateType(arg.getValueType()); if (type instanceof TypeRef) { arg.setValueType((TypeRef) type); arg.setDeclarator(new DirectDeclarator(d.resolveName(), d.getBits(), arg.getDefaultValue())); } else { type = null; } } super.visitArg(arg); } private static final boolean mutateDeclaratorTypes = true;
@Override public void visitArg(Arg arg) { Declarator d = arg.getDeclarator(); if (d == null) { TypeRef tr = arg.getValueType(); if (tr instanceof TypeRef.Pointer) { TypeRef target = ((TypeRef.Pointer)tr).getTarget(); if (target instanceof TypeRef.FunctionSignature) { TypeRef.FunctionSignature fs = (TypeRef.FunctionSignature) target; Identifier name = fs.getFunction() == null ? null : fs.getFunction().getName(); if (name != null) { arg.setDeclarator(new DirectDeclarator(name.toString())); fs.getFunction().setName(null); } } } } else if (!(d instanceof DirectDeclarator)) { MutableByDeclarator type = d.mutateType(arg.getValueType()); if (type instanceof TypeRef) { arg.setValueType((TypeRef) type); arg.setDeclarator(new DirectDeclarator(d.resolveName(), d.getBits(), arg.getDefaultValue())); } else { type = null; } } super.visitArg(arg); } private static final boolean mutateDeclaratorTypes = true;
Declarator.MutableByDeclarator mutatedType = vs.mutateType(v.getValueType()); if (mutatedType instanceof Function) { Function f = (Function) mutatedType;
Declarator.MutableByDeclarator mutatedType = vs.mutateType(v.getValueType()); if (mutatedType instanceof Function) { Function f = (Function) mutatedType;
TypeRef varsType = d.getValueType(); for (Declarator sto : ((VariablesDeclaration) d).getDeclarators()) { Expression so = sizeofToJava(as(sto.mutateType(varsType), TypeRef.class), libraryClassName); if (so == null) { return null;
TypeRef varsType = d.getValueType(); for (Declarator sto : ((VariablesDeclaration) d).getDeclarators()) { Expression so = sizeofToJava(as(sto.mutateType(varsType), TypeRef.class), libraryClassName); if (so == null) { return null;