// ===== ===== ===== ===== ===== method ===== ===== ===== ===== ===== public LambdaExpression Generate(Lambda lambda) { Contract.Requires <ArgumentNullException>(lambda != null); Contract.Ensures(Contract.Result <LambdaExpression>() != null); var expr = GenElem(lambda.Element); var tmp = Expression.Parameter(expr.Type); var body = Expression.Block( new[] { tmp }, StmtGen.DebugInfo(lambda.Range), Expression.Assign(tmp, expr), StmtGen.ClearInfo(), tmp); return(Expression.Lambda(body, ParamList.ToEnum(_params).Reverse())); }
// ===== ===== ===== ===== ===== ctor ===== ===== ===== ===== ===== public ElemGen(StmtGen gen) { Contract.Requires <ArgumentNullException>(gen != null); StmtGen = gen; }
// ===== ===== ===== ===== ===== ctor ===== ===== ===== ===== ===== public DefunGen(StmtGen parent) : base(parent) { }
// ===== ===== ===== ===== ===== ctor ===== ===== ===== ===== ===== public BlockGen(StmtGen parent) { _parent = parent; }
// ===== ===== ===== ===== ===== ctor ===== ===== ===== ===== ===== public LambdaGen(StmtGen gen) : base(gen) { }
protected virtual Expression GenLambdaParam(LambdaParameter elem) { Contract.Requires <ArgumentNullException>(elem != null); Contract.Ensures(Contract.Result <Expression>() != null); throw StmtGen.Error("ラムダパラメタはラムダ式の内部でのみ利用出来ます。", elem.Range.Start); }
protected SyntaxException Error(string message, TextLocation location) { return(StmtGen.Error(message, location)); }
private Expression GenSymbol(Symbol elem) { Contract.Requires <ArgumentNullException>(elem != null); Contract.Ensures(Contract.Result <Expression>() != null); return(StmtGen.GetValue(elem.Name)); }
// ===== ===== ===== ===== ===== ctor ===== ===== ===== ===== ===== public ElemGen(StmtGen gen) { Contract.Requires<ArgumentNullException>(gen != null); StmtGen = gen; }