Добавление ToString к нескольким классам определений

This commit is contained in:
andrewlord607 2018-04-28 05:16:38 +03:00
parent 113896662d
commit 7b7789454a
7 changed files with 21 additions and 9 deletions

View file

@ -161,7 +161,7 @@ namespace SymbolTable
return "GLOBAL";
return s;
}
//public override string ToString() => ScopeNum + "->" + TopScopeNum + "," + ScopeName();
public override string ToString() => TopScope==null? ScopeName(): ScopeName() + "->" + TopScope;
public SymbolsDictionary Symbols;
public List<Scope> InternalScopes;
@ -471,7 +471,10 @@ namespace SymbolTable
}
public override string ToString()
{
return InfoList.ToString();
System.Text.StringBuilder str = new System.Text.StringBuilder();
foreach (var sym in InfoList)
str.Append(sym.ToString() + ";");
return str.ToString();
}
}
#endregion

View file

@ -106,7 +106,7 @@ namespace PascalABCCompiler.TreeConverter
public class SymbolInfo
{
public override string ToString() => scope == null ? sym_info.ToString() : "(" + scope.ToString() + "," + sym_info.ToString()+")";
public override string ToString() => sym_info.ToString();
//private readonly name_information_type _name_information_type;
private definition_node _sym_info;

View file

@ -91,8 +91,6 @@ namespace PascalABCCompiler.TreeRealization
[Serializable]
public abstract class definition_node : semantic_node, SemanticTree.IDefinitionNode
{
public override string ToString() => this.GetType().Name;
protected string doc;
protected attributes_list _attributes;

View file

@ -10,6 +10,7 @@ namespace PascalABCCompiler.TreeRealization
[Serializable]
public abstract class constant_definition_node : definition_node, SemanticTree.IConstantDefinitionNode
{
public override string ToString() => name + " : " + type;
/// <summary>
/// Имя константы.
/// </summary>

View file

@ -593,7 +593,17 @@ namespace PascalABCCompiler.TreeRealization
[Serializable]
public abstract class common_function_node : function_node, SemanticTree.ICommonFunctionNode
{
public override string ToString() => "(" + GetType().Name + " " + name + "," + scope + ")";
public override string ToString()
{
System.Text.StringBuilder str = new System.Text.StringBuilder();
str.Append((return_variable != null ? "function " : "procedure ") + name + "(");
foreach (var par in parameters)
str.Append(par.ToString() + ";");
str.Append(")");
if (return_variable != null)
str.Append(": " + return_value_type);
return str.ToString();
}
protected string _name;

View file

@ -29,6 +29,8 @@ namespace PascalABCCompiler.TreeRealization
public class template_class : definition_node, PascalABCCompiler.SemanticTree.ITemplateClass
{
public override string ToString() => type_dec.type_def.ToString();
public static bool check_template_definitions = true;
public static bool TypeDependedFromTemplate(type_node tn)

View file

@ -17,6 +17,7 @@ namespace PascalABCCompiler.TreeRealization
[Serializable]
public abstract class type_node : definition_node, SemanticTree.ITypeNode
{
public override string ToString() => PrintableName;
private System.Collections.Generic.Dictionary<type_node, type_intersection_node> type_intersections;
//new System.Collections.Generic.Dictionary<type_node, type_intersection_node>();
private List<type_node> generated_type_intersections = null;//new List<type_node>();
@ -1169,7 +1170,6 @@ namespace PascalABCCompiler.TreeRealization
[Serializable]
public class common_type_node : wrapped_type, SemanticTree.ICommonTypeNode
{
public override string ToString() => "("+GetType().Name + " " + PrintableName + "," + scope + ")";
/// <summary>
/// Имя типа.
/// </summary>
@ -2543,8 +2543,6 @@ namespace PascalABCCompiler.TreeRealization
[Serializable]
public class compiled_type_node : wrapped_type, SemanticTree.ICompiledTypeNode , SemanticTree.ILocated
{
public override string ToString() => this.full_name.ToString();
internal System.Type _compiled_type;
protected compiled_type_node _base_type;