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); }
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()); } } }
private void BindToAst(TypeInferenceUnit ast) { try { _ast = ast; _ast.InitializeMainTypePoint(); _ast.InitializeTypeLinks(); } catch (Exception) { #if DEBUG Dump(); #endif Dispose(); throw; } }
public FieldExpression(String name, TypeInferenceUnit target) : base(ExpressionType.Field, Enumerable.Repeat(target, 1)) { Name = name; Target = Children.ElementAt(0); }
public ConversionExpression(TypeInferenceUnit target) : base("<>op_Convert", target, Enumerable.Empty<TypeInferenceUnit>()) { }
public ConditionalExpression(TypeInferenceUnit cond, TypeInferenceUnit ifTrue, TypeInferenceUnit ifFalse) : base(ExpressionType.Ternary, new []{cond, ifTrue, ifFalse}) { }
protected FuzzyMetadata() { Host = TypeInferenceUnit.Current; Links = Enumerable.Empty<TypeLink>(); }
public TypeInferenceEngine(TypeInferenceUnit ast) :this() { BindToAst(ast); }
private void FlattenAst(List<TypeInferenceUnit> list, TypeInferenceUnit root) { list.Add(root); root.Children.ForEach(child => FlattenAst(list, child)); }
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"); } }
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); } } }
public LambdaExpression(IEnumerable<String> args, TypeInferenceUnit body) : base(ExpressionType.Lambda, Enumerable.Repeat(body, 1)) { Args = args; Body = Children.ElementAt(0); }