public override void Visit(ILocalDeclarationStatement declaration) { if (!CheckForExistingNull(declaration.InitialValue)) { MarkMutationTarget(declaration); } }
public override void Visit(ILocalDeclarationStatement declaration) { if (!CheckForExistingNull(declaration.InitialValue)) { MarkMutationTarget(declaration); } }
public override IStatement Rewrite(ILocalDeclarationStatement localDeclarationStatement) { if (this.iteratorLocalCount != null) { uint count = 0; this.iteratorLocalCount.TryGetValue(this.currentBlockStatement, out count); this.iteratorLocalCount[this.currentBlockStatement] = ++count; } BoundField /*?*/ boundField; if (this.fieldForCapturedLocalOrParameter.TryGetValue(localDeclarationStatement.LocalVariable, out boundField)) { if (localDeclarationStatement.InitialValue != null && !localDeclarationStatement.InitialValue.Equals(Dummy.Expression)) { ExpressionStatement assignToLocal = new ExpressionStatement() { Expression = new Assignment() { Source = localDeclarationStatement.InitialValue, Target = new TargetExpression() { Definition = localDeclarationStatement.LocalVariable, Instance = null, Type = localDeclarationStatement.LocalVariable.Type }, Type = localDeclarationStatement.LocalVariable.Type }, Locations = IteratorHelper.EnumerableIsEmpty(localDeclarationStatement.Locations) ? null : new List <ILocation>(localDeclarationStatement.Locations) }; base.RewriteChildren(assignToLocal); return(assignToLocal); } } return(base.Rewrite(localDeclarationStatement)); }
public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { if (!insideResourceUse) { this.sourceEmitterOutput.Write("", true); } this.PrintLocalDefinition(localDeclarationStatement.LocalVariable); if (localDeclarationStatement.InitialValue != null) { this.sourceEmitterOutput.Write(" = "); this.Traverse(localDeclarationStatement.InitialValue); } else if (localDeclarationStatement.LocalVariable.IsConstant) { this.sourceEmitterOutput.Write(" = "); this.Traverse(localDeclarationStatement.LocalVariable.CompileTimeValue); } if (!insideResourceUse) { this.sourceEmitterOutput.WriteLine(";"); } }
public ReturnRewriter(IMetadataHost host, ILabeledStatement target, ILocalDeclarationStatement local) : base(host) { Contract.Requires(host != null && target != null); this.target = target; this.local = local; }
public override void Visit(ILocalDeclarationStatement localDeclarationStatement) { if (Process(localDeclarationStatement)) { visitor.Visit(localDeclarationStatement); } base.Visit(localDeclarationStatement); }
public override void Visit(ILocalDeclarationStatement dec) { if (dec.InitialValue != null) { var expanded = new HashSet <string>(Names.Names(Expand(dec.InitialValue))); expanded.Add("<local>" + dec.LocalVariable.Name.Value); Mark(expanded); } }
public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { var be = localDeclarationStatement.InitialValue as IBoundExpression; if (be != null) { this.localsToInitializers.Add(localDeclarationStatement.LocalVariable, be); } }
public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { base.TraverseChildren(localDeclarationStatement); if (localDeclarationStatement.InitialValue == null) { return; } this.numberOfAssignmentsToLocal[localDeclarationStatement.LocalVariable]++; }
public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { base.TraverseChildren(localDeclarationStatement); if (localDeclarationStatement.InitialValue != null && localDeclarationStatement.LocalVariable.Type is Dummy) { var temp = (TempVariable)localDeclarationStatement.LocalVariable; temp.Type = localDeclarationStatement.InitialValue.Type; } }
public override void Visit(ILocalDeclarationStatement localDeclarationStatement) { NewLineAddIndent(); AppendElementType(localDeclarationStatement); Visit(localDeclarationStatement.LocalVariable); //output.Append("="); //AppendSpace(); Visit(localDeclarationStatement.InitialValue); base.Visit(localDeclarationStatement); }
public override IStatement Rewrite(ILocalDeclarationStatement localDeclarationStatement) { var local = localDeclarationStatement.LocalVariable as LocalDefinition; if (local != null && this.delegatesCachedInLocals != null && this.delegatesCachedInLocals.ContainsKey(local)) { return(CodeDummy.Block); } return(base.Rewrite(localDeclarationStatement)); }
public ILocalDeclarationStatement DefineLocal(IStatementBlockLocalMember local) { if (local.ParentTarget == this) { ILocalDeclarationStatement localDecl = local.GetDeclarationStatement(); localDecl.ReferencedMember.AutoDeclare = false; Add(localDecl); return(localDecl); } throw new InvalidOperationException("Cannot declare a local outside its scope."); }
/// <summary> /// If the local declaration has an initial value, then generate the /// statement "loc := e" from it. /// Special case: if "loc" is a struct, then treat it as a call to /// the default ctor. /// Otherwise ignore it. /// </summary> public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { var initVal = localDeclarationStatement.InitialValue; var typ = localDeclarationStatement.LocalVariable.Type; var isStruct = TranslationHelper.IsStruct(typ); if (initVal == null && !isStruct) { return; } var boogieLocal = this.sink.FindOrCreateLocalVariable(localDeclarationStatement.LocalVariable); var boogieLocalExpr = Bpl.Expr.Ident(boogieLocal); var tok = localDeclarationStatement.Token(); Bpl.Expr e = null; var structCopy = isStruct && initVal != null && !(initVal is IDefaultValue); // then a struct value of type S is being assigned: "lhs := s" // model this as the statement "call lhs := S..#copy_ctor(s)" that does the bit-wise copying if (isStruct) { if (!structCopy) { var defaultValue = new DefaultValue() { DefaultValueType = typ, Locations = new List <ILocation>(localDeclarationStatement.Locations), Type = typ, }; var e2 = ExpressionFor(defaultValue); StmtBuilder.Add(Bpl.Cmd.SimpleAssign(tok, boogieLocalExpr, e2)); } else /*if (structCopy) */ { var proc = this.sink.FindOrCreateProcedureForStructCopy(typ); e = ExpressionFor(initVal); StmtBuilder.Add(new Bpl.CallCmd(tok, proc.Name, new List <Bpl.Expr> { e, }, new List <Bpl.IdentifierExpr> { boogieLocalExpr, })); } } else { e = ExpressionFor(initVal); AddRecordCall(localDeclarationStatement.LocalVariable.Name.Value, initVal, e); StmtBuilder.Add(Bpl.Cmd.SimpleAssign(tok, boogieLocalExpr, e)); } return; }
public override IStatement Rewrite(ILocalDeclarationStatement declaration) { return(new LocalDeclarationStatement(declaration) { InitialValue = new Conversion() { Type = declaration.InitialValue.Type, TypeAfterConversion = declaration.InitialValue.Type, ValueToConvert = new CompileTimeConstant() { Type = Host.PlatformType.SystemObject, Value = null, } } }); }
private void ProcessLocalDeclarationStatement(ILocalDeclarationStatement pStatement) { if (mCurrentBlock.Terminated) { mCurrentBlock = CreateBlock(CreateLabel()); } if (pStatement.InitialValue == null) { return; } HLLocation locationLocalVariable = HLLocalLocation.Create(HLDomain.GetLocal(pStatement.LocalVariable)); HLLocation locationInitialValue = ProcessExpression(pStatement.InitialValue); mCurrentBlock.EmitAssignment(locationLocalVariable, locationInitialValue); }
public override IStatement Rewrite(ILocalDeclarationStatement declaration) { return new LocalDeclarationStatement(declaration) { InitialValue = new Conversion() { Type = declaration.InitialValue.Type, TypeAfterConversion = declaration.InitialValue.Type, ValueToConvert = new CompileTimeConstant() { Type = Host.PlatformType.SystemObject, Value = null, } } }; }
public override IStatement Rewrite(ILocalDeclarationStatement localDeclarationStatement) { var capturedLocal = localDeclarationStatement.LocalVariable as CapturedLocalDefinition; if (capturedLocal != null) { Contract.Assume(capturedLocal.capturingField != null); var binding = this.closureFieldToLocalOrParameterMap[capturedLocal.capturingField.InternedKey] as BoundExpression; if (binding != null && binding.Definition != capturedLocal) { return(CodeDummy.Block); } } if (this.closures.Find(localDeclarationStatement.LocalVariable.Type.InternedKey) != null) { return(CodeDummy.Block); } return(base.Rewrite(localDeclarationStatement)); }
public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { if (localDeclarationStatement.LocalVariable.IsConstant) { this.sourceEmitterOutput.Write("const ", true); } else { this.sourceEmitterOutput.Write("", true); } string type = TypeHelper.GetTypeName(localDeclarationStatement.LocalVariable.Type, NameFormattingOptions.ContractNullable | NameFormattingOptions.UseTypeKeywords); this.sourceEmitterOutput.Write(type); if (localDeclarationStatement.LocalVariable.IsReference) { if (localDeclarationStatement.LocalVariable.IsPinned) { this.sourceEmitterOutput.Write("*"); } else { this.sourceEmitterOutput.Write("&"); } } this.sourceEmitterOutput.Write(" "); this.PrintLocalName(localDeclarationStatement.LocalVariable); if (localDeclarationStatement.InitialValue != null) { this.sourceEmitterOutput.Write(" = "); this.Traverse(localDeclarationStatement.InitialValue); } else if (localDeclarationStatement.LocalVariable.IsConstant) { this.sourceEmitterOutput.Write(" = "); this.Traverse(localDeclarationStatement.LocalVariable.CompileTimeValue); } this.sourceEmitterOutput.WriteLine(";"); }
private static ICreateObjectInstance /*?*/ GetICreateObjectInstance(IStatement statement) { IExpressionStatement expressionStatement = statement as IExpressionStatement; if (expressionStatement != null) { IAssignment assignment = expressionStatement.Expression as IAssignment; if (assignment == null) { return(null); } ICreateObjectInstance createObjectInstance = assignment.Source as ICreateObjectInstance; return(createObjectInstance); } ILocalDeclarationStatement localDeclaration = statement as ILocalDeclarationStatement; if (localDeclaration != null) { ICreateObjectInstance createObjectInstance = localDeclaration.InitialValue as ICreateObjectInstance; return(createObjectInstance); } return(null); }
public virtual void onASTElement(ILocalDeclarationStatement localDeclarationStatement) { }
/// <summary> /// Generates IL for the specified local declaration statement. /// </summary> /// <param name="localDeclarationStatement">The local declaration statement.</param> public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { this.EmitSequencePoint(localDeclarationStatement.Locations); if (localDeclarationStatement.LocalVariable.IsConstant) { this.generator.AddConstantToCurrentScope(localDeclarationStatement.LocalVariable); this.generator.Emit(OperationCode.Nop); //Make sure the constant always has a scope } else { this.GetLocalIndex(localDeclarationStatement.LocalVariable); this.generator.AddVariableToCurrentScope(localDeclarationStatement.LocalVariable); if (localDeclarationStatement.InitialValue != null) { this.Traverse(localDeclarationStatement.InitialValue); this.VisitAssignmentTo(localDeclarationStatement.LocalVariable); } } this.lastStatementWasUnconditionalTransfer = false; }
public abstract void TranslateStatement(ILocalDeclarationStatement localDeclare);
/// <summary> /// Performs some computation with the given local declaration statement. /// </summary> /// <param name="localDeclarationStatement"></param> public virtual void Visit(ILocalDeclarationStatement localDeclarationStatement) { this.Visit((IStatement)localDeclarationStatement); }
/// <summary> /// Returns a shallow copy of the given local declaration statement. /// </summary> /// <param name="localDeclarationStatement"></param> public LocalDeclarationStatement Copy(ILocalDeclarationStatement localDeclarationStatement) { Contract.Requires(localDeclarationStatement != null); Contract.Ensures(Contract.Result<LocalDeclarationStatement>() != null); return new LocalDeclarationStatement(localDeclarationStatement); }
/// <summary> /// Performs some computation with the given local declaration statement. /// </summary> /// <param name="localDeclarationStatement"></param> public virtual void Visit(ILocalDeclarationStatement localDeclarationStatement) { }
/// <summary> /// Traverses the children of the local declaration statement. /// </summary> public virtual void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { Contract.Requires(localDeclarationStatement != null); this.TraverseChildren((IStatement)localDeclarationStatement); if (this.StopTraversal) return; this.Traverse(localDeclarationStatement.LocalVariable); if (this.StopTraversal) return; if (localDeclarationStatement.InitialValue != null) this.Traverse(localDeclarationStatement.InitialValue); }
/// <summary> /// Rewrites the given local declaration statement. /// </summary> /// <param name="localDeclarationStatement"></param> public virtual IStatement Rewrite(ILocalDeclarationStatement localDeclarationStatement) { return localDeclarationStatement; }
public TestLinkerResult Visit(ILocalDeclarationStatement statement, ICompilationContext context) { throw new NotImplementedException(); }
public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { this.declaredLocals[localDeclarationStatement.LocalVariable] = true; base.TraverseChildren(localDeclarationStatement); }
public void Visit(ILocalDeclarationStatement localDeclarationStatement) { throw new NotImplementedException(); }
/// <summary> /// Performs some computation with the given local declaration statement. /// </summary> /// <param name="localDeclarationStatement"></param> public virtual void Visit(ILocalDeclarationStatement localDeclarationStatement) { }
public override void TranslateStatement(ILocalDeclarationStatement localDeclare) { this.Provider.GenerateCodeFromStatement(localDeclare.GenerateCodeDom(this.Options), base.Target, this.Options.Options); }
public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { this.localsOrParametersInScope[localDeclarationStatement.LocalVariable] = true; base.TraverseChildren(localDeclarationStatement); }
public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { MethodEnter(localDeclarationStatement); base.TraverseChildren(localDeclarationStatement); MethodExit(); }
public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { if (this.currentAnonymousDelegate != null) this.definitionsToIgnore[localDeclarationStatement.LocalVariable] = true; base.TraverseChildren(localDeclarationStatement); }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Traverses the given local declaration statement. /// </summary> /// <param name="localDeclarationStatement"></param> public virtual void Visit(ILocalDeclarationStatement localDeclarationStatement) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(localDeclarationStatement); if (localDeclarationStatement.InitialValue != null) this.Visit(localDeclarationStatement.InitialValue); //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not decrease this.path.Count. this.path.Pop(); }
public override void Visit(ILocalDeclarationStatement localDeclarationStatement) { allElements.Add(new InvokInfo(Traverser, "ILocalDeclarationStatement", localDeclarationStatement)); }
/// <summary> /// Traverses the local declaration statement. /// </summary> public void Traverse(ILocalDeclarationStatement localDeclarationStatement) { Contract.Requires(localDeclarationStatement != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(localDeclarationStatement); if (this.StopTraversal) return; this.TraverseChildren(localDeclarationStatement); if (this.StopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(localDeclarationStatement); }
public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { var be = localDeclarationStatement.InitialValue as IBoundExpression; if (be != null) { this.localsToInitializers.Add(localDeclarationStatement.LocalVariable, be); } }
public void Visit(ILocalDeclarationStatement localDeclarationStatement) { this.traverser.Traverse(localDeclarationStatement); }
public void Visit(ILocalDeclarationStatement localDeclarationStatement) { this.result = this.copier.Copy(localDeclarationStatement); }
public void Visit(ILocalDeclarationStatement localDeclarationStatement) { Contract.Requires(localDeclarationStatement != null); throw new NotImplementedException(); }
public override IStatement Rewrite(ILocalDeclarationStatement localDeclarationStatement) { var local = localDeclarationStatement.LocalVariable as LocalDefinition; if (local != null && this.delegatesCachedInLocals != null && this.delegatesCachedInLocals.ContainsKey(local)) return CodeDummy.Block; return base.Rewrite(localDeclarationStatement); }
public override IStatement Rewrite(ILocalDeclarationStatement localDeclarationStatement) { if (this.iteratorLocalCount != null) { uint count = 0; this.iteratorLocalCount.TryGetValue(this.currentBlockStatement, out count); this.iteratorLocalCount[this.currentBlockStatement] = ++count; } BoundField/*?*/ boundField; if (this.fieldForCapturedLocalOrParameter.TryGetValue(localDeclarationStatement.LocalVariable, out boundField)) { if (localDeclarationStatement.InitialValue != null && !localDeclarationStatement.InitialValue.Equals(Dummy.Expression)) { ExpressionStatement assignToLocal = new ExpressionStatement() { Expression = new Assignment() { Source = localDeclarationStatement.InitialValue, Target = new TargetExpression() { Definition = localDeclarationStatement.LocalVariable, Instance = null, Type = localDeclarationStatement.LocalVariable.Type }, Type = localDeclarationStatement.LocalVariable.Type }, Locations = IteratorHelper.EnumerableIsEmpty(localDeclarationStatement.Locations) ? null : new List<ILocation>(localDeclarationStatement.Locations) }; base.RewriteChildren(assignToLocal); return assignToLocal; } } return base.Rewrite(localDeclarationStatement); }
public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { MethodEnter(localDeclarationStatement); base.TraverseChildren(localDeclarationStatement); MethodExit(); }
/// <summary> /// Initializes an object that represents the declaration of a local variable, with optional initializer. /// </summary> /// <param name="localDeclarationStatement">The local declaration statement.</param> public LocalDeclarationStatement(ILocalDeclarationStatement localDeclarationStatement) : base(localDeclarationStatement) { this.initialValue = localDeclarationStatement.InitialValue; this.localVariable = localDeclarationStatement.LocalVariable; }
/// <summary> /// Visits the specified local declaration statement. /// </summary> /// <param name="localDeclarationStatement">The local declaration statement.</param> public override void Visit(ILocalDeclarationStatement localDeclarationStatement) { LocalDeclarationStatement mutableLocalDeclarationStatement = new LocalDeclarationStatement(localDeclarationStatement); this.resultStatement = this.myCodeCopier.DeepCopy(mutableLocalDeclarationStatement); }
public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { if (this.captures.ContainsKey(localDeclarationStatement.LocalVariable)) this.scopesWithCapturedLocals[this.currentBlock] = true; base.TraverseChildren(localDeclarationStatement); }
/// <summary> /// Returns a deep copy of the given local declaration statement. /// </summary> /// <param name="localDeclarationStatement"></param> public LocalDeclarationStatement Copy(ILocalDeclarationStatement localDeclarationStatement) { var mutableCopy = this.shallowCopier.Copy(localDeclarationStatement); if (!this.LocalsInsideCone.ContainsKey(mutableCopy.LocalVariable)) { //work around bug in decompiler, for now mutableCopy.LocalVariable = this.Copy(mutableCopy.LocalVariable); this.LocalsInsideCone.Add(localDeclarationStatement.LocalVariable, mutableCopy.LocalVariable); } if (mutableCopy.InitialValue != null) mutableCopy.InitialValue = this.Copy(mutableCopy.InitialValue); return mutableCopy; }
/// <summary> /// Rewrites the children of the given local declaration statement. /// </summary> public override IStatement Rewrite(ILocalDeclarationStatement localDeclarationStatement) { var local = localDeclarationStatement.LocalVariable; if (this.fieldReferencesForUseInsideAnonymousMethods.ContainsKey(local)) { Contract.Assume(!this.isInsideAnonymousMethod); //only locals outside of delegates get captured as far as this rewriter is concerned. this.isInsideAnonymousMethod = true; var fieldType = this.Rewrite(this.copier.Copy(local.Type)); //get the type as the anon delegate will see it this.isInsideAnonymousMethod = false; this.CreateClosureField(local, fieldType, local.Type, localDeclarationStatement.LocalVariable.Name.Value); if (localDeclarationStatement.InitialValue == null) return new EmptyStatement(); var field = this.fieldReferencesForUseInsideThisMethod[local]; return new ExpressionStatement() { Expression = new Assignment() { Target = new TargetExpression() { Instance = this.currentClosureObject, Definition = field, Type = field.Type }, Source = this.Rewrite(localDeclarationStatement.InitialValue), Type = fieldType, } }; } return base.Rewrite(localDeclarationStatement); }
/// <summary> /// Returns a shallow copy of the given local declaration statement. /// </summary> /// <param name="localDeclarationStatement"></param> public LocalDeclarationStatement Copy(ILocalDeclarationStatement localDeclarationStatement) { return new LocalDeclarationStatement(localDeclarationStatement); }
public virtual void onASTElement(ILocalDeclarationStatement localDeclarationStatement) { }
public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { if (localDeclarationStatement.LocalVariable.IsConstant) this.sourceEmitterOutput.Write("const ", true); else this.sourceEmitterOutput.Write("", true); string type = TypeHelper.GetTypeName(localDeclarationStatement.LocalVariable.Type, NameFormattingOptions.ContractNullable|NameFormattingOptions.UseTypeKeywords); this.sourceEmitterOutput.Write(type); if (localDeclarationStatement.LocalVariable.IsReference) { if (localDeclarationStatement.LocalVariable.IsPinned) this.sourceEmitterOutput.Write("*"); else this.sourceEmitterOutput.Write("&"); } this.sourceEmitterOutput.Write(" "); this.PrintLocalName(localDeclarationStatement.LocalVariable); if (localDeclarationStatement.InitialValue != null) { this.sourceEmitterOutput.Write(" = "); this.Traverse(localDeclarationStatement.InitialValue); } else if (localDeclarationStatement.LocalVariable.IsConstant) { this.sourceEmitterOutput.Write(" = "); this.Traverse(localDeclarationStatement.LocalVariable.CompileTimeValue); } this.sourceEmitterOutput.WriteLine(";"); }
public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { this.declaredLocals[localDeclarationStatement.LocalVariable] = true; base.TraverseChildren(localDeclarationStatement); }
public override void TraverseChildren(ILocalDeclarationStatement localDeclarationStatement) { if (!insideResourceUse) this.sourceEmitterOutput.Write("", true); this.PrintLocalDefinition(localDeclarationStatement.LocalVariable); if (localDeclarationStatement.InitialValue != null) { this.sourceEmitterOutput.Write(" = "); this.Traverse(localDeclarationStatement.InitialValue); } else if (localDeclarationStatement.LocalVariable.IsConstant) { this.sourceEmitterOutput.Write(" = "); this.Traverse(localDeclarationStatement.LocalVariable.CompileTimeValue); } if (!insideResourceUse) this.sourceEmitterOutput.WriteLine(";"); }