This commit is contained in:
Бондарев Иван 2018-10-04 21:31:31 +02:00
parent 226ab08fbd
commit 742a30f047
3 changed files with 76 additions and 20 deletions

View file

@ -79,7 +79,7 @@ namespace CodeCompletion
{
returned_scope = null;
}
if (returned_scope != null && returned_scope is ElementScope && (returned_scope as ElementScope).sc is ProcType)
if (returned_scope != null && returned_scope is ElementScope && (returned_scope as ElementScope).sc is ProcType && expr is method_call)
{
if (by_dot)
if (((returned_scope as ElementScope).sc as ProcType).target.return_type != null)
@ -99,7 +99,7 @@ namespace CodeCompletion
else
returned_scope = null;
}
else if (returned_scope != null && returned_scope is ElementScope && (returned_scope as ElementScope).sc is CompiledScope && ((returned_scope as ElementScope).sc as CompiledScope).CompiledType.BaseType == typeof(MulticastDelegate))
else if (returned_scope != null && returned_scope is ElementScope && (returned_scope as ElementScope).sc is CompiledScope && ((returned_scope as ElementScope).sc as CompiledScope).CompiledType.BaseType == typeof(MulticastDelegate) && expr is method_call)
{
ProcScope invoke_meth = ((returned_scope as ElementScope).sc as CompiledScope).FindNameOnlyInThisType("Invoke") as ProcScope;
if (invoke_meth != null)
@ -351,9 +351,9 @@ namespace CodeCompletion
}
else if (returned_scope is ElementScope && (returned_scope as ElementScope).sc is ProcType && by_dot)
{
TypeScope ts = ((returned_scope as ElementScope).sc as ProcType).target.return_type;
if (ts != null)
returned_scope = new ElementScope(ts);
//TypeScope ts = ((returned_scope as ElementScope).sc as ProcType).target.return_type;
//if (ts != null)
// returned_scope = new ElementScope(ts);
}
if (returned_scope is ElementScope)
returned_scope = CheckForAccess(entry_scope, returned_scope as ElementScope);
@ -785,13 +785,14 @@ namespace CodeCompletion
else
returned_scope = new ElementScope((returned_scope as ProcScope).return_type);
}
else if (returned_scope != null && returned_scope is ElementScope && (returned_scope as ElementScope).sc is ProcType)
else if (returned_scope != null && returned_scope is ElementScope && (returned_scope as ElementScope).sc is ProcType && _dot_node.left is method_call)
{
TypeScope ts = ((returned_scope as ElementScope).sc as ProcType).target.return_type;
if (ts != null)
returned_scope = new ElementScope(ts);
}
else if ((returned_scope != null && returned_scope is ElementScope && (returned_scope as ElementScope).sc is CompiledScope))
else if ((returned_scope != null && returned_scope is ElementScope && (returned_scope as ElementScope).sc is CompiledScope) && _dot_node.left is method_call)
{
ProcScope invoke_meth = ((returned_scope as ElementScope).sc as CompiledScope).FindNameOnlyInThisType("Invoke") as ProcScope;
if (invoke_meth != null)

View file

@ -1695,12 +1695,14 @@ namespace CodeCompletion
{
public ProcScope target;
private CompiledScope parent;
private ProcScope invokeMeth;
public ProcType(ProcScope target)
{
this.target = target;
this.si = new SymInfo(this.ToString(), SymbolKind.Delegate, this.ToString());
this.parent = TypeTable.get_compiled_type(PascalABCCompiler.NetHelper.NetHelper.MulticastDelegateType);
}
public ProcType(ProcScope target, List<string> generic_params):this(target)
@ -1737,20 +1739,59 @@ namespace CodeCompletion
}
}
public ProcScope InvokeMethod
{
get
{
if (invokeMeth == null)
{
invokeMeth = new ProcScope("Invoke", target);
invokeMeth.declaringType = parent;
invokeMeth.parameters = target.parameters;
invokeMeth.return_type = target.return_type;
invokeMeth.is_virtual = true;
invokeMeth.Complete();
}
return invokeMeth;
}
}
public override TypeScope GetInstance(List<TypeScope> gen_args, bool exact = false)
{
return this;
}
public override List<SymScope> FindOverloadNames(string name)
{
List<SymScope> lst = new List<SymScope>();
if (string.Compare(name, InvokeMethod.name, true) == 0)
lst.Add(InvokeMethod);
else
lst.AddRange(parent.FindOverloadNames(name));
return lst;
}
public override List<SymScope> FindOverloadNamesOnlyInType(string name)
{
List<SymScope> lst = new List<SymScope>();
if (string.Compare(name, InvokeMethod.name, true) == 0)
lst.Add(InvokeMethod);
else
lst.AddRange(parent.FindOverloadNamesOnlyInType(name));
return lst;
}
public override SymInfo[] GetNames()
{
//SortedDictionary<string,SymInfo> dict = new SortedDictionary<string,SymInfo>();
return parent.GetNames();
List<SymInfo> lst = new List<SymInfo>();
lst.Add(InvokeMethod.si);
lst.AddRange(parent.GetNames());
return lst.ToArray();
}
public override SymInfo[] GetNames(ExpressionVisitor ev, PascalABCCompiler.Parsers.KeywordKind keyword, bool called_in_base)
{
return null;
return parent.GetNames(ev, keyword, called_in_base);
}
public override string GetDescription()
@ -1770,36 +1811,38 @@ namespace CodeCompletion
public override SymInfo[] GetNamesAsInObject()
{
//SortedDictionary<string,SymInfo> dict = new SortedDictionary<string,SymInfo>();
return parent.GetNamesAsInObject();
List<SymInfo> lst = new List<SymInfo>();
lst.Add(InvokeMethod.si);
lst.AddRange(parent.GetNamesAsInObject());
return lst.ToArray();
}
public override SymInfo[] GetNamesAsInObject(ExpressionVisitor ev)
{
//SortedDictionary<string,SymInfo> dict = new SortedDictionary<string,SymInfo>();
return parent.GetNamesAsInObject(ev);
List<SymInfo> lst = new List<SymInfo>();
lst.Add(InvokeMethod.si);
lst.AddRange(parent.GetNamesAsInObject(ev));
return lst.ToArray();
}
public override SymScope FindName(string name)
{
if (topScope != null) return topScope.FindName(name);
return null;
return topScope.FindName(name);
}
public override SymScope FindNameInAnyOrder(string name)
{
if (topScope != null) return topScope.FindNameInAnyOrder(name);
return null;
return parent.FindNameInAnyOrder(name);
}
public override SymScope FindNameOnlyInType(string name)
{
return null;
return parent.FindNameOnlyInType(name);
}
public override SymScope FindNameOnlyInThisType(string name)
{
return null;
return parent.FindNameOnlyInThisType(name);
}
public override bool IsConvertable(TypeScope ts)

View file

@ -0,0 +1,12 @@
procedure A1(x: procedure) := x.DynamicInvoke{@function Delegate.DynamicInvoke(params args: array of Object): System.Object;@}();
procedure A2(x: procedure) := x.Invoke{@procedure Invoke(); virtual;@}();
function B1(x: function: byte) := x.DynamicInvoke{@function Delegate.DynamicInvoke(params args: array of Object): System.Object;@}();
function B2(x: function: byte) := x.Invoke{@function Invoke(): byte; virtual;@}();
function D1(x: Func0<byte>) := x.DynamicInvoke{@function Delegate.DynamicInvoke(params args: array of System.Object): System.Object;@}();
function D2(x: Func0<byte>) := x.Invoke{@function Func<>.Invoke(): byte; virtual;@}();
begin
end.