public ArgumentTuple(Element arg, string sfx) { Contract.Requires<ArgumentNullException>(arg != null); Contract.Requires<ArgumentNullException>(sfx != null); this.Argument = arg; this.Suffix = sfx; }
public Assign(string name, Element value, bool isMaybe, TextRange range) : base(isMaybe, range) { Contract.Requires<ArgumentNullException>(name != null); this.Name = name; this.Value = value; }
/// <summary> /// そのままExpressionに直した状態。 /// </summary> public Expression GenElemCore(Element elem) { Contract.Requires<ArgumentNullException>(elem != null); Contract.Ensures(Contract.Result<Expression>() != null); Contract.Ensures(Contract.Result<Expression>().Type != typeof(void)); switch (elem.ElementType) { // data case ElementType.Literal: return GeLiteral((Literal)elem); case ElementType.Tuple: return GenTuple((TupleExpr)elem); case ElementType.List: return GenList((ListExpr)elem); // expr case ElementType.Binary: return GenBinary((BinaryExpr)elem); case ElementType.Unary: return GenUnary((UnaryExpr)elem); // other case ElementType.Property: return GenProp((PropertyAccess)elem); case ElementType.Lambda: return GenLambda((Lambda)elem); case ElementType.Symbol: return GenSymbol((Symbol)elem); case ElementType.LambdaParam: return GenLambdaParam((LambdaParameter)elem); } throw Error("未知の要素が出現しました。", elem.Range.Start); }
/// <summary> /// 要素を必要に応じてObjectに変換した状態。 /// </summary> public Expression GenElem(Element elem) { Contract.Requires<ArgumentNullException>(elem != null); Contract.Ensures(Contract.Result<Expression>() != null); Contract.Ensures(Contract.Result<Expression>().Type == typeof(object)); var expr = GenElemCore(elem); if (expr.Type == typeof(object)) return expr; return Expression.Convert(expr, typeof(object)); }
// ===== ===== ===== ===== ===== method ===== ===== ===== ===== ===== /// <summary> /// 要素がBoolでなければBoolに変換した状態。 /// </summary> public Expression GenBoolElem(Element elem) { Contract.Requires<ArgumentNullException>(elem != null); Contract.Ensures(Contract.Result<Expression>() != null); Contract.Ensures(Contract.Result<Expression>().Type == typeof(bool)); var expr = GenElemCore(elem); if (expr.Type == typeof(bool)) return expr; return Expression.Dynamic(StmtGen.Factory.ToBoolBinder, typeof(bool), expr); }
public TupleExpr(Element head, Element tail, TextRange range) : base(range) { Contract.Requires<ArgumentNullException>(head != null); Contract.Requires<ArgumentNullException>(tail != null); this.Head = head; this.Tail = tail; }
public Return(Element value) { Contract.Requires<ArgumentNullException>(value != null); this.Value = value; }
public PropertySet(PropertyAccess property, Element value, bool isMaybe, TextRange range) : base(isMaybe, range) { Contract.Requires<ArgumentNullException>(property != null); this.Property = property; this.Value = value; }
public PropertyAccess(Element value, string name, TextRange range) : base(range) { Contract.Requires<ArgumentNullException>(value != null); Contract.Requires<ArgumentNullException>(name != null); this.Value = value; this.Name = name; }
public MapCall(Element name, ArgumentTuple firstArg, IList<ArgumentTuple> args, bool isMaybe, TextRange range) : base(name, args, isMaybe, range) { this.FirstArg = firstArg; }
public Lambda(Element elem, TextRange range) : base(range) { Contract.Requires<ArgumentNullException>(elem != null); this.Element = elem; }
public DefineValue(string name, Element value, TextRange range) : base(false, range) { Contract.Requires<ArgumentNullException>(name != null); this.Name = name; this.Value = value; }
public CondThenPair(Element cond, NormalStatement stmt) { Contract.Requires<ArgumentNullException>(cond != null); Contract.Requires<ArgumentNullException>(stmt != null); this.Condition = cond; this.Statement = stmt; }
public Call(Element target, IEnumerable<ArgumentTuple> args, bool isMaybe, TextRange range) : base(isMaybe, range) { Contract.Requires<ArgumentNullException>(target != null); Contract.Requires<ArgumentNullException>(args != null); this.Target = target; Arguments = Array.AsReadOnly(args.ToArray()); }
public BinaryExpr(Element left, BinaryOperationType type, Element right, TextRange range) : base(range) { Contract.Requires<ArgumentNullException>(left != null); Contract.Requires<ArgumentNullException>(right != null); this.Left = left; this.Right = right; this.ExprType = type; }
public UnaryExpr(UnaryOperationType type, Element value, TextRange range) : base(range) { Contract.Requires<ArgumentNullException>(value != null); this.ExprType = type; this.Value = value; }