Example #1
0
 public ArgumentTuple(Element arg, string sfx)
 {
     Contract.Requires<ArgumentNullException>(arg != null);
     Contract.Requires<ArgumentNullException>(sfx != null);
     this.Argument = arg;
     this.Suffix = sfx;
 }
Example #2
0
 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);
 }
Example #6
0
 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;
 }
Example #7
0
 public Return(Element value)
 {
     Contract.Requires<ArgumentNullException>(value != null);
     this.Value = value;
 }
Example #8
0
 public PropertySet(PropertyAccess property, Element value, bool isMaybe, TextRange range)
     : base(isMaybe, range)
 {
     Contract.Requires<ArgumentNullException>(property != null);
     this.Property = property;
     this.Value = value;
 }
Example #9
0
 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;
 }
Example #10
0
 public MapCall(Element name, ArgumentTuple firstArg, IList<ArgumentTuple> args, bool isMaybe, TextRange range)
     : base(name, args, isMaybe, range)
 {
     this.FirstArg = firstArg;
 }
Example #11
0
 public Lambda(Element elem, TextRange range)
     : base(range)
 {
     Contract.Requires<ArgumentNullException>(elem != null);
     this.Element = elem;
 }
Example #12
0
 public DefineValue(string name, Element value, TextRange range)
     : base(false, range)
 {
     Contract.Requires<ArgumentNullException>(name != null);
     this.Name = name;
     this.Value = value;
 }
Example #13
0
 public CondThenPair(Element cond, NormalStatement stmt)
 {
     Contract.Requires<ArgumentNullException>(cond != null);
     Contract.Requires<ArgumentNullException>(stmt != null);
     this.Condition = cond;
     this.Statement = stmt;
 }
Example #14
0
 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());
 }
Example #15
0
 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;
 }
Example #16
0
 public UnaryExpr(UnaryOperationType type, Element value, TextRange range)
     : base(range)
 {
     Contract.Requires<ArgumentNullException>(value != null);
     this.ExprType = type;
     this.Value = value;
 }