protected void ImplementGetPrimitives(Member[] primitiveMembers, FieldInstance[] f_primitives, FieldInstance[] f_nullFlags) { MethodInstance template_m_getPrimitives = new MethodInstance(null, typeof(RootCacheValue), typeof(Object[]), "GetPrimitives"); IMethodVisitor mv = VisitMethod(template_m_getPrimitives); mv.Push(f_primitives.Length); mv.NewArray(objType); for (int primitiveIndex = 0, size = f_primitives.Length; primitiveIndex < size; primitiveIndex++) { FieldInstance f_primitive = f_primitives[primitiveIndex]; FieldInstance f_nullFlag = f_nullFlags[primitiveIndex]; Label?l_fieldIsNull = null; if (f_nullFlag != null) { l_fieldIsNull = mv.NewLabel(); // only do something if the field is non-null mv.GetThisField(f_nullFlag); mv.IfZCmp(CompareOperator.NE, l_fieldIsNull.Value); } // duplicate array instance on stack mv.Dup(); mv.Push(primitiveIndex); mv.GetThisField(f_primitive); mv.ValueOf(f_primitive.Type.Type); mv.ArrayStore(objType); if (f_nullFlag != null) { mv.Mark(l_fieldIsNull.Value); } } mv.ReturnValue(); mv.EndMethod(); }
protected void ImplementGetRelations(RelationMember[] relationMembers, FieldInstance[] f_relations) { MethodInstance template_m_getRelations = new MethodInstance(null, typeof(RootCacheValue), typeof(IObjRef[][]), "GetRelations"); IMethodVisitor mv = VisitMethod(template_m_getRelations); mv.Push(f_relations.Length); mv.NewArray(objRefArrayType); for (int relationIndex = 0, size = f_relations.Length; relationIndex < size; relationIndex++) { FieldInstance f_primitive = f_relations[relationIndex]; // duplicate array instance on stack mv.Dup(); mv.Push(relationIndex); mv.GetThisField(f_primitive); mv.ArrayStore(objRefArrayType); } mv.ReturnValue(); mv.EndMethod(); }