Example #1
0
 public void SaveContext(syntax_tree_visitor syntax_tree_visitor)
 {
     converted_type = syntax_tree_visitor.context.converted_type;
     syntax_tree_visitor.context.converted_type = null;
     statement_list_stack = syntax_tree_visitor.convertion_data_and_alghoritms.statement_list_stack;
     syntax_tree_visitor.convertion_data_and_alghoritms.statement_list_stack = new statement_list_stack();
     curr_fal = syntax_tree_visitor.context.get_field_access_level();
     current_var_defs = syntax_tree_visitor.context.var_defs;
     syntax_tree_visitor.context.var_defs = new List<var_definition_node>();
     block_stack = syntax_tree_visitor.context.block_stack;
     syntax_tree_visitor.context.block_stack = new Stack<code_block>();
     cycle_stack = syntax_tree_visitor.context.CyclesStack;
     syntax_tree_visitor.context.CyclesStack = new statement_node_stack();
     current_member_decls = syntax_tree_visitor.context.member_decls;
     syntax_tree_visitor.context.member_decls = new Hashtable();
     function_node_stack = syntax_tree_visitor.context.func_stack;
     syntax_tree_visitor.context.func_stack = new common_function_node_stack();
     current_last_created_function = syntax_tree_visitor.context.last_created_function;
     SemanticRulesThrowErrorWithoutSave = SemanticRules.ThrowErrorWithoutSave;
     SemanticRules.ThrowErrorWithoutSave = true;
 }
        public void SaveContextAndUpToNearestDefSect() 
        {
            // _scope_stack вообще не трогать - он не используется !!!!!
            SavedContext = new ContextState();
            SavedContext.stlist_stack = convertion_data_and_alghoritms.statement_list_stack;
            SavedContext.cmn = _cmn;
            SavedContext.ctn = _ctn;
            SavedContext.func_stack = func_stack;
            SavedContext.block_stack = block_stack;
            SavedContext.ShortStringTypes = ShortStringTypes;
            SavedContext.var_defs = var_defs;
            SavedContext.var_defs_stack = var_defs_stack;
            SavedContext.special_local_vars = _special_local_vars;
            SavedContext.possible_incorrect_instances = possible_incorrect_instances;
            SavedContext.skip_check_where_sections = skip_check_where_sections;
            SavedContext.main_procedure = main_procedure;
            SavedContext.allow_inherited_ctor_call = allow_inherited_ctor_call;
            SavedContext.is_order_independed_method_description = is_order_independed_method_description;
            SavedContext.ctt = _ctt;
            SavedContext.compiled_tn = _compiled_tn;
            SavedContext.last_created_function = last_created_function;
            SavedContext.cycles_stack = _cycles_stack;
            SavedContext.num_of_for_cycles = num_of_for_cycles;
            SavedContext._fal = _fal;
            SavedContext.member_decls = member_decls;
            SavedContext.types_predefined = _types_predefined;
            SavedContext.ret_value = syntax_tree_visitor.ret.get_result();

            SavedContextStack.Push(SavedContext);
            // SavedContext.type_stack = type_stack;

            convertion_data_and_alghoritms.statement_list_stack = new statement_list_stack();
            //_cmn = null;
            //_ctn = null;
            //func_stack = new common_function_node_stack();
            //block_stack = new Stack<code_block>();
            ShortStringTypes = new Dictionary<int,short_string_type_node>();
            //var_defs = new List<var_definition_node>();
            //var_defs_stack = new Stack<List<var_definition_node>>();
            _special_local_vars = new List<local_variable>();
            possible_incorrect_instances = new List<type_instance_and_location>();
            skip_check_where_sections = false;
            main_procedure = null;
            allow_inherited_ctor_call = false;
            is_order_independed_method_description = false;
            _ctt = null;
            _compiled_tn = null;
		    last_created_function = null;
    	    _cycles_stack = new statement_node_stack();
            _num_of_for_cycles = 0;
            _fal = SemanticTree.field_access_level.fal_private;
            member_decls = new Hashtable();
            _types_predefined = new List<common_type_node>();
            syntax_tree_visitor.ret.return_value(null);
            // _type_stack = new Stack<common_type_node>(); 

        }