本文整理汇总了C#中Galaxy_Editor_2.Compiler.Generated.node.AMethodDecl.SetName方法的典型用法代码示例。如果您正苦于以下问题:C# AMethodDecl.SetName方法的具体用法?C# AMethodDecl.SetName怎么用?C# AMethodDecl.SetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Galaxy_Editor_2.Compiler.Generated.node.AMethodDecl
的用法示例。
在下文中一共展示了AMethodDecl.SetName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
//.........这里部分代码省略.........
if (includeItem.Children.Count == 0)
{
if (includeItem.Parent == null)
break;
i++;
continue;
}
i = 0;
//Put all children into this
while (includeItem.Children.Count > 0)
{
int childNr = includeItem.Children.Count - 1;
allItems.Remove(includeItem.Children[childNr]);
if (includeItem.Children[childNr] is FieldItem)
{
FieldItem aItem = (FieldItem)includeItem.Children[childNr];
Node node = aItem.FieldDecl;
node.Parent().RemoveChild(node);
includeItem.Current.GetDecl().Insert(0, node);
}
else if (includeItem.Children[childNr] is StructItem)
{
StructItem aItem = (StructItem)includeItem.Children[childNr];
Node node = aItem.StructDecl;
node.Parent().RemoveChild(node);
includeItem.Current.GetDecl().Insert(0, node);
}
else if (includeItem.Children[childNr] is MethodDeclItem)
{
MethodDeclItem aItem = (MethodDeclItem)includeItem.Children[childNr];
AMethodDecl aNode = new AMethodDecl();
if (aItem.RealDecl.GetStatic() != null) aNode.SetStatic(new TStatic("static"));
aNode.SetReturnType(Util.MakeClone(aItem.RealDecl.GetReturnType(), finalTrans.data));
aNode.SetName(new TIdentifier(aItem.RealDecl.GetName().Text));
foreach (AALocalDecl formal in aItem.RealDecl.GetFormals())
{
AALocalDecl clone = new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null, Util.MakeClone(formal.GetType(), finalTrans.data), new TIdentifier(formal.GetName().Text), null);
aNode.GetFormals().Add(clone);
}
includeItem.Current.GetDecl().Insert(0, aNode);
}
else if (includeItem.Children[childNr] is IncludeItem)
{
IncludeItem aChild = (IncludeItem)includeItem.Children[childNr];
if (aChild.Current == null)
{
AIncludeDecl node = new AIncludeDecl(new TInclude("include"),
new TStringLiteral("\"TriggerLibs/NativeLib\""));
includeItem.Current.GetDecl().Insert(0, node);
}
else
{
PDecl[] decls = new PDecl[aChild.Current.GetDecl().Count];
aChild.Current.GetDecl().CopyTo(decls, 0);
for (int k = decls.Length - 1; k >= 0; k--)
{
includeItem.Current.GetDecl().Insert(0, decls[k]);
}
aChild.Current.Parent().RemoveChild(aChild.Current);
//i = -1;
}
}
includeItem.Children.RemoveAt(childNr);
}
}
}
示例2: CreateResizeArrayMethod
//.........这里部分代码省略.........
AMethodDecl method = new AMethodDecl(new APublicVisibilityModifier(), null, null, null, null, null,
new AVoidType(new TVoid("void")),
new TIdentifier("ResizeArray"),
new ArrayList() { newSizeFormal, idFormal }, methodBlock);
AASourceFile sourceFile = Util.GetAncestor<AASourceFile>(node);
sourceFile.GetDecl().Add(method);
data.Methods.Add(new SharedData.DeclItem<AMethodDecl>(sourceFile, method));
data.LvalueTypes[oldSizeRef1] =
data.LvalueTypes[oldSizeRef2] =
data.LvalueTypes[oldSizeRef3] =
//data.LvalueTypes[oldSizeRef4] =
data.LvalueTypes[oldSizeRef5] =
data.ExpTypes[oldSizeRef1Exp] =
data.ExpTypes[oldSizeRef3Exp] =
//data.ExpTypes[oldSizeRef4Exp] =
data.ExpTypes[oldSizeRef5Exp] =
data.LvalueTypes[newSizeRef1] =
data.LvalueTypes[newSizeRef2] =
data.ExpTypes[newSizeRef1Exp] =
data.ExpTypes[newSizeRef2Exp] =
data.ExpTypes[binop3] =
data.ExpTypes[assignment1] =
data.ExpTypes[getSizeInvoke] = new ANamedType(new TIdentifier("int"), null);
data.LvalueTypes[idRef1] =
//data.LvalueTypes[idRef2] =
data.LvalueTypes[idRef3] =
data.LvalueTypes[idRef4] =
data.ExpTypes[idRef1Exp] =
//data.ExpTypes[idRef2Exp] =
data.ExpTypes[idRef3Exp] =
data.ExpTypes[idRef4Exp] =
data.ExpTypes[stringConstExp1] =
//data.ExpTypes[stringConstExp2] =
//data.ExpTypes[stringConstExp3] =
data.ExpTypes[stringConstExp4] =
data.ExpTypes[stringConstExp5] =
data.ExpTypes[stringConstExp6] =
data.ExpTypes[binop1] =
//data.ExpTypes[binop4] =
//data.ExpTypes[binop5] =
//data.ExpTypes[binop6] =
data.ExpTypes[binop7] =
data.ExpTypes[binop8] =
data.ExpTypes[binop9] =
data.ExpTypes[binop10] =
//data.ExpTypes[intToString1] =
data.ExpTypes[intToString2] = new ANamedType(new TIdentifier("string"), null);
data.ExpTypes[dataTableRemove] =
//data.ExpTypes[deleteStructInvoke] =
data.ExpTypes[setSizeInvoke] = new AVoidType(new TVoid("void"));
data.ExpTypes[boolConstExp1] =
data.ExpTypes[boolConstExp2] =
data.ExpTypes[boolConstExp3] =
data.ExpTypes[binop2] = new ANamedType(new TIdentifier("bool"), null);
data.LocalLinks[oldSizeRef1] =
data.LocalLinks[oldSizeRef2] =
data.LocalLinks[oldSizeRef3] =
data.LocalLinks[oldSizeRef5] = oldSizeDecl;
data.LocalLinks[newSizeRef1] =
data.LocalLinks[newSizeRef2] = newSizeFormal;
data.LocalLinks[idRef1] =
data.LocalLinks[idRef3] =
data.LocalLinks[idRef4] = idFormal;
data.SimpleMethodLinks[getSizeInvoke] =
data.Libraries.Methods.First(m => m.GetName().Text == getSizeInvoke.GetName().Text);
data.SimpleMethodLinks[setSizeInvoke] =
data.Libraries.Methods.First(m => m.GetName().Text == setSizeInvoke.GetName().Text);
data.SimpleMethodLinks[dataTableRemove] =
data.Libraries.Methods.First(m => m.GetName().Text == dataTableRemove.GetName().Text);
data.SimpleMethodLinks[intToString2] =
data.Libraries.Methods.First(m => m.GetName().Text == intToString2.GetName().Text);
if (aBaseType == null)
return simpleResizeArrayMethod = method;
data.LvalueTypes[oldSizeRef4] =
data.ExpTypes[oldSizeRef4Exp] = new ANamedType(new TIdentifier("int"), null);
data.LvalueTypes[idRef2] =
data.ExpTypes[idRef2Exp] =
data.ExpTypes[stringConstExp2] =
data.ExpTypes[stringConstExp3] =
data.ExpTypes[binop4] =
data.ExpTypes[binop5] =
data.ExpTypes[binop6] =
data.ExpTypes[intToString1] = new ANamedType(new TIdentifier("string"), null);
data.ExpTypes[deleteStructInvoke] = new AVoidType(new TVoid("void"));
data.LocalLinks[oldSizeRef4] = oldSizeDecl;
data.LocalLinks[idRef2] = idFormal;
data.SimpleMethodLinks[deleteStructInvoke] = CreateDeleteStructMethod(node, structDecl, data);
data.SimpleMethodLinks[intToString1] = data.SimpleMethodLinks[intToString2];
method.SetName(new TIdentifier("Resize" + aBaseType.AsIdentifierString() + "Array"));
resizeArrayMethods.Add(structDecl, method);
return method;
}
示例3: LoadLibraries
public void LoadLibraries(List<DirectoryInfo> libraries)
{
LibraryData lib = new LibraryData();
StreamWriter writer = new StreamWriter(new FileInfo("outputList.txt").Open(FileMode.Create, FileAccess.Write));
foreach (DirectoryInfo library in libraries)
{
retry:
FileInfo precompFile = new FileInfo(library.FullName + "\\Precompiled.LibraryData");
/*if (!precompFile.Exists)*/
CompileLibrary(library, writer);
IFormatter formatter = new BinaryFormatter();
Stream stream = precompFile.OpenRead();
try
{
lib.Join((LibraryData) formatter.Deserialize(stream));
stream.Close();
}
catch (Exception err)
{
stream.Close();
precompFile.Delete();
goto retry;
}
}
libraryData = lib;
{
List<AMethodDecl> newMethods = new List<AMethodDecl>();
List<AFieldDecl> newFields = new List<AFieldDecl>();
XmlTextReader reader = new XmlTextReader(new FileInfo("Galaxy.xml").Open(FileMode.Open, FileAccess.Read));
while (reader.Read())
{
if (reader.NodeType != XmlNodeType.Element)
continue;
if (reader.Name == "KeyWord")
{
if (reader.GetAttribute("func") == null)
{
AFieldDecl fieldDecl = new AFieldDecl(new APublicVisibilityModifier(), null, null, null, new TIdentifier(reader.GetAttribute("name")), null);
newFields.Add(fieldDecl);
continue;
}
AMethodDecl methodDecl = new AMethodDecl();
methodDecl.SetName(new TIdentifier(reader.GetAttribute("name")));
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.EndElement)
{
break;
}
if (reader.NodeType != XmlNodeType.Element)
continue;
if (reader.Name != "Param")
continue;
string type = reader.GetAttribute("name");
type = type.Substring(0, type.IndexOf(" "));
string name = reader.GetAttribute("name");
name = name.Substring(name.IndexOf(" ") + 1);
methodDecl.GetFormals().Add(new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
new ANamedType(new TIdentifier(type), null),
new TIdentifier(name), null));
}
if (reader.EOF)
break;
newMethods.Add(methodDecl);
}
}
reader.Close();
List<AMethodDecl> oldMethods = new List<AMethodDecl>();
oldMethods.AddRange(libraryData.Methods);
List<AFieldDecl> oldFields = new List<AFieldDecl>();
oldFields.AddRange(libraryData.Fields);
//Remove dublicates in old
for (int i = 0; i < oldMethods.Count; i++)
{
for (int j = i + 1; j < oldMethods.Count; j++)
{
if (oldMethods[i].GetName().Text == oldMethods[j].GetName().Text)
{
oldMethods.RemoveAt(j);
j--;
}
}
}
for (int i = 0; i < oldFields.Count; i++)
{
for (int j = i + 1; j < oldFields.Count; j++)
{
if (oldFields[i].GetName().Text == oldFields[j].GetName().Text)
{
oldFields.RemoveAt(j);
//.........这里部分代码省略.........
示例4: loadLibraries
/// <summary>
/// Crawls the StarCraft 2 MPQs to grab the *.galaxy files inside. These files are parsed for (native) functions and constants.
/// </summary>
/// <returns>The functions and constants of StarCraft 2 in form of a LibraryData</returns>
LibraryData loadLibraries()
{
// parse the files for functions and constants
CrawlAndParseMpqs();
// convert the functions and constants to a LibraryData format
LibraryData lib = new LibraryData();
// create the methods with from crawled info
foreach (ParsedFunction function in functions)
{
AMethodDecl method = new AMethodDecl();
if (function.IsNative)
method.SetNative(new TNative("native"));
method.SetName(new TIdentifier(function.Name));
method.SetReturnType(new ANamedType(new TIdentifier(function.ReturnType), null));
// add function parameter
foreach (var parameter in function.Parameters)
{
method.GetFormals().Add(new AALocalDecl(new APublicVisibilityModifier(), null, null, null, null,
new ANamedType(new TIdentifier(parameter.Item1), null),
new TIdentifier(parameter.Item2), null));
}
lib.Methods.Add(method);
}
// create the constants from the crawled info
foreach (ParsedConstant constant in constants)
{
AFieldDecl field = new AFieldDecl(new APublicVisibilityModifier(), null, new TConst("const"),
new ANamedType(new TIdentifier(constant.Type), null),
new TIdentifier(constant.Name), new AStringConstExp(new TStringLiteral(constant.Value)));
lib.Fields.Add(field);
}
functions.Clear();
constants.Clear();
return lib;
}