private void VisitNodeInternalUp(JSNode node, IEnumerable <SequencePoint> sequencePoints) { if (node == null) { return; } if (sequencePoints != null && node.SymbolInfo == null) { node.SymbolInfo = new SymbolInfo(sequencePoints, true); } foreach (var child in node.Children) { if (child == null) { continue; } if (child.SymbolInfo != null) { sequencePoints = child.SymbolInfo.SequencePoints; } VisitNodeInternalUp(child, sequencePoints); } }
protected void VisitControlFlowNode(JSNode node) { var stackSlice = Stack.Take(3).ToArray(); var parentEs = stackSlice[1] as JSExpressionStatement; var parentBlock = stackSlice[2] as JSBlockStatement; if ((parentEs != null) && (parentBlock == BlockStack.Peek())) { AbsoluteJumpsSeen += 1; if (AbsoluteJumpsSeen > 1) { if (TraceLevel >= 1) { Console.WriteLine("// Eliminating {0}", node); } var replacement = new JSNullExpression(); ParentNode.ReplaceChild(node, replacement); MadeChanges = true; return; } else { if (TraceLevel >= 4) { Console.WriteLine("// Not eliminating {0}", node); } } } VisitChildren(node); }
public JSModel DoAnalysis() { var lowerSupportNode = new JSNode(new Vector2d(0, 0)) { XRestrained = true, YRestrained = true }; var upperSupportNode = new JSNode(new Vector2d(0, 10)) { XRestrained = true, YRestrained = true }; var forceNode = new JSNode(new Vector2d(5, 5)); var nodes = new JSNode[] { upperSupportNode, forceNode, lowerSupportNode }; var force = new JSPointLoad(new Vector2d(0, -1), forceNode); var forces = new JSPointLoad[] { force }; var lowerBar = new JSBar(lowerSupportNode, forceNode); var upperBar = new JSBar(upperSupportNode, forceNode); var bars = new JSBar[] { upperBar, lowerBar }; var analyser = new JSModel(); analyser.AddItems(bars, nodes, forces); analyser.Solve(); return(analyser); }
protected void EliminateVariable(JSNode context, JSVariable variable, JSExpression replaceWith, QualifiedMemberIdentifier method) { { var replacer = new VariableEliminator( variable, JSChangeTypeExpression.New(replaceWith, variable.GetActualType(TypeSystem), TypeSystem) ); replacer.Visit(context); } { var replacer = new VariableEliminator(variable, replaceWith); var assignments = (from a in FirstPass.Assignments where variable.Equals(a.NewValue) || a.NewValue.SelfAndChildrenRecursive.Any(variable.Equals) select a).ToArray(); foreach (var a in assignments) { if (!variable.Equals(a.NewValue)) { replacer.Visit(a.NewValue); } } } Variables.Remove(variable.Identifier); FunctionSource.InvalidateFirstPass(method); }
public static JSExpression DeconstructMutationAssignment ( JSNode parentNode, JSBinaryOperatorExpression boe, TypeSystem typeSystem, TypeReference intermediateType ) { var assignmentOperator = boe.Operator as JSAssignmentOperator; if (assignmentOperator == null) return null; JSBinaryOperator replacementOperator; if (!IntroduceEnumCasts.ReverseCompoundAssignments.TryGetValue(assignmentOperator, out replacementOperator)) return null; var leftType = boe.Left.GetActualType(typeSystem); var newBoe = new JSBinaryOperatorExpression( JSOperator.Assignment, MakeLhsForAssignment(boe.Left), new JSBinaryOperatorExpression( replacementOperator, boe.Left, boe.Right, intermediateType ), leftType ); var result = ConvertReadExpressionToWriteExpression(newBoe, typeSystem); if (parentNode is JSExpressionStatement) { return result; } else { var comma = new JSCommaExpression( newBoe, boe.Left ); return comma; } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { var point = new Point3d(); //Input types. Declare that JointSolver2D.Vector2d<=>Rhino.Geometry.Vector3d is a substituted with Point if (!DA.GetData(0, ref point)) { return; } var point2d = new Vector2d(point.X, point.Y); //Convert ot Joint2d type bool xRestr = false; if (!DA.GetData(1, ref xRestr)) { return; } bool yRestr = false; if (!DA.GetData(2, ref yRestr)) { return; } //The actual method! var node = new JSNode(point2d, xRestr, yRestr); var nodeGoo = new JSNode_Goo() { Value = node }; DA.SetData(0, nodeGoo); }
protected void EliminateVariable (JSNode context, JSVariable variable, JSExpression replaceWith, QualifiedMemberIdentifier method) { { var replacer = new VariableEliminator( variable, JSChangeTypeExpression.New(replaceWith, variable.GetActualType(TypeSystem), TypeSystem) ); replacer.Visit(context); } { var replacer = new VariableEliminator(variable, replaceWith); var assignments = (from a in FirstPass.Assignments where variable.Equals(a.NewValue) || a.NewValue.SelfAndChildrenRecursive.Any(variable.Equals) select a).ToArray(); foreach (var a in assignments) { if (!variable.Equals(a.NewValue)) replacer.Visit(a.NewValue); } } Variables.Remove(variable.Identifier); FunctionSource.InvalidateFirstPass(method); }
public override JSNodeTraversalArrayRecordState StartEnumeration(JSNode parent) { return(new JSNodeTraversalArrayRecordState { UserData = parent, Index = 0 }); }
public JSAstCursor(JSNode root, params string[] namesToSkip) { Root = root; NamesToSkip = new HashSet<string>(namesToSkip); Reset(); }
private void VisitNodeInternalUp(JSNode node, IEnumerable<SequencePoint> sequencePoints) { if (node == null) { return; } if (sequencePoints != null && node.SymbolInfo == null) { node.SymbolInfo = new SymbolInfo(sequencePoints, true); } foreach (var child in node.Children) { if (child == null) { continue; } if (child.SymbolInfo != null) { sequencePoints = child.SymbolInfo.SequencePoints; } VisitNodeInternalUp(child, sequencePoints); } }
public State (JSNode node, string name, int depth, int nodeIndex, int? statementIndex) { Node = node; Name = name; Depth = depth; NodeIndex = nodeIndex; StatementIndex = statementIndex; }
/// <summary> /// 指定したパスに基づいてツリー構造を生成します。 /// </summary> /// <param name="root">基点となるノード</param> /// <param name="path">基点となるノードからのパス</param> /// <returns>生成または取得された末端のノード</returns> private static JSNode CreateNodePath(JSNode root, string path) { string nodeName, laterPath; if (string.IsNullOrEmpty(path)) { //パスが無効な場合は基点ノードをそのまま返す return(root); } else if (path.IndexOf('\\') == -1) { //末端のノードである場合 nodeName = path; laterPath = ""; } else { //途中のノードである場合 nodeName = path.Substring(0, path.IndexOf('\\')); laterPath = path.Substring(path.IndexOf('\\') + 1); } //現在のノードを探索する foreach (var node in root.SubNodes) { if (node.Text == nodeName) { if (string.IsNullOrEmpty(laterPath)) { //既存の末端ノード return(node); } else { //既存の中間ノード return(CreateNodePath(node, laterPath)); } } } //見つからなかったら新規作成する var newNode = new JSNode(nodeName); root.SubNodes.Add(newNode); if (string.IsNullOrEmpty(laterPath)) { //新規の末端ノード return(newNode); } else { //新規の中間ノード return(CreateNodePath(newNode, laterPath)); } }
private void SkipNode (JSNode node, string name, Indices indices, int depth) { indices.GetNodeIndex(); if (node is JSStatement) indices.GetStatementIndex(); foreach (var e in VisitChildren(node, indices, depth)) { foreach (var c in e) ; } }
/// <summary> /// このノードをコピーします。 /// </summary> public object Clone() { var newInstance = new JSNode(this.Text) { obj = this.obj //SQObjectは参照をコピーする }; foreach (var subNode in this.SubNodes) { newInstance.SubNodes.Add(subNode.Clone() as JSNode); } return(newInstance); }
public override JSNodeTraversalArrayRecordState StartEnumeration(JSNode parent) { var enumerable = GetField(parent); if (enumerable == null) { return(new JSNodeTraversalArrayRecordState()); } return(new JSNodeTraversalArrayRecordState { UserData = enumerable.GetEnumerator() }); }
public override void ReplaceChild (JSNode oldChild, JSNode newChild) { if (oldChild == null) throw new ArgumentNullException("oldChild"); var stmt = newChild as JSStatement; if (stmt == null) return; for (int i = 0, c = Statements.Count; i < c; i++) { if (Statements[i] == oldChild) Statements[i] = stmt; } }
public static bool IsPropertySetterInvocation(JSNode parentNode, JSBinaryOperatorExpression boe, out JSPropertyAccess pa) { var isValidParent = (parentNode is JSExpressionStatement); pa = boe.Left as JSPropertyAccess; return (pa != null) && pa.IsWrite && (boe.Operator == JSOperator.Assignment) && isValidParent && CanConvertToInvocation(pa); }
/// <summary> /// 内部ノードをフラットにします。 /// </summary> private static List <JSNode> GetFlatJSNodes(JSNode root) { var nodes = new List <JSNode>(); foreach (var subNode in root.SubNodes) { nodes.Add(subNode); if (subNode.SubNodes.Count > 0) { nodes.AddRange(GetFlatJSNodes(subNode)); } } return(nodes); }
public override void VisitNode(JSNode node) { if ((node != null) && !node.IsNull) { Console.Error.WriteLine("Cannot emit {0}", node.GetType().Name); Output.Identifier("JSIL.UntranslatableNode", null); Output.LPar(); Output.Value(node.GetType().Name); Output.RPar(); Output.Semicolon(); } base.VisitNode(node); }
public static IEnumerable <T> GetChildNodes <T> (JSNode root, Func <T, bool> predicate = null) where T : JSNode { foreach (var n in root.AllChildrenRecursive) { var value = n as T; if (value != null) { if ((predicate == null) || predicate(value)) { yield return(value); } } } }
public static bool IsPropertyGetterInvocation(JSNode parentNode, JSPropertyAccess pa) { var parentBoe = parentNode as JSBinaryOperatorExpression; var parentUoe = parentNode as JSUnaryOperatorExpression; bool isMutation = ( (parentUoe != null) && (parentUoe.Operator is JSUnaryMutationOperator) ) || ( (parentBoe != null) && (parentBoe.Operator is JSAssignmentOperator) && (pa == parentBoe.Left) ); return !pa.IsWrite && !isMutation && CanConvertToInvocation(pa); }
/// <summary> /// 指定した相対パスが存在する場合は該当するノードを、存在しない場合はnullを返します。 /// </summary> /// <param name="root">基点となるノード</param> /// <param name="path">基点となるノードからのパス</param> /// <returns>取得された末端のノード</returns> private static JSNode GetExistsNode(JSNode root, string path) { string nodeName, laterPath; if (string.IsNullOrEmpty(path)) { //パスが無効なときは中断 return(null); } else if (path.IndexOf('\\') == -1) { //末端のノードである場合 nodeName = path; laterPath = ""; } else { //途中のノードである場合 nodeName = path.Substring(0, path.IndexOf('\\')); laterPath = path.Substring(path.IndexOf('\\') + 1); } //現在のノードを探索する foreach (var node in root.SubNodes) { if (node.Text == nodeName) { if (string.IsNullOrEmpty(laterPath)) { //既存の末端ノード return(node); } else { //既存の中間ノード return(GetExistsNode(node, laterPath)); } } } //見つからなかった return(null); }
public static JSExpression DeconstructMutationAssignment( JSNode parentNode, JSBinaryOperatorExpression boe, TypeSystem typeSystem, TypeReference intermediateType ) { var assignmentOperator = boe.Operator as JSAssignmentOperator; if (assignmentOperator == null) { return(null); } JSBinaryOperator replacementOperator; if (!IntroduceEnumCasts.ReverseCompoundAssignments.TryGetValue(assignmentOperator, out replacementOperator)) { return(null); } var leftType = boe.Left.GetActualType(typeSystem); var newBoe = new JSBinaryOperatorExpression( JSOperator.Assignment, MakeLhsForAssignment(boe.Left), new JSBinaryOperatorExpression( replacementOperator, boe.Left, boe.Right, intermediateType ), leftType ); var result = ConvertReadExpressionToWriteExpression(newBoe, typeSystem); if (parentNode is JSExpressionStatement) { return(result); } else { var comma = new JSCommaExpression( newBoe, boe.Left ); return(comma); } }
public override void VisitNode(JSNode node) { if (node == null) { return; } if (node.SymbolInfo != null /* && node.SymbolInfo.Inferred*/) { if ((ParentNode is JSForLoop && ((JSForLoop)ParentNode).Condition == node)) { } else { node.SymbolInfo = null; } } VisitChildren(node); }
public override void VisitNode(JSNode node) { if (node == null) { return; } if (node.SymbolInfo != null /* && node.SymbolInfo.Inferred*/) { if ((ParentNode is JSForLoop && ((JSForLoop) ParentNode).Condition == node)) { } else { node.SymbolInfo = null; } } VisitChildren(node); }
private IEnumerable<State> VisitNode (JSNode node, string name = null, Indices indices = null, int depth = 0) { int? statementIndex = null; if (indices == null) indices = new Indices(); int nodeIndex = indices.GetNodeIndex(); if (node is JSStatement) statementIndex = indices.GetStatementIndex(); yield return new State( node, name, depth, nodeIndex, statementIndex ); foreach (var e in VisitChildren(node, indices, depth)) { foreach (var c in e) yield return c; } }
protected IEnumerable <EnclosingNode <T> > GetEnclosingNodes <T> (Func <T, bool> selector = null, Func <JSNode, bool> halter = null) where T : JSNode { JSNode previous = null; string previousName = null; // F**k the C# compiler and its busted enumerator transform // https://connect.microsoft.com/VisualStudio/feedback/details/781746/c-compiler-produces-incorrect-code-for-use-of-enumerator-structs-inside-enumerator-functions using (var eNodes = (IEnumerator <JSNode>)Stack.GetEnumerator()) using (var eNames = (IEnumerator <string>)NameStack.GetEnumerator()) while (eNodes.MoveNext() && eNames.MoveNext()) { iterationStart: var value = eNodes.Current as T; var name = eNames.Current; if (value == null) { previous = eNodes.Current; previousName = name; continue; } if ((selector == null) || selector(value)) { yield return(new EnclosingNode <T> { Node = value, Child = previous, ChildName = previousName }); } if ((halter != null) && halter(value)) { yield break; } previous = eNodes.Current; previousName = name; } }
protected void EliminateVariable(JSNode context, JSVariable variable, JSExpression replaceWith, QualifiedMemberIdentifier method) { { var replacer = new VariableEliminator( variable, JSChangeTypeExpression.New(replaceWith, TypeSystem, variable.GetActualType(TypeSystem)) ); replacer.Visit(context); } { var replacer = new VariableEliminator(variable, replaceWith); var assignments = (from a in FirstPass.Assignments where variable.Equals(a.NewValue) || a.NewValue.SelfAndChildrenRecursive.Any((_n) => variable.Equals(_n)) select a).ToArray(); foreach (var a in assignments) { if (variable.Equals(a.NewValue)) { FirstPass.Assignments.Remove(a); FirstPass.Assignments.Add( new FunctionAnalysis1stPass.Assignment( a.ParentNodeIndices, a.StatementIndex, a.NodeIndex, a.Target, replaceWith, a.Operator, a.TargetType, a.SourceType ) ); } else { replacer.Visit(a.NewValue); } } } Variables.Remove(variable.Identifier); FunctionSource.InvalidateFirstPass(method); }
private void VisitNodeInternalDown(JSNode node) { if (node == null) { return; } foreach (var child in node.Children) { VisitNodeInternalDown(child); } if (node.SymbolInfo == null) { var childSymboInfo = node.Children.Where(item => item != null).Select(item => item.SymbolInfo).FirstOrDefault(item => item != null); if (childSymboInfo != null) { node.SymbolInfo = new SymbolInfo(childSymboInfo.SequencePoints, true); } } }
private void WriteNode(XmlWriter xw, JSNode node, string nodeName, int nodeDepth) { var indent = new string(' ', nodeDepth * 4); if (node.IsNull) { return; } if ( (node is JSBlockStatement) || (node is JSIfStatement) || (node is JSLabelGroupStatement) || (node is JSSwitchStatement) || (node is JSSwitchCase) ) { WriteRow( xw, new StyledCell { StyleID = "code", Value = indent + node.GetType().Name } ); return; } else if (node is JSExpressionStatement) { return; } WriteRow( xw, new StyledCell { StyleID = "code", Value = indent + node.ToString() } ); }
public void Emit(JSNode node) { Visit(node); }
protected void EliminateVariable(JSNode context, JSVariable variable, JSExpression replaceWith) { { var replacer = new VariableEliminator( variable, JSChangeTypeExpression.New(replaceWith, TypeSystem, variable.GetExpectedType(TypeSystem)) ); replacer.Visit(context); } { var replacer = new VariableEliminator(variable, replaceWith); var assignments = (from a in FirstPass.Assignments where variable.Equals(a.NewValue) || a.NewValue.AllChildrenRecursive.Any((_n) => variable.Equals(_n)) select a).ToArray(); foreach (var a in assignments) { if (variable.Equals(a.NewValue)) { FirstPass.Assignments.Remove(a); FirstPass.Assignments.Add( new FunctionAnalysis1stPass.Assignment( a.StatementIndex, a.NodeIndex, a.Target, replaceWith, a.Operator, a.TargetType, a.SourceType ) ); } else { replacer.Visit(a.NewValue); } } } Variables.Remove(variable.Identifier); }
public override void ReplaceChild(JSNode oldChild, JSNode newChild) { if (oldChild == null) throw new ArgumentNullException("oldChild"); var boe = newChild as JSBinaryOperatorExpression; if (boe == null) Declarations.RemoveAll((c) => c == oldChild); else if (boe.Operator != JSOperator.Assignment) throw new InvalidOperationException("A variable declaration statement may only contain assignments"); else for (int i = 0, c = Declarations.Count; i < c; i++) { if (Declarations[i] == oldChild) Declarations[i] = boe; } }
public override void ReplaceChild(JSNode oldChild, JSNode newChild) { if (oldChild == null) throw new ArgumentNullException("oldChild"); if (_Condition == oldChild) _Condition = (JSExpression)newChild; var cse = newChild as JSSwitchCase; if (cse != null) { for (int i = 0, c = Cases.Count; i < c; i++) { if (Cases[i] == oldChild) Cases[i] = cse; } } }
public override void ReplaceChild(JSNode oldChild, JSNode newChild) { return; }
public override void ReplaceChild(JSNode oldChild, JSNode newChild) { if (oldChild == null) throw new ArgumentNullException("oldChild"); var stmt = newChild as JSStatement; if (stmt == null) return; foreach (var kvp in Labels.ToArray()) { if (kvp.Value == oldChild) { if (stmt.Label == kvp.Key) Labels.Replace(kvp.Key, stmt); else if (stmt.Label == null) { stmt.Label = kvp.Key; if (stmt.IsNull) Labels.Remove(kvp.Key); else Labels.Replace(kvp.Key, stmt); } else { Labels.Remove(kvp.Key); if (!stmt.IsNull) { if (Labels.ContainsKey(stmt.Label)) throw new InvalidOperationException("Replacing LabelGroupStatement child '" + oldChild + "' with '" + newChild + "' but group already contains the label '" + stmt.Label + "'"); Add(stmt); } } } } }
public override void ReplaceChild(JSNode oldChild, JSNode newChild) { if (oldChild == null) throw new ArgumentNullException("oldChild"); if (oldChild == _Expression) _Expression = (JSExpression)newChild; }
/// <summary> /// Create a bar between 2 nodes. /// </summary> public JSBar(JSNode startNode, JSNode endNode) { StartVertex = new JSVertex(startNode, this); EndVertex = new JSVertex(endNode, this); }
public override void ReplaceChild(JSNode oldChild, JSNode newChild) { if (GenericArguments == null) return; var oldExpression = oldChild as JSExpression; var newExpression = newChild as JSExpression; if ( (oldExpression != null) && ((newExpression != null) == (newChild != null)) ) { for (var i = 0; i < GenericArguments.Length; i++) { if (GenericArguments[i] == oldExpression) GenericArguments[i] = newExpression; } } }
public override void ReplaceChild(JSNode oldChild, JSNode newChild) { if (newChild == this) throw new InvalidOperationException("Direct cycle formed by replacement"); if (DefaultValue == oldChild) DefaultValue = (JSExpression)newChild; }
private IEnumerable<IEnumerable<State>> VisitChildren(JSNode node, Indices indices, int depth) { if (node == null) throw new ArgumentNullException("node"); JSNode nextSibling = null; string nextSiblingName = null; int nextDepth = depth + 1; using (var e = node.Children.EnumeratorTemplate) while (e.MoveNext()) { var toVisit = nextSibling; var toVisitName = nextSiblingName; nextSibling = e.Current; nextSiblingName = e.CurrentName; if (toVisit != null) { if (toVisitName == null || !NamesToSkip.Contains(toVisitName)) { yield return VisitNode(toVisit, toVisitName, indices, nextDepth); } else { SkipNode(toVisit, toVisitName, indices, nextDepth); } } } if (nextSibling != null) { if (nextSiblingName == null || !NamesToSkip.Contains(nextSiblingName)) { yield return VisitNode(nextSibling, nextSiblingName, indices, nextDepth); } else { SkipNode(nextSibling, nextSiblingName, indices, nextDepth); } } }
public override void ReplaceChild(JSNode oldChild, JSNode newChild) { if (oldChild == null) throw new ArgumentNullException("oldChild"); var stmt = newChild as JSStatement; if (stmt == null) return; foreach (var kvp in Labels.ToArray()) { if (kvp.Value == oldChild) { if (stmt.Label == kvp.Key) Labels.Replace(kvp.Key, stmt); else { Labels.Remove(kvp.Key); if (!stmt.IsNull) Add(stmt); } } } }
public override void ReplaceChild(JSNode oldChild, JSNode newChild) { if (oldChild == null) throw new ArgumentNullException("oldChild"); var boe = newChild as JSBinaryOperatorExpression; if (boe == null) Declarations.RemoveAll((c) => c == oldChild); else for (int i = 0, c = Declarations.Count; i < c; i++) { if (Declarations[i] == oldChild) Declarations[i] = boe; } }
public void Emit(JSNode node) { }
/// <summary> /// Create a bar between a node and a point positions (unconnected to nodes). /// The unconnected vertex position will be connected to a node when this bar is added to a JointAnalysis model. /// </summary> public JSBar(JSNode startNode, Vector2d endPoint) { StartVertex = new JSVertex(startNode, this); EndVertex = new JSVertex(endPoint, this); }
public override void ReplaceChild(JSNode oldChild, JSNode newChild) { if (oldChild == null) throw new ArgumentNullException("oldChild"); if (_Condition == oldChild) _Condition = (JSExpression)newChild; if (_TrueClause == oldChild) _TrueClause = (JSStatement)newChild; if (_FalseClause == oldChild) _FalseClause = (JSStatement)newChild; }
/// <summary> /// Create a bar between a node and a point positions (unconnected to nodes). /// The unconnected vertex position will be connected to a node when this bar is added to a JointAnalysis model. /// </summary> public JSBar(Vector2d startPoint, JSNode endNode) { StartVertex = new JSVertex(startPoint, this); EndVertex = new JSVertex(endNode, this); }
protected static bool GetChild(JSNode parent, int index, out JSNode node, out string name) { var self = (JSLabelGroupStatement)parent; if (index >= self.Labels.Count) { node = null; name = null; return false; } node = self.Labels.AtIndex(index).Value; name = "Labels"; return true; }
public abstract void Get(JSNode parent, out JSNode node, out string name);
public override void ReplaceChild(JSNode oldChild, JSNode newChild) { if (Values == null) return; var jse = newChild as JSExpression; if (jse != null) { for (var i = 0; i < Values.Length; i++) if (oldChild.Equals(Values[i])) Values[i] = jse; } }
public abstract JSNodeTraversalArrayRecordState StartEnumeration(JSNode parent);
public override void ReplaceChild(JSNode oldChild, JSNode newChild) { if (oldChild == null) throw new ArgumentNullException("oldChild"); if (CatchVariable == oldChild) CatchVariable = (JSVariable)newChild; if (Catch == oldChild) Catch = (JSStatement)newChild; if (Finally == oldChild) Finally = (JSStatement)newChild; Body.ReplaceChild(oldChild, newChild); }
public override void Get(JSNode parent, out JSNode node, out string name) { node = GetField(parent); name = Name; }
public override void ReplaceChild(JSNode oldChild, JSNode newChild) { if (oldChild == null) throw new ArgumentNullException("oldChild"); if (_Condition == oldChild) _Condition = (JSExpression)newChild; if (newChild is JSStatement) base.ReplaceChild(oldChild, newChild); }
protected IEnumerable <JSGotoExpression> FindGotos(JSNode context, string targetLabel) { return(context.AllChildrenRecursive.OfType <JSGotoExpression>() .Where((ge) => ge.TargetLabel == targetLabel)); }
public JSPointLoad(JSPointLoad pointLoad) { Force = pointLoad.Force; Node = pointLoad.Node; }
public JSPointLoad(Vector2d forces, JSNode trussNode) { Force = forces; Node = trussNode; }
/// <summary> /// Create a vertex to a node. /// </summary> public JSVertex(JSNode node, JSBar bar) { Position = node.Position; Node = node; Bar = bar; }
protected void VisitControlFlowNode(JSNode node) { var stackSlice = Stack.Take(3).ToArray(); var parentEs = stackSlice[1] as JSExpressionStatement; var parentBlock = stackSlice[2] as JSBlockStatement; if ((parentEs != null) && (parentBlock == BlockStack.Peek())) { AbsoluteJumpsSeen += 1; if (AbsoluteJumpsSeen > 1) { if (TraceLevel >= 1) Console.WriteLine("// Eliminating {0}", node); var replacement = new JSNullExpression(); ParentNode.ReplaceChild(node, replacement); return; } else { if (TraceLevel >= 3) Console.WriteLine("// Not eliminating {0}", node); } } VisitChildren(node); }