📄 csharpast.cs
字号:
stmt = (Dom.CheckedStmt)((CheckedStmt)tok).GetGraph() ;
else if(tok is UncheckedStmt)
stmt = (Dom.UncheckedStmt)((UncheckedStmt)tok).GetGraph() ;
else if(tok is LockStmt)
stmt = (Dom.LockStmt)((LockStmt)tok).GetGraph() ;
else if(tok is UsingStmt)
stmt = (Dom.UsingStmt)((UsingStmt)tok).GetGraph() ;
else if(tok is TryCatchFinallyStmt)
stmt = (Dom.TryCatchFinallyStmt)((TryCatchFinallyStmt)tok).GetGraph() ;
else if(tok is ThrowStmt)
stmt = (Dom.ThrowStmt)((ThrowStmt)tok).GetGraph() ;
else if(tok is CommentNode)
stmt = (Dom.CommentStmt)((CommentNode)tok).GetGraph() ;
return stmt;
}
}
#endregion
#region LabeledStmt *
public class LabeledStmt : Statement
{
// Label, Statement
public override Dom.IGraph GetGraph()
{
Dom.LabeledStmt graph =
new Dom.LabeledStmt();
return this.GetGraph(graph);
}
public Dom.LabeledStmt
GetGraph(Dom.LabeledStmt graph)
{
//graph.Clear();
base.GetGraph(graph);
AST tok = this.getFirstChild();
while(tok != null)
{
if(tok is Ident)
{
graph.Label = tok.getText();
}
else if(tok is Statement)
graph.Statement = Statement.ParseStatement( ((Statement)tok) );
tok = tok.getNextSibling();
}
return graph;
}
}
#endregion
#region ExprStmt *
public class ExprStmt : Statement
{
// Expression
public override Dom.IGraph GetGraph()
{
Dom.ExprStmt graph =
new Dom.ExprStmt();
return this.GetGraph(graph);
}
public Dom.ExprStmt
GetGraph(Dom.ExprStmt graph)
{
//graph.Clear();
base.GetGraph(graph);
AST tok = this.getFirstChild();
if(tok is Expression)
{
graph.Expression = Expression.Parse(((Expression)tok));
}
AddRootExpression(graph.Expression, graph.GetType(), "Expression");
return graph;
}
}
#endregion
#region VariableDeclStmt *
public class VariableDeclStmt : Statement
{
// Init // Name // Type
public override Dom.IGraph GetGraph()
{
Dom.VariableDeclStmt graph =
new Dom.VariableDeclStmt();
return this.GetGraph(graph);
}
public Dom.VariableDeclStmt
GetGraph(Dom.VariableDeclStmt graph)
{
//graph.Clear();
base.GetGraph(graph);
AST tok = this.getFirstChild();
while(tok != null)
{
if(tok is TypeRef)
{
graph.Type = (Dom.TypeRef)((TypeRef)tok).GetGraph();
}
else if(tok is Declarator)
{
((Declarator)tok).GetGraph(graph.Delcarators);
}
tok = tok.getNextSibling();
}
foreach(Dom.Declarator d in graph.Delcarators)
{
d.Definition.Type = graph.Type;
}
return graph;
}
}
#endregion
#region ConstantDeclStmt *
public class ConstantDeclStmt : Statement
{
// Init // Name // Type
public override Dom.IGraph GetGraph()
{
Dom.ConstantDeclStmt graph =
new Dom.ConstantDeclStmt();
return this.GetGraph(graph);
}
public Dom.ConstantDeclStmt
GetGraph(Dom.ConstantDeclStmt graph)
{
//graph.Clear();
base.GetGraph(graph);
AST tok = this.getFirstChild();
while(tok != null)
{
if(tok is TypeRef)
{
graph.Type = (Dom.TypeRef)((TypeRef)tok).GetGraph();
}
else if(tok is Declarator)
{
((Declarator)tok).GetGraph(graph.Delcarators);
}
tok = tok.getNextSibling();
}
foreach(Dom.Declarator d in graph.Delcarators)
{
d.Definition.Type = graph.Type;
}
return graph;
}
}
#endregion
#region IfStmt *
public class IfStmt : Statement
{
public override Dom.IGraph GetGraph()
{
Dom.IfStmt graph =
new Dom.IfStmt();
return this.GetGraph(graph);
}
public Dom.IfStmt
GetGraph(Dom.IfStmt graph)
{
// Condition, FalseStatements, TrueStatements
//graph.Clear();
base.GetGraph(graph);
AST tok = this.getFirstChild();
while(tok != null)
{
if(tok is Statements)
{
string tf = tok.getText();
if(tf == "true")
{
this.OpenBlockScope();
((Statements)tok).GetGraph(graph.TrueStatements);
this.CloseScope();
}
else if(tf == "false")
{
this.OpenBlockScope();
((Statements)tok).GetGraph(graph.FalseStatements);
this.CloseScope();
}
}
else if(tok is Expression)
{
graph.Condition = Expression.Parse(((Expression)tok));
}
tok = tok.getNextSibling();
}
AddRootExpression(graph.Condition, graph.GetType(), "Condition");
return graph;
}
}
#endregion
#region SwitchStmt *
public class SwitchStmt : Statement
{
public override Dom.IGraph GetGraph()
{
Dom.SwitchStmt graph =
new Dom.SwitchStmt();
return this.GetGraph(graph);
}
public Dom.SwitchStmt
GetGraph(Dom.SwitchStmt graph)
{
// Condition, Cases
//graph.Clear();
base.GetGraph(graph);
AST tok = this.getFirstChild();
while(tok != null)
{
if(tok is SwitchSection)
{
graph.Cases.Add( (Dom.Case)((SwitchSection)tok).GetGraph() );
}
else if(tok is Expression)
{
graph.Condition = Expression.Parse(((Expression)tok));
}
tok = tok.getNextSibling();
}
AddRootExpression(graph.Condition, graph.GetType(), "Condition");
return graph;
}
}
#endregion
#region SwitchSection *
public class SwitchSection : CSharpAST
{
// IsDefault, Condition, Statements
public override Dom.IGraph GetGraph()
{
Dom.Case graph =
new Dom.Case();
return this.GetGraph(graph);
}
public Dom.Case
GetGraph(Dom.Case graph)
{
// Condition, FalseStatements, TrueStatements
base.GetGraph(graph);
this.OpenBlockScope();
AST tok = this.getFirstChild();
while(tok != null)
{
if(tok is Statements)
{
((Statements)tok).GetGraph(graph.Statements);
}
else if(tok is Expression)
{
if(tok.getText() == "default")
graph.IsDefault = true;
else
graph.Condition = Expression.Parse(((Expression)tok));
}
tok = tok.getNextSibling();
}
this.CloseScope();
AddRootExpression(graph.Condition, graph.GetType(), "Condition");
return graph;
}
}
#endregion
#region IterationStmt *
public class IterationStmt : Statement
{
// InitStatement, IncrementStatement, TestExpression, Statements, TestFirst (bool)
public override Dom.IGraph GetGraph()
{
Dom.IterationStmt graph =
new Dom.IterationStmt();
return this.GetGraph(graph);
}
public Dom.IterationStmt
GetGraph(Dom.IterationStmt graph)
{
//graph.Clear();
this.OpenBlockScope();
base.GetGraph(graph);
AST tok = this.getFirstChild();
while(tok != null)
{
if(tok is InitStmt)
{
((Statements)tok).GetGraph(graph.Init);
}
else if(tok is IncStmt)
{
((Statements)tok).GetGraph(graph.Increment);
}
else if(tok is Statements)
{
((Statements)tok).GetGraph(graph.Statements);
}
else if(tok is Expression) // test expr
{
if(tok.getText() == "do")
graph.IterationType = Dom.IterationType.Do;
else if(tok.getText() == "while")
graph.IterationType = Dom.IterationType.While;
else if(tok.getText() == "for")
graph.IterationType = Dom.IterationType.For;
graph.Test = Expression.Parse(((Expression)tok));
}
tok = tok.getNextSibling();
}
this.CloseScope();
AddRootExpression(graph.Test, graph.GetType(), "Test");
return graph;
}
}
#endregion
#region InitStmt *
public class InitStmt : Statements
{
// Holder class for Init Statements in loop
}
#endregion
#region IncStmt *
public class IncStmt : Statements
{
// Holder class for Inc Statements in loop
}
#endregion
#region ForEachStmt *
public class ForEachStmt : Statement
{
// InitStatement, IncrementStatement, TestExpression, Statements, TestFirst (bool)
public override Dom.IGraph GetGraph()
{
Dom.ForEachStmt graph =
new Dom.ForEachStmt();
return this.GetGraph(graph);
}
public Dom.ForEachStmt
GetGraph(Dom.ForEachStmt graph)
{
//graph.Clear();
this.OpenBlockScope();
base.GetGraph(graph);
AST tok = this.getFirstChild();
while(tok != null)
{
if(tok is Ident)
graph.Name = tok.getText();
else if(tok is TypeRef)
{
graph.Type = (Dom.TypeRef)((TypeRef)tok).GetGraph();
}
else if(tok is Statements)
{
((Statements)tok).GetGraph(graph.Statements);
}
else if(tok is Expression)
{
graph.Collection = Expression.Parse(((Expression)tok));
}
tok = tok.getNextSibling();
}
this.CloseScope();
AddRootExpression(graph.Collection, graph.GetType(), "Collection");
return graph;
}
}
#endregion
#region GotoStmt *
public class GotoStmt : Statement
{
public override Dom.IGraph GetGraph()
{
Dom.GotoStmt graph =
new Dom.GotoStmt();
return this.GetGraph(graph);
}
public Dom.GotoStmt
GetGraph(Dom.GotoStmt graph)
{
//graph.Clear();
base.GetGraph(graph);
AST tok = this.getFirstChild();
while(tok != null)
{
if(tok is Ident)
{
graph.Label = tok.getText();
}
if(tok is ModifierAttributes)
{
graph.Label = tok.getFirstChild().getText();
}
else if(tok is Expression)
{
graph.CaseLabel = Expression.Parse(((Expression)tok));
}
tok = tok.getNextSibling();
}
AddRootExpression(graph.CaseLabel, graph.GetType(), "CaseLabel");
return graph;
}
}
#endregion
#region ReturnStmt *
public class ReturnStmt : Statement
{
public override Dom.IGraph GetGraph()
{
Dom.ReturnStmt graph =
new Dom.ReturnStmt();
return this.GetGraph(graph);
}
public Dom.ReturnStmt
GetGraph(Dom.ReturnStmt graph)
{
//graph.Clear();
base.GetGraph(graph);
AST tok = this.getFirstChild();
while(tok != null)
{
if(tok is Expression)
{
graph.Expression = Expression.Parse(((Expression)tok));
}
tok = tok.getNextSibling();
}
AddRootExpression(graph.Expression, graph.GetType(), "Expression");
return graph;
}
}
#endregion
#region BreakStmt *
public class BreakStmt : Statement
{
public override Dom.IGraph GetGraph()
{
Dom.BreakStmt graph =
new Dom.BreakStmt();
return this.GetGraph(graph);
}
public Dom.BreakStmt
GetGraph(Dom.BreakStmt graph)
{
//graph.Clear();
base.GetGraph(graph);
AST tok = this.getFirstChild();
while(tok != null)
{
tok = tok.getNextSibling();
}
return graph;
}
}
#endregion
#region ContinueStmt *
public class ContinueStmt : Statement
{
public override Dom.IGraph GetGraph()
{
Dom.ContinueStmt graph =
new Dom.ContinueStmt();
return this.GetGraph(graph);
}
public Dom.ContinueStmt
GetGraph(Dom.ContinueStmt graph)
{
//graph.Clear();
base.GetGraph(graph);
AST tok = this.getFirstChild();
while(tok != null)
{
tok = tok.getNextSibling();
}
return graph;
}
}
#endregion
#region CheckedStmt *
public class CheckedStmt : Statement
{
public override Dom.IGraph GetGraph()
{
Dom.CheckedStmt graph =
new Dom.CheckedStmt();
return this.GetGraph(graph);
}
public Dom.CheckedStmt
GetGraph(Dom.CheckedStmt graph)
{
//graph.Clear();
this.OpenBlockScope();
base.GetGraph(graph);
AST tok = this.getFirstChild();
while(tok != null)
{
if(tok is Statements)
{
((Statements)tok).GetGraph(graph.Statements);
}
tok = tok.getNextSibling();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -