Esempio n. 1
0
 public virtual void WriteIncludesForFieldDeclaration(CppCodeWriter writer)
 {
     if (this.TreatAsValueType())
     {
         writer.AddIncludeForTypeDefinition(this._typeRef);
     }
     else
     {
         this.WriteMarshaledTypeForwardDeclaration(writer);
     }
 }
Esempio n. 2
0
 public virtual void WriteIncludesForMarshaling(CppCodeWriter writer)
 {
     writer.AddIncludeForTypeDefinition(this._typeRef);
 }
Esempio n. 3
0
 public override void WriteIncludesForFieldDeclaration(CppCodeWriter writer)
 {
     base.WriteIncludesForFieldDeclaration(writer);
     writer.AddIncludeForTypeDefinition(base._elementType);
 }
Esempio n. 4
0
        private void WriteMainInvocation(CppCodeWriter writer, IRuntimeMetadataAccess metadataAccess)
        {
            if (this.ValidateMainMethod(writer))
            {
                writer.AddIncludeForMethodDeclarations(_entryPoint.DeclaringType);
                List<string> argumentArray = new List<string> {
                    Naming.Null
                };
                if (_entryPoint.Parameters.Count > 0)
                {
                    ArrayType parameterType = (ArrayType) _entryPoint.Parameters[0].ParameterType;
                    writer.AddIncludeForTypeDefinition(parameterType);
                    object[] args = new object[] { Naming.ForVariable(parameterType), Emit.NewSZArray(parameterType, "argc - 1", metadataAccess) };
                    writer.WriteLine("{0} args = {1};", args);
                    writer.WriteLine();
                    writer.WriteLine("for (int i = 1; i < argc; i++)");
                    using (new BlockWriter(writer, false))
                    {
                        writer.WriteLine("DECLARE_NATIVE_C_STRING_AS_STRING_VIEW_OF_IL2CPP_CHARS(argumentUtf16, argv[i]);");
                        object[] objArray2 = new object[] { Naming.ForVariable(TypeProvider.SystemString) };
                        writer.WriteLine("{0} argument = il2cpp_codegen_string_new_utf16(argumentUtf16);", objArray2);
                        writer.WriteStatement(Emit.StoreArrayElement("args", "i - 1", "argument", false));
                    }
                    writer.WriteLine();
                    argumentArray.Add("args");
                }
                if (MethodSignatureWriter.NeedsHiddenMethodInfo(_entryPoint, MethodCallType.Normal, false))
                {
                    argumentArray.Add(metadataAccess.HiddenMethodInfo(_entryPoint));
                }
                if ((_entryPoint.DeclaringType.Attributes & (TypeAttributes.AnsiClass | TypeAttributes.BeforeFieldInit)) == TypeAttributes.AnsiClass)
                {
                    object[] objArray3 = new object[] { metadataAccess.TypeInfoFor(_entryPoint.DeclaringType) };
                    writer.WriteLine("IL2CPP_RUNTIME_CLASS_INIT({0});", objArray3);
                }
                Unity.IL2CPP.ILPreProcessor.TypeResolver typeResolverForMethodToCall = Unity.IL2CPP.ILPreProcessor.TypeResolver.For(_entryPoint.DeclaringType, _entryPoint);
                string block = MethodBodyWriter.GetMethodCallExpression(null, _entryPoint, _entryPoint, typeResolverForMethodToCall, MethodCallType.Normal, metadataAccess, new VTableBuilder(), argumentArray, false, null);
                switch (_entryPoint.ReturnType.MetadataType)
                {
                    case MetadataType.Void:
                        writer.WriteStatement(block);
                        writer.WriteLine("return 0;");
                        break;

                    case MetadataType.Int32:
                    {
                        object[] objArray4 = new object[] { block };
                        writer.WriteLine("return {0};", objArray4);
                        break;
                    }
                    case MetadataType.UInt32:
                    {
                        object[] objArray5 = new object[] { block };
                        writer.WriteLine("uint32_t exitCode = {0};", objArray5);
                        writer.WriteLine("return static_cast<int>(exitCode);");
                        break;
                    }
                }
            }
        }