Exemplo n.º 1
0
		public expression_node visit(SyntaxTree.expression expr)
		{
            expr.visit(syntax_tree_visitor);

            /*addressed_expression ad = ret_semantic as addressed_expression;
            if (ad != null && ad.is_addressed)
            {
                if (convertion_data_and_alghoritms.check_for_constant(ad))
                    ad.is_addressed = false;
            }*/

            //Надеюсь, это сильно не скажется на производительности, хотя в другом случае этот же код просто будет разбросан по всем метдам syntax_tree_visitor-а.
            base_function_call bfc = ret_semantic as base_function_call;
            if (bfc != null)
            {
                if (bfc.simple_function_node.compile_time_executor != null)
                {
                    expression_node ex = bfc.simple_function_node.compile_time_executor(bfc.location, bfc.parameters.ToArray());
                    if (ex != null)
                    {
                        return ex;
                    }
                }
            }

            return ret_semantic as expression_node;
		}
        public void hard_node_test_and_visit(SyntaxTree.syntax_tree_node tn)
        {
#if (DEBUG)
//            try
//            {
                if (tn == null)
                {
                    throw new CompilerInternalError("This node can not be null");
                }
#endif
                convertion_data_and_alghoritms.check_node_parser_error(tn);
                if (is_direct_type_decl && !(tn is SyntaxTree.ref_type))
                    is_direct_type_decl = false;
                tn.visit(this);
/*#if (DEBUG)
            }
            catch (Exception e)
            {
                if (tn != null)
                    throw new Exception("" + tn.source_context.ToString() + System.Environment.NewLine + e.ToString());
                else throw e;
            }
#endif*/
        }
 public void weak_node_test_and_visit(SyntaxTree.syntax_tree_node tn)
 {
     if (tn != null)
     {
         convertion_data_and_alghoritms.check_node_parser_error(tn);
         tn.visit(this);
     }
 }
        //TODO: Исправить коллекцию модулей.
        public PascalABCCompiler.TreeRealization.common_unit_node CompileInterface(SyntaxTree.compilation_unit SyntaxUnit,
            PascalABCCompiler.TreeRealization.unit_node_list UsedUnits, List<Errors.Error> ErrorsList, List<Errors.CompilerWarning> WarningsList, PascalABCCompiler.Errors.SyntaxError parser_error,
            System.Collections.Hashtable bad_nodes, TreeRealization.using_namespace_list namespaces, Dictionary<SyntaxTree.syntax_tree_node,string> docs, bool debug, bool debugging)
		{
            //convertion_data_and_alghoritms.__i = 0;
			stv.parser_error=parser_error;
            stv.bad_nodes_in_syntax_tree = bad_nodes;
			stv.referenced_units=UsedUnits;
			//stv.comp_units=UsedUnits;
			//stv.visit(SyntaxUnit
            //stv.interface_using_list = namespaces;
            stv.using_list.clear();
            stv.interface_using_list.clear();
            stv.using_list.AddRange(namespaces);
            stv.current_document = new TreeRealization.document(SyntaxUnit.file_name);
            stv.ErrorsList = ErrorsList;
            stv.WarningsList = WarningsList;
            stv.SymbolTable.CaseSensitive = SemanticRules.SymbolTableCaseSensitive;
            stv.docs = docs;
            stv.debug = debug;
            stv.debugging = debugging;
			SystemLibrary.SystemLibrary.syn_visitor = stv;
            SetSemanticRules(SyntaxUnit);
            

            foreach (SyntaxTree.compiler_directive cd in SyntaxUnit.compiler_directives)
                cd.visit(stv);

            stv.DirectivesToNodesLinks = CompilerDirectivesToSyntaxTreeNodesLinker.BuildLinks(SyntaxUnit, ErrorsList);  //MikhailoMMX добавил передачу списка ошибок (02.10.10)

            SyntaxUnit.visit(stv);
			/*SyntaxTree.program_module pmod=SyntaxUnit as SyntaxTree.program_module;
			if (pmod!=null)
			{
				stv.visit(pmod);
			}
			else
			{
				SyntaxTree.unit_module umod=SyntaxUnit as SyntaxTree.unit_module;
				if (umod==null)
				{
					throw new PascalABCCompiler.TreeConverter.CompilerInternalError("Undefined module type (not program and not unit)");
				}
				stv.visit(umod);
			}*/
			//stv.visit(SyntaxUnit);
			//if (ErrorsList.Count>0) throw ErrorsList[0];
			return stv.compiled_unit;
		}
Exemplo n.º 5
0
		public addressed_expression visit(SyntaxTree.addressed_value av)
		{
            av.visit(syntax_tree_visitor);
            return ret_semantic as addressed_expression;
		}
Exemplo n.º 6
0
		public type_node visit(SyntaxTree.type_definition type_def)
		{
            type_def.visit(syntax_tree_visitor);
            return ret_semantic as type_node;
		}
Exemplo n.º 7
0
		public statement_node visit(SyntaxTree.statement st)
		{
            st.visit(syntax_tree_visitor);
            return ret_semantic as statement_node;
		}
Exemplo n.º 8
0
		public semantic_node visit(SyntaxTree.syntax_tree_node tn)
		{
            tn.visit(syntax_tree_visitor);
            return ret_semantic;
		}