package org.shedlang.compiler.patio; import org.pcollections.PVector; import org.shedlang.compiler.patio.types.PatioType; import org.shedlang.compiler.sources.Source; import org.shedlang.compiler.sources.Sources; import org.shedlang.compiler.util.P; import java.util.List; public record PatioFunctionDeclaration( String name, List params, List returnTypes, Source source ) implements PatioCompilationUnitElement { public static Builder builder() { return new Builder( "f", P.vector(), P.vector() ); } public record Builder( String name, PVector params, PVector returnTypes ) { public Builder withName(String name) { return new Builder( name, this.params, this.returnTypes ); } public Builder addParam(PatioLocal param) { return new Builder( this.name, this.params.plus(param), this.returnTypes ); } public Builder addReturnType(PatioType returnType) { return new Builder( this.name, this.params, this.returnTypes.plus(returnType) ); } public PatioFunctionDeclaration build() { return new PatioFunctionDeclaration( this.name, this.params, this.returnTypes, Sources.NULL ); } } }