/// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="root">Корень обходимого поддерева</param>
 /// <param name="context">Контекст. Необходим для поиска переменных</param>
 /// <param name="isForNode">True при обходе цикла, False при обходе секций</param>
 public VarFinderSyntaxVisitor(syntax_tree_node root, compilation_context context, bool isForNode)
 {
     this.isForNode = isForNode;
     this.context = context;
     ProcessNode(root);
     FixResultVar();
 }
        public syntax_tree_visitor()
        {
            convertion_data_and_alghoritms = new convertion_data_and_alghoritms(this);
            
            ret = new returner(this);
            context = new compilation_context(convertion_data_and_alghoritms, this);
			contextChanger = new ContextChanger(context);
            internal_reset();
        }
Example #3
0
 public static void RemoveLambdaInfoFromCompilationContext(compilation_context context, function_lambda_definition lambdaDefinition)
 {
     if (context.converted_namespace != null
                     && context.converted_namespace.functions != null
                     && context.converted_namespace.functions.Any())
     // Если добавилось в глобальные функции, то удаляем оттуда
     {
         var lastIndex = context.converted_namespace.functions.Count - 1;
         if (context.converted_namespace.functions[lastIndex].name ==
             lambdaDefinition.lambda_name)
         {
             context.converted_namespace.functions.remove_at(lastIndex);
         }
     }
     //else SSM 27/04/16 - грубое исправление ошибки #147
     {
         // Если добавилась лямбда как метод класса, то удаляем оттуда
         if (context.converted_type != null
             && context.converted_type.methods != null
             && context.converted_type.methods.Any())
         {
             var lastIndex = context.converted_type.methods.Count - 1;
             if (context.converted_type.methods[lastIndex].name ==
                 lambdaDefinition.lambda_name)
             {
                 context.converted_type.methods.remove_at(lastIndex);
             }
         }
     }
 }
Example #4
0
 /// <summary>
 /// выдает свободное имя
 /// </summary>
 /// <param name="template">шаблон</param>
 /// <param name="StartFrom">перебирать имена, приписывая к шаблону числа начиная с этой позиции. После того как найдет - возвращает следующее число</param>
 /// <param name="context">контекст, в котором искать</param>
 /// <returns>первое свободное имя</returns>
 private static string GetFreeName(string template, ref int StartFrom, compilation_context context)
 {
     string name;
     while (context.CurrentScope.Find((name = string.Format(template + StartFrom.ToString(), StartFrom++))) != null)
         ;
     return name;
 }
		public ContextChanger(compilation_context context)
		{
			this.context = context;
            this.is_active = false;
		}
 public compilation_context(convertion_data_and_alghoritms convertion_data_and_alghoritms, syntax_tree_visitor syntax_tree_visitor)
 {
     this.convertion_data_and_alghoritms = convertion_data_and_alghoritms;
     this.syntax_tree_visitor = syntax_tree_visitor;
     _instance = this;
 }