using System.Reflection.Emit;
using System.Diagnostics;
-namespace Mono.CSharp {
+namespace Mono.MonoBASIC {
public class RootContext {
//
static Tree tree;
+ //
+ // Tracks Imported namespaces
+ //
+ static SourceBeingCompiled sourceBeingCompiled = new SourceBeingCompiled();
+
//
// This hashtable contains all of the #definitions across the source code
// it is used by the ConditionalAttribute handler.
//
public static Hashtable AllDefines = new Hashtable ();
- //
- // The list of global attributes (those that target the assembly)
- //
- static Hashtable global_attributes = new Hashtable ();
-
//
// Whether we are being linked against the standard libraries.
// This is only used to tell whether `System.Object' should
attribute_types.Add (tc);
}
+ public static void InitializeImports(ArrayList ImportsList)
+ {
+ sourceBeingCompiled.InitializeImports (ImportsList);
+ }
+
+ public static SourceBeingCompiled SourceBeingCompiled
+ {
+ get { return sourceBeingCompiled; }
+ }
+
+ public static void VerifyImports()
+ {
+ sourceBeingCompiled.VerifyImports();
+ }
+
//
// The default compiler checked state
//
//
static public bool Unsafe = false;
+ // Root namespace name (implicit namespace)
+ static public string RootNamespace = "";
+
static string MakeFQN (string nsn, string name)
{
string prefix = (nsn == "" ? "" : nsn + ".");
{
TypeContainer root = Tree.Types;
- ArrayList ifaces = root.Interfaces;
+ //ArrayList ifaces = root.Interfaces;
if (root.Enums != null)
foreach (Enum en in root.Enums)
//
// Try the aliases in the current namespace
//
- string alias = curr_ns.LookupAlias (name);
+ string alias = sourceBeingCompiled.LookupAlias (name);
if (alias != null) {
t = TypeManager.LookupType (alias);
//
// Then try with the using clauses
//
- ArrayList using_list = ns.UsingTable;
- if (using_list == null)
+ ICollection imports_list = sourceBeingCompiled.ImportsTable;
+
+ if (imports_list == null)
continue;
Type match = null;
- foreach (Namespace.UsingEntry ue in using_list) {
+ foreach (SourceBeingCompiled.ImportsEntry ue in imports_list) {
+ //TODO: deal with standard modules
match = TypeManager.LookupType (MakeFQN (ue.Name, name));
if (match != null){
if (t != null){
//
// Try with aliases
//
- string a = ns.LookupAlias (name);
+ string a = sourceBeingCompiled.LookupAlias (name);
if (a != null) {
t = TypeManager.LookupType (a);
if (t != null)
}
if (!silent)
- Report.Error (246, loc, "Cannot find type `"+name+"'");
+ Report.Error (30002, loc, "Cannot find type `"+name+"'");
return null;
}
static public void EmitCode ()
{
- //
- // Because of the strange way in which we do things, global
- // attributes must be processed first.
- //
- if (global_attributes.Count > 0){
- AssemblyBuilder ab = CodeGen.AssemblyBuilder;
- TypeContainer dummy = new TypeContainer (null, "", new Location (-1));
- EmitContext temp_ec = new EmitContext (
- dummy, Mono.CSharp.Location.Null, null, null, 0, false);
-
- foreach (DictionaryEntry de in global_attributes){
- Namespace ns = (Namespace) de.Key;
- Attributes attrs = (Attributes) de.Value;
-
- dummy.Namespace = ns;
- Attribute.ApplyAttributes (temp_ec, ab, ab, attrs, attrs.Location);
- }
- }
-
if (attribute_types != null)
foreach (TypeContainer tc in attribute_types)
tc.Emit ();
+
+ CodeGen.EmitGlobalAttributes ();
if (type_container_resolve_order != null) {
foreach (TypeContainer tc in type_container_resolve_order)
static public FieldBuilder MakeStaticData (byte [] data)
{
FieldBuilder fb;
- int size = data.Length;
+ //int size = data.Length;
if (impl_details_class == null)
impl_details_class = CodeGen.ModuleBuilder.DefineType (
return fb;
}
- //
- // Adds a global attribute that was declared in `container',
- // the attribute is in `attr', and it was defined at `loc'
- //
- static public void AddGlobalAttribute (TypeContainer container,
- AttributeSection attr, Location loc)
- {
- Namespace ns = container.Namespace;
- Attributes a = (Attributes) global_attributes [ns];
-
- if (a == null)
- global_attributes [ns] = new Attributes (attr, loc);
- else
- a.AddAttribute (attr);
- }
}
}
-
-