mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
MAINT: The great TODO cleanup.
This commit is contained in:
parent
ea3f2eae5f
commit
c8443b9181
@ -529,7 +529,6 @@ impl FuncOpDef {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(jwall): this should probably be moved to a Val::Module IR type.
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub struct ModuleDef {
|
pub struct ModuleDef {
|
||||||
pub scope: Option<Scope>,
|
pub scope: Option<Scope>,
|
||||||
|
@ -524,8 +524,6 @@ fn test_copy_expression_wrong_field_type_compile_failure() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(jwall): Function call errors
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_func_call_wrong_argument_length_compile_failure() {
|
fn test_func_call_wrong_argument_length_compile_failure() {
|
||||||
assert_build_failure(
|
assert_build_failure(
|
||||||
|
@ -105,7 +105,6 @@ impl<'a> ExpressionFormatter<'a> {
|
|||||||
pos: &Position,
|
pos: &Position,
|
||||||
) -> Result<Val, Box<dyn Error>> {
|
) -> Result<Val, Box<dyn Error>> {
|
||||||
// we expect the next char to be { or we error.
|
// we expect the next char to be { or we error.
|
||||||
// TODO(jwall): Consume until you reach the last '}'
|
|
||||||
let mut expr_string = String::new();
|
let mut expr_string = String::new();
|
||||||
let mut brace_count = 0;
|
let mut brace_count = 0;
|
||||||
match iter.next() {
|
match iter.next() {
|
||||||
|
@ -18,7 +18,6 @@ pub enum Val {
|
|||||||
Float(f64),
|
Float(f64),
|
||||||
Str(String),
|
Str(String),
|
||||||
List(Vec<Rc<Val>>),
|
List(Vec<Rc<Val>>),
|
||||||
// TODO(jwall): Remove the need for PositionedItem here
|
|
||||||
Tuple(Vec<(String, Rc<Val>)>),
|
Tuple(Vec<(String, Rc<Val>)>),
|
||||||
Env(Vec<(String, String)>),
|
Env(Vec<(String, String)>),
|
||||||
Func(FuncDef),
|
Func(FuncDef),
|
||||||
|
@ -331,7 +331,6 @@ impl<'a> FileBuilder<'a> {
|
|||||||
Some(val) => Ok(val),
|
Some(val) => Ok(val),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO(jwall): We can probably use actual errors now?
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
let cause = Box::new(simple_error::SimpleError::new(err));
|
let cause = Box::new(simple_error::SimpleError::new(err));
|
||||||
Err(error::BuildError::with_pos(
|
Err(error::BuildError::with_pos(
|
||||||
@ -345,7 +344,6 @@ impl<'a> FileBuilder<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Non file builder specific.
|
|
||||||
/// Evaluate an input string as UCG.
|
/// Evaluate an input string as UCG.
|
||||||
pub fn eval_string(&mut self, input: &str) -> Result<Rc<Val>, Box<dyn Error>> {
|
pub fn eval_string(&mut self, input: &str) -> Result<Rc<Val>, Box<dyn Error>> {
|
||||||
self.eval_input(OffsetStrIter::new(input))
|
self.eval_input(OffsetStrIter::new(input))
|
||||||
@ -374,7 +372,6 @@ impl<'a> FileBuilder<'a> {
|
|||||||
) -> Result<PathBuf, Box<dyn Error>> {
|
) -> Result<PathBuf, Box<dyn Error>> {
|
||||||
// Try a relative path first.
|
// Try a relative path first.
|
||||||
let path = path.into();
|
let path = path.into();
|
||||||
// TODO(jwall): Change this to take a root directory.
|
|
||||||
let mut normalized = self.working_dir.clone();
|
let mut normalized = self.working_dir.clone();
|
||||||
if path.is_relative() {
|
if path.is_relative() {
|
||||||
normalized.push(&path);
|
normalized.push(&path);
|
||||||
@ -408,7 +405,6 @@ impl<'a> FileBuilder<'a> {
|
|||||||
let result = match maybe_asset {
|
let result = match maybe_asset {
|
||||||
Some(v) => v.clone(),
|
Some(v) => v.clone(),
|
||||||
None => {
|
None => {
|
||||||
// TODO(jwall): This does not need to be a FileBuilder specifically
|
|
||||||
let mut b = self.clone_builder();
|
let mut b = self.clone_builder();
|
||||||
b.eval_string(self.std.get(&def.path.fragment).unwrap())?;
|
b.eval_string(self.std.get(&def.path.fragment).unwrap())?;
|
||||||
b.get_outputs_as_val()
|
b.get_outputs_as_val()
|
||||||
@ -1012,7 +1008,6 @@ impl<'a> FileBuilder<'a> {
|
|||||||
if let &BinaryExprType::DOT = kind {
|
if let &BinaryExprType::DOT = kind {
|
||||||
return self.do_dot_lookup(&def.right, &child_scope);
|
return self.do_dot_lookup(&def.right, &child_scope);
|
||||||
};
|
};
|
||||||
// TODO(jwall): We need to handle call and copy expressions specially.
|
|
||||||
let right = match self.eval_expr(&def.right, scope) {
|
let right = match self.eval_expr(&def.right, scope) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(e) => return Err(e),
|
Err(e) => return Err(e),
|
||||||
@ -1143,7 +1138,6 @@ impl<'a> FileBuilder<'a> {
|
|||||||
let maybe_tpl = mod_def.clone().arg_tuple.unwrap().clone();
|
let maybe_tpl = mod_def.clone().arg_tuple.unwrap().clone();
|
||||||
if let &Val::Tuple(ref src_fields) = maybe_tpl.as_ref() {
|
if let &Val::Tuple(ref src_fields) = maybe_tpl.as_ref() {
|
||||||
// 1. First we create a builder.
|
// 1. First we create a builder.
|
||||||
// TODO(jwall): This file should optionally come from the module def itself.
|
|
||||||
let mut b = self.clone_builder();
|
let mut b = self.clone_builder();
|
||||||
b.is_module = true;
|
b.is_module = true;
|
||||||
// 2. We construct an argument tuple by copying from the defs
|
// 2. We construct an argument tuple by copying from the defs
|
||||||
@ -1272,7 +1266,6 @@ impl<'a> FileBuilder<'a> {
|
|||||||
Ok(Rc::new(Val::Func(def.clone())))
|
Ok(Rc::new(Val::Func(def.clone())))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(jwall): This stays with the FileBuilder specifically.
|
|
||||||
fn file_dir(&self) -> PathBuf {
|
fn file_dir(&self) -> PathBuf {
|
||||||
return if self.working_dir.is_file() {
|
return if self.working_dir.is_file() {
|
||||||
// Only use the dirname portion if the root is a file.
|
// Only use the dirname portion if the root is a file.
|
||||||
@ -1284,7 +1277,6 @@ impl<'a> FileBuilder<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn eval_module_def(&self, def: &ModuleDef, scope: &Scope) -> Result<Rc<Val>, Box<dyn Error>> {
|
fn eval_module_def(&self, def: &ModuleDef, scope: &Scope) -> Result<Rc<Val>, Box<dyn Error>> {
|
||||||
// TODO(jwall): This should actually be passed in to here.
|
|
||||||
let root = self.file_dir();
|
let root = self.file_dir();
|
||||||
// Always work on a copy. The original should not be modified.
|
// Always work on a copy. The original should not be modified.
|
||||||
let mut def = def.clone();
|
let mut def = def.clone();
|
||||||
@ -1559,7 +1551,6 @@ impl<'a> FileBuilder<'a> {
|
|||||||
return match maybe_target.as_ref() {
|
return match maybe_target.as_ref() {
|
||||||
&Val::List(ref elems) => self.eval_functional_list_processing(elems, macdef, typ),
|
&Val::List(ref elems) => self.eval_functional_list_processing(elems, macdef, typ),
|
||||||
&Val::Tuple(ref fs) => self.eval_functional_tuple_processing(fs, macdef, typ),
|
&Val::Tuple(ref fs) => self.eval_functional_tuple_processing(fs, macdef, typ),
|
||||||
// TODO(jwall): Strings?
|
|
||||||
&Val::Str(ref s) => self.eval_functional_string_processing(s, macdef, typ),
|
&Val::Str(ref s) => self.eval_functional_string_processing(s, macdef, typ),
|
||||||
other => Err(error::BuildError::with_pos(
|
other => Err(error::BuildError::with_pos(
|
||||||
format!(
|
format!(
|
||||||
|
@ -61,7 +61,6 @@ impl TomlConverter {
|
|||||||
fn convert_value(&self, v: &Val) -> Result {
|
fn convert_value(&self, v: &Val) -> Result {
|
||||||
let toml_val = match v {
|
let toml_val = match v {
|
||||||
&Val::Boolean(b) => toml::Value::Boolean(b),
|
&Val::Boolean(b) => toml::Value::Boolean(b),
|
||||||
// TODO(jwall): This is an error apparently
|
|
||||||
&Val::Empty => {
|
&Val::Empty => {
|
||||||
let err = SimpleError::new("Nulls are not allowed in Toml Conversions!");
|
let err = SimpleError::new("Nulls are not allowed in Toml Conversions!");
|
||||||
return Err(Box::new(err));
|
return Err(Box::new(err));
|
||||||
|
@ -20,7 +20,6 @@ use std::result;
|
|||||||
|
|
||||||
use crate::build::Val;
|
use crate::build::Val;
|
||||||
|
|
||||||
// TODO Rename to ConvertResult
|
|
||||||
pub type ConvertResult = result::Result<(), Box<dyn Error>>;
|
pub type ConvertResult = result::Result<(), Box<dyn Error>>;
|
||||||
|
|
||||||
pub type ImportResult = result::Result<Rc<Val>, Box<dyn Error>>;
|
pub type ImportResult = result::Result<Rc<Val>, Box<dyn Error>>;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user