コード例 #1
0
ファイル: statements.cs プロジェクト: shusha1311/pascalabcnet
 /// <summary>
 /// Конструктор класса.
 /// </summary>
 /// <param name="condition">Условие.</param>
 /// <param name="then_body">Тело then.</param>
 /// <param name="else_body">Тело else.</param>
 /// <param name="loc">Расположение узла.</param>
 public if_node(expression_node condition, statement_node then_body, statement_node else_body, location loc) :
     base(loc)
 {
     _condition = condition;
     _then_body = then_body;
     _else_body = else_body;
 }
コード例 #2
0
ファイル: statements.cs プロジェクト: shusha1311/pascalabcnet
 public exception_filter(type_node filter_type, local_block_variable_reference exception_var,
                         statement_node exception_handler, location loc) : base(loc)
 {
     _filter_type       = filter_type;
     _exception_var     = exception_var;
     _exception_handler = exception_handler;
 }
コード例 #3
0
ファイル: statements.cs プロジェクト: shusha1311/pascalabcnet
 public try_block(statement_node try_statements, statement_node finally_statements,
                  exception_filters_list filters, location loc)
     : base(loc)
 {
     _try_statements     = try_statements;
     _finally_statements = finally_statements;
     _filters            = filters;
 }
コード例 #4
0
ファイル: statements.cs プロジェクト: shusha1311/pascalabcnet
 /// <summary>
 /// Конструктор клааса.
 /// </summary>
 /// <param name="initialization_statement">Выражение инициализации переменной цикла.</param>
 /// <param name="while_expr">Условие цикла.</param>
 /// <param name="increment_statement">Выражение измененияя счетчика цикла.</param>
 /// <param name="body">Тело цикла.</param>
 public for_node(statement_node initialization_statement, expression_node while_expr, expression_node init_while_expr,
                 statement_node increment_statement, statement_node body, location loc) : base(loc)
 {
     _initialization_statement = initialization_statement;
     _while_expr          = while_expr;
     _init_while_expr     = init_while_expr;
     _increment_statement = increment_statement;
     _body = body;
 }
コード例 #5
0
ファイル: block_info.cs プロジェクト: lisiynos/pascalabcnet
 public void reset()
 {
     _cmn = null;
     _ctn = null;
     _func_stack.clear();
     var_defs.Clear();
     _main_procedure = null;
     _last_created_function = null;
     _cycles_stack.clear();
     _num_of_for_cycles = 0;
     _fal = SemanticTree.field_access_level.fal_private;
     rec_num = 1;
     var_defs_stack.Clear();
     type_stack.Clear();
     clear_special_local_vars();
     _scope_stack.Clear();
 }
コード例 #6
0
ファイル: statements.cs プロジェクト: shusha1311/pascalabcnet
 /// <summary>
 /// Конструктор узла.
 /// </summary>
 /// <param name="body">Тело цикла.</param>
 /// <param name="condition">Условие.</param>
 /// <param name="loc">Расположение узла.</param>
 public repeat_node(statement_node body, expression_node condition, location loc) : base(loc)
 {
     _body      = body;
     _condition = condition;
 }
コード例 #7
0
ファイル: statements.cs プロジェクト: shusha1311/pascalabcnet
 /// <summary>
 /// Конструктор класса.
 /// </summary>
 /// <param name="condition">Условие цикла.</param>
 /// <param name="body">Тело цикла.</param>
 /// <param name="loc">Расположение узла.</param>
 public while_node(expression_node condition, statement_node body, location loc) : base(loc)
 {
     _condition = condition;
     _body      = body;
 }
コード例 #8
0
ファイル: statements.cs プロジェクト: lisiynos/pascalabcnet
 public try_block(statement_node try_statements, statement_node finally_statements,
     exception_filters_list filters, location loc)
     : base(loc)
 {
     _try_statements = try_statements;
     _finally_statements = finally_statements;
     _filters = filters;
 }
