[csdoc-patches] CVS: csdoc/src/csdoc ChangeLog,1.13,1.14 driver.cs,1.7,1.8
Status: Planning
Brought to you by:
mastergaurav
|
From: Gaurav V. <mas...@us...> - 2003-02-25 12:26:42
|
Update of /cvsroot/csdoc/csdoc/src/csdoc
In directory sc8-pr-cvs1:/tmp/cvs-serv7788
Modified Files:
ChangeLog driver.cs
Log Message:
2003-02-25
* driver.cs : Revert back to one from mcs.
Restart again!
Index: ChangeLog
===================================================================
RCS file: /cvsroot/csdoc/csdoc/src/csdoc/ChangeLog,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- ChangeLog 25 Feb 2003 06:35:41 -0000 1.13
+++ ChangeLog 25 Feb 2003 12:26:35 -0000 1.14
@@ -1,6 +1,11 @@
2003-02-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net>
+ * driver.cs : Revert back to one from mcs.
+ Restart again!
+
+2003-02-25 Gaurav Vaish <mastergaurav AT users DOT sf DOT net>
+
* driver.cs : Oh! I have to populate the items.
* .cvsignore : Ignore only MCSDoc.exe
* MCSDoc : Created new directory.
Index: driver.cs
===================================================================
RCS file: /cvsroot/csdoc/csdoc/src/csdoc/driver.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- driver.cs 25 Feb 2003 06:35:41 -0000 1.7
+++ driver.cs 25 Feb 2003 12:26:35 -0000 1.8
@@ -28,17 +28,61 @@
public class Driver
{
+ //
+ // Assemblies references to be linked. Initialized with
+ // mscorlib.dll here.
+ static ArrayList references;
+
+ //
+ // If any of these fail, we ignore the problem. This is so
+ // that we can list all the assemblies in Windows and not fail
+ // if they are missing on Linux.
+ //
+ static ArrayList soft_references;
+
+ // Lookup paths
+ static ArrayList link_paths;
+
+ // Whether we want Yacc to output its progress
+ static bool yacc_verbose = false;
+
static string first_source;
- static bool timestamps = false;
- static bool pause = false;
+
+ //static Target target = Target.Exe;
+ //static string target_ext = ".exe";
+
+ static bool want_debugging_support = false;
+
+ //static bool parse_only = false;
+ //static bool timestamps = false;
+ //static bool pause = false;
+
+ //
+ // Whether to load the initial config file (what CSC.RSP has by default)
+ //
+ static bool load_default_config = true;
static Hashtable response_file_list;
//
+ // A list of resource files
+ //
+ static ArrayList resources;
+ static ArrayList embedded_resources;
+
+ //
+ // An array of the defines from the command line
+ //
+ static ArrayList defines;
+
+ //
// Output file
//
static string output_file = null;
+ //
+ // Last time we took the time
+ //
static DateTime last_time, first_time;
//
@@ -51,17 +95,8 @@
//
static bool using_default_encoder = true;
- //static string xmlFileName = "";
- static ArrayList references = new ArrayList();
- static ArrayList soft_references = new ArrayList();
- static ArrayList link_paths = new ArrayList();
- static ArrayList defines;
-
- public static void ShowTime (string msg)
+ public static void ShowTime(string msg)
{
- if (!timestamps)
- return;
-
DateTime now = DateTime.Now;
TimeSpan span = now - last_time;
last_time = now;
@@ -69,16 +104,10 @@
Console.WriteLine (
"[{0:00}:{1:000}] {2}",
(int) span.TotalSeconds, span.Milliseconds, msg);
-
- if (pause)
- Console.ReadLine ();
}
- public static void ShowTotalTime (string msg)
+ public static void ShowTotalTime(string msg)
{
- if (!timestamps)
- return;
-
DateTime now = DateTime.Now;
TimeSpan span = now - first_time;
last_time = now;
@@ -89,27 +118,29 @@
}
// MonoTODO("Change error code for aborted compilation to something reasonable")]
- static void parse (SourceFile file)
+ static void parse(SourceFile file)
{
CSharpParser parser;
Stream input;
- try {
- input = File.OpenRead (file.Name);
- } catch {
- Report.Error (2001, "Source file '" + file.Name + "' could not be opened");
+ try
+ {
+ input = File.OpenRead(file.Name);
+ } catch
+ {
+ Report.Error(2001, "Source file '" + file.Name + "' could not be opened");
return;
}
- StreamReader reader = new StreamReader (input, encoding, using_default_encoder);
+ StreamReader reader = new StreamReader(input, encoding, using_default_encoder);
- //parser = new CSharpParser (reader, file, defines);
- parser = new CSharpParser(reader, file, null);
- //parser.yacc_verbose = yacc_verbose;
- parser.yacc_verbose = false;
- try {
- parser.parse ();
- } catch (Exception ex) {
+ parser = new CSharpParser (reader, file, defines);
+ parser.yacc_verbose = yacc_verbose;
+ try
+ {
+ parser.parse();
+ } catch(Exception ex)
+ {
Report.Error(666, "Compilation aborted: " + ex);
} finally {
input.Close ();
@@ -137,6 +168,10 @@
" --help Display command line options and exit\n" +
" --about About the CSDoc Document Generator\n" +
"\n" +
+ "Resources:\n" +
+ " --linkresource FILE[,ID] Links FILE as a resource\n" +
+ " --resource FILE[,ID] Embed FILE as a resource\n" +
+ "\n" +
"Options can be of the form -option or /option" + /* options */
"");
}
@@ -154,69 +189,156 @@
"");
}
- public static int Main (string[] args)
+ public static int Main(string[] args)
{
- bool ok = MainDriver (args);
+ bool ok = MainDriver(args);
- if (ok && Report.Errors == 0) {
+ if (ok && Report.Errors == 0)
+ {
Console.Write("Compilation succeeded");
- if (Report.Warnings > 0) {
+ if(Report.Warnings > 0)
+ {
Console.Write(" - {0} warning(s)", Report.Warnings);
}
Console.WriteLine();
return 0;
- } else {
+ } else
+ {
Console.WriteLine("Compilation failed: {0} error(s), {1} warnings",
Report.Errors, Report.Warnings);
return 1;
}
}
- static string [] LoadArgs (string file)
+ static public void LoadAssembly(string assembly, bool soft)
+ {
+ Assembly a;
+ string total_log = "";
+
+ try
+ {
+ char[] path_chars = { '/', '\\', '.' };
+
+ if (assembly.IndexOfAny(path_chars) != -1)
+ {
+ a = Assembly.LoadFrom(assembly);
+ } else
+ {
+ a = Assembly.Load(assembly);
+ }
+ TypeManager.AddAssembly(a);
+
+ } catch(FileNotFoundException)
+ {
+ foreach (string dir in link_paths)
+ {
+ string full_path = Path.Combine(dir, assembly);
+ if(!assembly.EndsWith(".dll"))
+ full_path += ".dll";
+
+ try
+ {
+ a = Assembly.LoadFrom(full_path);
+ TypeManager.AddAssembly(a);
+ return;
+ } catch (FileNotFoundException ff)
+ {
+ total_log += ff.FusionLog;
+ continue;
+ }
+ }
+ if(!soft)
+ {
+ Report.Error(6, "Cannot find assembly `" + assembly + "'" );
+ Console.WriteLine("Log: \n" + total_log);
+ }
+ } catch(BadImageFormatException f)
+ {
+ Report.Error(6, "Cannot load assembly (bad file format)" + f.FusionLog);
+ } catch(FileLoadException f)
+ {
+ Report.Error(6, "Cannot load assembly " + f.FusionLog);
+ } catch(ArgumentNullException)
+ {
+ Report.Error(6, "Cannot load assembly (null argument)");
+ }
+ }
+
+ /// <summary>
+ /// Loads all assemblies referenced on the command line
+ /// </summary>
+ static public void LoadReferences()
+ {
+ foreach(string r in references)
+ LoadAssembly(r, false);
+
+ foreach(string r in soft_references)
+ LoadAssembly(r, true);
+
+ return;
+ }
+
+ static void SetupDefaultDefines()
+ {
+ defines = new ArrayList ();
+ defines.Add("__MonoCS__");
+ defines.Add("__MCSDoc__");
+ }
+
+ static string [] LoadArgs(string file)
{
StreamReader f;
- ArrayList args = new ArrayList ();
+ ArrayList args = new ArrayList();
string line;
- try {
- f = new StreamReader (file);
- } catch {
+ try
+ {
+ f = new StreamReader(file);
+ } catch
+ {
return null;
}
StringBuilder sb = new StringBuilder ();
- while ((line = f.ReadLine ()) != null){
+ while((line = f.ReadLine()) != null)
+ {
int t = line.Length;
- for (int i = 0; i < t; i++){
+ for (int i = 0; i < t; i++)
+ {
char c = line [i];
- if (c == '"' || c == '\''){
+ if (c == '"' || c == '\'')
+ {
char end = c;
- for (i++; i < t; i++){
+ for(i++; i < t; i++)
+ {
c = line [i];
if (c == end)
break;
sb.Append (c);
}
- } else if (c == ' '){
- if (sb.Length > 0){
+ } else if (c == ' ')
+ {
+ if (sb.Length > 0)
+ {
args.Add (sb.ToString ());
sb.Length = 0;
}
} else
sb.Append (c);
}
- if (sb.Length > 0){
+ if (sb.Length > 0)
+ {
args.Add (sb.ToString ());
sb.Length = 0;
}
}
- string [] ret_value = new string [args.Count];
- args.CopyTo (ret_value, 0);
+ string[] ret_value = new string[args.Count];
+ args.CopyTo(ret_value, 0);
return ret_value;
}
@@ -226,12 +348,14 @@
//
static string GetSystemDir()
{
- Assembly [] assemblies = AppDomain.CurrentDomain.GetAssemblies ();
+ Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
- foreach (Assembly a in assemblies){
+ foreach (Assembly a in assemblies)
+ {
string codebase = a.Location;
- if (codebase.EndsWith ("corlib.dll")){
- return codebase.Substring (0, codebase.LastIndexOf (System.IO.Path.DirectorySeparatorChar));
+ if(codebase.EndsWith ("corlib.dll"))
+ {
+ return codebase.Substring(0, codebase.LastIndexOf(System.IO.Path.DirectorySeparatorChar));
}
}
@@ -242,28 +366,31 @@
//
// Given a path specification, splits the path from the file/pattern
//
- static void SplitPathAndPattern (string spec, out string path, out string pattern)
+ static void SplitPathAndPattern(string spec, out string path, out string pattern)
{
- int p = spec.LastIndexOf ("/");
+ int p = spec.LastIndexOf("/");
if (p != -1){
//
// Windows does not like /file.cs, switch that to:
// "\", "file.cs"
//
- if (p == 0){
+ if (p == 0)
+ {
path = "\\";
- pattern = spec.Substring (1);
- } else {
- path = spec.Substring (0, p);
- pattern = spec.Substring (p + 1);
+ pattern = spec.Substring(1);
+ } else
+ {
+ path = spec.Substring(0, p);
+ pattern = spec.Substring(p + 1);
}
return;
}
- p = spec.LastIndexOf ("\\");
- if (p != -1){
- path = spec.Substring (0, p);
- pattern = spec.Substring (p + 1);
+ p = spec.LastIndexOf("\\");
+ if (p != -1)
+ {
+ path = spec.Substring(0, p);
+ pattern = spec.Substring(p + 1);
return;
}
@@ -271,74 +398,142 @@
pattern = spec;
}
- static void ProcessFile (string f)
+ static void ProcessFile(string f)
{
if (first_source == null)
first_source = f;
- Location.AddFile (f);
+ Location.AddFile(f);
}
- static void ProcessFiles ()
+ static void ProcessFiles()
{
- Location.Initialize ();
+ Location.Initialize();
- foreach (SourceFile file in Location.SourceFiles) {
- parse (file);
+ foreach(SourceFile file in Location.SourceFiles)
+ {
+ parse(file);
}
}
- static void CompileFiles (string spec, bool recurse)
+ static void CompileFiles(string spec, bool recurse)
{
string path, pattern;
- SplitPathAndPattern (spec, out path, out pattern);
- if (pattern.IndexOf ("*") == -1){
- ProcessFile (spec);
+
+ SplitPathAndPattern(spec, out path, out pattern);
+ if(pattern.IndexOf("*") == -1)
+ {
+ ProcessFile(spec);
return;
}
- string [] files = null;
- try {
+ string[] files = null;
+ try
+ {
files = Directory.GetFiles (path, pattern);
- } catch (System.IO.DirectoryNotFoundException) {
+ } catch (System.IO.DirectoryNotFoundException)
+ {
Report.Error (2001, "Source file `" + spec + "' could not be found");
return;
- } catch (System.IO.IOException){
+ } catch (System.IO.IOException)
+ {
Report.Error (2001, "Source file `" + spec + "' could not be found");
return;
}
- foreach (string f in files) {
- ProcessFile (f);
+
+ foreach(string f in files)
+ {
+ ProcessFile(f);
}
- if (!recurse)
+ if(!recurse)
return;
- string [] dirs = null;
+ string[] dirs = null;
- try {
+ try
+ {
dirs = Directory.GetDirectories (path);
- } catch {
- }
-
- foreach (string d in dirs) {
+ } catch { }
+ foreach(string d in dirs)
+ {
// Don't include path in this string, as each
// directory entry already does
CompileFiles (d + "/" + pattern, true);
}
}
- static void SetOutputFile (string name)
+ static void DefineDefaultConfig()
+ {
+ //
+ // For now the "default config" is harcoded into the compiler
+ // we can move this outside later
+ //
+ string[] default_config =
+ {
+ "System",
+ "System.Xml",
+#if false
+ //
+ // Is it worth pre-loading all this stuff?
+ //
+ "Accessibility",
+ "System.Configuration.Install",
+ "System.Data",
+ "System.Design",
+ "System.DirectoryServices",
+ "System.Drawing.Design",
+ "System.Drawing",
+ "System.EnterpriseServices",
+ "System.Management",
+ "System.Messaging",
+ "System.Runtime.Remoting",
+ "System.Runtime.Serialization.Formatters.Soap",
+ "System.Security",
+ "System.ServiceProcess",
+ "System.Web",
+ "System.Web.RegularExpressions",
+ "System.Web.Services",
+ "System.Windows.Forms"
+#endif
+ };
+
+ int p = 0;
+ foreach(string def in default_config)
+ soft_references.Insert(p++, def);
+ }
+
+ static void SetOutputFile(string name)
{
output_file = name;
}
- static void Version ()
+ static void SetWarningLevel(string s)
{
- string version = Assembly.GetExecutingAssembly ().GetName ().Version.ToString ();
- Console.WriteLine ("C# Document Generator Version {0}", version);
- Environment.Exit (0);
+ int level = 0;
+
+ try
+ {
+ level = Int32.Parse(s);
+ } catch
+ {
+ Report.Error(1900, "--wlevel requires an value from 0 to 4");
+ Environment.Exit(1);
+ }
+ if (level < 0 || level > 4)
+ {
+ Report.Error(1900, "Warning level must be 0 to 4");
+ Environment.Exit(1);
+ } else
+ RootContext.WarningLevel = level;
+ }
+
+ static void Version()
+ {
+ string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
+ Console.WriteLine("C# Document Generator Version {0}", version);
+ Environment.Exit(0);
}
//
@@ -346,18 +541,19 @@
// deprecated in favor of the CSCParseOption, which will also handle the
// options that start with a dash in the future.
//
- static bool UnixParseOption (string arg, ref string [] args, ref int i)
+ static bool UnixParseOption(string arg, ref string [] args, ref int i)
{
- switch (arg){
+ switch (arg)
+ {
case "--version":
- Version ();
+ Version();
return true;
case "/?": case "/h": case "/help":
case "--help":
- Usage ();
- Environment.Exit (0);
+ Usage();
+ Environment.Exit(0);
return true;
case "--about":
@@ -366,17 +562,42 @@
return true;
case "--recurse":
- if ((i + 1) >= args.Length){
- Report.Error (5, "--recurse requires an argument");
- Environment.Exit (1);
+ if ((i + 1) >= args.Length)
+ {
+ Report.Error(5, "--recurse requires an argument");
+ Environment.Exit(1);
}
- CompileFiles (args [++i], true);
+ CompileFiles(args [++i], true);
return true;
- case "--timestamp":
- timestamps = true;
- last_time = first_time = DateTime.Now;
+ case "--linkresource":
+ case "--linkres":
+ if((i + 1) >= args.Length)
+ {
+ Usage();
+ Report.Error(5, "Missing argument to --linkres");
+ Environment.Exit(1);
+ }
+ if (resources == null)
+ resources = new ArrayList();
+
+ resources.Add(args[++i]);
+ return true;
+
+ case "--resource":
+ case "--res":
+ if ((i + 1) >= args.Length)
+ {
+ Usage();
+ Report.Error(5, "Missing argument to --resource");
+ Environment.Exit(1);
+ }
+ if (embedded_resources == null)
+ embedded_resources = new ArrayList();
+
+ embedded_resources.Add(args[++i]);
return true;
+
}
return false;
}
@@ -385,21 +606,23 @@
// Currently it is very basic option parsing, but eventually, this will
// be the complete option parser
//
- static bool CSCParseOption (string option, ref string [] args, ref int i)
+ static bool CSCParseOption(string option, ref string [] args, ref int i)
{
- int idx = option.IndexOf (":");
+ int idx = option.IndexOf(":");
string arg, value;
- if (idx == -1){
+ if (idx == -1)
+ {
arg = option;
value = "";
- } else {
+ } else
+ {
arg = option.Substring (0, idx);
-
value = option.Substring (idx + 1);
}
- switch (arg){
+ switch(arg)
+ {
case "/nologo":
return true;
@@ -416,105 +639,37 @@
Usage ();
Environment.Exit (0);
return true;
- }
- return false;
- }
- static void SetupDefaultDefines()
- {
- defines = new ArrayList();
- defines.Add("__MonoCS__");
- defines.Add("__MCSDoc__");
- }
-
- public static void LoadReferences()
- {
- foreach(string r in references)
- LoadAssembly(r, false);
- foreach(string s in soft_references)
- LoadAssembly(s, true);
- }
-
- static void LoadAssembly(string assembly, bool isSoft)
- {
- Assembly a;
- string total_log = "";
-
- try
- {
- char[] path_chars = { '/', '\\', '.' };
- if(assembly.IndexOfAny(path_chars) != -1)
+ case "/linkresource":
+ case "/linkres":
+ if ((i + 1) >= args.Length)
{
- a = Assembly.LoadFrom(assembly);
- } else
- {
- a = Assembly.Load(assembly);
+ Usage();
+ Report.Error(5, "Missing argument to --linkres");
+ Environment.Exit(1);
}
- TypeManager.AddAssembly(a);
- } catch(FileNotFoundException)
- {
- foreach(string dir in link_paths)
- {
- string full_path = Path.Combine(dir, assembly);
- if (!assembly.EndsWith(".dll"))
- full_path += ".dll";
+ if (resources == null)
+ resources = new ArrayList();
- try
- {
- a = Assembly.LoadFrom(full_path);
- TypeManager.AddAssembly(a);
- return;
- } catch (FileNotFoundException ff)
- {
- total_log += ff.FusionLog;
- continue;
- }
- }
- if(!isSoft)
+ resources.Add(args[++i]);
+ return true;
+
+ case "/resource":
+ case "/res":
+ if ((i + 1) >= args.Length)
{
- Report.Error(6, "Cannot find assembly `" + assembly + "'" );
- Console.WriteLine("Log: \n" + total_log);
+ Usage();
+ Report.Error(5, "Missing argument to --resource");
+ Environment.Exit(1);
}
- } catch(BadImageFormatException f)
- {
- Report.Error(6, "Cannot load assembly (bad file format)" + f.FusionLog);
- } catch(FileLoadException f)
- {
- Report.Error(6, "Cannot load assembly " + f.FusionLog);
- } catch(ArgumentNullException)
- {
- Report.Error(6, "Cannot load assembly (null argument)");
- }
- }
+ if (embedded_resources == null)
+ embedded_resources = new ArrayList();
- static void DefineDefaultConfig()
- {
- string [] default_config = {
- "System",
- "System.Xml",
- "Accessibility",
- "System.Configuration.Install",
- "System.Data",
- "System.Design",
- "System.DirectoryServices",
- "System.Drawing.Design",
- "System.Drawing",
- "System.EnterpriseServices",
- "System.Management",
- "System.Messaging",
- "System.Runtime.Remoting",
- "System.Runtime.Serialization.Formatters.Soap",
- "System.Security",
- "System.ServiceProcess",
- "System.Web",
- "System.Web.RegularExpressions",
- "System.Web.Services",
- "System.Windows.Forms"
- };
-
- int p = 0;
- foreach (string def in default_config)
- soft_references.Insert (p++, def);
+ embedded_resources.Add(args[++i]);
+ return true;
+
+ }
+ return false;
}
/// <summary>
@@ -532,17 +687,31 @@
int i;
bool parsing_options = true;
- try {
+ try
+ {
encoding = Encoding.GetEncoding (28591);
- } catch {
+ } catch
+ {
Console.WriteLine ("Error: could not load encoding 28591, trying 1252");
encoding = Encoding.GetEncoding (1252);
}
+ references = new ArrayList();
+ soft_references = new ArrayList();
+ link_paths = new ArrayList();
+
SetupDefaultDefines();
+ //
+ // Setup defaults
+ //
+ // This is not required because Assembly.Load knows about this
+ // path.
+ //
+
int argc = args.Length;
- for (i = 0; i < argc; i++){
+ for (i = 0; i < argc; i++)
+ {
string arg = args [i];
if (arg.StartsWith ("@")){
@@ -598,103 +767,226 @@
}
}
- CompileFiles (arg, false);
+ CompileFiles(arg, false);
}
- ProcessFiles ();
+ ProcessFiles();
if (first_source == null){
Report.Error (2008, "No files to compile were specified");
return false;
}
- if(Report.Errors > 0)
+ if (Report.Errors > 0)
return false;
- if(RootContext.StdLib)
- {
- references.Insert(0, "mscorlib");
- }
-
- DefineDefaultConfig();
-
- if(Report.Errors > 0)
+ //
+ // Load Core Library for default compilation
+ //
+ if (RootContext.StdLib)
+ references.Insert (0, "mscorlib");
+
+ if (load_default_config)
+ DefineDefaultConfig ();
+
+ if (Report.Errors > 0){
return false;
+ }
+
+ //
+ // Load assemblies required
+ //
+ first_time = last_time = DateTime.Now;
+
+ ShowTime ("Loading references");
link_paths.Add(GetSystemDir());
LoadReferences();
-
- if(Report.Errors > 0)
+
+ ShowTime(" References loaded");
+
+ if (Report.Errors > 0){
return false;
-
- if(!RootContext.StdLib)
+ }
+
+ //
+ // Quick hack
+ //
+ // Unfortunately, I'll need to keep this. :-((
+ output_file = "MCSDoc.dll";
+ //*/
+
+ CodeGen.Init(output_file, output_file, want_debugging_support);
+
+ TypeManager.AddModule(CodeGen.ModuleBuilder);
+
+#if false
+ DateTime start = DateTime.Now;
+ TypeManager.GetAssemblyNamespaces (output_file);
+ DateTime end = DateTime.Now;
+ //Console.WriteLine ("Loading namespaces: " + (end - start));
+ start = DateTime.Now;
+ //TypeManager.GetAllTypes ();
+ end = DateTime.Now;
+ //Console.WriteLine ("Getting Types: " + (end - start));
+#endif
+
+ //
+ // Before emitting, we need to get the core
+ // types emitted from the user defined types
+ // or from the system ones.
+ //
+ ShowTime("Initializing Core Types");
+
+ if (!RootContext.StdLib)
{
RootContext.ResolveCore();
if(Report.Errors > 0)
return false;
}
-
- //TypeManager.InitCoreTypes();
- //RootContext.ResolveTree();
- if(!RootContext.StdLib)
- RootContext.BootCorlib_PopulateCoreTypes();
- RootContext.PopulateTypes ();
- RootContext.DefineTypes ();
+ TypeManager.InitCoreTypes();
- if(Report.Errors > 0)
- return false;
+ ShowTime(" Core Types done");
+
+ //
+ // The second pass of the compiler
+ //
+ ShowTime("Resolving tree");
- TypeContainer tc = RootContext.Tree.Types;
- ArrayList tree = tc.Types;
- foreach(object current in tree)
+ RootContext.ResolveTree();
+
+ ShowTime("Populate tree");
+
+ if (!RootContext.StdLib)
+ RootContext.BootCorlib_PopulateCoreTypes ();
+ RootContext.PopulateTypes();
+ RootContext.DefineTypes();
+
+ TypeManager.InitCodeHelpers ();
+
+ if (Report.Errors > 0)
{
- string dispName = "";
- string baseNames = "";
- if(current is Class)
- {
- baseNames = DisplayClass((Class)current);
- dispName = ((Class)current).Name + baseNames;
+ System.Console.WriteLine("Exiting after initializing code helpers...");
+ return false;
+ }
+
+ //
+ // The code generator
+ //
+ // Now, I don't need the rest of the stuff.
+#if false
+ if (timestamps)
+ ShowTime ("Emitting code");
+ ShowTotalTime ("Total so far");
+ RootContext.EmitCode();
+ if (timestamps)
+ ShowTime (" done");
+
+ if (Report.Errors > 0){
+ return false;
+ }
+
+ if (timestamps)
+ ShowTime ("Closing types");
+
+ if (RootContext.WarningLevel >= 4)
+ if (!Namespace.VerifyUsing ())
+ return false;
+
+ RootContext.CloseTypes ();
+
+ PEFileKinds k = PEFileKinds.ConsoleApplication;
+
+ if (target == Target.Library || target == Target.Module)
+ k = PEFileKinds.Dll;
+ else if (target == Target.Exe)
+ k = PEFileKinds.ConsoleApplication;
+ else if (target == Target.WinExe)
+ k = PEFileKinds.WindowApplication;
+
+ if (target == Target.Exe || target == Target.WinExe){
+ MethodInfo ep = RootContext.EntryPoint;
+
+ if (ep == null){
+ if (Report.Errors == 0)
+ Report.Error (5001, "Program " + output_file +
+ " does not have an entry point defined");
+ return false;
}
- else if(current is Struct)
- dispName = ((Struct)current).Name;
- Console.WriteLine("<type>: " + current.GetType().ToString() + "->" + dispName);
+
+ CodeGen.AssemblyBuilder.SetEntryPoint (ep, k);
}
- Console.WriteLine("\n-----Finished with structs and classes-----\n");
- if(tc.Interfaces != null)
- foreach(Interface interf in tc.Interfaces)
- {
- Console.WriteLine("<type>: " + interf.GetType().ToString() + "->" + interf.Name);
+
+ //
+ // Add the resources
+ //
+ if (resources != null){
+ foreach (string spec in resources){
+ string file, res;
+ int cp;
+
+ cp = spec.IndexOf (',');
+ if (cp != -1){
+ file = spec.Substring (0, cp);
+ res = spec.Substring (cp + 1);
+ } else
+ file = res = spec;
+
+ CodeGen.AssemblyBuilder.AddResourceFile (res, file);
}
- Console.WriteLine("\n-----Finished with inteface -----\n");
- if(tc.Enums != null)
- foreach(Mono.CSharp.Enum e in tc.Enums)
- {
- Console.WriteLine("<type>: " + e.GetType().ToString() + "->" + e.Name);
+ }
+
+ if (embedded_resources != null){
+ object[] margs = new object [2];
+ Type[] argst = new Type [2];
+ argst [0] = argst [1] = typeof (string);
+ MethodInfo embed_res = typeof (AssemblyBuilder).GetMethod ("EmbedResourceFile", argst);
+ if (embed_res == null) {
+ Report.Warning (0, new Location (-1), "Cannot embed resources on this runtime: try the Mono runtime instead.");
+ } else {
+ foreach (string spec in embedded_resources) {
+ int cp;
+
+ cp = spec.IndexOf (',');
+ if (cp != -1){
+ margs [0] = spec.Substring (cp + 1);
+ margs [1] = spec.Substring (0, cp);
+ } else
+ margs [0] = margs [1] = spec;
+
+ if (File.Exists ((string) margs [1]))
+ embed_res.Invoke (CodeGen.AssemblyBuilder, margs);
+ else {
+ Report.Error (1566, "Can not find the resource " + margs [1]);
+ }
+ }
}
+ }
- return (Report.Errors == 0);
- }
+ if (Report.Errors > 0)
+ return false;
- static string DisplayClass(Class klass)
- {
- string retVal = ": ";
- ArrayList b = klass.Bases;
- if(b == null || b.Count == 0)
- {
- Console.WriteLine("------- No Bases -------");
- return String.Empty;
+ CodeGen.Save (output_file);
+ if (timestamps) {
+ ShowTime ("Saved output");
+ ShowTotalTime ("Total");
}
- foreach(object tc in b)
- {
- //if(tc is Class)
- // retVal += (((Class)tc).Name + ", ");
- //else if(tc is Interface)
- // retVal += (((Interface)tc).Name + ", ");
- //else
- retVal += (tc.ToString() + ", ");
+
+ Timer.ShowTimers ();
+
+ if (Report.ExpectedError != 0){
+ Console.WriteLine("Failed to report expected error " + Report.ExpectedError);
+ Environment.Exit (1);
+ return false;
}
- return retVal.Substring(0, retVal.Length - 2);
+#endif
+#if DEBUGME
+ Console.WriteLine ("Size of strings held: " + DeclSpace.length);
+ Console.WriteLine ("Size of strings short: " + DeclSpace.small);
+#endif
+ return (Report.Errors == 0);
}
+
}
}
|