Skip to content

Commit

Permalink
**** Merged from MCS ****
Browse files Browse the repository at this point in the history
svn path=/trunk/mcs/; revision=34173
  • Loading branch information
Martin Baulig committed Sep 21, 2004
1 parent 95231dc commit beb2c32
Show file tree
Hide file tree
Showing 13 changed files with 198 additions and 245 deletions.
2 changes: 1 addition & 1 deletion mcs/gmcs/assign.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public override Expression DoResolve (EmitContext ec)
}

if ((source.eclass == ExprClass.Type) && (source is TypeExpr)) {
source.Error_UnexpectedKind ("variable or value");
source.Error_UnexpectedKind ("variable or value", loc);
return null;
} else if ((RootContext.Version == LanguageVersion.ISO_1) &&
(source is MethodGroupExpr)){
Expand Down
6 changes: 3 additions & 3 deletions mcs/gmcs/attribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ void Error_InvalidNamedArgument (string name)
{
Report.Error (617, Location, "'" + name + "' is not a valid named attribute " +
"argument. Named attribute arguments must be fields which are not " +
"readonly, static or const, or properties with a set accessor which "+
"are not static.");
"readonly, static or const, or read-write properties which are not static.");
}

static void Error_AttributeArgumentNotValid (Location loc)
Expand Down Expand Up @@ -404,7 +403,8 @@ public CustomAttributeBuilder Resolve (EmitContext ec)
PropertyExpr pe = (PropertyExpr) member;
PropertyInfo pi = pe.PropertyInfo;

if (!pi.CanWrite) {
if (!pi.CanWrite || !pi.CanRead) {
Report.SymbolRelatedToPreviousError (pi);
Error_InvalidNamedArgument (member_name);
return null;
}
Expand Down
22 changes: 11 additions & 11 deletions mcs/gmcs/class.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public override void DefineContainerMembers ()
MethodArrayList methods;

// Holds the events
MemberCoreArrayList events;
protected MemberCoreArrayList events;

// Holds the indexers
IndexerArrayList indexers;
Expand Down Expand Up @@ -535,7 +535,7 @@ public void AddMethod (Method method)
public void AddConstructor (Constructor c)
{
if (c.Name != Basename) {
Report.Error (1520, Location, "Class, struct, or interface method must have a return type");
Report.Error (1520, c.Location, "Class, struct, or interface method must have a return type");
}

bool is_static = (c.ModFlags & Modifiers.STATIC) != 0;
Expand Down Expand Up @@ -1013,8 +1013,7 @@ TypeExpr[] GetNormalBases (out TypeExpr parent, out bool error)
/// </summary>
TypeExpr [] GetClassBases (out TypeExpr parent, out bool error)
{
ArrayList bases = Bases;
int start, j, i;
int i;

error = false;

Expand Down Expand Up @@ -2126,13 +2125,6 @@ protected virtual void VerifyMembers (EmitContext ec)
Report.Warning (649, f.Location, "Field '{0}' is never assigned to, and will always have its default value '{1}'", f.GetSignatureForError (), "");
}
}

if ((events != null) && (RootContext.WarningLevel >= 3)) {
foreach (Event e in events){
if (e.status == 0)
Report.Warning (67, e.Location, "The event '{0}' is never used", e.GetSignatureForError ());
}
}
}
}

Expand Down Expand Up @@ -2752,7 +2744,15 @@ protected override void VerifyMembers (EmitContext ec)
}
}
}

base.VerifyMembers (ec);

if ((events != null) && (RootContext.WarningLevel >= 3)) {
foreach (Event e in events){
if (e.status == 0)
Report.Warning (67, e.Location, "The event '{0}' is never used", e.GetSignatureForError ());
}
}
}

public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
Expand Down
65 changes: 38 additions & 27 deletions mcs/gmcs/codegen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ static public void Save (string name)
// variable mapping.
//
public class VariableStorage {
ILGenerator ig;
FieldBuilder fb;
LocalBuilder local;

Expand All @@ -194,47 +193,46 @@ public VariableStorage (EmitContext ec, Type t)
fb = ec.CurrentIterator.MapVariable ("s_", count.ToString (), t);
else
local = ec.ig.DeclareLocal (t);
ig = ec.ig;
}

