Skip to content

Commit

Permalink
Added IsArgsCall
Browse files Browse the repository at this point in the history
  • Loading branch information
kev committed Jan 27, 2024
1 parent ac312d1 commit 5cb16e1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions CLVMDotNet/src/Tools/Stages/Stage2/Optimize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,25 @@ public static class Optimize
public static byte RAISE_ATOM => Keywords.KEYWORD_TO_ATOM["x"];
public static int DEBUG_OPTIMIZATIONS = 0;
public static SExp CONS_Q_A_OPTIMIZER_PATTERN => BinUtils.Assemble("(a (q . (: . sexp)) (: . args))");
public static SExp CONS_PATTERN = BinUtils.Assemble("(c (: . first) (: . rest)))");
public static SExp VAR_CHANGE_OPTIMIZER_CONS_EVAL_PATTERN = BinUtils.Assemble("(a (q . (: . sexp)) (: . args))");
public static SExp CONS_OPTIMIZER_PATTERN_FIRST = BinUtils.Assemble("(f (c (: . first) (: . rest)))");
public static SExp CONS_OPTIMIZER_PATTERN_REST = BinUtils.Assemble("(r (c (: . first) (: . rest)))");
public static SExp FIRST_ATOM_PATTERN = BinUtils.Assemble("(f ($ . atom))");
public static SExp REST_ATOM_PATTERN = BinUtils.Assemble("(r ($ . atom))");
public static SExp QUOTE_PATTERN_1 = BinUtils.Assemble("(q . 0)");
public static SExp APPLY_NULL_PATTERN_1 = BinUtils.Assemble("(a 0 . (: . rest))");


public static bool NonNil(SExp sexp)
{
return sexp.Listp() || (sexp.AsAtom().Length > 0);

Check warning on line 28 in CLVMDotNet/src/Tools/Stages/Stage2/Optimize.cs

View workflow job for this annotation

GitHub Actions / Build

Dereference of a possibly null reference.
}

public static bool IsArgsCall(SExp r)
{
if (!r.Listp() && r.AsInt() == 1)
return true;
return false;
}
}

0 comments on commit 5cb16e1

Please sign in to comment.