some clean up

This commit is contained in:
gluax 2021-04-13 15:33:00 -04:00
parent a54488b45f
commit dc5d75da85
3 changed files with 1 additions and 21 deletions

View File

@ -216,6 +216,7 @@ impl<'a, F: PrimeField, G: GroupType<F>> Compiler<'a, F, G> {
// Use the parser to construct the abstract syntax tree (ast).
let mut ast = parse_ast(self.main_file_path.to_str().unwrap_or_default(), program_string)?;
// Preform compiler optimization via canonicalizing AST if its enabled.
if self.options.canonicalization_enabled {
ast.canonicalize()?;

View File

@ -22,18 +22,6 @@ pub struct CompilerOptions {
pub canonicalization_enabled: bool,
pub constant_folding_enabled: bool,
pub dead_code_elimination_enabled: bool,
pub type_inference_enabled: bool,
}
impl CompilerOptions {
pub fn new_all_false() -> Self {
Self {
canonicalization_enabled: false,
constant_folding_enabled: false,
dead_code_elimination_enabled: false,
type_inference_enabled: false,
}
}
}
impl Default for CompilerOptions {
@ -45,7 +33,6 @@ impl Default for CompilerOptions {
canonicalization_enabled: true,
constant_folding_enabled: true,
dead_code_elimination_enabled: true,
type_inference_enabled: true,
}
}
}

View File

@ -152,10 +152,6 @@ impl<R: ReconstructingReducer, O: CombinerOptions> CombineAstAsgDirector<R, O> {
asg: &AsgExpression,
) -> Result<AstExpression, ReducerError> {
let new = match (ast, asg) {
// TODO what to do for the following:
// Ast::Identifier, Asg::ValueRef
// AsgExpression::Identifier(identifier) => AsgExpression::Identifier(self.reduce_identifier(&identifier)?),
(AstExpression::Value(value), AsgExpression::Constant(const_)) => {
AstExpression::Value(self.reduce_value(&value, &const_)?)
}
@ -313,11 +309,9 @@ impl<R: ReconstructingReducer, O: CombinerOptions> CombineAstAsgDirector<R, O> {
ast: &CircuitMemberAccessExpression,
_asg: &AsgCircuitAccessExpression,
) -> Result<CircuitMemberAccessExpression, ReducerError> {
// TODO FIGURE IT OUT
// let circuit = self.reduce_expression(&circuit_member_access.circuit)?;
// let name = self.reduce_identifier(&circuit_member_access.name)?;
// let target = input.target.get().map(|e| self.reduce_expression(e));
// does it matter?
self.ast_reducer
.reduce_circuit_member_access(ast, *ast.circuit.clone(), ast.name.clone())
@ -328,11 +322,9 @@ impl<R: ReconstructingReducer, O: CombinerOptions> CombineAstAsgDirector<R, O> {
ast: &CircuitStaticFunctionAccessExpression,
_asg: &AsgCircuitAccessExpression,
) -> Result<CircuitStaticFunctionAccessExpression, ReducerError> {
// TODO FIGURE IT OUT
// let circuit = self.reduce_expression(&circuit_member_access.circuit)?;
// let name = self.reduce_identifier(&circuit_member_access.name)?;
// let target = input.target.get().map(|e| self.reduce_expression(e));
// does it matter?
self.ast_reducer
.reduce_circuit_static_fn_access(ast, *ast.circuit.clone(), ast.name.clone())