private static bool IsType(IType value, string namespaceName, string name)
        {
            ITypeReference typeReference = value as ITypeReference;

            if (typeReference != null)
            {
                return((typeReference.Name == name) && (typeReference.Namespace == namespaceName) && (typeReference.GenericArguments.Count == 0));
            }

            IRequiredModifier requiredModifier = value as IRequiredModifier;

            if (requiredModifier != null)
            {
                return(IsType(requiredModifier.ElementType, namespaceName, name));
            }

            IOptionalModifier optionalModifier = value as IOptionalModifier;

            if (optionalModifier != null)
            {
                return(IsType(optionalModifier.ElementType, namespaceName, name));
            }

            return(false);
        }
Exemplo n.º 2
0
        private void WriteVariableDecl(LanguageWriter w, bool nohandle)
        {
            if (nohandle)
            {
                IObjectCreateExpression exp_create = (IObjectCreateExpression)this.exp;

                // 変数型
                IOptionalModifier modopt = this.var_type as IOptionalModifier;
                if (modopt != null && modopt.Modifier.Namespace == "System.Runtime.CompilerServices" && modopt.Modifier.Name == "IsConst")
                {
                    this.var_type = modopt.ElementType;
                }
                new TypeRef(this.var_type).WriteName(w);

                // 変数名
                w.Write(" ");
                w.WriteDeclaration(this.var_name);

                // 初期化子
                if (exp_create.Arguments.Count == 0)
                {
                    w.WriteComment(" /* 既定のコンストラクタ */");
                }
                else
                {
                    w.Write("(");
                    w.WriteExpressionCollection(exp_create.Arguments);
                    w.Write(")");
                }
            }
            else
            {
                // = で代入の場合: ハンドル表記でないと、コンストラクタ呼び出しになってしまう

                // 変数型
                new TypeRef(this.var_type).WriteNameWithRef(w);

                // 変数名
                w.Write(" ");
                w.WriteDeclaration(this.var_name);

                // 代入する値
                w.Write("=");
                ExpressionWriter.WriteExpression(w, this.exp, false);
            }

            w.Write(";");
        }
Exemplo n.º 3
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }

            IOptionalModifier optionalModifier = obj as IOptionalModifier;

            if (optionalModifier == null)
            {
                return(false);
            }

            return
                (this.ElementType.Equals(optionalModifier.ElementType) &&
                 this.Modifier.Equals(optionalModifier.Modifier));
        }
Exemplo n.º 4
0
        public int CompareTo(object obj)
        {
            IOptionalModifier optionalModifier = obj as IOptionalModifier;

            if (optionalModifier == null)
            {
                return(-1);
            }

            int ret = this.ElementType.CompareTo(optionalModifier.ElementType);

            if (ret != 0)
            {
                return(ret);
            }

            return(this.Modifier.CompareTo(optionalModifier.Modifier));
        }
