//Compiles list literal private ExprData CompileList(ElaListLiteral p, LabelMap map, Hints hints) { var len = p.Values.Count; AddLinePragma(p); cw.Emit(Op.Newlist); //If len is 0 than we have an empty (nil) list which is created by Newlist. for (var i = 0; i < len; i++) { CompileExpression(p.Values[p.Values.Count - i - 1], map, Hints.None, p); cw.Emit(Op.Cons); } if ((hints & Hints.Left) == Hints.Left) AddValueNotUsed(p); return new ExprData(DataKind.VarType, (Int32)ElaTypeCode.List); }
void ListLiteral(out ElaExpression exp) { exp = null; if (la.kind == 21) { Get(); var list = default(List<ElaExpression>); var comp = default(ElaComprehension); var rng = default(ElaRange); var ot = t; exp = null; if (StartOf(3)) { ParamList(out list, out comp, out rng); if (list != null) { var listExp = new ElaListLiteral(ot) { Values = list }; exp = listExp; } else if (comp != null) exp = comp; else if (rng != null) exp = rng; } if (exp == null) exp = new ElaListLiteral(ot); Expect(22); } else if (la.kind == 59) { Get(); var comp = default(ElaComprehension); var ot = t; exp = null; var cexp = default(ElaExpression); Expr(out cexp); ComprehensionExpr(cexp, out comp); comp.Lazy = true; exp = comp; Expect(22); } else SynErr(70); }