本文整理匯總了C#中AST.GetType方法的典型用法代碼示例。如果您正苦於以下問題:C# AST.GetType方法的具體用法?C# AST.GetType怎麽用?C# AST.GetType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AST
的用法示例。
在下文中一共展示了AST.GetType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ConvertToPythonAst
internal static PythonAst ConvertToPythonAst(CodeContext codeContext, AST source )
{
Statement stmt;
PythonCompilerOptions options = new PythonCompilerOptions(ModuleOptions.ExecOrEvalCode);
SourceUnit unit = new SourceUnit(codeContext.LanguageContext, NullTextContentProvider.Null, "", SourceCodeKind.AutoDetect);
CompilerContext compilerContext = new CompilerContext(unit, options, ErrorSink.Default);
bool printExpression = false;
if (source is Expression) {
Expression exp = (Expression)source;
stmt = new ReturnStatement(expr.Revert(exp.body));
} else if (source is Module) {
Module module = (Module)source;
stmt = _ast.stmt.RevertStmts(module.body);
} else if (source is Interactive) {
Interactive interactive = (Interactive)source;
stmt = _ast.stmt.RevertStmts(interactive.body);
printExpression = true;
} else
throw PythonOps.TypeError("unsupported type of AST: {0}",(source.GetType()));
return new PythonAst(stmt, false, ModuleOptions.ExecOrEvalCode, printExpression, compilerContext, new int[] {} );
}
示例2: MustBeInsideLoop
//-----------------------------------------------------------------------------
// This construct must be inside a loop
//-----------------------------------------------------------------------------
public static SymbolErrorException MustBeInsideLoop(AST.Node node)
{
string stHint = "?";
if (node is AST.BreakStatement)
{
stHint = "break";
} else if (node is AST.ContinueStatement)
{
stHint = "continue";
} else {
Debug.Assert(false, "Illegal type:"+ node.GetType());
}
return new SymbolErrorException(
Code.cMustBeInsideLoop,
node.Location,
"'" + stHint + "' must occur inside a control block (do, while, for)"
);
}
示例3: createFromAST
private AST createFromAST(AST node)
{
AST newNode = null;
var nodeAsTypeObj = node.GetType();
var creator = (ASTNodeCreator) typename2creator_[nodeAsTypeObj.FullName];
if (creator != null)
{
newNode = creator.Create();
if (newNode == null)
{
throw new ArgumentException("Unable to create AST Node Type: '" + nodeAsTypeObj.FullName + "'");
}
}
else
{
newNode = createFromNodeTypeObject(nodeAsTypeObj);
}
return newNode;
}
示例4: GenerateBody
//.........這裏部分代碼省略.........
{
foreach (AST.AstNode child in node.Children)
{
int cur_n = n++;
// children
GenerateBody(tw, vars, child, ref n, ref use_args, match_args, indent);
// shortcut and/or
if (cur_n == outer_n && node is AST.And)
{
GenerateAndShortcut(tw, node as AST.And, outer_n, match_args, indent);
}
else if (cur_n == outer_n && node is AST.Or)
{
GenerateOrShortcut(tw, node as AST.Or, outer_n, match_args, indent);
}
}
}
#region POST: Giant Switch Statement
//
if (node is AST.Code)
{
GenerateLiteralPost(tw, node as AST.Code, outer_n, match_args, indent);
}
else if (node is AST.Regexp)
{
GenerateRegexpPost(tw, node as AST.Regexp, outer_n, match_args, indent);
}
else if (node is AST.Fail)
{
GenerateFailPost(tw, node as AST.Fail, outer_n, match_args, indent);
}
else if (node is AST.Any)
{
GenerateAnyPost(tw, node as AST.Any, outer_n, match_args, indent);
}
else if (node is AST.Look)
{
GenerateLookPost(tw, node as AST.Look, outer_n, match_args, indent);
}
else if (node is AST.Not)
{
GenerateNotPost(tw, node as AST.Not, outer_n, match_args, indent);
}
else if (node is AST.Or)
{
GenerateOrPost(tw, node as AST.Or, outer_n, match_args, indent);
}
else if (node is AST.And)
{
GenerateAndPost(tw, node as AST.And, outer_n, match_args, indent);
}
else if (node is AST.Star)
{
GenerateStarPost(tw, node as AST.Star, outer_n, match_args, indent);
}
else if (node is AST.Plus)
{
GeneratePlusPost(tw, node as AST.Plus, outer_n, match_args, indent);
}
else if (node is AST.Ques)
{
GenerateQuesPost(tw, node as AST.Ques, outer_n, match_args, indent);
}
else if (node is AST.CallOrVar)
{
GenerateCallOrVarPost(tw, vars, node as AST.CallOrVar, outer_n, match_args, indent);
}
else if (node is AST.Call)
{
GenerateCallPost(tw, vars, node as AST.Call, outer_n, match_args, indent);
}
else if (node is AST.Bind)
{
GenerateBindPost(tw, vars, node as AST.Bind, outer_n, match_args, indent);
}
else if (node is AST.Cond)
{
GenerateCondPost(tw, node as AST.Cond, outer_n, match_args, indent);
}
else if (node is AST.Act)
{
GenerateActPost(tw, node as AST.Act, outer_n, match_args, indent);
}
else if (node is AST.InputClass)
{
GenerateInputClassPost(tw, node as AST.InputClass, outer_n, match_args, indent);
}
else if (node is AST.Args)
{
GenerateArgsPost(tw, vars, node as AST.Args, outer_n, match_args, indent);
}
else
{
throw new Exception("Unknown AST node type: " + node.GetType().FullName);
}
#endregion
}