示例#1
0
 public static class_members BuildClassFieldsSection(List<ident> names, List<type_definition> types)
 {
     var cm = new class_members(access_modifer.private_modifer);
     for (int i = 0; i < names.Count; i++)
         cm.Add(new var_def_statement(names[i], types[i]));
     return cm;
 }
示例#2
0
 public static class_members BuildSimpleReadPropertiesSection(List<ident> names, List<ident> fields, List<type_definition> types)
 {
     var cm = new class_members(access_modifer.public_modifer);
     for (int i = 0; i < names.Count; i++)
         cm.Add(BuildSimpleReadWriteProperty(names[i], fields[i], types[i]));
     return cm;
 }
示例#3
0
 public static class_members BuildSimpleConstructorSection(List<ident> fields, List<ident> formal_names, List<type_definition> types)
 {
     var cm = new class_members(access_modifer.public_modifer);
     cm.Add(BuildSimpleConstructor(fields,formal_names,types));
     return cm;
 }
示例#4
0
 public static class_members BuildOneMemberSection(declaration m)
 {
     var cm = new class_members(access_modifer.public_modifer);
     cm.Add(m);
     return cm;
 }
        private Tuple<type_declaration, List<procedure_definition>> CreateTypeDeclarationWithForwardDeclaration(type_declaration cl)
        {
            var oldClDef = (class_definition) cl.type_def;
            var classDef = SyntaxTreeBuilder.BuildClassDefinition();
            var typeDeclaration = new type_declaration(cl.type_name, classDef);
            classDef.where_section = oldClDef.where_section;
            var procedures = new List<procedure_definition>();
            var classMembers = new class_members(access_modifer.public_modifer);
            classDef.body.class_def_blocks.Add(classMembers);

            foreach (var member in oldClDef.body.class_def_blocks.SelectMany(x => x.members))
            {
                if (member is var_def_statement)
                {
                    classMembers.Add(member);
                }
                else
                {
                    var procDef = (procedure_definition) member;
                    if (procDef.proc_header is constructor)
                    {
                        classMembers.Add(procDef);
                        continue;
                    }
                    procedure_header procHeader;
                    if (procDef.proc_header is function_header)
                    {
                        var fh = (function_header) procDef.proc_header;
                        procHeader = new function_header
                            {
                                name = new method_name(fh.name.meth_name.name),
                                source_context = fh.source_context,
                                parameters = fh.parameters,
                                of_object = fh.of_object,
                                class_keyword = fh.class_keyword
                            };
                        ((function_header)procHeader).return_type = fh.return_type;
                    }
                    else
                    {
                        procHeader = new procedure_header
                            {
                                name = new method_name(procDef.proc_header.name.meth_name.name),
                                source_context = procDef.proc_header.source_context,
                                parameters = procDef.proc_header.parameters,
                                of_object = procDef.proc_header.of_object,
                                class_keyword = procDef.proc_header.class_keyword
                            };
                    }

                    procDef.proc_header.name.class_name = cl.type_name;
                    procedures.Add(procDef);
                    classMembers.Add(procHeader);
                }
            }

            return new Tuple<type_declaration, List<procedure_definition>>(typeDeclaration, procedures);
        }