public VariableInfo(IVariableDeclaration declaration) { Node = declaration; IsWriteUsage = true; FunctionLike = declaration.GetContainingNode<IJsFunctionLike>(); DeclaredElement = declaration.DeclaredElement; }
/// <summary> /// Determines if the value of the supplied expression will always be equal /// to another expression, and if so returns the other expression. /// Otherwise returns null. /// </summary> /// <param name="expr"></param> /// <returns></returns> private IExpression GetCopyExpr(IExpression expr) { IVariableDeclaration ivd = Recognizer.GetVariableDeclaration(expr); if (ivd == null) { return(null); } CopyOfAttribute coa = context.InputAttributes.Get <CopyOfAttribute>(ivd); if (coa == null) { return(null); } if (expressions.Contains(expr)) { Error("Copy cycle detected, starting from " + expr); return(null); } IExpression newExpr = coa.Replace(context, expr); if (newExpr != null) { expressions.Add(expr); newExpr = DoConvertExpression(newExpr); expressions.Remove(expr); } return(newExpr); }
private void SetLoopPriorities(DependencyGraph g) { var ssinfo = SchedulingTransform.GetSerialSchedulingInfo(g); var infos = ssinfo.loopInfos; var loopVarCount = analysis.loopVarCount; // sort infos by decreasing number of nodes infos.Sort((info1, info2) => Comparer <int> .Default.Compare(loopVarCount[info2.loopVar], loopVarCount[info1.loopVar])); // attach loop ordering information for LoopMergingTransform List <IVariableDeclaration> loopVars = new List <IVariableDeclaration>(loopVarCount.Keys); if (loopVars.Count > 0) { int maxCount = loopVarCount.Values.Max() + 1; // ensure Sequential loops have highest priority foreach (var info in infos) { loopVarCount[info.loopVar] += maxCount; } // sort loopVars by decreasing number of nodes loopVars.Sort((loopVar1, loopVar2) => Comparer <int> .Default.Compare(loopVarCount[loopVar2], loopVarCount[loopVar1])); for (int i = 0; i < loopVars.Count; i++) { IVariableDeclaration loopVar = loopVars[i]; context.OutputAttributes.Set(loopVar, new LoopPriority() { Priority = 1 + loopVars.Count - i }); } } }
private bool HasOffsetToContainer(IStatement container, int stmtIndex) { if (loopMergingInfo != null && container is IForStatement && stmtIndex >= 0) { IForStatement ifs = (IForStatement)container; Set <int> stmts = stmtsOfContainer[container]; IVariableDeclaration loopVar = Recognizer.LoopVariable(ifs); foreach (int edge in loopMergingInfo.graph.EdgesInto(stmtIndex)) { int source = loopMergingInfo.graph.SourceOf(edge); IOffsetInfo offsetInfo = loopMergingInfo.offsetInfos[edge]; if ((source == stmtIndex || stmts.Contains(source)) && offsetInfo != null && offsetInfo.ContainsKey(loopVar)) { return(true); } } foreach (int edge in loopMergingInfo.graph.EdgesOutOf(stmtIndex)) { int target = loopMergingInfo.graph.TargetOf(edge); IOffsetInfo offsetInfo = loopMergingInfo.offsetInfos[edge]; if ((target == stmtIndex || stmts.Contains(target)) && offsetInfo != null && offsetInfo.ContainsKey(loopVar)) { return(true); } } } return(false); }
public override void VisitVariableDeclaration(IVariableDeclaration operation) { LogSymbol(operation.Variable, header: nameof(IVariableDeclaration)); LogCommonPropertiesAndNewLine(operation); Visit(operation.InitialValue, "Initializer"); }
/// <summary> /// Converts a variable reference. /// </summary> /// <param name="ivre"></param> /// <returns></returns> protected override IExpression ConvertVariableRefExpr(IVariableReferenceExpression ivre) { if (Recognizer.IsBeingMutated(context, ivre)) { return(ivre); } else if (Recognizer.IsBeingIndexed(context)) { return(ivre); } IVariableDeclaration ivd = Recognizer.GetVariableDeclaration(ivre); if (ivd == null) { return(ivre); } VariableToChannelInformation vtci; if (usesOfVariable.TryGetValue(ivd, out vtci)) { if (vtci.usageDepth != 0) { Error("wrong usageDepth (" + vtci.usageDepth + " instead of 0)"); } return(Builder.ArrayIndex(Builder.VarRefExpr(vtci.usesDecl), Builder.LiteralExpr(GetUseNumber(ivd, vtci)))); } return(ivre); }
private RDomCatchStatement(IVariableDeclaration variable = null, IExpression condition = null) : this((SyntaxNode)null, null, null) { _variable = variable; _condition = condition; }
protected override IExpression ConvertAssign(IAssignExpression iae) { // for(i) array[i] = rhs // becomes: // temp = CopyStorage(array) // for(i) temp[i] = rhs // for(i) array[i] = SetTo(temp[i]) IVariableDeclaration ivd = Recognizer.GetVariableDeclaration(iae.Target); string name = VariableInformation.GenerateName(context, ivd.Name + "_new"); IVariableDeclaration clone = Builder.VarDecl(name, ivd.VariableType); var cloneDeclExpr = Builder.VarDeclExpr(clone); var newTarget = Builder.ReplaceExpression(iae.Target, Builder.VarRefExpr(ivd), Builder.VarRefExpr(clone)); IExpression copyStorage = Builder.StaticGenericMethod( new Func <PlaceHolder, PlaceHolder>(ArrayHelper.CopyStorage), new[] { ivd.VariableType }, Builder.VarRefExpr(ivd)); var cloneDeclStmt = Builder.AssignStmt(cloneDeclExpr, copyStorage); context.OutputAttributes.Set(cloneDeclStmt, new Initializer()); cloneDecls.Add(cloneDeclStmt); IExpression setTo = Builder.StaticGenericMethod( new Func <PlaceHolder, PlaceHolder, PlaceHolder>(ArrayHelper.SetTo), new[] { iae.GetExpressionType() }, iae.Target, newTarget); IStatement setToStmt = Builder.AssignStmt(iae.Target, setTo); setToStmt = Containers.WrapWithContainers(setToStmt, containers); cloneUpdates.Add(setToStmt); return(Builder.AssignExpr(newTarget, iae.Expression)); }
public override ITypeDeclaration Transform(ITypeDeclaration itd) { analysis = new ChannelAnalysisTransform(); analysis.Context.InputAttributes = context.InputAttributes; analysis.Transform(itd); context.Results = analysis.Context.Results; var itdOut = base.Transform(itd); if (context.trackTransform && debug) { IBlockStatement block = Builder.BlockStmt(); foreach (var entry in analysis.usageInfo) { IVariableDeclaration ivd = entry.Key; var info = entry.Value; block.Statements.Add(Builder.CommentStmt(info.ToString())); } context.OutputAttributes.Add(itdOut, new DebugInfo() { Transform = this, Name = "analysis", Value = block }); } return(itdOut); }
public static IVariableDeclaration GenerateLoopVar(BasicTransformContext context, string prefix) { IVariableDeclaration ivd = Builder.VarDecl(GenerateName(context, prefix), typeof(int)); //VariableInformation.GetVariableInformation(context, ivd); return(ivd); }
protected override IExpression ConvertVariableRefExpr(IVariableReferenceExpression ivre) { foreach (ConditionBinding binding in iterationContext) { if (binding.lhs.Equals(ivre)) { return(binding.rhs); } } IVariableDeclaration ivd = Recognizer.GetVariableDeclaration(ivre); UnrolledVar v; if (unrolledVars.TryGetValue(ivd, out v)) { Set <ConditionBinding> bindings = new Set <ConditionBinding>(); foreach (ConditionBinding binding in iterationContext) { if (v.loopVars.Contains(binding.lhs)) { bindings.Add(binding); } } if (!v.clones.ContainsKey(bindings)) { Error(ivre + " not defined in context " + bindings); return(ivre); } IVariableDeclaration clone = v.clones[bindings]; return(Builder.VarRefExpr(clone)); } return(ivre); }
private void CreateReducedVariableInformation(IVariableDeclaration ivd, HoistingInfo info) { int arrayDepth = info.maxDepthWhereDimensionCouldMatter.Length; var varInfo = VariableInformation.GetVariableInformation(context, ivd); var reducedVarInfo = VariableInformation.GetVariableInformation(context, info.newVariable); for (int bracket = 0; bracket < varInfo.sizes.Count; bracket++) { List <IExpression> newSizes = new List <IExpression>(); List <IVariableDeclaration> newIndexVars = new List <IVariableDeclaration>(); for (int dim = 0; dim < varInfo.sizes[bracket].Length; dim++) { if (info.maxDepthWhereDimensionCouldMatter[bracket][dim] == arrayDepth) { newSizes.Add(varInfo.sizes[bracket][dim]); if (varInfo.indexVars.Count > bracket && varInfo.indexVars[bracket].Length > dim) { newIndexVars.Add(varInfo.indexVars[bracket][dim]); } } } if (newSizes.Count > 0) { reducedVarInfo.sizes.Add(newSizes.ToArray()); reducedVarInfo.indexVars.Add(newIndexVars.ToArray()); } } }
/// <summary> /// Register a use of a variable at a specific indexing depth /// </summary> /// <param name="iaie"></param> /// <returns></returns> protected override IExpression ConvertArrayIndexer(IArrayIndexerExpression iaie) { IExpression expr = (IArrayIndexerExpression)base.ConvertArrayIndexer(iaie); // Only register the full indexer expression, not its sub-expressions if (Recognizer.IsBeingIndexed(context) || Recognizer.IsBeingMutated(context, expr)) { return(expr); } List <IList <IExpression> > indices = Recognizer.GetIndices(expr, out IExpression target); if (target is IVariableReferenceExpression) { IVariableDeclaration ivd = Recognizer.GetVariableDeclaration(target); if (ivd != null) { if (usageInfo.TryGetValue(ivd, out UsageInfo info)) { info.indexingDepths.Add(indices.Count); RegisterUse(info, expr); } } } return(expr); }
protected override IStatement ConvertFor(IForStatement ifs) { var loopSize = Recognizer.LoopSizeExpression(ifs); if (!((loopSize is IVariableReferenceExpression) || (loopSize is IArrayIndexerExpression) || (loopSize is IArgumentReferenceExpression) || (loopSize is ILiteralExpression) || (loopSize is IPropertyReferenceExpression))) { Error("Invalid expression type for the size of a loop (" + loopSize.GetType().Name + "): " + loopSize); return(ifs); } if (loopSize is ILiteralExpression) { // remove loops that execute for 0 iterations int loopSizeAsInt = (int)((ILiteralExpression)loopSize).Value; if (loopSizeAsInt == 0) { return(null); } } Containers c = Containers.GetContainersNeededForExpression(context, loopSize); c.Add(ifs); IVariableDeclaration loopVar = Recognizer.LoopVariable(ifs); context.InputAttributes.Remove <Containers>(loopVar); context.InputAttributes.Set(loopVar, c); return(base.ConvertFor(ifs)); }
public void Eat(ISnapshot snapshot, IVariableDeclaration variableDeclaration) { if (variableDeclaration == null) throw new ArgumentNullException("variableDeclaration"); GetEater(variableDeclaration).Eat(snapshot, variableDeclaration); }
private void SearchRangeAttributes(Range range) { IVariableDeclaration ivd = range.GetIndexDeclaration(); foreach (ICompilerAttribute attr in range.GetAttributes <ICompilerAttribute>()) { if (attr is ParallelSchedule ps) { toSearch.Push(ps.scheduleExpression); var attr2 = new ParallelScheduleExpression(ps.scheduleExpression.GetExpression()); Attributes.Set(ivd, attr2); } else if (attr is DistributedSchedule ds) { toSearch.Push(ds.commExpression); if (ds.scheduleExpression != null) { toSearch.Push(ds.scheduleExpression); } if (ds.schedulePerThreadExpression != null) { toSearch.Push(ds.schedulePerThreadExpression); } var attr2 = new DistributedScheduleExpression(ds.commExpression.GetExpression(), ds.scheduleExpression?.GetExpression(), ds.schedulePerThreadExpression?.GetExpression()); Attributes.Set(ivd, attr2); } else { Attributes.Set(ivd, attr); } } }
public void Eat([NotNull] ISnapshot snapshot, [NotNull] IVariableDeclaration variableDeclaration) { if (snapshot == null) { throw new ArgumentNullException("snapshot"); } if (variableDeclaration == null) { throw new ArgumentNullException("variableDeclaration"); } try { if (variableDeclaration is T) { Eat(snapshot, (T)variableDeclaration); } else { throw new UnexpectedTypeOfNodeToEatException(typeof(T), this, variableDeclaration); } } catch (ApplicationException) { throw; } catch (Exception ex) { throw new EatingException("Unexpected exception", ex, this, variableDeclaration); } }
private static void ForEachMatchingLoopVariable( List <IStatement> containersOfSource, List <IStatement> containersOfTarget, Action <IVariableDeclaration, IForStatement, IForStatement> action) { for (int i = 0; i < System.Math.Min(containersOfTarget.Count, containersOfSource.Count); i++) { if (containersOfTarget[i] is IForStatement) { if (!(containersOfSource[i] is IForStatement)) { break; } IForStatement afs = (IForStatement)containersOfTarget[i]; IForStatement bfs = (IForStatement)containersOfSource[i]; IVariableDeclaration loopVar = Recognizer.LoopVariable(afs); if (Recognizer.LoopVariable(bfs) != loopVar) { break; } // both loops use the same variable. action(loopVar, afs, bfs); } else if (!Containers.ContainersAreEqual(containersOfTarget[i], containersOfSource[i])) { break; } } }
public VariableInfo(IVariableDeclaration declaration) { Node = declaration; IsWriteUsage = true; FunctionLike = declaration.GetContainingNode <IJsFunctionLike>(); DeclaredElement = declaration.DeclaredElement; }
private static void SaveInvocationData(ControlFlowElementData data, IVariableDeclaration variable, byte position, string name, int offset, IPsiSourceFile sourceFile) { data[variable] = VariableDisposeStatus.DependsOnInvocation; var invokedExpression = new InvokedExpressionData(name, offset, position, sourceFile); data.InvokedExpressions.Add(variable, invokedExpression); }
private void HighlightNameNodes(IVariableDeclaration variableDeclaration, IHighlightingConsumer context, string highlightingAttributeId) { foreach (var name in variableDeclaration.NameNodes) { context.AddHighlighting(new CgHighlighting(highlightingAttributeId, name.GetDocumentRange())); } }
/// <summary> /// Lookups for a variable definition. If variable exists returns TRUE and the variable, otherwise FALSE. /// </summary> /// <param name="name"></param> /// <param name="variable"></param> /// <returns></returns> public bool TryGetVariable(string name, out IVariableDeclaration variable) { name = ScopeExtensions.NormalizeVariableName(name); return(thisMembers.TryGetValue(name, out variable) || variables.TryGetValue(name, out variable) || (Parent != null && Parent.TryGetVariable(name, out variable))); }
/// <summary> /// Split expr into a target and extra indices, where target will be replicated and extra indices will be added later. /// </summary> /// <param name="loop">The loop we are replicating over</param> /// <param name="expr">Expression being replicated</param> /// <param name="indices">Modified to contain the extra indices</param> /// <param name="target">Prefix of expr to replicate</param> protected void AddUnreplicatedIndices(IForStatement loop, IExpression expr, List<IEnumerable<IExpression>> indices, out IExpression target) { if (expr is IArrayIndexerExpression iaie) { AddUnreplicatedIndices(loop, iaie.Target, indices, out target); if (indices.Count == 0) { // determine if iaie.Indices can be replicated bool canReplicate = true; foreach (IExpression index in iaie.Indices) { if (NeedsContainer(loop, index)) { canReplicate = false; break; } } IVariableDeclaration loopVar = Recognizer.LoopVariable(loop); bool isPartitioned = context.InputAttributes.Has<Partitioned>(loopVar); if (isPartitioned && !AnyPartitionedExpr(iaie.Indices)) canReplicate = false; if (canReplicate) { target = expr; return; } // fall through } indices.Add(iaie.Indices); } else target = expr; }
protected override IExpression ConvertArrayIndexer(IArrayIndexerExpression iaie) { var indices = Recognizer.GetIndices(iaie, out IExpression target); if (target is IVariableReferenceExpression) { // Only convert indices that could matter. IVariableDeclaration ivd = Recognizer.GetVariableDeclaration(target); HoistingInfo info = GetOrCreateHoistingInfo(ivd); int indexingDepth = indices.Count; for (int bracket = 0; bracket < indexingDepth; bracket++) { for (int dim = 0; dim < indices[bracket].Count; dim++) { if (info.maxDepthWhereDimensionCouldMatter.Length <= bracket || info.maxDepthWhereDimensionCouldMatter[bracket][dim] >= indexingDepth) { ConvertExpression(indices[bracket][dim]); } } } return(iaie); } else { return(base.ConvertArrayIndexer(iaie)); } }
/// <summary> /// Adds the expression and any dependent expressions to the supplied list of contained expressions. /// </summary> /// <param name="containedExpressions"></param> /// <param name="expr"></param> /// <param name="context"></param> private static void AddToContainedExpressions(List <IExpression> containedExpressions, IExpression expr, BasicTransformContext context) { containedExpressions.Add(expr); IVariableDeclaration baseVar = Recognizer.GetVariableDeclaration(expr); if (expr is IArrayIndexerExpression iaie) { foreach (var ind in iaie.Indices) { AddToContainedExpressions(containedExpressions, ind, context); } } if (baseVar == null) { return; } Containers containers = context.InputAttributes.Get <Containers>(baseVar); if (containers == null) { throw new Exception("Containers not found for: " + baseVar); } foreach (IStatement container in containers.inputs) { if (container is IForStatement ifs) { containedExpressions.Add(Builder.VarRefExpr(Recognizer.LoopVariable(ifs))); } } }
private IExpression GetMessageExpression(IExpression expr, IDictionary <IVariableDeclaration, IVariableDeclaration> msgVars) { if (expr is IVariableReferenceExpression) { IVariableReferenceExpression ivre = (IVariableReferenceExpression)expr; IVariableDeclaration ivd = ivre.Variable.Resolve(); IVariableDeclaration msgVar; if (msgVars.TryGetValue(ivd, out msgVar)) { return(Builder.VarRefExpr(msgVar)); } else { return(null); } } else if (expr is IArrayIndexerExpression) { IArrayIndexerExpression iaie = (IArrayIndexerExpression)expr; IExpression targetMsg = GetMessageExpression(iaie.Target, msgVars); if (targetMsg == null) { return(null); } else { return(Builder.ArrayIndex(targetMsg, iaie.Indices)); } } else { throw new ArgumentException("Unrecognized method argument expression"); } }
private bool IsProhibited(int edge, IVariableDeclaration loopVar, bool isForwardLoop, bool isForwardEdge) { ICollection <IVariableDeclaration> prohibited = prohibitedLoopVars[edge]; if (prohibited != null && prohibited.Contains(loopVar)) { return(true); } IOffsetInfo offsetInfo = offsetInfos[edge]; if (offsetInfo != null) { foreach (var entry in offsetInfo) { if (entry.loopVar == loopVar) { int offset = entry.offset; if ((offset > 0) && isForwardLoop && isForwardEdge) { return(true); } if ((offset < 0) && !isForwardLoop && isForwardEdge) { return(true); } } } } return(false); }
/// <summary> /// Constructor for variable reference /// </summary> /// <param name="ivd">Variable declaration interface instance</param> /// <returns>new variable reference</returns> public virtual IVariableReference VarRef(IVariableDeclaration ivd) { IVariableReference ivr = new XVariableReference(); ivr.Variable = ivd; return(ivr); }
public override IStatement Visit(IVariableDeclaration stmt, int context) { return(new VariableDeclaration { Reference = _ref.Anonymize(stmt.Reference) }); }
private object AddMarginalStatements(IExpression expr) { object decl = Recognizer.GetDeclaration(expr); if (!marginalOfVariable.ContainsKey(decl)) { VariableInformation vi = VariableInformation.GetVariableInformation(context, decl); vi.DefineAllIndexVars(context); IList <IStatement> stmts = Builder.StmtCollection(); CreateMarginalChannel(decl, vi, stmts); CreateUseChannel(decl, vi, stmts); IVariableDeclaration useDecl = useOfVariable[decl]; useOfVariable.Remove(decl); IExpression useExpr = Builder.VarRefExpr(useDecl); IVariableDeclaration marginalDecl = marginalOfVariable[decl]; IExpression marginalExpr = Builder.VarRefExpr(marginalDecl); Type[] genArgs = new Type[] { expr.GetExpressionType() }; IAlgorithm algorithm = this.algorithmDefault; Delegate d = algorithm.GetVariableFactor(true, false); IExpression variableFactorExpr = Builder.StaticGenericMethod(d, genArgs, expr, marginalExpr); //IExpression variableFactorExpr = Builder.StaticGenericMethod(new Func<PlaceHolder, PlaceHolder>(Factor.Copy), genArgs, expr); context.OutputAttributes.Set(variableFactorExpr, new IsVariableFactor()); var assignStmt = Builder.AssignStmt(useExpr, variableFactorExpr); stmts.Add(assignStmt); context.AddStatementsBeforeCurrent(stmts); } return(decl); }
private bool CanBeConvertToStringEmpty(IStringLiteral literal) { IFieldDeclaration field = literal.Enclosing <IFieldDeclaration>(); if (field.Exists && field.Modifiers.Modifiers.IsConst()) { return(false); } IVariableDeclaration variable = literal.Enclosing <IVariableDeclaration>(); if (variable.Exists && variable.IsConst) { return(false); } IAttribute attributes = literal.Enclosing <IAttribute>(); if (attributes.Exists) { return(false); } return(true); }
/// <summary> /// Remove loops (and their dependent containers) that are not needed to evaluate the expression. /// </summary> /// <param name="containers"></param> /// <param name="context"></param> /// <param name="needed"></param> /// <returns></returns> internal static Containers RemoveUnusedLoops(Containers containers, BasicTransformContext context, Containers needed) { Containers result = new Containers(); Set <IVariableDeclaration> allowedVars = Containers.GetConditionedLoopVariables(context); allowedVars.Clear(); // for ReplicateWithConditionedIndexTest for (int i = 0; i < containers.inputs.Count; i++) { IStatement container = containers.inputs[i]; if (container is IForStatement) { IForStatement ifs = container as IForStatement; IVariableDeclaration loopVar = Recognizer.LoopVariable(ifs); if (!allowedVars.Contains(loopVar) && !needed.Contains(container)) { continue; } } result.inputs.Add(container); result.outputs.Add(containers.outputs[i]); } // Removing unused loops may have left us with containers that refer to the removed loop index. We must remove these also. // Note this routine could be merged with RemoveUnusedLoops. result = Containers.RemoveInvalidConditions(result, context); return(result); }
protected override IExpression ConvertVariableDeclExpr(IVariableDeclarationExpression ivde) { context.InputAttributes.Remove <Containers>(ivde.Variable); context.InputAttributes.Set(ivde.Variable, new Containers(context)); IVariableDeclaration ivd = ivde.Variable; if (!CodeRecognizer.IsStochastic(context, ivd)) { ProcessConstant(ivd); if (!context.InputAttributes.Has <DescriptionAttribute>(ivd)) { context.OutputAttributes.Set(ivd, new DescriptionAttribute("The constant '" + ivd.Name + "'")); } return(ivde); } VariableInformation vi = VariableInformation.GetVariableInformation(context, ivd); // Ensure the marginal prototype is set. MarginalPrototype mpa = Context.InputAttributes.Get <MarginalPrototype>(ivd); try { vi.SetMarginalPrototypeFromAttribute(mpa); } catch (ArgumentException ex) { Error(ex.Message); } return(ivde); }
// Добавляет или возвращают данные о статусе по имени переменной // Если элемент с нужным индексом не сущ., возвращается null public VariableDisposeStatus? this[IVariableDeclaration index] { set { if (value != null) _status[index] = value.Value; } get { if (index == null) return null; VariableDisposeStatus data; if (_status.TryGetValue(index, out data)) return data; return null; } }
public static bool CheckOnDisposeInvocation(IInvocationExpression invocationExpression, ControlFlowElementData data, bool isInvocationOnDisposableThis, IVariableDeclaration qualifierDisposableVariableDeclaration) { if (isInvocationOnDisposableThis) { if (IsSimpleDisposeInvocation(invocationExpression) || IsCloseInvocation(invocationExpression)) { data.ThisStatus = VariableDisposeStatus.Disposed; return true; } } else { if (qualifierDisposableVariableDeclaration != null && (IsSimpleDisposeInvocation(invocationExpression) || IsCloseInvocation(invocationExpression))) { data[qualifierDisposableVariableDeclaration] = VariableDisposeStatus.Disposed; return true; } } return false; }
/// <summary> /// Swap variable declaration to built in type. /// </summary> /// <param name="variableDeclaration"> /// The variable declaration. /// </param> private static void SwapVariableDeclarationToBuiltInType(IVariableDeclaration variableDeclaration) { if (variableDeclaration is ILocalVariableDeclaration) { ProcessLocalVariableDeclaration((ILocalVariableDeclaration)variableDeclaration); } else if (variableDeclaration is IForeachVariableDeclaration) { ProcessForeachVariableDeclaration((IForeachVariableDeclaration)variableDeclaration); } else { IDeclaredElement declaredElement = variableDeclaration.DeclaredElement; ITypeOwner typeOwner = (ITypeOwner)declaredElement; if (typeOwner != null) { using (WriteLockCookie.Create(true)) { variableDeclaration.SetType(typeOwner.Type); } } } }
private IVariableDeclarationEater GetEater(IVariableDeclaration variableDeclaration) { var eater = _container.GetInstance<IEnumerable<IVariableDeclarationEater>>() .SingleOrDefault(t => t.VariableDecalrationType.IsInstanceOfType(variableDeclaration)); if (eater == null) { return new StubVariableDeclarationEater(); } return eater; }
internal RDomVariableDeclaration(IVariableDeclaration oldRDom) : base(oldRDom) { }
// var $AnimateProvider = [ '$provide', function($provide) { ... private void ProcessProviderFunctionDeclaration(IVariableDeclaration variableDeclaration) { var providerFunctionName = variableDeclaration.NameNode.GetDeclaredName(); if (string.IsNullOrEmpty(providerFunctionName)) return; var factoryFunction = GetFactoryFunction(variableDeclaration.Value); if (factoryFunction == null) return; ProcessProviderFunctionDeclaration(providerFunctionName, factoryFunction); AssociateToProviderFunction(providerFunctionName, factoryFunction); }
private void FixSpacingAroundKeywordVarDec(IVariableDeclaration item) { List<string> keywordSearch = new List<string> { "new" }; foreach (var key in keywordSearch) { item.Text = this.whiteSpaceHelper.RemoveWhiteSpaceAroundKeyword(item.Text, key); } }
public virtual void VisitVariableDeclaration(IVariableDeclaration operation) { DefaultVisit(operation); }
public virtual void VisitVariableDeclaration(IVariableDeclaration value) { this.VisitType(value.VariableType); }
//------------------------------------------- // this writes one line of variable declaration and sets the hasvar flag to true // if it was false, put out the "var" definition line private void WriteVariableListEntry(IVariableDeclaration variable, IFormatter formatter, ref bool hasvar) { if (variable != null) this.WriteVariableDeclaration(variable, formatter); }
public void Add(IVariableDeclaration variableDeclaration) { SnapNodes.Add(new SnapNode(variableDeclaration)); }
private void WriteVariableDeclaration(IVariableDeclaration variableDeclaration, IFormatter formatter) { formatter.WriteKeyword("var "); this.WriteDeclaration(variableDeclaration.Name, formatter); // TODO Escape = true if (!this.forLoop) { formatter.Write(";"); formatter.WriteLine(); } }
public VariableNotFoundInSnapshotException(IVariableDeclaration localVariable, Snapshot snapshot) : base("Variable is not found in snapshot") { LocalVariable = localVariable; Snapshot = snapshot; }
public void Eat(ISnapshot snapshot, IVariableDeclaration variableDeclaration) { }
public override void VisitVariableDeclaration(IVariableDeclaration operation) { var variable = operation.Variable; base.VisitVariableDeclaration(operation); }
public void Except(IVariableDeclaration variableDeclaration) { var variable = SnapNodes.SingleOrDefault(t => t.Node == variableDeclaration); if (variable == null) throw new VariableNotFoundInSnapshotException(variableDeclaration, this); variable.ExceptInitialOccurence(); }
public virtual IVariableDeclarationCollection TransformVariableDeclarationCollection(IVariableDeclarationCollection value) { IVariableDeclaration[] array = new IVariableDeclaration[value.Count]; for (int i = 0; i < value.Count; i++) { array[i] = this.TransformVariableDeclaration(value[i]); } IVariableDeclarationCollection target = new VariableDeclarationCollection(); target.AddRange(array); return target; }
private static bool CheckVariableDecl(IVariableDeclaration o, IVariableDeclaration n) { if (o.Name != n.Name || o.Pinned != n.Pinned || o.VariableType.ToString() != n.VariableType.ToString() //||!CheckVariableDecl(o.Variable, n.Variable) ) { return false; } return true; }
public virtual IVariableDeclaration TransformVariableDeclaration(IVariableDeclaration value) { return value; }
public void Add(ExpressionKind expressionKind, IVariableDeclaration declaration) { AddAny(expressionKind, declaration); }