|
Lines 8-14
Link Here
|
| 8 |
// Dual licensed under the terms of the MIT X11 or GNU GPL |
8 |
// Dual licensed under the terms of the MIT X11 or GNU GPL |
| 9 |
// |
9 |
// |
| 10 |
// Copyright 2001, 2002, 2003 Ximian, Inc (http://www.ximian.com) |
10 |
// Copyright 2001, 2002, 2003 Ximian, Inc (http://www.ximian.com) |
| 11 |
// Copyright 2004, 2005, 2006, 2007, 2008 Novell, Inc |
11 |
// Copyright 2004, 2005, 2006, 2007, 2008, 2009 Novell, Inc |
| 12 |
// |
12 |
// |
| 13 |
|
13 |
|
| 14 |
namespace Mono.CSharp |
14 |
namespace Mono.CSharp |
|
Lines 17-22
Link Here
|
| 17 |
using System.Reflection; |
17 |
using System.Reflection; |
| 18 |
using System.Reflection.Emit; |
18 |
using System.Reflection.Emit; |
| 19 |
using System.Collections; |
19 |
using System.Collections; |
|
|
20 |
using System.Collections.Generic; |
| 20 |
using System.Collections.Specialized; |
21 |
using System.Collections.Specialized; |
| 21 |
using System.IO; |
22 |
using System.IO; |
| 22 |
using System.Text; |
23 |
using System.Text; |
|
Lines 318-326
Link Here
|
| 318 |
return 1; |
319 |
return 1; |
| 319 |
} |
320 |
} |
| 320 |
|
321 |
|
| 321 |
public void LoadAssembly (string assembly, bool soft) |
322 |
public Assembly LoadAssembly (string assembly, bool soft) |
| 322 |
{ |
323 |
{ |
| 323 |
LoadAssembly (assembly, null, soft); |
324 |
return LoadAssembly (assembly, null, soft); |
| 324 |
} |
325 |
} |
| 325 |
|
326 |
|
| 326 |
void Error6 (string name, string log) |
327 |
void Error6 (string name, string log) |
|
Lines 369-375
Link Here
|
| 369 |
Error9 ("assembly", filename, log); |
370 |
Error9 ("assembly", filename, log); |
| 370 |
} |
371 |
} |
| 371 |
|
372 |
|
| 372 |
public void LoadAssembly (string assembly, string alias, bool soft) |
373 |
public Assembly LoadAssembly (string assembly, string alias, bool soft) |
| 373 |
{ |
374 |
{ |
| 374 |
Assembly a = null; |
375 |
Assembly a = null; |
| 375 |
string total_log = ""; |
376 |
string total_log = ""; |
|
Lines 399-411
Link Here
|
| 399 |
break; |
400 |
break; |
| 400 |
} catch (FileNotFoundException ff) { |
401 |
} catch (FileNotFoundException ff) { |
| 401 |
if (soft) |
402 |
if (soft) |
| 402 |
return; |
403 |
return null; |
| 403 |
total_log += ff.FusionLog; |
404 |
total_log += ff.FusionLog; |
| 404 |
} |
405 |
} |
| 405 |
} |
406 |
} |
| 406 |
if (err) { |
407 |
if (err) { |
| 407 |
Error6 (assembly, total_log); |
408 |
Error6 (assembly, total_log); |
| 408 |
return; |
409 |
return null; |
| 409 |
} |
410 |
} |
| 410 |
} |
411 |
} |
| 411 |
|
412 |
|
|
Lines 422-427
Link Here
|
| 422 |
// ... while .NET 1.1 throws this |
423 |
// ... while .NET 1.1 throws this |
| 423 |
BadAssembly (f.FileName, f.FusionLog); |
424 |
BadAssembly (f.FileName, f.FusionLog); |
| 424 |
} |
425 |
} |
|
|
426 |
|
| 427 |
return a; |
| 425 |
} |
428 |
} |
| 426 |
|
429 |
|
| 427 |
public void LoadModule (string module) |
430 |
public void LoadModule (string module) |
|
Lines 473-489
Link Here
|
| 473 |
// |
476 |
// |
| 474 |
// Load Core Library for default compilation |
477 |
// Load Core Library for default compilation |
| 475 |
// |
478 |
// |
|
|
479 |
string core_lib_name = "mscorlib"; |
| 476 |
if (RootContext.StdLib) |
480 |
if (RootContext.StdLib) |
| 477 |
LoadAssembly ("mscorlib", false); |
481 |
LoadAssembly (core_lib_name, false); |
| 478 |
|
482 |
|
| 479 |
foreach (string r in soft_references) |
483 |
foreach (string r in soft_references) |
| 480 |
LoadAssembly (r, true); |
484 |
LoadAssembly (r, true); |
| 481 |
|
485 |
|
| 482 |
foreach (string r in references) |
486 |
List<Assembly> loaded_references = new List<Assembly> (); |
| 483 |
LoadAssembly (r, false); |
487 |
foreach (string r in references) { |
|
|
488 |
Assembly a = LoadAssembly (r, false); |
| 489 |
if (a != null) |
| 490 |
loaded_references.Add (a); |
| 491 |
} |
| 484 |
|
492 |
|
| 485 |
foreach (DictionaryEntry entry in external_aliases) |
493 |
foreach (DictionaryEntry entry in external_aliases) |
| 486 |
LoadAssembly ((string) entry.Value, (string) entry.Key, false); |
494 |
LoadAssembly ((string) entry.Value, (string) entry.Key, false); |
|
|
495 |
|
| 496 |
string mscorlib_name = core_lib_name + ", Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; |
| 497 |
|
| 498 |
bool failed_refs = false; |
| 499 |
foreach (Assembly a in loaded_references) { |
| 500 |
foreach (AssemblyName an in a.GetReferencedAssemblies ()) { |
| 501 |
if (an.ToString () == mscorlib_name) |
| 502 |
continue; |
| 503 |
|
| 504 |
Assembly match = null; |
| 505 |
foreach (Assembly candidate in loaded_references) { |
| 506 |
if (an.ToString () == candidate.GetName ().ToString ()) |
| 507 |
match = candidate; |
| 508 |
} |
| 509 |
if (match == null) { |
| 510 |
Report.Error (12, "The reference `{0}' depends on a type which is defined in an assembly that is not referenced. You must add a reference to assembly `{1}'", |
| 511 |
a.GetName ().Name, |
| 512 |
an.ToString ()); |
| 513 |
failed_refs = true; |
| 514 |
} |
| 515 |
} |
| 516 |
} |
| 517 |
|
| 518 |
if (failed_refs) |
| 519 |
Environment.Exit (1); |
| 487 |
|
520 |
|
| 488 |
GlobalRootNamespace.Instance.ComputeNamespaces (ctx); |
521 |
GlobalRootNamespace.Instance.ComputeNamespaces (ctx); |
| 489 |
} |
522 |
} |