Remove most unused variables
This commit is contained in:
parent
009095f771
commit
96595d8fb6
@ -44,7 +44,7 @@ impl<'a> Reducer<'a> {
|
||||
ast::StatementKind::Expression(expr) => {
|
||||
entrypoint.push(Statement::Expression(self.expression(&expr)));
|
||||
},
|
||||
ast::StatementKind::Declaration(ast::Declaration::Binding { name, constant, expr, ..}) => {
|
||||
ast::StatementKind::Declaration(ast::Declaration::Binding { name: _, constant, expr, ..}) => {
|
||||
let symbol = self.symbol_table.lookup_symbol(item_id).unwrap();
|
||||
entrypoint.push(Statement::Binding { id: symbol.def_id.clone(), constant: *constant, expr: self.expression(&expr) });
|
||||
},
|
||||
@ -73,7 +73,7 @@ impl<'a> Reducer<'a> {
|
||||
_ => ()
|
||||
},
|
||||
ast::StatementKind::Import(..) => (),
|
||||
ast::StatementKind::Module(modspec) => {
|
||||
ast::StatementKind::Module(_modspec) => {
|
||||
//TODO handle modules
|
||||
()
|
||||
}
|
||||
@ -132,7 +132,7 @@ impl<'a> Reducer<'a> {
|
||||
body: self.function(body),
|
||||
})
|
||||
},
|
||||
NamedStruct { name, fields } => Expression::ReductionError("NamedStruct not implemented".to_string()), //self.reduce_named_struct(name, fields),
|
||||
NamedStruct { .. } => Expression::ReductionError("NamedStruct not implemented".to_string()), //self.reduce_named_struct(name, fields),
|
||||
Index { .. } => Expression::ReductionError("Index expr not implemented".to_string()),
|
||||
WhileExpression { .. } => Expression::ReductionError("While expr not implemented".to_string()),
|
||||
ForExpression { .. } => Expression::ReductionError("For expr not implemented".to_string()),
|
||||
@ -140,7 +140,7 @@ impl<'a> Reducer<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn reduce_if_expression(&mut self, discriminator: Option<&ast::Expression>, body: &ast::IfExpressionBody) -> Expression {
|
||||
fn reduce_if_expression(&mut self, _discriminator: Option<&ast::Expression>, _body: &ast::IfExpressionBody) -> Expression {
|
||||
Expression::ReductionError("if expr".to_string())
|
||||
}
|
||||
|
||||
@ -210,7 +210,8 @@ impl<'a> Reducer<'a> {
|
||||
fn value(&mut self, qualified_name: &ast::QualifiedName) -> Expression {
|
||||
use SymbolSpec::*;
|
||||
|
||||
let ast::QualifiedName { id, components, .. } = qualified_name;
|
||||
let ast::QualifiedName { id: _, components, .. } = qualified_name;
|
||||
let _ = components;
|
||||
|
||||
let symbol = match self.symbol_table.lookup_symbol(&qualified_name.id) {
|
||||
Some(s) => s,
|
||||
@ -222,7 +223,7 @@ impl<'a> Reducer<'a> {
|
||||
GlobalBinding => Expression::Lookup { id: def_id.clone(), kind: Lookup::GlobalVar },
|
||||
LocalVariable => Expression::Lookup { id: def_id.clone(), kind: Lookup::LocalVar },
|
||||
FunctionParam(n) => Expression::Lookup { id: def_id.clone(), kind: Lookup::Param(*n) },
|
||||
DataConstructor { index, arity, .. } => {
|
||||
DataConstructor { .. } => {
|
||||
Expression::ReductionError("DataConstructor not supported".to_string())
|
||||
},
|
||||
RecordConstructor { .. } => {
|
||||
|
@ -17,6 +17,7 @@ pub struct ReducedIR {
|
||||
}
|
||||
|
||||
impl ReducedIR {
|
||||
#[allow(dead_code)]
|
||||
pub fn debug(&self, symbol_table: &SymbolTable) {
|
||||
println!("Reduced IR:");
|
||||
println!("Functions:");
|
||||
|
@ -4,8 +4,6 @@ use crate::ast::*;
|
||||
use crate::symbol_table::{Fqsn, Scope, SymbolTable, SymbolSpec};
|
||||
use crate::util::ScopeStack;
|
||||
|
||||
type FqsnPrefix = Vec<Scope>;
|
||||
|
||||
#[derive(Debug)]
|
||||
enum NameType {
|
||||
//TODO eventually this needs to support closures
|
||||
@ -17,6 +15,7 @@ enum NameType {
|
||||
#[derive(Debug)]
|
||||
enum ScopeType {
|
||||
Function {
|
||||
#[allow(dead_code)]
|
||||
name: Rc<String>
|
||||
},
|
||||
Lambda,
|
||||
|
@ -58,6 +58,7 @@ impl From<&str> for RuntimeError {
|
||||
}
|
||||
|
||||
impl RuntimeError {
|
||||
#[allow(dead_code)]
|
||||
fn get_msg(&self) -> String {
|
||||
format!("Runtime error: {}", self.msg)
|
||||
}
|
||||
@ -98,8 +99,8 @@ fn expr_to_repl(expr: &Expression) -> String {
|
||||
Literal::StringLit(s) => format!("\"{}\"", s),
|
||||
}
|
||||
Expression::Tuple(terms) => paren_wrapped(terms.iter().map(|x| expr_to_repl(x))),
|
||||
Expression::Assign { lval, rval } => {
|
||||
"".to_string()
|
||||
Expression::Assign { .. } => {
|
||||
"".to_string() //TODO maybe the repl should say *something* here?
|
||||
},
|
||||
e => format!("Expression {:?} shouldn't be here", e),
|
||||
}
|
||||
@ -109,7 +110,7 @@ impl RuntimeValue {
|
||||
fn to_repl(&self) -> String {
|
||||
match self {
|
||||
RuntimeValue::Primitive(ref prim) => expr_to_repl(&prim.to_expr()),
|
||||
RuntimeValue::Function(ref expr) => "<function>".to_string(),
|
||||
RuntimeValue::Function(..) => "<function>".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -193,7 +194,7 @@ impl<'a> State<'a> {
|
||||
|
||||
fn statement(&mut self, stmt: Statement) -> EvalResult<Option<RuntimeValue>> {
|
||||
match stmt {
|
||||
Statement::Binding { ref id, expr, constant } => {
|
||||
Statement::Binding { ref id, expr, constant: _ } => {
|
||||
println!("eval() binding id: {}", id);
|
||||
let evaluated = self.expression(expr)?;
|
||||
self.environments.insert(id.into(), evaluated.into());
|
||||
@ -239,7 +240,8 @@ impl<'a> State<'a> {
|
||||
},
|
||||
Expression::Assign { ref lval, box rval } => {
|
||||
let mem = lval.into();
|
||||
let mut env = self.environments.lookup(&mem);
|
||||
let _ = rval;
|
||||
let _env = self.environments.lookup(&mem);
|
||||
return Err("Assign not implemented".into());
|
||||
},
|
||||
Expression::Call { box f, args } => self.call_expression(f, args)?,
|
||||
@ -288,6 +290,21 @@ impl<'a> State<'a> {
|
||||
(FieldAccess, /*&[Node::PrimObject { .. }]*/ _) => {
|
||||
return Err("Field access unimplemented".into());
|
||||
}
|
||||
/* builtin functions */
|
||||
(IOPrint, &[ref anything]) => {
|
||||
print!("{}", expr_to_repl(anything));
|
||||
Primitive::Tuple(vec![])
|
||||
},
|
||||
(IOPrintLn, &[ref anything]) => {
|
||||
println!("{}", expr_to_repl(anything));
|
||||
Primitive::Tuple(vec![])
|
||||
},
|
||||
(IOGetLine, &[]) => {
|
||||
let mut buf = String::new();
|
||||
std::io::stdin().read_line(&mut buf).expect("Error readling line in 'getline'");
|
||||
StringLit(Rc::new(buf.trim().to_string())).into()
|
||||
},
|
||||
/* Binops */
|
||||
(binop, &[ref lhs, ref rhs]) => match (binop, lhs, rhs) {
|
||||
(Add, Lit(Nat(l)), Lit(Nat(r))) => Nat(l + r).into(),
|
||||
(Concatenate, Lit(StringLit(ref s1)), Lit(StringLit(ref s2))) => StringLit(Rc::new(format!("{}{}", s1, s2))).into(),
|
||||
@ -338,20 +355,6 @@ impl<'a> State<'a> {
|
||||
(Increment, Lit(Nat(n))) => Nat(*n),
|
||||
_ => return Err("No valid prefix op".into())
|
||||
}.into(),
|
||||
/* builtin functions */
|
||||
(IOPrint, &[ref anything]) => {
|
||||
print!("{}", expr_to_repl(anything));
|
||||
Primitive::Tuple(vec![])
|
||||
},
|
||||
(IOPrintLn, &[ref anything]) => {
|
||||
println!("{}", expr_to_repl(anything));
|
||||
Primitive::Tuple(vec![])
|
||||
},
|
||||
(IOGetLine, &[]) => {
|
||||
let mut buf = String::new();
|
||||
std::io::stdin().read_line(&mut buf).expect("Error readling line in 'getline'");
|
||||
StringLit(Rc::new(buf.trim().to_string())).into()
|
||||
},
|
||||
(x, args) => return Err(format!("bad or unimplemented builtin {:?} | {:?}", x, args).into()),
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user