protected override void CloneTo(CloneContext clonectx, Statement target) { throw new NotSupportedException (); }
public override object Visit (Statement stmt) { Console.WriteLine ("unknown statement:" + stmt); return null; }
// // This routine must be overrided in derived classes and make copies // of all the data that might be modified if resolved // protected abstract void CloneTo (CloneContext clonectx, Statement target);
protected override void CloneTo(CloneContext clonectx, Statement t) { Yield target = (Yield) t; target.expr = expr.Clone (clonectx); }
protected override void CloneTo (CloneContext clonectx, Statement t) { StatementExpression target = (StatementExpression) t; target.expr = (ExpressionStatement) expr.Clone (clonectx); }
public void Add (Statement statement) { statements.Add (statement); }
protected override Expression ResolveInitializer (BlockContext bc, LocalVariable li, Expression initializer) { Assign assign; if (li.Type == InternalType.Dynamic) { initializer = initializer.Resolve (bc); if (initializer == null) return null; initializer = Convert.ImplicitConversionRequired (bc, initializer, TypeManager.idisposable_type, loc); if (initializer == null) return null; var var = LocalVariable.CreateCompilerGenerated (TypeManager.idisposable_type, bc.CurrentBlock, loc); assign = new SimpleAssign (var.CreateReferenceExpression (bc, loc), initializer, loc); assign.ResolveStatement (bc); dispose_call = CreateDisposeCall (bc, var); dispose_call.Resolve (bc); return assign; } if (li == Variable) { CheckIDiposableConversion (bc, li, initializer); dispose_call = CreateDisposeCall (bc, li); dispose_call.Resolve (bc); } return base.ResolveInitializer (bc, li, initializer); }
protected override void CloneTo (CloneContext clonectx, Statement t) { Foreach target = (Foreach) t; target.type = type.Clone (clonectx); target.expr = expr.Clone (clonectx); target.statement = statement.Clone (clonectx); }
protected override void CloneTo (CloneContext clonectx, Statement t) { TryFinally target = (TryFinally) t; target.stmt = (Statement) stmt.Clone (clonectx); if (fini != null) target.fini = clonectx.LookupBlock (fini); }
protected override void CloneTo (CloneContext clonectx, Statement t) { TryCatch target = (TryCatch) t; target.Block = clonectx.LookupBlock (Block); if (General != null) target.General = (Catch) General.Clone (clonectx); if (Specific != null){ target.Specific = new List<Catch> (); foreach (Catch c in Specific) target.Specific.Add ((Catch) c.Clone (clonectx)); } }
public TryFinally (Statement stmt, Block fini, Location loc) : base (stmt, loc) { this.fini = fini; }
public For (Statement init_statement, BooleanExpression test, Statement increment, Statement statement, Location l) { InitStatement = init_statement; Test = test; Increment = increment; Statement = statement; loc = l; }
protected override void CloneTo (CloneContext clonectx, Statement t) { Catch target = (Catch) t; if (type_expr != null) target.type_expr = (FullNamedExpression) type_expr.Clone (clonectx); target.block = clonectx.LookupBlock (block); }
protected override void CloneTo (CloneContext clonectx, Statement t) { Fixed target = (Fixed) t; target.decl = (VariableDeclaration) decl.Clone (clonectx); target.statement = statement.Clone (clonectx); }
public Statement RewriteForDeclarators (BlockContext bc, Statement stmt) { for (int i = declarators.Count - 1; i >= 0; --i) { var d = declarators [i]; var vd = new VariableDeclaration (d.Variable, type_expr.Location); vd.Initializer = d.Initializer; vd.IsNested = true; vd.dispose_call = CreateDisposeCall (bc, d.Variable); vd.dispose_call.Resolve (bc); stmt = new Using (vd, stmt, d.Variable.Location); } declarators = null; return stmt; }
public override bool Resolve (BlockContext ec) { expr = expr.Resolve (ec); if (expr == null) return false; if (expr.IsNull) { ec.Report.Error (186, loc, "Use of null is not valid in this context"); return false; } if (expr.Type == TypeManager.string_type) { statement = new ArrayForeach (this, 1); } else if (expr.Type is ArrayContainer) { statement = new ArrayForeach (this, ((ArrayContainer) expr.Type).Rank); } else { if (expr.eclass == ExprClass.MethodGroup || expr is AnonymousMethodExpression) { ec.Report.Error (446, expr.Location, "Foreach statement cannot operate on a `{0}'", expr.ExprClassName); return false; } statement = new CollectionForeach (type, variable, expr, statement, loc); } return statement.Resolve (ec); }
public Using (VariableDeclaration decl, Statement stmt, Location loc) : base (stmt, loc) { this.decl = decl; }
protected override void CloneTo (CloneContext clonectx, Statement t) { For target = (For) t; if (InitStatement != null) target.InitStatement = InitStatement.Clone (clonectx); if (Test != null) target.Test = Test.Clone (clonectx); if (Increment != null) target.Increment = Increment.Clone (clonectx); target.Statement = Statement.Clone (clonectx); }
public Using (Expression expr, Statement stmt, Location loc) : base (stmt, loc) { this.decl = new VariableDeclaration (expr); }
public StatementList (Statement first, Statement second) { statements = new List<Statement> () { first, second }; }
protected override void CloneTo (CloneContext clonectx, Statement t) { Using target = (Using) t; target.decl = (VariableDeclaration) decl.Clone (clonectx); target.stmt = stmt.Clone (clonectx); }
protected override void CloneTo (CloneContext clonectx, Statement target) { StatementList t = (StatementList) target; t.statements = new List<Statement> (statements.Count); foreach (Statement s in statements) t.statements.Add (s.Clone (clonectx)); }
public ArrayForeach (Foreach @foreach, int rank) { for_each = @foreach; statement = for_each.statement; loc = @foreach.loc; variable = new LocalVariableReference (for_each.variable, loc); counter = new StatementExpression[rank]; variables = new TemporaryVariableReference[rank]; length_exprs = new Expression [rank]; // // Only use temporary length variables when dealing with // multi-dimensional arrays // if (rank > 1) lengths = new TemporaryVariableReference [rank]; }
protected override void CloneTo (CloneContext clonectx, Statement t) { Return target = (Return) t; // It's null for simple return; if (Expr != null) target.Expr = Expr.Clone (clonectx); }
public Body (TypeSpec type, LocalVariable variable, Expression current, Statement statement, Location loc) { this.type = type; this.variable = new LocalVariableReference (variable, loc); this.current = current; this.statement = statement; this.loc = loc; }
protected override void CloneTo(CloneContext clonectx, Statement target) { IteratorStatement t = (IteratorStatement) target; t.original_block = (ExplicitBlock) original_block.Clone (clonectx); t.iterator = (Iterator) iterator.Clone (clonectx); }
public override bool Resolve (BlockContext ec) { bool is_dynamic = expr.Type == InternalType.Dynamic; if (is_dynamic) { expr = Convert.ImplicitConversionRequired (ec, expr, TypeManager.ienumerable_type, loc); } else if (TypeManager.IsNullableType (expr.Type)) { expr = new Nullable.UnwrapCall (expr).Resolve (ec); } var get_enumerator_mg = ResolveGetEnumerator (ec); if (get_enumerator_mg == null) { return false; } var get_enumerator = get_enumerator_mg.BestCandidate; enumerator_variable = TemporaryVariableReference.Create (get_enumerator.ReturnType, variable.Block, loc); enumerator_variable.Resolve (ec); // Prepare bool MoveNext () var move_next_mg = ResolveMoveNext (ec, get_enumerator); if (move_next_mg == null) { return false; } move_next_mg.InstanceExpression = enumerator_variable; // Prepare ~T~ Current { get; } var current_prop = ResolveCurrent (ec, get_enumerator); if (current_prop == null) { return false; } var current_pe = new PropertyExpr (current_prop, loc) { InstanceExpression = enumerator_variable }.Resolve (ec); if (current_pe == null) return false; VarExpr ve = var_type as VarExpr; if (ve != null) { if (is_dynamic) { // Source type is dynamic, set element type to dynamic too var_type = new TypeExpression (InternalType.Dynamic, var_type.Location); } else { // Infer implicitly typed local variable from foreach enumerable type var_type = new TypeExpression (current_pe.Type, var_type.Location); } } else if (is_dynamic) { // Explicit cast of dynamic collection elements has to be done at runtime current_pe = EmptyCast.Create (current_pe, InternalType.Dynamic); } var_type = var_type.ResolveAsTypeTerminal (ec, false); if (var_type == null) return false; variable.Type = var_type.Type; var init = new Invocation (get_enumerator_mg, null); statement = new While (new BooleanExpression (new Invocation (move_next_mg, null)), new Body (var_type.Type, variable, current_pe, statement, loc), loc); var enum_type = enumerator_variable.Type; // // Add Dispose method call when enumerator can be IDisposable // if (!enum_type.ImplementsInterface (TypeManager.idisposable_type, false)) { if (!enum_type.IsSealed && !TypeManager.IsValueType (enum_type)) { // // Runtime Dispose check // var vd = new RuntimeDispose (enumerator_variable.LocalInfo, loc); vd.Initializer = init; statement = new Using (vd, statement, loc); } else { // // No Dispose call needed // this.init = new SimpleAssign (enumerator_variable, init); this.init.Resolve (ec); } } else { // // Static Dispose check // var vd = new Using.VariableDeclaration (enumerator_variable.LocalInfo, loc); vd.Initializer = init; statement = new Using (vd, statement, loc); } return statement.Resolve (ec); }
public DynamicEventCompoundAssign(string name, Arguments args, ExpressionStatement assignment, ExpressionStatement invoke, Location loc) : base(null, args, loc) { this.name = name; base.binder = this; // Used by += or -= only type = TypeManager.bool_type; condition = new If ( new Binary (Binary.Operator.Equality, this, new BoolLiteral (true, loc), loc), new StatementExpression (invoke), new StatementExpression (assignment), loc); }
public Foreach (Expression type, LocalVariable var, Expression expr, Statement stmt, Location l) { this.type = type; this.variable = var; this.expr = expr; statement = stmt; loc = l; }
protected override void CloneTo (CloneContext clonectx, Statement target) { // Nothing to clone }
public virtual object Visit(Statement stmt) { Debug.Fail("unknown statement:" + stmt); return(null); }