예제 #1
0
        public static string ConvertCompilerDirectiveAst(CompilerDirectiveAst node, MofQuirks quirks = MofQuirks.None)
        {
            var source = new StringBuilder();

            source.Append(node.PragmaKeyword.Extent.Text);
            source.Append(" ");
            source.Append(node.PragmaName);
            source.Append(" ");
            source.Append("(");
            source.Append(AstMofGenerator.ConvertStringValueAst(node.PragmaParameter));
            source.Append(")");
            return(source.ToString());
        }
예제 #2
0
        public static string ConvertIEnumElementValueAst(IEnumElementValueAst node, MofQuirks quirks = MofQuirks.None)
        {
            switch (node)
            {
            case IntegerValueAst ast:
                return(AstMofGenerator.ConvertIntegerValueAst(ast, quirks));

            case StringValueAst ast:
                return(AstMofGenerator.ConvertStringValueAst(ast, quirks));

            default:
                throw new NotImplementedException();
            }
        }
예제 #3
0
        public static string ConvertLiteralValueAst(LiteralValueAst node, MofQuirks quirks = MofQuirks.None)
        {
            switch (node)
            {
            case IntegerValueAst ast:
                return(AstMofGenerator.ConvertIntegerValueAst(ast, quirks));

            case RealValueAst ast:
                return(AstMofGenerator.ConvertRealValueAst(ast, quirks));

            case BooleanValueAst ast:
                return(AstMofGenerator.ConvertBooleanValueAst(ast, quirks));

            case NullValueAst ast:
                return(AstMofGenerator.ConvertNullValueAst(ast, quirks));

            case StringValueAst ast:
                return(AstMofGenerator.ConvertStringValueAst(ast, quirks));

            default:
                throw new NotImplementedException();
            }
        }
예제 #4
0
        public static string ConvertToMof(AstNode node, MofQuirks quirks = MofQuirks.None)
        {
            if (node == null)
            {
                return(null);
            }
            switch (node)
            {
            case MofSpecificationAst ast:
                // 7.2 MOF specification
                return(AstMofGenerator.ConvertMofSpecificationAst(ast, quirks));

            case CompilerDirectiveAst ast:
                // 7.3 Compiler directives
                return(AstMofGenerator.ConvertCompilerDirectiveAst(ast, quirks));

            case QualifierTypeDeclarationAst ast:
                // 7.4 Qualifiers
                return(AstMofGenerator.ConvertQualifierTypeDeclarationAst(ast, quirks));

            case QualifierListAst ast:
                // 7.4.1 QualifierList
                return(AstMofGenerator.ConvertQualifierListAst(ast, quirks));

            case ClassDeclarationAst ast:
                // 7.5.2 Class declaration
                return(AstMofGenerator.ConvertClassDeclarationAst(ast, quirks));

            case PropertyDeclarationAst ast:
                // 7.5.5 Property declaration
                return(AstMofGenerator.ConvertPropertyDeclarationAst(ast, quirks));

            case MethodDeclarationAst ast:
                // 7.5.6 Method declaration
                return(AstMofGenerator.ConvertMethodDeclarationAst(ast, quirks));

            case ParameterDeclarationAst ast:
                // 7.5.7 Parameter declaration
                return(AstMofGenerator.ConvertParameterDeclarationAst(ast, quirks));

            case ComplexValueArrayAst ast:
                // 7.5.9 Complex type value
                return(AstMofGenerator.ConvertComplexValueArrayAst(ast, quirks));

            case ComplexValueAst ast:
                // 7.5.9 Complex type value
                return(AstMofGenerator.ConvertComplexValueAst(ast, quirks));

            case PropertyValueListAst ast:
                // 7.5.9 Complex type value
                return(AstMofGenerator.ConvertPropertyValueListAst(ast, quirks));

            case LiteralValueArrayAst ast:
                // 7.6.1 Primitive type value
                return(AstMofGenerator.ConvertLiteralValueArrayAst(ast, quirks));

            case IntegerValueAst ast:
                // 7.6.1.1 Integer value
                return(AstMofGenerator.ConvertIntegerValueAst(ast, quirks));

            case RealValueAst ast:
                // 7.6.1.2 Real value
                return(AstMofGenerator.ConvertRealValueAst(ast, quirks));

            case StringValueAst ast:
                // 7.6.1.3 String values
                return(AstMofGenerator.ConvertStringValueAst(ast, quirks));

            case BooleanValueAst ast:
                // 7.6.1.5 Boolean value
                return(AstMofGenerator.ConvertBooleanValueAst(ast, quirks));

            case NullValueAst ast:
                // 7.6.1.6 Null value
                return(AstMofGenerator.ConvertNullValueAst(ast, quirks));

            case InstanceValueDeclarationAst ast:
                // 7.6.2 Complex type value
                return(AstMofGenerator.ConvertInstanceValueDeclarationAst(ast, quirks));

            case StructureValueDeclarationAst ast:
                // 7.6.2 Complex type value
                return(AstMofGenerator.ConvertStructureValueDeclarationAst(ast, quirks));

            case EnumValueAst ast:
                // 7.6.3 Enum type value
                return(AstMofGenerator.ConvertEnumValueAst(ast, quirks));

            case EnumValueArrayAst ast:
                // 7.6.3 Enum type value
                return(AstMofGenerator.ConvertEnumValueArrayAst(ast, quirks));

            case EnumTypeValueAst ast:
                // 7.6.3 Enum type value
                return(AstMofGenerator.ConvertEnumTypeValueAst(ast, quirks));

            case PropertyValueAst ast:
                // 7.5.9 Complex type value
                return(AstMofGenerator.ConvertPropertyValueAst(ast, quirks));

            default:
                // unknown
                throw new InvalidOperationException(node.GetType().FullName);
            }
        }