* tree.cs (RecordNamespace): Fix up to check for the correct key.
* cs-parser.jay (GetQualifiedIdentifier): New Helper method used in
local_variable_type to extract the string corresponding to the type.
(local_variable_type): Fixup the action to use the new helper method.
* codegen.cs : Get rid of RefOrOutParameter, it's not the right way to
go.
* expression.cs : Clean out code which uses the above.
svn path=/trunk/mcs/; revision=1239
-2001-10-31 Ravi Pratap <ravi@ximian.com>
+2001-11-01 Ravi Pratap <ravi@ximian.com>
+
+ * tree.cs (RecordNamespace): Fix up to check for the correct key.
+
+ * cs-parser.jay (GetQualifiedIdentifier): New Helper method used in
+ local_variable_type to extract the string corresponding to the type.
+
+ (local_variable_type): Fixup the action to use the new helper method.
+ * codegen.cs : Get rid of RefOrOutParameter, it's not the right way to
+ go.
+
+ * expression.cs : Clean out code which uses the above.
+
+2001-10-31 Ravi Pratap <ravi@ximian.com>
+
* typemanager.cs (RegisterMethod): Check if we already have an existing key
and bale out if necessary by returning a false.
error = false;
name = MakeFQN (ns, name);
-
+
t = RootContext.TypeManager.LookupType (name);
if (t != null)
return t;
} else {
parent = (Struct) RootContext.Tree.Structs [name];
}
-
+
if (parent != null){
t = parent.DefineType (builder);
if (t == null){
if (t != null)
return t;
+ //
+ // Attempt to do a direct unqualified lookup
+ //
+ t = LookupInterfaceOrClass (builder, "", name, is_class, out error);
+ if (error)
+ return null;
+
+ if (t != null)
+ return t;
+
//
// Attempt to lookup the class on any of the `using'
// namespaces
//
public bool InLoop;
- //
- // Whether we are currently emitting code for a ref/out parameter
- //
- public bool RefOrOutParameter;
-
}
}
// creeps up. If you use qualified_identifier (which is all we need
// really) two shift/reduces appear.
//
- // So, instead we do a super trick: we just allow ($1) to be a
- // SimpleName Expression.
- //
- if (((Expression) $1) is SimpleName)
- $$ = ((SimpleName) $1).Name + (string) $2;
- else {
+
+ // So we be a little smart :-)
+ Expression expr = (Expression) $1;
+ if (!(expr is SimpleName) && !(expr is MemberAccess)) {
Location l = lexer.Location;
+ Console.WriteLine (((MemberAccess) $1).Identifier);
Report.Error (-1, l, "Invalid Type definition");
$$ = "System.Object";
}
+ $$ = GetQualifiedIdentifier (expr) + (string) $2;
}
| builtin_types opt_rank_specifier
{
}
}
+// <summary>
+// This method is used to get at the complete string representation of
+// a fully-qualified type name, hiding inside a MemberAccess ;-)
+// This is necessary because local_variable_type admits primary_expression
+// as the type of the variable. So we do some extra checking
+// </summary>
+string GetQualifiedIdentifier (Expression expr)
+{
+ if (expr is SimpleName)
+ return ((SimpleName)expr).Name;
+ else if (expr is MemberAccess)
+ return GetQualifiedIdentifier (((MemberAccess)expr).Expr) + "." + ((MemberAccess) expr).Identifier;
+ else
+ throw new Exception ("Expr has to be either SimpleName or MemberAccess !");
+
+}
+
Block declare_local_variables (string type, ArrayList variable_declarators)
{
Block implicit_block;
ILGenerator ig = ec.ig;
int idx = vi.Idx;
- bool ref_parameter = ec.RefOrOutParameter;
-
vi.Used = true;
- if (!ref_parameter) {
+ switch (idx){
+ case 0:
+ ig.Emit (OpCodes.Ldloc_0);
+ break;
- switch (idx){
- case 0:
- ig.Emit (OpCodes.Ldloc_0);
- break;
-
- case 1:
- ig.Emit (OpCodes.Ldloc_1);
- break;
-
- case 2:
- ig.Emit (OpCodes.Ldloc_2);
- break;
-
- case 3:
- ig.Emit (OpCodes.Ldloc_3);
- break;
-
- default:
- if (idx <= 255)
- ig.Emit (OpCodes.Ldloc_S, (byte) idx);
- else
- ig.Emit (OpCodes.Ldloc, idx);
- break;
- }
- } else
- AddressOf (ec);
+ case 1:
+ ig.Emit (OpCodes.Ldloc_1);
+ break;
+
+ case 2:
+ ig.Emit (OpCodes.Ldloc_2);
+ break;
+
+ case 3:
+ ig.Emit (OpCodes.Ldloc_3);
+ break;
+
+ default:
+ if (idx <= 255)
+ ig.Emit (OpCodes.Ldloc_S, (byte) idx);
+ else
+ ig.Emit (OpCodes.Ldloc, idx);
+ break;
+ }
}
-
+
public static void Store (ILGenerator ig, int idx)
{
switch (idx){
public void Emit (EmitContext ec)
{
- if (ArgType == AType.Ref || ArgType == AType.Out)
- ec.RefOrOutParameter = true;
-
expr.Emit (ec);
- ec.RefOrOutParameter = false;
}
}
{
if (namespaces == null)
namespaces = new Hashtable ();
-
- if (namespaces.ContainsKey (name))
- return (Namespace) namespaces [name];
-
+
Namespace ns = new Namespace (parent, name);
+
+ if (namespaces.Contains (ns.Name))
+ return (Namespace) namespaces [ns.Name];
+
namespaces.Add (ns.Name, ns);
return ns;
}