Exemplo n.º 5
0
 public virtual void VisitOptionalModifier(IOptionalModifier type)
 {
     VisitType(type.Modifier);
     VisitType(type.ElementType);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Use the generic argument providers to specialize a type
        /// </summary>
        /// <param name="type">The type to resolve</param>
        /// <param name="declaringType">The declaring type as a generic argument provider</param>
        /// <param name="method">The method as a generic argument provider</param>
        /// <returns></returns>
        public static IType GetType(IType type, IGenericArgumentProvider declaringType, IGenericArgumentProvider method)
        {
            ITypeReference itr = type as ITypeReference;

            if (itr != null)
            {
                if (itr.GenericType == null)
                {
                    // The parameter is directly a non-generic type reference
                    return(itr);
                }
                else
                {
                    // The parameter is a reference to a generic type. Build an array of types of the
                    // generic arguments by recursion
                    IType[] ita = new IType[itr.GenericArguments.Count];
                    for (int i = 0; i < ita.Length; i++)
                    {
                        ita[i] = GetType(itr.GenericArguments[i], declaringType, method);
                    }
                    // Build the specialization (the 'instance') of the generic type
                    ITypeReference itr2 = new XTypeInstanceReference();
                    itr2.GenericType = itr.GenericType;
                    itr2.GenericArguments.AddRange(ita);
                    ((ISettableTypeDeclaration)itr2).Declaration = itr.Resolve();
                    return(itr2);
                }
            }

            // Check to see if the parameter is an array
            IArrayType iat = type as IArrayType;

            if (iat != null)
            {
                // The parameter is an array type. Build an array type and recurse to get its element type
                IArrayType iat2 = new XArrayType();
                iat2.ElementType = GetType(iat.ElementType, declaringType, method);
                iat2.DotNetType  = iat.DotNetType;
                return(iat2);
            }

            // Check to see if the parameter is a pointer
            IPointerType ipt = type as IPointerType;

            if (ipt != null)
            {
                // The parameter is a pointer type. Build a pointer type and recurse to set its element type
                IPointerType ipt2 = new XPointerType();
                ipt2.ElementType = GetType(ipt.ElementType, declaringType, method);
                return(ipt2);
            }

            // Check to see if the parameter is a reference
            IReferenceType irt = type as IReferenceType;

            if (irt != null)
            {
                // The parameter is a reference type. Build a reference type and recurse
                // to set its element type
                IReferenceType irt2 = new XReferenceType();
                irt2.ElementType = GetType(irt.ElementType, declaringType, method);
                return(irt2);
            }

            // Check to see if the parameter has an optional modifier
            IOptionalModifier iom = type as IOptionalModifier;

            if (iom != null)
            {
                // The parameter has an optional modifier. Build an optional modifier type and recurse
                // to set its element type
                IOptionalModifier iom2 = new XOptionalModifier();
                iom2.Modifier    = (ITypeReference)GetType(iom.Modifier, declaringType, method);
                iom2.ElementType = GetType(iom.ElementType, declaringType, method);
                return(iom2);
            }

            // Check to see if the parameter has an required modifier
            IRequiredModifier irm = type as IRequiredModifier;

            if (irm != null)
            {
                // The parameter has a required modifier. Build a required modifier type and recurse
                // to set its element type
                IRequiredModifier irm2 = new XRequiredModifier();
                irm2.Modifier    = (ITypeReference)GetType(irm.Modifier, declaringType, method);
                irm2.ElementType = GetType(irm.ElementType, declaringType, method);
                return(irm2);
            }

            // Deal with generic parameters
            IGenericParameter igp = type as IGenericParameter;
            IMethodReference  imr;

            if (igp != null)
            {
                itr = igp.Owner as ITypeReference;
                imr = igp.Owner as IMethodReference;
                ;
                if (itr == null && imr == null)
                {
                    throw new NotSupportedException("A generic parameter must be owned by a method or type");
                }

                if (itr == null)
                {
                    if (method != null)
                    {
                        // Get the parameter type from the method instance
                        return(method.GenericArguments[igp.Position]);
                    }
                    else
                    {
                        return(igp);
                    }
                }
                else
                {
                    if (declaringType != null)
                    {
                        // Get the parameter type from the declaring type
                        return(declaringType.GenericArguments[igp.Position]);
                    }
                    else
                    {
                        return(igp);
                    }
                }
            }

            // The only thing left is that the parameter is a generic argument
            IGenericArgument iga = type as IGenericArgument;

            if (iga == null)
            {
                throw new NotSupportedException("Unable to get the parameters type");
            }

            IType it = iga.Resolve();

            if (it == null || !(it is IGenericArgument) || (it is IGenericParameter))
            {
                itr = iga.Owner as ITypeReference;
                imr = iga.Owner as IMethodReference;
                if (itr == null && imr == null)
                {
                    throw new NotSupportedException();
                }

                if (itr == null)
                {
                    if (method != null)
                    {
                        IGenericArgument iga2 = new XGenericArgument();
                        iga2.Owner    = method;
                        iga2.Position = iga.Position;
                        return(iga2);
                    }
                    else
                    {
                        return(iga);
                    }
                }
                else
                {
                    IGenericArgument iga2 = new XGenericArgument();
                    iga2.Owner    = declaringType;
                    iga2.Position = iga.Position;
                    return(iga2);
                }
            }

            // Recurse
            return(GetType(it, declaringType, method));
        }
Exemplo n.º 7
0
        private string GetName(bool fullname)
        {
            if (tref != null)
            {
                string name = tref.Name.Replace(".", "::").Replace("+", "::");

                if (!fullname)
                {
                    string special;
                    if (tref.Namespace == "System" && specialTypeNames.TryGetValue(name, out special))
                    {
                        name = special;
                    }
                }

                ITypeCollection genericArguments = tref.GenericArguments;
                if (genericArguments.Count > 0)
                {
                    System.Text.StringBuilder build = new System.Text.StringBuilder(name);

                    build.Append('<');
                    bool first = true;
                    foreach (IType type1 in genericArguments)
                    {
                        if (first)
                        {
                            first = false;
                        }
                        else
                        {
                            build.Append(", ");
                        }
                        build.Append(new TypeRef(type1).GetNameWithRef(fullname));
                    }
                    build.Append('>');

                    name = build.ToString();
                }

                return(fullname?RawNamespace + name:name);
            }

            IArrayType type2 = type as IArrayType;

            if (type2 != null)
            {
                string name = type2.Dimensions.Count <= 1?"":", " + type2.Dimensions.Count.ToString();
                return("array<" + new TypeRef(type2.ElementType).GetNameWithRef(fullname) + name + ">");
            }

            IPointerType type4 = type as IPointerType;

            if (type4 != null)
            {
                return(new TypeRef(type4.ElementType).GetNameWithRef(fullname) + "*");
            }

            IReferenceType type3 = type as IReferenceType;

            if (type3 != null)
            {
                return(new TypeRef(type3.ElementType).GetNameWithRef(fullname) + "%");
            }

            IOptionalModifier modifier2 = type as IOptionalModifier;

            if (modifier2 != null)
            {
                return(Modify(new TypeRef(modifier2.Modifier), new TypeRef(modifier2.ElementType), fullname, false));
            }

            IRequiredModifier modifier = type as IRequiredModifier;

            if (modifier != null)
            {
                return(Modify(new TypeRef(modifier.Modifier), new TypeRef(modifier.ElementType), fullname, true));
            }

            IGenericParameter parameter = type as IGenericParameter;

            if (parameter != null)
            {
                return(parameter.Name);
            }

            IGenericArgument argument = type as IGenericArgument;

            if (argument != null)
            {
                return(new TypeRef(argument.Resolve()).GetNameWithRef(fullname));
            }

            IFunctionPointer fptr = type as IFunctionPointer;

            if (fptr != null)
            {
                System.Text.StringBuilder build = new System.Text.StringBuilder();
                build.Append("(");
                build.Append(new TypeRef(fptr.ReturnType.Type).GetNameWithRef(fullname));
                build.Append(" (*)(");
                bool first = true;
                foreach (IParameterDeclaration declaration in fptr.Parameters)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        build.Append(", ");
                    }
                    build.Append(new TypeRef(declaration.ParameterType).GetNameWithRef(fullname));
                }
                build.Append("))");
                return(build.ToString());
            }

            if (type is IValueTypeConstraint)
            {
                return("value class");
            }
            else if (type is IDefaultConstructorConstraint)
            {
                return("<DefaultConstructorConstraint>");
            }

            return("<不明な型>");
        }
