Skip to content

Commit

Permalink
reverting changes from c5d13c8
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Dec 3, 2024
1 parent cbf5196 commit 5be2f71
Show file tree
Hide file tree
Showing 14 changed files with 222 additions and 220 deletions.
368 changes: 184 additions & 184 deletions fastn-builtins/src/lib.rs

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions fastn-resolved/src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct Field {
pub name: String,
pub kind: fastn_resolved::KindData,
pub mutable: bool,
pub default: Option<fastn_resolved::PropertyValue>,
pub value: Option<fastn_resolved::PropertyValue>,
pub line_number: usize,
pub access_modifier: AccessModifier,
}
Expand All @@ -36,7 +36,7 @@ impl Field {
name: name.to_string(),
kind,
mutable,
default: value,
value,
line_number,
access_modifier: Default::default(),
}
Expand Down Expand Up @@ -67,7 +67,7 @@ impl Field {
name: name.to_string(),
kind,
mutable: false,
default: None,
value: None,
line_number: 0,
access_modifier: Default::default(),
}
Expand All @@ -82,7 +82,7 @@ impl Field {
name: name.to_string(),
kind,
mutable: false,
default: Some(value),
value: Some(value),
line_number: 0,
access_modifier: Default::default(),
}
Expand All @@ -104,7 +104,7 @@ impl Field {
if self.kind.is_optional() || self.kind.is_list() {
return false;
}
self.default.is_none()
self.value.is_none()
}
}