コード例 #9
0
ファイル: statements.cs プロジェクト: shusha1311/pascalabcnet
 public lock_statement(expression_node _lock_object, statement_node _body, location loc)
     : base(loc)
 {
     this._lock_object = _lock_object;
     this._body        = _body;
 }
コード例 #10
0
ファイル: statements.cs プロジェクト: lisiynos/pascalabcnet
 public lock_statement(expression_node _lock_object, statement_node _body, location loc)
     : base(loc)
 {
     this._lock_object = _lock_object;
     this._body = _body;
 }
コード例 #11
0
 //Возвращение конвертированного поддерева.
 private void return_value(statement_node stat)
 {
     ret.return_value(stat);
 }
コード例 #12
0
 private statements_list get_statements_list(statement_node sn)
 {
     statements_list snl = sn as statements_list;
     if (snl != null)
     {
         return snl;
     }
     snl = new statements_list(null);
     snl.statements.AddElement(sn);
     return snl;
 }
コード例 #13
0
 public labeled_statement(label_node v_label, statement_node v_statement, location v_location)
     : base(v_location)
 {
     _label     = v_label;
     _statement = v_statement;
 }
コード例 #14
0
ファイル: labels.cs プロジェクト: CSRedRat/pascalabcnet
 public labeled_statement(label_node v_label, statement_node v_statement, location v_location)
     : base(v_location)
 {
     _label = v_label;
     _statement = v_statement;
 }
