本文整理汇总了C#中Mono.CSharp.CompilationSourceFile类的典型用法代码示例。如果您正苦于以下问题:C# CompilationSourceFile类的具体用法?C# CompilationSourceFile怎么用?C# CompilationSourceFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompilationSourceFile类属于Mono.CSharp命名空间,在下文中一共展示了CompilationSourceFile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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 ();
}
开发者ID:severinh,项目名称:monodevelop-vala-afrodite-update,代码行数:25,代码来源:driver.cs
示例2: 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();
}
开发者ID:Nystul-the-Magician,项目名称:daggerfall-unity,代码行数:8,代码来源:CustomDynamicDriver.cs
示例3: Evaluator
public Evaluator (CompilerSettings settings, Report report)
{
ctx = new CompilerContext (settings, report);
module = new ModuleContainer (ctx);
module.Evaluator = this;
source_file = new CompilationSourceFile ("{interactive}", "", 1);
source_file.NamespaceContainer = new NamespaceContainer (null, module, null, source_file);
ctx.SourceFiles.Add (source_file);
// FIXME: Importer needs this assembly for internalsvisibleto
module.SetDeclaringAssembly (new AssemblyDefinitionDynamic (module, "evaluator"));
importer = new ReflectionImporter (module, ctx.BuiltinTypes);
InteractiveBaseClass = typeof (InteractiveBase);
fields = new Dictionary<string, Tuple<FieldSpec, FieldInfo>> ();
}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:19,代码来源:eval.cs
示例4: Evaluator
public Evaluator (CompilerContext ctx)
{
this.ctx = ctx;
module = new ModuleContainer (ctx);
module.Evaluator = this;
source_file = new CompilationSourceFile (module);
module.AddTypeContainer (source_file);
startup_files = ctx.SourceFiles.Count;
// FIXME: Importer needs this assembly for internalsvisibleto
module.SetDeclaringAssembly (new AssemblyDefinitionDynamic (module, "evaluator"));
importer = new ReflectionImporter (module, ctx.BuiltinTypes);
InteractiveBaseClass = typeof (InteractiveBase);
fields = new Dictionary<string, Tuple<FieldSpec, FieldInfo>> ();
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:19,代码来源:eval.cs
示例5: tokenize_file
void tokenize_file (SourceFile sourceFile, ModuleContainer module, ParserSession session)
{
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);
if (sourceFile.FileType == SourceFileType.CSharp) {
Tokenizer lexer = new Tokenizer (reader, file, session);
int token, tokens = 0, errors = 0;
while ((token = lexer.token ()) != Token.EOF){
tokens++;
if (token == Token.ERROR)
errors++;
}
} else {
Mono.PlayScript.Tokenizer lexer = new Mono.PlayScript.Tokenizer (reader, file, session);
lexer.ParsingPlayScript = sourceFile.PsExtended;
int token, tokens = 0, errors = 0;
while ((token = lexer.token ()) != Mono.PlayScript.Token.EOF){
tokens++;
if (token == Mono.PlayScript.Token.ERROR)
errors++;
}
}
}
return;
}
开发者ID:robterrell,项目名称:playscript-mono,代码行数:39,代码来源:driver.cs
示例6: NamespaceContainer
private NamespaceContainer (ModuleContainer module, NamespaceContainer parent, CompilationSourceFile file, Namespace ns, bool slave)
{
this.module = module;
this.parent = parent;
this.file = file;
this.IsImplicit = true;
this.ns = ns;
this.SlaveDeclSpace = slave ? new RootDeclSpace (module, this) : null;
}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:9,代码来源:namespace.cs
示例7: Visit
public virtual void Visit (CompilationSourceFile csf)
{
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:3,代码来源:visit.cs
示例8: Visit
public virtual void Visit (CompilationSourceFile csf)
{
VisitTypeContainer (csf);
}
开发者ID:nobled,项目名称:mono,代码行数:4,代码来源:visit.cs
示例9: AddSourceFile
void AddSourceFile (string fileName, List<CompilationSourceFile> sourceFiles)
{
string path = Path.GetFullPath (fileName);
int index;
if (source_file_index.TryGetValue (path, out index)) {
string other_name = sourceFiles[index - 1].Name;
if (fileName.Equals (other_name))
report.Warning (2002, 1, "Source file `{0}' specified multiple times", other_name);
else
report.Warning (2002, 1, "Source filenames `{0}' and `{1}' both refer to the same file: {2}", fileName, other_name, path);
return;
}
var unit = new CompilationSourceFile (fileName, path, sourceFiles.Count + 1);
sourceFiles.Add (unit);
source_file_index.Add (path, unit.Index);
}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:19,代码来源:rootcontext.cs
示例10: Parse
public static void Parse (SeekableStreamReader reader, SourceFile sourceFile, ModuleContainer module, ParserSession session, Report report)
{
var file = new CompilationSourceFile (module, sourceFile);
module.AddTypeContainer (file);
if (sourceFile.FileType == SourceFileType.CSharp) {
CSharpParser parser = new CSharpParser (reader, file, session);
parser.parse ();
} else {
PlayScriptParser parser = new PlayScriptParser (reader, file, session);
parser.parsing_playscript = sourceFile.PsExtended;
parser.parse ();
}
}
开发者ID:robterrell,项目名称:playscript-mono,代码行数:14,代码来源:driver.cs
示例11: Parse
public CSharpParser Parse (SeekableStreamReader reader, SourceFile sourceFile, ModuleContainer module)
{
var file = new CompilationSourceFile (module, sourceFile);
module.AddTypeContainer (file);
CSharpParser parser = new CSharpParser (reader, file);
parser.Lexer.sbag = new SpecialsBag ();
parser.parse ();
return parser;
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:10,代码来源:driver.cs
示例12: CSharpParser
public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file, ParserSession session, bool returnAtSignInVerbatimIdentifiers)
: this (reader, file, file.Compiler.Report, session, returnAtSignInVerbatimIdentifiers)
{
}
开发者ID:erik-kallen,项目名称:NRefactory,代码行数:4,代码来源:cs-parser.cs
示例13: NamespaceContainer
public NamespaceContainer (MemberName name, NamespaceContainer parent)
: base (parent, name, null, MemberKind.Namespace)
{
this.Parent = parent;
this.ns = parent.NS.AddNamespace (name);
containers = new List<TypeContainer> ();
var topParent = this;
while (topParent.Parent != null) {
topParent = topParent.Parent;
}
compSourceFile = topParent as CompilationSourceFile;
}
开发者ID:johnv315,项目名称:playscript-mono,代码行数:14,代码来源:namespace.cs
示例14: ParseFile
public static CompilerCompilationUnit ParseFile (string[] args, Stream input, string inputFile, ReportPrinter reportPrinter)
{
lock (parseLock) {
try {
// Driver d = Driver.Create (args, false, null, reportPrinter);
// if (d == null)
// return null;
var r = new Report (reportPrinter);
CommandLineParser cmd = new CommandLineParser (r, Console.Out);
var setting = cmd.ParseArguments (args);
if (setting == null || r.Errors > 0)
return null;
CompilerContext ctx = new CompilerContext (setting, r);
var files = new List<CompilationSourceFile> ();
var unit = new CompilationSourceFile (inputFile, inputFile, 0);
var module = new ModuleContainer (ctx);
unit.NamespaceContainer = new NamespaceContainer (null, module, null, unit);
files.Add (unit);
Location.Initialize (files);
// TODO: encoding from driver
SeekableStreamReader reader = new SeekableStreamReader (input, Encoding.Default);
RootContext.ToplevelTypes = module;
CSharpParser parser = new CSharpParser (reader, unit);
parser.Lexer.TabSize = 1;
parser.Lexer.sbag = new SpecialsBag ();
parser.LocationsBag = new LocationsBag ();
parser.UsingsBag = new UsingsBag ();
parser.parse ();
return new CompilerCompilationUnit () {
ModuleCompiled = RootContext.ToplevelTypes,
LocationsBag = parser.LocationsBag,
UsingsBag = parser.UsingsBag,
SpecialsBag = parser.Lexer.sbag,
LastYYValue = parser.LastYYVal
};
} finally {
Reset ();
}
}
}
开发者ID:severinh,项目名称:monodevelop-vala-afrodite-update,代码行数:47,代码来源:driver.cs
示例15: HandleXrefCommon
//
// Processes "see" or "seealso" elements from cref attribute.
//
void HandleXrefCommon (MemberCore mc, TypeContainer ds, XmlElement xref)
{
string cref = xref.GetAttribute ("cref");
// when, XmlReader, "if (cref == null)"
if (!xref.HasAttribute ("cref"))
return;
// Nothing to be resolved the reference is marked explicitly
if (cref.Length > 2 && cref [1] == ':')
return;
// Additional symbols for < and > are allowed for easier XML typing
cref = cref.Replace ('{', '<').Replace ('}', '>');
var encoding = module.Compiler.Settings.Encoding;
var s = new MemoryStream (encoding.GetBytes (cref));
SeekableStreamReader seekable = new SeekableStreamReader (s, encoding);
var source_file = new CompilationSourceFile (doc_module);
var report = new Report (doc_module.Compiler, new NullReportPrinter ());
var parser = new CSharpParser (seekable, source_file, report);
ParsedParameters = null;
ParsedName = null;
ParsedBuiltinType = null;
ParsedOperator = null;
parser.Lexer.putback_char = Tokenizer.DocumentationXref;
parser.Lexer.parsing_generic_declaration_doc = true;
parser.parse ();
if (report.Errors > 0) {
Report.Warning (1584, 1, mc.Location, "XML comment on `{0}' has syntactically incorrect cref attribute `{1}'",
mc.GetSignatureForError (), cref);
xref.SetAttribute ("cref", "!:" + cref);
return;
}
MemberSpec member;
string prefix = null;
FullNamedExpression fne = null;
//
// Try built-in type first because we are using ParsedName as identifier of
// member names on built-in types
//
if (ParsedBuiltinType != null && (ParsedParameters == null || ParsedName != null)) {
member = ParsedBuiltinType.Type;
} else {
member = null;
}
if (ParsedName != null || ParsedOperator.HasValue) {
TypeSpec type = null;
string member_name = null;
if (member == null) {
if (ParsedOperator.HasValue) {
type = mc.CurrentType;
} else if (ParsedName.Left != null) {
fne = ResolveMemberName (mc, ParsedName.Left);
if (fne != null) {
var ns = fne as Namespace;
if (ns != null) {
fne = ns.LookupTypeOrNamespace (mc, ParsedName.Name, ParsedName.Arity, LookupMode.Probing, Location.Null);
if (fne != null) {
member = fne.Type;
}
} else {
type = fne.Type;
}
}
} else {
fne = ResolveMemberName (mc, ParsedName);
if (fne == null) {
type = mc.CurrentType;
} else if (ParsedParameters == null) {
member = fne.Type;
} else if (fne.Type.MemberDefinition == mc.CurrentType.MemberDefinition) {
member_name = Constructor.ConstructorName;
type = fne.Type;
}
}
} else {
type = (TypeSpec) member;
member = null;
}
if (ParsedParameters != null) {
var old_printer = mc.Module.Compiler.Report.SetPrinter (new NullReportPrinter ());
foreach (var pp in ParsedParameters) {
pp.Resolve (mc);
}
mc.Module.Compiler.Report.SetPrinter (old_printer);
}
if (type != null) {
if (member_name == null)
//.........这里部分代码省略.........
开发者ID:royleban,项目名称:mono,代码行数:101,代码来源:doc.cs
示例16: ParseFiles
private void ParseFiles([NotNull] ModuleContainer container)
{
Location.Initialize(container.Compiler.SourceFiles);
var session = new ParserSession
{
UseJayGlobalArrays = true,
LocatedTokens = new LocatedToken[15000]
};
foreach (var sourceFile in container.Compiler.SourceFiles)
{
using (var stream = new FileStream(sourceFile.FullPathName, FileMode.Open))
{
var compilationSourceFile = new CompilationSourceFile(container, sourceFile);
container.AddTypeContainer(compilationSourceFile);
using (var seekStream = new SeekableStreamReader(stream, Encoding.UTF8))
{
new CSharpParser(seekStream, compilationSourceFile, _report, session).parse();
}
}
}
}
开发者ID:Tauron1990,项目名称:Radio-Streamer,代码行数:22,代码来源:Compiler.cs
示例17: CSharpParser
public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file, Report report, ParserSession session)
{
this.file = file;
current_container = current_namespace = file;
this.module = file.Module;
this.compiler = file.Compiler;
this.settings = compiler.Settings;
this.report = report;
lang_version = settings.Version;
yacc_verbose_flag = settings.VerboseParserFlag;
doc_support = settings.DocumentationFile != null;
lexer = new Tokenizer (reader, file, session);
oob_stack = new Stack<object> ();
lbag = session.LocationsBag;
use_global_stacks = session.UseJayGlobalArrays;
parameters_bucket = session.ParametersStack;
}
开发者ID:segaman,项目名称:NRefactory,代码行数:19,代码来源:cs-parser.cs
示例18: CSharpParser
public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file, Report report)
{
this.file = file;
current_container = current_namespace = file;
this.module = file.Module;
this.compiler = file.Compiler;
this.settings = compiler.Settings;
this.report = report;
lang_version = settings.Version;
yacc_verbose_flag = settings.VerboseParserFlag;
doc_support = settings.DocumentationFile != null;
oob_stack.Clear ();
lexer = new Tokenizer (reader, file);
#if FULL_AST
lbag = new LocationsBag ();
#else
lbag = null;
#endif
use_global_stacks = true;
}
开发者ID:xamarin-release-manager,项目名称:monodevelop,代码行数:24,代码来源:cs-parser.cs
示例19: CSharpParser
public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file)
: this (reader, file, file.NamespaceContainer.Module.Compiler.Report)
{
}
开发者ID:hduregger,项目名称:monodevelop,代码行数:4,代码来源:cs-parser.cs
示例20: CSharpParser
public CSharpParser (SeekableStreamReader reader, CompilationSourceFile file)
{
this.file = file;
current_namespace = file.NamespaceContainer;
this.module = current_namespace.Module;
this.compiler = module.Compiler;
this.settings = compiler.Settings;
lang_version = settings.Version;
doc_support = settings.Documentation != null;
current_class = current_namespace.SlaveDeclSpace;
current_container = current_class.PartialContainer; // == RootContest.ToplevelTypes
oob_stack.Clear ();
lexer = new Tokenizer (reader, file, compiler);
use_global_stacks = true;
}
开发者ID:okrmartin,项目名称:monodevelop,代码行数:17,代码来源:cs-parser.cs
注:本文中的Mono.CSharp.CompilationSourceFile类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论