Exemplo n.º 1
0
        private void NewObj()
        {
            var inst         = _instructions[_instructionPtr];
            var memberRef    = ((MethodReference)inst.Operand);
            var type         = _classLoader.LoadTypeFromTypeRef(memberRef.DeclaringType);
            var resolvedCtor = memberRef.Resolve();

            if (resolvedCtor.IsStatic || resolvedCtor.IsAbstract)
            {
                ThrowHelper.VerificationError("newobj on static or abstract method");
            }

            // There are four cases:
            // 1) Value types (ordinary constructor, resulting VALUECLASS pushed)
            // 2) String (var-args constructor, result automatically pushed)
            // 3) MDArray (var-args constructor, resulting OBJECTREF pushed)
            // 4) Reference types (ordinary constructor, resulting OBJECTREF pushed)
            var classInfo = memberRef.DeclaringType;

            if (classInfo.IsValueType)
            {
                // Value type
                throw ThrowHelper.NotImplementedYet;
            }
            else if (classInfo.Namespace == "System" && classInfo.Name == "String") // TODO: move to method table
            {
                // For a VAROBJSIZE class (currently == String), pass NULL as this to "pseudo-constructor."
                throw ThrowHelper.NotImplementedYet;
            }
            else
            {
                ObjectInstance thisArgObj = null;
                if (classInfo.IsArray)
                {
                    // Array
                    throw ThrowHelper.NotImplementedYet;
                }
                else
                {
                    // Reference
                    thisArgObj = PetitClrRuntime.AllocateObject(type);
                    DoCallWork(false, thisArgObj, resolvedCtor);
                }

                _opStack.Push(thisArgObj);
            }
        }
Exemplo n.º 2
0
 static PetitClrRuntime()
 {
     Current = new PetitClrRuntime();
     Current.Initialize();
 }
Exemplo n.º 3
0
 static PetitClrRuntime()
 {
     Current = new PetitClrRuntime();
     Current.Initialize();
 }