コード例 #15
0
ファイル: OpenMP.cs プロジェクト: lisiynos/pascalabcnet
        private static bool GenerateOMPParallelForCall(statement_node body, SyntaxTree.for_node for_node, var_definition_node loop_variable, statements_list omp_stmts, syntax_tree_visitor syntax_tree_visitor, expression_node fromInclusive, expression_node toInclusive)
        {
            SyntaxTree.statement syntax_body = for_node.statements;

            expression_node omp_call = null;
            base_function_call bfc = body as base_function_call;
            if (bfc != null && bfc.parameters.Count == 1 && bfc.parameters[0] is variable_reference &&
                ((variable_reference)bfc.parameters[0]).VariableDefinition == loop_variable && ((bfc.function.parameters[0].type as type_node).PrintableName.ToLower() == "integer"))
            {
                //если тело цикла - вызов функции с одни параметром - переменной цикла,
                //если при этом у вызываемой функции тип параметра - integer, а не какой-нибудь object, как это бывает с write и вообще может быть с перегрузкой
                //то генерировать класс не надо.
                //генерируем вызов и все
                omp_call = syntax_tree_visitor.CreateDelegateCall(bfc);
                if (omp_call == null)
                {
                    syntax_tree_visitor.AddWarning(new OMP_ConstructionNotSupportedNow(body.location));
                    syntax_tree_visitor.convertion_data_and_alghoritms.statement_list_stack_pop();
                    return false;
                }
                base_function_call omp_parallel_for_call = null;
                if (SystemLibrary.SystemLibInitializer.OMP_ParallelFor.sym_info is common_namespace_function_node)
                    omp_parallel_for_call = new common_namespace_function_call(SystemLibrary.SystemLibInitializer.OMP_ParallelFor.sym_info as common_namespace_function_node, body.location);
                else
                    omp_parallel_for_call = new compiled_static_method_call(SystemLibrary.SystemLibInitializer.OMP_ParallelFor.sym_info as compiled_function_node, body.location);
                omp_parallel_for_call.parameters.AddElement(fromInclusive);
                omp_parallel_for_call.parameters.AddElement(toInclusive);
                omp_parallel_for_call.parameters.AddElement(omp_call);
                omp_stmts.statements.AddElement(omp_parallel_for_call);
            }
            else
            {
                //ищем используемые переменные, получаем редукцию из директивы и составляем список переменных по типам
                VarFinderSyntaxVisitor VFvis = new VarFinderSyntaxVisitor(syntax_body, syntax_tree_visitor.context, true);
                SyntaxTree.compiler_directive dir = syntax_tree_visitor.DirectivesToNodesLinks[for_node];
                //if (DirInfosTable[dir].ErrorName == "WARNING_IN_CLAUSE_PARAMETERS_REPEATED_VARS")
                //    syntax_tree_visitor.AddWarning(new Errors.CommonWarning(StringResources.Get(DirInfosTable[dir].ErrorName), for_node.source_context.FileName, DirInfosTable[dir].SC.begin_position.line_num, DirInfosTable[dir].SC.begin_position.column_num));
                //else if (DirInfosTable[dir].ErrorName == "ERROR_IN_CLAUSE_PARAMETERS")
                //{
                //    syntax_tree_visitor.AddWarning(new Errors.CommonWarning(StringResources.Get(DirInfosTable[dir].ErrorName), for_node.source_context.FileName, DirInfosTable[dir].SC.begin_position.line_num, DirInfosTable[dir].SC.begin_position.column_num));
                //}
                //else
               
                if (DirInfosTable[dir].ErrorName !=null)//== "ERROR_IN_CLAUSE")
                {
                    syntax_tree_visitor.AddWarning(new Errors.CommonWarning(PascalABCCompiler.StringResources.Get(DirInfosTable[dir].ErrorName), for_node.source_context.FileName, DirInfosTable[dir].SC.begin_position.line_num, DirInfosTable[dir].SC.begin_position.column_num));
                }

                VarInfoContainer Vars = GetVarInfoContainer(VFvis, DirInfosTable[dir].Reductions, DirInfosTable[dir].Privates, syntax_tree_visitor, dir);

                //сохраняем контекст
                ContextInfo contextInfo = new ContextInfo(syntax_tree_visitor);

                string ClassName = syntax_tree_visitor.context.get_free_name("$for_class{0}");

                try
                {
                    //создаем и конвертируем класс
                    SyntaxTree.class_members member;
                    SyntaxTree.type_declarations Decls = CreateClass(ClassName, out member, Vars);
                    member.members.Add(CreateMethod("Method", syntax_body, for_node.loop_variable.name, member, Vars));
                    syntax_tree_visitor.visit(Decls);
                }
                finally
                {
                    //восстанавливаем контекст
                    contextInfo.RestoreContext(syntax_tree_visitor);
                }

                //создаем инициализацию, вызов и финализацию
                string ObjName = syntax_tree_visitor.context.get_free_name("$for_obj{0}");

                SyntaxTree.dot_node dn = new SyntaxTree.dot_node(new SyntaxTree.ident(ObjName), new SyntaxTree.ident("Method"));

                SyntaxTree.statement_list stl = CreateInitPart(ClassName, ObjName, Vars);
                stl.subnodes.Add(CreateNestedRegionBorder(true));
                stl.subnodes.Add(CreateOMPParallelForCall(dn, for_node.initial_value, for_node.finish_value));
                stl.subnodes.Add(CreateNestedRegionBorder(false));
                stl.subnodes.AddRange(CreateFinalPart(ObjName, Vars).subnodes);
                omp_stmts.statements.AddElement(syntax_tree_visitor.ret.visit(stl));
            }
            return true;
        }
コード例 #16
0
ファイル: statements.cs プロジェクト: lisiynos/pascalabcnet
        /// <summary>
        /// Конструктор клааса.
        /// </summary>
        /// <param name="initialization_statement">Выражение инициализации переменной цикла.</param>
        /// <param name="while_expr">Условие цикла.</param>
        /// <param name="increment_statement">Выражение измененияя счетчика цикла.</param>
        /// <param name="body">Тело цикла.</param>
		public for_node(statement_node initialization_statement,expression_node while_expr, expression_node init_while_expr,
			statement_node increment_statement,statement_node body, location loc) : base(loc)
		{
			_initialization_statement=initialization_statement;
			_while_expr=while_expr;
			_init_while_expr = init_while_expr;
			_increment_statement=increment_statement;
			_body=body;
		}
コード例 #17
0
ファイル: statements.cs プロジェクト: lisiynos/pascalabcnet
        /// <summary>
        /// Конструктор узла.
        /// </summary>
        /// <param name="body">Тело цикла.</param>
        /// <param name="condition">Условие.</param>
        /// <param name="loc">Расположение узла.</param>
		public repeat_node(statement_node body,expression_node condition, location loc) : base(loc)
		{
			_body=body;
			_condition=condition;
		}
