public static Expression SetVarCached(this IScope S, string Name, Expression E, bool Recursive = true) { var C = S.HasVar(Name, E.Type, Recursive); IScope Sc; if (C == -1) { C = S.HasVar(Name, Recursive); } if (C == -1) { Sc = S; Sc.DeclareVar(Name, E.Type); } else { Sc = S.ElementAt(C); if (!Sc.OnDateType.ContainsKey(Name)) { Sc.OnDateType.Add(Name, new List <Type>()); } else { Sc.OnDateType[Name].Clear(); } if (!Sc.HasVar(Name, E.Type)) { Sc.DeclareVar(Name, E.Type); } Sc.OnDateType[Name].Add(E.Type); } return(Sc.SetVar(Name, E)); }
public static Expression Generator(this VarAutExpression E) { Type T; if (E.Index == null) { T = E.UnboxTo ?? typeof(object); } else { E.Index = E.Index.Select(x => x.ConvertTo(typeof(int))).ToList(); if (E.UnboxTo != null) { if (E.Index.Count == 1) { T = E.UnboxTo.MakeArrayType(); } else { T = E.UnboxTo.MakeArrayType(E.Index.Count); } } else if (E.Index.Count == 1) { T = typeof(object[]); } else { T = typeof(object).MakeArrayType(E.Index.Count); } } IScope Sc; if (E.IsGlobal ?? false) { Sc = CurrentScope.Last(); } else { Sc = CurrentScope; } Sc.DeclareVar(E.Name, T); if (E.Index == null) { return(null); } else { return(Sc.SetVar(E.Name, Expression.NewArrayBounds(T.GetElementType(), E.Index))); } }