示例#1
0
 public void Clear()
 {
     symtab.Clear();
     main_ns = null;
     tree    = null;
     namespaces.Clear();
 }
示例#2
0
        public List <ICommonNamespaceFunctionNode> GetOverloadsList(ICommonNamespaceNode ns, ICommonNamespaceFunctionNode f)
        {
            List <ICommonNamespaceFunctionNode> lst = new List <ICommonNamespaceFunctionNode>();

            foreach (ICommonNamespaceFunctionNode m in ns.functions)
            {
                if (string.Compare(m.name, f.name, true) == 0)
                {
                    lst.Add(m);
                }
            }
            return(lst);
        }
示例#3
0
 internal void SetSemanticTree(IProgramNode tree)
 {
     this.tree = tree;
     if (tree != null)
     {
         foreach (ICommonNamespaceNode cnn in tree.namespaces)
         {
             if (string.Compare(cnn.namespace_name, Name, true) == 0)
             {
                 main_ns = cnn;
                 namespaces.Add(cnn);
                 break;
             }
         }
     }
 }
 public virtual void visit(ICommonNamespaceNode value)
 {
 }
示例#5
0
 private void MakeAttribute(ICommonNamespaceNode cnn)
 {
     IAttributeNode[] attrs = cnn.Attributes;
     for (int i = 0; i < attrs.Length; i++)
     {
         CustomAttributeBuilder cab = new CustomAttributeBuilder
             ((attrs[i].AttributeConstructor is ICompiledConstructorNode) ? (attrs[i].AttributeConstructor as ICompiledConstructorNode).constructor_info : helper.GetConstructor(attrs[i].AttributeConstructor).cnstr, get_constants(attrs[i].Arguments),
             get_named_properties(attrs[i].PropertyNames), get_constants(attrs[i].PropertyInitializers),
             get_named_fields(attrs[i].FieldNames), get_constants(attrs[i].FieldInitializers));
         ab.SetCustomAttribute(cab);
     }
 }
示例#6
0
 public void set_ns(int i)
 {
     main_ns = namespaces[i];
 }
示例#7
0
 public void visit(ICommonNamespaceNode value)
 {
     string s = value.GetType().Name + ".";
     prepare_string_node(value.namespace_name, s + "namespace_name");
     //prepare_node(value.comprehensive_namespace, s + "comprehensive_namespace");                         
     prepare_base_node_collection(value.constants, s + "constants", "constants", value.constants.Length);
     prepare_base_node_collection(value.functions, s + "functions", "functions", value.functions.Length);
     prepare_base_node_collection(value.nested_namespaces, s + "nested_namespaces", "nested_namespaces", value.nested_namespaces.Length);
     prepare_base_node_collection(value.types, s + "types", "types", value.types.Length);
     prepare_base_node_collection(value.variables, s + "variables", "variables", value.variables.Length);
 }
示例#8
0
		public virtual void visit(ICommonNamespaceNode value)
		{
		}
示例#9
0
        public void visit(IProgramNode value)
        {
            StringBuilder bodyBlock = new StringBuilder("");
            string currNamespace = "";

            // обнуляем отступ тела блокаame
            ISemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBodyDecrement();                                                 

            if (value.main_function != null)
                value.main_function.visit(this);
            mainFunction = ISemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBody + ISemanticNodeConverter.SourceTextBuilder.GetNodeFromStack();
                        
            // перед входом в блок ув. отступ
            //SemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBodyIncrement();
            mainNamespace = value.main_function.comprehensive_namespace;
            string outdir = System.IO.Path.GetDirectoryName(mainNamespace.Location.document.file_name);
            foreach (ICommonNamespaceNode nodeNamespace in value.namespaces)
            {
                nodeNamespace.visit(this);
                bodyBlock.Append(ISemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBody);
                currNamespace = ISemanticNodeConverter.SourceTextBuilder.GetNodeFromStack();
                bodyBlock.Append(currNamespace);                                                               
                if (value.namespaces[value.namespaces.Length-1] != nodeNamespace)
                    bodyBlock.Append(System.Environment.NewLine);
                string name = nodeNamespace.namespace_name.Replace('$', 'S');
                if (name == "")
                    name = System.IO.Path.GetFileNameWithoutExtension(mainNamespace.Location.document.file_name);
                SaveTextInFile(outdir + "\\" +name+".cs", currNamespace, false);
                nmspaceFiles.Add(outdir + "\\" + name + ".cs");
            }
            //bodyBlock.Append(mainFunctionNode);
            ISemanticNodeConverter.SourceTextBuilder.AddNodeInToStack(bodyBlock.ToString());
            ISemanticNodeConverter.SourceTextBuilder.AddNodeInToStack(ISemanticNodeConverter.ConvertPABCNETNodeProgram("program", value));
        }