Exemplo n.º 8
0
        private static string Modify(TypeRef modifier, TypeRef elemType, bool fullname, bool required)
        {
            string fix;

            if (modifier.tref != null && modifier.tref.Namespace == "System.Runtime.CompilerServices")
            {
                switch (modifier.tref.Name)
                {
                case "CallConvStdcall":         fix = " __stdcall"; goto postfix;

                case "CallConvCdecl":           fix = " __cdecl"; goto postfix;

                case "CallConvFastcall":        fix = " __fastcall"; goto postfix;

                case "CallConvThiscall":        fix = " __thiscall"; goto postfix;

                case "IsVolatile":
                    if (elemType.IsPointer)
                    {
                        fix = "volatile"; goto postfix;
                    }
                    else
                    {
                        fix = "volatile "; goto prefix;
                    }

                case "IsConst":
                    if (elemType.IsPointer)
                    {
                        fix = "const"; goto postfix;
                    }
                    else
                    {
                        fix = "const "; goto prefix;
                    }

                case "IsLong":
                    if (elemType.IsType("System", "Int32"))
                    {
                        return("long");
                    }
                    else if (elemType.IsType("System", "UInt32"))
                    {
                        return("unsigned long");
                    }
                    else if (elemType.IsType("System", "Double"))
                    {
                        return("long double");
                    }
                    break;

                case "IsExplicitlyDereferenced":
                    IReferenceType reftype = elemType.type as IReferenceType;
                    if (reftype != null)
                    {
                        return("pin_ptr<" + new TypeRef(reftype.ElementType).GetNameWithRef(fullname) + ">");
                    }
                    break;

                case "IsBoxed":
                    IOptionalModifier mod = elemType.type as IOptionalModifier;
                    if (mod == null)
                    {
                        break;
                    }

                    TypeRef modifier2 = new TypeRef(mod.Modifier);
                    if (!modifier2.IsValueType)
                    {
                        break;
                    }

                    if (!new TypeRef(mod.ElementType).IsType("System", "ValueType"))
                    {
                        break;
                    }

                    return(modifier2.GetName(fullname) + "^");
                }
            }

            fix = "<" + (required?"modreq":"modopt") + " " + modifier.Name + ">";
postfix:
            return(elemType.GetNameWithRef(fullname) + fix);

prefix:
            return(fix + elemType.GetNameWithRef(fullname));
        }
