// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
namespace PascalABCCompiler.TreeRealization
{
///
/// Пустое выражение.
///
[Serializable]
public class empty_statement : statement_node
{
///
/// Конструктор узла.
///
/// Расположение узла.
public empty_statement(location loc) : base(loc)
{
}
///
/// Тип выржения.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.empty_statement;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
}
[Serializable]
public class wrapped_statement : statement_node
{
///
/// Конструктор узла.
///
/// Расположение узла.
public wrapped_statement(location loc)
: base(loc)
{
}
///
/// Тип выржения.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.wrapped_statement;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
public virtual statement_node restore()
{
return null;
}
}
[Serializable]
public class runtime_statement : statement_node, SemanticTree.IRuntimeManagedMethodBody
{
private SemanticTree.runtime_statement_type _rts;
public runtime_statement(SemanticTree.runtime_statement_type rts,location loc) :base(loc)
{
_rts = rts;
}
public SemanticTree.runtime_statement_type runtime_statement_type
{
get
{
return _rts;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.runtime_statement;
}
}
}
//TODO: Луше сделать специальный вид функции.
///
/// Обращение к методу в неуправляемой dll.
///
[Serializable]
public class external_statement : statement_node, SemanticTree.IExternalStatementNode
{
///
/// Имя dll.
///
private string _module_name;
///
/// Имя метода.
///
private string _name;
///
/// Конструктор узла.
///
/// Имя dll.
/// Имя метода.
/// Расположение выражения.
public external_statement(string _module_name, string _name, location loc) : base(loc)
{
this._module_name = _module_name;
this._name = _name;
}
///
/// Имя dll.
///
public string module_name
{
get
{
return _module_name;
}
}
///
/// Имя метода.
///
public string name
{
get
{
return _name;
}
set
{
_name = value;
}
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.external_statement_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
}
[Serializable]
public class pinvoke_statement : statement_node, SemanticTree.IPInvokeStatementNode
{
public pinvoke_statement(location loc) : base(loc)
{
}
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.pinvoke_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
}
///
/// Класс, представляющий узел if в программе.
///
[Serializable]
public class if_node : statement_node, SemanticTree.IIfNode
{
///
/// Условие.
///
private expression_node _condition;
///
/// Тело then.
///
private statement_node _then_body;
///
/// Тело else.
///
private statement_node _else_body;
///
/// Конструктор класса.
///
/// Условие.
/// Тело then.
/// Тело else.
/// Расположение узла.
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;
}
///
/// Условие.
///
public expression_node condition
{
get
{
return _condition;
}
}
///
/// Тело then.
///
public statement_node then_body
{
get
{
return _then_body;
}
set
{
_then_body = value;
}
}
///
/// Тело else. Если if без then это свойство = null.
///
public statement_node else_body
{
get
{
return _else_body;
}
set
{
_else_body = value;
}
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.if_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
SemanticTree.IStatementNode SemanticTree.IIfNode.else_body
{
get
{
return _else_body;
}
}
SemanticTree.IExpressionNode SemanticTree.IIfNode.condition
{
get
{
return _condition;
}
}
SemanticTree.IStatementNode SemanticTree.IIfNode.then_body
{
get
{
return _then_body;
}
}
}
///
/// Класс, представляющий узел while в программе.
///
[Serializable]
public class while_node : statement_node, SemanticTree.IWhileNode
{
///
/// Условие цикла.
///
private expression_node _condition;
///
/// Тело цикла.
///
private statement_node _body;
///
/// Конструктор класса.
///
/// Условие цикла.
/// Расположение узла.
public while_node(expression_node condition, location loc)
: base(loc)
{
_condition = condition;
}
///
/// Конструктор класса.
///
/// Условие цикла.
/// Тело цикла.
/// Расположение узла.
public while_node(expression_node condition,statement_node body,location loc) : base(loc)
{
_condition=condition;
_body=body;
}
///
/// Условие цикла.
///
public expression_node condition
{
get
{
return _condition;
}
}
//Тело while.
public statement_node body
{
get
{
return _body;
}
set
{
_body = value;
}
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.while_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
SemanticTree.IExpressionNode SemanticTree.IWhileNode.condition
{
get
{
return _condition;
}
}
SemanticTree.IStatementNode SemanticTree.IWhileNode.body
{
get
{
return _body;
}
}
}
///
/// Класс, представляющий узел repeat в программе.
///
[Serializable]
public class repeat_node : statement_node, SemanticTree.IRepeatNode
{
///
/// Тело цикла.
///
private statement_node _body;
///
/// Условие цикла.
///
private expression_node _condition;
///
/// Конструктор узла.
///
/// Расположение узла.
public repeat_node(location loc)
: base(loc)
{
}
///
/// Конструктор узла.
///
/// Тело цикла.
/// Условие.
/// Расположение узла.
public repeat_node(statement_node body,expression_node condition, location loc) : base(loc)
{
_body=body;
_condition=condition;
}
///
/// Тело цикла.
///
public statement_node body
{
get
{
return _body;
}
set
{
_body = value;
}
}
///
/// Условие цикла.
///
public expression_node condition
{
get
{
return _condition;
}
set
{
_condition = value;
}
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.repeat_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
SemanticTree.IExpressionNode SemanticTree.IRepeatNode.condition
{
get
{
return _condition;
}
}
SemanticTree.IStatementNode SemanticTree.IRepeatNode.body
{
get
{
return _body;
}
}
}
///
/// Узел цикла for.
///
[Serializable]
public class for_node : statement_node, SemanticTree.IForNode
{
///
/// Выражение инициализации переменной цикла.
///
private statement_node _initialization_statement;
///
/// Условие цикла
///
private expression_node _while_expr;
private expression_node _init_while_expr;
///
/// Выражение измененияя счетчика цикла.
///
private statement_node _increment_statement;
///
/// Тело цикла.
///
private statement_node _body;
private bool _bool_cycle;
///
/// Конструктор клааса.
///
/// Выражение инициализации переменной цикла.
/// Условие цикла.
/// Выражение измененияя счетчика цикла.
/// Тело цикла.
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;
}
///
/// Выражение инициализации переменной цикла.
///
public statement_node initialization_statement
{
get
{
return _initialization_statement;
}
set
{
_increment_statement = value;
}
}
///
/// Условие продолжения цикла.
///
public expression_node while_expr
{
get
{
return _while_expr;
}
set
{
_while_expr = value;
}
}
public expression_node init_while_expr
{
get
{
return _init_while_expr;
}
set
{
_init_while_expr = value;
}
}
///
/// Изменение счетчиков цикла.
///
public statement_node increment_statement
{
get
{
return _increment_statement;
}
set
{
_increment_statement = value;
}
}
///
/// Тело цикла.
///
public statement_node body
{
get
{
return _body;
}
set
{
_body = value;
}
}
public bool bool_cycle
{
get
{
return _bool_cycle;
}
set
{
_bool_cycle = value;
}
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.for_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
SemanticTree.IStatementNode SemanticTree.IForNode.initialization_statement
{
get
{
return _initialization_statement;
}
}
SemanticTree.IStatementNode SemanticTree.IForNode.body
{
get
{
return _body;
}
}
SemanticTree.IStatementNode SemanticTree.IForNode.increment_statement
{
get
{
return _increment_statement;
}
}
SemanticTree.IExpressionNode SemanticTree.IForNode.while_expr
{
get
{
return _while_expr;
}
}
SemanticTree.IExpressionNode SemanticTree.IForNode.init_while_expr
{
get
{
return _init_while_expr;
}
}
bool SemanticTree.IForNode.IsBoolCycle
{
get
{
return _bool_cycle;
}
}
}
///
/// Список выражений.
///
[Serializable]
public class statements_list : statement_node, SemanticTree.IStatementsListNode
{
///
/// Список выражений.
///
private statement_node_list _statements = new statement_node_list();
private location _llbl=null,_rlbl=null;
///
/// Конструктор класса.
///
/// Расположение списка выражений.
public statements_list(location loc) : base(loc)
{
}
///
/// Конструктор класса.
///
/// Расположение списка выражений.
/// Положение левой логической скобки
/// Положение правой логической скобки
public statements_list(location loc, location leftLogicalBracketLocation, location rightLogicalBracketLocation)
: base(loc)
{
this._llbl = leftLogicalBracketLocation;
this._rlbl = rightLogicalBracketLocation;
}
private List _var_defs = new List();
///
/// Массив переменных, определенных в блоке.
/// Используется при обходе дерева посетителем.
///
SemanticTree.ILocalBlockVariableNode[] SemanticTree.IStatementsListNode.LocalVariables
{
get
{
return (_var_defs.ToArray());
}
}
public List local_variables
{
get
{
return _var_defs;
}
set
{
_var_defs = value;
}
}
///
/// Список statement-ов.
///
public statement_node_list statements
{
get
{
return _statements;
}
}
///
/// Положение левой логической скобки
///
public SemanticTree.ILocation LeftLogicalBracketLocation
{
get
{
return _llbl;
}
set
{
_llbl = (location)value;
}
}
///
/// Положение правой логической скобки
///
public SemanticTree.ILocation RightLogicalBracketLocation
{
get
{
return _rlbl;
}
set
{
_rlbl = (location)value;
}
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.statements_list;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
SemanticTree.IStatementNode[] SemanticTree.IStatementsListNode.statements
{
get
{
return (_statements.ToArray());
}
}
internal SymbolTable.Scope Scope = null;
}
//TODO: Неплохо-бы в следующих 3-х классах хранить ссылку на следующее за циклом выражение.
///
/// Узел break в цикле while.
///
[Serializable]
public class while_break_node : expression_node, SemanticTree.IWhileBreakNode
{
///
/// Узел while.
///
private while_node _whnd;
///
/// Конструктор класса.
///
/// Узел while из которого ведет этот break.
/// Расположение узла.
public while_break_node(while_node whnd,location loc) :
base(null,loc)
{
_whnd=whnd;
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.while_break_node;
}
}
public SemanticTree.IWhileNode while_node
{
get
{
return _whnd;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit((SemanticTree.IWhileBreakNode)this);
}
}
///
/// Узел break в цикле repeat.
///
[Serializable]
public class repeat_break_node : expression_node, SemanticTree.IRepeatBreakNode
{
///
/// Узел repeat, внутри которого расположен этот break.
///
private repeat_node _rpnd;
///
/// Конструктор касса.
///
/// Узел repeat, внутри которого расположен этот break.
/// Расположение узла.
public repeat_break_node(repeat_node rn,location loc) :
base(null,loc)
{
_rpnd=rn;
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.repeat_break_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit((SemanticTree.IRepeatBreakNode)this);
}
public SemanticTree.IRepeatNode repeat_node
{
get
{
return _rpnd;
}
}
}
///
/// Узел break в икле for.
///
[Serializable]
public class for_break_node : expression_node, SemanticTree.IForBreakNode
{
///
/// Цикл for внутри которого расположен этот break.
///
private for_node _frnd;
///
/// Конструктор класса.
///
/// Цикл for внутри которого расположен этот break.
/// Расположение узла.
public for_break_node(for_node fn,location loc) :
base(null,loc)
{
_frnd=fn;
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.for_break_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit((SemanticTree.IForBreakNode)this);
}
public SemanticTree.IForNode for_node
{
get
{
return _frnd;
}
}
}
[Serializable]
public class foreach_break_node : expression_node, SemanticTree.IForeachBreakNode
{
///
/// Цикл for внутри которого расположен этот break.
///
private foreach_node _frnd;
///
/// Конструктор класса.
///
/// Цикл for внутри которого расположен этот break.
/// Расположение узла.
public foreach_break_node(foreach_node fn,location loc) :
base(null,loc)
{
_frnd=fn;
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.foreach_break_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit((SemanticTree.IForeachBreakNode)this);
}
public SemanticTree.IForeachNode foreach_node
{
get
{
return _frnd;
}
}
}
///
/// Узел exit где угодно
///
[Serializable]
public class exit_procedure : expression_node, SemanticTree.IExitProcedure
{
///
/// Конструктор класса.
///
/// Расположение узла.
public exit_procedure(location loc)
:
base(null, loc)
{
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.exit_procedure;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit((SemanticTree.IExitProcedure)this);
}
}
///
/// Узел, представляющий continue внутри цикла while.
///
[Serializable]
public class while_continue_node : expression_node, SemanticTree.IWhileContinueNode
{
///
/// Цикл while внутри которого расположен этот continue.
///
private while_node _whnd;
///
/// Конструктор класса.
///
/// Цикл while внутри которого расположен этот continue.
/// Расположение узла.
public while_continue_node(while_node whnd,location loc) :
base(null,loc)
{
_whnd=whnd;
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.while_continue_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit((SemanticTree.IWhileContinueNode)this);
}
public SemanticTree.IWhileNode while_node
{
get
{
return _whnd;
}
}
}
///
/// Узел continue в цикле repeat.
///
[Serializable]
public class repeat_continue_node : expression_node, SemanticTree.IRepeatContinueNode
{
///
/// Цикл repeat, внутри которог расположен этот continue.
///
private repeat_node _rpnd;
///
/// Конструктор класса.
///
/// Цикл repeat, внутри которог расположен этот continue.
/// Расположение узла.
public repeat_continue_node(repeat_node rn, location loc) :
base(null,loc)
{
_rpnd=rn;
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.repeat_continue_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit((SemanticTree.IRepeatContinueNode)this);
}
public SemanticTree.IRepeatNode repeat_node
{
get
{
return _rpnd;
}
}
}
///
/// Узел continue внутри цикла for.
///
[Serializable]
public class for_continue_node : expression_node, SemanticTree.IForContinueNode
{
///
/// Цикл for, внутри которого расположен этот continue.
///
private for_node _frnd;
///
/// Конструктор класса.
///
///
/// Расположение узла.
public for_continue_node(for_node fn,location loc):
base(null,loc)
{
_frnd=fn;
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.for_continue_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit((SemanticTree.IForContinueNode)this);
}
public SemanticTree.IForNode for_node
{
get
{
return _frnd;
}
}
}
[Serializable]
public class foreach_continue_node : expression_node, SemanticTree.IForeachContinueNode
{
///
/// Цикл for, внутри которого расположен этот continue.
///
private foreach_node _frnd;
///
/// Конструктор класса.
///
///
/// Расположение узла.
public foreach_continue_node(foreach_node fn,location loc):
base(null,loc)
{
_frnd=fn;
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.foreach_continue_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit((SemanticTree.IForeachContinueNode)this);
}
public SemanticTree.IForeachNode foreach_node
{
get
{
return _frnd;
}
}
}
[Serializable]
public class switch_node : statement_node, SemanticTree.ISwitchNode
{
private expression_node _condition;
private case_variant_node_list _case_variants = new case_variant_node_list();
private statement_node _default_statement;
public switch_node(location loc) : base(loc)
{
}
public case_variant_node_list case_variants
{
get
{
return _case_variants;
}
}
public expression_node condition
{
get
{
return _condition;
}
set
{
_condition = value;
}
}
public statement_node default_statement
{
get
{
return _default_statement;
}
set
{
_default_statement = value;
}
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.switch_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
SemanticTree.ICaseVariantNode[] SemanticTree.ISwitchNode.case_variants
{
get
{
return _case_variants.ToArray();
}
}
SemanticTree.IStatementNode SemanticTree.ISwitchNode.default_statement
{
get
{
return _default_statement;
}
}
public SemanticTree.IExpressionNode case_expression
{
get
{
return _condition;
}
}
}
[Serializable]
public class case_variant_node : statement_node, SemanticTree.ICaseVariantNode
{
private case_range_node_list _case_ranges = new case_range_node_list();
//private constant_node_list _case_constants = new constant_node_list();
private int_const_node_list _case_constants = new int_const_node_list();
private statement_node _case_statement;
public case_variant_node(location loc) : base(loc)
{
}
public case_range_node_list case_ranges
{
get
{
return _case_ranges;
}
}
public int_const_node_list case_constants
{
get
{
return _case_constants;
}
}
public statement_node case_statement
{
get
{
return _case_statement;
}
set
{
_case_statement = value;
}
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.case_variant_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
public SemanticTree.IIntConstantNode[] elements
{
get
{
return _case_constants.ToArray();
}
}
public SemanticTree.ICaseRangeNode[] ranges
{
get
{
return _case_ranges.ToArray();
}
}
public SemanticTree.IStatementNode statement_to_execute
{
get
{
return _case_statement;
}
}
}
[Serializable]
public class case_range_node : statement_node, SemanticTree.ICaseRangeNode
{
private int_const_node _lower_bound;
private int_const_node _high_bound;
public case_range_node(int_const_node lower_bound, int_const_node high_bound, location loc) : base(loc)
{
_lower_bound = lower_bound;
_high_bound = high_bound;
}
public int_const_node lower_bound
{
get
{
return _lower_bound;
}
}
public int_const_node high_bound
{
get
{
return _high_bound;
}
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.case_range_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
SemanticTree.IIntConstantNode SemanticTree.ICaseRangeNode.lower_bound
{
get
{
return _lower_bound;
}
}
SemanticTree.IIntConstantNode SemanticTree.ICaseRangeNode.high_bound
{
get
{
return _high_bound;
}
}
}
[Serializable]
public class exception_filter : statement_node, SemanticTree.IExceptionFilterBlockNode
{
private type_node _filter_type;
private local_block_variable_reference _exception_var;
private statement_node _exception_handler;
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;
}
public type_node filter_type
{
get
{
return _filter_type;
}
set
{
_filter_type = value;
}
}
public local_block_variable_reference exception_var
{
get
{
return _exception_var;
}
set
{
_exception_var = value;
}
}
public statement_node exception_handler
{
get
{
return _exception_handler;
}
set
{
_exception_handler = value;
}
}
public SemanticTree.ITypeNode ExceptionType
{
get
{
return _filter_type;
}
}
public SemanticTree.ILocalBlockVariableReferenceNode ExceptionInstance
{
get
{
return _exception_var;
}
}
public SemanticTree.IStatementNode ExceptionHandler
{
get
{
return _exception_handler;
}
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.exception_filter;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
}
[Serializable]
public class try_block : statement_node, SemanticTree.ITryBlockNode
{
private statement_node _try_statements;
private statement_node _finally_statements;
private exception_filters_list _filters;
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;
}
public statement_node try_statements
{
get
{
return _try_statements;
}
}
public statement_node finally_statements
{
get
{
return _finally_statements;
}
}
public exception_filters_list filters
{
get
{
return _filters;
}
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.try_block;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
public SemanticTree.IStatementNode TryStatements
{
get
{
return _try_statements;
}
}
public SemanticTree.IStatementNode FinallyStatements
{
get
{
return _finally_statements;
}
}
public SemanticTree.IExceptionFilterBlockNode[] ExceptionFilters
{
get
{
return _filters.ToArray();
}
}
}
[Serializable]
public class foreach_node : statement_node, SemanticTree.IForeachNode
{
private var_definition_node _ident;
private expression_node _in_what;
private statement_node _what_do;
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;
}
public var_definition_node ident
{
get
{
return _ident;
}
set
{
_ident = value;
}
}
public expression_node in_what
{
get
{
return _in_what;
}
set
{
_in_what = value;
}
}
public statement_node what_do
{
get
{
return _what_do;
}
set
{
_what_do = value;
}
}
public SemanticTree.IStatementNode Body
{
get
{
return _what_do;
}
}
public SemanticTree.IExpressionNode InWhatExpr
{
get
{
return _in_what;
}
}
public SemanticTree.IVAriableDefinitionNode VarIdent
{
get
{
return _ident;
}
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.foreach_node;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
}
[Serializable]
public class lock_statement : statement_node, SemanticTree.ILockStatement
{
private expression_node _lock_object;
private statement_node _body;
public lock_statement(expression_node _lock_object, statement_node _body, location loc)
: base(loc)
{
this._lock_object = _lock_object;
this._body = _body;
}
public expression_node lock_object
{
get
{
return _lock_object;
}
set
{
_lock_object = value;
}
}
public statement_node body
{
get
{
return _body;
}
set
{
_body = value;
}
}
public SemanticTree.IStatementNode Body
{
get
{
return _body;
}
}
public SemanticTree.IExpressionNode LockObject
{
get
{
return _lock_object;
}
}
///
/// Тип узла.
///
public override semantic_node_type semantic_node_type
{
get
{
return semantic_node_type.lock_statement;
}
}
///
/// Метод для обхода дерева посетителем.
///
/// Класс - посетитель дерева.
public override void visit(SemanticTree.ISemanticVisitor visitor)
{
visitor.visit(this);
}
}
}