コード例 #1
0
ファイル: CallExpression.cs プロジェクト: xeno-by/relinq
 public CallExpression(String name, TypeInferenceUnit target, IEnumerable<TypeInferenceUnit> args)
     : base(ExpressionType.Call, Enumerable.Repeat(target, 1).Union(args))
 {
     Name = name;
     Target = Children.ElementAt(0);
     Args = Children.Skip(1);
 }
コード例 #2
0
        public Expression Visit(TypeInferenceUnit tiu)
        {
            if (tiu == null)
            {
                return null;
            } 
            else
            {
                if (!tiu.IsFullyInferred)
                {
                    throw new ArgumentException(String.Format(
                        "Type inference unit '{0}': underlying type not fully inferred", tiu));
                }
                else
                {
                    switch (tiu.NodeType)
                    {
                        case ExpressionType.Keyword:
                            return VisitKeyword((KeywordExpression)tiu);

                        case ExpressionType.Variable:
                            return VisitVariable((VariableExpression)tiu);

                        case ExpressionType.Literal:
                            return VisitLiteral((LiteralExpression)tiu);

                        case ExpressionType.Json:
                            return VisitJson((JsonExpression)tiu);

                        case ExpressionType.Lambda:
                            return VisitLambda((LambdaExpression)tiu);

                        case ExpressionType.Field:
                            return VisitField((FieldExpression)tiu);

                        case ExpressionType.Call:
                            return VisitCall((CallExpression)tiu);

                        case ExpressionType.Ternary:
                            return VisitTernary((ConditionalExpression)tiu);
                    }

                    throw new NotSupportedException(tiu.ToString());
                }
            }
        }
コード例 #3
0
ファイル: TypeInferenceEngine.cs プロジェクト: xeno-by/relinq
        private void BindToAst(TypeInferenceUnit ast)
        {
            try
            {
                _ast = ast;
                _ast.InitializeMainTypePoint();
                _ast.InitializeTypeLinks();
            }
            catch (Exception)
            {
#if DEBUG
                Dump();
#endif
                Dispose();
                throw;
            }
        }
コード例 #4
0
ファイル: FieldExpression.cs プロジェクト: xeno-by/relinq
 public FieldExpression(String name, TypeInferenceUnit target)
     : base(ExpressionType.Field, Enumerable.Repeat(target, 1))
 {
     Name = name;
     Target = Children.ElementAt(0);
 }
コード例 #5
0
 public ConversionExpression(TypeInferenceUnit target)
     : base("<>op_Convert", target, Enumerable.Empty<TypeInferenceUnit>())
 {
 }
コード例 #6
0
 public ConditionalExpression(TypeInferenceUnit cond, TypeInferenceUnit ifTrue, TypeInferenceUnit ifFalse) 
     : base(ExpressionType.Ternary, new []{cond, ifTrue, ifFalse})
 {
 }
コード例 #7
0
ファイル: FuzzyMetadata.cs プロジェクト: xeno-by/relinq
 protected FuzzyMetadata()
 {
     Host = TypeInferenceUnit.Current;
     Links = Enumerable.Empty<TypeLink>();
 }
コード例 #8
0
ファイル: TypeInferenceEngine.cs プロジェクト: xeno-by/relinq
 public TypeInferenceEngine(TypeInferenceUnit ast)
     :this()
 {
     BindToAst(ast);
 }
コード例 #9
0
ファイル: TypeInferenceEngine.cs プロジェクト: xeno-by/relinq
 private void FlattenAst(List<TypeInferenceUnit> list, TypeInferenceUnit root)
 {
     list.Add(root);
     root.Children.ForEach(child => FlattenAst(list, child));
 }
コード例 #10
0
ファイル: TypeInferenceEngine.cs プロジェクト: xeno-by/relinq
        private void DumpAst(TypeInferenceUnit root, StreamWriter sw, String tab)
        {
            sw.Write(tab);
            root.Dump(sw);

            foreach (var child in root.Children)
            {
                DumpAst(child, sw, tab + "\t");
            }
        }
コード例 #11
0
ファイル: TypeInferenceEngine.cs プロジェクト: xeno-by/relinq
 private void DumpAst(TypeInferenceUnit root)
 {
     if (Directory.Exists(@"d:\dumps\"))
     {
         using (var sw = new StreamWriter(@"d:\dumps\ast-" + Guid.NewGuid() + ".dump"))
         {
             DumpAst(root, sw, String.Empty);
         }
     }
 }
コード例 #12
0
ファイル: LambdaExpression.cs プロジェクト: xeno-by/relinq
 public LambdaExpression(IEnumerable<String> args, TypeInferenceUnit body)
     : base(ExpressionType.Lambda, Enumerable.Repeat(body, 1))
 {
     Args = args;
     Body = Children.ElementAt(0);
 }