示例#10
0
        public void visit(ICommonNamespaceNode value)
        {
            //value.Location.document.file_name
            StringBuilder bodyBlock = new StringBuilder("");
            // увеличиваем отступ тела блока перед входом в блок
            ISemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBodyIncrement();
            //bodyBlock.Append(SemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBody);

            // если находимся в главном namespace программы, добваляем main в body
            if (mainNamespace == value)
            {
                bodyBlock.Append(System.Environment.NewLine);
                bodyBlock.Append(ISemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBody);
                bodyBlock.Append(mainFunction);
                //SemanticNodeConverter.SourceTextBuilder.AddNodeInToStack(mainFunctionNode);     
            }  
            foreach (ICommonNamespaceNode nodeNamespace in value.nested_namespaces)
            {
                nodeNamespace.visit(this);
                bodyBlock.Append(ISemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBody);
                bodyBlock.Append(ISemanticNodeConverter.SourceTextBuilder.GetNodeFromStack());
                //if (value.nested_namespaces[value.nested_namespaces.Length - 1] != nodeNamespace)
                    bodyBlock.Append(System.Environment.NewLine);                
            }   
            //
            foreach (ICommonTypeNode types in value.types)
            {
                types.visit(this);
                bodyBlock.Append(ISemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBody);
                bodyBlock.Append(ISemanticNodeConverter.SourceTextBuilder.GetNodeFromStack());
                //if (value.types[value.types.Length - 1] != types)
                    bodyBlock.Append(System.Environment.NewLine);
                
            }
            foreach (ICommonNamespaceVariableNode var in value.variables)
            {
                var.visit(this);
                bodyBlock.Append(ISemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBody);
                bodyBlock.Append(ISemanticNodeConverter.SourceTextBuilder.GetNodeFromStack());
                bodyBlock.Append(";");
                //if (value.variables[value.variables.Length - 1] != var)
                    bodyBlock.Append(System.Environment.NewLine);
            }            
            foreach (ICommonNamespaceFunctionNode functions in value.functions)
            {
                functions.visit(this);
                bodyBlock.Append(ISemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBody);
                bodyBlock.Append(ISemanticNodeConverter.SourceTextBuilder.GetNodeFromStack());
                //bodyBlock.Append(";");
                bodyBlock.Append(System.Environment.NewLine);
            }
            foreach (INamespaceConstantDefinitionNode constants in value.constants)
            {
                constants.visit(this);
                bodyBlock.Append(ISemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBody);
                bodyBlock.Append(ISemanticNodeConverter.SourceTextBuilder.GetNodeFromStack());
                 bodyBlock.Append(";");
                bodyBlock.Append(System.Environment.NewLine);
            }             

            ISemanticNodeConverter.SourceTextBuilder.AddNodeInToStack(bodyBlock.ToString());
            // уменьшаем отступ тела блока перед выходом из блока            
            ISemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBodyDecrement();
            ISemanticNodeConverter.SourceTextBuilder.AddNodeInToStack(ISemanticNodeConverter.ConvertPABCNETNodeNamespace("namespace", value));
            
        }