public MidVarRef( SourceRange range, MidVar var) : base(range, var.Type) { _var = var; }
public MidLetExp( SourceRange range, MidVar var, MidExp exp, MidExp body) : base(range, new MidDummyType()) { _var = var; _exp = exp; _body = body; }
public MidForExp( SourceRange range, MidVar var, MidVal seq, MidExp body) : base(range, new MidVoidType()) { _var = var; _seq = seq; _body = body; }
public override MidVal CreateTemp(MidExp exp, MidType type) { if (_element != null) { var attrDecl = _element.CacheAttr(exp, type); return(_exps.AttributeRef(exp.Range, attrDecl)); } else { MidVar var = new MidVar(_identifiers.unique("temp"), type); Func <MidExp, MidExp> wrapper = (body) => new MidLetExp(exp.Range, var, exp, body); _wrappers.Insert(0, wrapper); return(new MidVarRef(exp.Range, var)); } }
private bool UsesVar( MidExp exp, MidVar var) { bool result = false; var transform = new MidTransform( (e) => { if (e is MidVarRef && (e as MidVarRef).Var == var) { result = true; } return(e); }); transform.Transform(exp); return(result); }
private MidExp TryFoldPath( MidVar var, MidExp exp, MidPath path) { if (exp is MidFieldRef) { var midFieldRef = (MidFieldRef)exp; if (midFieldRef.Obj is MidVarRef) { var midVarRef = (MidVarRef)midFieldRef.Obj; if (midVarRef.Var == var) { midFieldRef.Obj = path; return(midFieldRef); } } } return(exp); }
private MidExp EmitExpImpl( ResForExp resFor, MidEmitEnv env) { // \todo: Set up the variable... :( var resVar = resFor.Var; var midVar = new MidVar( resVar.Name, EmitTypeExp(resVar.Type, env)); var seq = EmitVal(resFor.Sequence, env); var bodyEnv = new MidLocalEmitEnv(env, _identifiers, null, _exps); bodyEnv.Insert(resVar, (SourceRange r) => new MidVarRef(r, midVar)); var body = bodyEnv.Wrap(EmitVal(resFor.Body, bodyEnv)); return(new MidForExp( resFor.Range, midVar, seq, body)); }
public void Insert(MidVar var, MidVal val) { _vars[var] = val; }
public void Insert( MidVar var, MidVal val ) { _vars[var] = val; }
private bool UsesVar( MidExp exp, MidVar var) { bool result = false; var transform = new MidTransform( (e) => { if (e is MidVarRef && (e as MidVarRef).Var == var) result = true; return e; }); transform.Transform(exp); return result; }
private MidExp TryFoldPath( MidVar var, MidExp exp, MidPath path) { if (exp is MidFieldRef) { var midFieldRef = (MidFieldRef)exp; if (midFieldRef.Obj is MidVarRef) { var midVarRef = (MidVarRef) midFieldRef.Obj; if (midVarRef.Var == var) { midFieldRef.Obj = path; return midFieldRef; } } } return exp; }