public void EmitThis ()
public void EmitThis (ILGenerator ig)
{
if (fb != null)
ig.Emit (OpCodes.Ldarg_0);
}

public void EmitStore ()
public void EmitStore (ILGenerator ig)
{
if (fb == null)
ig.Emit (OpCodes.Stloc, local);
else
ig.Emit (OpCodes.Stfld, fb);
}

public void EmitLoad ()
public void EmitLoad (ILGenerator ig)
{
if (fb == null)
ig.Emit (OpCodes.Ldloc, local);
else
ig.Emit (OpCodes.Ldfld, fb);
}

public void EmitLoadAddress ()
public void EmitLoadAddress (ILGenerator ig)
{
if (fb == null)
ig.Emit (OpCodes.Ldloca, local);
else
ig.Emit (OpCodes.Ldflda, fb);
}

public void EmitCall (MethodInfo mi)
public void EmitCall (ILGenerator ig, MethodInfo mi)
{
// FIXME : we should handle a call like tostring
// here, where boxing is needed. However, we will
// never encounter that with the current usage.

bool value_type_call;
EmitThis ();
EmitThis (ig);
if (fb == null) {
value_type_call = local.LocalType.IsValueType;

Expand Down Expand Up @@ -889,6 +887,37 @@ public void ResolveClsCompliance ()
is_cls_compliant = a.GetClsCompliantAttributeValue (null);
}

// fix bug #56621
private void SetPublicKey (AssemblyName an, byte[] strongNameBlob)
{
try {
// check for possible ECMA key
if (strongNameBlob.Length == 16) {
// will be rejected if not "the" ECMA key
an.SetPublicKey (strongNameBlob);
}
else {
// take it, with or without, a private key
RSA rsa = CryptoConvert.FromCapiKeyBlob (strongNameBlob);
// and make sure we only feed the public part to Sys.Ref
byte[] publickey = CryptoConvert.ToCapiPublicKeyBlob (rsa);

// AssemblyName.SetPublicKey requires an additional header
byte[] publicKeyHeader = new byte [12] { 0x00, 0x24, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00 };

byte[] encodedPublicKey = new byte [12 + publickey.Length];
Buffer.BlockCopy (publicKeyHeader, 0, encodedPublicKey, 0, 12);
Buffer.BlockCopy (publickey, 0, encodedPublicKey, 12, publickey.Length);
an.SetPublicKey (encodedPublicKey);
}
}
catch (Exception) {
Report.Error (1548, "Could not strongname the assembly. File `" +
RootContext.StrongNameKeyFile + "' incorrectly encoded.");
Environment.Exit (1);
}
}

public AssemblyName GetAssemblyName (string name, string output)
{
if (OptAttributes != null) {
Expand Down Expand Up @@ -969,25 +998,7 @@ public AssemblyName GetAssemblyName (string name, string output)

if (RootContext.StrongNameDelaySign) {
// delayed signing - DO NOT include private key
try {
// check for possible ECMA key
if (snkeypair.Length == 16) {
// will be rejected if not "the" ECMA key
an.KeyPair = new StrongNameKeyPair (snkeypair);
}
else {
// take it, with or without, a private key
RSA rsa = CryptoConvert.FromCapiKeyBlob (snkeypair);
// and make sure we only feed the public part to Sys.Ref
byte[] publickey = CryptoConvert.ToCapiPublicKeyBlob (rsa);
an.KeyPair = new StrongNameKeyPair (publickey);
}
}
catch (Exception) {
Report.Error (1548, "Could not strongname the assembly. File `" +
RootContext.StrongNameKeyFile + "' incorrectly encoded.");
Environment.Exit (1);
}
SetPublicKey (an, snkeypair);
}
else {
// no delay so we make sure we have the private key
Expand Down
1 change: 1 addition & 0 deletions mcs/gmcs/const.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public Const (TypeContainer parent, Expression constant_type, string name,
new MemberName (name), null, attrs, loc)
{
Expr = expr;
ModFlags |= Modifiers.STATIC;
}

public FieldAttributes FieldAttr {
Expand Down
31 changes: 20 additions & 11 deletions mcs/gmcs/cs-parser.jay
Original file line number Diff line number Diff line change
Expand Up @@ -825,12 +825,17 @@ constant_declaration
constant_declarators
SEMICOLON
{
int modflags = (int) $2;
foreach (VariableDeclaration constant in (ArrayList) $5){
Location l = constant.Location;
if ((modflags & Modifiers.STATIC) != 0) {
Report.Error (504, l, "The constant '{0}' cannot be marked static", current_container.GetSignatureForError () + '.' + (string) constant.identifier);
continue;
}

Const c = new Const (
current_class, (Expression) $4, (string) constant.identifier,
(Expression) constant.expression_or_array_initializer, (int) $2,
(Expression) constant.expression_or_array_initializer, modflags,
(Attributes) $1, l);

current_container.AddConstant (c);
Expand Down Expand Up @@ -1725,7 +1730,7 @@ constructor_declaration
}
} else {
// We let another layer check the validity of the constructor.
Console.WriteLine ("{0} and {1}", c.Name, current_container.Basename);
//Console.WriteLine ("{0} and {1}", c.Name, current_container.Basename);
}

current_container.AddConstructor (c);
Expand Down Expand Up @@ -3995,19 +4000,23 @@ try_statement
: TRY block catch_clauses
{
Catch g = null;
ArrayList s = new ArrayList (4);

foreach (Catch cc in (ArrayList) $3) {
if (cc.IsGeneral)
ArrayList c = (ArrayList)$3;
for (int i = 0; i < c.Count; ++i) {
Catch cc = (Catch) c [i];
if (cc.IsGeneral) {
if (i != c.Count - 1)
Report.Error (1017, cc.loc, "Empty catch block must be the last in a series of catch blocks");
g = cc;
else
s.Add (cc);
c.RemoveAt (i);
i--;
}
}

// Now s contains the list of specific catch clauses
// and g contains the general one.

$$ = new Try ((Block) $2, s, g, null, lexer.Location);
$$ = new Try ((Block) $2, c, g, null, lexer.Location);
}
| TRY block opt_catch_clauses FINALLY block
{
Expand Down Expand Up @@ -4624,10 +4633,10 @@ public void parse ()
Tokenizer tokenizer = lexer as Tokenizer;
tokenizer.cleanup ();
} catch (Exception e){
// Please do not remove this, it is used during debugging
// of the grammar
//
Console.WriteLine (e);
// Removed for production use, use parser verbose to get the output.
//
// Console.WriteLine (e);
Report.Error (-25, lexer.Location, "Parsing error");
if (Driver.parser_verbose)
Console.WriteLine (e);
Expand Down
2 changes: 1 addition & 1 deletion mcs/gmcs/delegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ public override Expression DoResolve (EmitContext ec)
Type e_type = e.Type;

if (!TypeManager.IsDelegateType (e_type)) {
e.Error_UnexpectedKind ("method");
e.Error_UnexpectedKind ("method", loc);
return null;
}

Expand Down
14 changes: 8 additions & 6 deletions mcs/gmcs/driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,6 @@ public class Driver
//
static bool using_default_encoder = true;

//
// The system version we are using, if not specified on the commandline we
// will use the same version as corlib for looking for libraries in the GAC.
//
static string sys_version;

public static void ShowTime (string msg)
{
if (!timestamps)
Expand Down Expand Up @@ -1052,7 +1046,15 @@ static bool CSCParseOption (string option, ref string [] args, ref int i)
if (embedded_resources == null)
embedded_resources = new ArrayList ();

if (embedded_resources.Contains (value)) {
Report.Error (1508, String.Format ("The resource identifier '{0}' has already been used in this assembly.", value));
}
else if (value.IndexOf (',') != -1 && embedded_resources.Contains (value.Split (',')[1])) {
Report.Error (1508, String.Format ("The resource identifier '{0}' has already been used in this assembly.", value));
}
else {
embedded_resources.Add (value);
}
return true;

case "/recurse":
Expand Down
Loading

0 comments on commit beb2c32

Please sign in to comment.