Skip to content

Commit

Permalink
Merge pull request #89 from calcit-lang/inline-kwd
Browse files Browse the repository at this point in the history
Inline keywords in javascript
  • Loading branch information
soyaine authored Sep 2, 2021
2 parents da37202 + fac62d8 commit cde1f3f
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 110 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "calcit_runner"
version = "0.4.25"
version = "0.4.26"
authors = ["jiyinyiyong <jiyinyiyong@gmail.com>"]
edition = "2018"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@calcit/procs",
"version": "0.4.25",
"version": "0.4.26",
"main": "./lib/calcit.procs.js",
"devDependencies": {
"@types/node": "^16.7.2",
Expand Down
2 changes: 1 addition & 1 deletion src/builtins/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
};

pub fn ffi_message(xs: &CalcitItems) -> Result<Calcit, String> {
if xs.len() >= 1 {
if !xs.is_empty() {
match &xs[0] {
Calcit::Str(s) | Calcit::Symbol(s, ..) => {
let items = xs.to_owned().slice(1..);
Expand Down
8 changes: 4 additions & 4 deletions src/builtins/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ pub fn foldl_shortcut(
Calcit::Tuple(x0, x1) => match *x0 {
Calcit::Bool(b) => {
if b {
return Ok(*x1.to_owned());
return Ok(*x1);
} else {
state = *x1.to_owned()
}
Expand All @@ -303,7 +303,7 @@ pub fn foldl_shortcut(
Calcit::Tuple(x0, x1) => match *x0 {
Calcit::Bool(b) => {
if b {
return Ok(*x1.to_owned());
return Ok(*x1);
} else {
state = *x1.to_owned()
}
Expand All @@ -330,7 +330,7 @@ pub fn foldl_shortcut(
Calcit::Tuple(x0, x1) => match *x0 {
Calcit::Bool(b) => {
if b {
return Ok(*x1.to_owned());
return Ok(*x1);
} else {
state = *x1.to_owned()
}
Expand Down Expand Up @@ -382,7 +382,7 @@ pub fn foldr_shortcut(
Calcit::Tuple(x0, x1) => match *x0 {
Calcit::Bool(b) => {
if b {
return Ok(*x1.to_owned());
return Ok(*x1);
} else {
state = *x1.to_owned()
}
Expand Down
2 changes: 1 addition & 1 deletion src/builtins/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ pub fn assoc(xs: &CalcitItems) -> Result<Calcit, String> {
for idx in 0..size {
ys.insert(xs[idx * 2 + 1].to_owned(), xs[idx * 2 + 2].to_owned());
}
Ok(Calcit::Map(ys.to_owned()))
Ok(Calcit::Map(ys))
}
}
Some(a) => Err(format!("map:assoc expected a map, got: {}", a)),
Expand Down
4 changes: 2 additions & 2 deletions src/builtins/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub fn invoke_method(
match find_in_fields(&fields, name) {
Some(idx) => {
let mut method_args: im::Vector<Calcit> = im::vector![];
method_args.push_back(value.to_owned());
method_args.push_back(value);
let mut at_first = true;
for x in invoke_args {
if at_first {
Expand Down Expand Up @@ -367,5 +367,5 @@ pub fn no_op() -> Result<Calcit, String> {

pub fn get_os(_xs: &CalcitItems) -> Result<Calcit, String> {
// https://doc.rust-lang.org/std/env/consts/constant.OS.html
return Ok(Calcit::Keyword(std::env::consts::OS.to_owned()));
Ok(Calcit::Keyword(std::env::consts::OS.to_owned()))
}
6 changes: 1 addition & 5 deletions src/builtins/records.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,7 @@ pub fn extend_as(xs: &CalcitItems) -> Result<Calcit, String> {
_ => Err(format!("")),
};

Ok(Calcit::Record(
new_name?.to_owned(),
next_fields.to_owned(),
next_values.to_owned(),
))
Ok(Calcit::Record(new_name?, next_fields, next_values))
}
},
a => Err(format!("invalid field `{}` for {:?}", a, fields)),
Expand Down
2 changes: 1 addition & 1 deletion src/builtins/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ pub fn rest(xs: &CalcitItems) -> Result<Calcit, String> {
}
buffer.push(c)
}
Ok(Calcit::Str(buffer.to_owned()))
Ok(Calcit::Str(buffer))
}
Some(a) => Err(format!("str:rest expected a string, got: {}", a)),
None => Err(String::from("str:rest expected 1 argument")),
Expand Down
4 changes: 2 additions & 2 deletions src/builtins/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ pub fn macroexpand_all(
let (resolved, _v) =
runner::preprocess::preprocess_expr(&v, &HashSet::new(), file_ns, program_code, check_warnings)?;
let warnings = check_warnings.to_owned().into_inner();
if warnings.len() > 0 {
if !warnings.is_empty() {
for message in &warnings {
println!("{}", message);
}
Expand All @@ -321,7 +321,7 @@ pub fn macroexpand_all(
check_warnings,
)?;
let warnings = check_warnings.to_owned().into_inner();
if warnings.len() > 0 {
if !warnings.is_empty() {
for message in &warnings {
println!("{}", message);
}
Expand Down
Loading

0 comments on commit cde1f3f

Please sign in to comment.