Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs/ilasm
diff options
context:
space:
mode:
authorAnkit Jain <radical@corewars.org>2006-05-26 18:11:50 +0400
committerAnkit Jain <radical@corewars.org>2006-05-26 18:11:50 +0400
commit23004be596eb133dc1f3cae89957f2626ecf5dd3 (patch)
tree9afb62ecce91052d5be85a7bc51ffab565359114 /mcs/ilasm
parentfc3c6e7fd36e853910b8c651befdfc00959d4740 (diff)
In ilasm/codegen:
* Assembly.cs: New. Represents a '.assembly {}' (assembly manifest). * CodeGen.cs: Update to use the Assembly class. In ilasm: * ilasm.exe.sources: Add Assembly.cs * Driver.cs: Update to use the new Assembly class. * ilasm.exe.sources: Add PermissionMember.cs, PermissionSet.cs & Permission.cs In ilasm/parser: * ILParser.jay: Update to use new Assembly class. svn path=/trunk/mcs/; revision=61164
Diffstat (limited to 'mcs/ilasm')
-rw-r--r--mcs/ilasm/ChangeLog10
-rw-r--r--mcs/ilasm/Driver.cs4
-rw-r--r--mcs/ilasm/codegen/Assembly.cs116
-rw-r--r--mcs/ilasm/codegen/ChangeLog5
-rw-r--r--mcs/ilasm/codegen/CodeGen.cs82
-rw-r--r--mcs/ilasm/ilasm.exe.sources1
-rw-r--r--mcs/ilasm/parser/ChangeLog4
-rw-r--r--mcs/ilasm/parser/ILParser.jay33
8 files changed, 166 insertions, 89 deletions
diff --git a/mcs/ilasm/ChangeLog b/mcs/ilasm/ChangeLog
index 96f78e20f3e..5e7c15a5221 100644
--- a/mcs/ilasm/ChangeLog
+++ b/mcs/ilasm/ChangeLog
@@ -1,3 +1,13 @@
+2006-05-26 Ankit Jain <jankit@novell.com>
+
+ * ilasm.exe.sources: Add Assembly.cs
+ * Driver.cs: Update to use the new Assembly class.
+
+2006-05-26 Ankit Jain <jankit@novell.com>
+
+ * ilasm.exe.sources: Add PermissionMember.cs, PermissionSet.cs &
+ Permission.cs
+
2006-05-11 Ankit Jain <jankit@novell.com>
* Report.cs (Report.Error): Add 2 new overloads.
diff --git a/mcs/ilasm/Driver.cs b/mcs/ilasm/Driver.cs
index 1b5ea904abe..d57ba98fe11 100644
--- a/mcs/ilasm/Driver.cs
+++ b/mcs/ilasm/Driver.cs
@@ -83,7 +83,7 @@ namespace Mono.ILASM {
if ((keyname != null) && !codegen.IsThisAssembly (null)) {
LoadKey ();
// this overrides any attribute or .publickey directive in the source
- codegen.SetAssemblyPublicKey (sn.PublicKey);
+ codegen.ThisAssembly.SetPublicKey (sn.PublicKey);
}
try {
@@ -360,7 +360,7 @@ namespace Mono.ILASM {
private void Version ()
{
- string version = Assembly.GetExecutingAssembly ().GetName ().Version.ToString ();
+ string version = System.Reflection.Assembly.GetExecutingAssembly ().GetName ().Version.ToString ();
Console.WriteLine ("Mono ILasm compiler version {0}", version);
Environment.Exit (0);
}
diff --git a/mcs/ilasm/codegen/Assembly.cs b/mcs/ilasm/codegen/Assembly.cs
new file mode 100644
index 00000000000..2a58988b47d
--- /dev/null
+++ b/mcs/ilasm/codegen/Assembly.cs
@@ -0,0 +1,116 @@
+//
+// Mono.ILASM.Assembly
+//
+// Represents .assembly { }
+//
+// Author(s):
+// Ankit Jain <JAnkit@novell.com>
+//
+// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System.Collections;
+
+namespace Mono.ILASM {
+
+ public class Assembly : IDeclSecurityTarget, ICustomAttrTarget
+ {
+ private DeclSecurity decl_sec;
+ private ArrayList customattr_list;
+
+ private string name;
+ private byte [] public_key;
+ private int major_version;
+ private int minor_version;
+ private int build_version;
+ private int revision_version;
+ private string locale;
+ private int hash_algorithm;
+
+ public Assembly (string name)
+ {
+ this.name = name;
+ }
+
+ public string Name {
+ get { return name; }
+ }
+
+ public DeclSecurity DeclSecurity {
+ get {
+ if (decl_sec == null)
+ decl_sec = new DeclSecurity ();
+ return decl_sec;
+ }
+ }
+
+ public void SetVersion (int major, int minor, int build, int revision)
+ {
+ this.major_version = major;
+ this.minor_version = minor;
+ this.build_version = build;
+ this.revision_version = revision;
+ }
+
+ public void SetLocale (string locale)
+ {
+ this.locale = locale;
+ }
+
+ public void SetHashAlgorithm (int algorithm)
+ {
+ hash_algorithm = algorithm;
+ }
+
+ public void SetPublicKey (byte [] public_key)
+ {
+ this.public_key = public_key;
+ }
+
+ public void AddCustomAttribute (CustomAttr customattr)
+ {
+ if (customattr_list == null)
+ customattr_list = new ArrayList ();
+
+ customattr_list.Add (customattr);
+ }
+
+ public void Resolve (CodeGen code_gen, PEAPI.Assembly asm)
+ {
+ if (customattr_list != null)
+ foreach (CustomAttr customattr in customattr_list) {
+ customattr.AddTo (code_gen, asm);
+ }
+
+ if (decl_sec != null)
+ decl_sec.AddTo (code_gen, asm);
+
+
+ asm.AddAssemblyInfo(major_version,
+ minor_version, build_version,
+ revision_version, public_key,
+ (uint) hash_algorithm, locale);
+
+ }
+ }
+}
diff --git a/mcs/ilasm/codegen/ChangeLog b/mcs/ilasm/codegen/ChangeLog
index ff553c38b79..d640e9fdbf6 100644
--- a/mcs/ilasm/codegen/ChangeLog
+++ b/mcs/ilasm/codegen/ChangeLog
@@ -1,5 +1,10 @@
2006-05-26 Ankit Jain <jankit@novell.com>
+ * Assembly.cs: New. Represents a '.assembly {}' (assembly manifest).
+ * CodeGen.cs: Update to use the Assembly class.
+
+2006-05-26 Ankit Jain <jankit@novell.com>
+
* PermissionSet.cs: New.
* Permission.cs: New.
* PermissionMember.cs: New. Classes for 2.0 metadata format of
diff --git a/mcs/ilasm/codegen/CodeGen.cs b/mcs/ilasm/codegen/CodeGen.cs
index 5971e442139..5fcf3cac5cf 100644
--- a/mcs/ilasm/codegen/CodeGen.cs
+++ b/mcs/ilasm/codegen/CodeGen.cs
@@ -21,12 +21,13 @@ using System.Security;
using SSPermissionSet = System.Security.PermissionSet;
using MIPermissionSet = Mono.ILASM.PermissionSet;
+using MIAssembly = Mono.ILASM.Assembly;
+
namespace Mono.ILASM {
public class CodeGen {
private PEFile pefile;
- private string assembly_name;
private ExternAssembly current_assemblyref;
private ExternModule current_moduleref;
private string current_namespace;
@@ -39,15 +40,7 @@ namespace Mono.ILASM {
private IDeclSecurityTarget current_declsectarget;
private PEAPI.NativeType current_field_native_type;
- private byte [] assembly_public_key;
- private int assembly_major_version;
- private int assembly_minor_version;
- private int assembly_build_version;
- private int assembly_revision_version;
- private string assembly_locale;
- private int assembly_hash_algorithm;
- private ArrayList assembly_custom_attributes;
- private DeclSecurity assembly_declsec;
+ private MIAssembly this_assembly;
private TypeManager type_manager;
private ExternTable extern_table;
@@ -247,10 +240,11 @@ namespace Mono.ILASM {
public void SetAssemblyName (string name)
{
- if (assembly_name != null && assembly_name != name)
+ if (this_assembly != null && this_assembly.Name != name)
Report.Error ("Multiple assembly declarations");
- assembly_name = name;
- if (assembly_name != "mscorlib")
+
+ this_assembly = new Assembly (name);
+ if (name != "mscorlib")
ExternTable.AddCorlib ();
}
@@ -265,9 +259,13 @@ namespace Mono.ILASM {
this.file_ref = file_ref;
}
+ public MIAssembly ThisAssembly {
+ get { return this_assembly; }
+ }
+
public bool IsThisAssembly (string name)
{
- return (name == assembly_name);
+ return (this_assembly != null && name == this_assembly.Name);
}
public Module ThisModule {
@@ -429,44 +427,6 @@ namespace Mono.ILASM {
defcont_list.Add (typedef);
}
- public void SetAssemblyPublicKey (byte [] public_key)
- {
- assembly_public_key = public_key;
- }
-
- public void SetAssemblyVersion (int major, int minor, int build, int revision)
- {
- assembly_major_version = major;
- assembly_minor_version = minor;
- assembly_build_version = build;
- assembly_revision_version = revision;
- }
-
- public void SetAssemblyLocale (string locale)
- {
- assembly_locale = locale;
- }
-
- public void SetAssemblyHashAlgorithm (int algorithm)
- {
- assembly_hash_algorithm = algorithm;
- }
-
- public void AddAssemblyCustomAttribute (CustomAttr attribute)
- {
- if (assembly_custom_attributes == null)
- assembly_custom_attributes = new ArrayList ();
- assembly_custom_attributes.Add (attribute);
- }
-
- public void AddAssemblyPermission (PEAPI.SecurityAction sec_action, object perm)
- {
- if (assembly_declsec == null)
- assembly_declsec = new DeclSecurity ();
-
- AddPermission (sec_action, perm, assembly_declsec);
- }
-
public void AddPermission (PEAPI.SecurityAction sec_action, object perm)
{
if (CurrentDeclSecurityTarget == null)
@@ -505,7 +465,7 @@ namespace Mono.ILASM {
this_module = new Module (Path.GetFileName (output_file));
out_stream = new FileStream (output_file, FileMode.Create, FileAccess.Write);
- pefile = new PEFile (assembly_name, ThisModule.Name, is_dll, assembly_name != null, null, out_stream);
+ pefile = new PEFile (ThisAssembly != null ? ThisAssembly.Name : null, ThisModule.Name, is_dll, ThisAssembly != null, null, out_stream);
PEAPI.Assembly asmb = pefile.GetThisAssembly ();
ThisModule.PeapiModule = pefile.GetThisModule ();
@@ -533,16 +493,10 @@ namespace Mono.ILASM {
typedef.DefineContents (this);
}
- if (assembly_custom_attributes != null) {
- foreach (CustomAttr cattr in assembly_custom_attributes)
- cattr.AddTo (this, asmb);
- }
-
+ if (ThisAssembly != null)
+ ThisAssembly.Resolve (this, pefile.GetThisAssembly ());
ThisModule.Resolve (this, pefile.GetThisModule ());
- if (assembly_declsec != null)
- assembly_declsec.AddTo (this, asmb);
-
if (sub_system != -1)
pefile.SetSubSystem ((PEAPI.SubSystem) sub_system);
if (cor_flags != -1)
@@ -550,12 +504,6 @@ namespace Mono.ILASM {
if (stack_reserve != -1)
pefile.SetStackReserve (stack_reserve);
- if (asmb != null)
- asmb.AddAssemblyInfo(assembly_major_version,
- assembly_minor_version, assembly_build_version,
- assembly_revision_version, assembly_public_key,
- (uint) assembly_hash_algorithm, assembly_locale);
-
pefile.WritePEFile ();
if (symwriter != null) {
diff --git a/mcs/ilasm/ilasm.exe.sources b/mcs/ilasm/ilasm.exe.sources
index 8a82cc9b921..4659f94aa16 100644
--- a/mcs/ilasm/ilasm.exe.sources
+++ b/mcs/ilasm/ilasm.exe.sources
@@ -1,6 +1,7 @@
Driver.cs
Report.cs
AssemblyInfo.cs
+codegen/Assembly.cs
codegen/PermissionMember.cs
codegen/PermissionSet.cs
codegen/Permission.cs
diff --git a/mcs/ilasm/parser/ChangeLog b/mcs/ilasm/parser/ChangeLog
index 87fde52d96f..2d09e0f8aff 100644
--- a/mcs/ilasm/parser/ChangeLog
+++ b/mcs/ilasm/parser/ChangeLog
@@ -1,5 +1,9 @@
2006-05-26 Ankit Jain <jankit@novell.com>
+ * ILParser.jay: Update to use new Assembly class.
+
+2006-05-26 Ankit Jain <jankit@novell.com>
+
Add support or 2.0 style declarative security attributes.
* ILParser.jay (primitive_type): New. Extracted from 'type'.
(field_init_primitive): New. Extracted from 'field_init', with all
diff --git a/mcs/ilasm/parser/ILParser.jay b/mcs/ilasm/parser/ILParser.jay
index bf04b9b150a..29431572f7e 100644
--- a/mcs/ilasm/parser/ILParser.jay
+++ b/mcs/ilasm/parser/ILParser.jay
@@ -67,7 +67,7 @@ namespace Mono.ILASM {
return true;
}
- public void AddSecDecl (object perm)
+ public void AddSecDecl (object perm, bool for_assembly)
{
PermPair pp = perm as PermPair;
@@ -77,7 +77,7 @@ namespace Mono.ILASM {
return;
}
- if (!CheckSecurityActionValidity ((System.Security.Permissions.SecurityAction) pp.sec_action, false))
+ if (!CheckSecurityActionValidity ((System.Security.Permissions.SecurityAction) pp.sec_action, for_assembly))
Report.Error (String.Format ("Invalid security action : {0}", pp.sec_action));
codegen.AddPermission (pp.sec_action, pp.perm);
@@ -869,7 +869,7 @@ class_decl : method_all
| data_decl
| sec_decl
{
- AddSecDecl ($1);
+ AddSecDecl ($1, false);
}
| extsource_spec
| customattr_decl
@@ -2148,7 +2148,7 @@ method_decl : D_EMITBYTE int32
| instr
| sec_decl
{
- AddSecDecl ($1);
+ AddSecDecl ($1, false);
}
| extsource_spec
| language_decl
@@ -3038,12 +3038,15 @@ file_entry : /* EMPTY */
assembly_all : assembly_head OPEN_BRACE assembly_decls CLOSE_BRACE
{
codegen.CurrentCustomAttrTarget = null;
+ codegen.CurrentDeclSecurityTarget = null;
}
;
assembly_head : D_ASSEMBLY asm_attr slashed_name
{
codegen.SetAssemblyName ((string) $3);
+ codegen.CurrentCustomAttrTarget = codegen.ThisAssembly;
+ codegen.CurrentDeclSecurityTarget = codegen.ThisAssembly;
}
;
@@ -3059,38 +3062,28 @@ assembly_decls : /* EMPTY */
assembly_decl : D_PUBLICKEY ASSIGN bytes_list
{
- codegen.SetAssemblyPublicKey ((byte []) $3);
+ codegen.ThisAssembly.SetPublicKey ((byte []) $3);
}
| D_VER int32 COLON int32 COLON int32 COLON int32
{
- codegen.SetAssemblyVersion ((int) $2, (int) $4, (int) $6, (int) $8);
+ codegen.ThisAssembly.SetVersion ((int) $2, (int) $4, (int) $6, (int) $8);
}
| D_LOCALE comp_qstring
{
- codegen.SetAssemblyLocale ((string) $2);
+ codegen.ThisAssembly.SetLocale ((string) $2);
}
| D_LOCALE ASSIGN bytes_list
| D_HASH K_ALGORITHM int32
{
- codegen.SetAssemblyHashAlgorithm ((int) $3);
+ codegen.ThisAssembly.SetHashAlgorithm ((int) $3);
}
| customattr_decl
{
- codegen.AddAssemblyCustomAttribute ((CustomAttr) $1);
+ codegen.ThisAssembly.AddCustomAttribute ((CustomAttr) $1);
}
| sec_decl
{
- PermPair pp = $1 as PermPair;
- if (pp == null) {
- MIPermissionSet ps_20 = (MIPermissionSet) $1;
- codegen.AddAssemblyPermission (ps_20.SecurityAction, ps_20);
- break;
- }
-
- if (!CheckSecurityActionValidity ((System.Security.Permissions.SecurityAction) (short) pp.sec_action, true))
- Report.Error (String.Format ("Invalid security action : {0}", pp.sec_action));
-
- codegen.AddAssemblyPermission (pp.sec_action, pp.perm);
+ AddSecDecl ($1, true);
}
;