diff --git a/CodeCompletion/SymTable.cs b/CodeCompletion/SymTable.cs index 5da5c935b..27b283682 100644 --- a/CodeCompletion/SymTable.cs +++ b/CodeCompletion/SymTable.cs @@ -805,6 +805,7 @@ namespace CodeCompletion else return ss; } else + if (members != null) foreach (SymScope ss in members) if (string.Compare(ss.si.name, name, !CodeCompletionController.CurrentParser.LanguageInformation.CaseSensitive) == 0) if (ss.loc != null && loc != null && check_for_def && cur_line != -1 && cur_col != -1) diff --git a/PluginsSupport/Interfaces.cs b/PluginsSupport/Interfaces.cs index 9db90d7d2..4ae809c49 100644 --- a/PluginsSupport/Interfaces.cs +++ b/PluginsSupport/Interfaces.cs @@ -267,6 +267,8 @@ namespace VisualPascalABCPlugins void SetFileAsChanged(string FileName); void OpenTabWithText(string tabName, string Text); ICodeFileDocument OpenFileForDebug(string FileName); + void CloseAllButThis(ICodeFileDocument nonCloseTab); + void PrintActiveDocument(); } public interface IWorkbenchProjectService diff --git a/TestSuite/extensionmethods8.pas b/TestSuite/extensionmethods8.pas index 07beb66a3..2a87eeb27 100644 --- a/TestSuite/extensionmethods8.pas +++ b/TestSuite/extensionmethods8.pas @@ -35,6 +35,10 @@ procedure Add(self: List; params arr: array of integer); extensionmetho begin self.AddRange(arr); end; +function BinarySearch(self: array of T; item: T): integer; extensionmethod; +begin + Result := System.Array.BinarySearch(self,item); +end; begin var arr := Arr(1,2,3); assert(arr.myfirst=1); @@ -55,4 +59,5 @@ begin var lst4 := new List; lst4.Add(2,3,4,5); assert(lst4[3]=5); + assert(arr.BinarySearch(3)=2); end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index e865ef810..2ac4d79fd 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -4921,7 +4921,7 @@ namespace PascalABCCompiler.TreeConverter if (_dot_node != null) { bool skip_first_parameter = false; //lroman// - + bool has_extension_overload = false; semantic_node sn = convert_semantic_strong(_dot_node.left); //SyntaxTree.ident id_right = ConvertOperatorNameToIdent(_dot_node.right as SyntaxTree.ident); @@ -5054,11 +5054,8 @@ namespace PascalABCCompiler.TreeConverter si = si.Next; } } - /*if (has_obj_methods) - { - exprs.remove_at(0); - skip_first_parameter = false; - }*/ + if (si != null) + si.Next = null; si = new_si; } if (_method_call.parameters != null) @@ -5433,6 +5430,7 @@ namespace PascalABCCompiler.TreeConverter { si = tn.find_in_type(id_right.name, context.CurrentScope);//CurrentScope delete_inherited_constructors(ref si, tn); + delete_extension_methods(ref si); } //definition_node ddn2=check_name_node_type(id_right.name,si,get_location(id_right), @@ -6460,6 +6458,35 @@ namespace PascalABCCompiler.TreeConverter } + private void delete_extension_methods(ref SymbolInfo si) + { + List si_list = new List(); + SymbolInfo tmp_si = si; + while (tmp_si != null) + { + if (!(tmp_si.sym_info is function_node && (tmp_si.sym_info as function_node).is_extension_method)) + si_list.Add(tmp_si); + tmp_si = tmp_si.Next; + } + SymbolInfo new_si = null; + for (int i = 0; i < si_list.Count; i++) + { + if (new_si == null) + { + new_si = si_list[i]; + si = new_si; + } + else + { + si.Next = si_list[i]; + si = si.Next; + } + } + if (si != null) + si.Next = null; + si = new_si; + } + //ssyy //Удаляет конструкторы предков в списке si private void delete_inherited_constructors(ref SymbolInfo si, type_node tn) @@ -11801,7 +11828,7 @@ namespace PascalABCCompiler.TreeConverter /*SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(context.converted_namespace.scope, top_function.ConnectedToType.Scope); top_function.scope = scope;*/ top_function.ConnectedToType.Scope.AddSymbol(top_function.name, new SymbolInfo(context.top_function)); - if (top_function.ConnectedToType.type_special_kind == SemanticTree.type_special_kind.array_kind) + if (top_function.ConnectedToType.type_special_kind == SemanticTree.type_special_kind.array_kind && top_function.ConnectedToType.element_type.is_generic_parameter) top_function.ConnectedToType.base_type.Scope.AddSymbol(top_function.name, new SymbolInfo(context.top_function)); break; diff --git a/TreeConverter/TreeRealization/functions.cs b/TreeConverter/TreeRealization/functions.cs index 6adaa2cb1..76e7807aa 100644 --- a/TreeConverter/TreeRealization/functions.cs +++ b/TreeConverter/TreeRealization/functions.cs @@ -1072,6 +1072,14 @@ namespace PascalABCCompiler.TreeRealization public type_node ConnectedToType = null; + public override bool is_extension_method + { + get + { + return ConnectedToType != null; + } + } + SemanticTree.ITypeNode SemanticTree.ICommonNamespaceFunctionNode.ConnectedToType { get diff --git a/TreeConverter/TreeRealization/types.cs b/TreeConverter/TreeRealization/types.cs index 9d65c0c37..2f79bd180 100644 --- a/TreeConverter/TreeRealization/types.cs +++ b/TreeConverter/TreeRealization/types.cs @@ -3104,7 +3104,8 @@ namespace PascalABCCompiler.TreeRealization si = AddToSymbolInfo(si, scope.SymbolTable.Find(scope,name)); return si; */ - + if (this.type_special_kind == SemanticTree.type_special_kind.array_kind && scope == null) + this.init_scope(); if (scope == null) { SymbolInfo si = compiled_find(name); @@ -3139,6 +3140,15 @@ namespace PascalABCCompiler.TreeRealization SymbolInfo si = scope.SymbolTable.Find(scope, name); SymbolInfo si2 = find_in_additional_names(name); SymbolInfo si3 = compiled_find(name); + if (this.type_special_kind == SemanticTree.type_special_kind.array_kind && this.base_type.Scope != null) + { + SymbolInfo tmp_si = this.base_type.Scope.SymbolTable.Find(this.base_type.Scope, name); + if (tmp_si != null) + { + tmp_si.Next = si; + si = tmp_si; + } + } if (si != null) { SymbolInfo tmp_si = si; diff --git a/VisualPascalABCNET/Form1.cs b/VisualPascalABCNET/Form1.cs index a53a7ab21..3bc0254a7 100644 --- a/VisualPascalABCNET/Form1.cs +++ b/VisualPascalABCNET/Form1.cs @@ -189,7 +189,7 @@ namespace VisualPascalABC public CompilerForm CompilerForm1; - public VisualStates visualStates; + public AboutBox AboutBox1; public FindReplaceForm FindForm; public GotoLineForm GotoLineForm; @@ -265,9 +265,6 @@ namespace VisualPascalABC //this.Width = 800; //this.Height = 600; UserOptions = new UserOptions(); - - visualStates = new VisualStates(); - SetFiltersAndHighlighting(); FormLeft = this.Left; FormTop = this.Top; FormWidth = this.Width; FormHeight = this.Height; diff --git a/VisualPascalABCNET/Workbench/FileOperations.cs b/VisualPascalABCNET/Workbench/FileOperations.cs index 491075b54..6942dd47d 100644 --- a/VisualPascalABCNET/Workbench/FileOperations.cs +++ b/VisualPascalABCNET/Workbench/FileOperations.cs @@ -16,6 +16,7 @@ namespace VisualPascalABC { List temp_open_files = new List(); public List LastOpenFiles; + private VisualStates visualStates = new VisualStates(); internal Dictionary OpenDocuments = new Dictionary(); internal Dictionary OpenBrowserDocuments = new Dictionary(); private int MaxLastOpenFiles = 10; @@ -423,6 +424,11 @@ namespace VisualPascalABC return true; } + void IWorkbenchFileService.CloseAllButThis(ICodeFileDocument nonCloseTab) + { + this.CloseAllButThis(nonCloseTab as CodeFileDocumentControl); + } + void CloseAllButThis(CodeFileDocumentControl nonCloseTab) { SaveCanceled = false; @@ -576,6 +582,11 @@ namespace VisualPascalABC return true; } + void IWorkbenchFileService.PrintActiveDocument() + { + ExecPrint(); + } + public void ExecPrint() { printDialog1.AllowSelection = true; diff --git a/bin/samples.pct b/bin/samples.pct index cc53f5512..c58387814 100644 --- a/bin/samples.pct +++ b/bin/samples.pct @@ -72,4 +72,10 @@ LINQ\Zip.pas LINQ\Zip2.pas [CRT] -StandardUnits\CRT\*.pas \ No newline at end of file +StandardUnits\CRT\*.pas + +[operator] +!MainFeatures\06_Classes\OperatorOverloading.pas + +[where] +!MainFeatures\06_Classes\Where.pas \ No newline at end of file