LNode ProcessBlockCallStmt(LNode stmt, int childStmtsStartAt) { List <LNode> childStmts = stmt.Slice(childStmtsStartAt).ToList(); LNode partialStmt = stmt.WithArgs(stmt.Args.First(childStmtsStartAt)); VList <LNode> advanceSequence; if (ProcessBlockCallStmt(ref partialStmt, out advanceSequence, childStmts)) { stmt = partialStmt.PlusArgs(childStmts); if (advanceSequence.Count != 0) { return(LNode.Call(CodeSymbols.Braces, LNode.List().AddRange(advanceSequence).Add(stmt)).SetStyle(NodeStyle.Statement)); } return(stmt); } else { return(stmt); } }
public static LNode set_tuple_type(LNode node, IMacroContext context) { var tupleMakers = MaybeInitTupleMakers(context.ScopedProperties); int? size = node.Args[0, F._Missing].Value as int?; var rest = node.Slice(size != null ? 1 : 0); if (!MathEx.IsInRange(rest.Count, 1, 2)) return Reject(context, node, "Incorrect number of arguments"); var tupleCfg = Pair.Create(rest[0], rest.TryGet(1, null)); if (tupleCfg.A.Value == null) tupleCfg.A = null; // Makes us ignore tuples of this size if (tupleCfg.B == null && tupleCfg.A != null) tupleCfg.B = F.Dot(tupleCfg.A, F.Id("Create")); if (size == null) { tupleMakers.Resize(1); context.ScopedProperties[DefaultTupleMaker] = tupleCfg; } else { while (tupleMakers.Count <= size.Value) tupleMakers.Add((Pair<LNode,LNode>)context.ScopedProperties[DefaultTupleMaker]); tupleMakers[size.Value] = tupleCfg; } return F.Call(S.Splice); }
public static LNode set_tuple_type(LNode node, IMessageSink sink) { MaybeInitTupleMakers(); int?size = node.Args[0, F._Missing].Value as int?; var rest = node.Slice(size != null ? 1 : 0); if (!MathEx.IsInRange(rest.Count, 1, 2)) { return(Reject(sink, node, "Incorrect number of arguments")); } var tupleCfg = Pair.Create(rest[0], rest.TryGet(1, null)); if (tupleCfg.A.Value == null) { tupleCfg.A = null; // Makes us ignore tuples of this size } if (tupleCfg.B == null && tupleCfg.A != null) { tupleCfg.B = F.Dot(tupleCfg.A, F.Id("Create")); } if (size == null) { TupleMakers.Resize(1); DefaultTupleMaker = tupleCfg; } else { while (TupleMakers.Count <= size.Value) { TupleMakers.Add(DefaultTupleMaker); } TupleMakers[size.Value] = tupleCfg; } return(F.Call(S.Splice)); }
public static LNode setTupleType(LNode node, IMacroContext context) { var tupleMakers = MaybeInitTupleMakers(context.ScopedProperties); int?size = node.Args[0, F.Missing].Value as int?; var rest = node.Slice(size != null ? 1 : 0); if (!rest.Count.IsInRange(1, 2)) { return(Reject(context, node, "Incorrect number of arguments")); } var tupleCfg = Pair.Create(rest[0], rest.TryGet(1, null)); if (tupleCfg.A.Value == null) { tupleCfg.A = null; // Makes us ignore tuples of this size } if (tupleCfg.B == null && tupleCfg.A != null) { tupleCfg.B = F.Dot(tupleCfg.A, F.Id("Create")); } if (size == null) { tupleMakers.Resize(1); context.ScopedProperties[DefaultTupleMaker] = tupleCfg; } else { while (tupleMakers.Count <= size.Value) { tupleMakers.Add((Pair <LNode, LNode>)context.ScopedProperties[DefaultTupleMaker]); } tupleMakers[size.Value] = tupleCfg; } return(F.Call(S.Splice)); }