Expand Down
2 changes: 1 addition & 1 deletion fastn-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ pub fn get_all_asts(
} else if let fastn_resolved::Definition::OrType(ot) = definition {
let mut fields = vec![];
for variant in &ot.variants {
if let Some(ref value) = variant.clone().fields().first().unwrap().default {
if let Some(ref value) = variant.clone().fields().first().unwrap().value {
fields.push((
variant
.name()
Expand Down
2 changes: 1 addition & 1 deletion fastn-runtime/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ pub(crate) fn is_module_argument(
component_arguments.iter().find_map(|v| {
if v.name.eq(module_name) && v.kind.is_module() {
let module = v
.default
.value
.as_ref()
.and_then(|v| v.value_optional())
.and_then(|v| v.module_name_optional())?;
Expand Down
2 changes: 1 addition & 1 deletion fastn-runtime/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl fastn_runtime::extensions::ExpressionExt for fastn_resolved::Expression {

impl fastn_runtime::extensions::ArgumentExt for fastn_resolved::Argument {
fn get_default_value(&self) -> Option<fastn_runtime::Value> {
if let Some(ref value) = self.default {
if let Some(ref value) = self.value {
Some(value.to_value())
} else if self.kind.is_list() {
Some(fastn_runtime::Value::Data(fastn_resolved::Value::List {
Expand Down
2 changes: 1 addition & 1 deletion ftd/src/executor/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl ExecuteDoc<'_> {
is_mutable: argument.mutable,
line_number: instruction.line_number,
}
} else if let Some(ref value) = argument.default {
} else if let Some(ref value) = argument.value {
value.to_owned()
} else {
unreachable!()
Expand Down
2 changes: 1 addition & 1 deletion ftd/src/html/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ pub(crate) fn to_argument_string(
let mut properties_string = "".to_string();
for argument in arguments {
let mut result_value = "null".to_string();
if let Some(ref value) = argument.default {
if let Some(ref value) = argument.value {
if let Ok(Some(value_string)) =
ftd::html::utils::get_formatted_dep_string_from_property_value(
id, doc, value, &None, None, false,
Expand Down
8 changes: 4 additions & 4 deletions ftd/src/interpreter/things/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ fn get_module_name_and_thing(
use ftd::interpreter::{PropertyValueExt, ValueExt};

let default_things = {
let value = if let Some(ref value) = component_argument.default {
let value = if let Some(ref value) = component_argument.value {
value.clone().resolve(doc, module_property.line_number)?
} else {
return ftd::interpreter::utils::e2(
Expand Down Expand Up @@ -353,7 +353,7 @@ fn get_module_name_and_thing(
module_property.line_number,
)?
{
if let Some(ref mut property_value) = argument.default {
if let Some(ref mut property_value) = argument.value {
if let fastn_resolved::PropertyValue::Value { value, .. } = property_value {
if let Some((name, thing)) = value.mut_module_optional() {
thing.extend(default_things);
Expand Down Expand Up @@ -1406,7 +1406,7 @@ impl ComponentExt for fastn_resolved::ComponentInvocation {
if arg.kind.is_module() {
let component_name = {
let (m_name, _) = match arg
.default
.value
.as_ref()
.unwrap()
.clone()
Expand Down Expand Up @@ -1541,7 +1541,7 @@ impl LoopExt for fastn_resolved::Loop {
name: self.alias.to_string(),
kind: fastn_resolved::KindData::new(kind),
mutable: self.on.is_mutable(),
default: Some(self.on.to_owned()),
value: Some(self.on.to_owned()),
line_number: self.on.line_number(),
access_modifier: Default::default(),
})
Expand Down
4 changes: 2 additions & 2 deletions ftd/src/interpreter/things/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl FunctionCallExt for fastn_resolved::FunctionCall {
if let Some(fastn_resolved::PropertyValue::Value {
value: fastn_resolved::Value::Module { ref name, .. },
..
}) = argument.default
}) = argument.value
{
if let Some(function) = function {
module_name = Some((
Expand Down Expand Up @@ -367,7 +367,7 @@ impl FunctionCallExt for fastn_resolved::FunctionCall {
loop_object_name_and_kind,
)?)
} else {
match argument.default {
match argument.value {
Some(ref value) => value.clone(),
None if argument.kind.is_optional() => fastn_resolved::PropertyValue::new_none(
argument.kind.clone(),
Expand Down
2 changes: 1 addition & 1 deletion ftd/src/interpreter/things/or_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ fn validate_constant_variant(
variant: &fastn_resolved::Field,
doc: &ftd::interpreter::TDoc,
) -> ftd::interpreter::Result<()> {
if variant.default.is_none()
if variant.value.is_none()
&& !(variant.kind.is_void() || variant.kind.is_optional() || variant.kind.is_list())
{
return ftd::interpreter::utils::e2(
Expand Down
6 changes: 3 additions & 3 deletions ftd/src/interpreter/things/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl FieldExt for fastn_resolved::Field {
None
};

field.default = value;
field.value = value;
}
let resolved_fields = fields_with_resolved_kinds
.into_iter()
Expand Down Expand Up @@ -368,7 +368,7 @@ impl FieldExt for fastn_resolved::Field {
name: field.name.to_string(),
kind,
mutable: field.mutable,
default: value,
value,
line_number: field.line_number,
access_modifier: access_modifier(field.access_modifier),
},
Expand Down Expand Up @@ -396,7 +396,7 @@ impl FieldExt for fastn_resolved::Field {
name: field.name.to_string(),
kind,
mutable: field.mutable,
default: None,
value: None,
line_number: field.line_number,
access_modifier: access_modifier(field.access_modifier),
},
Expand Down
26 changes: 14 additions & 12 deletions ftd/src/interpreter/things/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,16 +854,18 @@ impl PropertyValueExt for fastn_resolved::PropertyValue {
}

let constant = or_type_variant.ok_constant(doc.name)?;
let value = constant.default.clone().ok_or(
ftd::interpreter::Error::ParseError {
message: format!(
"Expected value for constant variant `{}`",
constant.name
),
doc_id: doc.name.to_string(),
line_number: constant.line_number,
},
)?;
let value =
constant
.value
.clone()
.ok_or(ftd::interpreter::Error::ParseError {
message: format!(
"Expected value for constant variant `{}`",
constant.name
),
doc_id: doc.name.to_string(),
line_number: constant.line_number,
})?;

ftd::interpreter::StateWithThing::new_thing(
fastn_resolved::Value::new_or_type(
Expand Down Expand Up @@ -1019,8 +1021,8 @@ impl PropertyValueExt for fastn_resolved::PropertyValue {
continue;
}

if headers.is_none() && field.default.is_some() {
let value = field.default.as_ref().unwrap();
if headers.is_none() && field.value.is_some() {
let value = field.value.as_ref().unwrap();
match value {
fastn_resolved::PropertyValue::Reference {
name: refernence,
Expand Down
6 changes: 3 additions & 3 deletions ftd/src/interpreter/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ pub(crate) fn insert_module_thing(
things,
name: module_name,
} = arg
.default
.value
.as_mut()
.ok_or(ftd::interpreter::Error::ValueNotFound {
doc_id: doc.name.to_string(),
Expand Down Expand Up @@ -829,7 +829,7 @@ pub(crate) fn validate_properties_and_set_default(

if argument.kind.is_module() {
let (_default_module, arg_things) = match argument
.default
.value
.as_ref()
.unwrap()
.value(doc_id, line_number)?
Expand All @@ -854,7 +854,7 @@ pub(crate) fn validate_properties_and_set_default(
}
}
if found_default.is_none() {
if let Some(ref default_value) = argument.default {
if let Some(ref default_value) = argument.value {
properties.push(fastn_resolved::Property {
value: default_value.to_owned(),
source: fastn_resolved::PropertySource::Default,
Expand Down
2 changes: 1 addition & 1 deletion ftd/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub fn document_into_js_ast(document: ftd::interpreter::Document) -> JSAstData {
} else if let ftd::interpreter::Thing::OrType(ot) = thing {
let mut fields = vec![];
for variant in &ot.variants {
if let Some(value) = &variant.clone().fields().get(0).unwrap().default {
if let Some(value) = &variant.clone().fields().get(0).unwrap().value {
fields.push((
variant
.name()
Expand Down

0 comments on commit 5be2f71

Please sign in to comment.