コード例 #18
0
ファイル: statements.cs プロジェクト: lisiynos/pascalabcnet
        /// <summary>
        /// Конструктор класса.
        /// </summary>
        /// <param name="condition">Условие цикла.</param>
        /// <param name="body">Тело цикла.</param>
        /// <param name="loc">Расположение узла.</param>
		public while_node(expression_node condition,statement_node body,location loc) : base(loc)
		{
			_condition=condition;
			_body=body;
		}
コード例 #19
0
ファイル: statements.cs プロジェクト: lisiynos/pascalabcnet
        /// <summary>
        /// Конструктор класса.
        /// </summary>
        /// <param name="condition">Условие.</param>
        /// <param name="then_body">Тело then.</param>
        /// <param name="else_body">Тело else.</param>
        /// <param name="loc">Расположение узла.</param>
		public if_node(expression_node condition,statement_node then_body,statement_node else_body,location loc) :
            base(loc)
		{
			_condition=condition;
			_then_body=then_body;
			_else_body=else_body;
		}
コード例 #20
0
		private void VisitStatement(statement_node sn)
		{
			if (sn is expression_node)
			{
				VisitExpression((expression_node)sn);
                WriteDebugInfo(sn.location);
				return;
			}
			bw.Write((byte)sn.semantic_node_type);
			switch (sn.semantic_node_type) {
				case semantic_node_type.if_node : VisitIf((if_node)sn); break;
				case semantic_node_type.while_node : VisitWhile((while_node)sn); break;
				case semantic_node_type.repeat_node : VisitRepeat((repeat_node)sn); break;
				case semantic_node_type.for_node : VisitFor((for_node)sn); break;
				case semantic_node_type.statements_list : VisitStatementList((statements_list)sn); break;
				case semantic_node_type.empty_statement : VisitEmpty((empty_statement)sn); break;
				case semantic_node_type.return_node : VisitReturnNode((return_node)sn); break;
                case semantic_node_type.switch_node : VisitSwitchNode((switch_node)sn); break;
                case semantic_node_type.external_statement_node: VisitExternalStatementNode((external_statement)sn); break;
                case semantic_node_type.throw_statement: VisitThrow((throw_statement_node)sn); break;
                case semantic_node_type.runtime_statement: VisitRuntimeStatement((runtime_statement)sn); break;
                case semantic_node_type.try_block: VisitTryBlock((try_block)sn); break;
                case semantic_node_type.labeled_statement: VisitLabeledStatement((labeled_statement)sn); break;
                case semantic_node_type.goto_statement: VisitGoto((goto_statement)sn); break;
                case semantic_node_type.foreach_node: VisitForeach((foreach_node)sn); break;
                case semantic_node_type.lock_statement: VisitLock((lock_statement)sn); break;
                case semantic_node_type.rethrow_statement: VisitRethrow((rethrow_statement_node)sn); break;
                case semantic_node_type.pinvoke_node : VisitPInvokeStatement((pinvoke_statement)sn); break;
                
            }
		    WriteDebugInfo(sn.location);
		}
コード例 #21
0
ファイル: statements.cs プロジェクト: lisiynos/pascalabcnet
 public exception_filter(type_node filter_type, local_block_variable_reference exception_var,
     statement_node exception_handler, location loc) : base(loc)
 {
     _filter_type = filter_type;
     _exception_var = exception_var;
     _exception_handler = exception_handler;
 }
コード例 #22
0
 private statements_list add_last_statement(statement_node list, statement_node statement)
 {
     statements_list snl = get_statements_list(list);
     snl.statements.AddElement(statement);
     return snl;
 }
コード例 #23
0
ファイル: statements.cs プロジェクト: shusha1311/pascalabcnet
 public foreach_node(var_definition_node _ident, expression_node _in_what, statement_node _what_do, location loc) : base(loc)
 {
     this._ident   = _ident;
     this._in_what = _in_what;
     this._what_do = _what_do;
 }
