private CodeExpression TranslateToLinq(CodeExpression projection, CompFor compFor) { var e = compFor.collection.Accept(this); var queryClauses = new List <CodeQueryClause>(); From(compFor.variable, e, queryClauses); var iter = compFor.next; while (iter != null) { if (iter is CompIf filter) { e = filter.test.Accept(this); queryClauses.Add(m.Where(e)); } else if (iter is CompFor join) { e = join.collection.Accept(this); From(join.variable, e, queryClauses); } iter = iter.next; } queryClauses.Add(m.Select(projection)); return(m.Query(queryClauses.ToArray())); }
private bool IsIdentityProjection(CompFor compFor, Exp projection) { var idV = compFor.variable as Identifier; var idP = projection as Identifier; return(idV != null && idP != null && idV.Name == idP.Name); }
private CodeExpression Translate(CodeExpression v, CompFor compFor) { var c = compFor.collection.Accept(this); if (compFor.next != null) { if (compFor.next is CompIf filter) { return(Where(c, v, filter.test.Accept(this))); } if (compFor.next is CompFor join) { //var pySrc = "((a, s) for a in stackframe.alocs.values() for s in a._segment_list)"; //string sExp = "stackframe.alocs.SelectMany(aa => aa._segment_list, (a, s) => Tuple.Create( a, s ))"; return(m.Appl( m.MethodRef(c, "SelectMany"), m.Lambda( new CodeExpression[] { ((Identifier)compFor.variable).Accept(this) }, join.collection.Accept(this)), m.Lambda( new CodeExpression[] { ((Identifier)compFor.variable).Accept(this), ((Identifier)join.variable).Accept(this) }, m.Appl( m.MethodRef( m.TypeRefExpr("Tuple"), "Create"), ((Identifier)compFor.variable).Accept(this), ((Identifier)join.variable).Accept(this))))); } } return(c); }
public DataType VisitCompFor(CompFor f) { var it = f.variable.Accept(this); scope.BindIterator(analyzer, f.variable, f.collection, it, BindingKind.SCOPE); //f.visit(node.ifs, s); return(f.variable.Accept(this)); }
public CodeExpression VisitCompFor(CompFor f) { throw new NotImplementedException(); //var v = compFor.variable.Accept(this); //var c = Translate(v, compFor); //var mr = new CodeMethodReferenceExpression(c, "Select"); //var s = m.Appl(mr, new CodeExpression[] { // m.Lambda( // new CodeExpression[] { v }, // a.name.Accept(this)) // }); //return s; }
public void VisitCompFor(CompFor f) { throw new NotImplementedException(); }