public void Dispose() { VList.Clear(); FList.Clear(); VList = null; FList = null; }
/// <summary> /// Clears all the data contained in this node. It is nessary to /// call this when disposing of the parent network in order to /// avoid cyclical refrences and potential memory leaks. /// </summary> internal void ClearData() { //desposes of the internal data sturctor if (inputs != null) { inputs.Clear(); } //deletes the network to avoid cyclic refrences this.network = null; this.inputs = null; }
// Statements that don't start with an Id and don't allow keyword attributes. LNode OtherStmt(int startIndex, VList<LNode> attrs, bool hasWordAttrs) { TokenType la1; Token lit_semi = default(Token); LNode result = default(LNode); bool addAttrs = false; string showWordAttrErrorFor = null; // Line 1391: ( BracedBlock / &(TT.NotBits (TT.ContextualKeyword|TT.Id|TT.This) TT.LParen TT.RParen TT.LBrace TT.RBrace) Destructor / TT.Semicolon / LabelStmt / default ExprStatement / AssemblyOrModuleAttribute / OperatorCastMethod ) do { switch (LA0) { case TT.LBrace: { result = BracedBlock(null, null, startIndex); // line 1392 showWordAttrErrorFor = "braced-block statement"; addAttrs = true; } break; case TT.NotBits: { if (Try_OtherStmt_Test0(0)) { la1 = LA(1); if (la1 == TT.ContextualKeyword || la1 == TT.Id || la1 == TT.This) { result = Destructor(startIndex, attrs); // line 1395 showWordAttrErrorFor = "destructor"; } else if (OtherStmt_set0.Contains((int) la1)) goto matchExprStatement; else goto error; } else goto matchExprStatement; } break; case TT.Semicolon: { lit_semi = MatchAny(); // line 1396 result = F.Id(S.Missing, startIndex, lit_semi.EndIndex); showWordAttrErrorFor = "empty statement"; addAttrs = true; } break; case TT.ContextualKeyword: { if (Is(0, _await)) { la1 = LA(1); if (la1 == TT.Colon) goto matchLabelStmt; else if (OtherStmt_set1.Contains((int) la1)) goto matchExprStatement; else goto error; } else { la1 = LA(1); if (la1 == TT.Colon) goto matchLabelStmt; else if (OtherStmt_set2.Contains((int) la1)) goto matchExprStatement; else goto error; } } case TT.Id: { la1 = LA(1); if (la1 == TT.Colon) goto matchLabelStmt; else if (OtherStmt_set2.Contains((int) la1)) goto matchExprStatement; else goto error; } case TT.Default: { la1 = LA(1); if (la1 == TT.Colon) goto matchLabelStmt; else if (la1 == TT.LParen) goto matchExprStatement; else goto error; } case TT.Add: case TT.AndBits: case TT.Break: case TT.Continue: case TT.DotDot: case TT.Forward: case TT.Goto: case TT.IncDec: case TT.LParen: case TT.Mul: case TT.Not: case TT.Power: case TT.Return: case TT.Sub: case TT.Substitute: case TT.Switch: case TT.Throw: goto matchExprStatement; case TT.Operator: { la1 = LA(1); switch (la1) { case TT.ContextualKeyword: case TT.Id: case TT.Operator: case TT.TypeKeyword: { result = OperatorCastMethod(startIndex, attrs); // line 1404 attrs.Clear(); } break; default: if (AnyOperator_set0.Contains((int) la1)) goto matchExprStatement; else goto error; } } break; case TT.At: case TT.Base: case TT.Checked: case TT.Delegate: case TT.Dot: case TT.Is: case TT.Literal: case TT.New: case TT.Sizeof: case TT.This: case TT.TypeKeyword: case TT.Typeof: case TT.Unchecked: goto matchExprStatement; case TT.LBrack: { result = AssemblyOrModuleAttribute(startIndex, attrs); // line 1403 showWordAttrErrorFor = "assembly or module attribute"; } break; default: goto error; } break; matchLabelStmt: { result = LabelStmt(startIndex); // line 1399 addAttrs = true; } break; matchExprStatement: { result = ExprStatement(); // line 1401 showWordAttrErrorFor = "expression"; addAttrs = true; } break; error: { // line 1410 result = Error("Statement expected, but got '{0}'", CurrentTokenText()); ScanToEndOfStmt(); } } while (false); // line 1414 if (addAttrs) { result = result.PlusAttrs(attrs); } if (hasWordAttrs && showWordAttrErrorFor != null) { NonKeywordAttrError(attrs, showWordAttrErrorFor); } return result; }
LNode OtherStmt(int startIndex, VList<LNode> attrs, bool hasWordAttrs) { TokenType la1; Token lit_semi = default(Token); LNode result = default(LNode); Token ths = default(Token); bool addAttrs = false; string showWordAttrErrorFor = null; // Line 1455: ( BracedBlock / &(TT.NotBits (TT.ContextualKeyword|TT.Id|TT.This) TT.LParen TT.RParen TT.LBrace TT.RBrace) Destructor / TT.Semicolon / LabelStmt / default ExprStatement / AssemblyOrModuleAttribute / OperatorCastMethod / TT.This &(DataType ComplexNameDecl) MethodOrPropertyOrVar ) do { switch (LA0) { case TT.LBrace: { result = BracedBlock(null, null, startIndex); // line 1456 showWordAttrErrorFor = "braced-block statement"; addAttrs = true; } break; case TT.NotBits: { if (Try_OtherStmt_Test0(0)) { switch (LA(1)) { case TT.ContextualKeyword: case TT.Id: case TT.This: { result = Destructor(startIndex, attrs); // line 1459 showWordAttrErrorFor = "destructor"; } break; case TT.Add: case TT.AndBits: case TT.At: case TT.Base: case TT.Checked: case TT.Default: case TT.Delegate: case TT.Dot: case TT.DotDot: case TT.Forward: case TT.IncDec: case TT.Is: case TT.LBrace: case TT.Literal: case TT.LParen: case TT.Mul: case TT.New: case TT.Not: case TT.NotBits: case TT.Operator: case TT.Power: case TT.Sizeof: case TT.Sub: case TT.Substitute: case TT.TypeKeyword: case TT.Typeof: case TT.Unchecked: goto matchExprStatement; default: goto error; } } else goto matchExprStatement; } break; case TT.Semicolon: { lit_semi = MatchAny(); // line 1460 result = F.Id(S.Missing, startIndex, lit_semi.EndIndex); showWordAttrErrorFor = "empty statement"; addAttrs = true; } break; case TT.ContextualKeyword: { if (Is(0, _await)) { if (!(_insideLinqExpr && LinqKeywords.Contains(LT(0).Value))) { la1 = LA(1); if (la1 == TT.Colon) goto matchLabelStmt; else if (OtherStmt_set0.Contains((int) la1)) goto matchExprStatement; else goto error; } else { la1 = LA(1); if (la1 == TT.Colon) goto matchLabelStmt; else if (PrefixExpr_set0.Contains((int) la1)) goto matchExprStatement; else goto error; } } else if (!(_insideLinqExpr && LinqKeywords.Contains(LT(0).Value))) { la1 = LA(1); if (la1 == TT.Colon) goto matchLabelStmt; else if (OtherStmt_set1.Contains((int) la1)) goto matchExprStatement; else goto error; } else goto matchLabelStmt; } case TT.Id: { la1 = LA(1); if (la1 == TT.Colon) goto matchLabelStmt; else if (OtherStmt_set1.Contains((int) la1)) goto matchExprStatement; else goto error; } case TT.Default: { la1 = LA(1); if (la1 == TT.Colon) goto matchLabelStmt; else if (la1 == TT.LParen) goto matchExprStatement; else goto error; } case TT.Add: case TT.AndBits: case TT.Dot: case TT.DotDot: case TT.Forward: case TT.IncDec: case TT.LParen: case TT.Mul: case TT.Not: case TT.Power: case TT.Sub: case TT.Substitute: goto matchExprStatement; case TT.Operator: { la1 = LA(1); switch (la1) { case TT.ContextualKeyword: case TT.Id: case TT.Operator: case TT.TypeKeyword: { result = OperatorCastMethod(startIndex, attrs); // line 1468 attrs.Clear(); } break; default: if (AnyOperator_set0.Contains((int) la1)) goto matchExprStatement; else goto error; } } break; case TT.This: { la1 = LA(1); switch (la1) { case TT.ContextualKeyword: case TT.Id: case TT.Operator: case TT.Substitute: case TT.TypeKeyword: { ths = MatchAny(); Check(Try_OtherStmt_Test1(0), "DataType ComplexNameDecl"); // line 1471 attrs.Add(F.Id(ths)); result = MethodOrPropertyOrVar(startIndex, attrs); } break; default: if (OtherStmt_set1.Contains((int) la1)) goto matchExprStatement; else goto error; } } break; case TT.At: case TT.Base: case TT.Checked: case TT.Delegate: case TT.Is: case TT.Literal: case TT.New: case TT.Sizeof: case TT.TypeKeyword: case TT.Typeof: case TT.Unchecked: goto matchExprStatement; case TT.LBrack: { result = AssemblyOrModuleAttribute(startIndex, attrs); // line 1467 showWordAttrErrorFor = "assembly or module attribute"; } break; default: goto error; } break; matchLabelStmt: { result = LabelStmt(startIndex); // line 1463 addAttrs = true; } break; matchExprStatement: { result = ExprStatement(); // line 1465 showWordAttrErrorFor = "expression"; addAttrs = true; } break; error: { // line 1474 result = Error("Statement expected, but got '{0}'", CurrentTokenText()); ScanToEndOfStmt(); } } while (false); // line 1478 if (addAttrs) { result = result.PlusAttrs(attrs); } if (hasWordAttrs && showWordAttrErrorFor != null) { NonKeywordAttrError(attrs, showWordAttrErrorFor); } return result; }
public void TestInsertRemove() { VList<int> list = new VList<int>(9); VList<int> list2 = new VList<int>(10, 11); list.Insert(0, 12); list.Insert(1, list2[1]); list.Insert(2, list2[0]); ExpectList(list, 12, 11, 10, 9); for (int i = 0; i < 9; i++) list.Insert(4, i); ExpectList(list, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); list2 = list; for (int i = 1; i <= 6; i++) list2.RemoveAt(i); ExpectList(list2, 12, 10, 8, 6, 4, 2, 0); ExpectList(list, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0); // unchanged Assert.AreEqual(0, list2.Pop()); list2.Insert(5, -2); ExpectList(list2, 12, 10, 8, 6, 4, -2, 2); list2.Insert(5, -1); ExpectList(list2, 12, 10, 8, 6, 4, -1, -2, 2); // Test changing items list = list2; for (int i = 0; i < list.Count; i++) list[i] = i; ExpectList(list, 0, 1, 2, 3, 4, 5, 6, 7); ExpectList(list2, 12, 10, 8, 6, 4, -1, -2, 2); list2.Clear(); ExpectList(list2); Assert.AreEqual(5, list[5]); }