コード例 #24
0
ファイル: functions.cs プロジェクト: Slav76/pascalabcnet
 /// <summary>
 /// Конструктор узла.
 /// </summary>
 /// <param name="ret_type">Тип возвращаемого значения функции.</param>
 public function_lambda_node(parameter_list parameters, type_node ret_type, statement_node body)
 {
     _parameters = parameters;
     _ret_type = ret_type;
     _body = body;
 }
コード例 #25
0
ファイル: statements.cs プロジェクト: lisiynos/pascalabcnet
 public foreach_node(var_definition_node _ident, expression_node _in_what, statement_node _what_do, location loc):base(loc)
 {
     this._ident = _ident;
     this._in_what = _in_what;
     this._what_do = _what_do;
 }
コード例 #26
0
ファイル: Optimizer.cs プロジェクト: lisiynos/pascalabcnet
 private void VisitStatement(statement_node sn)
 {
     if (sn == null) return;
     if (!(sn is statements_list) && is_break_stmt)
     {
         warns.Add(new UnreachableCodeDetected(sn.location));
         is_break_stmt = false;
     }
     if (sn is expression_node)
     {
         VisitExpression((expression_node)sn);
        
         return;
     }
     switch (sn.semantic_node_type)
     {
         case semantic_node_type.if_node: VisitIf((if_node)sn); break;
         case semantic_node_type.while_node: VisitWhile((while_node)sn); break;
         case semantic_node_type.repeat_node: VisitRepeat((repeat_node)sn); break;
         case semantic_node_type.for_node: VisitFor((for_node)sn); break;
         case semantic_node_type.statements_list: VisitStatementList((statements_list)sn); break;
         case semantic_node_type.empty_statement: VisitEmpty((empty_statement)sn); break;
         case semantic_node_type.return_node: VisitReturnNode((return_node)sn); break;
         case semantic_node_type.switch_node: VisitSwitchNode((switch_node)sn); break;
         case semantic_node_type.external_statement_node: VisitExternalStatementNode((external_statement)sn); break;
         case semantic_node_type.pinvoke_node: VisitPInvokeStatementNode((pinvoke_statement)sn); break;
         case semantic_node_type.throw_statement: VisitThrow((throw_statement_node)sn); break;
         case semantic_node_type.runtime_statement: VisitRuntimeStatement((runtime_statement)sn); break;
         case semantic_node_type.try_block: VisitTryBlock((try_block)sn); break;
         case semantic_node_type.labeled_statement: VisitLabeledStatement((labeled_statement)sn); break;
         case semantic_node_type.goto_statement: VisitGoto((goto_statement)sn); break;
         case semantic_node_type.foreach_node: VisitForeach((foreach_node)sn); break;
         case semantic_node_type.lock_statement: VisitLockStatement((lock_statement)sn); break;
     }
    
 }
コード例 #27
0
 public void reset()
 {
     _cmn = null;
     _ctn = null;
     _func_stack.clear();
     var_defs.Clear();
     _main_procedure = null;
     _last_created_function = null;
     _cycles_stack.clear();
     _num_of_for_cycles = 0;
     _fal = SemanticTree.field_access_level.fal_private;
     rec_num = 1;
     var_defs_stack.Clear();
     type_stack.Clear();
     clear_special_local_vars();
     _scope_stack.Clear();
     TypedFiles.Clear();
     ShortStringTypes.Clear();
     TypedSets.Clear();
     _compiled_tn = null;
     _explicit_interface_type = null;
     _ctt = null;
     allow_inherited_ctor_call = false;
     _types_predefined.Clear();
     _block_stack.Clear();
     member_decls.Clear();
     possible_incorrect_instances.Clear();
     skip_check_where_sections = false;
     LambdaHelper.Reset(); //lroman//
     SavedContext = null;
     SavedContextStack.Clear();
     compiled_tc_cache.Clear();
     extension_method = false;
     _last_created_function = null;
     in_parameters_block = false;
     is_order_independed_method_description = false;
     
 }