本文整理匯總了C#中AST.IsGlobal方法的典型用法代碼示例。如果您正苦於以下問題:C# AST.IsGlobal方法的具體用法?C# AST.IsGlobal怎麽用?C# AST.IsGlobal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AST
的用法示例。
在下文中一共展示了AST.IsGlobal方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetDeclns
public Tuple<AST.Env, List<Tuple<AST.Env, AST.Decln>>> GetDeclns(AST.Env env) {
// Get storage class, and base type.
Tuple<AST.Env, AST.Decln.SCS, AST.ExprType> r_specs = decln_specs.GetSCSType(env);
env = r_specs.Item1;
AST.Decln.SCS scs = r_specs.Item2;
AST.ExprType base_type = r_specs.Item3;
List<Tuple<AST.Env, AST.Decln>> declns = new List<Tuple<AST.Env, AST.Decln>>();
// For each init declarators, we'll generate a declaration.
foreach (InitDeclr init_declr in init_declrs) {
// Get the final type, name, and initializer.
Tuple<AST.Env, AST.ExprType, Option<AST.Initr>, String> r_declr = init_declr.GetInitDeclr(env, base_type);
env = r_declr.Item1;
AST.ExprType type = r_declr.Item2;
Option<AST.Initr> initr = r_declr.Item3;
String name = r_declr.Item4;
// Insert the new symbol into the environment.
AST.Env.EntryKind kind;
switch (scs) {
case AST.Decln.SCS.AUTO:
if (env.IsGlobal()) {
kind = AST.Env.EntryKind.GLOBAL;
} else {
kind = AST.Env.EntryKind.STACK;
}
break;
case AST.Decln.SCS.EXTERN:
kind = AST.Env.EntryKind.GLOBAL;
break;
case AST.Decln.SCS.STATIC:
kind = AST.Env.EntryKind.GLOBAL;
break;
case AST.Decln.SCS.TYPEDEF:
kind = AST.Env.EntryKind.TYPEDEF;
break;
default:
throw new InvalidOperationException();
}
env = env.PushEntry(kind, name, type);
// Generate the declaration.
declns.Add(Tuple.Create(env, new AST.Decln(name, scs, type, initr)));
}
return new Tuple<AST.Env, List<Tuple<AST.Env, AST.Decln>>>(env, declns);
}