本文整理汇总了C#中Mono.CSharp.ModuleContainer类的典型用法代码示例。如果您正苦于以下问题:C# ModuleContainer类的具体用法?C# ModuleContainer怎么用?C# ModuleContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModuleContainer类属于Mono.CSharp命名空间,在下文中一共展示了ModuleContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Simple
public void Simple ()
{
//string content = @"class A { }";
string content = @"
class Foo
{
void Bar ()
{
completionList.Add (""delegate"" + sb, ""md-keyword"", GettextCatalog.GetString (""Creates anonymous delegate.""), ""delegate"" + sb + "" {"" + Document.Editor.EolMarker + stateTracker.Engine.ThisLineIndent + TextEditorProperties.IndentString + ""|"" + Document.Editor.EolMarker + stateTracker.Engine.ThisLineIndent +""};"");
}
}"
;
var stream = new MemoryStream (Encoding.UTF8.GetBytes (content));
var ctx = new CompilerContext (new CompilerSettings (), new AssertReportPrinter ());
ModuleContainer module = new ModuleContainer (ctx);
var file = new SourceFile ("test", "asdfas", 0);
CSharpParser parser = new CSharpParser (
new SeekableStreamReader (stream, Encoding.UTF8),
new CompilationSourceFile (module, file),
ctx.Report,
new ParserSession ());
RootContext.ToplevelTypes = module;
Location.Initialize (new List<SourceFile> { file });
parser.parse ();
Assert.AreEqual (0, ctx.Report.Errors);
module.Accept (new TestVisitor ());
}
示例2: Parse
void Parse (ModuleContainer module)
{
bool tokenize_only = module.Compiler.Settings.TokenizeOnly;
var sources = module.Compiler.SourceFiles;
Location.Initialize (sources);
var session = new ParserSession () {
UseJayGlobalArrays = true,
LocatedTokens = new Tokenizer.LocatedToken[15000],
AsLocatedTokens = new Mono.PlayScript.Tokenizer.LocatedToken[15000]
};
bool has_playscript_files = false;
for (int i = 0; i < sources.Count; ++i) {
if (tokenize_only) {
tokenize_file (sources[i], module, session);
} else {
Parse (sources[i], module, session, Report);
}
if (sources[i].FileType == SourceFileType.PlayScript) {
has_playscript_files = true;
}
}
// PlayScript needs to add generated code after parsing.
if (has_playscript_files) {
Mono.PlayScript.CodeGenerator.GenerateCode(module, session, Report);
}
}
示例3: tokenize_file
void tokenize_file (SourceFile sourceFile, ModuleContainer module)
{
Stream input;
try {
input = File.OpenRead (sourceFile.Name);
} catch {
Report.Error (2001, "Source file `" + sourceFile.Name + "' could not be found");
return;
}
using (input){
SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding);
var file = new CompilationSourceFile (module, sourceFile);
Tokenizer lexer = new Tokenizer (reader, file);
int token, tokens = 0, errors = 0;
while ((token = lexer.token ()) != Token.EOF){
tokens++;
if (token == Token.ERROR)
errors++;
}
Console.WriteLine ("Tokenized: " + tokens + " found " + errors + " errors");
}
return;
}
示例4: CreateModuleContainer
private static ModuleContainer CreateModuleContainer([NotNull] CompilerContext context)
{
var container = new ModuleContainer(context);
RootContext.ToplevelTypes = container;
return container;
}
示例5: Visit
public virtual void Visit (ModuleContainer mc)
{
foreach (var container in mc.Containers) {
container.Accept (this);
}
}
示例6: StaticDataContainer
public StaticDataContainer (ModuleContainer module)
: base (module, new MemberName ("<PrivateImplementationDetails>", Location.Null),
Modifiers.STATIC | Modifiers.INTERNAL)
{
size_types = new Dictionary<int, Struct> ();
data_hashes = new Dictionary<string, FieldSpec> (StringComparer.Ordinal);
}
示例7: Parse
public void Parse (CompilationSourceFile file, ModuleContainer module)
{
Stream input;
try {
input = File.OpenRead (file.Name);
} catch {
Report.Error (2001, "Source file `{0}' could not be found", file.Name);
return;
}
// Check 'MZ' header
if (input.ReadByte () == 77 && input.ReadByte () == 90) {
Report.Error (2015, "Source file `{0}' is a binary file and not a text file", file.Name);
input.Close ();
return;
}
input.Position = 0;
SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding);
Parse (reader, file, module);
reader.Dispose ();
input.Close ();
}
示例8: Parse
public void Parse(ModuleContainer module)
{
bool tokenize_only = module.Compiler.Settings.TokenizeOnly;
var sources = module.Compiler.SourceFiles;
Location.Initialize(sources);
var session = new ParserSession
{
UseJayGlobalArrays = true,
LocatedTokens = new LocatedToken[15000]
};
for (int i = 0; i < sources.Count; ++i)
{
if (tokenize_only)
{
tokenize_file(sources[i], module, session);
}
else
{
Parse(sources[i], module, session, Report);
}
}
}
示例9: Parse
public static void Parse(SeekableStreamReader reader, SourceFile sourceFile, ModuleContainer module, ParserSession session, Report report)
{
var file = new CompilationSourceFile(module, sourceFile);
module.AddTypeContainer(file);
CSharpParser parser = new CSharpParser(reader, file, report, session);
parser.parse();
}
示例10: DocumentationBuilder
public DocumentationBuilder (ModuleContainer module)
{
doc_module = new ModuleContainer (module.Compiler);
doc_module.DocumentationBuilder = this;
this.module = module;
XmlDocumentation = new XmlDocument ();
XmlDocumentation.PreserveWhitespace = false;
}
示例11: Visit
public override void Visit(ModuleContainer mc)
{
bool first = true;
foreach (var container in mc.Containers) {
var nspace = container as NamespaceContainer;
if (nspace == null) {
container.Accept(this);
continue;
}
NamespaceDeclaration nDecl = null;
var loc = LocationsBag.GetLocations(nspace);
if (nspace.NS != null && !string.IsNullOrEmpty(nspace.NS.Name)) {
nDecl = new NamespaceDeclaration ();
if (loc != null) {
nDecl.AddChild(new CSharpTokenNode (Convert(loc [0])), Roles.NamespaceKeyword);
}
ConvertNamespaceName(nspace.RealMemberName, nDecl);
if (loc != null && loc.Count > 1) {
nDecl.AddChild(new CSharpTokenNode (Convert(loc [1])), Roles.LBrace);
}
AddToNamespace(nDecl);
namespaceStack.Push(nDecl);
}
if (nspace.Usings != null) {
foreach (var us in nspace.Usings) {
us.Accept(this);
}
}
if (first) {
first = false;
AddAttributeSection(Unit, mc);
}
if (nspace.Containers != null) {
foreach (var subContainer in nspace.Containers) {
subContainer.Accept(this);
}
}
if (nDecl != null) {
AddAttributeSection (nDecl, nspace.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole);
if (loc != null && loc.Count > 2)
nDecl.AddChild (new CSharpTokenNode (Convert (loc [2])), Roles.RBrace);
if (loc != null && loc.Count > 3)
nDecl.AddChild (new CSharpTokenNode (Convert (loc [3])), Roles.Semicolon);
namespaceStack.Pop ();
} else {
AddAttributeSection (unit, nspace.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole);
}
}
AddAttributeSection (unit, mc.UnattachedAttributes, EntityDeclaration.UnattachedAttributeRole);
}
示例12: GenerateCode
public static void GenerateCode (ModuleContainer module, ParserSession session, Report report)
{
GenerateDynamicPartialClasses(module, session, report);
if (report.Errors > 0)
return;
GenerateEmbedClasses(module, session, report);
if (report.Errors > 0)
return;
}
示例13: Visit
public virtual void Visit (ModuleContainer mc)
{/*
if (mc.Delegates != null) {
foreach (TypeContainer tc in mc.Delegates) {
tc.Accept (this);
}
}*/
if (mc.Types != null) {
foreach (TypeContainer tc in mc.Types) {
tc.Accept (this);
}
}
}
示例14: Evaluator
public Evaluator (CompilerSettings settings, Report report)
{
ctx = new CompilerContext (settings, report);
module = new ModuleContainer (ctx);
module.Evaluator = this;
// FIXME: Importer needs this assembly for internalsvisibleto
module.SetDeclaringAssembly (new AssemblyDefinitionDynamic (module, "evaluator"));
importer = new ReflectionImporter (module, ctx.BuildinTypes);
InteractiveBaseClass = typeof (InteractiveBase);
fields = new Dictionary<string, Tuple<FieldSpec, FieldInfo>> ();
}
示例15: Parse
void Parse (ModuleContainer module)
{
Location.Initialize ();
bool tokenize_only = ctx.Settings.TokenizeOnly;
var cu = Location.SourceFiles;
for (int i = 0; i < cu.Count; ++i) {
if (tokenize_only) {
tokenize_file (cu[i]);
} else {
Parse (cu[i], module);
}
}
}