Exemplo n.º 9
0
        private static void WriteModify(LanguageWriter w, TypeRef modifier, TypeRef elemType, bool required)
        {
            if (modifier.tref != null && modifier.tref.Namespace == "System.Runtime.CompilerServices")
            {
                switch (modifier.tref.Name)
                {
                case "IsVolatile":
                    if (elemType.IsPointer)
                    {
                        elemType.WriteNameWithRef(w);
                        w.WriteKeyword("volatile");
                    }
                    else
                    {
                        w.WriteKeyword("volatile");
                        w.Write(" ");
                        elemType.WriteNameWithRef(w);
                    }
                    return;

                case "IsConst":
                    if (elemType.IsPointer)
                    {
                        elemType.WriteNameWithRef(w);
                        w.WriteKeyword("const");
                    }
                    else
                    {
//#warning RefOnStack の場合には const は要らない → refOnStack で呼び出す側で、自分で之を取り除くようにした
                        w.WriteKeyword("const");
                        w.Write(" ");
                        elemType.WriteNameWithRef(w);
                    }
                    return;

                case "IsLong":
                    if (elemType.IsType("System", "Int32"))
                    {
                        w.WriteReference("long", elemType.FullName, elemType.tref);
                        return;
                    }
                    else if (elemType.IsType("System", "UInt32"))
                    {
                        w.WriteReference("unsigned long", elemType.FullName, elemType.tref);
                        return;
                    }
                    else if (elemType.IsType("System", "Double"))
                    {
                        w.WriteReference("long double", elemType.FullName, elemType.tref);
                        return;
                    }
                    break;

                case "IsExplicitlyDereferenced":
                    IReferenceType reftype = elemType.type as IReferenceType;
                    if (reftype != null)
                    {
                        w.WriteKeyword("pin_ptr");
                        w.Write("<");
                        new TypeRef(reftype.ElementType).WriteNameWithRef(w);
                        w.Write(">");
                        return;
                    }
                    break;

                case "CallConvStdcall":
                    elemType.WriteNameWithRef(w);
                    w.Write(" ");
                    w.WriteKeyword("__stdcall");
                    return;

                case "CallConvCdecl":
                    elemType.WriteNameWithRef(w);
                    w.Write(" ");
                    w.WriteKeyword("__cdecl");
                    return;

                case "CallConvFastcall":
                    elemType.WriteNameWithRef(w);
                    w.Write(" ");
                    w.WriteKeyword("__fastcall");
                    return;

                case "CallConvThiscall":
                    elemType.WriteNameWithRef(w);
                    w.Write(" ");
                    w.WriteKeyword("__thiscall");
                    return;

                case "IsBoxed":
                    IOptionalModifier mod = elemType.type as IOptionalModifier;
                    if (mod == null)
                    {
                        break;
                    }

                    TypeRef modifier2 = new TypeRef(mod.Modifier);
                    if (!modifier2.IsValueType)
                    {
                        break;
                    }

                    if (!new TypeRef(mod.ElementType).IsType("System", "ValueType"))
                    {
                        break;
                    }

                    modifier2.WriteName(w); w.Write("^");
                    return;
                }
            }

            elemType.WriteNameWithRef(w);
            w.Write("<");
            w.WriteKeyword(required?"modreq":"modopt");
            w.Write(" ");
            w.WriteReference(modifier.Name, modifier.FullName, modifier.tref);
            w.Write(">");
            return;
        }
