本文整理汇总了C#中CodeGenContext.CreateNestedClass方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenContext.CreateNestedClass方法的具体用法?C# CodeGenContext.CreateNestedClass怎么用?C# CodeGenContext.CreateNestedClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGenContext
的用法示例。
在下文中一共展示了CodeGenContext.CreateNestedClass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenCode0
internal override void GenCode0(CodeGenContext context)
{
bool scope_created, super_created;
CodeGenContext newContext = new CodeGenContext(context);
// scope and super must be evaluated in surrounding scope and passed to Init method
ISimple scope = PushScope(context, out scope_created);
ISimple super = PushSuper(context, out super_created);
string basename = ID.ToDotNetName(name.vid);
// BBTAG: try and get the superclass
PERWAPI.Class superClass = Runtime.ObjectRef;
bool superClassFound = false;
PERWAPI.Method superClassConstructor0 = null;
PERWAPI.Method superClassConstructor1 = Runtime.Object.ctor;
if (this is CLASS)
{
superClass = ((CLASS)this).GetSuperClassRef(newContext);
if (superClass != null)
{
superClassFound = true;
superClassConstructor0 = superClass.GetMethodDesc(".ctor", new Type[0]);
if (superClassConstructor0 is MethodDef)
superClassConstructor0 = ((MethodDef)superClassConstructor0).MakeRefOf();
superClassConstructor1 = superClass.GetMethodDesc(".ctor", new Type[] { Runtime.ClassRef });
if (superClassConstructor1 is MethodDef)
superClassConstructor1 = ((MethodDef)superClassConstructor1).MakeRefOf();
}
else
superClass = Runtime.ObjectRef;
}
//public class MyClass: Object {
// check if this class has already been created in a referenced DLL
// FIXME: this won't work for nested classes
PERWAPI.Class classRef = ClassSkeleton.FindPERWAPIClass(null, name, context.peFiles);
bool defineInteropClass = (classRef == null);
// if it seems like an extension of a ruby builtin class, don't generate an interop class
// FIXME: this won't work for nested classes
if (Ruby.Runtime.BuiltinClasses.IsBuiltinClass(basename))
{
Compiler.InteropWarning(basename + " is a Ruby built-in class, interop class not generated");
defineInteropClass = false;
}
//ClassDef interopClass = newContext.CreateNestedClass(CurrentInteropClass(), basename, Runtime.ObjectRef); // BBTAG
ClassDef interopClass = null;
if (defineInteropClass)
{
if (superClass is PERWAPI.ClassDef)
interopClass = newContext.CreateNestedClass(CurrentInteropClass(), basename, ((PERWAPI.ClassDef)superClass).MakeRefOf()); // BBTAG
else
interopClass = newContext.CreateNestedClass(CurrentInteropClass(), basename, superClass); // BBTAG
interopClasses.Push(interopClass);
classRef = interopClass;
}
//context.classes[classname] = interopClass;
// BBTAG: create skeleton for this class
ClassSkeleton skeleton;
if (context.currentSkeleton.nestedClasses.ContainsKey(basename))
skeleton = context.currentSkeleton.nestedClasses[basename];
else
skeleton = new ClassSkeleton(basename, classRef);
skeleton.lexicalParent = context.currentSkeleton;
newContext.currentSkeleton = skeleton;
skeleton.lexicalParent.nestedClasses[basename] = skeleton;
if (!superClassFound && this is AST.CLASS && ((AST.CLASS)this).super_class != null && defineInteropClass)
{
// do not add to post pass list if supertype is a built-in Ruby class
//List<string> qualifiedSuperClass = ClassSkeleton.ConstNodeToClassList(((AST.CLASS)this).super_class);
//if (!(qualifiedSuperClass.Count == 1 && Ruby.Runtime.BuiltinClasses.IsBuiltinClass(qualifiedSuperClass[0])))
newContext.postPassList.Add(new ClassSkeletonPostPass(skeleton, interopClass, ((AST.CLASS)this).super_class));
}
// public static Class classname;
int seqNo = 0;
internal_name = basename;
while (FileClass().GetField(internal_name) != null)
internal_name = basename + (seqNo++);
// Define singleton in file class so that it gets initialized by .cctor
singletonField = FileClass().AddField(PERWAPI.FieldAttr.PublicStatic, internal_name, Runtime.ClassRef);
newContext.CurrentRubyClass = singletonField;
// public MyClass() : base(singleton) { };
CodeGenContext class_constructor = null;
if (defineInteropClass)
{
//.........这里部分代码省略.........