本文整理汇总了C#中Boo.Lang.Compiler.Ast.Module类的典型用法代码示例。如果您正苦于以下问题:C# Module类的具体用法?C# Module怎么用?C# Module使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Module类属于Boo.Lang.Compiler.Ast命名空间,在下文中一共展示了Module类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitCompilationUnit
public object VisitCompilationUnit(CompilationUnit compilationUnit, object data)
{
module = new B.Module();
module.LexicalInfo = new B.LexicalInfo(fileName, 1, 1);
compilationUnit.AcceptChildren(this, data);
if (entryPointMethod != null) {
bool allMembersAreStatic = true;
foreach (B.TypeMember member in entryPointMethod.DeclaringType.Members) {
allMembersAreStatic &= member.IsStatic;
}
if (allMembersAreStatic) {
entryPointMethod.DeclaringType.Attributes.Add(MakeAttribute(("module")));
} else {
lastLexicalInfo = entryPointMethod.LexicalInfo;
B.Expression expr = MakeReferenceExpression(entryPointMethod.DeclaringType.Name + ".Main");
B.MethodInvocationExpression mie = new B.MethodInvocationExpression(lastLexicalInfo, expr);
if (entryPointMethod.Parameters.Count > 0) {
mie.Arguments.Add(MakeReferenceExpression("argv"));
}
B.SimpleTypeReference ret = entryPointMethod.ReturnType as B.SimpleTypeReference;
if (ret.Name == "void" || ret.Name == "System.Void")
module.Globals.Add(new B.ExpressionStatement(mie));
else
module.Globals.Add(new B.ReturnStatement(lastLexicalInfo, mie, null));
}
}
B.Module tmp = module;
module = null;
return tmp;
}
示例2: CreateBooCode
public static string CreateBooCode(CompilerErrorCollection errors,
CompilerWarningCollection warnings,
Module module,
IList<ICSharpCode.NRefactory.ISpecial> specials)
{
using (StringWriter w = new StringWriter())
{
foreach (CompilerError error in errors)
{
w.WriteLine("ERROR: " + error.ToString());
}
if (errors.Count > 0)
w.WriteLine();
foreach (CompilerWarning warning in warnings)
{
w.WriteLine("# WARNING: " + warning.ToString());
}
if (warnings.Count > 0)
w.WriteLine();
BooPrinterVisitorWithComments printer = new BooPrinterVisitorWithComments(specials, w);
printer.OnModule(module);
printer.Finish();
return w.ToString();
}
}
示例3: OnModule
/// <summary>
/// Inspect a module to check if we need to add a namespace
/// </summary>
/// <param name="node">The node.</param>
public override void OnModule(Module node)
{
if (node.Namespace != null)
return;
node.Namespace = new NamespaceDeclaration(node.FullName);
}
示例4: OnModule
public override void OnModule(Module module) {
replacecount = 0;
dowork = module["isduck"]==null|| module["isduck"].toBool();
//NameResolutionService.Reset();
Console.WriteLine("");
Console.Write("[" + module.Members[0].Name.Replace("_0_","/") + "](" + (cnt++) + ")");
base.OnModule(module);
if(replacecount==0) {
if (dowork) {
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine();
Console.WriteLine(module.Members[0].Name.Replace("_0_", "/") + " can be NODUCK");
}else {
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine();
Console.WriteLine(module.Members[0].Name.Replace("_0_", "/") + " is NODUCK");
}
}else {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine();
Console.WriteLine(module.Members[0].Name.Replace("_0_", "/") + " contains DUCKS");
}
Console.ResetColor();
}
示例5: OnModule
override public void OnModule(Module module)
{
EnterNamespace(InternalModule.ScopeFor(module));
VisitTypeDefinitionBody(module);
Visit(module.AssemblyAttributes);
LeaveNamespace();
}
示例6: InternalModule
public InternalModule(InternalTypeSystemProvider provider, Module module)
{
_provider = provider;
_module = module;
_namespace = SafeNamespace(module);
_module.Imports.Changed += (sender, e) => _namespaceList = null;
_module.Members.Changed += (sender, e) => _memberCache = null;
}
示例7: OnModule
public override void OnModule(Module node){
bmlelements = new List<MacroStatement>();
exceptions = null;
allowall = false;
Visit(node.Members);
Visit(node.Globals.Statements);
collectTemplates();
}
示例8: OnModule
/// <summary>
/// Add the namespaces to the module
/// </summary>
public override void OnModule(Module node)
{
foreach (string ns in namespaces)
{
Import import = new Import(node.LexicalInfo, ns);
node.Imports.Add(import);
}
}
示例9: ModuleEntity
public ModuleEntity(NameResolutionService nameResolutionService,
TypeSystemServices typeSystemServices,
Module module)
{
_nameResolutionService = nameResolutionService;
_typeSystemServices = typeSystemServices;
_module = module;
_namespace = SafeNamespace(module);
}
示例10: Generate
public string Generate(XElement xml) {
var m = new Module {
Namespace = new NamespaceDeclaration(xml.Name.LocalName)
};
foreach (var element in xml.Elements()) {
generateElement(element, m.Globals);
}
return m.ToCodeString();
}
示例11: ReifyIntoShouldFailWithAlreadyConnectedMember
public void ReifyIntoShouldFailWithAlreadyConnectedMember()
{
var module = new Module();
RunCompilerStepAfterExpressionResolutionOn(new CompileUnit(module), new ActionStep(() =>
{
var klass = new ClassDefinition { Name = "Foo" };
module.Members.Add(klass);
Exceptions.Expecting<ArgumentException>(() => CodeReifier().ReifyInto(module, klass));
}));
}
示例12: OnModule
public override void OnModule(Module node)
{
var imports = new[] { "UnityEngine", "System.Collections" };
foreach (var importName in imports)
{
var targetImport = new Import(LexicalInfo.Empty, importName);
if (node.Imports.Contains(targetImport))
node.Imports.Add(targetImport);
}
}
示例13: OnModule
override public void OnModule(Module node)
{
var existingModuleClass = FindModuleClass(node);
var moduleClass = existingModuleClass ?? NewModuleClassFor(node);
Method entryPoint = moduleClass.Members["Main"] as Method;
int removed = 0;
TypeMember[] members = node.Members.ToArray();
for (int i=0; i<members.Length; ++i)
{
TypeMember member = members[i];
if (member is TypeDefinition) continue;
if (member.NodeType == NodeType.Method)
{
if (EntryPointMethodName == member.Name)
{
entryPoint = (Method)member;
}
member.Modifiers |= TypeMemberModifiers.Static;
}
node.Members.RemoveAt(i-removed);
moduleClass.Members.Add(member);
++removed;
}
if (!node.Globals.IsEmpty)
{
Method method = new Method();
method.IsSynthetic = true;
method.Parameters.Add(new ParameterDeclaration("argv", new ArrayTypeReference(new SimpleTypeReference("string"))));
method.ReturnType = CodeBuilder.CreateTypeReference(TypeSystemServices.VoidType);
method.Body = node.Globals;
method.LexicalInfo = node.Globals.Statements[0].LexicalInfo;
method.EndSourceLocation = node.EndSourceLocation;
method.Name = EntryPointMethodName;
method.Modifiers = TypeMemberModifiers.Static | TypeMemberModifiers.Private;
moduleClass.Members.Add(method);
node.Globals = null;
entryPoint = method;
}
SetEntryPointIfNecessary(entryPoint);
if (existingModuleClass != null || ForceModuleClass || (moduleClass.Members.Count > 0))
{
if (moduleClass != existingModuleClass)
{
moduleClass.Members.Add(AstUtil.CreateConstructor(node, TypeMemberModifiers.Private));
node.Members.Add(moduleClass);
}
InitializeModuleClassEntity(node, moduleClass);
}
}
示例14: ScriptDirectoryProperty
// get the directory name where this script reside and create a property
// that return this value.
// this is used to calculate relative paths when loading subviews.
private void ScriptDirectoryProperty(ClassDefinition macro, Module module)
{
Property p = new Property("ScriptDirectory");
p.Modifiers = TypeMemberModifiers.Override;
p.Getter = new Method("getScriptDirectory");
p.Getter.Body.Add(
new ReturnStatement(
new StringLiteralExpression(
Path.GetDirectoryName(module.LexicalInfo.FileName))));
macro.Members.Add(p);
}
示例15: Parse
private Module Parse()
{
var module = new Module();
var globals = module.Globals;
while (_position < _code.Length)
{
var expression = ParseNextExpression();
if (expression == null)
break;
globals.Add(expression);
}
return module;
}