Exemplo n.º 10
0
        public string WriteName(LanguageWriter w)
        {
            if (tref != null)
            {
                string name = tref.Name.Replace(".", "::").Replace("+", "::");

                string special;
                if (tref.Namespace == "System" && specialTypeNames.TryGetValue(name, out special))
                {
                    name = special;
                }

                name = NameMangling.UnDecorateName(name);

                w.WriteReference(name, this.FullName, tref);

                ITypeCollection genericArguments = tref.GenericArguments;
                if (genericArguments.Count > 0)
                {
                    w.Write("<");
                    bool first = true;
                    foreach (IType type1 in genericArguments)
                    {
                        if (first)
                        {
                            first = false;
                        }
                        else
                        {
                            w.Write(", ");
                        }
                        new TypeRef(type1).WriteNameWithRef(w);
                    }
                    w.Write(">");
                }

                return(name);
            }

            IArrayType type2 = type as IArrayType;

            if (type2 != null)
            {
                w.WriteKeyword("array");
                w.Write("<");
                new TypeRef(type2.ElementType).WriteNameWithRef(w);

                if (type2.Dimensions.Count > 1)
                {
                    w.Write(", ");
                    w.WriteAsLiteral(type2.Dimensions.Count);
                }
                w.Write(">");
            }

            IPointerType type4 = type as IPointerType;

            if (type4 != null)
            {
                new TypeRef(type4.ElementType).WriteNameWithRef(w);
                w.Write("*");
            }

            IReferenceType type3 = type as IReferenceType;

            if (type3 != null)
            {
                new TypeRef(type3.ElementType).WriteNameWithRef(w);
                w.Write("%");
            }

            IOptionalModifier modifier2 = type as IOptionalModifier;

            if (modifier2 != null)
            {
                WriteModify(w, new TypeRef(modifier2.Modifier), new TypeRef(modifier2.ElementType), false);
            }

            IRequiredModifier modifier = type as IRequiredModifier;

            if (modifier != null)
            {
                WriteModify(w, new TypeRef(modifier.Modifier), new TypeRef(modifier.ElementType), true);
            }

            IFunctionPointer fptr = type as IFunctionPointer;

            if (fptr != null)
            {
                w.Write("(");
                new TypeRef(fptr.ReturnType.Type).WriteNameWithRef(w);
                w.Write(" (*)(");
                bool first = true;
                foreach (IParameterDeclaration declaration in fptr.Parameters)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        w.Write(", ");
                    }
                    new TypeRef(declaration.ParameterType).WriteNameWithRef(w);
                }
                w.Write("))");
            }

            IGenericParameter parameter = type as IGenericParameter;

            if (parameter != null)
            {
                w.WriteReference(parameter.Name, "/* ジェネリックパラメータ */ " + parameter.Name, null);
            }

            IGenericArgument argument = type as IGenericArgument;

            if (argument != null)
            {
                new TypeRef(argument.Resolve()).WriteNameWithRef(w);
            }

            if (type is IValueTypeConstraint)
            {
                w.WriteKeyword("value class");
            }
            else if (type is IDefaultConstructorConstraint)
            {
                w.Write("<DefaultConstructorConstraint>");
            }

            return("<不明な型>");
        }
        private string GetTypeText(IType value)
        {
            ITypeReference typeReference = value as ITypeReference;

            if (typeReference != null)
            {
                string specialName = this.GetTypeSpecialNameText(typeReference);
                if ((specialName != null) && (specialName.Length > 0))
                {
                    return(specialName);
                }

                string typeReferenceText = this.GetTypeReferenceText(typeReference);
                return(typeReferenceText);
            }

            IPointerType pointerType = value as IPointerType;

            if (pointerType != null)
            {
                return(this.GetTypeText(pointerType.ElementType) + "*");
            }

            IReferenceType referenceType = value as IReferenceType;

            if (referenceType != null)
            {
                return(this.GetTypeText(referenceType.ElementType) + "&");
            }

            IArrayType arrayType = value as IArrayType;

            if (arrayType != null)
            {
                using (StringWriter writer = new StringWriter(CultureInfo.InvariantCulture))
                {
                    writer.Write(this.GetTypeText(arrayType.ElementType));
                    writer.Write("[");

                    IArrayDimensionCollection dimensions = arrayType.Dimensions;
                    for (int i = 0; i < dimensions.Count; i++)
                    {
                        if (i != 0)
                        {
                            writer.Write(",");
                        }

                        int lowerBound = dimensions[i].LowerBound;
                        int upperBound = dimensions[i].UpperBound;

                        if (lowerBound != -1)
                        {
                            writer.Write(lowerBound.ToString(CultureInfo.InvariantCulture));
                        }

                        if ((lowerBound != -1) || (upperBound != -1))
                        {
                            writer.Write(":");
                        }

                        if (upperBound != -1)
                        {
                            writer.Write(upperBound.ToString(CultureInfo.InvariantCulture));
                        }
                    }

                    writer.Write("]");
                    return(writer.ToString());
                }
            }

            IOptionalModifier optionalModifier = value as IOptionalModifier;

            if (optionalModifier != null)
            {
                return("{optional:" + this.GetTypeText(optionalModifier.Modifier) + "}" + this.GetTypeText(optionalModifier.ElementType));
            }

            IRequiredModifier requiredModifier = value as IRequiredModifier;

            if (requiredModifier != null)
            {
                return("{required:" + this.GetTypeText(requiredModifier.Modifier) + "}" + this.GetTypeText(requiredModifier.ElementType));
            }

            IFunctionPointer functionPointer = value as IFunctionPointer;

            if (functionPointer != null)
            {
                using (StringWriter writer = new StringWriter(CultureInfo.InvariantCulture))
                {
                    writer.Write("*");
                    writer.Write("(");

                    for (int i = 0; i < functionPointer.Parameters.Count; i++)
                    {
                        if (i != 0)
                        {
                            writer.Write(",");
                        }

                        writer.Write(this.GetTypeText(functionPointer.Parameters[i].ParameterType));
                    }

                    writer.Write(")");
                    writer.Write(":");
                    writer.Write(this.GetTypeText(functionPointer.ReturnType.Type));
                    return(writer.ToString());
                }
            }

            IGenericParameter genericParameter = value as IGenericParameter;

            if (genericParameter != null)
            {
                return(genericParameter.Name);
            }

            IGenericArgument genericArgument = value as IGenericArgument;

            if (genericArgument != null)
            {
                ITypeReference genericType = genericArgument.Owner as ITypeReference;
                if (genericType != null)
                {
                    return("<!" + genericArgument.Position.ToString(CultureInfo.InvariantCulture) + ">");
                }

                IMethodReference genericMethod = genericArgument.Owner as IMethodReference;
                if (genericMethod != null)
                {
                    return("<!!" + genericArgument.Position.ToString(CultureInfo.InvariantCulture) + ">");
                }
            }

            throw new NotSupportedException("Invalid type in code identifier.");
        }
