本文整理匯總了C#中AST.SetCurrentFunction方法的典型用法代碼示例。如果您正苦於以下問題:C# AST.SetCurrentFunction方法的具體用法?C# AST.SetCurrentFunction怎麽用?C# AST.SetCurrentFunction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AST
的用法示例。
在下文中一共展示了AST.SetCurrentFunction方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetFuncDef
public Tuple<AST.Env, AST.FuncDef> GetFuncDef(AST.Env env)
{
// Get storage class specifier and base type from declaration specifiers.
Tuple<AST.Env, AST.Decln.SCS, AST.ExprType> r_specs = this.specs.GetSCSType(env);
env = r_specs.Item1;
AST.Decln.SCS scs = r_specs.Item2;
AST.ExprType base_type = r_specs.Item3;
// Get function name and function type from declarator.
Tuple<String, AST.ExprType> r_declr = this.declr.GetNameAndType(env, base_type);
String name = r_declr.Item1;
AST.ExprType type = r_declr.Item2;
AST.TFunction func_type;
if (type.kind == AST.ExprType.Kind.FUNCTION) {
func_type = (AST.TFunction)type;
} else {
throw new InvalidOperationException($"{name} is not a function.");
}
switch (scs) {
case AST.Decln.SCS.AUTO:
case AST.Decln.SCS.EXTERN:
case AST.Decln.SCS.STATIC:
env = env.PushEntry(AST.Env.EntryKind.GLOBAL, name, type);
break;
case AST.Decln.SCS.TYPEDEF:
default:
throw new InvalidOperationException("Invalid storage class specifier for function definition.");
}
env = env.SetCurrentFunction(func_type);
Tuple<AST.Env, AST.Stmt> r_stmt = this.stmt.GetStmt(env);
env = r_stmt.Item1;
AST.Stmt stmt = r_stmt.Item2;
env = env.SetCurrentFunction(new AST.TEmptyFunction());
return Tuple.Create(env, new AST.FuncDef(name, scs, func_type, stmt));
}