/// <summary> /// Bind a name to this scope, including destructuring assignment. /// </summary> public void Bind(Analyzer analyzer, Exp target, DataType rvalue, BindingKind kind) { if (target is Identifier id) { this.Bind(analyzer, id, rvalue, kind); } else if (target is PyTuple tup) { this.Bind(analyzer, tup.values, rvalue, kind); } else if (target is PyList list) { this.Bind(analyzer, list.elts, rvalue, kind); } else if (target is AttributeAccess attr) { DataType targetType = TransformExp(analyzer, attr.Expression, this); setAttr(analyzer, attr, rvalue, targetType); } else if (target is ArrayRef sub) { DataType valueType = TransformExp(analyzer, sub.array, this); var xform = new TypeTransformer(this, analyzer); TransformExprs(analyzer, sub.subs, this); if (valueType is ListType t) { t.setElementType(UnionType.Union(t.eltType, rvalue)); } } else if (target != null) { analyzer.AddProblem(target, "invalid location for assignment"); } }
public static void TransformExprs(Analyzer analyzer, List <Slice> exprs, State s) { var x = new TypeTransformer(s, analyzer); foreach (var e in exprs) { e.Accept(x); } }
public void ApplyUncalled() { IProgress progress = new Progress(s => this.msg_(s), uncalled.Count, 50, this.HasOption("quiet")); while (uncalled.Count != 0) { var uncalledDup = uncalled.ToList(); foreach (FunType cl in uncalledDup) { progress.Tick(); TypeTransformer.Apply(this, cl, null, null, null, null, null); } } }