Exemplo n.º 12
0
        private static void WriteLocalRefVariable(LanguageWriter w, LocalRefVariableStatement state)
        {
            state.Write(w);
            return;

            if (!state.noblock)
            {
                w.PushScope();
                //---------------------------------------------
                w.Write("{");
                w.WriteLine();
                w.WriteIndent();
            }
            if (!w.SuppressOutput)
            {
                //*
#warning local-ref: 上層で無駄な宣言を取り除くべき
                if (w.scope.ContainsVariable(state.var_name))
                {
                    w.scope[state.var_name].local_scope = true;
                }
                else
                {
                    w.scope.RegisterVariable(state.var_name, true);
                }
                //*/
            }

            IObjectCreateExpression exp_create = state.exp as IObjectCreateExpression;
            bool nohandle = exp_create != null;         // ハンドル表記でなくても良いかどうか
            if (nohandle)
            {
                // 変数型
                IOptionalModifier modopt = state.var_type as IOptionalModifier;
                if (modopt != null && modopt.Modifier.Namespace == "System.Runtime.CompilerServices" && modopt.Modifier.Name == "IsConst")
                {
                    state.var_type = modopt.ElementType;
                }
                new TypeRef(state.var_type).WriteName(w);

                // 変数名
                w.Write(" ");
                w.WriteDeclaration(state.var_name);

                // 初期化子
                if (exp_create.Arguments.Count == 0)
                {
                    w.WriteComment(" /* 既定のコンストラクタ */");
                }
                else
                {
                    w.Write("(");
                    w.WriteExpressionCollection(exp_create.Arguments);
                    w.Write(")");
                }
            }
            else
            {
                // = で代入の場合: ハンドル表記でないと、コンストラクタ呼び出しになってしまう

                // 変数型
                new TypeRef(state.var_type).WriteNameWithRef(w);

                // 変数名
                w.Write(" ");
                w.WriteDeclaration(state.var_name);

                // 代入する値
                w.Write("=");
                ExpressionWriter.WriteExpression(w, state.exp, false);
            }

            w.Write(";");

            // 後に続く内容
            w.WriteLine();
            WriteBlock(w, state.block);

            // ハンドル表記で宣言した場合はちゃんと delete
            if (!nohandle)
            {
                WriteStatement(w, new DeleteStatement(new VariableReferenceExpression(state.decl)));
            }

            w.WriteOutdent();
            w.Write("}");
            w.WriteLine();
            if (state.labelname != null)
            {
                w.__WriteLabel(state.labelname);
                w.Write(";");
                w.WriteLine();
            }
            if (!state.noblock)
            {
                //---------------------------------------------
                w.PopScope();
            }
            //*/
        }
Exemplo n.º 13
0
 public override void VisitOptionalModifier(IOptionalModifier type)
 {
     WriteUnsupported(type.ToString());
 }
Exemplo n.º 14
0
 public virtual void VisitOptionalModifier(IOptionalModifier type)
 {
     this.VisitType(type.Modifier);
     this.VisitType(type.ElementType);
 }
Exemplo n.º 15
0
 public virtual IType TransformOptionalModifier(IOptionalModifier value)
 {
     value.ElementType = this.TransformType(value.ElementType);
     value.Modifier = (ITypeReference)this.TransformTypeReference(value.Modifier);
     return value;
 }