mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-18 07:11:53 +03:00
make fields not public
This commit is contained in:
parent
8482430299
commit
016b669a8d
@ -44,14 +44,33 @@ impl fmt::Display for ParamMode {
|
||||
pub struct FunctionInputVariable {
|
||||
/// The name the parameter is accessible as in the function's body.
|
||||
pub identifier: Identifier,
|
||||
/// Is it a const parameter?
|
||||
pub mode: ParamMode,
|
||||
/// The mode of the function parameter.
|
||||
mode: ParamMode,
|
||||
/// What's the parameter's type?
|
||||
pub type_: Type,
|
||||
type_: Type,
|
||||
/// The parameters span from any annotations to its type.
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl FunctionInputVariable {
|
||||
pub fn new(identifier: Identifier, mode: ParamMode, type_: Type, span: Span) -> Self {
|
||||
Self {
|
||||
identifier,
|
||||
mode,
|
||||
type_,
|
||||
span,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mode(&self) -> ParamMode {
|
||||
self.mode
|
||||
}
|
||||
|
||||
pub fn type_(&self) -> Type {
|
||||
self.type_.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl FunctionInputVariable {
|
||||
fn format(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{} ", self.mode)?;
|
||||
|
@ -282,7 +282,7 @@ impl<R: ReconstructingReducer> ReconstructingDirector<R> {
|
||||
variable: &FunctionInputVariable,
|
||||
) -> Result<FunctionInputVariable> {
|
||||
let identifier = self.reduce_identifier(&variable.identifier)?;
|
||||
let type_ = self.reduce_type(&variable.type_, &variable.span)?;
|
||||
let type_ = self.reduce_type(&variable.type_(), &variable.span)?;
|
||||
|
||||
self.reducer.reduce_function_input_variable(variable, identifier, type_)
|
||||
}
|
||||
|
@ -272,12 +272,12 @@ pub trait ReconstructingReducer {
|
||||
identifier: Identifier,
|
||||
type_: Type,
|
||||
) -> Result<FunctionInputVariable> {
|
||||
Ok(FunctionInputVariable {
|
||||
Ok(FunctionInputVariable::new(
|
||||
identifier,
|
||||
mode: variable.mode,
|
||||
variable.mode(),
|
||||
type_,
|
||||
span: variable.span.clone(),
|
||||
})
|
||||
variable.span.clone(),
|
||||
))
|
||||
}
|
||||
|
||||
fn reduce_function_input(&mut self, _input: &FunctionInput, new: FunctionInput) -> Result<FunctionInput> {
|
||||
|
@ -91,12 +91,12 @@ impl ParserContext<'_> {
|
||||
|
||||
self.expect(Token::Colon)?;
|
||||
let type_ = self.parse_type()?.0;
|
||||
Ok(FunctionInput::Variable(FunctionInputVariable {
|
||||
Ok(FunctionInput::Variable(FunctionInputVariable::new(
|
||||
name.clone(),
|
||||
mode,
|
||||
type_,
|
||||
span: name.span.clone(),
|
||||
identifier: name,
|
||||
}))
|
||||
name.span,
|
||||
)))
|
||||
}
|
||||
|
||||
/// Returns an [`(Identifier, Function)`] AST node if the next tokens represent a function name
|
||||
|
Loading…
Reference in New Issue
Block a user