Compare commits

..
Author SHA1 Message Date
nobody 69876c30ff This commit was manufactured by cvs2svn to create tag
'GMCS_MARTIN_2'.

svn path=/tags/GMCS_MARTIN_2/mcs/; revision=35876
2004-11-09 04:38:03 +00:00
55 changed files with 1164 additions and 4410 deletions

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyVersion("1.1.2")]
[assembly: AssemblyVersion("1.1.1")]
[assembly: AssemblyTitle ("Mono C# Compiler")]
[assembly: AssemblyDescription ("Mono C# Compiler with Generics")]
[assembly: AssemblyCopyright ("2001, 2002, 2003 Ximian, Inc.")]
-773
View File
@@ -1,776 +1,3 @@
2004-11-07 Miguel de Icaza <[email protected]>
* expression.cs (Invocation.OverloadResolve): Flag error if we are
calling an unsafe method from a safe location.
2004-11-06 Marek Safar <[email protected]>
Fix #69167
* codegen.cs (ApplyAttributeBuilder): Do not return; it is only warning.
2004-11-06 Miguel de Icaza <[email protected]>
* namespace.cs (VerifyUsing): use GetPartialName instead of
ToString.
2004-11-05 Miguel de Icaza <[email protected]>
* statement.cs (Return.Resolve): Fix regression in typo: if
`in_exc', we have to request a NeedReturnLabel, this was a typo
introduced in the anonymous method check-in. Fixes #69131.
* Indexers were using the ShortName when defining themselves,
causing a regression in the compiler bootstrap when applying the
patch from 2004-11-02 (first part), now they use their full name
and the bug is gone.
2004-11-04 Zoltan Varga <[email protected]>
* driver.cs: Strip the path from the names of embedded resources. Fixes
#68519.
2004-11-04 Raja R Harinath <[email protected]>
Fix error message regression: cs0104-2.cs.
* namespace.cs (NamespaceEntry.Lookup): Remove 'silent' flag.
(AliasEntry.Resolve): Update.
* rootcontext.cs (RootContext.NamespaceLookup): Update. Remove
'silent' flag.
(RootContext.LookupType): Update.
2004-11-03 Carlos Alberto Cortez <[email protected]>
* cs-parser.jay: Add support for handling accessor modifiers
* class: Add support port accessor modifiers and error checking,
define PropertyMethod.Define as virtual (not abstract anymore)
* ecore.cs: Add checking for proeprties access with access modifiers
* iterators.cs: Modify Accessor constructor call based in the modified
constructor
2004-11-02 Ben Maurer <[email protected]>
* expression.cs (StringConcat): Handle being called twice,
as when we have a concat in a field init with more than two
ctors in the class
2004-11-02 Miguel de Icaza <[email protected]>
* class.cs (Event.Define, Indexer.Define, Property.Define): Do not
special case explicit implementations, we should always produce
the .property or .event declaration.
* decl.cs (MemberName): Renamed GetFullName to GetPartialName
since it will not return correct data if people use this
unresolved in the presence of using statements (see test-313).
* class.cs (MethodData.Define): If we are an explicit interface
implementation, set the method name to the full name of the
interface plus the name of the method.
Notice that using the method.MethodName.GetFullName() does not
work, as it will only contain the name as declared on the source
file (it can be a shorthand in the presence of using statements)
and not the fully qualifed type name, for example:
using System;
class D : ICloneable {
object ICloneable.Clone () {
}
}
Would produce a method called `ICloneable.Clone' instead of
`System.ICloneable.Clone'.
* namespace.cs (Alias.Resolve): Use GetPartialName.
2004-11-01 Marek Safar <[email protected]>
* cs-parser.jay: Add error 1055 report.
2004-11-01 Miguel de Icaza <[email protected]>
* assign.cs (Assign.DoResolve): Only do the transform of
assignment into a New if the types are compatible, if not, fall
through and let the implicit code deal with the errors and with
the necessary conversions.
2004-11-01 Marek Safar <[email protected]>
* cs-parser.jay: Add error 1031 report.
* cs-tokenizer.cs: Add location for error 1038.
2004-10-31 Marek Safar <[email protected]>
* cs-parser.jay: Add error 1016 report.
2004-10-31 Marek Safar <[email protected]>
* cs-parser.jay: Add errors 1575,1611 report.
2004-10-31 Marek Safar <[email protected]>
* cs-parser.jay: Add error 1001 report.
2004-10-31 Marek Safar <[email protected]>
Fix #68850
* attribute.cs (GetMarshal): Add method argument for
caller identification.
* class.cs, codegen.cs, enum.cs, parameter.cs: Added
agument for GetMarshal and RuntimeMissingSupport.
2004-10-31 Marek Safar <[email protected]>
* attribute.cs (ExtractSecurityPermissionSet): Removed
TypeManager.code_access_permission_type.
* typemanager.cs: Removed TypeManager.code_access_permission_type.
2004-10-27 Miguel de Icaza <[email protected]>
* expression.cs (LocalVariableReference.DoResolveLValue): Check
for obsolete use of a variable here. Fixes regression on errors
cs0619-25 and cs0619-26.
2004-10-27 Marek Safar <[email protected]>
Fix #62358, implemented security attribute encoding.
* attribute.cs (Attribute.CheckSecurityActionValididy): New method.
Tests permitted SecurityAction for assembly or other types.
(Assembly.ExtractSecurityPermissionSet): New method. Transforms
data from SecurityPermissionAttribute to PermisionSet class.
* class.cs (ApplyAttributeBuilder): Added special handling
for System.Security.Permissions.SecurityAttribute based types.
* codegen.cs (AssemblyClass.ApplyAttributeBuilder): Added
special handling for System.Security.Permissions.SecurityAttribute
based types.
* enum.cs (ApplyAttributeBuilder): Added special handling
for System.Security.Permissions.SecurityAttribute based types.
* parameter.cs (ApplyAttributeBuilder): Added special handling
for System.Security.Permissions.SecurityAttribute based types.
* rootcontext.cs: Next 2 core types.
* typemanager.cs (TypeManager.security_permission_attr_type):
Built in type for the SecurityPermission Attribute.
(code_access_permission_type): Build in type.
2004-10-17 Miguel de Icaza <[email protected]>
* expression.cs (LocalVariableReference.DoResolveBase, Emit):
Remove the tests for `ec.RemapToProxy' from here, and encapsulate
all of this information into
EmitContext.EmitCapturedVariableInstance.
* codegen.cs (EmitCapturedVariableInstance): move here the
funcionality of emitting an ldarg.0 in the presence of a
remapping. This centralizes the instance emit code.
(EmitContext.EmitThis): If the ScopeInfo contains a THIS field,
then emit a load of this: it means that we have reached the
topmost ScopeInfo: the one that contains the pointer to the
instance of the class hosting the anonymous method.
* anonymous.cs (AddField, HaveCapturedFields): Propagate field
captures to the topmost CaptureContext.
2004-10-12 Miguel de Icaza <[email protected]>
* expression.cs (LocalVariableReference): Move the knowledge about
the iterators into codegen's EmitCapturedVariableInstance.
2004-10-11 Miguel de Icaza <[email protected]>
* codegen.cs (EmitContext.ResolveTopBlock): Emit a 1643 when not
all code paths return a value from an anonymous method (it is the
same as the 161 error, but for anonymous methods).
2004-10-08 Miguel de Icaza <[email protected]>
The introduction of anonymous methods in the compiler changed
various ways of doing things in the compiler. The most
significant one is the hard split between the resolution phase
and the emission phases of the compiler.
For instance, routines that referenced local variables no
longer can safely create temporary variables during the
resolution phase: they must do so from the emission phase,
since the variable might have been "captured", hence access to
it can not be done with the local-variable operations from the runtime.
* statement.cs
(Block.Flags): New flag `IsTopLevel' to indicate that this block
is a toplevel block.
(ToplevelBlock): A new kind of Block, these are the blocks that
are created by the parser for all toplevel method bodies. These
include methods, accessors and anonymous methods.
These contain some extra information not found in regular blocks:
A pointer to an optional CaptureContext (for tracking captured
local variables and parameters). A pointer to the parent
ToplevelBlock.
(Return.Resolve): Catch missmatches when returning a value from an
anonymous method (error 1662).
Invoke NeedReturnLabel from the Resolve phase instead of the emit
phase.
(Break.Resolve): ditto.
(SwitchLabel): instead of defining the labels during the
resolution phase, we now turned the public ILLabel and ILLabelCode
labels into methods called GetILLabelCode() and GetILLabel() that
only define the label during the Emit phase.
(GotoCase): Track the SwitchLabel instead of the computed label
(its contained therein). Emit the code by using
SwitchLabel.GetILLabelCode ().
(LocalInfo.Flags.Captured): A new flag has been introduce to track
whether the Local has been captured or not.
(LocalInfo.IsCaptured): New property, used to tell whether the
local has been captured.
* anonymous.cs: Vastly updated to contain the anonymous method
support.
The main classes here are: CaptureContext which tracks any
captured information for a toplevel block and ScopeInfo used to
track the activation frames for various local variables.
Each toplevel block has an optional capture context associated
with it. When a method contains an anonymous method both the
toplevel method and the anonymous method will create a capture
context. When variables or parameters are captured, they are
recorded on the CaptureContext that owns them, for example:
void Demo () {
int a;
MyDelegate d = delegate {
a = 1;
}
}
Here `a' will be recorded as captured on the toplevel
CapturedContext, the inner captured context will not have anything
(it will only have data if local variables or parameters from it
are captured in a nested anonymous method.
The ScopeInfo is used to track the activation frames for local
variables, for example:
for (int i = 0; i < 10; i++)
for (int j = 0; j < 10; j++){
MyDelegate d = delegate {
call (i, j);
}
}
At runtime this captures a single captured variable `i', but it
captures 10 different versions of the variable `j'. The variable
`i' will be recorded on the toplevel ScopeInfo, while `j' will be
recorded on a child.
The toplevel ScopeInfo will also track information like the `this'
pointer if instance variables were referenced (this is necessary
as the anonymous method lives inside a nested class in the host
type of the method).
(AnonymousMethod): Expanded to track the Toplevel, implement
`AnonymousMethod.Compatible' to tell whether an anonymous method
can be converted to a target delegate type.
The routine now also produces the anonymous method content
(AnonymousDelegate): A helper class that derives from
DelegateCreation, this is used to generate the code necessary to
produce the delegate for the anonymous method that was created.
* assign.cs: API adjustments for new changes in
Convert.ImplicitStandardConversionExists.
* class.cs: Adjustments to cope with the fact that now toplevel
blocks are of type `ToplevelBlock'.
* cs-parser.jay: Now we produce ToplevelBlocks for toplevel blocks
insteda of standard blocks.
Flag errors if params arguments are passed to anonymous methods.
* codegen.cs (EmitContext): Replace `InAnonymousMethod' with
`CurrentAnonymousMethod' which points to the current Anonymous
Method. The variable points to the AnonymousMethod class that
holds the code being compiled. It is set in the new EmitContext
created for the anonymous method.
(EmitContext.Phase): Introduce a variable and an enumeration to
assist in enforcing some rules about when and where we are allowed
to invoke certain methods (EmitContext.NeedsReturnLabel is the
only one that enfonces this right now).
(EmitContext.HaveCaptureInfo): new helper method that returns
whether we have a CapturedContext initialized.
(EmitContext.CaptureVariable): New method used to register that a
LocalInfo must be flagged for capturing.
(EmitContext.CapturedParameter): New method used to register that a
parameters must be flagged for capturing.
(EmitContext.CapturedField): New method used to register that a
field must be flagged for capturing.
(EmitContext.HaveCapturedVariables,
EmitContext.HaveCapturedFields): Return whether there are captured
variables or fields.
(EmitContext.EmitMethodHostInstance): This is used to emit the
instance for the anonymous method. The instance might be null
(static methods), this (for anonymous methods that capture nothing
and happen to live side-by-side with the current method body) or a
more complicated expression if the method has a CaptureContext.
(EmitContext.EmitTopBlock): Routine that drives the emission of
code: it will first resolve the top block, then emit any metadata
and then emit the code. The split is done so that we can extract
any anonymous methods and flag any captured variables/parameters.
(EmitContext.ResolveTopBlock): Triggers the resolution phase,
during this phase, the ILGenerator should not be used as labels
and local variables declared here might not be accessible to any
code that is part of an anonymous method.
Exceptions to this include the temporary variables that are
created by some statements internally for holding temporary
variables.
(EmitContext.EmitMeta): New routine, in charge of emitting all the
metadata for a cb
(EmitContext.TemporaryReturn): This method is typically called
from the Emit phase, and its the only place where we allow the
ReturnLabel to be defined other than the EmitMeta. The reason is
that otherwise we would have to duplicate a lot of logic in the
Resolve phases of various methods that today is on the Emit
phase.
(EmitContext.NeedReturnLabel): This no longer creates the label,
as the ILGenerator is not valid during the resolve phase.
(EmitContext.EmitThis): Extended the knowledge in this class to
work in anonymous methods in addition to iterators.
(EmitContext.EmitCapturedVariableInstance): This emits whatever
code is necessary on the stack to access the instance to a local
variable (the variable will be accessed as a field).
(EmitContext.EmitParameter, EmitContext.EmitAssignParameter,
EmitContext.EmitAddressOfParameter): Routines to support
parameters (not completed at this point).
Removals: Removed RemapLocal and RemapLocalLValue. We probably
will also remove the parameters.
* convert.cs (Convert): Define a `ConstantEC' which points to a
null. This is just to prefity some code that uses
ImplicitStandardConversion code and do not have an EmitContext
handy.
The idea is to flag explicitly that at that point in time, it is
known that the conversion will not trigger the delegate checking
code in implicit conversions (which requires a valid
EmitContext).
Everywhere: pass new EmitContext parameter since
ImplicitStandardConversionExists now requires it to check for
anonymous method conversions.
(Convert.ImplicitStandardConversionExists): If the type of an
expression is the anonymous_method_type, and the type is a
delegate, we invoke the AnonymousMethod.Compatible method to check
whether an implicit conversion is possible.
(Convert.ImplicitConversionStandard): Only do implicit method
group conversions if the language level is not ISO_1.
* delegate.cs (Delegate.GetInvokeMethod): Common method to get the
MethodInfo for the Invoke method. used by Delegate and
AnonymousDelegate.
* expression.cs (Binary.DoNumericPromotions): only allow anonymous
method conversions if the target type is a delegate.
Removed extra debugging nops.
(LocalVariableReference): Turn the `local_info' into a public
field.
Add `prepared' field, the same hack used for FieldExprs to cope
with composed assignments, as Local variables do not necessarily
operate purely on the stack as they used to: they can be captured
fields.
Add `temp' for a temporary result, like fields.
Refactor DoResolve and DoResolveLValue into DoResolveBase.
It now copes with Local variables that are captured and emits the
proper instance variable to load it from a field in the captured
case.
(ParameterReference.DoResolveBase): During the resolve phase,
capture parameters if we are in an anonymous method.
(ParameterReference.Emit, ParameterReference.AddressOf): If in an
anonymous method, use the EmitContext helper routines to emit the
parameter reference.
* iterators.cs: Set RemapToProxy to true/false during the
EmitDispose class.
* parameters.cs (GetParameterByName): New helper method.
* typemanager.cs (anonymous_method_type) a new type that
represents an anonyous method. This is always an internal type,
used as a fencepost to test against the anonymous-methodness of an
expression.
2004-10-24 Marek Safar <[email protected]>
Fixed bugs #63705, #67130
* decl.cs (MemberCache.MemberCache): Add parameter to distinguish
imported and defined interfaces.
(CacheEntry, EntryType): Changed to protected internal.
* class.cs (TypeContainer.DoDefineMembers): Setup cache for
interfaces too.
* typemanager.cs (LookupInterfaceContainer): New method.
Fills member container from base interfaces.
2004-10-20 Marek Safar <[email protected]>
* class.cs (MethodCore.CheckBase): Add errors 505, 533, 544,
561 report.
(PropertyBase.FindOutParentMethod): Add errors 545, 546 report.
2004-11-10 Martin Baulig <[email protected]>
* expression.cs (Invocation.BetterFunction): If two methods have
equal parameter types, but only one of them is generic, the
non-generic one wins.
(New.DoResolve): Don't set `is_struct' to false if we're a generic
instance; just use `Type.IsValueType' to determine whether
something is a struct or not.
(MemberAccess.DoResolveAsTypeStep): Don't modify the `args' field,
so we can be called multiple times.
2004-11-10 Martin Baulig <[email protected]>
* generic.cs (TypeParameter.DefineConstraints): New public method.
(TypeParameter.CheckAccessLevel): Override this and return true.
(ConstructedType.ResolveType): Renamed to DoResolveType(), don't
override ResolveType() anymore.
(ConstructedType.DoResolveAsTypeStep): Call DoResolveType() here.
2004-11-10 Martin Baulig <[email protected]>
* rootcontext.cs (RootContext.LookupType): If we're a nested type,
call DeclSpace.ResolveNestedType() on it.
2004-11-10 Martin Baulig <[email protected]>
* support.cs (ReflectionParameters.ParameterModifier): If `gpd' is
non-null, call ParameterModifier() on it.
2004-11-10 Martin Baulig <[email protected]>
* iterators.cs
(Iterators): Added `current_type' and `this_type' fields.
(Iterators.DefineIterator): Create a new EmitContext and store it
in `ec'; compute `this_type'.
2004-11-10 Martin Baulig <[email protected]>
* typemanager.cs
(TypeManager.IsPrivateAccessible): New public method.
(Closure.Filter): Use IsPrivateAccessible() instead of IsEqual().
2004-11-10 Martin Baulig <[email protected]>
* class.cs (TypeContainer.DefineType): Call
TypeBuilder.DefineGenericParameters() before resolving the type
parameters.
(MethodData.parent_method): New protected field.
(MethodData..ctor): Added `MethodInfo parent_method' argument.
(MethodData.Define): Compute `parent_method'.
* decl.cs
(MemberCore.GetObsoleteAttribute): Don't create a new EmitContext.
(MemberCore.GetClsCompliantAttributeValue): Likewise.
(DeclSpace.ec): New protected field; store the EmitContext here.
(DeclSpace.EmitContext): New public property.
(DeclSpace.ResolveType): Un-comment from the [Obsolte] attribute.
(DeclSpace.ResolveNestedType): New public method.
(DeclSpace.ResolveTypeExpr): Just call ResolveAsTypeTerminal() here.
(DeclSpace.NestedAccessible): Added `Type tb' argument.
(DeclSpace.FamilyAccessible): Likewise.
(DeclSpace.FindType): Call ResolveNestedType() for nested types.
(DeclSpace.GetClsCompliantAttributeValue): Don't create a new
EmitContext.
* delegate.cs (Delegate.Define): Store the EmitContext in the `ec'
field.
* enum.cs (Enum.Define): Store the EmitContext in the `ec' field.
(Enum.Emit): Don't create a new EmitContext.
2004-10-18 Martin Baulig <[email protected]>
* statement.cs (Fixed.Resolve): Don't access the TypeExpr's
`Type' directly, but call ResolveType() on it.
(Catch.Resolve): Likewise.
(Foreach.Resolve): Likewise.
2004-10-18 Martin Baulig <[email protected]>
* expression.cs (Cast.DoResolve): Don't access the TypeExpr's
`Type' directly, but call ResolveType() on it.
(Probe.DoResolve): Likewise.
(ArrayCreation.LookupType): Likewise.
(TypeOf.DoResolve): Likewise.
(SizeOf.DoResolve): Likewise.
2004-10-18 Raja R Harinath <[email protected]>
* class.cs (FieldMember.DoDefine): Reset ec.InUnsafe after doing
the ResolveType.
2004-10-17 John Luke <[email protected]>
* class.cs (Operator.GetSignatureForError): use CSharpName
* parameter.cs (Parameter.GetSignatureForError): Returns
correct name even if was not defined.
2004-10-13 Raja R Harinath <[email protected]>
Fix #65816.
* class.cs (TypeContainer.EmitContext): New property.
(DefineNestedTypes): Create an emitcontext for each part.
(MethodCore.DoDefineParameters): Use container's emitcontext.
Pass type array to InternalParameters.
(MemberBase.DoDefine): Use container's emitcontext.
(FieldMember.Define): Likewise.
(Event.Define): Likewise.
(SetMethod.GetParameterInfo): Change argument to EmitContext.
Pass type array to InternalParameters.
(SetIndexerMethod.GetParameterInfo): Likewise.
(SetMethod.Define): Pass emitcontext to GetParameterInfo.
* delegate.cs (Define): Pass emitcontext to
ComputeAndDefineParameterTypes and GetParameterInfo. Pass type
array to InternalParameters.
* expression.cs (ParameterReference.DoResolveBase): Pass
emitcontext to GetParameterInfo.
(ComposedCast.DoResolveAsTypeStep): Remove check on
ec.ResolvingTypeTree.
* parameter.cs (Parameter.Resolve): Change argument to
EmitContext. Use ResolveAsTypeTerminal.
(Parameter.GetSignature): Change argument to EmitContext.
(Parameters.ComputeSignature): Likewise.
(Parameters.ComputeParameterTypes): Likewise.
(Parameters.GetParameterInfo): Likewise.
(Parameters.ComputeAndDefineParameterTypes): Likewise.
Re-use ComputeParameterTypes. Set ec.ResolvingTypeTree.
* support.cs (InternalParameters..ctor): Remove variant that takes
a DeclSpace.
* typemanager.cs (system_intptr_expr): New.
(InitExpressionTypes): Initialize it.
2004-10-12 Chris Toshok <[email protected]>
* cs-parser.jay: fix location for try_statement and catch_clause.
2004-10-18 Martin Baulig <[email protected]>
* class.cs (FieldMember.Define): Don't access the TypeExpr's
`Type' directly, but call ResolveType() on it.
(MemberBase.DoDefine): Likewise.
* expression.cs (New.DoResolve): Don't access the TypeExpr's
`Type' directly, but call ResolveType() on it.
(ComposedCast.DoResolveAsTypeStep): Likewise.
* statement.cs (LocalInfo.Resolve): Don't access the TypeExpr's
`Type' directly, but call ResolveType() on it.
2004-10-17 John Luke <[email protected]>
* class.cs (Operator.GetSignatureForError): use CSharpName
* parameter.cs (Parameter.GetSignatureForError): Returns
correct name even if was not defined.
2004-10-13 Raja R Harinath <[email protected]>
Fix #65816.
* class.cs (TypeContainer.EmitContext): New property.
(DefineNestedTypes): Create an emitcontext for each part.
(MethodCore.DoDefineParameters): Use container's emitcontext.
Pass type array to InternalParameters.
(MemberBase.DoDefine): Use container's emitcontext.
(FieldMember.Define): Likewise.
(Event.Define): Likewise.
(SetMethod.GetParameterInfo): Change argument to EmitContext.
Pass type array to InternalParameters.
(SetIndexerMethod.GetParameterInfo): Likewise.
(SetMethod.Define): Pass emitcontext to GetParameterInfo.
* delegate.cs (Define): Pass emitcontext to
ComputeAndDefineParameterTypes and GetParameterInfo. Pass type
array to InternalParameters.
* expression.cs (ParameterReference.DoResolveBase): Pass
emitcontext to GetParameterInfo.
(ComposedCast.DoResolveAsTypeStep): Remove check on
ec.ResolvingTypeTree.
* parameter.cs (Parameter.Resolve): Change argument to
EmitContext. Use ResolveAsTypeTerminal.
(Parameter.GetSignature): Change argument to EmitContext.
(Parameters.ComputeSignature): Likewise.
(Parameters.ComputeParameterTypes): Likewise.
(Parameters.GetParameterInfo): Likewise.
(Parameters.ComputeAndDefineParameterTypes): Likewise.
Re-use ComputeParameterTypes. Set ec.ResolvingTypeTree.
* support.cs (InternalParameters..ctor): Remove variant that takes
a DeclSpace.
* typemanager.cs (system_intptr_expr): New.
(InitExpressionTypes): Initialize it.
2004-10-12 Chris Toshok <[email protected]>
* cs-parser.jay: fix location for try_statement and catch_clause.
2004-10-07 Raja R Harinath <[email protected]>
More DeclSpace.ResolveType avoidance.
* decl.cs (MemberCore.InUnsafe): New property.
* class.cs (MemberBase.DoDefine): Use ResolveAsTypeTerminal
with newly created EmitContext.
(FieldMember.Define): Likewise.
* delegate.cs (Delegate.Define): Likewise.
* ecore.cs (SimpleName.ResolveAsTypeStep): Lookup with alias
only if normal name-lookup fails.
(TypeExpr.DoResolve): Enable error-checking.
* expression.cs (ArrayCreation.DoResolve): Use ResolveAsTypeTerminal.
(SizeOf.DoResolve): Likewise.
(ComposedCast.DoResolveAsTypeStep): Likewise.
(StackAlloc.DoResolve): Likewise.
* statement.cs (Block.Flags): Add new flag 'Unsafe'.
(Block.Unsafe): New property.
(Block.EmitMeta): Set ec.InUnsafe as appropriate.
(Unsafe): Set 'unsafe' flag of contained block.
(LocalInfo.Resolve): Use ResolveAsTypeTerminal.
(Fixed.Resolve): Likewise.
(Catch.Resolve): Likewise.
(Using.ResolveLocalVariableDecls): Likewise.
(Foreach.Resolve): Likewise.
2004-10-05 John Luke <[email protected]>
* cs-parser.jay: add location to error CS0175
2004-10-04 Miguel de Icaza <[email protected]>
* ecore.cs (Expression.Constantity): Add support for turning null
into a constant.
* const.cs (Const.Define): Allow constants to be reference types
as long as the value is Null.
2004-10-04 Juraj Skripsky <[email protected]>
* namespace.cs (NamespaceEntry.Using): No matter which warning
level is set, check if this namespace name has already been added.
2004-10-03 Ben Maurer <[email protected]>
* expression.cs: reftype [!=]= null should always use br[true,false].
# 67410
2004-10-03 Marek Safar <[email protected]>
Fix #67108
* attribute.cs: Enum conversion moved to
GetAttributeArgumentExpression to be applied to the all
expressions.
2004-10-01 Raja R Harinath <[email protected]>
Fix #65833, test-300.cs, cs0122-5.cs, cs0122-6.cs.
* class.c (TypeContainer.DefineType): Flag error if
base types aren't accessible due to access permissions.
* decl.cs (DeclSpace.ResolveType): Move logic to
Expression.ResolveAsTypeTerminal.
(DeclSpace.ResolveTypeExpr): Thin layer over
Expression.ResolveAsTypeTerminal.
(DeclSpace.CheckAccessLevel, DeclSpace.FamilyAccess):
Refactor code into NestedAccess. Use it.
(DeclSpace.NestedAccess): New.
* ecore.cs (Expression.ResolveAsTypeTerminal): Add new
argument to silence errors. Check access permissions.
(TypeExpr.DoResolve, TypeExpr.ResolveType): Update.
* expression.cs (ProbeExpr.DoResolve): Use ResolveAsTypeTerminal.
(Cast.DoResolve): Likewise.
(New.DoResolve): Likewise.
(InvocationOrCast.DoResolve,ResolveStatement): Likewise.
(TypeOf.DoResolve): Likewise.
* expression.cs (Invocation.BetterConversion): Return the Type of
the better conversion. Implement section 14.4.2.3 more faithfully.
(Invocation.BetterFunction): Make boolean. Make correspondence to
section 14.4.2.2 explicit.
(Invocation.OverloadResolve): Update.
(Invocation): Remove is_base field.
(Invocation.DoResolve): Don't use is_base. Use mg.IsBase.
(Invocation.Emit): Likewise.
2004-09-24 Marek Safar <[email protected]>
* cs-parser.jay: Reverted 642 warning fix.
2004-09-23 Marek Safar <[email protected]>
Fix bug #66615
* decl.cs (FindMemberWithSameName): Indexer can have more than
1 argument.
2004-09-23 Marek Safar <[email protected]>
* expression.cs (LocalVariableReference.DoResolveLValue):
Do not report warning 219 for out values.
(EmptyExpression.Null): New member to avoid extra allocations.
2004-09-23 Marek Safar <[email protected]>
* cs-parser.jay: Fix wrong warning 642 report.
* cs-tokenizer.cs (CheckNextToken): New helper;
Inspect next character if is same as expected.
2004-09-23 Martin Baulig <[email protected]>
* convert.cs (Convert.ImplicitReferenceConversion): Some code cleanup.
(Convert.ImplicitReferenceConversionExists): Likewise.
2004-11-09 Raja R Harinath <[email protected]>
* Makefile (DISTFILES): Comment out a few missing files.
+7 -1093
View File
File diff suppressed because it is too large. Load diff
+13 -14
View File
@@ -393,6 +393,16 @@ namespace Mono.CSharp {
return null;
}
if (source is New && target_type.IsValueType &&
(target.eclass != ExprClass.IndexerAccess) && (target.eclass != ExprClass.PropertyAccess)){
New n = (New) source;
if (n.SetValueTypeVariable (target))
return n;
else
return null;
}
if ((source.eclass == ExprClass.Type) && (source is TypeExpr)) {
source.Error_UnexpectedKind ("variable or value", loc);
return null;
@@ -403,20 +413,9 @@ namespace Mono.CSharp {
}
if (target_type == source_type){
if (source is New && target_type.IsValueType &&
(target.eclass != ExprClass.IndexerAccess) && (target.eclass != ExprClass.PropertyAccess)){
New n = (New) source;
if (n.SetValueTypeVariable (target))
return n;
else
return null;
}
if (target_type == source_type)
return this;
}
//
// If this assignemnt/operator was part of a compound binary
// operator, then we allow an explicit conversion, as detailed
@@ -443,7 +442,7 @@ namespace Mono.CSharp {
// 2. and the original right side is implicitly convertible to
// the type of target
//
if (Convert.ImplicitStandardConversionExists (ec, a.original_source, target_type))
if (Convert.ImplicitStandardConversionExists (a.original_source, target_type))
return this;
//
+24 -151
View File
@@ -18,8 +18,6 @@ using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
namespace Mono.CSharp {
@@ -132,20 +130,6 @@ namespace Mono.CSharp {
-202, loc, "Can not use a type parameter in an attribute");
}
/// <summary>
/// This is rather hack. We report many emit attribute error with same error to be compatible with
/// csc. But because csc has to report them this way because error came from ilasm we needn't.
/// </summary>
public void Error_AttributeEmitError (string inner)
{
Report.Error (647, Location, "Error emitting '{0}' attribute because '{1}'", Name, inner);
}
public void Error_InvalidSecurityParent ()
{
Error_AttributeEmitError ("it is attached to invalid parent");
}
void Error_AttributeConstructorMismatch ()
{
Report.Error (-6, Location,
@@ -227,11 +211,7 @@ namespace Mono.CSharp {
public static bool GetAttributeArgumentExpression (Expression e, Location loc, Type arg_type, out object result)
{
if (e is EnumConstant) {
if (RootContext.StdLib)
result = ((EnumConstant)e).GetValueAsEnumType ();
else
result = ((EnumConstant)e).GetValue ();
result = e;
return true;
}
@@ -323,6 +303,7 @@ namespace Mono.CSharp {
}
pos_values = new object [pos_arg_count];
object[] real_pos_values = new object [pos_arg_count];
//
// First process positional arguments
@@ -342,14 +323,21 @@ namespace Mono.CSharp {
if (!GetAttributeArgumentExpression (e, Location, a.Type, out val))
return null;
pos_values [i] = val;
if (val is EnumConstant) {
EnumConstant econst = (EnumConstant) e;
pos_values [i] = val = econst.GetValue ();
real_pos_values [i] = econst.GetValueAsEnumType ();
} else {
real_pos_values [i] = pos_values [i] = val;
}
if (DoCompares){
if (usage_attr) {
usage_attribute = new AttributeUsageAttribute ((AttributeTargets)val);
} else if (MethodImplAttr) {
if (usage_attr)
usage_attribute = new AttributeUsageAttribute ((AttributeTargets) val);
else if (MethodImplAttr)
this.ImplOptions = (MethodImplOptions) val;
} else if (GuidAttr){
else if (GuidAttr){
//
// we will later check the validity of the type
//
@@ -510,16 +498,16 @@ namespace Mono.CSharp {
continue;
if (j == group_in_params_array){
object v = pos_values [j];
object v = real_pos_values [j];
int count = pos_arg_count - j;
object [] array = new object [count];
pos_values [j] = array;
real_pos_values [j] = array;
array [0] = v;
} else {
object [] array = (object []) pos_values [group_in_params_array];
object [] array = (object []) real_pos_values [group_in_params_array];
array [j - group_in_params_array] = pos_values [j];
array [j - group_in_params_array] = real_pos_values [j];
}
}
@@ -531,8 +519,8 @@ namespace Mono.CSharp {
object [] new_pos_values = new object [argc];
for (int p = 0; p < argc; p++)
new_pos_values [p] = pos_values [p];
pos_values = new_pos_values;
new_pos_values [p] = real_pos_values [p];
real_pos_values = new_pos_values;
}
try {
@@ -549,13 +537,13 @@ namespace Mono.CSharp {
prop_infos.CopyTo (prop_info_arr, 0);
cb = new CustomAttributeBuilder (
(ConstructorInfo) constructor, pos_values,
(ConstructorInfo) constructor, real_pos_values,
prop_info_arr, prop_values_arr,
field_info_arr, field_values_arr);
}
else
cb = new CustomAttributeBuilder (
(ConstructorInfo) constructor, pos_values);
(ConstructorInfo) constructor, real_pos_values);
} catch (NullReferenceException) {
//
// Don't know what to do here
@@ -734,108 +722,6 @@ namespace Mono.CSharp {
return (bool)pos_values [0];
}
/// <summary>
/// Tests permitted SecurityAction for assembly or other types
/// </summary>
public bool CheckSecurityActionValidity (bool for_assembly)
{
SecurityAction action = GetSecurityActionValue ();
if ((action == SecurityAction.RequestMinimum || action == SecurityAction.RequestOptional || action == SecurityAction.RequestRefuse) && for_assembly)
return true;
if (!for_assembly) {
if (action < SecurityAction.Demand || action > SecurityAction.InheritanceDemand) {
Error_AttributeEmitError ("SecurityAction is out of range");
return false;
}
if ((action != SecurityAction.RequestMinimum && action != SecurityAction.RequestOptional && action != SecurityAction.RequestRefuse) && !for_assembly)
return true;
}
Error_AttributeEmitError (String.Concat ("SecurityAction '", action, "' is not valid for this declaration"));
return false;
}
System.Security.Permissions.SecurityAction GetSecurityActionValue ()
{
return (SecurityAction)pos_values [0];
}
/// <summary>
/// Creates instance of SecurityAttribute class and add result of CreatePermission method to permission table.
/// </summary>
/// <returns></returns>
public void ExtractSecurityPermissionSet (ListDictionary permissions)
{
if (TypeManager.LookupDeclSpace (Type) != null && RootContext.StdLib) {
Error_AttributeEmitError ("security custom attributes can not be referenced from defining assembly");
return;
}
SecurityAttribute sa;
// For all assemblies except corlib we can avoid all hacks
if (RootContext.StdLib) {
sa = (SecurityAttribute) Activator.CreateInstance (Type, pos_values);
if (prop_info_arr != null) {
for (int i = 0; i < prop_info_arr.Length; ++i) {
PropertyInfo pi = prop_info_arr [i];
pi.SetValue (sa, prop_values_arr [i], null);
}
}
} else {
Type temp_type = Type.GetType (Type.FullName);
// HACK: All mscorlib attributes have same ctor syntax
sa = (SecurityAttribute) Activator.CreateInstance (temp_type, new object[] { GetSecurityActionValue () } );
// All types are from newly created corlib but for invocation with old we need to convert them
if (prop_info_arr != null) {
for (int i = 0; i < prop_info_arr.Length; ++i) {
PropertyInfo emited_pi = prop_info_arr [i];
PropertyInfo pi = temp_type.GetProperty (emited_pi.Name, emited_pi.PropertyType);
object old_instance = pi.PropertyType.IsEnum ?
System.Enum.ToObject (pi.PropertyType, prop_values_arr [i]) :
prop_values_arr [i];
pi.SetValue (sa, old_instance, null);
}
}
}
IPermission perm = sa.CreatePermission ();
SecurityAction action;
// IS is correct because for corlib we are using an instance from old corlib
if (perm is System.Security.CodeAccessPermission) {
action = GetSecurityActionValue ();
} else {
switch (GetSecurityActionValue ()) {
case SecurityAction.Demand:
action = (SecurityAction)13;
break;
case SecurityAction.LinkDemand:
action = (SecurityAction)14;
break;
case SecurityAction.InheritanceDemand:
action = (SecurityAction)15;
break;
default:
Error_AttributeEmitError ("Invalid SecurityAction for non-Code Access Security permission");
return;
}
}
PermissionSet ps = (PermissionSet)permissions [action];
if (ps == null) {
ps = new PermissionSet (PermissionState.None);
permissions.Add (action, ps);
}
ps.AddPermission (sa.CreatePermission ());
}
object GetValue (object value)
{
if (value is EnumConstant)
@@ -863,14 +749,8 @@ namespace Mono.CSharp {
return null;
}
public UnmanagedMarshal GetMarshal (Attributable attr)
public UnmanagedMarshal GetMarshal ()
{
object value = GetFieldValue ("SizeParamIndex");
if (value != null && UnmanagedType != UnmanagedType.LPArray) {
Error_AttributeEmitError ("SizeParamIndex field is not valid for the specified unmanaged type");
return null;
}
object o = GetFieldValue ("ArraySubType");
UnmanagedType array_sub_type = o == null ? UnmanagedType.I4 : (UnmanagedType) o;
@@ -878,10 +758,8 @@ namespace Mono.CSharp {
case UnmanagedType.CustomMarshaler:
MethodInfo define_custom = typeof (UnmanagedMarshal).GetMethod ("DefineCustom",
BindingFlags.Static | BindingFlags.Public);
if (define_custom == null) {
Report.RuntimeMissingSupport (Location, "set marshal info");
if (define_custom == null)
return null;
}
object [] args = new object [4];
args [0] = GetFieldValue ("MarshalTypeRef");
@@ -897,11 +775,6 @@ namespace Mono.CSharp {
return UnmanagedMarshal.DefineSafeArray (array_sub_type);
case UnmanagedType.ByValArray:
FieldMember fm = attr as FieldMember;
if (fm == null) {
Error_AttributeEmitError ("Specified unmanaged type is only valid on fields");
return null;
}
return UnmanagedMarshal.DefineByValArray ((int) GetFieldValue ("SizeConst"));
case UnmanagedType.ByValTStr:
+108 -367
View File
@@ -33,13 +33,10 @@
using System;
using System.Text;
using System.Collections;
using System.Collections.Specialized;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using Mono.CompilerServices.SymbolWriter;
@@ -421,6 +418,9 @@ namespace Mono.CSharp {
// Holds the parts of a partial class;
ArrayList parts;
// The emit context for toplevel objects.
EmitContext ec;
//
// Pointers to the default constructor and the default static constructor
//
@@ -1206,24 +1206,14 @@ namespace Mono.CSharp {
}
}
catch (ArgumentException) {
Report.RuntimeMissingSupport (Location, "static classes");
Report.RuntimeMissingSupport ("static classes");
return null;
}
TypeManager.AddUserType (Name, TypeBuilder, this);
if (IsGeneric) {
string[] param_names = new string [TypeParameters.Length];
for (int i = 0; i < TypeParameters.Length; i++)
param_names [i] = TypeParameters [i].Name;
GenericTypeParameterBuilder[] gen_params;
gen_params = TypeBuilder.DefineGenericParameters (param_names);
int offset = CountTypeParameters - CurrentTypeParameters.Length;
for (int i = offset; i < gen_params.Length; i++)
CurrentTypeParameters [i - offset].Define (gen_params [i]);
foreach (TypeParameter type_param in CurrentTypeParameters) {
if (!type_param.Resolve (this)) {
error = true;
@@ -1231,10 +1221,19 @@ namespace Mono.CSharp {
}
}
for (int i = offset; i < gen_params.Length; i++)
CurrentTypeParameters [i - offset].DefineConstraints ();
CurrentType = new ConstructedType (
Name, TypeParameters, Location);
CurrentType = new ConstructedType (Name, TypeParameters, Location);
string[] param_names = new string [TypeParameters.Length];
for (int i = 0; i < TypeParameters.Length; i++)
param_names [i] = TypeParameters [i].Name;
GenericTypeParameterBuilder[] gen_params;
gen_params = TypeBuilder.DefineGenericParameters (param_names);
for (int i = offset; i < gen_params.Length; i++)
CurrentTypeParameters [i - offset].Define (gen_params [i]);
}
if (IsGeneric) {
@@ -1380,7 +1379,6 @@ namespace Mono.CSharp {
foreach (ClassPart part in Parts) {
part.TypeBuilder = TypeBuilder;
part.parent_type = parent_type;
part.ec = new EmitContext (part, Mono.CSharp.Location.Null, null, null, ModFlags);
}
}
@@ -1440,8 +1438,10 @@ namespace Mono.CSharp {
if (TypeBuilder.BaseType != null)
parent_container = TypeManager.LookupMemberContainer (TypeBuilder.BaseType);
if (TypeBuilder.IsInterface)
parent_container = TypeManager.LookupInterfaceContainer (ifaces);
// TODO:
//if (TypeBuilder.IsInterface) {
// parent_container = TypeManager.LookupInterfaceContainer (base_inteface_types);
//}
if (IsTopLevel) {
if ((ModFlags & Modifiers.NEW) != 0)
@@ -1529,7 +1529,7 @@ namespace Mono.CSharp {
#if CACHE
if (!(this is ClassPart))
member_cache = new MemberCache (this, false);
member_cache = new MemberCache (this);
#endif
if (parts != null) {
@@ -2716,7 +2716,6 @@ namespace Mono.CSharp {
public abstract class ClassOrStruct : TypeContainer {
bool hasExplicitLayout = false;
ListDictionary declarative_security;
public ClassOrStruct (NamespaceEntry ns, TypeContainer parent,
MemberName name, Attributes attrs, Kind kind,
@@ -2750,14 +2749,6 @@ namespace Mono.CSharp {
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
{
if (a.Type.IsSubclassOf (TypeManager.security_attr_type) && a.CheckSecurityActionValidity (false)) {
if (declarative_security == null)
declarative_security = new ListDictionary ();
a.ExtractSecurityPermissionSet (declarative_security);
return;
}
if (a.Type == TypeManager.struct_layout_attribute_type
&& (LayoutKind) a.GetPositionalValue (0) == LayoutKind.Explicit)
hasExplicitLayout = true;
@@ -2765,17 +2756,6 @@ namespace Mono.CSharp {
base.ApplyAttributeBuilder (a, cb);
}
public override void Emit()
{
base.Emit ();
if (declarative_security != null) {
foreach (DictionaryEntry de in declarative_security) {
TypeBuilder.AddDeclarativeSecurity ((SecurityAction)de.Key, (PermissionSet)de.Value);
}
}
}
public override void Register ()
{
Parent.AddClassOrStruct (this);
@@ -3046,7 +3026,7 @@ namespace Mono.CSharp {
public readonly Parameters Parameters;
public readonly GenericMethod GenericMethod;
public readonly DeclSpace ds;
protected ToplevelBlock block;
protected Block block;
//
// Parameters, cached for semantic analysis.
@@ -3097,7 +3077,7 @@ namespace Mono.CSharp {
}
}
public ToplevelBlock Block {
public Block Block {
get {
return block;
}
@@ -3146,17 +3126,6 @@ namespace Mono.CSharp {
"change return type when overriding inherited member");
return false;
}
} else {
if (parent_method.IsAbstract && !IsInterface) {
Report.SymbolRelatedToPreviousError (parent_method);
Report.Error (533, Location, "'{0}' hides inherited abstract member", GetSignatureForError (Parent));
return false;
}
}
if (parent_method.IsSpecialName && !(this is PropertyBase)) {
Report.Error (561, Location, "'{0}': cannot override '{1}' because it is a special compiler-generated method", GetSignatureForError (Parent), TypeManager.GetFullNameSignature (parent_method));
return false;
}
if (RootContext.WarningLevel > 2) {
@@ -3177,19 +3146,12 @@ namespace Mono.CSharp {
return true;
}
MemberInfo conflict_symbol = Parent.FindMemberWithSameName (Name, !(this is Property));
if ((ModFlags & Modifiers.OVERRIDE) != 0) {
if (conflict_symbol != null) {
Report.SymbolRelatedToPreviousError (conflict_symbol);
if (this is PropertyBase)
Report.Error (544, Location, "'{0}': cannot override because '{1}' is not a property", GetSignatureForError (Parent), TypeManager.GetFullNameSignature (conflict_symbol));
else
Report.Error (505, Location, "'{0}': cannot override because '{1}' is not a method", GetSignatureForError (Parent), TypeManager.GetFullNameSignature (conflict_symbol));
} else
Report.Error (115, Location, "'{0}': no suitable methods found to override", GetSignatureForError (Parent));
Report.Error (115, Location, "'{0}': no suitable methods found to override", GetSignatureForError (Parent));
return false;
}
MemberInfo conflict_symbol = Parent.FindMemberWithSameName (Name, !(this is Property));
if (conflict_symbol == null) {
if ((RootContext.WarningLevel >= 4) && ((ModFlags & Modifiers.NEW) != 0)) {
Report.Warning (109, Location, "The member '{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError (Parent));
@@ -3315,7 +3277,7 @@ namespace Mono.CSharp {
Report.SymbolRelatedToPreviousError (parent_method);
if (!IsInterface && (parent_method.IsVirtual || parent_method.IsAbstract)) {
if (RootContext.WarningLevel >= 2)
Report.Warning (114, Location, "'{0}' hides inherited member '{1}'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword", GetSignatureForError (Parent), TypeManager.CSharpSignature (parent_method));
Report.Warning (114, Location, "'{0}' hides inherited member '{1}'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword", GetSignatureForError (Parent), parent_method);
} else
Report.Warning (108, Location, "The keyword new is required on '{0}' because it hides inherited member", GetSignatureForError (Parent));
}
@@ -3352,22 +3314,14 @@ namespace Mono.CSharp {
protected virtual bool DoDefineParameters ()
{
EmitContext ec = ds.EmitContext;
if (ec == null)
throw new InternalErrorException ("DoDefineParameters invoked too early");
bool old_unsafe = ec.InUnsafe;
ec.InUnsafe = InUnsafe;
// Check if arguments were correct
parameter_types = Parameters.GetParameterInfo (ec);
ec.InUnsafe = old_unsafe;
parameter_types = Parameters.GetParameterInfo (ds);
if ((parameter_types == null) ||
!CheckParameters (ds, parameter_types))
return false;
TypeParameter[] tparam = ds.IsGeneric ? ds.TypeParameters : null;
parameter_info = new InternalParameters (parameter_types, Parameters, tparam);
parameter_info = new InternalParameters (ds, Parameters, tparam);
Parameter array_param = Parameters.ArrayParameter;
if ((array_param != null) &&
@@ -3635,7 +3589,6 @@ namespace Mono.CSharp {
public MethodBuilder MethodBuilder;
public MethodData MethodData;
ReturnParameter return_attributes;
ListDictionary declarative_security;
/// <summary>
/// Modifiers allowed in a class declaration
@@ -3763,13 +3716,6 @@ namespace Mono.CSharp {
return;
}
if (a.Type.IsSubclassOf (TypeManager.security_attr_type) && a.CheckSecurityActionValidity (false)) {
if (declarative_security == null)
declarative_security = new ListDictionary ();
a.ExtractSecurityPermissionSet (declarative_security);
return;
}
if (a.Type == TypeManager.conditional_attribute_type) {
if (IsOperator || IsExplicitImpl) {
Report.Error (577, Location, "Conditional not valid on '{0}' because it is a destructor, operator, or explicit interface implementation", GetSignatureForError ());
@@ -3862,7 +3808,7 @@ namespace Mono.CSharp {
if (GenericMethod != null) {
string mname = MemberName.GetMethodName ();
mb = Parent.TypeBuilder.DefineGenericMethod (mname, flags);
if (!GenericMethod.Define (mb, ReturnType))
if (!GenericMethod.Define (mb))
return false;
}
@@ -3876,7 +3822,7 @@ namespace Mono.CSharp {
flags |= MethodAttributes.SpecialName | MethodAttributes.HideBySig;
MethodData = new MethodData (this, ParameterInfo, ModFlags, flags,
this, mb, GenericMethod, parent_method);
this, mb, GenericMethod);
if (!MethodData.Define (Parent))
return false;
@@ -3938,13 +3884,6 @@ namespace Mono.CSharp {
{
MethodData.Emit (Parent, this);
base.Emit ();
if (declarative_security != null) {
foreach (DictionaryEntry de in declarative_security) {
MethodBuilder.AddDeclarativeSecurity ((SecurityAction)de.Key, (PermissionSet)de.Value);
}
}
Block = null;
MethodData = null;
}
@@ -4277,7 +4216,6 @@ namespace Mono.CSharp {
public class Constructor : MethodCore, IMethodData {
public ConstructorBuilder ConstructorBuilder;
public ConstructorInitializer Initializer;
ListDictionary declarative_security;
// <summary>
// Modifiers allowed for a constructor.
@@ -4343,14 +4281,6 @@ namespace Mono.CSharp {
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
{
if (a.Type.IsSubclassOf (TypeManager.security_attr_type) && a.CheckSecurityActionValidity (false)) {
if (declarative_security == null) {
declarative_security = new ListDictionary ();
}
a.ExtractSecurityPermissionSet (declarative_security);
return;
}
ConstructorBuilder.SetCustomAttribute (cb);
}
@@ -4540,12 +4470,6 @@ namespace Mono.CSharp {
base.Emit ();
if (declarative_security != null) {
foreach (DictionaryEntry de in declarative_security) {
ConstructorBuilder.AddDeclarativeSecurity ((SecurityAction)de.Key, (PermissionSet)de.Value);
}
}
block = null;
}
@@ -4650,7 +4574,7 @@ namespace Mono.CSharp {
GenericMethod GenericMethod { get; }
Attributes OptAttributes { get; }
ToplevelBlock Block { get; }
Block Block { get; }
EmitContext CreateEmitContext (TypeContainer tc, ILGenerator ig);
ObsoleteAttribute GetObsoleteAttribute ();
@@ -4684,7 +4608,6 @@ namespace Mono.CSharp {
protected int modifiers;
protected MethodAttributes flags;
protected Type declaring_type;
protected MethodInfo parent_method;
EmitContext ec;
@@ -4715,12 +4638,11 @@ namespace Mono.CSharp {
public MethodData (MemberBase member, InternalParameters parameters,
int modifiers, MethodAttributes flags,
IMethodData method, MethodBuilder builder,
GenericMethod generic, MethodInfo parent_method)
GenericMethod generic)
: this (member, parameters, modifiers, flags, method)
{
this.builder = builder;
this.GenericMethod = generic;
this.parent_method = parent_method;
}
static string RemoveArity (string name)
@@ -4769,14 +4691,10 @@ namespace Mono.CSharp {
implementing = container.Pending.IsInterfaceMethod (
member.InterfaceType, name, method.ReturnType, ParameterTypes);
if (member.InterfaceType != null){
if (implementing == null){
Report.Error (539, method.Location,
"'{0}' in explicit interface declaration is not an interface", method_name);
if (member.InterfaceType != null && implementing == null){
Report.Error (539, method.Location, "'{0}' in explicit interface declaration is not an interface", method_name);
return false;
}
method_name = member.InterfaceType.FullName + "." + name;
}
}
//
@@ -4887,10 +4805,10 @@ namespace Mono.CSharp {
bool is_override = member.IsExplicitImpl |
((modifiers & Modifiers.OVERRIDE) != 0);
if (implementing != null)
parent_method = implementing;
is_override &= IsImplementing;
if (!GenericMethod.DefineType (ec, builder, parent_method, is_override))
if (!GenericMethod.DefineType (
ec, builder, implementing, is_override))
return false;
}
@@ -4960,8 +4878,7 @@ namespace Mono.CSharp {
if (member is MethodCore)
((MethodCore) member).Parameters.LabelParameters (ec, MethodBuilder, loc);
SymbolWriter sw = CodeGen.SymbolWriter;
ToplevelBlock block = method.Block;
Block block = method.Block;
//
// abstract or extern methods have no bodies
@@ -5017,7 +4934,7 @@ namespace Mono.CSharp {
source.CloseMethod ();
}
void EmitDestructor (EmitContext ec, ToplevelBlock block)
void EmitDestructor (EmitContext ec, Block block)
{
ILGenerator ig = ec.ig;
@@ -5194,10 +5111,6 @@ namespace Mono.CSharp {
protected virtual bool DoDefineBase ()
{
EmitContext ec = Parent.EmitContext;
if (ec == null)
throw new InternalErrorException ("MemberBase.DoDefine called too early");
if (Name == null)
throw new InternalErrorException ();
@@ -5223,22 +5136,8 @@ namespace Mono.CSharp {
protected virtual bool DoDefine (DeclSpace decl)
{
EmitContext ec = decl.EmitContext;
if (ec == null)
throw new InternalErrorException ("MemberBase.DoDefine called too early");
ec.InUnsafe = InUnsafe;
// Lookup Type, verify validity
bool old_unsafe = ec.InUnsafe;
ec.InUnsafe = InUnsafe;
TypeExpr texpr = Type.ResolveAsTypeTerminal (ec, false);
ec.InUnsafe = old_unsafe;
if (texpr == null)
return false;
MemberType = texpr.ResolveType (ec);
MemberType = decl.ResolveType (Type, false, Location);
if (MemberType == null)
return false;
@@ -5284,12 +5183,9 @@ namespace Mono.CSharp {
return false;
if (IsExplicitImpl) {
Expression expr = ExplicitInterfaceName.GetTypeExpression (Location);
TypeExpr iface_texpr = expr.ResolveAsTypeTerminal (ec, false);
if (iface_texpr == null)
return false;
Expression iface_expr = ExplicitInterfaceName.GetTypeExpression (Location);
InterfaceType = iface_texpr.ResolveType (ec);
InterfaceType = Parent.ResolveType (iface_expr, false, Location);
if (InterfaceType == null)
return false;
@@ -5356,10 +5252,7 @@ namespace Mono.CSharp {
public Status status;
[Flags]
public enum Status : byte {
ASSIGNED = 1,
USED = 2
}
public enum Status : byte { ASSIGNED = 1, USED = 2 }
static string[] attribute_targets = new string [] { "field" };
@@ -5389,17 +5282,15 @@ namespace Mono.CSharp {
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
{
if (a.Type == TypeManager.marshal_as_attr_type) {
UnmanagedMarshal marshal = a.GetMarshal (this);
UnmanagedMarshal marshal = a.GetMarshal ();
if (marshal != null) {
FieldBuilder.SetMarshal (marshal);
return;
}
Report.Warning (-24, a.Location, "The Microsoft Runtime cannot set this marshal info. Please use the Mono runtime instead.");
return;
}
if (a.Type.IsSubclassOf (TypeManager.security_attr_type)) {
a.Error_InvalidSecurityParent ();
return;
}
FieldBuilder.SetCustomAttribute (cb);
}
@@ -5553,29 +5444,19 @@ namespace Mono.CSharp {
public override bool Define()
{
EmitContext ec = Parent.EmitContext;
if (ec == null)
throw new InternalErrorException ("FieldMember.Define called too early");
bool old_unsafe = ec.InUnsafe;
ec.InUnsafe = InUnsafe;
TypeExpr texpr = Type.ResolveAsTypeTerminal (ec, false);
if (texpr == null)
return false;
MemberType = texpr.ResolveType (ec);
ec.InUnsafe = old_unsafe;
MemberType = Parent.ResolveType (Type, false, Location);
if (MemberType == null)
return false;
if (!CheckBase ())
return false;
if (!Parent.AsAccessible (MemberType, ModFlags)) {
Report.Error (52, Location,
"Inconsistent accessibility: field type `" +
TypeManager.CSharpName (MemberType) + "' is less " +
"accessible than field `" + Name + "'");
"Inconsistent accessibility: field type `" +
TypeManager.CSharpName (MemberType) + "' is less " +
"accessible than field `" + Name + "'");
return false;
}
@@ -5719,23 +5600,15 @@ namespace Mono.CSharp {
//
// Null if the accessor is empty, or a Block if not
//
public const int AllowedModifiers =
Modifiers.PUBLIC |
Modifiers.PROTECTED |
Modifiers.INTERNAL |
Modifiers.PRIVATE;
public ToplevelBlock Block;
public Block Block;
public Attributes Attributes;
public Location Location;
public int ModFlags;
public Accessor (ToplevelBlock b, int mod, Attributes attrs, Location loc)
public Accessor (Block b, Attributes attrs, Location loc)
{
Block = b;
Attributes = attrs;
Location = loc;
ModFlags = Modifiers.Check (AllowedModifiers, mod, 0, loc);
}
}
@@ -5744,8 +5617,7 @@ namespace Mono.CSharp {
// When it will be possible move here a lot of child code and template method type.
public abstract class AbstractPropertyEventMethod: MemberCore, IMethodData {
protected MethodData method_data;
protected ToplevelBlock block;
protected ListDictionary declarative_security;
protected Block block;
// The accessor are created event if they are not wanted.
// But we need them because their names are reserved.
@@ -5786,7 +5658,7 @@ namespace Mono.CSharp {
#region IMethodData Members
public ToplevelBlock Block {
public Block Block {
get {
return block;
}
@@ -5834,13 +5706,6 @@ namespace Mono.CSharp {
return;
}
if (a.Type.IsSubclassOf (TypeManager.security_attr_type) && a.CheckSecurityActionValidity (false)) {
if (declarative_security == null)
declarative_security = new ListDictionary ();
a.ExtractSecurityPermissionSet (declarative_security);
return;
}
if (a.Target == AttributeTargets.Method) {
method_data.MethodBuilder.SetCustomAttribute (cb);
return;
@@ -5870,13 +5735,6 @@ namespace Mono.CSharp {
public virtual void Emit (TypeContainer container)
{
method_data.Emit (container, this);
if (declarative_security != null) {
foreach (DictionaryEntry de in declarative_security) {
method_data.MethodBuilder.AddDeclarativeSecurity ((SecurityAction)de.Key, (PermissionSet)de.Value);
}
}
block = null;
}
@@ -5939,9 +5797,7 @@ namespace Mono.CSharp {
public override MethodBuilder Define(TypeContainer container)
{
base.Define (container);
method_data = new MethodData (method, method.ParameterInfo, ModFlags, flags, this);
method_data = new MethodData (method, method.ParameterInfo, method.ModFlags, method.flags, this);
if (!method_data.Define (container))
return null;
@@ -5995,23 +5851,17 @@ namespace Mono.CSharp {
base.ApplyAttributeBuilder (a, cb);
}
protected virtual InternalParameters GetParameterInfo (EmitContext ec)
protected virtual InternalParameters GetParameterInfo (TypeContainer container)
{
Parameter [] parms = new Parameter [1];
parms [0] = new Parameter (method.Type, "value", Parameter.Modifier.NONE, null);
Parameters parameters = new Parameters (parms, null, method.Location);
Type [] types = parameters.GetParameterInfo (ec);
return new InternalParameters (types, parameters);
return new InternalParameters (
container, new Parameters (parms, null, method.Location));
}
public override MethodBuilder Define(TypeContainer container)
{
if (container.EmitContext == null)
throw new InternalErrorException ("SetMethod.Define called too early");
base.Define (container);
method_data = new MethodData (method, GetParameterInfo (container.EmitContext), ModFlags, flags, this);
method_data = new MethodData (method, GetParameterInfo (container), method.ModFlags, method.flags, this);
if (!method_data.Define (container))
return null;
@@ -6047,7 +5897,6 @@ namespace Mono.CSharp {
public abstract class PropertyMethod: AbstractPropertyEventMethod {
protected readonly MethodCore method;
protected MethodAttributes flags;
public PropertyMethod (MethodCore method, string prefix)
: base (method, prefix)
@@ -6059,12 +5908,6 @@ namespace Mono.CSharp {
: base (method, accessor, prefix)
{
this.method = method;
this.ModFlags = accessor.ModFlags;
if (accessor.ModFlags != 0 && RootContext.Version == LanguageVersion.ISO_1) {
Report.FeatureIsNotStandardized (Location, "accessor modifiers");
Environment.Exit (1);
}
}
public override AttributeTargets AttributeTargets {
@@ -6085,24 +5928,7 @@ namespace Mono.CSharp {
}
}
public virtual MethodBuilder Define (TypeContainer container)
{
//
// Check for custom access modifier
//
if (ModFlags == 0) {
ModFlags = method.ModFlags;
flags = method.flags;
} else {
CheckModifiers (container, ModFlags);
ModFlags |= (method.ModFlags & (~Modifiers.Accessibility));
flags = Modifiers.MethodAttr (ModFlags);
flags |= (method.flags & (~MethodAttributes.MemberAccessMask));
}
return null;
}
public abstract MethodBuilder Define (TypeContainer container);
public override Type[] ParameterTypes {
get {
@@ -6127,29 +5953,7 @@ namespace Mono.CSharp {
{
return String.Concat (tc.Name, '.', method.Name);
}
void CheckModifiers (TypeContainer container, int modflags)
{
int flags = 0;
int mflags = method.ModFlags & Modifiers.Accessibility;
if ((mflags & Modifiers.PUBLIC) != 0) {
flags |= Modifiers.PROTECTED | Modifiers.INTERNAL | Modifiers.PRIVATE;
}
else if ((mflags & Modifiers.PROTECTED) != 0) {
if ((mflags & Modifiers.INTERNAL) != 0)
flags |= Modifiers.PROTECTED | Modifiers.INTERNAL;
flags |= Modifiers.PRIVATE;
}
else if ((mflags & Modifiers.INTERNAL) != 0)
flags |= Modifiers.PRIVATE;
if ((mflags == modflags) || (modflags & (~flags)) != 0)
Report.Error (273, Location, "{0}: accessibility modifier must be more restrictive than the property or indexer",
GetSignatureForError (container));
}
}
}
public PropertyMethod Get, Set;
public PropertyBuilder PropertyBuilder;
@@ -6168,11 +5972,6 @@ namespace Mono.CSharp {
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
{
if (a.Type.IsSubclassOf (TypeManager.security_attr_type)) {
a.Error_InvalidSecurityParent ();
return;
}
PropertyBuilder.SetCustomAttribute (cb);
}
@@ -6198,23 +5997,6 @@ namespace Mono.CSharp {
if (!base.DoDefine (ds))
return false;
//
// Accessors modifiers check
//
if (Get.ModFlags != 0 && Set.ModFlags != 0) {
Report.Error (274, Location, "'{0}': cannot specify accessibility modifiers for both accessors of the property or indexer.",
GetSignatureForError ());
return false;
}
if ((Get.IsDummy || Set.IsDummy)
&& (Get.ModFlags != 0 || Set.ModFlags != 0) && (ModFlags & Modifiers.OVERRIDE) == 0) {
Report.Error (276, Location,
"'{0}': accessibility modifiers on accessors may only be used if the property or indexer has both a get and a set accessor.",
GetSignatureForError ());
return false;
}
if (MemberType.IsAbstract && MemberType.IsSealed) {
Report.Error (722, Location, Error722, TypeManager.CSharpName (MemberType));
return false;
@@ -6260,7 +6042,6 @@ namespace Mono.CSharp {
return true;
}
// TODO: rename to Resolve......
protected override MethodInfo FindOutParentMethod (TypeContainer container, ref Type parent_ret_type)
{
PropertyInfo parent_property = container.ParentContainer.MemberCache.FindMemberToOverride (
@@ -6270,52 +6051,14 @@ namespace Mono.CSharp {
return null;
parent_ret_type = parent_property.PropertyType;
MethodInfo get_accessor = parent_property.GetGetMethod (true);
MethodInfo set_accessor = parent_property.GetSetMethod (true);
MethodAttributes get_accessor_access, set_accessor_access;
if ((ModFlags & Modifiers.OVERRIDE) != 0) {
if (Get != null && !Get.IsDummy && get_accessor == null) {
Report.SymbolRelatedToPreviousError (parent_property);
Report.Error (545, Location, "'{0}': cannot override because '{1}' does not have an overridable get accessor", GetSignatureForError (), TypeManager.GetFullNameSignature (parent_property));
}
MethodInfo temp_m;
temp_m = parent_property.GetGetMethod (true);
if (temp_m != null)
return temp_m;
if (Set != null && !Set.IsDummy && set_accessor == null) {
Report.SymbolRelatedToPreviousError (parent_property);
Report.Error (546, Location, "'{0}': cannot override because '{1}' does not have an overridable set accessor", GetSignatureForError (), TypeManager.GetFullNameSignature (parent_property));
}
}
//
// Check parent accessors access
//
get_accessor_access = set_accessor_access = 0;
if ((ModFlags & Modifiers.NEW) == 0) {
if (get_accessor != null) {
MethodAttributes get_flags = Modifiers.MethodAttr (Get.ModFlags != 0 ? Get.ModFlags : ModFlags);
get_accessor_access = (get_accessor.Attributes & MethodAttributes.MemberAccessMask);
if (!Get.IsDummy && (get_accessor_access) !=
(get_flags & MethodAttributes.MemberAccessMask))
Report.Error (507, Location, "'{0}' can't change the access modifiers when overriding inherited member '{1}'",
GetSignatureForError (), TypeManager.GetFullNameSignature (parent_property));
}
if (set_accessor != null) {
MethodAttributes set_flags = Modifiers.MethodAttr (Set.ModFlags != 0 ? Set.ModFlags : ModFlags);
set_accessor_access = (set_accessor.Attributes & MethodAttributes.MemberAccessMask);
if (!Set.IsDummy & (set_accessor_access) !=
(set_flags & MethodAttributes.MemberAccessMask))
Report.Error (507, Location, "'{0}' can't change the access modifiers when overriding inherited member '{1}'",
GetSignatureForError (container), TypeManager.GetFullNameSignature (parent_property));
}
}
//
// Get the less restrictive access
//
return get_accessor_access > set_accessor_access ? get_accessor : set_accessor;
System.Diagnostics.Debug.Assert (parent_property.GetSetMethod (true) != null, "Internal error property without get/set");
return parent_property.GetSetMethod (true);
}
public override void Emit ()
@@ -6448,16 +6191,18 @@ namespace Mono.CSharp {
prop_attr |= PropertyAttributes.RTSpecialName |
PropertyAttributes.SpecialName;
PropertyBuilder = Parent.TypeBuilder.DefineProperty (
Name, prop_attr, MemberType, null);
if (!IsExplicitImpl){
PropertyBuilder = Parent.TypeBuilder.DefineProperty (
Name, prop_attr, MemberType, null);
if (!Get.IsDummy)
PropertyBuilder.SetGetMethod (GetBuilder);
if (!Get.IsDummy)
PropertyBuilder.SetGetMethod (GetBuilder);
if (!Set.IsDummy)
PropertyBuilder.SetSetMethod (SetBuilder);
if (!Set.IsDummy)
PropertyBuilder.SetSetMethod (SetBuilder);
TypeManager.RegisterProperty (PropertyBuilder, GetBuilder, SetBuilder);
TypeManager.RegisterProperty (PropertyBuilder, GetBuilder, SetBuilder);
}
return true;
}
@@ -6878,11 +6623,6 @@ namespace Mono.CSharp {
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
{
if (a.Type.IsSubclassOf (TypeManager.security_attr_type)) {
a.Error_InvalidSecurityParent ();
return;
}
EventBuilder.SetCustomAttribute (cb);
}
@@ -6901,7 +6641,7 @@ namespace Mono.CSharp {
{
EventAttributes e_attr;
e_attr = EventAttributes.None;
;
if (!DoDefineBase ())
return false;
@@ -6920,19 +6660,10 @@ namespace Mono.CSharp {
return false;
}
EmitContext ec = Parent.EmitContext;
if (ec == null)
throw new InternalErrorException ("Event.Define called too early?");
bool old_unsafe = ec.InUnsafe;
ec.InUnsafe = InUnsafe;
Parameter [] parms = new Parameter [1];
parms [0] = new Parameter (Type, "value", Parameter.Modifier.NONE, null);
Parameters parameters = new Parameters (parms, null, Location);
Type [] types = parameters.GetParameterInfo (ec);
InternalParameters ip = new InternalParameters (types, parameters);
ec.InUnsafe = old_unsafe;
InternalParameters ip = new InternalParameters (
Parent, new Parameters (parms, null, Location));
if (!CheckBase ())
return false;
@@ -6949,9 +6680,12 @@ namespace Mono.CSharp {
if (RemoveBuilder == null)
return false;
EventBuilder = new MyEventBuilder (this, Parent.TypeBuilder, Name, e_attr, MemberType);
if (!IsExplicitImpl){
EventBuilder = new MyEventBuilder (this,
Parent.TypeBuilder, Name, e_attr, MemberType);
if (Add.Block == null && Remove.Block == null && !IsInterface) {
if (Add.Block == null && Remove.Block == null &&
!IsInterface) {
FieldBuilder = Parent.TypeBuilder.DefineField (
Name, MemberType,
FieldAttributes.Private | ((ModFlags & Modifiers.STATIC) != 0 ? FieldAttributes.Static : 0));
@@ -6964,6 +6698,8 @@ namespace Mono.CSharp {
EventBuilder.SetRemoveOnMethod (RemoveBuilder);
TypeManager.RegisterEvent (EventBuilder, AddBuilder, RemoveBuilder);
}
return true;
}
@@ -7055,7 +6791,7 @@ namespace Mono.CSharp {
}
}
protected override InternalParameters GetParameterInfo (EmitContext ec)
protected override InternalParameters GetParameterInfo (TypeContainer container)
{
Parameter [] fixed_parms = parameters.FixedParameters;
@@ -7082,12 +6818,13 @@ namespace Mono.CSharp {
method.Type, "value", Parameter.Modifier.NONE, null);
Parameters set_formal_params = new Parameters (tmp, null, method.Location);
Type [] types = set_formal_params.GetParameterInfo (ec);
return new InternalParameters (types, set_formal_params);
return new InternalParameters (container, set_formal_params);
}
}
const int AllowedModifiers =
Modifiers.NEW |
Modifiers.PUBLIC |
@@ -7143,21 +6880,17 @@ namespace Mono.CSharp {
ShortName = indexer_attr.GetIndexerAttributeValue (ec);
if (IsExplicitImpl) {
Report.Error (415, indexer_attr.Location,
"The 'IndexerName' attribute is valid only on an" +
"indexer that is not an explicit interface member declaration");
Report.Error (415, indexer_attr.Location, "The 'IndexerName' attribute is valid only on an indexer that is not an explicit interface member declaration");
return false;
}
if ((ModFlags & Modifiers.OVERRIDE) != 0) {
Report.Error (609, indexer_attr.Location,
"Cannot set the 'IndexerName' attribute on an indexer marked override");
Report.Error (609, indexer_attr.Location, "Cannot set the 'IndexerName' attribute on an indexer marked override");
return false;
}
if (!Tokenizer.IsValidIdentifier (ShortName)) {
Report.Error (633, indexer_attr.Location,
"The argument to the 'IndexerName' attribute must be a valid identifier");
Report.Error (633, indexer_attr.Location, "The argument to the 'IndexerName' attribute must be a valid identifier");
return false;
}
@@ -7226,8 +6959,15 @@ namespace Mono.CSharp {
}
}
//
// Define the PropertyBuilder if one of the following conditions are met:
// a) we're not implementing an interface indexer.
// b) the indexer has a different IndexerName and this is no
// explicit interface implementation.
//
if (!IsExplicitImpl) {
PropertyBuilder = Parent.TypeBuilder.DefineProperty (
Name, prop_attr, MemberType, ParameterTypes);
ShortName, prop_attr, MemberType, ParameterTypes);
if (!Get.IsDummy)
PropertyBuilder.SetGetMethod (GetBuilder);
@@ -7235,7 +6975,9 @@ namespace Mono.CSharp {
if (!Set.IsDummy)
PropertyBuilder.SetSetMethod (SetBuilder);
TypeManager.RegisterIndexer (PropertyBuilder, GetBuilder, SetBuilder, ParameterTypes);
TypeManager.RegisterIndexer (PropertyBuilder, GetBuilder, SetBuilder,
ParameterTypes);
}
return true;
}
@@ -7309,7 +7051,7 @@ namespace Mono.CSharp {
public Operator (TypeContainer parent, OpType type, Expression ret_type,
int mod_flags, Parameters parameters,
ToplevelBlock block, Attributes attrs, Location loc)
Block block, Attributes attrs, Location loc)
: base (parent, null, ret_type, mod_flags, AllowedModifiers, false,
new MemberName ("op_" + type), attrs, parameters, loc)
{
@@ -7574,8 +7316,7 @@ namespace Mono.CSharp {
public override string GetSignatureForError (TypeContainer tc)
{
StringBuilder sb = new StringBuilder ();
sb.AppendFormat ("{0}.operator {1} {2}({3}", tc.Name, GetName (OperatorType), Type.Type == null ? Type.ToString () : TypeManager.CSharpName (Type.Type),
Parameters.FixedParameters [0].GetSignatureForError ());
sb.AppendFormat ("{0}.operator {1} {2}({3}", tc.Name, GetName (OperatorType), Type.ToString (), Parameters.FixedParameters [0].GetSignatureForError ());
if (Parameters.FixedParameters.Length > 1) {
sb.Append (",");
+53 -295
View File
@@ -4,20 +4,16 @@
// Author:
// Miguel de Icaza ([email protected])
//
// (C) 2001, 2002, 2003 Ximian, Inc.
// (C) 2004 Novell, Inc.
// (C) 2001 Ximian, Inc.
//
//#define PRODUCTION
using System;
using System.IO;
using System.Collections;
using System.Collections.Specialized;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using Mono.Security.Cryptography;
@@ -371,7 +367,7 @@ namespace Mono.CSharp {
/// <summary>
/// Whether we are inside an anonymous method.
/// </summary>
public AnonymousMethod CurrentAnonymousMethod;
public bool InAnonymousMethod;
/// <summary>
/// Location for this EmitContext
@@ -395,35 +391,14 @@ namespace Mono.CSharp {
/// </summary>
public bool InEnumContext;
/// <summary>
/// Anonymous methods can capture local variables and fields,
/// this object tracks it. It is copied from the TopLevelBlock
/// field.
/// </summary>
public CaptureContext capture_context;
/// <summary>
/// Trace when method is called and is obsolete then this member suppress message
/// when call is inside next [Obsolete] method or type.
/// </summary>
public bool TestObsoleteMethodUsage = true;
/// <summary>
/// The current iterator
/// </summary>
public Iterator CurrentIterator;
/// <summary>
/// Whether we are in the resolving stage or not
/// </summary>
enum Phase {
Created,
Resolving,
Emitting
}
Phase current_phase;
FlowBranching current_flow_branching;
public EmitContext (DeclSpace parent, DeclSpace ds, Location l, ILGenerator ig,
@@ -443,7 +418,6 @@ namespace Mono.CSharp {
IsConstructor = is_constructor;
CurrentBlock = null;
CurrentFile = 0;
current_phase = Phase.Created;
if (parent != null){
// Can only be null for the ResolveType contexts.
@@ -477,12 +451,6 @@ namespace Mono.CSharp {
}
}
public bool HaveCaptureInfo {
get {
return capture_context != null;
}
}
// <summary>
// Starts a new code branching. This inherits the state of all local
// variables and parameters from the current branching.
@@ -549,141 +517,30 @@ namespace Mono.CSharp {
current_flow_branching = current_flow_branching.Parent;
}
public void CaptureVariable (LocalInfo li)
public void EmitTopBlock (Block block, InternalParameters ip, Location loc)
{
capture_context.AddLocal (CurrentAnonymousMethod, li);
li.IsCaptured = true;
}
public void CaptureParameter (string name, Type t, int idx)
{
capture_context.AddParameter (this, CurrentAnonymousMethod, name, t, idx);
}
//
// Use to register a field as captured
//
public void CaptureField (FieldExpr fe)
{
capture_context.AddField (fe);
}
//
// Whether anonymous methods have captured variables
//
public bool HaveCapturedVariables ()
{
if (capture_context != null)
return capture_context.HaveCapturedVariables;
return false;
}
//
// Whether anonymous methods have captured fields or this.
//
public bool HaveCapturedFields ()
{
if (capture_context != null)
return capture_context.HaveCapturedFields;
return false;
}
//
// Emits the instance pointer for the host method
//
public void EmitMethodHostInstance (EmitContext target, AnonymousMethod am)
{
if (capture_context != null)
capture_context.EmitMethodHostInstance (target, am);
else if (IsStatic)
target.ig.Emit (OpCodes.Ldnull);
else
target.ig.Emit (OpCodes.Ldarg_0);
}
//
// Returns whether the `local' variable has been captured by an anonymous
// method
//
public bool IsCaptured (LocalInfo local)
{
return capture_context.IsCaptured (local);
}
public bool IsParameterCaptured (string name)
{
if (capture_context != null)
return capture_context.IsParameterCaptured (name);
return false;
}
public void EmitMeta (ToplevelBlock b, InternalParameters ip)
{
if (capture_context != null)
capture_context.EmitHelperClasses (this);
b.EmitMeta (this);
if (HasReturnLabel)
ReturnLabel = ig.DefineLabel ();
}
//
// Here until we can fix the problem with Mono.CSharp.Switch, which
// currently can not cope with ig == null during resolve (which must
// be fixed for switch statements to work on anonymous methods).
//
public void EmitTopBlock (ToplevelBlock block, InternalParameters ip, Location loc)
{
if (block == null)
return;
bool unreachable;
if (ResolveTopBlock (null, block, ip, loc, out unreachable)){
EmitMeta (block, ip);
current_phase = Phase.Emitting;
EmitResolvedTopBlock (block, unreachable);
}
}
public bool ResolveTopBlock (EmitContext anonymous_method_host, ToplevelBlock block,
InternalParameters ip, Location loc, out bool unreachable)
{
current_phase = Phase.Resolving;
unreachable = false;
capture_context = block.CaptureContext;
bool unreachable = false;
if (!Location.IsNull (loc))
CurrentFile = loc.File;
#if PRODUCTION
try {
#endif
if (block != null){
try {
int errors = Report.Errors;
block.ResolveMeta (block, this, ip);
block.EmitMeta (this, ip);
if (Report.Errors == errors){
bool old_do_flow_analysis = DoFlowAnalysis;
DoFlowAnalysis = true;
if (anonymous_method_host != null)
current_flow_branching = FlowBranching.CreateBranching (
anonymous_method_host.CurrentBranching, FlowBranching.BranchingType.Block,
block, loc);
else
current_flow_branching = FlowBranching.CreateBranching (
null, FlowBranching.BranchingType.Block, block, loc);
if (!block.Resolve (this)) {
current_flow_branching = null;
DoFlowAnalysis = old_do_flow_analysis;
return false;
return;
}
FlowBranching.Reachability reachability = current_flow_branching.MergeTopBlock ();
@@ -691,50 +548,41 @@ namespace Mono.CSharp {
DoFlowAnalysis = old_do_flow_analysis;
block.Emit (this);
if (reachability.AlwaysReturns ||
reachability.AlwaysThrows ||
reachability.IsUnreachable)
unreachable = true;
}
#if PRODUCTION
} catch (Exception e) {
Console.WriteLine ("Exception caught by the compiler while compiling:");
Console.WriteLine (" Block that caused the problem begin at: " + loc);
if (CurrentBlock != null){
Console.WriteLine (" Block being compiled: [{0},{1}]",
CurrentBlock.StartLocation, CurrentBlock.EndLocation);
}
Console.WriteLine (e.GetType ().FullName + ": " + e.Message);
throw;
}
#if FIXME
} catch (Exception e) {
Console.WriteLine ("Exception caught by the compiler while compiling:");
Console.WriteLine (" Block that caused the problem begin at: " + loc);
if (CurrentBlock != null){
Console.WriteLine (" Block being compiled: [{0},{1}]",
CurrentBlock.StartLocation, CurrentBlock.EndLocation);
}
Console.WriteLine (e.GetType ().FullName + ": " + e.Message);
Console.WriteLine (Report.FriendlyStackTrace (e));
Environment.Exit (1);
#else
} finally {
#endif
}
}
if (ReturnType != null && !unreachable){
if (!InIterator){
if (CurrentAnonymousMethod != null){
Report.Error (1643, loc, "Not all code paths return a value in anonymous method of type `{0}'",
CurrentAnonymousMethod.Type);
} else {
Report.Error (161, loc, "Not all code paths return a value");
}
return false;
Report.Error (161, loc, "Not all code paths return a value");
return;
}
}
block.CompleteContexts ();
return true;
}
public void EmitResolvedTopBlock (ToplevelBlock block, bool unreachable)
{
if (block != null)
block.Emit (this);
if (HasReturnLabel)
ig.MarkLabel (ReturnLabel);
if (return_value != null){
ig.Emit (OpCodes.Ldloc, return_value);
ig.Emit (OpCodes.Ret);
@@ -760,12 +608,6 @@ namespace Mono.CSharp {
ig.Emit (OpCodes.Ret);
}
}
//
// Close pending helper classes if we are the toplevel
//
if (capture_context != null && capture_context.ParentToplevel == null)
capture_context.CloseHelperClasses ();
}
/// <summary>
@@ -872,42 +714,24 @@ namespace Mono.CSharp {
/// return value from the function. By default this is not
/// used. This is only required when returns are found inside
/// Try or Catch statements.
///
/// This method is typically invoked from the Emit phase, so
/// we allow the creation of a return label if it was not
/// requested during the resolution phase. Could be cleaned
/// up, but it would replicate a lot of logic in the Emit phase
/// of the code that uses it.
/// </summary>
public LocalBuilder TemporaryReturn ()
{
if (return_value == null){
return_value = ig.DeclareLocal (ReturnType);
if (!HasReturnLabel){
ReturnLabel = ig.DefineLabel ();
HasReturnLabel = true;
}
}
return return_value;
}
/// <summary>
/// This method is used during the Resolution phase to flag the
/// need to define the ReturnLabel
/// </summary>
public void NeedReturnLabel ()
{
if (current_phase != Phase.Resolving){
//
// The reason is that the `ReturnLabel' is declared between
// resolution and emission
//
throw new Exception ("NeedReturnLabel called from Emit phase, should only be called during Resolve");
}
if (!InIterator && !HasReturnLabel)
if (!InIterator && !HasReturnLabel) {
ReturnLabel = ig.DefineLabel ();
HasReturnLabel = true;
}
}
//
@@ -921,6 +745,24 @@ namespace Mono.CSharp {
throw new Exception ("MapVariable for an unknown state");
}
//
// Invoke this routine to remap a VariableInfo into the
// proper MemberAccess expression
//
public Expression RemapLocal (LocalInfo local_info)
{
FieldExpr fe = new FieldExpr (local_info.FieldBuilder, loc);
fe.InstanceExpression = new ProxyInstance ();
return fe.DoResolve (this);
}
public Expression RemapLocalLValue (LocalInfo local_info, Expression right_side)
{
FieldExpr fe = new FieldExpr (local_info.FieldBuilder, loc);
fe.InstanceExpression = new ProxyInstance ();
return fe.DoResolveLValue (this, right_side);
}
public Expression RemapParameter (int idx)
{
FieldExpr fe = new FieldExprNoAddress (CurrentIterator.parameter_fields [idx].FieldBuilder, loc);
@@ -942,58 +784,13 @@ namespace Mono.CSharp {
public void EmitThis ()
{
ig.Emit (OpCodes.Ldarg_0);
if (InIterator){
if (!IsStatic){
if (InIterator && !IsStatic){
FieldBuilder this_field = CurrentIterator.this_field.FieldBuilder;
if (TypeManager.IsValueType (this_field.FieldType))
ig.Emit (OpCodes.Ldflda, this_field);
else
ig.Emit (OpCodes.Ldfld, this_field);
}
} else if (capture_context != null && CurrentAnonymousMethod != null){
ScopeInfo si = CurrentAnonymousMethod.Scope;
while (si != null){
if (si.ParentLink != null)
ig.Emit (OpCodes.Ldfld, si.ParentLink);
if (si.THIS != null){
ig.Emit (OpCodes.Ldfld, si.THIS);
break;
}
si = si.ParentScope;
}
}
}
//
// Emits the code necessary to load the instance required
// to access the captured LocalInfo
//
public void EmitCapturedVariableInstance (LocalInfo li)
{
if (RemapToProxy){
ig.Emit (OpCodes.Ldarg_0);
return;
}
if (capture_context == null)
throw new Exception ("Calling EmitCapturedContext when there is no capture_context");
capture_context.EmitCapturedVariableInstance (this, li, CurrentAnonymousMethod);
}
public void EmitParameter (string name)
{
capture_context.EmitParameter (this, name);
}
public void EmitAssignParameter (string name, Expression source, bool leave_copy, bool prepare_for_load)
{
capture_context.EmitAssignParameter (this, name, source, leave_copy, prepare_for_load);
}
public void EmitAddressOfParameter (string name)
{
capture_context.EmitAddressOfParameter (this, name);
}
public Expression GetThis (Location loc)
@@ -1057,8 +854,6 @@ namespace Mono.CSharp {
bool is_cls_compliant;
ListDictionary declarative_security;
static string[] attribute_targets = new string [] { "assembly" };
public AssemblyClass (): base ()
@@ -1237,47 +1032,9 @@ namespace Mono.CSharp {
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder customBuilder)
{
if (a.Type.IsSubclassOf (TypeManager.security_attr_type) && a.CheckSecurityActionValidity (true)) {
if (declarative_security == null)
declarative_security = new ListDictionary ();
a.ExtractSecurityPermissionSet (declarative_security);
return;
}
Builder.SetCustomAttribute (customBuilder);
}
public override void Emit (TypeContainer tc)
{
base.Emit (tc);
if (declarative_security != null) {
MethodInfo add_permission = typeof (AssemblyBuilder).GetMethod ("AddPermissionRequests", BindingFlags.Instance | BindingFlags.NonPublic);
object builder_instance = Builder;
try {
// Microsoft runtime hacking
if (add_permission == null) {
Type assembly_builder = typeof (AssemblyBuilder).Assembly.GetType ("System.Reflection.Emit.AssemblyBuilderData");
add_permission = assembly_builder.GetMethod ("AddPermissionRequests", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo fi = typeof (AssemblyBuilder).GetField ("m_assemblyData", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
builder_instance = fi.GetValue (Builder);
}
object[] args = new object [] { declarative_security [SecurityAction.RequestMinimum],
declarative_security [SecurityAction.RequestOptional],
declarative_security [SecurityAction.RequestRefuse] };
add_permission.Invoke (builder_instance, args);
}
catch {
Report.RuntimeMissingSupport (Location.Null, "assembly permission setting");
}
}
}
public override string[] ValidAttributeTargets {
get {
return attribute_targets;
@@ -1327,6 +1084,7 @@ namespace Mono.CSharp {
{
if (a != null && a.Type == TypeManager.cls_compliant_attribute_type) {
Report.Warning (3012, a.Location, "You must specify the CLSCompliant attribute on the assembly, not the module, to enable CLS compliance checking");
return;
}
Builder.SetCustomAttribute (customBuilder);
+3 -2
View File
@@ -82,7 +82,8 @@ namespace Mono.CSharp {
while (ttype.IsArray)
ttype = TypeManager.GetElementType (ttype);
if (!TypeManager.IsBuiltinType (ttype) && (!ttype.IsSubclassOf (TypeManager.enum_type)) && !(Expr is NullLiteral)) {
if (!TypeManager.IsBuiltinType (ttype) &&
(!ttype.IsSubclassOf (TypeManager.enum_type))) {
Report.Error (
-3, Location,
"Constant type is not valid (only system types are allowed)");
@@ -111,7 +112,7 @@ namespace Mono.CSharp {
if (expr is NullLiteral && !type.IsValueType && !TypeManager.IsEnumType (type))
return NullLiteral.Null;
if (!Convert.ImplicitStandardConversionExists (Convert.ConstantEC, expr, type)){
if (!Convert.ImplicitStandardConversionExists (expr, type)){
Convert.Error_CannotImplicitConversion (loc, expr.Type, type);
return null;
}
+53 -108
View File
@@ -19,16 +19,6 @@ namespace Mono.CSharp {
// A container class for all the conversion operations
//
public class Convert {
//
// This is used to prettify the code: a null argument is allowed
// for ImplicitStandardConversion as long as it is known that
// no anonymous method will play a role.
//
// FIXME: renamed from `const' to `static' to allow bootstraping from older
// versions of the compiler that could not cope with this construct.
//
public static EmitContext ConstantEC = null;
static void Error_CannotConvertType (Location loc, Type source, Type target)
{
Report.Error (30, loc, "Cannot convert type '" +
@@ -60,16 +50,16 @@ namespace Mono.CSharp {
return true;
}
static Type TypeParam_EffectiveBaseType (EmitContext ec, Type t)
static Type TypeParam_EffectiveBaseType (Type t)
{
GenericConstraints gc = TypeManager.GetTypeParameterConstraints (t);
if (gc == null)
return TypeManager.object_type;
return TypeParam_EffectiveBaseType (ec, gc);
return TypeParam_EffectiveBaseType (gc);
}
static Type TypeParam_EffectiveBaseType (EmitContext ec, GenericConstraints gc)
static Type TypeParam_EffectiveBaseType (GenericConstraints gc)
{
ArrayList list = new ArrayList ();
list.Add (gc.EffectiveBaseClass);
@@ -79,9 +69,9 @@ namespace Mono.CSharp {
GenericConstraints new_gc = TypeManager.GetTypeParameterConstraints (t);
if (new_gc != null)
list.Add (TypeParam_EffectiveBaseType (ec, new_gc));
list.Add (TypeParam_EffectiveBaseType (new_gc));
}
return FindMostEncompassedType (ec, list);
return FindMostEncompassedType (list);
}
static Expression TypeParameterConversion (Expression expr, bool is_reference, Type target_type)
@@ -92,8 +82,7 @@ namespace Mono.CSharp {
return new BoxedCast (expr, target_type);
}
static Expression ImplicitTypeParameterConversion (EmitContext ec, Expression expr,
Type target_type)
static Expression ImplicitTypeParameterConversion (Expression expr, Type target_type)
{
Type expr_type = expr.Type;
@@ -108,7 +97,7 @@ namespace Mono.CSharp {
// We're converting from a type parameter which is known to be a reference type.
bool is_reference = gc.IsReferenceType;
Type base_type = TypeParam_EffectiveBaseType (ec, gc);
Type base_type = TypeParam_EffectiveBaseType (gc);
if (TypeManager.IsSubclassOf (base_type, target_type))
return TypeParameterConversion (expr, is_reference, target_type);
@@ -134,7 +123,7 @@ namespace Mono.CSharp {
}
static EmptyExpression MyEmptyExpr;
static public Expression ImplicitReferenceConversion (EmitContext ec, Expression expr, Type target_type)
static public Expression ImplicitReferenceConversion (Expression expr, Type target_type)
{
Type expr_type = expr.Type;
@@ -148,7 +137,7 @@ namespace Mono.CSharp {
return null;
if (expr_type.IsGenericParameter)
return ImplicitTypeParameterConversion (ec, expr, target_type);
return ImplicitTypeParameterConversion (expr, target_type);
//
// notice that it is possible to write "ValueType v = 1", the ValueType here
@@ -163,11 +152,8 @@ namespace Mono.CSharp {
if (TypeManager.IsValueType (expr_type))
return new BoxedCast (expr);
if (expr_type.IsClass || expr_type.IsInterface || expr_type == TypeManager.enum_type){
if (target_type == TypeManager.anonymous_method_type)
return null;
if (expr_type.IsClass || expr_type.IsInterface || expr_type == TypeManager.enum_type)
return new EmptyCast (expr, target_type);
}
return null;
} else if (target_type == TypeManager.value_type) {
@@ -244,7 +230,7 @@ namespace Mono.CSharp {
Type target_element_type = TypeManager.GetElementType (target_type);
if (!expr_element_type.IsValueType && !target_element_type.IsValueType)
if (ImplicitStandardConversionExists (ConstantEC, MyEmptyExpr,
if (ImplicitStandardConversionExists (MyEmptyExpr,
target_element_type))
return new EmptyCast (expr, target_type);
}
@@ -276,12 +262,12 @@ namespace Mono.CSharp {
// Tests whether an implicit reference conversion exists between expr_type
// and target_type
//
public static bool ImplicitReferenceConversionExists (EmitContext ec, Expression expr, Type target_type)
public static bool ImplicitReferenceConversionExists (Expression expr, Type target_type)
{
Type expr_type = expr.Type;
if (expr_type.IsGenericParameter)
return ImplicitTypeParameterConversion (ec, expr, target_type) != null;
return ImplicitTypeParameterConversion (expr, target_type) != null;
//
// This is the boxed case.
@@ -289,7 +275,6 @@ namespace Mono.CSharp {
if (target_type == TypeManager.object_type) {
if (expr_type.IsClass || TypeManager.IsValueType (expr_type) ||
expr_type.IsInterface || expr_type == TypeManager.enum_type)
if (target_type != TypeManager.anonymous_method_type)
return true;
return false;
@@ -323,7 +308,7 @@ namespace Mono.CSharp {
Type target_element_type = TypeManager.GetElementType (target_type);
if (!expr_element_type.IsValueType && !target_element_type.IsValueType)
if (ImplicitStandardConversionExists (ConstantEC, MyEmptyExpr,
if (ImplicitStandardConversionExists (MyEmptyExpr,
target_element_type))
return true;
}
@@ -532,7 +517,7 @@ namespace Mono.CSharp {
if ((expr is NullLiteral) && target_type.IsGenericParameter)
return TypeParameter_to_Null (target_type);
if (ImplicitStandardConversionExists (ec, expr, target_type))
if (ImplicitStandardConversionExists (expr, target_type))
return true;
Expression dummy = ImplicitUserConversion (ec, expr, target_type, Location.Null);
@@ -553,10 +538,8 @@ namespace Mono.CSharp {
/// <summary>
/// Determines if a standard implicit conversion exists from
/// expr_type to target_type
///
/// ec should point to a real EmitContext if expr.Type is TypeManager.anonymous_method_type.
/// </summary>
public static bool ImplicitStandardConversionExists (EmitContext ec, Expression expr, Type target_type)
public static bool ImplicitStandardConversionExists (Expression expr, Type target_type)
{
Type expr_type = expr.Type;
@@ -674,7 +657,7 @@ namespace Mono.CSharp {
return true;
}
if (ImplicitReferenceConversionExists (ec, expr, target_type))
if (ImplicitReferenceConversionExists (expr, target_type))
return true;
//
@@ -735,18 +718,6 @@ namespace Mono.CSharp {
if (target_type == TypeManager.void_ptr_type && expr_type.IsPointer)
return true;
if (expr_type == TypeManager.anonymous_method_type){
if (!TypeManager.IsDelegateType (target_type))
return false;
AnonymousMethod am = (AnonymousMethod) expr;
int errors = Report.Errors;
Expression conv = am.Compatible (ec, target_type, true);
if (conv != null)
return true;
}
return false;
}
@@ -761,7 +732,7 @@ namespace Mono.CSharp {
/// Finds "most encompassed type" according to the spec (13.4.2)
/// amongst the methods in the MethodGroupExpr
/// </summary>
static Type FindMostEncompassedType (EmitContext ec, ArrayList types)
static Type FindMostEncompassedType (ArrayList types)
{
Type best = null;
@@ -776,7 +747,7 @@ namespace Mono.CSharp {
continue;
}
if (ImplicitStandardConversionExists (ec, priv_fmet_param, best))
if (ImplicitStandardConversionExists (priv_fmet_param, best))
best = t;
}
@@ -794,7 +765,7 @@ namespace Mono.CSharp {
/// Finds "most encompassing type" according to the spec (13.4.2)
/// amongst the types in the given set
/// </summary>
static Type FindMostEncompassingType (EmitContext ec, ArrayList types)
static Type FindMostEncompassingType (ArrayList types)
{
Type best = null;
@@ -809,7 +780,7 @@ namespace Mono.CSharp {
continue;
}
if (ImplicitStandardConversionExists (ec, priv_fmee_ret, t))
if (ImplicitStandardConversionExists (priv_fmee_ret, t))
best = t;
}
@@ -826,8 +797,8 @@ namespace Mono.CSharp {
/// by making use of FindMostEncomp* methods. Applies the correct rules separately
/// for explicit and implicit conversion operators.
/// </summary>
static public Type FindMostSpecificSource (EmitContext ec, MethodGroupExpr me,
Expression source, bool apply_explicit_conv_rules,
static public Type FindMostSpecificSource (MethodGroupExpr me, Expression source,
bool apply_explicit_conv_rules,
Location loc)
{
ArrayList src_types_set = new ArrayList ();
@@ -856,17 +827,17 @@ namespace Mono.CSharp {
// or encompassed by S to a type encompassing or encompassed by T
//
priv_fms_expr.SetType (param_type);
if (ImplicitStandardConversionExists (ec, priv_fms_expr, source_type))
if (ImplicitStandardConversionExists (priv_fms_expr, source_type))
src_types_set.Add (param_type);
else {
if (ImplicitStandardConversionExists (ec, source, param_type))
if (ImplicitStandardConversionExists (source, param_type))
src_types_set.Add (param_type);
}
} else {
//
// Only if S is encompassed by param_type
//
if (ImplicitStandardConversionExists (ec, source, param_type))
if (ImplicitStandardConversionExists (source, param_type))
src_types_set.Add (param_type);
}
}
@@ -878,21 +849,21 @@ namespace Mono.CSharp {
ArrayList candidate_set = new ArrayList ();
foreach (Type param_type in src_types_set){
if (ImplicitStandardConversionExists (ec, source, param_type))
if (ImplicitStandardConversionExists (source, param_type))
candidate_set.Add (param_type);
}
if (candidate_set.Count != 0)
return FindMostEncompassedType (ec, candidate_set);
return FindMostEncompassedType (candidate_set);
}
//
// Final case
//
if (apply_explicit_conv_rules)
return FindMostEncompassingType (ec, src_types_set);
return FindMostEncompassingType (src_types_set);
else
return FindMostEncompassedType (ec, src_types_set);
return FindMostEncompassedType (src_types_set);
}
//
@@ -903,8 +874,8 @@ namespace Mono.CSharp {
/// <summary>
/// Finds the most specific target Tx according to section 13.4.4
/// </summary>
static public Type FindMostSpecificTarget (EmitContext ec, MethodGroupExpr me,
Type target, bool apply_explicit_conv_rules,
static public Type FindMostSpecificTarget (MethodGroupExpr me, Type target,
bool apply_explicit_conv_rules,
Location loc)
{
ArrayList tgt_types_set = new ArrayList ();
@@ -932,11 +903,11 @@ namespace Mono.CSharp {
// or encompassed by S to a type encompassing or encompassed by T
//
priv_fms_expr.SetType (ret_type);
if (ImplicitStandardConversionExists (ec, priv_fms_expr, target))
if (ImplicitStandardConversionExists (priv_fms_expr, target))
tgt_types_set.Add (ret_type);
else {
priv_fms_expr.SetType (target);
if (ImplicitStandardConversionExists (ec, priv_fms_expr, ret_type))
if (ImplicitStandardConversionExists (priv_fms_expr, ret_type))
tgt_types_set.Add (ret_type);
}
} else {
@@ -944,7 +915,7 @@ namespace Mono.CSharp {
// Only if T is encompassed by param_type
//
priv_fms_expr.SetType (ret_type);
if (ImplicitStandardConversionExists (ec, priv_fms_expr, target))
if (ImplicitStandardConversionExists (priv_fms_expr, target))
tgt_types_set.Add (ret_type);
}
}
@@ -958,21 +929,21 @@ namespace Mono.CSharp {
foreach (Type ret_type in tgt_types_set){
priv_fmt_expr.SetType (ret_type);
if (ImplicitStandardConversionExists (ec, priv_fmt_expr, target))
if (ImplicitStandardConversionExists (priv_fmt_expr, target))
candidate_set.Add (ret_type);
}
if (candidate_set.Count != 0)
return FindMostEncompassingType (ec, candidate_set);
return FindMostEncompassingType (candidate_set);
}
//
// Okay, final case !
//
if (apply_explicit_conv_rules)
return FindMostEncompassedType (ec, tgt_types_set);
return FindMostEncompassedType (tgt_types_set);
else
return FindMostEncompassingType (ec, tgt_types_set);
return FindMostEncompassingType (tgt_types_set);
}
/// <summary>
@@ -1086,11 +1057,11 @@ namespace Mono.CSharp {
Type most_specific_source, most_specific_target;
most_specific_source = FindMostSpecificSource (ec, union, source, look_for_explicit, loc);
most_specific_source = FindMostSpecificSource (union, source, look_for_explicit, loc);
if (most_specific_source == null)
return null;
most_specific_target = FindMostSpecificTarget (ec, union, target, look_for_explicit, loc);
most_specific_target = FindMostSpecificTarget (union, target, look_for_explicit, loc);
if (most_specific_target == null)
return null;
@@ -1184,17 +1155,14 @@ namespace Mono.CSharp {
if (expr.eclass == ExprClass.MethodGroup){
if (!TypeManager.IsDelegateType (target_type)){
Report.Error (428, loc,
String.Format (
"Cannot convert method group to `{0}', since it is not a delegate",
TypeManager.CSharpName (target_type)));
return null;
}
//
// Only allow anonymous method conversions on post ISO_1
//
if (RootContext.Version != LanguageVersion.ISO_1){
MethodGroupExpr mg = expr as MethodGroupExpr;
if (mg != null)
return ImplicitDelegateCreation.Create (ec, mg, target_type, loc);
}
return ImplicitDelegateCreation.Create (ec, (MethodGroupExpr) expr, target_type, loc);
}
if (expr_type.Equals (target_type) && !(expr is NullLiteral))
@@ -1204,7 +1172,7 @@ namespace Mono.CSharp {
if (e != null)
return e;
e = ImplicitReferenceConversion (ec, expr, target_type);
e = ImplicitReferenceConversion (expr, target_type);
if (e != null)
return e;
@@ -1241,30 +1209,6 @@ namespace Mono.CSharp {
}
}
if (expr_type == TypeManager.anonymous_method_type){
if (!TypeManager.IsDelegateType (target_type)){
Report.Error (1660, loc,
"Cannot convert anonymous method to `{0}', since it is not a delegate",
TypeManager.CSharpName (target_type));
return null;
}
AnonymousMethod am = (AnonymousMethod) expr;
int errors = Report.Errors;
Expression conv = am.Compatible (ec, target_type, false);
if (conv != null)
return conv;
//
// We return something instead of null, to avoid
// the duplicate error, since am.Compatible would have
// reported that already
//
if (errors != Report.Errors)
return new EmptyCast (expr, target_type);
}
return null;
}
@@ -1325,10 +1269,11 @@ namespace Mono.CSharp {
static public void Error_CannotImplicitConversion (Location loc, Type source, Type target)
{
Report.Error (29, loc, "Cannot convert implicitly from {0} to `{1}'",
source == TypeManager.anonymous_method_type ?
"anonymous method" : "`" + TypeManager.CSharpName (source) + "'",
TypeManager.CSharpName (target));
string msg = "Cannot convert implicitly from `"+
TypeManager.CSharpName (source) + "' to `" +
TypeManager.CSharpName (target) + "'";
Report.Error (29, loc, msg);
}
/// <summary>
@@ -1383,7 +1328,7 @@ namespace Mono.CSharp {
if (TypeManager.IsEnumType (real_target_type))
real_target_type = TypeManager.EnumToUnderlying (real_target_type);
if (ImplicitStandardConversionExists (ec, expr, real_target_type)){
if (ImplicitStandardConversionExists (expr, real_target_type)){
Expression ce = ImplicitConversionStandard (ec, expr, real_target_type, loc);
if (real_target_type != target_type)
+36 -77
View File
@@ -40,7 +40,13 @@ namespace Mono.CSharp
/// Current block is used to add statements as we find
/// them.
/// </summary>
Block current_block, top_current_block;
Block current_block;
/// <summary>
/// If true, creates a toplevel block in the block production
/// This is flagged by the delegate creation
/// </summary>
bool create_toplevel_block;
Delegate current_delegate;
@@ -687,11 +693,6 @@ named_argument_list
$$ = args;
}
| named_argument_list COMMA expression
{
Report.Error (1016, lexer.Location, "Named attribute argument expected");
$$ = null;
}
;
named_argument
@@ -940,11 +941,6 @@ variable_initializer
{
$$ = new StackAlloc ((Expression) $2, (Expression) $4, lexer.Location);
}
| STACKALLOC type
{
Report.Error (1575, lexer.Location, "A stackalloc expression requires [] after type");
$$ = null;
}
;
method_declaration
@@ -971,7 +967,7 @@ method_declaration
}
}
method.Block = (ToplevelBlock) $3;
method.Block = (Block) $3;
current_container.AddMethod (method);
current_local_parameters = null;
@@ -1158,13 +1154,6 @@ fixed_parameter
{
$$ = new Parameter ((Expression) $3, (string) $4, (Parameter.Modifier) $2, (Attributes) $1);
}
| opt_attributes
opt_parameter_modifier
type
{
Report.Error (1001, lexer.Location, "Identifier expected");
$$ = null;
}
| opt_attributes
opt_parameter_modifier
type
@@ -1200,11 +1189,6 @@ parameter_array
$$ = new Parameter ((Expression) $3, (string) $4, Parameter.Modifier.PARAMS, (Attributes) $1);
note ("type must be a single-dimension array type");
}
| opt_attributes PARAMS parameter_modifier type IDENTIFIER
{
Report.Error (1611, lexer.Location, "The params parameter cannot be declared as ref or out");
$$ = null;
}
| opt_attributes PARAMS type error {
CheckIdentifierToken (yyToken);
$$ = null;
@@ -1275,7 +1259,7 @@ opt_set_accessor_declaration
;
get_accessor_declaration
: opt_attributes opt_modifiers GET
: opt_attributes GET
{
// If this is not the case, then current_local_parameters has already
// been set in indexer_declaration
@@ -1287,14 +1271,14 @@ get_accessor_declaration
}
accessor_body
{
$$ = new Accessor ((ToplevelBlock) $5, (int) $2, (Attributes) $1, lexer.Location);
$$ = new Accessor ((Block) $4, (Attributes) $1, lexer.Location);
current_local_parameters = null;
lexer.PropertyParsing = true;
}
;
set_accessor_declaration
: opt_attributes opt_modifiers SET
: opt_attributes SET
{
Parameter [] args;
Parameter implicit_value_parameter = new Parameter (
@@ -1324,7 +1308,7 @@ set_accessor_declaration
}
accessor_body
{
$$ = new Accessor ((ToplevelBlock) $5, (int) $2, (Attributes) $1, lexer.Location);
$$ = new Accessor ((Block) $4, (Attributes) $1, lexer.Location);
current_local_parameters = null;
lexer.PropertyParsing = true;
}
@@ -1586,7 +1570,7 @@ operator_declaration
Operator op = new Operator (
current_class, decl.optype, decl.ret_type, (int) $2,
new Parameters (param_list, null, decl.location),
(ToplevelBlock) $5, (Attributes) $1, decl.location);
(Block) $5, (Attributes) $1, decl.location);
if (SimpleIteratorContainer.Simple.Yields)
op.SetYields ();
@@ -1715,7 +1699,7 @@ constructor_declaration
constructor_body
{
Constructor c = (Constructor) $3;
c.Block = (ToplevelBlock) $4;
c.Block = (Block) $4;
c.OptAttributes = (Attributes) $1;
c.ModFlags = (int) $2;
@@ -1830,7 +1814,7 @@ destructor_declaration
current_class, TypeManager.system_void_expr, m, "Finalize",
new Parameters (null, null, l), (Attributes) $1, l);
d.Block = (ToplevelBlock) $7;
d.Block = (Block) $7;
current_container.AddMethod (d);
}
}
@@ -1912,12 +1896,6 @@ event_accessor_declarations
}
| add_accessor_declaration { $$ = null; }
| remove_accessor_declaration { $$ = null; }
| error
{
Report.Error (1055, lexer.Location, "An add or remove accessor expected");
$$ = null;
}
| { $$ = null; }
;
add_accessor_declaration
@@ -1935,7 +1913,7 @@ add_accessor_declaration
}
block
{
$$ = new Accessor ((ToplevelBlock) $4, 0, (Attributes) $1, lexer.Location);
$$ = new Accessor ((Block) $4, (Attributes) $1, lexer.Location);
lexer.EventParsing = true;
}
| opt_attributes ADD error {
@@ -1959,7 +1937,7 @@ remove_accessor_declaration
}
block
{
$$ = new Accessor ((ToplevelBlock) $4, 0, (Attributes) $1, lexer.Location);
$$ = new Accessor ((Block) $4, (Attributes) $1, lexer.Location);
lexer.EventParsing = true;
}
| opt_attributes REMOVE error {
@@ -2588,7 +2566,7 @@ base_access
$$ = new BaseIndexerAccess ((ArrayList) $3, lexer.Location);
}
| BASE error {
Report.Error (175, lexer.Location, "Use of keyword `base' is not valid in this context");
Report.Error (175, "Use of keyword `base' is not valid in this context");
$$ = null;
}
;
@@ -2632,11 +2610,6 @@ array_creation_expression
{
$$ = new ArrayCreation ((Expression) $2, (string) $3, (ArrayList) $4, lexer.Location);
}
| NEW error
{
Report.Error (1031, lexer.Location, "Type expected");
$$ = null;
}
| NEW type error
{
Report.Error (1526, lexer.Location, "new expression requires () or [] after type");
@@ -2778,32 +2751,25 @@ anonymous_method_expression
: DELEGATE opt_anonymous_method_signature {
oob_stack.Push (current_local_parameters);
current_local_parameters = (Parameters)$2;
// Force the next block to be created as a ToplevelBlock
oob_stack.Push (current_block);
oob_stack.Push (top_current_block);
oob_stack.Push (lexer.Location);
current_block = null;
create_toplevel_block = true;
} block {
Location loc = (Location) oob_stack.Pop ();
top_current_block = (Block) oob_stack.Pop ();
current_block = (Block) oob_stack.Pop ();
if (true){
Report.Error (-213, lexer.Location, "Anonymous methods are not supported in this branch");
$$ = null;
} else {
create_toplevel_block = false;
if (RootContext.Version == LanguageVersion.ISO_1){
Report.FeatureIsNotStandardized (lexer.Location, "anonymous methods");
$$ = null;
} else {
ToplevelBlock anon_block = (ToplevelBlock) $4;
anon_block.Parent = current_block;
$$ = new AnonymousMethod ((Parameters) $2, (ToplevelBlock) top_current_block,
anon_block, loc);
} else
$$ = new AnonymousMethod ((Parameters) $2, (Block) $4, lexer.Location);
current_local_parameters = (Parameters) oob_stack.Pop ();
}
current_local_parameters = (Parameters) oob_stack.Pop ();
}
;
opt_anonymous_method_signature
: /* empty */ { $$ = null; }
: /* empty */ { $$ = Parameters.EmptyReadOnlyParameters; }
| anonymous_method_signature
;
@@ -2843,11 +2809,7 @@ anonymous_method_parameter_list
anonymous_method_parameter
: opt_parameter_modifier type IDENTIFIER {
$$ = new Parameter ((Expression) $2, (string) $3, (Parameter.Modifier) $1, null);
}
| PARAMS type IDENTIFIER {
Report.Error (-221, lexer.Location, "params modifier not allowed in anonymous method declaration");
$$ = null;
$$ = new Parameter ((Expression) $2, (string) $2, (Parameter.Modifier) $1, null);
}
;
@@ -3363,9 +3325,8 @@ type_parameter_constraint
block
: OPEN_BRACE
{
if (current_block == null){
current_block = new ToplevelBlock ((ToplevelBlock) top_current_block, current_local_parameters, lexer.Location);
top_current_block = current_block;
if (current_block == null || create_toplevel_block){
current_block = new ToplevelBlock (current_local_parameters, lexer.Location);
} else {
current_block = new Block (current_block, current_local_parameters,
lexer.Location, Location.Null);
@@ -3378,8 +3339,6 @@ block
$$ = current_block;
current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent;
if (current_block == null)
top_current_block = null;
}
;
@@ -4057,7 +4016,7 @@ try_statement
// Now s contains the list of specific catch clauses
// and g contains the general one.
$$ = new Try ((Block) $2, c, g, null, ((Block) $2).loc);
$$ = new Try ((Block) $2, c, g, null, lexer.Location);
}
| TRY block opt_catch_clauses FINALLY block
{
@@ -4074,7 +4033,7 @@ try_statement
}
}
$$ = new Try ((Block) $2, s, g, (Block) $5, ((Block) $2).loc);
$$ = new Try ((Block) $2, s, g, (Block) $5, lexer.Location);
}
| TRY block error
{
@@ -4151,7 +4110,7 @@ catch_clause
}
$$ = new Catch (type, id , (Block) $4, ((Block) $4).loc);
$$ = new Catch (type, id , (Block) $4, lexer.Location);
}
;
@@ -4385,9 +4344,9 @@ public class InterfaceAccessorInfo {
Attributes get_attrs, Attributes set_attrs, Location get_loc, Location set_loc)
{
if (has_get)
Get = new Accessor (null, 0, get_attrs, get_loc);
Get = new Accessor (null, get_attrs, get_loc);
if (has_set)
Set = new Accessor (null, 0, set_attrs, set_loc);
Set = new Accessor (null, set_attrs, set_loc);
}
}
+2 -2
View File
@@ -2195,9 +2195,9 @@ namespace Mono.CSharp
if (ifstack != null && ifstack.Count >= 1) {
int state = (int) ifstack.Pop ();
if ((state & REGION) != 0)
Report.Error (1038, Location, "#endregion directive expected");
Report.Error (1038, "#endregion directive expected");
else
Report.Error (1027, Location, "#endif directive expected");
Report.Error (1027, "#endif directive expected");
}
}
+126 -91
View File
@@ -90,16 +90,12 @@ namespace Mono.CSharp {
public string GetMethodName ()
{
if (Left != null)
return Left.GetPartialName () + "." + Name;
return Left.GetFullName () + "." + Name;
else
return Name;
}
///
/// This returns exclusively the name as seen on the source code
/// it is not the fully qualifed type after resolution
///
public string GetPartialName ()
public string GetFullName ()
{
string full_name;
if (TypeArguments != null)
@@ -107,7 +103,7 @@ namespace Mono.CSharp {
else
full_name = Name;
if (Left != null)
return Left.GetPartialName () + "." + full_name;
return Left.GetFullName () + "." + full_name;
else
return full_name;
}
@@ -198,9 +194,6 @@ namespace Mono.CSharp {
public override string ToString ()
{
throw new Exception ("This exception is thrown because someone is miss-using\n" +
"MemberName.ToString in the compiler. Please report this bug");
string full_name;
if (TypeArguments != null)
full_name = Name + "<" + TypeArguments + ">";
@@ -318,12 +311,6 @@ namespace Mono.CSharp {
VerifyClsCompliance (Parent);
}
public bool InUnsafe {
get {
return ((ModFlags & Modifiers.UNSAFE) != 0) || Parent.UnsafeContext;
}
}
//
// Whehter is it ok to use an unsafe pointer in this type container
//
@@ -357,8 +344,11 @@ namespace Mono.CSharp {
if (OptAttributes == null)
return null;
Attribute obsolete_attr = OptAttributes.Search (
TypeManager.obsolete_attribute_type, ds.EmitContext);
// TODO: remove this allocation
EmitContext ec = new EmitContext (ds.Parent, ds, ds.Location,
null, null, ds.ModFlags, false);
Attribute obsolete_attr = OptAttributes.Search (TypeManager.obsolete_attribute_type, ec);
if (obsolete_attr == null)
return null;
@@ -411,7 +401,9 @@ namespace Mono.CSharp {
bool GetClsCompliantAttributeValue (DeclSpace ds)
{
if (OptAttributes != null) {
Attribute cls_attribute = OptAttributes.GetClsCompliantAttribute (ds.EmitContext);
EmitContext ec = new EmitContext (ds.Parent, ds, ds.Location,
null, null, ds.ModFlags, false);
Attribute cls_attribute = OptAttributes.GetClsCompliantAttribute (ec);
if (cls_attribute != null) {
caching_flags |= Flags.HasClsCompliantAttribute;
return cls_attribute.GetClsCompliantAttributeValue (ds);
@@ -499,13 +491,6 @@ namespace Mono.CSharp {
readonly bool is_generic;
readonly int count_type_params;
// The emit context for toplevel objects.
protected EmitContext ec;
public EmitContext EmitContext {
get { return ec; }
}
//
// Whether we are Generic
//
@@ -542,7 +527,7 @@ namespace Mono.CSharp {
/// </summary>
protected bool AddToContainer (MemberCore symbol, bool is_method, string fullname, string basename)
{
if (basename == Basename && !(this is Interface)) {
if (basename == Basename) {
Report.SymbolRelatedToPreviousError (this);
Report.Error (542, "'{0}': member names cannot be the same as their enclosing type", symbol.Location, symbol.GetSignatureForError ());
return false;
@@ -686,17 +671,31 @@ namespace Mono.CSharp {
}
// <summary>
// Looks up the type, as parsed into the expression `e'.
// Looks up the type, as parsed into the expression `e'
// </summary>
[Obsolete ("This method is going away soon")]
public Type ResolveType (Expression e, bool silent, Location loc)
{
TypeExpr d = ResolveTypeExpr (e, silent, loc);
return d == null ? null : d.Type;
if (d == null)
return null;
return ResolveType (d, loc);
}
public Type ResolveNestedType (Type t, Location loc)
public Type ResolveType (TypeExpr d, Location loc)
{
if (!d.CheckAccessLevel (this)) {
Report.Error (122, loc, "'{0}' is inaccessible due to its protection level", d.Name);
return null;
}
Type t = d.ResolveType (type_resolve_ec);
if (t == null)
return null;
if (d is UnboundTypeExpression)
return t;
TypeContainer tc = TypeManager.LookupTypeContainer (t);
if ((tc != null) && tc.IsGeneric) {
if (!IsGeneric) {
@@ -708,14 +707,10 @@ namespace Mono.CSharp {
return null;
}
TypeParameter[] args;
if (this is GenericMethod)
args = Parent.TypeParameters;
else
args = TypeParameters;
ConstructedType ctype = new ConstructedType (
t, TypeParameters, loc);
ConstructedType ctype = new ConstructedType (t, args, loc);
t = ctype.ResolveType (ec);
t = ctype.ResolveType (type_resolve_ec);
}
return t;
@@ -723,7 +718,7 @@ namespace Mono.CSharp {
// <summary>
// Resolves the expression `e' for a type, and will recursively define
// types. This should only be used for resolving base types.
// types.
// </summary>
public TypeExpr ResolveTypeExpr (Expression e, bool silent, Location loc)
{
@@ -735,13 +730,50 @@ namespace Mono.CSharp {
else
type_resolve_ec.ContainerType = TypeBuilder;
return e.ResolveAsTypeTerminal (type_resolve_ec, silent);
int errors = Report.Errors;
TypeExpr d = e.ResolveAsTypeTerminal (type_resolve_ec);
if ((d != null) && (d.eclass == ExprClass.Type))
return d;
if (silent || (Report.Errors != errors))
return null;
if (e is SimpleName){
SimpleName s = new SimpleName (((SimpleName) e).Name, loc);
d = s.ResolveAsTypeTerminal (type_resolve_ec);
if ((d == null) || (d.Type == null)) {
Report.Error (246, loc, "Cannot find type `{0}'", e);
return null;
}
int num_args = TypeManager.GetNumberOfTypeArguments (d.Type);
if (num_args == 0) {
Report.Error (308, loc,
"The non-generic type `{0}' cannot " +
"be used with type arguments.",
TypeManager.CSharpName (d.Type));
return null;
}
Report.Error (305, loc,
"Using the generic type `{0}' " +
"requires {1} type arguments",
TypeManager.GetFullName (d.Type), num_args);
return null;
}
Report.Error (246, loc, "Cannot find type `{0}'", e);
return null;
}
public bool CheckAccessLevel (Type check_type)
{
TypeBuilder tb;
if ((this is GenericMethod) || (this is Iterator))
if (this is GenericMethod)
tb = Parent.TypeBuilder;
else
tb = TypeBuilder;
@@ -756,7 +788,7 @@ namespace Mono.CSharp {
return true; // FIXME
TypeAttributes check_attr = check_type.Attributes & TypeAttributes.VisibilityMask;
//
// Broken Microsoft runtime, return public for arrays, no matter what
// the accessibility is for their underlying class, and they return
@@ -771,21 +803,37 @@ namespace Mono.CSharp {
case TypeAttributes.NotPublic:
if (TypeBuilder == null)
// FIXME: TypeBuilder will be null when invoked by Class.GetNormalBases().
// However, this is invoked again later -- so safe to return true.
// May also be null when resolving top-level attributes.
return true;
//
// This test should probably use the declaringtype.
//
// In same cases is null.
if (TypeBuilder == null)
return true;
//
// This test should probably use the declaringtype.
//
return check_type.Assembly == TypeBuilder.Assembly;
case TypeAttributes.NestedPublic:
return true;
case TypeAttributes.NestedPrivate:
return NestedAccessible (tb, check_type);
string check_type_name = check_type.FullName;
string type_name = tb.FullName;
int cio = check_type_name.LastIndexOf ('+');
string container = check_type_name.Substring (0, cio);
//
// Check if the check_type is a nested class of the current type
//
if (check_type_name.StartsWith (type_name + "+")){
return true;
}
if (type_name.StartsWith (container)){
return true;
}
return false;
case TypeAttributes.NestedFamily:
//
@@ -810,31 +858,24 @@ namespace Mono.CSharp {
}
protected bool NestedAccessible (Type tb, Type check_type)
{
string check_type_name = check_type.FullName;
// At this point, we already know check_type is a nested class.
int cio = check_type_name.LastIndexOf ('+');
// Ensure that the string 'container' has a '+' in it to avoid false matches
string container = check_type_name.Substring (0, cio + 1);
// Ensure that type_name ends with a '+' so that it can match 'container', if necessary
string type_name = tb.FullName + "+";
// If the current class is nested inside the container of check_type,
// we can access check_type even if it is private or protected.
return type_name.StartsWith (container);
}
protected bool FamilyAccessible (Type tb, Type check_type)
protected bool FamilyAccessible (TypeBuilder tb, Type check_type)
{
Type declaring = check_type.DeclaringType;
if (tb == declaring || TypeManager.IsFamilyAccessible (tb, declaring))
if (tb.IsSubclassOf (declaring))
return true;
return NestedAccessible (tb, check_type);
string check_type_name = check_type.FullName;
int cio = check_type_name.LastIndexOf ('+');
string container = check_type_name.Substring (0, cio);
//
// Check if the check_type is a nested class of the current type
//
if (check_type_name.StartsWith (container + "+"))
return true;
return false;
}
// Access level of a type.
@@ -1072,7 +1113,7 @@ namespace Mono.CSharp {
return null;
if ((t != null) && containing_ds.CheckAccessLevel (t))
return ResolveNestedType (t, loc);
return t;
current_type = current_type.BaseType;
}
@@ -1200,6 +1241,8 @@ namespace Mono.CSharp {
caching_flags &= ~Flags.HasCompliantAttribute_Undetected;
if (OptAttributes != null) {
EmitContext ec = new EmitContext (Parent, this, Location,
null, null, ModFlags, false);
Attribute cls_attribute = OptAttributes.GetClsCompliantAttribute (ec);
if (cls_attribute != null) {
caching_flags |= Flags.HasClsCompliantAttribute;
@@ -1640,7 +1683,7 @@ namespace Mono.CSharp {
/// <summary>
/// Create a new MemberCache for the given IMemberContainer `container'.
/// </summary>
public MemberCache (IMemberContainer container, bool setup_inherited_interfaces)
public MemberCache (IMemberContainer container)
{
this.Container = container;
@@ -1657,8 +1700,8 @@ namespace Mono.CSharp {
if (Container.ParentContainer != null)
parent = Container.ParentContainer.MemberCache;
else
parent = null;
member_hash = SetupCacheForInterface (parent, setup_inherited_interfaces);
parent = TypeHandle.ObjectType.MemberCache;
member_hash = SetupCacheForInterface (parent);
} else if (Container.ParentContainer != null)
member_hash = SetupCache (Container.ParentContainer.MemberCache);
else
@@ -1684,13 +1727,11 @@ namespace Mono.CSharp {
Hashtable SetupCache (MemberCache parent)
{
Hashtable hash = new Hashtable ();
if (parent == null)
return hash;
IDictionaryEnumerator it = parent.member_hash.GetEnumerator ();
while (it.MoveNext ()) {
hash [it.Key] = ((ArrayList) it.Value).Clone ();
}
}
return hash;
}
@@ -1721,13 +1762,9 @@ namespace Mono.CSharp {
/// Type.GetMembers() won't return any inherited members for interface types,
/// so we need to do this manually. Interfaces also inherit from System.Object.
/// </summary>
Hashtable SetupCacheForInterface (MemberCache parent, bool deep_setup)
Hashtable SetupCacheForInterface (MemberCache parent)
{
Hashtable hash = SetupCache (parent);
if (!deep_setup)
return hash;
Type [] ifaces = TypeManager.GetInterfaces (Container.Type);
foreach (Type itype in ifaces) {
@@ -1749,10 +1786,8 @@ namespace Mono.CSharp {
{
// We need to call AddMembers() with a single member type at a time
// to get the member type part of CacheEntry.EntryType right.
if (!container.IsInterface) {
AddMembers (MemberTypes.Constructor, container);
AddMembers (MemberTypes.Field, container);
}
AddMembers (MemberTypes.Constructor, container);
AddMembers (MemberTypes.Field, container);
AddMembers (MemberTypes.Method, container);
AddMembers (MemberTypes.Property, container);
AddMembers (MemberTypes.Event, container);
@@ -1904,7 +1939,7 @@ namespace Mono.CSharp {
/// number to speed up the searching process.
/// </summary>
[Flags]
protected internal enum EntryType {
protected enum EntryType {
None = 0x000,
Instance = 0x001,
@@ -1927,7 +1962,7 @@ namespace Mono.CSharp {
MaskType = Constructor|Event|Field|Method|Property|NestedType
}
protected internal struct CacheEntry {
protected struct CacheEntry {
public readonly IMemberContainer Container;
public readonly EntryType EntryType;
public readonly MemberInfo Member;
@@ -2252,7 +2287,7 @@ namespace Mono.CSharp {
// Does exist easier way how to detect indexer ?
if ((entry.EntryType & EntryType.Property) != 0) {
Type[] arg_types = TypeManager.GetArgumentTypes ((PropertyInfo)entry.Member);
if (arg_types.Length > 0)
if (arg_types.Length == 1)
continue;
}
}
+26 -38
View File
@@ -142,7 +142,8 @@ namespace Mono.CSharp {
{
MethodAttributes mattr;
int i;
ec = new EmitContext (this, this, Location, null, null, ModFlags, false);
EmitContext ec = new EmitContext (this, this, Location, null,
null, ModFlags, false);
if (IsGeneric) {
foreach (TypeParameter type_param in TypeParameters)
@@ -170,10 +171,8 @@ namespace Mono.CSharp {
//
// FIXME: POSSIBLY make these static, as they are always the same
Parameter [] fixed_pars = new Parameter [2];
fixed_pars [0] = new Parameter (TypeManager.system_object_expr, "object",
Parameter.Modifier.NONE, null);
fixed_pars [1] = new Parameter (TypeManager.system_intptr_expr, "method",
Parameter.Modifier.NONE, null);
fixed_pars [0] = new Parameter (null, null, Parameter.Modifier.NONE, null);
fixed_pars [1] = new Parameter (null, null, Parameter.Modifier.NONE, null);
Parameters const_parameters = new Parameters (fixed_pars, null, Location);
TypeManager.RegisterMethod (
@@ -190,10 +189,10 @@ namespace Mono.CSharp {
// First, call the `out of band' special method for
// defining recursively any types we need:
if (!Parameters.ComputeAndDefineParameterTypes (ec))
if (!Parameters.ComputeAndDefineParameterTypes (this))
return false;
param_types = Parameters.GetParameterInfo (ec);
param_types = Parameters.GetParameterInfo (this);
if (param_types == null)
return false;
@@ -214,7 +213,7 @@ namespace Mono.CSharp {
return false;
}
ReturnType = ReturnType.ResolveAsTypeTerminal (ec, false);
ReturnType = ResolveTypeExpr (ReturnType, false, Location);
if (ReturnType == null)
return false;
@@ -273,7 +272,7 @@ namespace Mono.CSharp {
InvokeBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
TypeManager.RegisterMethod (InvokeBuilder,
new InternalParameters (param_types, Parameters),
new InternalParameters (Parent, Parameters),
param_types);
//
@@ -336,10 +335,11 @@ namespace Mono.CSharp {
Parameter.Modifier.NONE, null);
Parameters async_parameters = new Parameters (async_params, null, Location);
async_parameters.ComputeAndDefineParameterTypes (ec);
async_parameters.ComputeAndDefineParameterTypes (this);
async_parameters.ComputeAndDefineParameterTypes (this);
TypeManager.RegisterMethod (BeginInvokeBuilder,
new InternalParameters (async_param_types, async_parameters),
new InternalParameters (Parent, async_parameters),
async_param_types);
//
@@ -380,11 +380,11 @@ namespace Mono.CSharp {
}
Parameters end_parameters = new Parameters (end_params, null, Location);
end_parameters.ComputeAndDefineParameterTypes (ec);
end_parameters.ComputeAndDefineParameterTypes (this);
TypeManager.RegisterMethod (
EndInvokeBuilder,
new InternalParameters (end_param_types, end_parameters),
new InternalParameters (Parent, end_parameters),
end_param_types);
return true;
@@ -393,6 +393,8 @@ namespace Mono.CSharp {
public override void Emit ()
{
if (OptAttributes != null) {
EmitContext ec = new EmitContext (
Parent, this, Location, null, null, ModFlags, false);
Parameters.LabelParameters (ec, InvokeBuilder, Location);
OptAttributes.Emit (ec, this);
}
@@ -421,25 +423,6 @@ namespace Mono.CSharp {
return true;
}
//
// Returns the MethodBase for "Invoke" from a delegate type, this is used
// to extract the signature of a delegate.
//
public static MethodGroupExpr GetInvokeMethod (EmitContext ec, Type delegate_type,
Location loc)
{
Expression ml = Expression.MemberLookup (
ec, delegate_type, "Invoke", loc);
MethodGroupExpr mg = ml as MethodGroupExpr;
if (mg == null) {
Report.Error (-100, loc, "Internal error: could not find Invoke method!");
return null;
}
return mg;
}
/// <summary>
/// Verifies whether the method in question is compatible with the delegate
/// Returns the method itself if okay and null if not.
@@ -447,14 +430,19 @@ namespace Mono.CSharp {
public static MethodBase VerifyMethod (EmitContext ec, Type delegate_type, MethodBase mb,
Location loc)
{
MethodGroupExpr mg = GetInvokeMethod (ec, delegate_type, loc);
if (mg == null)
Expression ml = Expression.MemberLookup (
ec, delegate_type, "Invoke", loc);
if (!(ml is MethodGroupExpr)) {
Report.Error (-100, loc, "Internal error: could not find Invoke method!");
return null;
}
MethodBase invoke_mb = ((MethodGroupExpr) ml).Methods [0];
MethodBase invoke_mb = mg.Methods [0];
ParameterData invoke_pd = Invocation.GetParameterData (invoke_mb);
if (!mg.HasTypeArguments &&
if (!((MethodGroupExpr) ml).HasTypeArguments &&
!Invocation.InferTypeArguments (ec, invoke_pd, ref mb))
return null;
@@ -513,8 +501,8 @@ namespace Mono.CSharp {
if (!params_method && pd_count != arg_count) {
Report.Error (1593, loc,
"Delegate '{0}' does not take {1} arguments",
delegate_type.ToString (), arg_count);
"Delegate '" + delegate_type.ToString ()
+ "' does not take '" + arg_count + "' arguments");
return false;
}
+1 -1
View File
@@ -1675,7 +1675,7 @@ namespace Mono.CSharp
margs [1] = spec.Substring (0, cp);
} else {
margs [1] = spec;
margs [0] = Path.GetFileName (spec);
margs [0] = spec.Replace ('/','.').Replace ('\\', '.');
}
if (File.Exists ((string) margs [1]))
+39 -54
View File
@@ -272,24 +272,9 @@ namespace Mono.CSharp {
// value will be returned if the expression is not a type
// reference
//
public TypeExpr ResolveAsTypeTerminal (EmitContext ec, bool silent)
public TypeExpr ResolveAsTypeTerminal (EmitContext ec)
{
int errors = Report.Errors;
TypeExpr te = ResolveAsTypeStep (ec) as TypeExpr;
if (te == null || te.eclass != ExprClass.Type) {
if (!silent && errors == Report.Errors)
Report.Error (246, Location, "Cannot find type '{0}'", ToString ());
return null;
}
if (!te.CheckAccessLevel (ec.DeclSpace)) {
Report.Error (122, Location, "'{0}' is inaccessible due to its protection level", te.Name);
return null;
}
return te;
return ResolveAsTypeStep (ec) as TypeExpr;
}
/// <summary>
@@ -511,9 +496,7 @@ namespace Mono.CSharp {
Constant e = Constantify (v, real_type);
return new EnumConstant (e, t);
} else if (v == null && !TypeManager.IsValueType (t))
return NullLiteral.Null;
else
} else
throw new Exception ("Unknown type for constant (" + t +
"), details: " + v);
}
@@ -926,7 +909,7 @@ namespace Mono.CSharp {
/// </summary>
public static object ConvertIntLiteral (Constant c, Type target_type, Location loc)
{
if (!Convert.ImplicitStandardConversionExists (Convert.ConstantEC, c, target_type)){
if (!Convert.ImplicitStandardConversionExists (c, target_type)){
Convert.Error_CannotImplicitConversion (loc, c.Type, target_type);
return null;
}
@@ -2077,7 +2060,7 @@ namespace Mono.CSharp {
TypeParameterExpr generic_type = ds.LookupGeneric (Name, loc);
if (generic_type != null)
return generic_type.ResolveAsTypeTerminal (ec, false);
return generic_type.ResolveAsTypeTerminal (ec);
if (ec.ResolvingTypeTree){
int errors = Report.Errors;
@@ -2097,10 +2080,10 @@ namespace Mono.CSharp {
}
}
if ((t = RootContext.LookupType (ds, Name, true, loc)) != null)
return t;
if (alias_value != null) {
//
// First, the using aliases
//
if (alias_value != null){
if (alias_value.IsType)
return alias_value.Type;
if ((t = RootContext.LookupType (ds, alias_value.Name, true, loc)) != null)
@@ -2110,6 +2093,14 @@ namespace Mono.CSharp {
return new SimpleName (alias_value.Name, loc);
}
//
// Stage 2: Lookup up if we are an alias to a type
// or a namespace.
//
if ((t = RootContext.LookupType (ds, Name, true, loc)) != null)
return t;
// No match, maybe our parent can compose us
// into something meaningful.
return this;
@@ -2180,12 +2171,21 @@ namespace Mono.CSharp {
return var.Resolve (ec);
}
ParameterReference pref = current_block.GetParameterReference (Name, loc);
if (pref != null) {
int idx = -1;
Parameter par = null;
Parameters pars = current_block.Parameters;
if (pars != null)
par = pars.GetParameterByName (Name, out idx);
if (par != null) {
ParameterReference param;
param = new ParameterReference (pars, current_block, idx, Name, loc);
if (right_side != null)
return pref.ResolveLValue (ec, right_side);
return param.ResolveLValue (ec, right_side);
else
return pref.Resolve (ec);
return param.Resolve (ec);
}
}
@@ -2322,7 +2322,7 @@ namespace Mono.CSharp {
override public Expression DoResolve (EmitContext ec)
{
return ResolveAsTypeTerminal (ec, false);
return ResolveAsTypeTerminal (ec);
}
override public void Emit (EmitContext ec)
@@ -2379,7 +2379,7 @@ namespace Mono.CSharp {
public virtual Type ResolveType (EmitContext ec)
{
TypeExpr t = ResolveAsTypeTerminal (ec, false);
TypeExpr t = ResolveAsTypeTerminal (ec);
if (t == null)
return null;
@@ -2532,7 +2532,7 @@ namespace Mono.CSharp {
}
ConstructedType ctype = new ConstructedType (type, args, loc);
return ctype.ResolveAsTypeTerminal (ec, false);
return ctype.ResolveAsTypeTerminal (ec);
} else if (num_args > 0) {
Report.Error (305, loc,
"Using the generic type `{0}' " +
@@ -2546,7 +2546,7 @@ namespace Mono.CSharp {
public override Type ResolveType (EmitContext ec)
{
TypeExpr t = ResolveAsTypeTerminal (ec, false);
TypeExpr t = ResolveAsTypeTerminal (ec);
if (t == null)
return null;
@@ -2932,16 +2932,6 @@ namespace Mono.CSharp {
AttributeTester.Report_ObsoleteMessage (oa, TypeManager.GetFullNameSignature (FieldInfo), loc);
}
if (ec.CurrentAnonymousMethod != null){
if (!FieldInfo.IsStatic){
if (ec.TypeContainer is Struct){
Report.Error (1673, loc, "Can not reference instance variables in anonymous methods hosted in structs");
return null;
}
ec.CaptureField (this);
}
}
// If the instance expression is a local variable or parameter.
IVariable var = instance_expr as IVariable;
if ((var == null) || (var.VariableInfo == null))
@@ -3374,6 +3364,11 @@ namespace Mono.CSharp {
{
FindAccessors (ec.ContainerType);
if (setter != null && !IsAccessorAccessible (ec.ContainerType, setter) ||
getter != null && !IsAccessorAccessible (ec.ContainerType, getter)) {
Report.Error (122, loc, "'{0}' is inaccessible due to its protection level", PropertyInfo.Name);
}
is_static = getter != null ? getter.IsStatic : setter.IsStatic;
}
@@ -3436,11 +3431,6 @@ namespace Mono.CSharp {
return null;
}
if (!IsAccessorAccessible (ec.ContainerType, getter)) {
Report.Error (122, loc, "'{0}.get' is inaccessible due to its protection level", PropertyInfo.Name);
return null;
}
if (!InstanceResolve (ec))
return null;
@@ -3483,11 +3473,6 @@ namespace Mono.CSharp {
return null;
}
if (!IsAccessorAccessible (ec.ContainerType, setter)) {
Report.Error (122, loc, "'{0}.set' is inaccessible due to its protection level", PropertyInfo.Name);
return null;
}
if (!InstanceResolve (ec))
return null;
+8 -6
View File
@@ -36,15 +36,12 @@ namespace Mono.CSharp {
public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
{
if (a.Type == TypeManager.marshal_as_attr_type) {
UnmanagedMarshal marshal = a.GetMarshal (this);
UnmanagedMarshal marshal = a.GetMarshal ();
if (marshal != null) {
builder.SetMarshal (marshal);
}
return;
}
if (a.Type.IsSubclassOf (TypeManager.security_attr_type)) {
a.Error_InvalidSecurityParent ();
Report.Warning (-24, a.Location, "The Microsoft Runtime cannot set this marshal info. Please use the Mono runtime instead.");
return;
}
@@ -618,7 +615,9 @@ namespace Mono.CSharp {
if (TypeBuilder == null)
return false;
ec = new EmitContext (this, this, Location, null, UnderlyingType, ModFlags, false);
EmitContext ec = new EmitContext (this, this, Location, null,
UnderlyingType, ModFlags, false);
object default_value = 0;
@@ -677,6 +676,9 @@ namespace Mono.CSharp {
public override void Emit ()
{
EmitContext ec = new EmitContext (
Parent, this, Location, null, null, ModFlags, false);
if (OptAttributes != null) {
OptAttributes.Emit (ec, this);
}
+218 -355
View File
File diff suppressed because it is too large. Load diff
+19 -26
View File
@@ -372,8 +372,8 @@ namespace Mono.CSharp {
Type t2 = constraints.ClassConstraint;
TypeExpr e2 = constraints.class_constraint;
if (!Convert.ImplicitReferenceConversionExists (ec, e1, t2) &&
!Convert.ImplicitReferenceConversionExists (ec, e2, t1)) {
if (!Convert.ImplicitReferenceConversionExists (e1, t2) &&
!Convert.ImplicitReferenceConversionExists (e2, t1)) {
Report.Error (455, loc,
"Type parameter `{0}' inherits " +
"conflicting constraints `{1}' and `{2}'",
@@ -533,13 +533,10 @@ namespace Mono.CSharp {
throw new InvalidOperationException ();
this.type = type;
TypeManager.AddTypeParameter (type, this);
}
public void DefineConstraints ()
{
Type[] ifaces = null;
if (constraints != null)
constraints.Define (type);
TypeManager.AddTypeParameter (type, this);
}
public bool DefineType (EmitContext ec)
@@ -837,11 +834,6 @@ namespace Mono.CSharp {
get { return false; }
}
public override bool CheckAccessLevel (DeclSpace ds)
{
return true;
}
public void Error_CannotUseAsUnmanagedType (Location loc)
{
Report.Error (-203, loc, "Can not use type parameter as unamanged type");
@@ -954,7 +946,8 @@ namespace Mono.CSharp {
atypes = new Type [count];
for (int i = 0; i < count; i++){
TypeExpr te = ((Expression) args [i]).ResolveAsTypeTerminal (ec, false);
TypeExpr te = ds.ResolveTypeExpr (
(Expression) args [i], false, Location);
if (te == null) {
ok = false;
continue;
@@ -1077,7 +1070,7 @@ namespace Mono.CSharp {
return false;
}
return Convert.ImplicitStandardConversionExists (ec, expr, ctype);
return Convert.ImplicitStandardConversionExists (expr, ctype);
}
protected bool CheckConstraints (EmitContext ec, int index)
@@ -1176,10 +1169,8 @@ namespace Mono.CSharp {
public override TypeExpr DoResolveAsTypeStep (EmitContext ec)
{
if (type != null)
return this;
if (gt != null)
return DoResolveType (ec);
return this;
//
// First, resolve the generic type.
@@ -1197,14 +1188,14 @@ namespace Mono.CSharp {
new_args.Add (args);
args = new_args;
return DoResolveType (ec);
return this;
}
Type t;
int num_args;
SimpleName sn = new SimpleName (name, loc);
TypeExpr resolved = sn.ResolveAsTypeTerminal (ec, true);
TypeExpr resolved = sn.ResolveAsTypeTerminal (ec);
if ((resolved == null) || (resolved.Type == null)) {
Report.Error (246, loc,
"The type or namespace name `{0}<...>' "+
@@ -1229,11 +1220,16 @@ namespace Mono.CSharp {
}
gt = t.GetGenericTypeDefinition ();
return DoResolveType (ec);
return this;
}
TypeExpr DoResolveType (EmitContext ec)
public override Type ResolveType (EmitContext ec)
{
if (type != null)
return type;
if (DoResolveAsTypeStep (ec) == null)
return null;
//
// Resolve the arguments.
//
@@ -1261,7 +1257,7 @@ namespace Mono.CSharp {
// Now bind the parameters.
//
type = gt.BindGenericParameters (atypes);
return this;
return type;
}
public Expression GetSimpleName (EmitContext ec)
@@ -1349,7 +1345,7 @@ namespace Mono.CSharp {
return true;
}
public bool Define (MethodBuilder mb, Type return_type)
public bool Define (MethodBuilder mb)
{
if (!Define ())
return false;
@@ -1360,9 +1356,6 @@ namespace Mono.CSharp {
for (int i = 0; i < TypeParameters.Length; i++)
TypeParameters [i].Define (gen_params [i]);
ec = new EmitContext (
this, this, Location, null, return_type, ModFlags, false);
return true;
}
+24 -36
View File
@@ -51,8 +51,9 @@ namespace Mono.CSharp {
"catch clause");
return false;
}
if (ec.CurrentAnonymousMethod != null){
Report.Error (1621, loc, "yield statement can not appear inside an anonymoud method");
if (ec.InAnonymousMethod){
Report.Error (1621, loc, "yield statement can not appear " +
"inside an anonymoud method");
return false;
}
@@ -111,9 +112,9 @@ namespace Mono.CSharp {
}
public class Iterator : Class {
ToplevelBlock original_block;
ToplevelBlock block;
string original_name;
Block original_block;
Block block;
Type iterator_type;
TypeExpr iterator_type_expr;
@@ -133,8 +134,6 @@ namespace Mono.CSharp {
// Context from the original method
//
TypeContainer container;
TypeExpr current_type;
Type this_type;
Type return_type;
Type [] param_types;
InternalParameters parameters;
@@ -224,7 +223,6 @@ namespace Mono.CSharp {
Label dispatcher = ig.DefineLabel ();
ig.Emit (OpCodes.Br, dispatcher);
ec.RemapToProxy = true;
Label [] labels = new Label [resume_points.Count];
for (int i = 0; i < labels.Length; i++) {
ResumePoint point = (ResumePoint) resume_points [i];
@@ -248,7 +246,6 @@ namespace Mono.CSharp {
ig.EndExceptionBlock ();
ig.Emit (OpCodes.Br, end);
}
ec.RemapToProxy = false;
ig.MarkLabel (dispatcher);
ig.Emit (OpCodes.Ldarg_0);
@@ -358,7 +355,7 @@ namespace Mono.CSharp {
//
public Iterator (TypeContainer container, string name, Type return_type,
Type [] param_types, InternalParameters parameters,
int modifiers, ToplevelBlock block, Location loc)
int modifiers, Block block, Location loc)
: base (container.NamespaceEntry, container, MakeProxyName (name),
Modifiers.PRIVATE, null, loc)
{
@@ -368,7 +365,7 @@ namespace Mono.CSharp {
this.parameters = parameters;
this.original_name = name;
this.original_block = block;
this.block = new ToplevelBlock (loc);
this.block = new Block (null);
fields = new Hashtable ();
@@ -377,8 +374,6 @@ namespace Mono.CSharp {
public bool DefineIterator ()
{
ec = new EmitContext (this, Mono.CSharp.Location.Null, null, null, ModFlags);
if (!CheckType (return_type)) {
Report.Error (
1624, Location,
@@ -398,11 +393,6 @@ namespace Mono.CSharp {
}
}
if (container.CurrentType != null)
this_type = container.CurrentType.ResolveType (ec);
else
this_type = container.TypeBuilder;
generic_args = new TypeArguments (Location);
generic_args.Add (new TypeExpression (iterator_type, Location));
@@ -442,11 +432,6 @@ namespace Mono.CSharp {
//
protected override bool DefineNestedTypes ()
{
if (CurrentType != null)
current_type = CurrentType;
else
current_type = new TypeExpression (TypeBuilder, Location);
Define_Fields ();
Define_Constructor ();
Define_Current (false);
@@ -479,7 +464,7 @@ namespace Mono.CSharp {
ArrayList args = new ArrayList ();
if (!is_static) {
Type t = this_type;
Type t = container.TypeBuilder;
args.Add (new Argument (
new ThisParameterReference (t, 0, Location)));
}
@@ -492,7 +477,8 @@ namespace Mono.CSharp {
new SimpleParameterReference (t, first + i, Location)));
}
Expression new_expr = new New (current_type, args, Location);
Expression new_expr = new New (
new TypeExpression (TypeBuilder, Location), args, Location);
block.AddStatement (new NoCheckReturn (new_expr, Location));
}
@@ -513,7 +499,8 @@ namespace Mono.CSharp {
if (!is_static) {
this_field = new Field (
this, new TypeExpression (this_type, loc),
this,
new TypeExpression (container.TypeBuilder, Location),
Modifiers.PRIVATE, "this", null, null, loc);
AddField (this_field);
}
@@ -539,7 +526,7 @@ namespace Mono.CSharp {
if (!is_static)
list.Add (new Parameter (
new TypeExpression (this_type, Location),
new TypeExpression (container.TypeBuilder, Location),
"this", Parameter.Modifier.NONE, null));
list.Add (new Parameter (
TypeManager.system_boolean_expr, "initialized",
@@ -563,10 +550,10 @@ namespace Mono.CSharp {
Location);
AddConstructor (ctor);
ToplevelBlock block = ctor.Block = new ToplevelBlock (Location);
Block block = ctor.Block = new Block (null);
if (!is_static) {
Type t = this_type;
Type t = container.TypeBuilder;
Assign assign = new Assign (
new FieldExpression (this_field),
@@ -631,7 +618,7 @@ namespace Mono.CSharp {
MemberName name = new MemberName (left, "Current", null);
ToplevelBlock get_block = new ToplevelBlock (Location);
Block get_block = new Block (null);
get_block.AddStatement (new If (
new Binary (
@@ -643,7 +630,7 @@ namespace Mono.CSharp {
new FieldExpression (current_field), Location),
Location));
Accessor getter = new Accessor (get_block, 0, null, Location);
Accessor getter = new Accessor (get_block, null, Location);
Property current = new Property (
this, type, 0, false, name, null, getter, null, Location);
@@ -659,7 +646,7 @@ namespace Mono.CSharp {
Location.Null);
AddMethod (move_next);
ToplevelBlock block = move_next.Block = new ToplevelBlock (Location);
Block block = move_next.Block = new Block (null);
MoveNextMethod inline = new MoveNextMethod (this, Location);
block.AddStatement (inline);
@@ -687,7 +674,7 @@ namespace Mono.CSharp {
Location.Null);
AddMethod (get_enumerator);
get_enumerator.Block = new ToplevelBlock (Location);
get_enumerator.Block = new Block (null);
Expression ce = new MemberAccess (
new SimpleName ("System.Threading.Interlocked", Location),
@@ -720,7 +707,8 @@ namespace Mono.CSharp {
args.Add (new Argument (
new FieldExpression (parameter_fields [i])));
Expression new_expr = new New (current_type, args, Location);
Expression new_expr = new New (
new TypeExpression (TypeBuilder, Location), args, Location);
get_enumerator.Block.AddStatement (new Return (new_expr, Location));
}
@@ -903,7 +891,7 @@ namespace Mono.CSharp {
Parameters.EmptyReadOnlyParameters, null, Location);
AddMethod (reset);
reset.Block = new ToplevelBlock (Location);
reset.Block = new Block (null);
reset.Block.AddStatement (Create_ThrowNotSupported ());
}
@@ -915,11 +903,11 @@ namespace Mono.CSharp {
Parameters.EmptyReadOnlyParameters, null, Location);
AddMethod (dispose);
dispose.Block = new ToplevelBlock (Location);
dispose.Block = new Block (null);
dispose.Block.AddStatement (new DisposeMethod (this, Location));
}
public ToplevelBlock Block {
public Block Block {
get { return block; }
}
+11 -9
View File
@@ -270,14 +270,14 @@ namespace Mono.CSharp {
// According to section 16.3.1, the namespace-or-type-name is resolved
// as if the immediately containing namespace body has no using-directives.
resolved = NamespaceEntry.Lookup (
null, alias, Alias.CountTypeArguments, true, Location);
null, alias, Alias.CountTypeArguments, true, false, Location);
NamespaceEntry curr_ns = NamespaceEntry.Parent;
while ((curr_ns != null) && (resolved == null)) {
resolved = curr_ns.Lookup (
null, alias, Alias.CountTypeArguments,
false, Location);
false, false, Location);
if (resolved == null)
curr_ns = curr_ns.Parent;
@@ -365,11 +365,12 @@ namespace Mono.CSharp {
if (using_clauses == null)
using_clauses = new ArrayList ();
foreach (UsingEntry old_entry in using_clauses) {
if (old_entry.Name == ns) {
if (RootContext.WarningLevel >= 3)
if (RootContext.WarningLevel >= 3) {
foreach (UsingEntry old_entry in using_clauses){
if (old_entry.Name == ns){
Report.Warning (105, loc, "The using directive for '{0}' appeared previously in this namespace", ns);
return;
}
}
}
@@ -419,7 +420,7 @@ namespace Mono.CSharp {
}
public IAlias Lookup (DeclSpace ds, string name, int num_type_params,
bool ignore_using, Location loc)
bool ignore_using, bool silent, Location loc)
{
IAlias o;
Namespace ns;
@@ -432,7 +433,7 @@ namespace Mono.CSharp {
string first = name.Substring (0, pos);
string last = name.Substring (pos + 1);
o = Lookup (ds, first, 0, ignore_using, loc);
o = Lookup (ds, first, 0, ignore_using, silent, loc);
if (o == null)
return null;
@@ -480,7 +481,8 @@ namespace Mono.CSharp {
match = using_ns.Lookup (ds, name, loc);
if ((match != null) && match.IsType){
if (t != null) {
DeclSpace.Error_AmbiguousTypeReference (loc, name, t.Name, match.Name);
if (!silent)
DeclSpace.Error_AmbiguousTypeReference (loc, name, t.Name, match.Name);
return null;
} else {
t = match;
@@ -627,7 +629,7 @@ namespace Mono.CSharp {
continue;
}
error246 (entry.Location, entry.Alias.GetPartialName ());
error246 (entry.Location, entry.Alias.ToString ());
}
}
}
+73 -48
View File
@@ -31,15 +31,12 @@ namespace Mono.CSharp {
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
{
if (a.Type == TypeManager.marshal_as_attr_type) {
UnmanagedMarshal marshal = a.GetMarshal (this);
UnmanagedMarshal marshal = a.GetMarshal ();
if (marshal != null) {
builder.SetMarshal (marshal);
}
return;
return;
}
if (a.Type.IsSubclassOf (TypeManager.security_attr_type)) {
a.Error_InvalidSecurityParent ();
Report.Warning (-24, a.Location, "The Microsoft Runtime cannot set this marshal info. Please use the Mono runtime instead.");
return;
}
@@ -139,7 +136,7 @@ namespace Mono.CSharp {
static string[] attribute_targets = new string [] { "param" };
public Expression TypeName;
public readonly Expression TypeName;
public readonly Modifier ModFlags;
public readonly string Name;
GenericConstraints constraints;
@@ -165,9 +162,9 @@ namespace Mono.CSharp {
// <summary>
// Resolve is used in method definitions
// </summary>
public bool Resolve (EmitContext ec, Location l)
public bool Resolve (DeclSpace ds, Location l)
{
TypeExpr texpr = TypeName.ResolveAsTypeTerminal (ec, false);
TypeExpr texpr = ds.ResolveTypeExpr (TypeName, false, l);
if (texpr == null)
return false;
@@ -175,8 +172,8 @@ namespace Mono.CSharp {
if (tparam != null)
constraints = tparam.TypeParameter.Constraints;
parameter_type = texpr.ResolveType (ec);
parameter_type = ds.ResolveType (texpr, l);
if (parameter_type.IsAbstract && parameter_type.IsSealed) {
Report.Error (721, l, "'{0}': static types cannot be used as parameters", GetSignatureForError ());
return false;
@@ -247,10 +244,10 @@ namespace Mono.CSharp {
/// Returns the signature for this parameter evaluating it on the
/// @tc context
/// </summary>
public string GetSignature (EmitContext ec, Location loc)
public string GetSignature (DeclSpace ds, Location loc)
{
if (parameter_type == null){
if (!Resolve (ec, loc))
if (!Resolve (ds, loc))
return null;
}
@@ -259,15 +256,8 @@ namespace Mono.CSharp {
public string GetSignatureForError ()
{
string typeName;
if (parameter_type != null)
typeName = TypeManager.CSharpName (parameter_type);
else if (TypeName.Type != null)
typeName = TypeManager.CSharpName (TypeName.Type);
else
typeName = TypeName.ToString ();
switch (ModFlags & unchecked (~Modifier.ISBYREF)) {
string typeName = TypeManager.CSharpName (parameter_type);
switch (ModFlags & ~Modifier.ISBYREF) {
case Modifier.OUT:
return "out " + typeName;
case Modifier.PARAMS:
@@ -350,14 +340,14 @@ namespace Mono.CSharp {
}
}
public void ComputeSignature (EmitContext ec)
public void ComputeSignature (DeclSpace ds)
{
signature = "";
if (FixedParameters != null){
for (int i = 0; i < FixedParameters.Length; i++){
Parameter par = FixedParameters [i];
signature += par.GetSignature (ec, loc);
signature += par.GetSignature (ds, loc);
}
}
//
@@ -382,9 +372,9 @@ namespace Mono.CSharp {
count = FixedParameters.Length;
string array_par_name = ArrayParameter != null ? ArrayParameter.Name : null;
for (i = 0; i < count; i++){
string base_name = FixedParameters [i].Name;
for (j = i + 1; j < count; j++){
if (base_name != FixedParameters [j].Name)
continue;
@@ -402,13 +392,13 @@ namespace Mono.CSharp {
/// <summary>
/// Returns the signature of the Parameters evaluated in
/// the @ec EmitContext
/// the @tc environment
/// </summary>
public string GetSignature (EmitContext ec)
public string GetSignature (DeclSpace ds)
{
if (signature == null){
VerifyArgs ();
ComputeSignature (ec);
ComputeSignature (ds);
}
return signature;
@@ -442,14 +432,7 @@ namespace Mono.CSharp {
return null;
}
public Parameter GetParameterByName (string name)
{
int idx;
return GetParameterByName (name, out idx);
}
bool ComputeParameterTypes (EmitContext ec)
bool ComputeParameterTypes (DeclSpace ds)
{
int extra = (ArrayParameter != null) ? 1 : 0;
int i = 0;
@@ -472,7 +455,7 @@ namespace Mono.CSharp {
foreach (Parameter p in FixedParameters){
Type t = null;
if (p.Resolve (ec, loc))
if (p.Resolve (ds, loc))
t = p.ExternalType ();
else
failed = true;
@@ -483,7 +466,7 @@ namespace Mono.CSharp {
}
if (extra > 0){
if (ArrayParameter.Resolve (ec, loc))
if (ArrayParameter.Resolve (ds, loc))
types [i] = ArrayParameter.ExternalType ();
else
failed = true;
@@ -501,13 +484,55 @@ namespace Mono.CSharp {
// This variant is used by Delegates, because they need to
// resolve/define names, instead of the plain LookupType
//
public bool ComputeAndDefineParameterTypes (EmitContext ec)
public bool ComputeAndDefineParameterTypes (DeclSpace ds)
{
bool old_type_resolving = ec.ResolvingTypeTree;
ec.ResolvingTypeTree = true;
bool retval = ComputeParameterTypes (ec);
ec.ResolvingTypeTree = old_type_resolving;
return retval;
int extra = (ArrayParameter != null) ? 1 : 0;
int i = 0;
int pc;
if (FixedParameters == null)
pc = extra;
else
pc = extra + FixedParameters.Length;
types = new Type [pc];
if (!VerifyArgs ()){
FixedParameters = null;
return false;
}
bool ok_flag = true;
if (FixedParameters != null){
foreach (Parameter p in FixedParameters){
Type t = null;
if (p.Resolve (ds, loc))
t = p.ExternalType ();
else
ok_flag = false;
types [i] = t;
i++;
}
}
if (extra > 0){
if (ArrayParameter.Resolve (ds, loc))
types [i] = ArrayParameter.ExternalType ();
else
ok_flag = false;
}
//
// invalidate the cached types
//
if (!ok_flag){
types = null;
}
return ok_flag;
}
/// <summary>
@@ -515,7 +540,7 @@ namespace Mono.CSharp {
/// </summary>
static Type [] no_types = new Type [0];
public Type [] GetParameterInfo (EmitContext ec)
public Type [] GetParameterInfo (DeclSpace ds)
{
if (types != null)
return types;
@@ -523,7 +548,7 @@ namespace Mono.CSharp {
if (FixedParameters == null && ArrayParameter == null)
return no_types;
if (ComputeParameterTypes (ec) == false){
if (ComputeParameterTypes (ds) == false){
types = null;
return null;
}
@@ -538,7 +563,7 @@ namespace Mono.CSharp {
/// Note that the returned type will not contain any dereference in this
/// case (ie, you get "int" for a ref int instead of "int&"
/// </summary>
public Type GetParameterInfo (EmitContext ec, int idx, out Parameter.Modifier mod)
public Type GetParameterInfo (DeclSpace ds, int idx, out Parameter.Modifier mod)
{
mod = Parameter.Modifier.NONE;
@@ -551,7 +576,7 @@ namespace Mono.CSharp {
return null;
if (types == null)
if (ComputeParameterTypes (ec) == false)
if (ComputeParameterTypes (ds) == false)
return null;
//
+2 -2
View File
@@ -267,9 +267,9 @@ namespace Mono.CSharp {
Console.WriteLine (String.Format ("{0}({1}) (Location of symbol related to previous error)", loc.Name, loc.Row));
}
static public void RuntimeMissingSupport (Location loc, string feature)
static public void RuntimeMissingSupport (string feature)
{
Report.Error (-88, loc, "Your .NET Runtime does not support '{0}'. Please use the latest Mono runtime instead.", feature);
Report.Error (-88, "Your .NET Runtime does not support '{0}'. Please use the latest Mono runtime instead.", feature);
}
/// <summary>
+4 -7
View File
@@ -379,15 +379,13 @@ namespace Mono.CSharp {
"System.ParamArrayAttribute",
"System.CLSCompliantAttribute",
"System.Security.UnverifiableCodeAttribute",
"System.Security.Permissions.SecurityAttribute",
"System.Runtime.CompilerServices.IndexerNameAttribute",
"System.Runtime.InteropServices.InAttribute",
"System.Runtime.InteropServices.StructLayoutAttribute",
"System.Runtime.InteropServices.FieldOffsetAttribute",
"System.InvalidOperationException",
"System.NotSupportedException",
"System.MarshalByRefObject",
"System.Security.CodeAccessPermission"
"System.MarshalByRefObject"
};
// We must store them here before calling BootstrapCorlib_ResolveDelegate.
@@ -489,13 +487,13 @@ namespace Mono.CSharp {
}
static TypeExpr NamespaceLookup (DeclSpace ds, string name,
int num_type_args, Location loc)
int num_type_args, bool silent, Location loc)
{
//
// Try in the current namespace and all its implicit parents
//
for (NamespaceEntry ns = ds.NamespaceEntry; ns != null; ns = ns.ImplicitParent) {
IAlias result = ns.Lookup (ds, name, num_type_args, false, loc);
IAlias result = ns.Lookup (ds, name, num_type_args, false, silent, loc);
if (result == null)
continue;
@@ -547,7 +545,6 @@ namespace Mono.CSharp {
//
Type type = TypeManager.LookupType (current_type.FullName + "." + name);
if (type != null){
type = ds.ResolveNestedType (type, loc);
t = new TypeExpression (type, loc);
ds.Cache [name] = t;
return t;
@@ -559,7 +556,7 @@ namespace Mono.CSharp {
containing_ds = containing_ds.Parent;
}
t = NamespaceLookup (ds, name, num_type_params, loc);
t = NamespaceLookup (ds, name, num_type_params, silent, loc);
if (t != null){
ds.Cache [name] = t;
return t;
+67 -350
View File
@@ -6,7 +6,6 @@
// Martin Baulig ([email protected])
//
// (C) 2001, 2002, 2003 Ximian, Inc.
// (C) 2003, 2004 Novell, Inc.
//
using System;
@@ -559,12 +558,7 @@ namespace Mono.CSharp {
public override bool Resolve (EmitContext ec)
{
if (ec.ReturnType == null){
if (Expr != null){
if (ec.CurrentAnonymousMethod != null){
Report.Error (1662, loc, String.Format (
"Anonymous method could not be converted to delegate " +
"since the return value does not match the delegate value"));
}
if (Expr != null){
Error (127, "Return with a value not allowed here");
return false;
}
@@ -604,9 +598,6 @@ namespace Mono.CSharp {
} else
vector.CheckOutParameters (ec.CurrentBranching);
if (in_exc)
ec.NeedReturnLabel ();
ec.CurrentBranching.CurrentUsageVector.Return ();
return true;
}
@@ -620,12 +611,14 @@ namespace Mono.CSharp {
ec.ig.Emit (OpCodes.Stloc, ec.TemporaryReturn ());
}
if (in_exc)
if (in_exc) {
ec.NeedReturnLabel ();
ec.ig.Emit (OpCodes.Leave, ec.ReturnLabel);
else
} else {
ec.ig.Emit (OpCodes.Ret);
}
}
}
public class Goto : Statement {
string target;
@@ -762,7 +755,7 @@ namespace Mono.CSharp {
/// </summary>
public class GotoCase : Statement {
Expression expr;
SwitchLabel sl;
Label label;
public GotoCase (Expression e, Location l)
{
@@ -792,7 +785,7 @@ namespace Mono.CSharp {
if (val == null)
return false;
sl = (SwitchLabel) ec.Switch.Elements [val];
SwitchLabel sl = (SwitchLabel) ec.Switch.Elements [val];
if (sl == null){
Report.Error (
@@ -801,13 +794,15 @@ namespace Mono.CSharp {
return false;
}
label = sl.ILLabelCode;
ec.CurrentBranching.CurrentUsageVector.Goto ();
return true;
}
protected override void DoEmit (EmitContext ec)
{
ec.ig.Emit (OpCodes.Br, sl.GetILLabelCode (ec));
ec.ig.Emit (OpCodes.Br, label);
}
}
@@ -896,9 +891,6 @@ namespace Mono.CSharp {
crossing_exc = ec.CurrentBranching.BreakCrossesTryCatchBoundary ();
if (!crossing_exc)
ec.NeedReturnLabel ();
ec.CurrentBranching.CurrentUsageVector.Break ();
return true;
}
@@ -910,6 +902,7 @@ namespace Mono.CSharp {
if (crossing_exc)
ig.Emit (OpCodes.Leave, ec.LoopEnd);
else {
ec.NeedReturnLabel ();
ig.Emit (OpCodes.Br, ec.LoopEnd);
}
}
@@ -952,17 +945,13 @@ namespace Mono.CSharp {
}
}
//
// The information about a user-perceived local variable
//
public class LocalInfo {
public Expression Type;
//
// Most of the time a variable will be stored in a LocalBuilder
//
// But sometimes, it will be stored in a field (variables that have been
// hoisted by iterators or by anonymous methods). The context of the field will
// But sometimes, it will be stored in a field. The context of the field will
// be stored in the EmitContext
//
//
@@ -980,8 +969,7 @@ namespace Mono.CSharp {
Used = 1,
ReadOnly = 2,
Pinned = 4,
IsThis = 8,
Captured = 16
IsThis = 8
}
Flags flags;
@@ -1022,15 +1010,8 @@ namespace Mono.CSharp {
public bool Resolve (EmitContext ec)
{
if (VariableType == null) {
TypeExpr texpr = Type.ResolveAsTypeTerminal (ec, false);
if (texpr == null)
return false;
VariableType = texpr.ResolveType (ec);
if (VariableType == null)
return false;
}
if (VariableType == null)
VariableType = ec.DeclSpace.ResolveType (Type, false, Location);
if (VariableType == TypeManager.void_type) {
Report.Error (1547, Location,
@@ -1038,6 +1019,9 @@ namespace Mono.CSharp {
return false;
}
if (VariableType == null)
return false;
if (VariableType.IsAbstract && VariableType.IsSealed) {
Report.Error (723, Location, "Cannot declare variable of static type '{0}'", TypeManager.CSharpName (VariableType));
return false;
@@ -1061,16 +1045,6 @@ namespace Mono.CSharp {
}
}
public bool IsCaptured {
get {
return (flags & Flags.Captured) != 0;
}
set {
flags |= Flags.Captured;
}
}
public override string ToString ()
{
return String.Format ("LocalInfo ({0},{1},{2},{3})",
@@ -1082,7 +1056,7 @@ namespace Mono.CSharp {
return (flags & Flags.Used) != 0;
}
set {
flags = value ? (flags | Flags.Used) : (unchecked (flags & ~Flags.Used));
flags = value ? (flags | Flags.Used) : (flags & ~Flags.Used);
}
}
@@ -1091,7 +1065,7 @@ namespace Mono.CSharp {
return (flags & Flags.ReadOnly) != 0;
}
set {
flags = value ? (flags | Flags.ReadOnly) : (unchecked (flags & ~Flags.ReadOnly));
flags = value ? (flags | Flags.ReadOnly) : (flags & ~Flags.ReadOnly);
}
}
@@ -1133,21 +1107,19 @@ namespace Mono.CSharp {
/// they contain extra information that is not necessary on normal blocks.
/// </remarks>
public class Block : Statement {
public Block Parent;
public readonly Block Parent;
public readonly Location StartLocation;
public Location EndLocation = Location.Null;
[Flags]
public enum Flags {
public enum Flags : byte {
Implicit = 1,
Unchecked = 2,
BlockUsed = 4,
VariablesInitialized = 8,
HasRet = 16,
IsDestructor = 32,
HasVarargs = 64,
IsToplevel = 128,
Unsafe = 256
HasVarargs = 64
}
Flags flags;
@@ -1166,15 +1138,6 @@ namespace Mono.CSharp {
}
}
public bool Unsafe {
get {
return (flags & Flags.Unsafe) != 0;
}
set {
flags |= Flags.Unsafe;
}
}
public bool HasVarargs {
get {
if (Parent != null)
@@ -1216,17 +1179,12 @@ namespace Mono.CSharp {
// Keeps track of constants
Hashtable constants;
//
// The parameters for the block, this is only needed on the toplevel block really
// TODO: move `parameters' into ToplevelBlock
Parameters parameters;
//
// If this is a switch section, the enclosing switch block.
//
Block switch_block;
protected static int id;
static int id;
int this_id;
@@ -1595,76 +1553,14 @@ namespace Mono.CSharp {
return e != null;
}
//
// Returns a `ParameterReference' for the given name, or null if there
// is no such parameter
//
public ParameterReference GetParameterReference (string name, Location loc)
{
Parameters parameters = null;
public Parameters Parameters {
get {
Block b = this;
do {
Parameters pars = b.parameters;
if (pars != null){
Parameter par;
int idx;
par = pars.GetParameterByName (name, out idx);
if (par != null){
ParameterReference pr;
pr = new ParameterReference (pars, this, idx, name, loc);
return pr;
}
}
while (b.Parent != null)
b = b.Parent;
} while (b != null);
return null;
return b.parameters;
}
//
// Whether the parameter named `name' is local to this block,
// or false, if the parameter belongs to an encompassing block.
//
public bool IsLocalParameter (string name)
{
Block b = this;
int toplevel_count = 0;
do {
if (this is ToplevelBlock)
toplevel_count++;
Parameters pars = b.parameters;
if (pars != null){
if (pars.GetParameterByName (name) != null)
return true;
return false;
}
if (toplevel_count > 0)
return false;
b = b.Parent;
} while (b != null);
return false;
}
//
// Whether the `name' is a parameter reference
//
public bool IsParameterReference (string name)
{
Block b = this;
do {
Parameters pars = b.parameters;
if (pars != null)
if (pars.GetParameterByName (name) != null)
return true;
b = b.Parent;
} while (b != null);
return false;
}
/// <returns>
@@ -1715,7 +1611,7 @@ namespace Mono.CSharp {
public VariableMap ParameterMap {
get {
if ((flags & Flags.VariablesInitialized) == 0)
throw new Exception ("Variables have not been initialized yet");
throw new Exception ();
return param_map;
}
@@ -1724,12 +1620,17 @@ namespace Mono.CSharp {
public VariableMap LocalMap {
get {
if ((flags & Flags.VariablesInitialized) == 0)
throw new Exception ("Variables have not been initialized yet");
throw new Exception ();
return local_map;
}
}
public bool LiftVariable (LocalInfo local_info)
{
return false;
}
/// <summary>
/// Emits the variable declarations and labels.
/// </summary>
@@ -1737,16 +1638,10 @@ namespace Mono.CSharp {
/// tc: is our typecontainer (to resolve type references)
/// ig: is the code generator:
/// </remarks>
public void ResolveMeta (ToplevelBlock toplevel, EmitContext ec, InternalParameters ip)
public void EmitMeta (EmitContext ec, InternalParameters ip)
{
ILGenerator ig = ec.ig;
bool old_unsafe = ec.InUnsafe;
// If some parent block was unsafe, we remain unsafe even if this block
// isn't explicitly marked as such.
ec.InUnsafe |= Unsafe;
//
// Compute the VariableMap's.
//
@@ -1774,6 +1669,7 @@ namespace Mono.CSharp {
bool old_check_state = ec.ConstantCheckState;
ec.ConstantCheckState = (flags & Flags.Unchecked) == 0;
bool remap_locals = ec.RemapToProxy;
//
// Process this block variables
@@ -1799,7 +1695,6 @@ namespace Mono.CSharp {
continue;
}
#if false
if (remap_locals)
vi.FieldBuilder = ec.MapVariable (name, vi.VariableType);
else if (vi.Pinned)
@@ -1810,7 +1705,6 @@ namespace Mono.CSharp {
vi.LocalBuilder = TypeManager.DeclareLocalPinned (ig, vi.VariableType);
else if (!vi.IsThis)
vi.LocalBuilder = ig.DeclareLocal (vi.VariableType);
#endif
if (constants == null)
continue;
@@ -1849,46 +1743,7 @@ namespace Mono.CSharp {
//
if (children != null){
foreach (Block b in children)
b.ResolveMeta (toplevel, ec, ip);
}
ec.InUnsafe = old_unsafe;
}
//
// Emits the local variable declarations for a block
//
public void EmitMeta (EmitContext ec)
{
ILGenerator ig = ec.ig;
if (variables != null){
bool have_captured_vars = ec.HaveCapturedVariables ();
bool remap_locals = ec.RemapToProxy;
foreach (DictionaryEntry de in variables){
LocalInfo vi = (LocalInfo) de.Value;
if (have_captured_vars && ec.IsCaptured (vi))
continue;
if (remap_locals){
vi.FieldBuilder = ec.MapVariable (vi.Name, vi.VariableType);
} else {
if (vi.Pinned)
//
// This is needed to compile on both .NET 1.x and .NET 2.x
// the later introduced `DeclareLocal (Type t, bool pinned)'
//
vi.LocalBuilder = TypeManager.DeclareLocalPinned (ig, vi.VariableType);
else if (!vi.IsThis)
vi.LocalBuilder = ig.DeclareLocal (vi.VariableType);
}
}
}
if (children != null){
foreach (Block b in children)
b.EmitMeta (ec);
b.EmitMeta (ec, ip);
}
}
@@ -2059,128 +1914,28 @@ namespace Mono.CSharp {
ec.CurrentBlock = prev_block;
}
public ToplevelBlock Toplevel {
get {
Block b = this;
while (b.Parent != null){
if ((b.flags & Flags.IsToplevel) != 0)
break;
b = b.Parent;
}
return (ToplevelBlock) b;
}
}
//
// Returns true if we ar ea child of `b'.
//
public bool IsChildOf (Block b)
{
Block current = this;
do {
if (current.Parent == b)
return true;
current = current.Parent;
} while (current != null);
return false;
}
}
//
// A toplevel block contains extra information, the split is done
// only to separate information that would otherwise bloat the more
// lightweight Block.
//
// In particular, this was introduced when the support for Anonymous
// Methods was implemented.
//
public class ToplevelBlock : Block {
//
// Pointer to the host of this anonymous method, or null
// if we are the topmost block
//
public ToplevelBlock Container;
CaptureContext capture_context;
Hashtable capture_contexts;
static int did = 0;
int my_id = did++;
public void RegisterCaptureContext (CaptureContext cc)
{
if (capture_contexts == null)
capture_contexts = new Hashtable ();
capture_contexts [cc] = cc;
}
public void CompleteContexts ()
{
if (capture_contexts == null)
return;
foreach (CaptureContext cc in capture_contexts.Keys){
cc.AdjustScopes ();
}
}
public CaptureContext ToplevelBlockCaptureContext {
get {
return capture_context;
}
}
//
// Parent is only used by anonymous blocks to link back to their
// parents
//
public ToplevelBlock (ToplevelBlock container, Parameters parameters, Location start) :
base (null, Flags.IsToplevel, parameters, start, Location.Null)
{
Container = container;
}
public ToplevelBlock (Parameters parameters, Location start) :
base (null, Flags.IsToplevel, parameters, start, Location.Null)
base (null, parameters, start, Location.Null)
{
}
public ToplevelBlock (Flags flags, Parameters parameters, Location start) :
base (null, flags | Flags.IsToplevel, parameters, start, Location.Null)
base (null, flags, parameters, start, Location.Null)
{
}
public ToplevelBlock (Location loc) : base (null, Flags.IsToplevel, loc, loc)
{
}
public void SetHaveAnonymousMethods (Location loc, AnonymousMethod host)
{
if (capture_context == null)
capture_context = new CaptureContext (this, loc, host);
}
public CaptureContext CaptureContext {
get {
return capture_context;
}
}
}
public class SwitchLabel {
Expression label;
object converted;
public Location loc;
Label il_label;
bool il_label_set;
Label il_label_code;
bool il_label_code_set;
public Label ILLabel;
public Label ILLabelCode;
//
// if expr == null, then it is the default case.
@@ -2203,30 +1958,15 @@ namespace Mono.CSharp {
}
}
public Label GetILLabel (EmitContext ec)
{
if (!il_label_set){
il_label = ec.ig.DefineLabel ();
il_label_set = true;
}
return il_label;
}
public Label GetILLabelCode (EmitContext ec)
{
if (!il_label_code_set){
il_label_code = ec.ig.DefineLabel ();
il_label_code_set = true;
}
return il_label_code;
}
//
// Resolves the expression, reduces it to a literal if possible
// and then converts it to the requested type.
//
public bool ResolveAndReduce (EmitContext ec, Type required_type)
{
ILLabel = ec.ig.DefineLabel ();
ILLabelCode = ec.ig.DefineLabel ();
if (label == null)
return true;
@@ -2243,6 +1983,7 @@ namespace Mono.CSharp {
if (e is StringConstant || e is NullLiteral){
if (required_type == TypeManager.string_type){
converted = e;
ILLabel = ec.ig.DefineLabel ();
return true;
}
}
@@ -2709,7 +2450,7 @@ namespace Mono.CSharp {
ig.Emit (OpCodes.Ldloc, val);
EmitObjectInteger (ig, key);
SwitchLabel sl = (SwitchLabel) Elements [key];
ig.Emit (OpCodes.Beq, sl.GetILLabel (ec));
ig.Emit (OpCodes.Beq, sl.ILLabel);
}
}
else
@@ -2765,7 +2506,7 @@ namespace Mono.CSharp {
if (System.Convert.ToInt64 (key) == kb.nFirst + iJump)
{
SwitchLabel sl = (SwitchLabel) Elements [key];
rgLabels [iJump] = sl.GetILLabel (ec);
rgLabels [iJump] = sl.ILLabel;
iKey++;
}
else
@@ -2793,8 +2534,8 @@ namespace Mono.CSharp {
{
foreach (SwitchLabel sl in ss.Labels)
{
ig.MarkLabel (sl.GetILLabel (ec));
ig.MarkLabel (sl.GetILLabelCode (ec));
ig.MarkLabel (sl.ILLabel);
ig.MarkLabel (sl.ILLabelCode);
if (sl.Label == null)
{
ig.MarkLabel (lblDefault);
@@ -2852,7 +2593,7 @@ namespace Mono.CSharp {
null_found = false;
for (int label = 0; label < label_count; label++){
SwitchLabel sl = (SwitchLabel) ss.Labels [label];
ig.MarkLabel (sl.GetILLabel (ec));
ig.MarkLabel (sl.ILLabel);
if (!first_test){
ig.MarkLabel (next_test);
@@ -2894,7 +2635,7 @@ namespace Mono.CSharp {
ig.MarkLabel (null_target);
ig.MarkLabel (sec_begin);
foreach (SwitchLabel sl in ss.Labels)
ig.MarkLabel (sl.GetILLabelCode (ec));
ig.MarkLabel (sl.ILLabelCode);
if (mark_default)
ig.MarkLabel (default_target);
@@ -3232,7 +2973,6 @@ namespace Mono.CSharp {
public Unsafe (Block b)
{
Block = b;
Block.Unsafe = true;
}
public override bool Resolve (EmitContext ec)
@@ -3290,12 +3030,10 @@ namespace Mono.CSharp {
return false;
}
TypeExpr texpr = type.ResolveAsTypeTerminal (ec, false);
if (texpr == null)
expr_type = ec.DeclSpace.ResolveType (type, false, loc);
if (expr_type == null)
return false;
expr_type = texpr.ResolveType (ec);
CheckObsolete (expr_type);
if (ec.RemapToProxy){
@@ -3559,12 +3297,10 @@ namespace Mono.CSharp {
public override bool Resolve (EmitContext ec)
{
if (type_expr != null) {
TypeExpr te = type_expr.ResolveAsTypeTerminal (ec, false);
if (te == null)
type = ec.DeclSpace.ResolveType (type_expr, false, loc);
if (type == null)
return false;
type = te.ResolveType (ec);
CheckObsolete (type);
if (type != TypeManager.exception_type && !type.IsSubclassOf (TypeManager.exception_type)){
@@ -3763,14 +3499,12 @@ namespace Mono.CSharp {
//
bool ResolveLocalVariableDecls (EmitContext ec)
{
expr_type = ec.DeclSpace.ResolveType (expr, false, loc);
int i = 0;
TypeExpr texpr = expr.ResolveAsTypeTerminal (ec, false);
if (texpr == null)
if (expr_type == null)
return false;
expr_type = texpr.ResolveType (ec);
//
// The type must be an IDisposable or an implicit conversion
// must exist.
@@ -4040,12 +3774,10 @@ namespace Mono.CSharp {
if (expr == null)
return false;
TypeExpr texpr = type.ResolveAsTypeTerminal (ec, false);
if (texpr == null)
var_type = ec.DeclSpace.ResolveType (type, false, loc);
if (var_type == null)
return false;
var_type = texpr.ResolveType (ec);
//
// We need an instance variable. Not sure this is the best
// way of doing this.
@@ -4090,8 +3822,6 @@ namespace Mono.CSharp {
// Although it is not as important in this case, as the type
// will not likely be object (what the enumerator will return).
//
Report.Debug (64, "RESOLVE FOREACH #1", element_type, empty.Type, element_type == empty.Type,
var_type, empty.Type.DeclaringType, var_type.DeclaringType, loc);
conv = Convert.ExplicitConversion (ec, empty, var_type, loc);
if (conv == null)
ok = false;
@@ -4221,8 +3951,6 @@ namespace Mono.CSharp {
static bool GetEnumeratorFilter (MemberInfo m, object criteria)
{
Report.Debug (64, "GET ENUMERATOR FILTER", m, criteria);
if (m == null)
return false;
@@ -4355,15 +4083,9 @@ namespace Mono.CSharp {
{
ForeachHelperMethods hm = new ForeachHelperMethods (ec);
Report.Debug (64, "PROBE COLLECTION TYPE", t);
for (Type tt = t; tt != null && tt != TypeManager.object_type;){
Report.Debug (64, "PROBE COLLECTION TYPE #1", t, tt);
if (TryType (tt, hm)) {
Report.Debug (64, "PROBE COLLECTION TYPE #2", t, tt);
if (TryType (tt, hm))
return hm;
}
tt = tt.BaseType;
}
@@ -4373,14 +4095,9 @@ namespace Mono.CSharp {
while (t != null){
Type [] ifaces = t.GetInterfaces ();
Report.Debug (64, "PROBE COLLECTION TYPE #3", t, ifaces);
foreach (Type i in ifaces){
Report.Debug (64, "PROBE COLLECTION TYPE #4", t, ifaces, i);
if (TryType (i, hm)) {
Report.Debug (64, "PROBE COLLECTION TYPE #5", t, ifaces, i);
if (TryType (i, hm))
return hm;
}
}
//
@@ -4462,7 +4179,7 @@ namespace Mono.CSharp {
if (ec.InIterator){
conv.Emit (ec);
ig.Emit (OpCodes.Stfld, ((LocalVariableReference) variable).local_info.FieldBuilder);
ig.Emit (OpCodes.Stfld, ((FieldExpr) variable).FieldInfo);
} else
((IAssignMethod)variable).EmitAssign (ec, conv, false, false);
@@ -4571,7 +4288,7 @@ namespace Mono.CSharp {
ArrayAccess.EmitLoadOpcode (ig, element_type);
if (ec.InIterator){
conv.Emit (ec);
ig.Emit (OpCodes.Stfld, ((LocalVariableReference) variable).local_info.FieldBuilder);
ig.Emit (OpCodes.Stfld, ((FieldExpr) variable).FieldInfo);
} else
((IAssignMethod)variable).EmitAssign (ec, conv, false, false);
@@ -4651,7 +4368,7 @@ namespace Mono.CSharp {
ig.Emit (OpCodes.Call, get);
if (ec.InIterator){
conv.Emit (ec);
ig.Emit (OpCodes.Stfld, ((LocalVariableReference) variable).local_info.FieldBuilder);
ig.Emit (OpCodes.Stfld, ((FieldExpr) variable).FieldInfo);
} else
((IAssignMethod)variable).EmitAssign (ec, conv, false, false);
statement.Emit (ec);
+7 -6
View File
@@ -140,13 +140,10 @@ namespace Mono.CSharp {
int len = pi.Length;
if (last_arg_is_params && pos >= pi.Length - 1)
return Parameter.Modifier.PARAMS;
return Parameter.Modifier.PARAMS;
else if (is_varargs && pos >= pi.Length)
return Parameter.Modifier.ARGLIST;
if (gpd != null)
return gpd.ParameterModifier (pos);
Type t = pi [pos].ParameterType;
if (t.IsByRef){
if ((pi [pos].Attributes & ParameterAttributes.Out) != 0)
@@ -177,7 +174,11 @@ namespace Mono.CSharp {
{
this.param_types = param_types;
this.Parameters = parameters;
}
public InternalParameters (DeclSpace ds, Parameters parameters)
: this (parameters.GetParameterInfo (ds), parameters)
{
has_varargs = parameters.HasArglist;
if (param_types == null)
@@ -186,9 +187,9 @@ namespace Mono.CSharp {
count = param_types.Length;
}
public InternalParameters (Type [] param_types, Parameters parameters,
public InternalParameters (DeclSpace ds, Parameters parameters,
TypeParameter [] type_params)
: this (param_types, parameters)
: this (ds, parameters)
{
this.TypeParameters = type_params;
}
+5 -107
View File
@@ -89,14 +89,12 @@ public class TypeManager {
static public Type obsolete_attribute_type;
static public Type conditional_attribute_type;
static public Type in_attribute_type;
static public Type anonymous_method_type;
static public Type cls_compliant_attribute_type;
static public Type typed_reference_type;
static public Type arg_iterator_type;
static public Type mbr_type;
static public Type struct_layout_attribute_type;
static public Type field_offset_attribute_type;
static public Type security_attr_type;
static public Type generic_ienumerator_type;
static public Type generic_ienumerable_type;
@@ -123,7 +121,6 @@ public class TypeManager {
static public TypeExpr system_asynccallback_expr;
static public TypeExpr system_iasyncresult_expr;
static public TypeExpr system_valuetype_expr;
static public TypeExpr system_intptr_expr;
//
// This is only used when compiling corlib
@@ -364,7 +361,6 @@ public class TypeManager {
system_asynccallback_expr = new TypeLookupExpression ("System.AsyncCallback");
system_iasyncresult_expr = new TypeLookupExpression ("System.IAsyncResult");
system_valuetype_expr = new TypeLookupExpression ("System.ValueType");
system_intptr_expr = new TypeLookupExpression ("System.IntPtr");
}
static TypeManager ()
@@ -509,54 +505,6 @@ public class TypeManager {
return LookupTypeContainer (t);
}
/// <summary>
/// Fills member container from base interfaces
/// </summary>
public static IMemberContainer LookupInterfaceContainer (Type[] types)
{
if (types == null)
return null;
IMemberContainer complete = null;
foreach (Type t in types) {
IMemberContainer one_type_cont = null;
if (t is TypeBuilder) {
one_type_cont = builder_to_declspace [t] as IMemberContainer;
} else
one_type_cont = TypeHandle.GetTypeHandle (t);
if (complete == null) {
complete = one_type_cont;
continue;
}
// We need to avoid including same member more than once
foreach (DictionaryEntry de in one_type_cont.MemberCache.Members) {
object o = complete.MemberCache.Members [de.Key];
if (o == null) {
complete.MemberCache.Members.Add (de.Key, de.Value);
continue;
}
ArrayList al_old = (ArrayList)o;
ArrayList al_new = (ArrayList)de.Value;
foreach (MemberCache.CacheEntry ce in al_new) {
bool exist = false;
foreach (MemberCache.CacheEntry ce_old in al_old) {
if (ce.Member == ce_old.Member) {
exist = true;
break;
}
}
if (!exist)
al_old.Add (ce);
}
}
}
return complete;
}
public static IMemberContainer LookupMemberContainer (Type t)
{
if (t is TypeBuilder) {
@@ -1229,7 +1177,6 @@ public class TypeManager {
cls_compliant_attribute_type = CoreLookupType ("System.CLSCompliantAttribute");
struct_layout_attribute_type = CoreLookupType ("System.Runtime.InteropServices.StructLayoutAttribute");
field_offset_attribute_type = CoreLookupType ("System.Runtime.InteropServices.FieldOffsetAttribute");
security_attr_type = CoreLookupType ("System.Security.Permissions.SecurityAttribute");
//
// Generic types
@@ -1323,11 +1270,6 @@ public class TypeManager {
system_asynccallback_expr.Type = asynccallback_type;
system_iasyncresult_expr.Type = iasyncresult_type;
system_valuetype_expr.Type = value_type;
//
// These are only used for compare purposes
//
anonymous_method_type = typeof (AnonymousMethod);
}
//
@@ -2002,48 +1944,6 @@ public class TypeManager {
return false;
}
public static bool IsPrivateAccessible (Type type, Type parent)
{
if (type.Equals (parent))
return true;
if ((type is TypeBuilder) && type.IsGenericTypeDefinition && parent.IsGenericInstance) {
//
// `a' is a generic type definition's TypeBuilder and `b' is a
// generic instance of the same type.
//
// Example:
//
// class Stack<T>
// {
// void Test (Stack<T> stack) { }
// }
//
// The first argument of `Test' will be the generic instance
// "Stack<!0>" - which is the same type than the "Stack" TypeBuilder.
//
//
// We hit this via Closure.Filter() for gen-82.cs.
//
if (type != parent.GetGenericTypeDefinition ())
return false;
return true;
}
if (type.IsGenericInstance && parent.IsGenericInstance) {
Type tdef = type.GetGenericTypeDefinition ();
Type pdef = parent.GetGenericTypeDefinition ();
if (type.GetGenericTypeDefinition () != parent.GetGenericTypeDefinition ())
return false;
return true;
}
return false;
}
public static bool IsFamilyAccessible (Type type, Type parent)
{
TypeParameter tparam = LookupTypeParameter (type);
@@ -2932,7 +2832,7 @@ public class TypeManager {
if (ma == MethodAttributes.Private)
return private_ok ||
IsPrivateAccessible (invocation_type, mb.DeclaringType) ||
IsEqual (invocation_type, mb.DeclaringType) ||
IsNestedChildOf (invocation_type, mb.DeclaringType);
//
@@ -2983,7 +2883,7 @@ public class TypeManager {
if (fa == FieldAttributes.Private)
return private_ok ||
IsPrivateAccessible (invocation_type, fi.DeclaringType) ||
IsEqual (invocation_type, fi.DeclaringType) ||
IsNestedChildOf (invocation_type, fi.DeclaringType);
//
@@ -3044,7 +2944,7 @@ public class TypeManager {
if (((qualifier_type == null) || (qualifier_type == invocation_type)) &&
(invocation_type != null) &&
IsPrivateAccessible (m.DeclaringType, invocation_type))
IsEqual (m.DeclaringType, invocation_type))
return true;
//
@@ -3206,10 +3106,8 @@ public class TypeManager {
// This happens with interfaces, they have a null
// basetype. Look members up in the Object class.
//
if (current_type == null) {
if (current_type == null)
current_type = TypeManager.object_type;
searching = true;
}
}
if (list.Length == 0)
@@ -3414,7 +3312,7 @@ public sealed class TypeHandle : IMemberContainer {
if (type.BaseType != null)
BaseType = GetTypeHandle (type.BaseType);
this.is_interface = type.IsInterface || type.IsGenericParameter;
this.member_cache = new MemberCache (this, true);
this.member_cache = new MemberCache (this);
}
// IMemberContainer methods
-5
View File
@@ -1,8 +1,3 @@
Tue Nov 9 17:29:28 CET 2004 Paolo Molaro <[email protected]>
* dis-cil.c, get.c, get.h: update to exception clause structure changes.
2004-11-08 Ben Maurer <[email protected]>
* get.c, dump.c: warning free.
+2 -2
View File
@@ -104,7 +104,7 @@ dissasemble_cil (MonoImage *m, MonoMethodHeader *mh)
fprintf (output, "\t%s} { // %d\n", indent, i);
} else {
char * klass = mh->clauses[i].flags ? g_strdup ("") :
dis_stringify_object_with_class (m, mh->clauses[i].data.catch_class);
dis_stringify_token (m, mh->clauses[i].token_or_filter);
fprintf (output, "\t%s%s %s { // %d\n", indent,
clause_names [mh->clauses[i].flags], klass, i);
g_free (klass);
@@ -113,7 +113,7 @@ dissasemble_cil (MonoImage *m, MonoMethodHeader *mh)
if (mh->clauses[i].flags == MONO_EXCEPTION_CLAUSE_FAULT)
in_fault = 1;
}
if (mh->clauses[i].flags == MONO_EXCEPTION_CLAUSE_FILTER && ptr == start + mh->clauses[i].data.filter_offset) {
if (mh->clauses[i].flags == 1 && ptr == start + mh->clauses[i].token_or_filter) {
fprintf (output, "\t%s%s {\n", indent, clause_names[1]);
CODE_INDENT;
}
+1 -1
View File
@@ -703,7 +703,7 @@ dis_stringify_function_ptr (MonoImage *m, MonoMethodSignature *method)
return retval;
}
char *
static char *
dis_stringify_object_with_class (MonoImage *m, MonoClass *c)
{
/* FIXME: handle MONO_TYPE_OBJECT ... */
-1
View File
@@ -8,7 +8,6 @@ char *get_moduleref (MonoImage *m, int idx);
char *get_assemblyref (MonoImage *m, int idx);
char *get_typeref (MonoImage *m, int idx);
char *get_typedef_or_ref (MonoImage *m, guint32 dor_token);
char *dis_stringify_object_with_class (MonoImage *m, MonoClass *c);
char *get_type_or_methdef (MonoImage *m, guint32 dor_token);
char *get_field_signature (MonoImage *m, guint32 blob_signature);
char *get_fieldref_signature (MonoImage *m, int idx);
-5
View File
@@ -1,8 +1,3 @@
Tue Nov 9 17:28:48 CET 2004 Paolo Molaro <[email protected]>
* interp.c: update to exception clause structure changes.
2004-11-08 Ben Maurer <[email protected]>
* interp.c: warning free
+1 -1
View File
@@ -3892,7 +3892,7 @@ array_constructed:
clause = &inv->runtime_method->clauses [i];
if (clause->flags <= 1 && MONO_OFFSET_IN_CLAUSE (clause, ip_offset)) {
if (!clause->flags) {
if (mono_object_isinst ((MonoObject*)frame->ex, clause->data.catch_class)) {
if (mono_object_isinst ((MonoObject*)frame->ex, mono_class_get (method->klass->image, clause->token_or_filter))) {
/*
* OK, we found an handler, now we need to execute the finally
* and fault blocks before branching to the handler code.
-57
View File
@@ -1,60 +1,3 @@
2004-11-09 Gonzalo Paniagua Javier <[email protected]>
* icall.c: use memmove in BlockCopyInternal when the source and
destination arrays are the same.
2004-11-09 Martin Baulig <[email protected]>
* class-internals.h (MonoGenericContainer): Removed `method' and
`signature', replaced them with `is_method' and `is_signature'
flags. Added `context'.
* loader.c (method_from_methodspec): Take a `MonoGenericContext *'
instead of a `MonoGenericContainer *'.
* metadata.c (mono_metadata_generic_param_equal): Removed the hack
for dynamic type parameters.
(mono_metadata_load_generic_params): Setup `container->context'.
* reflection.c (mono_reflection_setup_generic_class): Setup
`tb->generic_container->context'.
(do_mono_reflection_bind_generic_parameters): Use
mono_class_inflate_generic_type() to correctly inflate types,
rather than using our own hack just for MONO_TYPE_VAR.
2004-11-09 Martin Baulig <[email protected]>
* class.c (mono_class_inflate_generic_method): Small fix; don't
crash here.
* icall.c
(ves_icall_MonoType_GetGenericArguments): Don't ignore `byref' types.
(ves_icall_Type_get_IsGenericTypeDefinition): Likewise.
(ves_icall_Type_GetGenericTypeDefinition_impl): Likewise.
(ves_icall_Type_BindGenericParameters): Likewise.
(ves_icall_Type_get_IsGenericInstance): Likewise.
(ves_icall_Type_GetGenericParameterPosition): Likewise.
(ves_icall_MonoType_get_HasGenericArguments): Likewise.
(ves_icall_MonoType_get_IsGenericParameter): Likewise.
(ves_icall_MonoType_get_DeclaringMethod): Likewise.
2004-11-09 Zoltan Varga <[email protected]>
* assembly.c (mono_assembly_names_equal): Reenable the comparison of
assembly versions and public key tokens. Fixes #69113.
Tue Nov 9 17:34:05 CET 2004 Paolo Molaro <[email protected]>
* metadata.c: fix bug introduced with the type cache changes
on 2004-11-06.
Tue Nov 9 17:26:29 CET 2004 Paolo Molaro <[email protected]>
* metadata.h, metadata.c, domain-internals.h, marshal.c: include
the MonoClass pointer instead of the token in exception clauses.
* reflection.c: updates for the above and make the code not depend
on the structure of MonoExceptionClause.
2004-11-08 Zoltan Varga <[email protected]>
* icall.c (ves_icall_System_Reflection_Assembly_GetModulesInternal):
+15 -7
View File
@@ -132,17 +132,25 @@ mono_assembly_names_equal (MonoAssemblyName *l, MonoAssemblyName *r)
if (l->culture && r->culture && strcmp (l->culture, r->culture))
return FALSE;
/*
* simply compare names until some other issues are resolved
* (version info not getting set correctly for custom
* attributes).
*/
/*
if (l->major != r->major || l->minor != r->minor ||
l->build != r->build || l->revision != r->revision)
if (! ((l->major == 0 && l->minor == 0 && l->build == 0 && l->revision == 0) || (r->major == 0 && r->minor == 0 && r->build == 0 && r->revision == 0)))
return FALSE;
if (!l->public_key_token [0] || !r->public_key_token [0])
return TRUE;
if (strcmp (l->public_key_token, r->public_key_token))
return FALSE;
if (!l->public_tok_value && !r->public_tok_value)
return TRUE;
if ((l->public_tok_value && !r->public_tok_value) || (!l->public_tok_value && r->public_tok_value))
return FALSE;
if (strcmp (l->public_tok_value, r->public_tok_value))
return FALSE;
*/
return TRUE;
}
+3 -4
View File
@@ -339,11 +339,10 @@ struct _MonoGenericContext {
struct _MonoGenericContainer {
MonoGenericContainer *parent;
MonoGenericContext *context;
MonoClass *klass;
int type_argc : 6;
int is_method : 1;
int is_signature : 1;
MonoMethod *method;
MonoMethodSignature *signature;
int type_argc;
MonoGenericParam *type_params;
};
+7 -7
View File
@@ -398,7 +398,6 @@ mono_class_inflate_generic_method (MonoMethod *method, MonoGenericContext *conte
MonoClass *klass)
{
MonoMethodInflated *result;
MonoClass *rklass;
if ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
@@ -416,10 +415,11 @@ mono_class_inflate_generic_method (MonoMethod *method, MonoGenericContext *conte
mono_method_get_header (method), context);
if (klass)
rklass = result->nmethod.method.klass = klass;
result->nmethod.method.klass = klass;
else {
MonoType *declaring = mono_class_inflate_generic_type (&method->klass->byval_arg, context);
rklass = result->nmethod.method.klass = mono_class_from_mono_type (declaring);
MonoType *declaring = mono_class_inflate_generic_type (
&method->klass->byval_arg, context);
result->nmethod.method.klass = mono_class_from_mono_type (declaring);
}
result->nmethod.method.signature = inflate_generic_signature (
@@ -428,11 +428,11 @@ mono_class_inflate_generic_method (MonoMethod *method, MonoGenericContext *conte
if (context->gmethod) {
result->context = g_new0 (MonoGenericContext, 1);
result->context->gmethod = context->gmethod;
result->context->ginst = rklass->generic_inst;
result->context->ginst = result->nmethod.method.klass->generic_inst;
mono_stats.generics_metadata_size += sizeof (MonoGenericContext);
} else if (rklass->generic_inst)
result->context = rklass->generic_inst->context;
} else
result->context = result->nmethod.method.klass->generic_inst->context;
if (method->signature->is_inflated)
result->declaring = ((MonoMethodInflated *) method)->declaring;
+1 -1
View File
@@ -39,7 +39,7 @@ typedef struct {
gpointer try_end;
gpointer handler_start;
union {
MonoClass *catch_class;
guint32 token;
gpointer filter;
} data;
} MonoJitExceptionInfo;
+30 -5
View File
@@ -254,6 +254,12 @@ ves_icall_System_Array_SetValueImpl (MonoArray *this, MonoObject *value, guint32
vsize = mono_class_instance_size (vc) - sizeof (MonoObject);
#if 0
g_message (G_STRLOC ": %d (%d) <= %d (%d)",
ec->byval_arg.type, esize,
vc->byval_arg.type, vsize);
#endif
#define ASSIGN_UNSIGNED(etype) G_STMT_START{\
switch (vc->byval_arg.type) { \
case MONO_TYPE_U1: \
@@ -1746,7 +1752,9 @@ ves_icall_MonoType_GetGenericArguments (MonoReflectionType *type)
klass = mono_class_from_mono_type (type->type);
if (klass->generic_container) {
if (type->type->byref) {
res = mono_array_new (mono_object_domain (type), mono_defaults.monotype_class, 0);
} else if (klass->generic_container) {
MonoGenericContainer *container = klass->generic_container;
res = mono_array_new (mono_object_domain (type), mono_defaults.monotype_class, container->type_argc);
for (i = 0; i < container->type_argc; ++i) {
@@ -1771,6 +1779,8 @@ ves_icall_Type_get_IsGenericTypeDefinition (MonoReflectionType *type)
MonoClass *klass;
MONO_ARCH_SAVE_REGS;
if (type->type->byref)
return FALSE;
klass = mono_class_from_mono_type (type->type);
return klass->generic_container != NULL;
@@ -1782,6 +1792,8 @@ ves_icall_Type_GetGenericTypeDefinition_impl (MonoReflectionType *type)
MonoClass *klass;
MONO_ARCH_SAVE_REGS;
if (type->type->byref)
return NULL;
klass = mono_class_from_mono_type (type->type);
if (klass->generic_container) {
return type; /* check this one */
@@ -1806,6 +1818,9 @@ ves_icall_Type_BindGenericParameters (MonoReflectionType *type, MonoArray *type_
MONO_ARCH_SAVE_REGS;
if (type->type->byref)
return NULL;
count = mono_array_length (type_array);
types = g_new0 (MonoType *, count);
@@ -1825,6 +1840,8 @@ ves_icall_Type_get_IsGenericInstance (MonoReflectionType *type)
MonoClass *klass;
MONO_ARCH_SAVE_REGS;
if (type->type->byref)
return FALSE;
klass = mono_class_from_mono_type (type->type);
return klass->generic_inst != NULL;
}
@@ -1834,6 +1851,8 @@ ves_icall_Type_GetGenericParameterPosition (MonoReflectionType *type)
{
MONO_ARCH_SAVE_REGS;
if (type->type->byref)
return -1;
if (type->type->type == MONO_TYPE_VAR || type->type->type == MONO_TYPE_MVAR)
return type->type->data.generic_param->num;
return -1;
@@ -1877,6 +1896,8 @@ ves_icall_MonoType_get_HasGenericArguments (MonoReflectionType *type)
MonoClass *klass;
MONO_ARCH_SAVE_REGS;
if (type->type->byref)
return FALSE;
klass = mono_class_from_mono_type (type->type);
if (klass->generic_container || klass->generic_inst)
return TRUE;
@@ -1888,6 +1909,8 @@ ves_icall_MonoType_get_IsGenericParameter (MonoReflectionType *type)
{
MONO_ARCH_SAVE_REGS;
if (type->type->byref)
return FALSE;
if (type->type->type == MONO_TYPE_VAR || type->type->type == MONO_TYPE_MVAR)
return TRUE;
return FALSE;
@@ -1898,6 +1921,8 @@ ves_icall_TypeBuilder_get_IsGenericParameter (MonoReflectionTypeBuilder *tb)
{
MONO_ARCH_SAVE_REGS;
if (tb->type.type->byref)
return FALSE;
if (tb->type.type->type == MONO_TYPE_VAR || tb->type.type->type == MONO_TYPE_MVAR)
return TRUE;
return FALSE;
@@ -2129,6 +2154,9 @@ ves_icall_MonoType_get_DeclaringMethod (MonoReflectionType *type)
MONO_ARCH_SAVE_REGS;
if (type->type->byref)
return FALSE;
method = type->type->data.generic_param->method;
if (!method)
return NULL;
@@ -4858,10 +4886,7 @@ ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, Mo
src_buf = (gint8 *)src->vector + src_offset;
dest_buf = (gint8 *)dest->vector + dest_offset;
if (src != dest)
memcpy (dest_buf, src_buf, count);
else
memmove (dest_buf, src_buf, count); /* Source and dest are the same array */
memcpy (dest_buf, src_buf, count);
return TRUE;
}
+10 -21
View File
@@ -423,11 +423,11 @@ method_from_memberref (MonoImage *image, guint32 idx, MonoGenericContext *contex
}
static MonoMethod *
method_from_methodspec (MonoImage *image, MonoGenericContext *context, guint32 idx)
method_from_methodspec (MonoImage *image, MonoGenericContainer *generic_container, guint32 idx)
{
MonoMethod *method, *inflated;
MonoTableInfo *tables = image->tables;
MonoGenericContext *new_context = NULL;
MonoGenericContext *context;
MonoGenericMethod *gmethod;
MonoGenericContainer *container = NULL;
const char *ptr;
@@ -454,15 +454,9 @@ method_from_methodspec (MonoImage *image, MonoGenericContext *context, guint32 i
container = ((MonoMethodNormal *) ((MonoMethodInflated *) method)->declaring)->generic_container;
else
container = ((MonoMethodNormal *) method)->generic_container;
g_assert (container && container->is_method);
if (context) {
if (context->ginst) {
g_assert (context->ginst->container);
container->parent = context->ginst->container;
} else
container->parent = context->container;
}
g_assert (container && container->method);
if (generic_container)
container->parent = generic_container;
gmethod = g_new0 (MonoGenericMethod, 1);
gmethod->container = container;
@@ -477,20 +471,15 @@ method_from_methodspec (MonoImage *image, MonoGenericContext *context, guint32 i
gmethod->is_open = mono_class_is_open_constructed_type (gmethod->mtype_argv [i]);
}
if (!context) {
new_context = g_new0 (MonoGenericContext, 1);
new_context->gmethod = gmethod;
context = new_context;
}
context = g_new0 (MonoGenericContext, 1);
context->gmethod = gmethod;
mono_stats.generics_metadata_size += sizeof (MonoGenericMethod) +
sizeof (MonoGenericContext) + param_count * sizeof (MonoType);
inflated = mono_class_inflate_generic_method (method, context, NULL);
if (new_context)
context->ginst = inflated->klass->generic_inst;
context->ginst = inflated->klass->generic_inst;
return inflated;
}
@@ -805,7 +794,7 @@ mono_get_method_from_token (MonoImage *image, guint32 token, MonoClass *klass,
generic_container = context->container;
}
if (table == MONO_TABLE_METHODSPEC)
return method_from_methodspec (image, context, idx);
return method_from_methodspec (image, generic_container, idx);
if (table != MONO_TABLE_MEMBERREF)
g_print("got wrong token: 0x%08x\n", token);
g_assert (table == MONO_TABLE_MEMBERREF);
@@ -837,7 +826,7 @@ mono_get_method_from_token (MonoImage *image, guint32 token, MonoClass *klass,
generic_container = mono_metadata_load_generic_params (image, token);
if (generic_container) {
generic_container->parent = container;
generic_container->is_method = 1;
generic_container->method = result;
container = generic_container;
}
}
+1 -1
View File
@@ -2434,7 +2434,7 @@ handle_enum:
clause->try_len = mb->pos;
/* filter code */
clause->data.filter_offset = mb->pos;
clause->token_or_filter = mb->pos;
mono_mb_emit_byte (mb, CEE_POP);
mono_mb_emit_byte (mb, CEE_LDARG_2);
+24 -28
View File
@@ -1450,13 +1450,10 @@ mono_metadata_parse_method_signature_full (MonoImage *m, MonoGenericContainer *g
method->call_convention = call_convention;
method->generic_param_count = gen_param_count;
if (gen_param_count && (!generic_container || !generic_container->is_method)) {
if (gen_param_count && (!generic_container || !generic_container->method)) {
container = g_new0 (MonoGenericContainer, 1);
container->parent = generic_container;
container->is_signature = 1;
container->context = g_new0 (MonoGenericContext, 1);
container->context->container = container;
container->signature = method;
container->type_argc = gen_param_count;
container->type_params = g_new0 (MonoGenericParam, gen_param_count);
@@ -1626,12 +1623,12 @@ mono_metadata_parse_generic_param (MonoImage *m, MonoGenericContainer *generic_c
*/
generic_container = generic_container->parent;
}
g_assert (generic_container && !generic_container->is_method);
g_assert (generic_container && !generic_container->method);
g_assert (index < generic_container->type_argc);
return &generic_container->type_params [index];
} else {
g_assert (generic_container && (generic_container->is_method || generic_container->is_signature));
g_assert (generic_container && (generic_container->method || generic_container->signature));
g_assert (index < generic_container->type_argc);
return &generic_container->type_params [index];
@@ -1734,11 +1731,6 @@ mono_metadata_free_type (MonoType *type)
return;
switch (type->type){
case MONO_TYPE_OBJECT:
case MONO_TYPE_STRING:
if (!type->data.klass)
break;
/* fall through */
case MONO_TYPE_CLASS:
case MONO_TYPE_VALUETYPE:
if (type == &type->data.klass->byval_arg || type == &type->data.klass->this_arg)
@@ -1785,7 +1777,7 @@ hex_dump (const char *buffer, int base, int count)
* @ptr: Points to the beginning of the Section Data (25.3)
*/
static void
parse_section_data (MonoImage *m, MonoMethodHeader *mh, const unsigned char *ptr)
parse_section_data (MonoMethodHeader *mh, const unsigned char *ptr)
{
unsigned char sect_data_flags;
const unsigned char *sptr;
@@ -1823,8 +1815,9 @@ parse_section_data (MonoImage *m, MonoMethodHeader *mh, const unsigned char *ptr
mh->clauses = g_new0 (MonoExceptionClause, mh->num_clauses);
for (i = 0; i < mh->num_clauses; ++i) {
MonoExceptionClause *ec = &mh->clauses [i];
guint32 tof_value;
if (is_fat) {
/* we could memcpy and byteswap */
ec->flags = read32 (p);
p += 4;
ec->try_offset = read32 (p);
@@ -1835,7 +1828,7 @@ parse_section_data (MonoImage *m, MonoMethodHeader *mh, const unsigned char *ptr
p += 4;
ec->handler_len = read32 (p);
p += 4;
tof_value = read32 (p);
ec->token_or_filter = read32 (p);
p += 4;
} else {
ec->flags = read16 (p);
@@ -1848,16 +1841,9 @@ parse_section_data (MonoImage *m, MonoMethodHeader *mh, const unsigned char *ptr
p += 2;
ec->handler_len = *p;
++p;
tof_value = read32 (p);
ec->token_or_filter = read32 (p);
p += 4;
}
if (ec->flags == MONO_EXCEPTION_CLAUSE_FILTER) {
ec->data.filter_offset = tof_value;
} else if (ec->flags == MONO_EXCEPTION_CLAUSE_NONE) {
ec->data.catch_class = tof_value? mono_class_get (m, tof_value): 0;
} else {
ec->data.catch_class = NULL;
}
/* g_print ("try %d: %x %04x-%04x %04x\n", i, ec->flags, ec->try_offset, ec->try_offset+ec->try_len, ec->try_len); */
}
@@ -1972,7 +1958,7 @@ mono_metadata_parse_mh_full (MonoImage *m, MonoGenericContainer *generic_contain
mh->max_stack = max_stack;
mh->init_locals = init_locals;
if (fat_flags & METHOD_HEADER_MORE_SECTS)
parse_section_data (m, mh, (const unsigned char*)ptr);
parse_section_data (mh, (const unsigned char*)ptr);
return mh;
}
@@ -2708,6 +2694,16 @@ mono_metadata_generic_param_equal (MonoGenericParam *p1, MonoGenericParam *p2, g
if (p1->owner == p2->owner)
return TRUE;
/*
* This should only happen for dynamic type parameters; we copy them from the
* MonoReflectionGenericParam into the newly created MonoGenericContainer, so their
* addresses may be different.
*/
if (p1->owner->klass && (p1->owner->klass == p2->owner->klass))
return TRUE;
if (p1->owner->method && (p1->owner->method == p2->owner->method))
return TRUE;
/*
* If `signature_only' is true, we're comparing two (method) signatures.
* In this case, the owner of two type parameters doesn't need to match.
@@ -3600,6 +3596,7 @@ mono_metadata_load_generic_params (MonoImage *image, guint32 token)
guint32 cols [MONO_GENERICPARAM_SIZE];
guint32 i, owner = 0, last_num, n;
MonoGenericContainer *container;
MonoGenericContext *context;
MonoGenericParam *params;
if (mono_metadata_token_table (token) == MONO_TABLE_TYPEDEF)
@@ -3608,7 +3605,6 @@ mono_metadata_load_generic_params (MonoImage *image, guint32 token)
owner = MONO_TYPEORMETHOD_METHOD;
else {
g_error ("wrong token %x to load_generics_params", token);
return NULL;
}
owner |= mono_metadata_token_index (token) << MONO_TYPEORMETHOD_BITS;
if (!tdef->base)
@@ -3642,11 +3638,11 @@ mono_metadata_load_generic_params (MonoImage *image, guint32 token)
container->type_argc = n;
container->type_params = params;
container->context = g_new0 (MonoGenericContext, 1);
container->context->container = container;
context = g_new0 (MonoGenericContext, 1);
context->container = container;
for (i = 0; i < n; i++)
params [i].constraints = get_constraints (image, i + 1, container->context);
params [i].constraints = get_constraints (image, i + 1, context);
return container;
}
+1 -4
View File
@@ -268,10 +268,7 @@ typedef struct {
guint32 try_len;
guint32 handler_offset;
guint32 handler_len;
union {
guint32 filter_offset;
MonoClass *catch_class;
} data;
guint32 token_or_filter;
} MonoExceptionClause;
typedef struct _MonoType MonoType;
+27 -48
View File
@@ -873,11 +873,11 @@ method_encode_clauses (MonoDynamicImage *assembly, MonoReflectionILGen *ilgen, g
clause->try_len = ex_info->len;
clause->handler_offset = ex_block->start;
clause->handler_len = ex_block->len;
clause->token_or_filter = ex_block->extype ? mono_metadata_token_from_dor (
mono_image_typedef_or_ref (assembly, ex_block->extype->type)): 0;
if (ex_block->extype) {
clause->data.catch_class = mono_class_from_mono_type (ex_block->extype->type);
} else {
/* FIXME: handle filters */
clause->data.filter_offset = 0;
mono_g_hash_table_insert (assembly->tokens,
GUINT_TO_POINTER (clause->token_or_filter), ex_block->extype);
}
finally_start = ex_block->start + ex_block->len;
@@ -981,6 +981,7 @@ fat_header:
mono_image_add_stream_data (&assembly->code, mono_array_addr (code, char, 0), code_size);
if (num_exception) {
unsigned char sheader [4];
MonoExceptionClause clause;
MonoILExceptionInfo * ex_info;
MonoILExceptionBlock * ex_block;
int j;
@@ -988,7 +989,7 @@ fat_header:
stream_data_align (&assembly->code);
/* always use fat format for now */
sheader [0] = METHOD_HEADER_SECTION_FAT_FORMAT | METHOD_HEADER_SECTION_EHTABLE;
num_exception *= 6 * sizeof (guint32);
num_exception *= sizeof (MonoExceptionClause);
num_exception += 4; /* include the size of the header */
sheader [1] = num_exception & 0xff;
sheader [2] = (num_exception >> 8) & 0xff;
@@ -1001,37 +1002,23 @@ fat_header:
if (ex_info->handlers) {
int finally_start = ex_info->start + ex_info->len;
for (j = 0; j < mono_array_length (ex_info->handlers); ++j) {
guint32 val;
ex_block = (MonoILExceptionBlock*)mono_array_addr (ex_info->handlers, MonoILExceptionBlock, j);
/* the flags */
val = GUINT32_TO_LE (ex_block->type);
mono_image_add_stream_data (&assembly->code, (char*)&val, sizeof (guint32));
/* try offset */
val = GUINT32_TO_LE (ex_info->start);
mono_image_add_stream_data (&assembly->code, (char*)&val, sizeof (guint32));
clause.flags = GUINT32_TO_LE (ex_block->type);
clause.try_offset = GUINT32_TO_LE (ex_info->start);
/* need fault, too, probably */
if (ex_block->type == MONO_EXCEPTION_CLAUSE_FINALLY)
val = GUINT32_TO_LE (finally_start - ex_info->start);
clause.try_len = GUINT32_TO_LE (finally_start - ex_info->start);
else
val = GUINT32_TO_LE (ex_info->len);
mono_image_add_stream_data (&assembly->code, (char*)&val, sizeof (guint32));
/* handler offset */
val = GUINT32_TO_LE (ex_block->start);
mono_image_add_stream_data (&assembly->code, (char*)&val, sizeof (guint32));
/* handler len */
val = GUINT32_TO_LE (ex_block->len);
mono_image_add_stream_data (&assembly->code, (char*)&val, sizeof (guint32));
clause.try_len = GUINT32_TO_LE (ex_info->len);
clause.handler_offset = GUINT32_TO_LE (ex_block->start);
clause.handler_len = GUINT32_TO_LE (ex_block->len);
finally_start = ex_block->start + ex_block->len;
if (ex_block->extype) {
val = mono_metadata_token_from_dor (mono_image_typedef_or_ref (assembly, ex_block->extype->type));
} else {
/* FIXME: handle filters */
val = 0;
}
val = GUINT32_TO_LE (val);
mono_image_add_stream_data (&assembly->code, (char*)&val, sizeof (guint32));
clause.token_or_filter = ex_block->extype ? mono_metadata_token_from_dor (
mono_image_typedef_or_ref (assembly, ex_block->extype->type)): 0;
clause.token_or_filter = GUINT32_TO_LE (clause.token_or_filter);
/*g_print ("out clause %d: from %d len=%d, handler at %d, %d, finally_start=%d, ex_info->start=%d, ex_info->len=%d, ex_block->type=%d, j=%d, i=%d\n",
clause.flags, clause.try_offset, clause.try_len, clause.handler_offset, clause.handler_len, finally_start, ex_info->start, ex_info->len, ex_block->type, j, i);*/
mono_image_add_stream_data (&assembly->code, (char*)&clause, sizeof (clause));
}
} else {
g_error ("No clauses for ex info block %d", i);
@@ -7328,9 +7315,6 @@ mono_reflection_setup_generic_class (MonoReflectionTypeBuilder *tb)
tb->generic_container = g_new0 (MonoGenericContainer, 1);
tb->generic_container->klass = klass;
tb->generic_container->context = g_new0 (MonoGenericContext, 1);
tb->generic_container->context->container = tb->generic_container;
}
/*
@@ -7800,24 +7784,18 @@ do_mono_reflection_bind_generic_parameters (MonoReflectionType *type, int type_a
ginst = g_new0 (MonoGenericInst, 1);
ginst->type_argc = type_argc;
ginst->type_argv = types;
if (!klass->generic_inst) {
ginst->type_argc = type_argc;
ginst->type_argv = types;
for (i = 0; i < ginst->type_argc; ++i) {
if (!ginst->is_open)
ginst->is_open = mono_class_is_open_constructed_type (types [i]);
}
for (i = 0; i < ginst->type_argc; ++i) {
if (!ginst->is_open)
ginst->is_open = mono_class_is_open_constructed_type (types [i]);
}
ginst->generic_type = &klass->byval_arg;
if (klass->generic_inst) {
ginst->generic_type = &klass->byval_arg;
} else {
MonoGenericInst *kginst = klass->generic_inst;
MonoGenericInst *oginst = ginst;
oginst->context = g_new0 (MonoGenericContext, 1);
oginst->context->ginst = oginst;
ginst = g_new0 (MonoGenericInst, 1);
ginst->type_argc = kginst->type_argc;
ginst->type_argv = g_new0 (MonoType *, ginst->type_argc);
@@ -7825,7 +7803,8 @@ do_mono_reflection_bind_generic_parameters (MonoReflectionType *type, int type_a
for (i = 0; i < ginst->type_argc; i++) {
MonoType *t = kginst->type_argv [i];
t = mono_class_inflate_generic_type (t, oginst->context);
if (t->type == MONO_TYPE_VAR)
t = types [t->data.generic_param->num];
if (!ginst->is_open)
ginst->is_open = mono_class_is_open_constructed_type (t);
-21
View File
@@ -1,24 +1,3 @@
2004-11-10 Martin Baulig <martin@localhost>
* mini.c (mono_method_to_ir): Use `generic_container->context'
rather than creating a new one.
2004-11-09 Neale Ferguson <[email protected]>
* exceptions-s390.c, mini-s390, cpu-s390.md: Add support for OP_RETHROW.
* inssel-390.md, mini-s390.c: Correct register allocation for globals.
2004-11-09 Zoltan Varga <[email protected]>
* aot.c (mono_aot_init): Add MONO_AOT_CACHE env variable to turn on
the experimental aot cache stuff.
Tue Nov 9 17:30:20 CET 2004 Paolo Molaro <[email protected]>
* aot.c, mini.c, exceptions-ppc.c, exceptions-s390.c, exceptions-s390x.c,
mini-exceptions.c: update to exception clause structure changes.
2004-11-08 Zoltan Varga <[email protected]>
* exceptions-x86.c (throw_exception): Fix warnings.
+3 -7
View File
@@ -387,8 +387,6 @@ mono_aot_init (void)
if (getenv ("MONO_LASTAOT"))
mono_last_aot_method = atoi (getenv ("MONO_LASTAOT"));
if (getenv ("MONO_AOT_CACHE"))
use_aot_cache = TRUE;
}
static MonoJitInfo *
@@ -471,8 +469,6 @@ mono_aot_get_method_inner (MonoDomain *domain, MonoMethod *method)
if (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER)
ei->data.filter = (guint8*)ei->data.filter + offset;
else
ei->data.catch_class = header->clauses [i].data.catch_class;
ei->try_start = (guint8*)ei->try_start + offset;
ei->try_end = (guint8*)ei->try_end + offset;
ei->handler_start = (guint8*)ei->handler_start + offset;
@@ -564,7 +560,7 @@ mono_aot_load_method (MonoDomain *domain, MonoAotModule *aot_module, MonoMethod
if (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER)
ei->data.filter = code + *(guint32*)info;
else
ei->data.catch_class = ec->data.catch_class;
ei->data.token = *(guint32*)info;
info += 4;
ei->try_start = code + *(guint32*)info;
info += 4;
@@ -1069,8 +1065,8 @@ emit_method (MonoAotCompile *acfg, MonoCompile *cfg)
if (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER)
fprintf (tmpfp, "\t.long %d\n", (gint)((guint8*)ei->data.filter - code));
else
/* the class is loaded from the header: optimize away later */
fprintf (tmpfp, "\t.long %d\n", 0);
/* fixme: tokens are not global */
fprintf (tmpfp, "\t.long %d\n", ei->data.token);
fprintf (tmpfp, "\t.long %d\n", (gint)((guint8*)ei->try_start - code));
fprintf (tmpfp, "\t.long %d\n", (gint)((guint8*)ei->try_end - code));
+1 -1
View File
@@ -446,7 +446,7 @@ rem_un_imm: dest:i src1:i src2:i len:24
rename:
ret:
retarg:
rethrow: src1:i len:8
rethrow:
s390_move: len:48 dest:b src1:b
s390_setf4ret: dest:f src1:f len:4 clob:r
sbb: dest:i src1:i src2:i len:6
+1 -1
View File
@@ -941,7 +941,7 @@ arch_handle_exception (MonoContext *ctx, gpointer obj, gboolean test_only)
filtered = call_filter (ctx, ei->data.filter, mono_ex);
if ((ei->flags == MONO_EXCEPTION_CLAUSE_NONE &&
mono_object_isinst (obj, ei->data.catch_class)) || filtered) {
mono_object_isinst (obj, mono_class_get (ji->method->klass->image, ei->data.token))) || filtered) {
if (test_only) {
if (mono_ex) {
trace_ips = g_list_reverse (trace_ips);
+10 -42
View File
@@ -42,8 +42,7 @@
#define S390_THROWSTACK_ACCPRM S390_MINIMAL_STACK_SIZE
#define S390_THROWSTACK_FPCPRM S390_THROWSTACK_ACCPRM+sizeof(gpointer)
#define S390_THROWSTACK_RETHROW S390_THROWSTACK_FPCPRM+sizeof(gulong)
#define S390_THROWSTACK_INTREGS S390_THROWSTACK_RETHROW+sizeof(gboolean)
#define S390_THROWSTACK_INTREGS S390_THROWSTACK_FPCPRM+sizeof(gulong)
#define S390_THROWSTACK_FLTREGS S390_THROWSTACK_INTREGS+(16*sizeof(gulong))
#define S390_THROWSTACK_ACCREGS S390_THROWSTACK_FLTREGS+(16*sizeof(gdouble))
#define S390_THROWSTACK_SIZE (S390_THROWSTACK_ACCREGS+(16*sizeof(gulong)))
@@ -259,8 +258,7 @@ arch_get_call_filter (void)
static void
throw_exception (MonoObject *exc, unsigned long ip, unsigned long sp,
gulong *int_regs, gdouble *fp_regs, gulong *acc_regs,
guint fpc, gboolean rethrow)
gulong *int_regs, gdouble *fp_regs, gulong *acc_regs, guint fpc)
{
static void (*restore_context) (MonoContext *);
MonoContext ctx;
@@ -286,8 +284,7 @@ throw_exception (MonoObject *exc, unsigned long ip, unsigned long sp,
if (mono_object_isinst (exc, mono_defaults.exception_class)) {
MonoException *mono_ex = (MonoException*)exc;
if (!rethrow)
mono_ex->stack_trace = NULL;
mono_ex->stack_trace = NULL;
}
mono_arch_handle_exception (&ctx, exc, FALSE);
setcontext(&ctx);
@@ -299,7 +296,7 @@ throw_exception (MonoObject *exc, unsigned long ip, unsigned long sp,
/*------------------------------------------------------------------*/
/* */
/* Name - get_throw_exception_generic */
/* Name - arch_get_throw_exception_generic */
/* */
/* Function - Return a function pointer which can be used to */
/* raise exceptions. The returned function has the */
@@ -310,8 +307,7 @@ throw_exception (MonoObject *exc, unsigned long ip, unsigned long sp,
/*------------------------------------------------------------------*/
static gpointer
get_throw_exception_generic (guint8 *start, int size,
int by_name, gboolean rethrow)
mono_arch_get_throw_exception_generic (guint8 *start, int size, int by_name)
{
guint8 *code;
int alloc_size, pos, i, offset;
@@ -371,8 +367,6 @@ get_throw_exception_generic (guint8 *start, int size,
s390_la (code, s390_r7, 0, STK_BASE, S390_THROWSTACK_ACCREGS);
s390_st (code, s390_r7, 0, STK_BASE, S390_THROWSTACK_ACCPRM);
s390_stfpc(code, STK_BASE, S390_THROWSTACK_FPCPRM);
s390_lhi (code, s390_r7, rethrow);
s390_st (code, s390_r7, 0, STK_BASE, S390_THROWSTACK_RETHROW);
offset = (guint32) S390_RELATIVE(throw_exception, code);
s390_brasl(code, s390_r14, offset);
/* we should never reach this breakpoint */
@@ -397,38 +391,12 @@ get_throw_exception_generic (guint8 *start, int size,
gpointer
mono_arch_get_throw_exception (void)
{
static guint8 start [384];
static guint8 start [256];
static int inited = 0;
if (inited)
return start;
get_throw_exception_generic (start, sizeof (start), FALSE, FALSE);
inited = 1;
return start;
}
/*========================= End of Function ========================*/
/*------------------------------------------------------------------*/
/* */
/* Name - arch_get_rethrow_exception */
/* */
/* Function - Return a function pointer which can be used to */
/* raise exceptions. The returned function has the */
/* following signature: */
/* void (*func) (MonoException *exc); */
/* */
/*------------------------------------------------------------------*/
gpointer
mono_arch_get_rethrow_exception (void)
{
static guint8 start [384];
static int inited = 0;
if (inited)
return start;
get_throw_exception_generic (start, sizeof (start), FALSE, TRUE);
mono_arch_get_throw_exception_generic (start, sizeof (start), FALSE);
inited = 1;
return start;
}
@@ -449,12 +417,12 @@ mono_arch_get_rethrow_exception (void)
gpointer
mono_arch_get_throw_exception_by_name (void)
{
static guint8 start [384];
static guint8 start [160];
static int inited = 0;
if (inited)
return start;
get_throw_exception_generic (start, sizeof (start), TRUE, FALSE);
mono_arch_get_throw_exception_generic (start, sizeof (start), TRUE);
inited = 1;
return start;
}
@@ -902,7 +870,7 @@ mono_arch_handle_exception (void *uc, gpointer obj, gboolean test_only)
filtered = call_filter (ctx, ei->data.filter, obj);
if ((ei->flags == MONO_EXCEPTION_CLAUSE_NONE) &&
(mono_object_isinst (obj, ei->data.catch_class)) ||
(mono_object_isinst (obj, mono_class_get (ji->method->klass->image, ei->data.token))) ||
(filtered)) {
if (test_only) {
if (mono_ex) {
+1 -1
View File
@@ -1030,7 +1030,7 @@ mono_arch_handle_exception (void *uc, gpointer obj, gboolean test_only)
MONO_CONTEXT_GET_IP (ctx) <= ei->try_end) {
/* catch block */
if ((ei->flags == MONO_EXCEPTION_CLAUSE_NONE &&
mono_object_isinst (obj, ei->data.catch_class)) ||
mono_object_isinst (obj, mono_class_get (ji->method->klass->image, ei->data.token))) ||
((ei->flags == MONO_EXCEPTION_CLAUSE_FILTER &&
call_filter (ctx, ei->data.filter, obj)))) {
if (test_only) {
+4 -7
View File
@@ -585,9 +585,8 @@ base: OP_S390_STKARG "0" {
int tmpr;
tmpr = mono_regstate_next_int (s->rs);
// MONO_EMIT_NEW_BIALU_IMM (s, OP_ADD_IMM, tmpr, s->frame_reg,
// (s->stack_offset+state->tree->unused));
MONO_EMIT_NEW_LOAD_MEMBASE (s, tmpr, s->frame_reg, 0);
MONO_EMIT_NEW_BIALU_IMM (s, OP_ADD_IMM, tmpr, s->frame_reg,
(s->stack_offset+state->tree->unused));
tree->inst_offset = state->tree->inst_offset;
tree->inst_basereg = tmpr;
}
@@ -615,11 +614,9 @@ base: OP_LDADDR (OP_S390_ARGPTR) "0" {
base: OP_LDADDR (OP_S390_STKARG) "0" {
int tmpr;
printf("OP_LDADDR (OP_S390_STKARG)\n");
tmpr = mono_regstate_next_int (s->rs);
// MONO_EMIT_NEW_BIALU_IMM (s, OP_ADD_IMM, tmpr, s->frame_reg,
// (s->stack_offset + state->left->tree->unused));
MONO_EMIT_NEW_LOAD_MEMBASE (s, tmpr, s->frame_reg, 0);
MONO_EMIT_NEW_BIALU_IMM (s, OP_ADD_IMM, tmpr, s->frame_reg,
(s->stack_offset + state->left->tree->unused));
MONO_EMIT_NEW_BIALU_IMM (s, OP_ADD_IMM, tmpr, tmpr,
state->left->tree->inst_offset);
tree->inst_offset = 0;
+1 -6
View File
@@ -63,7 +63,7 @@ mono_varlist_sort (MonoCompile *cfg, GList *list, int sort_type)
return NULL;
}
// #define DEBUG_LSCAN
//#define DEBUG_LSCAN
void
mono_linear_scan (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_mask)
@@ -209,11 +209,6 @@ mono_linear_scan (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_ma
*used_mask |= used_regs;
#ifdef DEBUG_LSCAN
if (cfg->verbose_level > 2)
printf ("EXIT: final used mask: %08x\n", *used_mask);
#endif
g_list_free (regs);
g_list_free (active);
g_list_free (vars);
+1 -1
View File
@@ -440,7 +440,7 @@ mono_handle_exception (MonoContext *ctx, gpointer obj, gpointer original_ip, gbo
}
if ((ei->flags == MONO_EXCEPTION_CLAUSE_NONE &&
mono_object_isinst (obj, ei->data.catch_class)) || filtered) {
mono_object_isinst (obj, mono_class_get (ji->method->klass->image, ei->data.token))) || filtered) {
if (test_only) {
if (mono_ex) {
trace_ips = g_list_reverse (trace_ips);
+72 -83
View File
@@ -98,19 +98,19 @@ if (ins->flags & MONO_INST_BRLABEL) { \
#undef DEBUG
#define DEBUG(a) if (cfg->verbose_level > 1) a
/*----------------------------------------*/
/* use s390_r2-s390_r5 as temp registers */
/*----------------------------------------*/
#define S390_CALLER_REGS (0x10fc)
#define reg_is_freeable(r) (S390_CALLER_REGS & 1 << (r))
/*----------------------------------------*/
/* use s390_f1/s390_f3-s390_f15 as temps */
/*----------------------------------------*/
#define S390_CALLER_FREGS (0xfffa)
#define reg_is_freeable(r) ((r) >= 3 && (r) <= 10)
#define freg_is_freeable(r) ((r) >= 1 && (r) <= 14)
/*----------------------------------------*/
/* use s390_r3-s390_r10 as temp registers */
/*----------------------------------------*/
#define S390_CALLER_REGS (0x03f8)
/*----------------------------------------*/
/* use s390_f2-s390_f14 as temp registers */
/*----------------------------------------*/
#define S390_CALLER_FREGS (0x73f8)
#define S390_TRACE_STACK_SIZE (5*sizeof(gint32)+3*sizeof(gdouble))
/*========================= End of Defines =========================*/
@@ -930,11 +930,8 @@ mono_arch_cpu_optimizazions (guint32 *exclude_mask)
{
guint32 opts = 0;
/*----------------------------------------------------------*/
/* no s390-specific optimizations yet */
/*----------------------------------------------------------*/
/* no s390-specific optimizations yet */
*exclude_mask = MONO_OPT_INLINE|MONO_OPT_LINEARS;
// *exclude_mask = MONO_OPT_INLINE;
return opts;
}
@@ -1024,12 +1021,10 @@ GList *
mono_arch_get_global_int_regs (MonoCompile *cfg)
{
GList *regs = NULL;
int i, top = 13;
int i, top = 12;
for (i = 8; i < top; ++i) {
if (cfg->frame_reg != i)
regs = g_list_prepend (regs, GUINT_TO_POINTER (i));
}
for (i = 3; i < top; ++i)
regs = g_list_prepend (regs, GUINT_TO_POINTER (i));
return regs;
}
@@ -1362,7 +1357,7 @@ enum_retvalue:
/*------------------------------------------------------------------*/
void
mono_arch_allocate_vars (MonoCompile *cfg)
mono_arch_allocate_vars (MonoCompile *m)
{
MonoMethodSignature *sig;
MonoMethodHeader *header;
@@ -1373,7 +1368,7 @@ mono_arch_allocate_vars (MonoCompile *cfg)
int frame_reg = STK_BASE;
int sArg, eArg;
header = mono_method_get_header (cfg->method);
header = mono_method_get_header (m->method);
/*---------------------------------------------------------*/
/* We use the frame register also for any method that has */
@@ -1385,29 +1380,29 @@ mono_arch_allocate_vars (MonoCompile *cfg)
/* before stack unwinding happens) when the filter code */
/* would call any method. */
/*---------------------------------------------------------*/
if ((cfg->flags & MONO_CFG_HAS_ALLOCA) || header->num_clauses)
if ((m->flags & MONO_CFG_HAS_ALLOCA) || header->num_clauses)
frame_reg = s390_r11;
cfg->frame_reg = frame_reg;
m->frame_reg = frame_reg;
if (frame_reg != STK_BASE)
cfg->used_int_regs |= 1 << frame_reg;
m->used_int_regs |= 1 << frame_reg;
sig = cfg->method->signature;
sig = m->method->signature;
cinfo = calculate_sizes (sig, &sz, sig->pinvoke);
if (cinfo->struct_ret) {
cfg->ret->opcode = OP_REGVAR;
cfg->ret->inst_c0 = s390_r2;
m->ret->opcode = OP_REGVAR;
m->ret->inst_c0 = s390_r2;
} else {
/* FIXME: handle long and FP values */
switch (sig->ret->type) {
case MONO_TYPE_VOID:
break;
default:
cfg->ret->opcode = OP_REGVAR;
cfg->ret->dreg = s390_r2;
m->ret->opcode = OP_REGVAR;
m->ret->dreg = s390_r2;
break;
}
}
@@ -1419,10 +1414,10 @@ mono_arch_allocate_vars (MonoCompile *cfg)
/* to point at the local variables. */
/* add parameter area size for called functions */
/*--------------------------------------------------------------*/
offset = (cfg->param_area + S390_MINIMAL_STACK_SIZE);
offset = (m->param_area + S390_MINIMAL_STACK_SIZE);
if (cinfo->struct_ret) {
inst = cfg->ret;
inst = m->ret;
offset = S390_ALIGN(offset, sizeof(gpointer));
inst->inst_offset = offset;
inst->opcode = OP_REGOFFSET;
@@ -1431,7 +1426,7 @@ mono_arch_allocate_vars (MonoCompile *cfg)
}
if (sig->hasthis) {
inst = cfg->varinfo [0];
inst = m->varinfo [0];
if (inst->opcode != OP_REGVAR) {
inst->opcode = OP_REGOFFSET;
inst->inst_basereg = frame_reg;
@@ -1447,7 +1442,7 @@ mono_arch_allocate_vars (MonoCompile *cfg)
eArg = sig->param_count + sArg;
for (iParm = sArg; iParm < eArg; ++iParm) {
inst = cfg->varinfo [curinst];
inst = m->varinfo [curinst];
if (inst->opcode != OP_REGVAR) {
switch (cinfo->args[iParm].regtype) {
case RegTypeStructByAddr :
@@ -1490,11 +1485,10 @@ mono_arch_allocate_vars (MonoCompile *cfg)
curinst++;
}
curinst = cfg->locals_start;
for (iVar = curinst; iVar < cfg->num_varinfo; ++iVar) {
inst = cfg->varinfo [iVar];
if ((inst->flags & MONO_INST_IS_DEAD) ||
(inst->opcode == OP_REGVAR))
curinst = m->locals_start;
for (iVar = curinst; iVar < m->num_varinfo; ++iVar) {
inst = m->varinfo [iVar];
if (inst->opcode == OP_REGVAR)
continue;
/*--------------------------------------------------*/
@@ -1512,25 +1506,25 @@ mono_arch_allocate_vars (MonoCompile *cfg)
inst->opcode = OP_REGOFFSET;
inst->inst_basereg = frame_reg;
offset += size;
DEBUG (g_print("allocating local %d to %d\n", iVar, inst->inst_offset));
//DEBUG (g_print("allocating local %d to %d\n", iVar, inst->inst_offset));
}
/*------------------------------------------------------*/
/* Allow space for the trace method stack area if needed*/
/*------------------------------------------------------*/
if (mono_jit_trace_calls != NULL && mono_trace_eval (cfg))
if (mono_jit_trace_calls != NULL && mono_trace_eval (m))
offset += S390_TRACE_STACK_SIZE;
/*------------------------------------------------------*/
/* Reserve space to save LMF and caller saved registers */
/*------------------------------------------------------*/
if (cfg->method->save_lmf)
if (m->method->save_lmf)
offset += sizeof (MonoLMF);
/*------------------------------------------------------*/
/* align the offset */
/*------------------------------------------------------*/
cfg->stack_offset = S390_ALIGN(offset, S390_STACK_ALIGNMENT);
m->stack_offset = S390_ALIGN(offset, S390_STACK_ALIGNMENT);
}
@@ -1574,7 +1568,7 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb,
cfg->flags |= MONO_CFG_HAS_CALLS;
if (cinfo->struct_ret)
call->used_iregs |= 1 << cinfo->ret.reg;
call->used_iregs |= 1 << cinfo->struct_ret;
for (i = 0; i < n; ++i) {
ainfo = cinfo->args + i;
@@ -2585,10 +2579,10 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
while (ins) {
spec = ins_spec [ins->opcode];
DEBUG (print_ins (i, ins));
// if (spec [MONO_INST_CLOB] == 'c') {
// MonoCallInst * call = (MonoCallInst*)ins;
// int j;
// }
if (spec [MONO_INST_CLOB] == 'c') {
MonoCallInst * call = (MonoCallInst*)ins;
int j;
}
if (spec [MONO_INST_SRC1]) {
if (spec [MONO_INST_SRC1] == 'f')
reginfo1 = reginfof;
@@ -2621,7 +2615,7 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
if (reginfod [ins->dreg].born_in == 0 || reginfod [ins->dreg].born_in > i)
reginfod [ins->dreg].born_in = i;
if (spec [MONO_INST_DEST] == 'l') {
/* result in R2/R3, the virtual register is allocated sequentially */
/* result in eax:edx, the virtual register is allocated sequentially */
reginfod [ins->dreg + 1].prev_use = reginfod [ins->dreg + 1].last_use;
reginfod [ins->dreg + 1].last_use = i;
if (reginfod [ins->dreg + 1].born_in == 0 || reginfod [ins->dreg + 1].born_in > i)
@@ -2770,10 +2764,7 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
create_copy_ins (cfg, ins->dreg, s390_r3, ins);
}
}
if (reg_is_freeable (val) &&
hreg >= 0 &&
(reginfo [hreg].born_in >= i &&
!(cur_iregs & (1 << val)))) {
if (reg_is_freeable (val) && hreg >= 0 && (reginfo [hreg].born_in >= i && !(cur_iregs & (1 << val)))) {
DEBUG (g_print ("\tfreeable %s (R%d)\n", mono_arch_regname (val), hreg));
mono_regstate_free_int (rs, val);
}
@@ -2806,6 +2797,7 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
/* the register gets spilled after this inst */
spill = -val -1;
}
//g_assert (val == -1); /* source cannot be spilled */
val = mono_regstate_alloc_float (rs, src1_mask);
if (val < 0)
val = get_float_register_spilling (cfg, tmp, ins, src1_mask, ins->sreg1);
@@ -2930,6 +2922,16 @@ mono_arch_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb)
}
}
}
/*if (reg_is_freeable (ins->sreg1) && prev_sreg1 >= 0 && reginfo [prev_sreg1].born_in >= i) {
DEBUG (g_print ("freeable %s\n", mono_arch_regname (ins->sreg1)));
mono_regstate_free_int (rs, ins->sreg1);
}
if (reg_is_freeable (ins->sreg2) && prev_sreg2 >= 0 && reginfo [prev_sreg2].born_in >= i) {
DEBUG (g_print ("freeable %s\n", mono_arch_regname (ins->sreg2)));
mono_regstate_free_int (rs, ins->sreg2);
}*/
//DEBUG (print_ins (i, ins));
tmp = tmp->next;
}
}
@@ -3065,49 +3067,49 @@ guint8 cond;
switch (ins->opcode) {
case OP_STOREI1_MEMBASE_IMM: {
s390_lhi (code, s390_r0, ins->inst_imm);
s390_lhi (code, s390_r14, ins->inst_imm);
if (s390_is_uimm12(ins->inst_offset))
s390_stc (code, s390_r0, 0, ins->inst_destbasereg, ins->inst_offset);
s390_stc (code, s390_r14, 0, ins->inst_destbasereg, ins->inst_offset);
else {
s390_basr (code, s390_r13, 0);
s390_j (code, 4);
s390_word (code, ins->inst_offset);
s390_l (code, s390_r13, 0, s390_r13, 4);
s390_stc (code, s390_r0, s390_r13, ins->inst_destbasereg, 0);
s390_stc (code, s390_r14, s390_r13, ins->inst_destbasereg, 0);
}
}
break;
case OP_STOREI2_MEMBASE_IMM: {
s390_lhi (code, s390_r0, ins->inst_imm);
s390_lhi (code, s390_r14, ins->inst_imm);
if (s390_is_uimm12(ins->inst_offset)) {
s390_sth (code, s390_r0, 0, ins->inst_destbasereg, ins->inst_offset);
s390_sth (code, s390_r14, 0, ins->inst_destbasereg, ins->inst_offset);
} else {
s390_basr (code, s390_r13, 0);
s390_j (code, 4);
s390_word (code, ins->inst_offset);
s390_l (code, s390_r13, 0, s390_r13, 4);
s390_sth (code, s390_r0, s390_r13, ins->inst_destbasereg, 0);
s390_sth (code, s390_r14, s390_r13, ins->inst_destbasereg, 0);
}
}
break;
case OP_STORE_MEMBASE_IMM:
case OP_STOREI4_MEMBASE_IMM: {
if (s390_is_imm16(ins->inst_imm)) {
s390_lhi (code, s390_r0, ins->inst_imm);
s390_lhi (code, s390_r14, ins->inst_imm);
} else {
s390_basr (code, s390_r13, 0);
s390_j (code, 4);
s390_word (code, ins->inst_imm);
s390_l (code, s390_r0, 0, s390_r13, 4);
s390_l (code, s390_r14, 0, s390_r13, 4);
}
if (s390_is_uimm12(ins->inst_offset)) {
s390_st (code, s390_r0, 0, ins->inst_destbasereg, ins->inst_offset);
s390_st (code, s390_r14, 0, ins->inst_destbasereg, ins->inst_offset);
} else {
s390_basr (code, s390_r13, 0);
s390_j (code, 4);
s390_word (code, ins->inst_offset);
s390_l (code, s390_r13, 0, s390_r13, 4);
s390_st (code, s390_r0, s390_r13, ins->inst_destbasereg, 0);
s390_st (code, s390_r14, s390_r13, ins->inst_destbasereg, 0);
}
}
break;
@@ -3795,16 +3797,16 @@ guint8 cond;
break;
case OP_LMUL: {
s390_l (code, s390_r0, 0, ins->sreg1, 4);
s390_lr (code, s390_r14, s390_r0);
s390_srda (code, s390_r0, 0, 32);
s390_m (code, s390_r0, 0, ins->sreg2, 4);
s390_l (code, s390_r0, 0, ins->sreg1, 4);
s390_srl (code, s390_r0, 0, 31);
s390_a (code, s390_r0, 0, ins->sreg1, 0);
s390_srl (code, s390_r14, 0, 31);
s390_a (code, s390_r14, 0, ins->sreg1, 0);
s390_l (code, s390_r13, 0, ins->sreg2, 0);
s390_srl (code, s390_r13, 0, 31);
s390_ms (code, s390_r13, 0, ins->sreg1, 4);
s390_ar (code, s390_r0, s390_r13);
s390_st (code, s390_r0, 0, ins->dreg, 0);
s390_ar (code, s390_r14, s390_r13);
s390_st (code, s390_r14, 0, ins->dreg, 0);
s390_st (code, s390_r1, 0, ins->dreg, 4);
}
break;
@@ -3989,13 +3991,6 @@ guint8 cond;
s390_brasl (code, s390_r14, 0);
}
break;
case CEE_RETHROW: {
s390_lr (code, s390_r2, ins->sreg1);
mono_add_patch_info (cfg, code-cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD,
(gpointer)"mono_arch_rethrow_exception");
s390_brasl (code, s390_r14, 0);
}
break;
case OP_START_HANDLER: {
if (s390_is_uimm12 (ins->inst_left->inst_offset)) {
s390_st (code, s390_r14, 0,
@@ -4448,7 +4443,6 @@ guint8 cond;
s390_word (code, ins->inst_offset);
s390_a (code, s390_r0, 0, s390_r13, 4);
}
s390_lr (code, s390_r14, s390_r12);
s390_lr (code, s390_r12, ins->sreg1);
if (s390_is_imm16 (ins->inst_imm)) {
s390_ahi (code, s390_r12, ins->inst_imm);
@@ -4462,7 +4456,6 @@ guint8 cond;
s390_lr (code, s390_r13, s390_r1);
s390_mvcle(code, s390_r0, s390_r12, 0, 0);
s390_jo (code, -2);
s390_lr (code, s390_r12, s390_r14);
}
}
}
@@ -5252,15 +5245,11 @@ mono_arch_print_tree (MonoInst *tree, int arity)
switch (tree->opcode) {
case OP_S390_LOADARG:
case OP_S390_ARGPTR:
case OP_S390_STKARG:
printf ("[0x%x(%s)]", tree->inst_offset,
mono_arch_regname (tree->inst_basereg));
done = 1;
break;
case OP_S390_STKARG:
printf ("[0x%x(previous_frame)]",
tree->inst_offset);
done = 1;
break;
case OP_S390_MOVE:
printf ("[0x%x(%d,%s),0x%x(%s)]",
tree->inst_offset, tree->unused,
@@ -5297,7 +5286,7 @@ guint32
mono_arch_regalloc_cost (MonoCompile *cfg, MonoMethodVar *vmv)
{
/* FIXME: */
return 2;
return 3;
}
/*========================= End of Function ========================*/
+12 -10
View File
@@ -686,8 +686,8 @@ mono_find_block_region (MonoCompile *cfg, int offset, int *filter_lengths)
/* first search for handlers and filters */
for (i = 0; i < header->num_clauses; ++i) {
clause = &header->clauses [i];
if ((clause->flags == MONO_EXCEPTION_CLAUSE_FILTER) && (offset >= clause->data.filter_offset) &&
(offset < (clause->data.filter_offset + filter_lengths [i])))
if ((clause->flags & MONO_EXCEPTION_CLAUSE_FILTER) && (offset >= clause->token_or_filter) &&
(offset < (clause->token_or_filter + filter_lengths [i])))
return ((i + 1) << 8) | MONO_REGION_FILTER | clause->flags;
if (MONO_OFFSET_IN_HANDLER (clause, offset)) {
@@ -2803,8 +2803,10 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (method->signature->is_inflated)
generic_context = ((MonoMethodInflated *) method)->context;
else if (generic_container)
generic_context = generic_container->context;
else if (generic_container) {
generic_context = g_new0 (MonoGenericContext, 1);
generic_context->container = generic_container;
}
if (cfg->method == method) {
real_offset = 0;
@@ -2881,8 +2883,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
tblock->in_stack [0] = cfg->exvar;
if (clause->flags == MONO_EXCEPTION_CLAUSE_FILTER) {
GET_BBLOCK (cfg, bbhash, tblock, ip + clause->data.filter_offset);
tblock->real_offset = clause->data.filter_offset;
GET_BBLOCK (cfg, bbhash, tblock, ip + clause->token_or_filter);
tblock->real_offset = clause->token_or_filter;
tblock->in_scount = 1;
tblock->in_stack = mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*));
tblock->in_stack [0] = cfg->exvar;
@@ -5583,13 +5585,13 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
for (cc = 0; cc < header->num_clauses; ++cc) {
clause = &header->clauses [cc];
if ((clause->flags & MONO_EXCEPTION_CLAUSE_FILTER) &&
(!nearest || (clause->data.filter_offset > nearest->data.filter_offset))) {
(!nearest || (clause->token_or_filter > nearest->token_or_filter))) {
nearest = clause;
nearest_num = cc;
}
}
g_assert (nearest);
filter_lengths [nearest_num] = (ip - header->code) - nearest->data.filter_offset;
filter_lengths [nearest_num] = (ip - header->code) - nearest->token_or_filter;
break;
}
@@ -7847,11 +7849,11 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, gbool
ei->flags = ec->flags;
if (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER) {
tblock = g_hash_table_lookup (cfg->bb_hash, ip + ec->data.filter_offset);
tblock = g_hash_table_lookup (cfg->bb_hash, ip + ec->token_or_filter);
g_assert (tblock);
ei->data.filter = cfg->native_code + tblock->native_offset;
} else {
ei->data.catch_class = ec->data.catch_class;
ei->data.token = ec->token_or_filter;
}
tblock = g_hash_table_lookup (cfg->bb_hash, ip + ec->try_offset);
+5 -13
View File
@@ -169,8 +169,6 @@ s390_magic_trampoline (MonoMethod *method, guchar *code, char *sp)
int reg, base;
unsigned short opcode;
char *fname;
MonoJitInfo *codeJi,
*addrJi;
addr = mono_compile_method(method);
g_assert(addr);
@@ -181,9 +179,7 @@ s390_magic_trampoline (MonoMethod *method, guchar *code, char *sp)
/* The top bit needs to be ignored on S/390 */
(guint32) code &= 0x7fffffff;
fname = mono_method_full_name (method, TRUE);
codeJi = mono_jit_info_table_find (mono_domain_get(), code);
addrJi = mono_jit_info_table_find (mono_domain_get(), addr);
fname = mono_method_full_name (method, TRUE);
opcode = *((unsigned short *) (code - 6));
switch (opcode) {
@@ -199,19 +195,15 @@ s390_magic_trampoline (MonoMethod *method, guchar *code, char *sp)
base = *((int *) (sp + CREATE_GR_OFFSET+
sizeof(int)*(reg-2)));
addr = get_unbox_trampoline(method, addr);
if (mono_method_same_domain (codeJi, addrJi)) {
code = base + displace;
s390_patch(code, addr);
}
code = base + displace;
s390_patch(code, addr);
break;
case 0xc0e5 :
/* This is the 'brasl' instruction */
code -= 4;
displace = ((gint32) addr - (gint32) (code - 2)) / 2;
if (mono_method_same_domain (codeJi, addrJi)) {
s390_patch (code, displace);
mono_arch_flush_icache (code, 4);
}
s390_patch (code, displace);
mono_arch_flush_icache (code, 4);
break;
default :
g_error("Unable to patch instruction prior to %p",code);