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