本文整理汇总了C#中Galaxy_Editor_2.Compiler.Generated.node.AMethodDecl.GetDelegate方法的典型用法代码示例。如果您正苦于以下问题:C# AMethodDecl.GetDelegate方法的具体用法?C# AMethodDecl.GetDelegate怎么用?C# AMethodDecl.GetDelegate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Galaxy_Editor_2.Compiler.Generated.node.AMethodDecl
的用法示例。
在下文中一共展示了AMethodDecl.GetDelegate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MethodDescription
public MethodDescription(AMethodDecl method)
{
Parser parser = new Parser(method);
Start = parser.Start;
End = parser.End;
ReturnType = parser.ReturnType;
Name = parser.Name;
Formals = parser.Formals;
Locals = parser.Locals;
if (method.Parent() != null)
method.Parent().RemoveChild(method);
IsDelegate = method.GetDelegate() != null;
//if (!IsDelegate)
Decl = method;
IsStatic = method.GetStatic() != null;
Visibility = method.GetVisibilityModifier();
realType = (PType)method.GetReturnType().Clone();
Position = TextPoint.FromCompilerCoords(method.GetName());
}
示例2: CaseAMethodDecl
public override void CaseAMethodDecl(AMethodDecl node)
{
InAMethodDecl(node);
if (node.GetBlock() != null)
{
node.GetBlock().Apply(this);
}
{
Object[] temp = new Object[node.GetFormals().Count];
node.GetFormals().CopyTo(temp, 0);
for (int i = temp.Length - 1; i >= 0; i--)
{
((PLocalDecl)temp[i]).Apply(this);
}
}
if (node.GetName() != null)
{
node.GetName().Apply(this);
}
if (node.GetReturnType() != null)
{
node.GetReturnType().Apply(this);
}
if (node.GetDelegate() != null)
{
node.GetDelegate().Apply(this);
}
if (node.GetInline() != null)
{
node.GetInline().Apply(this);
}
if (node.GetNative() != null)
{
node.GetNative().Apply(this);
}
if (node.GetStatic() != null)
{
node.GetStatic().Apply(this);
}
if (node.GetTrigger() != null)
{
node.GetTrigger().Apply(this);
}
if (node.GetVisibilityModifier() != null)
{
node.GetVisibilityModifier().Apply(this);
}
OutAMethodDecl(node);
}
示例3: foreach
/*public override void InAMethodDecl(AMethodDecl node)
{
AABlock block = (AABlock) node.GetBlock();
if (block != null)
{
if (!data.Locals.ContainsKey(block))
data.Locals.Add(block, new List<AALocalDecl>());
foreach (AALocalDecl formal in node.GetFormals())
{
data.Locals[block].Add(formal);
}
}
}
public override void InAConstructorDecl(AConstructorDecl node)
{
AABlock block = (AABlock)node.GetBlock();
if (block != null)
{
if (!data.Locals.ContainsKey(block))
data.Locals.Add(block, new List<AALocalDecl>());
foreach (AALocalDecl formal in node.GetFormals())
{
data.Locals[block].Add(formal);
}
}
}*/
public override void OutAMethodDecl(AMethodDecl node)
{
AStructDecl parentStruct = Util.GetAncestor<AStructDecl>(node);
AEnrichmentDecl parentEnrichment = Util.GetAncestor<AEnrichmentDecl>(node);
if (parentStruct != null)
{
//Struct method
data.StructMethods[parentStruct].Add(node);
}
else if (parentEnrichment == null)
{//Global method
//Dont care about abstract methods - will add them later
if (node.GetBlock() != null || node.GetNative() != null)
{
data.Methods.Add(new SharedData.DeclItem<AMethodDecl>(currentSourceFile, node));
data.UserMethods.Add(node);
}
else if (node.GetDelegate() != null)
data.Delegates.Add(new SharedData.DeclItem<AMethodDecl>(currentSourceFile, node));
else
{
node.Parent().RemoveChild(node);
return;
}
}
base.OutAMethodDecl(node);
}
示例4: OutAMethodDecl
public override void OutAMethodDecl(AMethodDecl node)
{
//If void return is missing, insert it.
if (node.GetReturnType() is AVoidType && node.GetBlock() != null)
{
AABlock block = (AABlock)node.GetBlock();
bool insertReturn = false;
while (true)
{
if (block.GetStatements().Count == 0)
{
insertReturn = true;
break;
}
PStm lastStm = (PStm)block.GetStatements()[block.GetStatements().Count - 1];
if (lastStm is AVoidReturnStm)
break;
if (lastStm is ABlockStm)
{
block = (AABlock)((ABlockStm)block.GetStatements()[block.GetStatements().Count - 1]).GetBlock();
continue;
}
insertReturn = true;
break;
}
if (insertReturn)
{
block.GetStatements().Add(new AVoidReturnStm(new TReturn("return", block.GetToken().Line, block.GetToken().Pos)));
}
}
//Check if delegate is valid
if (node.GetDelegate() != null)
{
if (node.GetBlock() != null)
errors.Add(new ErrorCollection.Error(node.GetDelegate(), currentSourceFile, LocRM.GetString("ErrorText195")));
if (node.GetInline() != null)
errors.Add(new ErrorCollection.Error(node.GetDelegate(), currentSourceFile, LocRM.GetString("ErrorText196")));
if (node.GetTrigger() != null)
errors.Add(new ErrorCollection.Error(node.GetDelegate(), currentSourceFile, LocRM.GetString("ErrorText197")));
if (node.GetStatic() != null)
errors.Add(new ErrorCollection.Error(node.GetDelegate(), currentSourceFile, LocRM.GetString("ErrorText198")));
if (node.GetNative() != null)
errors.Add(new ErrorCollection.Error(node.GetDelegate(), currentSourceFile, LocRM.GetString("ErrorText199")));
}
//If it's protected, it must be in a struct
if (!Util.HasAncestor<AStructDecl>(node))
{
if (node.GetVisibilityModifier() is AProtectedVisibilityModifier)
errors.Add(new ErrorCollection.Error(node.GetName(),
LocRM.GetString("ErrorText200")));
}
base.OutAMethodDecl(node);
}
示例5: Disambiguate
//.........这里部分代码省略.........
if (!(decl is AFieldDecl))
continue;
AFieldDecl field = (AFieldDecl)decl;
if (field.GetName().Text == structLvalue.GetName().Text)
{
//Static fields must be referenced from same file.
if ((field.GetStatic() != null || field.GetVisibilityModifier() is APrivateVisibilityModifier) &&
Util.GetAncestor<AASourceFile>(field) != Util.GetAncestor<AASourceFile>(aName))
continue;
AFieldLvalue fieldLvalue = new AFieldLvalue(structLvalue.GetName());
data.FieldLinks.Add(fieldLvalue, field);
structLvalue.ReplaceBy(fieldLvalue);
//fieldLvalue.Apply(this);
return null;
}
}
}
}
}
if (name.Parent().Parent().Parent() is ANonstaticInvokeExp)
{
ANonstaticInvokeExp invoke = (ANonstaticInvokeExp) name.Parent().Parent().Parent();
AAProgram program = Util.GetAncestor<AAProgram>(name);
foreach (AASourceFile sourceFile in program.GetSourceFiles())
{
if (sourceFile.GetNamespace() != null &&
sourceFile.GetNamespace().Text == aName.GetIdentifier().Text)
{
ASimpleInvokeExp simpleInvoke = new ASimpleInvokeExp(invoke.GetName(), new List<PExp>());
while (invoke.GetArgs().Count > 0)
{
simpleInvoke.GetArgs().Add(invoke.GetArgs()[0]);
}
data.SimpleNamespaceInvokes.Add(simpleInvoke, aName.GetIdentifier().Text);
invoke.ReplaceBy(simpleInvoke);
simpleInvoke.Apply(this);
return null;
}
}
}
//Static field
if (name.Parent().Parent() is ALvalueExp &&
name.Parent().Parent().Parent() is AStructLvalue)
{
AStructLvalue strLvalue = (AStructLvalue)name.Parent().Parent().Parent();
foreach (AStructDecl s in data.Structs.Select(declItem => declItem.Decl))
{
if (s.GetName().Text == aName.GetIdentifier().Text)
{
foreach (AALocalDecl structField in s.GetLocals().OfType<AALocalDecl>())
{
if (structField.GetName().Text == strLvalue.GetName().Text && !data.EnheritanceLocalMap.ContainsKey(structField))
{
if (structField.GetStatic() == null)
{
errors.Add(new ErrorCollection.Error(strLvalue.GetName(),
"The struct field is not marked as static.",
false,
new ErrorCollection.Error(
structField.GetName(), "Matching field")));
throw new ParserException(null, "");
}
AStructFieldLvalue structFieldLvalue = new AStructFieldLvalue(new TIdentifier("renameMe"));
data.StructMethodFieldLinks[structFieldLvalue] = structField;
strLvalue.ReplaceBy(structFieldLvalue);
return null;
}
}
}
}
}
//name.Parent is AAmbigiousLvalue
//PP is lvalueExp
//PPP is AStructLvalue
if ( name.Parent().Parent() is ALvalueExp &&
name.Parent().Parent().Parent() is AStructLvalue &&
name.Parent().Parent().Parent().Parent() is ADelegateExp)
return new ANamespaceLvalue(aName.GetIdentifier());
*/
/*
if (matchedStatic)
{
errors.Add(new ErrorCollection.Error(aName.GetIdentifier(), "To reference a static field/property, you must type " + str.GetName().Text + "." + aName.GetIdentifier().Text));
}
else
errors.Add(new ErrorCollection.Error(aName.GetIdentifier(), currentSourceFile, aName.GetIdentifier().Text + " did not match any defined methods, fields, locals or namespaces"), true);
return null;
}*/
public override void CaseAMethodDecl(AMethodDecl node)
{
if (node.GetDelegate() != null)
{
node.Parent().RemoveChild(node);
}
base.CaseAMethodDecl(node);
}