mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 11:21:39 -10:00
Compare commits
49
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5df4e8d92d | ||
|
|
23e223e84c | ||
|
|
dba4e47765 | ||
|
|
93428a4b1a | ||
|
|
31364d46d9 | ||
|
|
026ca88943 | ||
|
|
9aa6a02591 | ||
|
|
6e97c46f77 | ||
|
|
ccc7c27707 | ||
|
|
56e8a4966a | ||
|
|
697feac29f | ||
|
|
af68119b19 | ||
|
|
c652047713 | ||
|
|
0ece5c719b | ||
|
|
a426c45779 | ||
|
|
ca09272c3d | ||
|
|
2ce246b7a6 | ||
|
|
a17130c3e1 | ||
|
|
1a79dadc8d | ||
|
|
5048ba327e | ||
|
|
dc9fc91b28 | ||
|
|
494ada810e | ||
|
|
d1946a1561 | ||
|
|
5b1c7198c3 | ||
|
|
c7e21d4cdc | ||
|
|
95330baf49 | ||
|
|
8d1865e473 | ||
|
|
086328f27c | ||
|
|
248f9d555d | ||
|
|
82eb66bd27 | ||
|
|
fdabee4f02 | ||
|
|
bda13fb6ef | ||
|
|
818b199243 | ||
|
|
7965d1a1ab | ||
|
|
dbecb978fb | ||
|
|
2b9908512f | ||
|
|
1186c7fa5d | ||
|
|
88a687f3a2 | ||
|
|
3115b24291 | ||
|
|
e7e10996ba | ||
|
|
b1645af508 | ||
|
|
c7c86c3e86 | ||
|
|
8e9b9b89e3 | ||
|
|
a8f82f863f | ||
|
|
bbfd6b33ff | ||
|
|
b1ebd3393a | ||
|
|
824e434072 | ||
|
|
1f37e89f8e | ||
|
|
4f459917b6 |
No files matched your search
@@ -1,7 +1,7 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyVersion("1.1.1")]
|
||||
[assembly: AssemblyVersion("1.1.2")]
|
||||
[assembly: AssemblyTitle ("Mono C# Compiler")]
|
||||
[assembly: AssemblyDescription ("Mono C# Compiler with Generics")]
|
||||
[assembly: AssemblyCopyright ("2001, 2002, 2003 Ximian, Inc.")]
|
||||
|
||||
@@ -1,3 +1,776 @@
|
||||
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.
|
||||
|
||||
+1093
-7
File diff suppressed because it is too large.
Load diff
+14
-13
@@ -393,16 +393,6 @@ 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;
|
||||
@@ -413,9 +403,20 @@ namespace Mono.CSharp {
|
||||
|
||||
}
|
||||
|
||||
if (target_type == source_type)
|
||||
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;
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// If this assignemnt/operator was part of a compound binary
|
||||
// operator, then we allow an explicit conversion, as detailed
|
||||
@@ -442,7 +443,7 @@ namespace Mono.CSharp {
|
||||
// 2. and the original right side is implicitly convertible to
|
||||
// the type of target
|
||||
//
|
||||
if (Convert.ImplicitStandardConversionExists (a.original_source, target_type))
|
||||
if (Convert.ImplicitStandardConversionExists (ec, a.original_source, target_type))
|
||||
return this;
|
||||
|
||||
//
|
||||
|
||||
+151
-24
@@ -18,6 +18,8 @@ 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 {
|
||||
@@ -130,6 +132,20 @@ 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,
|
||||
@@ -211,7 +227,11 @@ namespace Mono.CSharp {
|
||||
public static bool GetAttributeArgumentExpression (Expression e, Location loc, Type arg_type, out object result)
|
||||
{
|
||||
if (e is EnumConstant) {
|
||||
result = e;
|
||||
if (RootContext.StdLib)
|
||||
result = ((EnumConstant)e).GetValueAsEnumType ();
|
||||
else
|
||||
result = ((EnumConstant)e).GetValue ();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -303,7 +323,6 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
pos_values = new object [pos_arg_count];
|
||||
object[] real_pos_values = new object [pos_arg_count];
|
||||
|
||||
//
|
||||
// First process positional arguments
|
||||
@@ -323,21 +342,14 @@ namespace Mono.CSharp {
|
||||
if (!GetAttributeArgumentExpression (e, Location, a.Type, out val))
|
||||
return null;
|
||||
|
||||
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;
|
||||
}
|
||||
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
|
||||
//
|
||||
@@ -498,16 +510,16 @@ namespace Mono.CSharp {
|
||||
continue;
|
||||
|
||||
if (j == group_in_params_array){
|
||||
object v = real_pos_values [j];
|
||||
object v = pos_values [j];
|
||||
int count = pos_arg_count - j;
|
||||
|
||||
object [] array = new object [count];
|
||||
real_pos_values [j] = array;
|
||||
pos_values [j] = array;
|
||||
array [0] = v;
|
||||
} else {
|
||||
object [] array = (object []) real_pos_values [group_in_params_array];
|
||||
object [] array = (object []) pos_values [group_in_params_array];
|
||||
|
||||
array [j - group_in_params_array] = real_pos_values [j];
|
||||
array [j - group_in_params_array] = pos_values [j];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -519,8 +531,8 @@ namespace Mono.CSharp {
|
||||
object [] new_pos_values = new object [argc];
|
||||
|
||||
for (int p = 0; p < argc; p++)
|
||||
new_pos_values [p] = real_pos_values [p];
|
||||
real_pos_values = new_pos_values;
|
||||
new_pos_values [p] = pos_values [p];
|
||||
pos_values = new_pos_values;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -537,13 +549,13 @@ namespace Mono.CSharp {
|
||||
prop_infos.CopyTo (prop_info_arr, 0);
|
||||
|
||||
cb = new CustomAttributeBuilder (
|
||||
(ConstructorInfo) constructor, real_pos_values,
|
||||
(ConstructorInfo) constructor, pos_values,
|
||||
prop_info_arr, prop_values_arr,
|
||||
field_info_arr, field_values_arr);
|
||||
}
|
||||
else
|
||||
cb = new CustomAttributeBuilder (
|
||||
(ConstructorInfo) constructor, real_pos_values);
|
||||
(ConstructorInfo) constructor, pos_values);
|
||||
} catch (NullReferenceException) {
|
||||
//
|
||||
// Don't know what to do here
|
||||
@@ -722,6 +734,108 @@ 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)
|
||||
@@ -749,8 +863,14 @@ namespace Mono.CSharp {
|
||||
return null;
|
||||
}
|
||||
|
||||
public UnmanagedMarshal GetMarshal ()
|
||||
public UnmanagedMarshal GetMarshal (Attributable attr)
|
||||
{
|
||||
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;
|
||||
|
||||
@@ -758,8 +878,10 @@ namespace Mono.CSharp {
|
||||
case UnmanagedType.CustomMarshaler:
|
||||
MethodInfo define_custom = typeof (UnmanagedMarshal).GetMethod ("DefineCustom",
|
||||
BindingFlags.Static | BindingFlags.Public);
|
||||
if (define_custom == null)
|
||||
if (define_custom == null) {
|
||||
Report.RuntimeMissingSupport (Location, "set marshal info");
|
||||
return null;
|
||||
}
|
||||
|
||||
object [] args = new object [4];
|
||||
args [0] = GetFieldValue ("MarshalTypeRef");
|
||||
@@ -775,6 +897,11 @@ 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:
|
||||
|
||||
+367
-108
@@ -33,10 +33,13 @@
|
||||
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;
|
||||
|
||||
@@ -418,9 +421,6 @@ 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,14 +1206,24 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
catch (ArgumentException) {
|
||||
Report.RuntimeMissingSupport ("static classes");
|
||||
Report.RuntimeMissingSupport (Location, "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;
|
||||
@@ -1221,19 +1231,10 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
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]);
|
||||
CurrentTypeParameters [i - offset].DefineConstraints ();
|
||||
|
||||
CurrentType = new ConstructedType (Name, TypeParameters, Location);
|
||||
}
|
||||
|
||||
if (IsGeneric) {
|
||||
@@ -1379,6 +1380,7 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1438,10 +1440,8 @@ namespace Mono.CSharp {
|
||||
if (TypeBuilder.BaseType != null)
|
||||
parent_container = TypeManager.LookupMemberContainer (TypeBuilder.BaseType);
|
||||
|
||||
// TODO:
|
||||
//if (TypeBuilder.IsInterface) {
|
||||
// parent_container = TypeManager.LookupInterfaceContainer (base_inteface_types);
|
||||
//}
|
||||
if (TypeBuilder.IsInterface)
|
||||
parent_container = TypeManager.LookupInterfaceContainer (ifaces);
|
||||
|
||||
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);
|
||||
member_cache = new MemberCache (this, false);
|
||||
#endif
|
||||
|
||||
if (parts != null) {
|
||||
@@ -2716,6 +2716,7 @@ 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,
|
||||
@@ -2749,6 +2750,14 @@ 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;
|
||||
@@ -2756,6 +2765,17 @@ 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);
|
||||
@@ -3026,7 +3046,7 @@ namespace Mono.CSharp {
|
||||
public readonly Parameters Parameters;
|
||||
public readonly GenericMethod GenericMethod;
|
||||
public readonly DeclSpace ds;
|
||||
protected Block block;
|
||||
protected ToplevelBlock block;
|
||||
|
||||
//
|
||||
// Parameters, cached for semantic analysis.
|
||||
@@ -3077,7 +3097,7 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public Block Block {
|
||||
public ToplevelBlock Block {
|
||||
get {
|
||||
return block;
|
||||
}
|
||||
@@ -3126,6 +3146,17 @@ 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) {
|
||||
@@ -3146,12 +3177,19 @@ namespace Mono.CSharp {
|
||||
return true;
|
||||
}
|
||||
|
||||
MemberInfo conflict_symbol = Parent.FindMemberWithSameName (Name, !(this is Property));
|
||||
if ((ModFlags & Modifiers.OVERRIDE) != 0) {
|
||||
Report.Error (115, Location, "'{0}': no suitable methods found to override", GetSignatureForError (Parent));
|
||||
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));
|
||||
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));
|
||||
@@ -3277,7 +3315,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), 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), TypeManager.CSharpSignature (parent_method));
|
||||
} else
|
||||
Report.Warning (108, Location, "The keyword new is required on '{0}' because it hides inherited member", GetSignatureForError (Parent));
|
||||
}
|
||||
@@ -3314,14 +3352,22 @@ 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 (ds);
|
||||
parameter_types = Parameters.GetParameterInfo (ec);
|
||||
ec.InUnsafe = old_unsafe;
|
||||
|
||||
if ((parameter_types == null) ||
|
||||
!CheckParameters (ds, parameter_types))
|
||||
return false;
|
||||
|
||||
TypeParameter[] tparam = ds.IsGeneric ? ds.TypeParameters : null;
|
||||
parameter_info = new InternalParameters (ds, Parameters, tparam);
|
||||
parameter_info = new InternalParameters (parameter_types, Parameters, tparam);
|
||||
|
||||
Parameter array_param = Parameters.ArrayParameter;
|
||||
if ((array_param != null) &&
|
||||
@@ -3589,6 +3635,7 @@ namespace Mono.CSharp {
|
||||
public MethodBuilder MethodBuilder;
|
||||
public MethodData MethodData;
|
||||
ReturnParameter return_attributes;
|
||||
ListDictionary declarative_security;
|
||||
|
||||
/// <summary>
|
||||
/// Modifiers allowed in a class declaration
|
||||
@@ -3716,6 +3763,13 @@ 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 ());
|
||||
@@ -3808,7 +3862,7 @@ namespace Mono.CSharp {
|
||||
if (GenericMethod != null) {
|
||||
string mname = MemberName.GetMethodName ();
|
||||
mb = Parent.TypeBuilder.DefineGenericMethod (mname, flags);
|
||||
if (!GenericMethod.Define (mb))
|
||||
if (!GenericMethod.Define (mb, ReturnType))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3822,7 +3876,7 @@ namespace Mono.CSharp {
|
||||
flags |= MethodAttributes.SpecialName | MethodAttributes.HideBySig;
|
||||
|
||||
MethodData = new MethodData (this, ParameterInfo, ModFlags, flags,
|
||||
this, mb, GenericMethod);
|
||||
this, mb, GenericMethod, parent_method);
|
||||
|
||||
if (!MethodData.Define (Parent))
|
||||
return false;
|
||||
@@ -3884,6 +3938,13 @@ 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;
|
||||
}
|
||||
@@ -4216,6 +4277,7 @@ namespace Mono.CSharp {
|
||||
public class Constructor : MethodCore, IMethodData {
|
||||
public ConstructorBuilder ConstructorBuilder;
|
||||
public ConstructorInitializer Initializer;
|
||||
ListDictionary declarative_security;
|
||||
|
||||
// <summary>
|
||||
// Modifiers allowed for a constructor.
|
||||
@@ -4281,6 +4343,14 @@ 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);
|
||||
}
|
||||
|
||||
@@ -4470,6 +4540,12 @@ 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;
|
||||
}
|
||||
|
||||
@@ -4574,7 +4650,7 @@ namespace Mono.CSharp {
|
||||
GenericMethod GenericMethod { get; }
|
||||
|
||||
Attributes OptAttributes { get; }
|
||||
Block Block { get; }
|
||||
ToplevelBlock Block { get; }
|
||||
|
||||
EmitContext CreateEmitContext (TypeContainer tc, ILGenerator ig);
|
||||
ObsoleteAttribute GetObsoleteAttribute ();
|
||||
@@ -4608,6 +4684,7 @@ namespace Mono.CSharp {
|
||||
protected int modifiers;
|
||||
protected MethodAttributes flags;
|
||||
protected Type declaring_type;
|
||||
protected MethodInfo parent_method;
|
||||
|
||||
EmitContext ec;
|
||||
|
||||
@@ -4638,11 +4715,12 @@ namespace Mono.CSharp {
|
||||
public MethodData (MemberBase member, InternalParameters parameters,
|
||||
int modifiers, MethodAttributes flags,
|
||||
IMethodData method, MethodBuilder builder,
|
||||
GenericMethod generic)
|
||||
GenericMethod generic, MethodInfo parent_method)
|
||||
: this (member, parameters, modifiers, flags, method)
|
||||
{
|
||||
this.builder = builder;
|
||||
this.GenericMethod = generic;
|
||||
this.parent_method = parent_method;
|
||||
}
|
||||
|
||||
static string RemoveArity (string name)
|
||||
@@ -4691,10 +4769,14 @@ namespace Mono.CSharp {
|
||||
implementing = container.Pending.IsInterfaceMethod (
|
||||
member.InterfaceType, name, method.ReturnType, ParameterTypes);
|
||||
|
||||
if (member.InterfaceType != null && implementing == null){
|
||||
Report.Error (539, method.Location, "'{0}' in explicit interface declaration is not an interface", method_name);
|
||||
if (member.InterfaceType != null){
|
||||
if (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;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -4805,10 +4887,10 @@ namespace Mono.CSharp {
|
||||
bool is_override = member.IsExplicitImpl |
|
||||
((modifiers & Modifiers.OVERRIDE) != 0);
|
||||
|
||||
is_override &= IsImplementing;
|
||||
if (implementing != null)
|
||||
parent_method = implementing;
|
||||
|
||||
if (!GenericMethod.DefineType (
|
||||
ec, builder, implementing, is_override))
|
||||
if (!GenericMethod.DefineType (ec, builder, parent_method, is_override))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4878,7 +4960,8 @@ namespace Mono.CSharp {
|
||||
if (member is MethodCore)
|
||||
((MethodCore) member).Parameters.LabelParameters (ec, MethodBuilder, loc);
|
||||
|
||||
Block block = method.Block;
|
||||
SymbolWriter sw = CodeGen.SymbolWriter;
|
||||
ToplevelBlock block = method.Block;
|
||||
|
||||
//
|
||||
// abstract or extern methods have no bodies
|
||||
@@ -4934,7 +5017,7 @@ namespace Mono.CSharp {
|
||||
source.CloseMethod ();
|
||||
}
|
||||
|
||||
void EmitDestructor (EmitContext ec, Block block)
|
||||
void EmitDestructor (EmitContext ec, ToplevelBlock block)
|
||||
{
|
||||
ILGenerator ig = ec.ig;
|
||||
|
||||
@@ -5111,6 +5194,10 @@ 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 ();
|
||||
|
||||
@@ -5136,8 +5223,22 @@ 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
|
||||
MemberType = decl.ResolveType (Type, false, Location);
|
||||
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);
|
||||
if (MemberType == null)
|
||||
return false;
|
||||
|
||||
@@ -5183,9 +5284,12 @@ namespace Mono.CSharp {
|
||||
return false;
|
||||
|
||||
if (IsExplicitImpl) {
|
||||
Expression iface_expr = ExplicitInterfaceName.GetTypeExpression (Location);
|
||||
Expression expr = ExplicitInterfaceName.GetTypeExpression (Location);
|
||||
TypeExpr iface_texpr = expr.ResolveAsTypeTerminal (ec, false);
|
||||
if (iface_texpr == null)
|
||||
return false;
|
||||
|
||||
InterfaceType = Parent.ResolveType (iface_expr, false, Location);
|
||||
InterfaceType = iface_texpr.ResolveType (ec);
|
||||
if (InterfaceType == null)
|
||||
return false;
|
||||
|
||||
@@ -5252,7 +5356,10 @@ 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" };
|
||||
|
||||
@@ -5282,15 +5389,17 @@ namespace Mono.CSharp {
|
||||
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
|
||||
{
|
||||
if (a.Type == TypeManager.marshal_as_attr_type) {
|
||||
UnmanagedMarshal marshal = a.GetMarshal ();
|
||||
UnmanagedMarshal marshal = a.GetMarshal (this);
|
||||
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);
|
||||
}
|
||||
@@ -5444,19 +5553,29 @@ namespace Mono.CSharp {
|
||||
|
||||
public override bool Define()
|
||||
{
|
||||
MemberType = Parent.ResolveType (Type, false, Location);
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -5600,15 +5719,23 @@ namespace Mono.CSharp {
|
||||
//
|
||||
// Null if the accessor is empty, or a Block if not
|
||||
//
|
||||
public Block Block;
|
||||
public const int AllowedModifiers =
|
||||
Modifiers.PUBLIC |
|
||||
Modifiers.PROTECTED |
|
||||
Modifiers.INTERNAL |
|
||||
Modifiers.PRIVATE;
|
||||
|
||||
public ToplevelBlock Block;
|
||||
public Attributes Attributes;
|
||||
public Location Location;
|
||||
public int ModFlags;
|
||||
|
||||
public Accessor (Block b, Attributes attrs, Location loc)
|
||||
public Accessor (ToplevelBlock b, int mod, Attributes attrs, Location loc)
|
||||
{
|
||||
Block = b;
|
||||
Attributes = attrs;
|
||||
Location = loc;
|
||||
ModFlags = Modifiers.Check (AllowedModifiers, mod, 0, loc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5617,7 +5744,8 @@ 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 Block block;
|
||||
protected ToplevelBlock block;
|
||||
protected ListDictionary declarative_security;
|
||||
|
||||
// The accessor are created event if they are not wanted.
|
||||
// But we need them because their names are reserved.
|
||||
@@ -5658,7 +5786,7 @@ namespace Mono.CSharp {
|
||||
|
||||
#region IMethodData Members
|
||||
|
||||
public Block Block {
|
||||
public ToplevelBlock Block {
|
||||
get {
|
||||
return block;
|
||||
}
|
||||
@@ -5706,6 +5834,13 @@ 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;
|
||||
@@ -5735,6 +5870,13 @@ 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;
|
||||
}
|
||||
|
||||
@@ -5797,7 +5939,9 @@ namespace Mono.CSharp {
|
||||
|
||||
public override MethodBuilder Define(TypeContainer container)
|
||||
{
|
||||
method_data = new MethodData (method, method.ParameterInfo, method.ModFlags, method.flags, this);
|
||||
base.Define (container);
|
||||
|
||||
method_data = new MethodData (method, method.ParameterInfo, ModFlags, flags, this);
|
||||
|
||||
if (!method_data.Define (container))
|
||||
return null;
|
||||
@@ -5851,17 +5995,23 @@ namespace Mono.CSharp {
|
||||
base.ApplyAttributeBuilder (a, cb);
|
||||
}
|
||||
|
||||
protected virtual InternalParameters GetParameterInfo (TypeContainer container)
|
||||
protected virtual InternalParameters GetParameterInfo (EmitContext ec)
|
||||
{
|
||||
Parameter [] parms = new Parameter [1];
|
||||
parms [0] = new Parameter (method.Type, "value", Parameter.Modifier.NONE, null);
|
||||
return new InternalParameters (
|
||||
container, new Parameters (parms, null, method.Location));
|
||||
Parameters parameters = new Parameters (parms, null, method.Location);
|
||||
Type [] types = parameters.GetParameterInfo (ec);
|
||||
return new InternalParameters (types, parameters);
|
||||
}
|
||||
|
||||
public override MethodBuilder Define(TypeContainer container)
|
||||
{
|
||||
method_data = new MethodData (method, GetParameterInfo (container), method.ModFlags, method.flags, this);
|
||||
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);
|
||||
|
||||
if (!method_data.Define (container))
|
||||
return null;
|
||||
@@ -5897,6 +6047,7 @@ namespace Mono.CSharp {
|
||||
|
||||
public abstract class PropertyMethod: AbstractPropertyEventMethod {
|
||||
protected readonly MethodCore method;
|
||||
protected MethodAttributes flags;
|
||||
|
||||
public PropertyMethod (MethodCore method, string prefix)
|
||||
: base (method, prefix)
|
||||
@@ -5908,6 +6059,12 @@ 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 {
|
||||
@@ -5928,7 +6085,24 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract MethodBuilder Define (TypeContainer container);
|
||||
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 override Type[] ParameterTypes {
|
||||
get {
|
||||
@@ -5953,7 +6127,29 @@ 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;
|
||||
@@ -5972,6 +6168,11 @@ 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);
|
||||
}
|
||||
|
||||
@@ -5997,6 +6198,23 @@ 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;
|
||||
@@ -6042,6 +6260,7 @@ 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 (
|
||||
@@ -6051,14 +6270,52 @@ 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;
|
||||
|
||||
MethodInfo temp_m;
|
||||
temp_m = parent_property.GetGetMethod (true);
|
||||
if (temp_m != null)
|
||||
return temp_m;
|
||||
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));
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.Assert (parent_property.GetSetMethod (true) != null, "Internal error property without get/set");
|
||||
return parent_property.GetSetMethod (true);
|
||||
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;
|
||||
}
|
||||
|
||||
public override void Emit ()
|
||||
@@ -6191,18 +6448,16 @@ namespace Mono.CSharp {
|
||||
prop_attr |= PropertyAttributes.RTSpecialName |
|
||||
PropertyAttributes.SpecialName;
|
||||
|
||||
if (!IsExplicitImpl){
|
||||
PropertyBuilder = Parent.TypeBuilder.DefineProperty (
|
||||
Name, prop_attr, MemberType, null);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -6623,6 +6878,11 @@ 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);
|
||||
}
|
||||
|
||||
@@ -6641,7 +6901,7 @@ namespace Mono.CSharp {
|
||||
{
|
||||
EventAttributes e_attr;
|
||||
e_attr = EventAttributes.None;
|
||||
;
|
||||
|
||||
if (!DoDefineBase ())
|
||||
return false;
|
||||
|
||||
@@ -6660,10 +6920,19 @@ 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);
|
||||
InternalParameters ip = new InternalParameters (
|
||||
Parent, new Parameters (parms, null, Location));
|
||||
Parameters parameters = new Parameters (parms, null, Location);
|
||||
Type [] types = parameters.GetParameterInfo (ec);
|
||||
InternalParameters ip = new InternalParameters (types, parameters);
|
||||
|
||||
ec.InUnsafe = old_unsafe;
|
||||
|
||||
if (!CheckBase ())
|
||||
return false;
|
||||
@@ -6680,12 +6949,9 @@ namespace Mono.CSharp {
|
||||
if (RemoveBuilder == null)
|
||||
return false;
|
||||
|
||||
if (!IsExplicitImpl){
|
||||
EventBuilder = new MyEventBuilder (this,
|
||||
Parent.TypeBuilder, Name, e_attr, MemberType);
|
||||
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));
|
||||
@@ -6698,8 +6964,6 @@ namespace Mono.CSharp {
|
||||
EventBuilder.SetRemoveOnMethod (RemoveBuilder);
|
||||
|
||||
TypeManager.RegisterEvent (EventBuilder, AddBuilder, RemoveBuilder);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -6791,7 +7055,7 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
protected override InternalParameters GetParameterInfo (TypeContainer container)
|
||||
protected override InternalParameters GetParameterInfo (EmitContext ec)
|
||||
{
|
||||
Parameter [] fixed_parms = parameters.FixedParameters;
|
||||
|
||||
@@ -6818,13 +7082,12 @@ 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 (container, set_formal_params);
|
||||
return new InternalParameters (types, set_formal_params);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
const int AllowedModifiers =
|
||||
Modifiers.NEW |
|
||||
Modifiers.PUBLIC |
|
||||
@@ -6880,17 +7143,21 @@ 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;
|
||||
}
|
||||
|
||||
@@ -6959,15 +7226,8 @@ 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 (
|
||||
ShortName, prop_attr, MemberType, ParameterTypes);
|
||||
Name, prop_attr, MemberType, ParameterTypes);
|
||||
|
||||
if (!Get.IsDummy)
|
||||
PropertyBuilder.SetGetMethod (GetBuilder);
|
||||
@@ -6975,9 +7235,7 @@ namespace Mono.CSharp {
|
||||
if (!Set.IsDummy)
|
||||
PropertyBuilder.SetSetMethod (SetBuilder);
|
||||
|
||||
TypeManager.RegisterIndexer (PropertyBuilder, GetBuilder, SetBuilder,
|
||||
ParameterTypes);
|
||||
}
|
||||
TypeManager.RegisterIndexer (PropertyBuilder, GetBuilder, SetBuilder, ParameterTypes);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -7051,7 +7309,7 @@ namespace Mono.CSharp {
|
||||
|
||||
public Operator (TypeContainer parent, OpType type, Expression ret_type,
|
||||
int mod_flags, Parameters parameters,
|
||||
Block block, Attributes attrs, Location loc)
|
||||
ToplevelBlock block, Attributes attrs, Location loc)
|
||||
: base (parent, null, ret_type, mod_flags, AllowedModifiers, false,
|
||||
new MemberName ("op_" + type), attrs, parameters, loc)
|
||||
{
|
||||
@@ -7316,7 +7574,8 @@ 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.ToString (), Parameters.FixedParameters [0].GetSignatureForError ());
|
||||
sb.AppendFormat ("{0}.operator {1} {2}({3}", tc.Name, GetName (OperatorType), Type.Type == null ? Type.ToString () : TypeManager.CSharpName (Type.Type),
|
||||
Parameters.FixedParameters [0].GetSignatureForError ());
|
||||
|
||||
if (Parameters.FixedParameters.Length > 1) {
|
||||
sb.Append (",");
|
||||
|
||||
+295
-53
@@ -4,16 +4,20 @@
|
||||
// Author:
|
||||
// Miguel de Icaza ([email protected])
|
||||
//
|
||||
// (C) 2001 Ximian, Inc.
|
||||
// (C) 2001, 2002, 2003 Ximian, Inc.
|
||||
// (C) 2004 Novell, 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;
|
||||
|
||||
@@ -367,7 +371,7 @@ namespace Mono.CSharp {
|
||||
/// <summary>
|
||||
/// Whether we are inside an anonymous method.
|
||||
/// </summary>
|
||||
public bool InAnonymousMethod;
|
||||
public AnonymousMethod CurrentAnonymousMethod;
|
||||
|
||||
/// <summary>
|
||||
/// Location for this EmitContext
|
||||
@@ -391,14 +395,35 @@ 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,
|
||||
@@ -418,6 +443,7 @@ 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.
|
||||
@@ -451,6 +477,12 @@ 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.
|
||||
@@ -517,30 +549,141 @@ namespace Mono.CSharp {
|
||||
current_flow_branching = current_flow_branching.Parent;
|
||||
}
|
||||
|
||||
public void EmitTopBlock (Block block, InternalParameters ip, Location loc)
|
||||
public void CaptureVariable (LocalInfo li)
|
||||
{
|
||||
bool unreachable = false;
|
||||
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;
|
||||
|
||||
if (!Location.IsNull (loc))
|
||||
CurrentFile = loc.File;
|
||||
|
||||
if (block != null){
|
||||
try {
|
||||
#if PRODUCTION
|
||||
try {
|
||||
#endif
|
||||
int errors = Report.Errors;
|
||||
|
||||
block.EmitMeta (this, ip);
|
||||
block.ResolveMeta (block, 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;
|
||||
return false;
|
||||
}
|
||||
|
||||
FlowBranching.Reachability reachability = current_flow_branching.MergeTopBlock ();
|
||||
@@ -548,41 +691,50 @@ namespace Mono.CSharp {
|
||||
|
||||
DoFlowAnalysis = old_do_flow_analysis;
|
||||
|
||||
block.Emit (this);
|
||||
|
||||
if (reachability.AlwaysReturns ||
|
||||
reachability.AlwaysThrows ||
|
||||
reachability.IsUnreachable)
|
||||
unreachable = true;
|
||||
}
|
||||
#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 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;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ReturnType != null && !unreachable){
|
||||
if (!InIterator){
|
||||
Report.Error (161, loc, "Not all code paths return a value");
|
||||
return;
|
||||
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;
|
||||
}
|
||||
}
|
||||
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);
|
||||
@@ -608,6 +760,12 @@ 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>
|
||||
@@ -714,24 +872,42 @@ 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 (!InIterator && !HasReturnLabel) {
|
||||
ReturnLabel = ig.DefineLabel ();
|
||||
HasReturnLabel = true;
|
||||
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)
|
||||
HasReturnLabel = true;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -745,24 +921,6 @@ 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);
|
||||
@@ -784,13 +942,58 @@ namespace Mono.CSharp {
|
||||
public void EmitThis ()
|
||||
{
|
||||
ig.Emit (OpCodes.Ldarg_0);
|
||||
if (InIterator && !IsStatic){
|
||||
if (InIterator){
|
||||
if (!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)
|
||||
@@ -854,6 +1057,8 @@ namespace Mono.CSharp {
|
||||
|
||||
bool is_cls_compliant;
|
||||
|
||||
ListDictionary declarative_security;
|
||||
|
||||
static string[] attribute_targets = new string [] { "assembly" };
|
||||
|
||||
public AssemblyClass (): base ()
|
||||
@@ -1032,9 +1237,47 @@ 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;
|
||||
@@ -1084,7 +1327,6 @@ 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);
|
||||
|
||||
+2
-3
@@ -82,8 +82,7 @@ namespace Mono.CSharp {
|
||||
while (ttype.IsArray)
|
||||
ttype = TypeManager.GetElementType (ttype);
|
||||
|
||||
if (!TypeManager.IsBuiltinType (ttype) &&
|
||||
(!ttype.IsSubclassOf (TypeManager.enum_type))) {
|
||||
if (!TypeManager.IsBuiltinType (ttype) && (!ttype.IsSubclassOf (TypeManager.enum_type)) && !(Expr is NullLiteral)) {
|
||||
Report.Error (
|
||||
-3, Location,
|
||||
"Constant type is not valid (only system types are allowed)");
|
||||
@@ -112,7 +111,7 @@ namespace Mono.CSharp {
|
||||
if (expr is NullLiteral && !type.IsValueType && !TypeManager.IsEnumType (type))
|
||||
return NullLiteral.Null;
|
||||
|
||||
if (!Convert.ImplicitStandardConversionExists (expr, type)){
|
||||
if (!Convert.ImplicitStandardConversionExists (Convert.ConstantEC, expr, type)){
|
||||
Convert.Error_CannotImplicitConversion (loc, expr.Type, type);
|
||||
return null;
|
||||
}
|
||||
|
||||
+108
-53
@@ -19,6 +19,16 @@ 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 '" +
|
||||
@@ -50,16 +60,16 @@ namespace Mono.CSharp {
|
||||
return true;
|
||||
}
|
||||
|
||||
static Type TypeParam_EffectiveBaseType (Type t)
|
||||
static Type TypeParam_EffectiveBaseType (EmitContext ec, Type t)
|
||||
{
|
||||
GenericConstraints gc = TypeManager.GetTypeParameterConstraints (t);
|
||||
if (gc == null)
|
||||
return TypeManager.object_type;
|
||||
|
||||
return TypeParam_EffectiveBaseType (gc);
|
||||
return TypeParam_EffectiveBaseType (ec, gc);
|
||||
}
|
||||
|
||||
static Type TypeParam_EffectiveBaseType (GenericConstraints gc)
|
||||
static Type TypeParam_EffectiveBaseType (EmitContext ec, GenericConstraints gc)
|
||||
{
|
||||
ArrayList list = new ArrayList ();
|
||||
list.Add (gc.EffectiveBaseClass);
|
||||
@@ -69,9 +79,9 @@ namespace Mono.CSharp {
|
||||
|
||||
GenericConstraints new_gc = TypeManager.GetTypeParameterConstraints (t);
|
||||
if (new_gc != null)
|
||||
list.Add (TypeParam_EffectiveBaseType (new_gc));
|
||||
list.Add (TypeParam_EffectiveBaseType (ec, new_gc));
|
||||
}
|
||||
return FindMostEncompassedType (list);
|
||||
return FindMostEncompassedType (ec, list);
|
||||
}
|
||||
|
||||
static Expression TypeParameterConversion (Expression expr, bool is_reference, Type target_type)
|
||||
@@ -82,7 +92,8 @@ namespace Mono.CSharp {
|
||||
return new BoxedCast (expr, target_type);
|
||||
}
|
||||
|
||||
static Expression ImplicitTypeParameterConversion (Expression expr, Type target_type)
|
||||
static Expression ImplicitTypeParameterConversion (EmitContext ec, Expression expr,
|
||||
Type target_type)
|
||||
{
|
||||
Type expr_type = expr.Type;
|
||||
|
||||
@@ -97,7 +108,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 (gc);
|
||||
Type base_type = TypeParam_EffectiveBaseType (ec, gc);
|
||||
|
||||
if (TypeManager.IsSubclassOf (base_type, target_type))
|
||||
return TypeParameterConversion (expr, is_reference, target_type);
|
||||
@@ -123,7 +134,7 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
static EmptyExpression MyEmptyExpr;
|
||||
static public Expression ImplicitReferenceConversion (Expression expr, Type target_type)
|
||||
static public Expression ImplicitReferenceConversion (EmitContext ec, Expression expr, Type target_type)
|
||||
{
|
||||
Type expr_type = expr.Type;
|
||||
|
||||
@@ -137,7 +148,7 @@ namespace Mono.CSharp {
|
||||
return null;
|
||||
|
||||
if (expr_type.IsGenericParameter)
|
||||
return ImplicitTypeParameterConversion (expr, target_type);
|
||||
return ImplicitTypeParameterConversion (ec, expr, target_type);
|
||||
|
||||
//
|
||||
// notice that it is possible to write "ValueType v = 1", the ValueType here
|
||||
@@ -152,8 +163,11 @@ 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 (expr_type.IsClass || expr_type.IsInterface || expr_type == TypeManager.enum_type){
|
||||
if (target_type == TypeManager.anonymous_method_type)
|
||||
return null;
|
||||
return new EmptyCast (expr, target_type);
|
||||
}
|
||||
|
||||
return null;
|
||||
} else if (target_type == TypeManager.value_type) {
|
||||
@@ -230,7 +244,7 @@ namespace Mono.CSharp {
|
||||
Type target_element_type = TypeManager.GetElementType (target_type);
|
||||
|
||||
if (!expr_element_type.IsValueType && !target_element_type.IsValueType)
|
||||
if (ImplicitStandardConversionExists (MyEmptyExpr,
|
||||
if (ImplicitStandardConversionExists (ConstantEC, MyEmptyExpr,
|
||||
target_element_type))
|
||||
return new EmptyCast (expr, target_type);
|
||||
}
|
||||
@@ -262,12 +276,12 @@ namespace Mono.CSharp {
|
||||
// Tests whether an implicit reference conversion exists between expr_type
|
||||
// and target_type
|
||||
//
|
||||
public static bool ImplicitReferenceConversionExists (Expression expr, Type target_type)
|
||||
public static bool ImplicitReferenceConversionExists (EmitContext ec, Expression expr, Type target_type)
|
||||
{
|
||||
Type expr_type = expr.Type;
|
||||
|
||||
if (expr_type.IsGenericParameter)
|
||||
return ImplicitTypeParameterConversion (expr, target_type) != null;
|
||||
return ImplicitTypeParameterConversion (ec, expr, target_type) != null;
|
||||
|
||||
//
|
||||
// This is the boxed case.
|
||||
@@ -275,6 +289,7 @@ 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;
|
||||
@@ -308,7 +323,7 @@ namespace Mono.CSharp {
|
||||
Type target_element_type = TypeManager.GetElementType (target_type);
|
||||
|
||||
if (!expr_element_type.IsValueType && !target_element_type.IsValueType)
|
||||
if (ImplicitStandardConversionExists (MyEmptyExpr,
|
||||
if (ImplicitStandardConversionExists (ConstantEC, MyEmptyExpr,
|
||||
target_element_type))
|
||||
return true;
|
||||
}
|
||||
@@ -517,7 +532,7 @@ namespace Mono.CSharp {
|
||||
if ((expr is NullLiteral) && target_type.IsGenericParameter)
|
||||
return TypeParameter_to_Null (target_type);
|
||||
|
||||
if (ImplicitStandardConversionExists (expr, target_type))
|
||||
if (ImplicitStandardConversionExists (ec, expr, target_type))
|
||||
return true;
|
||||
|
||||
Expression dummy = ImplicitUserConversion (ec, expr, target_type, Location.Null);
|
||||
@@ -538,8 +553,10 @@ 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 (Expression expr, Type target_type)
|
||||
public static bool ImplicitStandardConversionExists (EmitContext ec, Expression expr, Type target_type)
|
||||
{
|
||||
Type expr_type = expr.Type;
|
||||
|
||||
@@ -657,7 +674,7 @@ namespace Mono.CSharp {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ImplicitReferenceConversionExists (expr, target_type))
|
||||
if (ImplicitReferenceConversionExists (ec, expr, target_type))
|
||||
return true;
|
||||
|
||||
//
|
||||
@@ -718,6 +735,18 @@ 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;
|
||||
}
|
||||
|
||||
@@ -732,7 +761,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 (ArrayList types)
|
||||
static Type FindMostEncompassedType (EmitContext ec, ArrayList types)
|
||||
{
|
||||
Type best = null;
|
||||
|
||||
@@ -747,7 +776,7 @@ namespace Mono.CSharp {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ImplicitStandardConversionExists (priv_fmet_param, best))
|
||||
if (ImplicitStandardConversionExists (ec, priv_fmet_param, best))
|
||||
best = t;
|
||||
}
|
||||
|
||||
@@ -765,7 +794,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 (ArrayList types)
|
||||
static Type FindMostEncompassingType (EmitContext ec, ArrayList types)
|
||||
{
|
||||
Type best = null;
|
||||
|
||||
@@ -780,7 +809,7 @@ namespace Mono.CSharp {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ImplicitStandardConversionExists (priv_fmee_ret, t))
|
||||
if (ImplicitStandardConversionExists (ec, priv_fmee_ret, t))
|
||||
best = t;
|
||||
}
|
||||
|
||||
@@ -797,8 +826,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 (MethodGroupExpr me, Expression source,
|
||||
bool apply_explicit_conv_rules,
|
||||
static public Type FindMostSpecificSource (EmitContext ec, MethodGroupExpr me,
|
||||
Expression source, bool apply_explicit_conv_rules,
|
||||
Location loc)
|
||||
{
|
||||
ArrayList src_types_set = new ArrayList ();
|
||||
@@ -827,17 +856,17 @@ namespace Mono.CSharp {
|
||||
// or encompassed by S to a type encompassing or encompassed by T
|
||||
//
|
||||
priv_fms_expr.SetType (param_type);
|
||||
if (ImplicitStandardConversionExists (priv_fms_expr, source_type))
|
||||
if (ImplicitStandardConversionExists (ec, priv_fms_expr, source_type))
|
||||
src_types_set.Add (param_type);
|
||||
else {
|
||||
if (ImplicitStandardConversionExists (source, param_type))
|
||||
if (ImplicitStandardConversionExists (ec, source, param_type))
|
||||
src_types_set.Add (param_type);
|
||||
}
|
||||
} else {
|
||||
//
|
||||
// Only if S is encompassed by param_type
|
||||
//
|
||||
if (ImplicitStandardConversionExists (source, param_type))
|
||||
if (ImplicitStandardConversionExists (ec, source, param_type))
|
||||
src_types_set.Add (param_type);
|
||||
}
|
||||
}
|
||||
@@ -849,21 +878,21 @@ namespace Mono.CSharp {
|
||||
ArrayList candidate_set = new ArrayList ();
|
||||
|
||||
foreach (Type param_type in src_types_set){
|
||||
if (ImplicitStandardConversionExists (source, param_type))
|
||||
if (ImplicitStandardConversionExists (ec, source, param_type))
|
||||
candidate_set.Add (param_type);
|
||||
}
|
||||
|
||||
if (candidate_set.Count != 0)
|
||||
return FindMostEncompassedType (candidate_set);
|
||||
return FindMostEncompassedType (ec, candidate_set);
|
||||
}
|
||||
|
||||
//
|
||||
// Final case
|
||||
//
|
||||
if (apply_explicit_conv_rules)
|
||||
return FindMostEncompassingType (src_types_set);
|
||||
return FindMostEncompassingType (ec, src_types_set);
|
||||
else
|
||||
return FindMostEncompassedType (src_types_set);
|
||||
return FindMostEncompassedType (ec, src_types_set);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -874,8 +903,8 @@ namespace Mono.CSharp {
|
||||
/// <summary>
|
||||
/// Finds the most specific target Tx according to section 13.4.4
|
||||
/// </summary>
|
||||
static public Type FindMostSpecificTarget (MethodGroupExpr me, Type target,
|
||||
bool apply_explicit_conv_rules,
|
||||
static public Type FindMostSpecificTarget (EmitContext ec, MethodGroupExpr me,
|
||||
Type target, bool apply_explicit_conv_rules,
|
||||
Location loc)
|
||||
{
|
||||
ArrayList tgt_types_set = new ArrayList ();
|
||||
@@ -903,11 +932,11 @@ namespace Mono.CSharp {
|
||||
// or encompassed by S to a type encompassing or encompassed by T
|
||||
//
|
||||
priv_fms_expr.SetType (ret_type);
|
||||
if (ImplicitStandardConversionExists (priv_fms_expr, target))
|
||||
if (ImplicitStandardConversionExists (ec, priv_fms_expr, target))
|
||||
tgt_types_set.Add (ret_type);
|
||||
else {
|
||||
priv_fms_expr.SetType (target);
|
||||
if (ImplicitStandardConversionExists (priv_fms_expr, ret_type))
|
||||
if (ImplicitStandardConversionExists (ec, priv_fms_expr, ret_type))
|
||||
tgt_types_set.Add (ret_type);
|
||||
}
|
||||
} else {
|
||||
@@ -915,7 +944,7 @@ namespace Mono.CSharp {
|
||||
// Only if T is encompassed by param_type
|
||||
//
|
||||
priv_fms_expr.SetType (ret_type);
|
||||
if (ImplicitStandardConversionExists (priv_fms_expr, target))
|
||||
if (ImplicitStandardConversionExists (ec, priv_fms_expr, target))
|
||||
tgt_types_set.Add (ret_type);
|
||||
}
|
||||
}
|
||||
@@ -929,21 +958,21 @@ namespace Mono.CSharp {
|
||||
foreach (Type ret_type in tgt_types_set){
|
||||
priv_fmt_expr.SetType (ret_type);
|
||||
|
||||
if (ImplicitStandardConversionExists (priv_fmt_expr, target))
|
||||
if (ImplicitStandardConversionExists (ec, priv_fmt_expr, target))
|
||||
candidate_set.Add (ret_type);
|
||||
}
|
||||
|
||||
if (candidate_set.Count != 0)
|
||||
return FindMostEncompassingType (candidate_set);
|
||||
return FindMostEncompassingType (ec, candidate_set);
|
||||
}
|
||||
|
||||
//
|
||||
// Okay, final case !
|
||||
//
|
||||
if (apply_explicit_conv_rules)
|
||||
return FindMostEncompassedType (tgt_types_set);
|
||||
return FindMostEncompassedType (ec, tgt_types_set);
|
||||
else
|
||||
return FindMostEncompassingType (tgt_types_set);
|
||||
return FindMostEncompassingType (ec, tgt_types_set);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1057,11 +1086,11 @@ namespace Mono.CSharp {
|
||||
|
||||
Type most_specific_source, most_specific_target;
|
||||
|
||||
most_specific_source = FindMostSpecificSource (union, source, look_for_explicit, loc);
|
||||
most_specific_source = FindMostSpecificSource (ec, union, source, look_for_explicit, loc);
|
||||
if (most_specific_source == null)
|
||||
return null;
|
||||
|
||||
most_specific_target = FindMostSpecificTarget (union, target, look_for_explicit, loc);
|
||||
most_specific_target = FindMostSpecificTarget (ec, union, target, look_for_explicit, loc);
|
||||
if (most_specific_target == null)
|
||||
return null;
|
||||
|
||||
@@ -1155,14 +1184,17 @@ 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;
|
||||
}
|
||||
|
||||
return ImplicitDelegateCreation.Create (ec, (MethodGroupExpr) expr, target_type, loc);
|
||||
//
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
if (expr_type.Equals (target_type) && !(expr is NullLiteral))
|
||||
@@ -1172,7 +1204,7 @@ namespace Mono.CSharp {
|
||||
if (e != null)
|
||||
return e;
|
||||
|
||||
e = ImplicitReferenceConversion (expr, target_type);
|
||||
e = ImplicitReferenceConversion (ec, expr, target_type);
|
||||
if (e != null)
|
||||
return e;
|
||||
|
||||
@@ -1209,6 +1241,30 @@ 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;
|
||||
}
|
||||
|
||||
@@ -1269,11 +1325,10 @@ namespace Mono.CSharp {
|
||||
|
||||
static public void Error_CannotImplicitConversion (Location loc, Type source, Type target)
|
||||
{
|
||||
string msg = "Cannot convert implicitly from `"+
|
||||
TypeManager.CSharpName (source) + "' to `" +
|
||||
TypeManager.CSharpName (target) + "'";
|
||||
|
||||
Report.Error (29, loc, msg);
|
||||
Report.Error (29, loc, "Cannot convert implicitly from {0} to `{1}'",
|
||||
source == TypeManager.anonymous_method_type ?
|
||||
"anonymous method" : "`" + TypeManager.CSharpName (source) + "'",
|
||||
TypeManager.CSharpName (target));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1328,7 +1383,7 @@ namespace Mono.CSharp {
|
||||
if (TypeManager.IsEnumType (real_target_type))
|
||||
real_target_type = TypeManager.EnumToUnderlying (real_target_type);
|
||||
|
||||
if (ImplicitStandardConversionExists (expr, real_target_type)){
|
||||
if (ImplicitStandardConversionExists (ec, expr, real_target_type)){
|
||||
Expression ce = ImplicitConversionStandard (ec, expr, real_target_type, loc);
|
||||
|
||||
if (real_target_type != target_type)
|
||||
|
||||
+77
-36
@@ -40,13 +40,7 @@ namespace Mono.CSharp
|
||||
/// Current block is used to add statements as we find
|
||||
/// them.
|
||||
/// </summary>
|
||||
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;
|
||||
Block current_block, top_current_block;
|
||||
|
||||
Delegate current_delegate;
|
||||
|
||||
@@ -693,6 +687,11 @@ named_argument_list
|
||||
|
||||
$$ = args;
|
||||
}
|
||||
| named_argument_list COMMA expression
|
||||
{
|
||||
Report.Error (1016, lexer.Location, "Named attribute argument expected");
|
||||
$$ = null;
|
||||
}
|
||||
;
|
||||
|
||||
named_argument
|
||||
@@ -941,6 +940,11 @@ 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
|
||||
@@ -967,7 +971,7 @@ method_declaration
|
||||
}
|
||||
}
|
||||
|
||||
method.Block = (Block) $3;
|
||||
method.Block = (ToplevelBlock) $3;
|
||||
current_container.AddMethod (method);
|
||||
|
||||
current_local_parameters = null;
|
||||
@@ -1154,6 +1158,13 @@ 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
|
||||
@@ -1189,6 +1200,11 @@ 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;
|
||||
@@ -1259,7 +1275,7 @@ opt_set_accessor_declaration
|
||||
;
|
||||
|
||||
get_accessor_declaration
|
||||
: opt_attributes GET
|
||||
: opt_attributes opt_modifiers GET
|
||||
{
|
||||
// If this is not the case, then current_local_parameters has already
|
||||
// been set in indexer_declaration
|
||||
@@ -1271,14 +1287,14 @@ get_accessor_declaration
|
||||
}
|
||||
accessor_body
|
||||
{
|
||||
$$ = new Accessor ((Block) $4, (Attributes) $1, lexer.Location);
|
||||
$$ = new Accessor ((ToplevelBlock) $5, (int) $2, (Attributes) $1, lexer.Location);
|
||||
current_local_parameters = null;
|
||||
lexer.PropertyParsing = true;
|
||||
}
|
||||
;
|
||||
|
||||
set_accessor_declaration
|
||||
: opt_attributes SET
|
||||
: opt_attributes opt_modifiers SET
|
||||
{
|
||||
Parameter [] args;
|
||||
Parameter implicit_value_parameter = new Parameter (
|
||||
@@ -1308,7 +1324,7 @@ set_accessor_declaration
|
||||
}
|
||||
accessor_body
|
||||
{
|
||||
$$ = new Accessor ((Block) $4, (Attributes) $1, lexer.Location);
|
||||
$$ = new Accessor ((ToplevelBlock) $5, (int) $2, (Attributes) $1, lexer.Location);
|
||||
current_local_parameters = null;
|
||||
lexer.PropertyParsing = true;
|
||||
}
|
||||
@@ -1570,7 +1586,7 @@ operator_declaration
|
||||
Operator op = new Operator (
|
||||
current_class, decl.optype, decl.ret_type, (int) $2,
|
||||
new Parameters (param_list, null, decl.location),
|
||||
(Block) $5, (Attributes) $1, decl.location);
|
||||
(ToplevelBlock) $5, (Attributes) $1, decl.location);
|
||||
|
||||
if (SimpleIteratorContainer.Simple.Yields)
|
||||
op.SetYields ();
|
||||
@@ -1699,7 +1715,7 @@ constructor_declaration
|
||||
constructor_body
|
||||
{
|
||||
Constructor c = (Constructor) $3;
|
||||
c.Block = (Block) $4;
|
||||
c.Block = (ToplevelBlock) $4;
|
||||
c.OptAttributes = (Attributes) $1;
|
||||
c.ModFlags = (int) $2;
|
||||
|
||||
@@ -1814,7 +1830,7 @@ destructor_declaration
|
||||
current_class, TypeManager.system_void_expr, m, "Finalize",
|
||||
new Parameters (null, null, l), (Attributes) $1, l);
|
||||
|
||||
d.Block = (Block) $7;
|
||||
d.Block = (ToplevelBlock) $7;
|
||||
current_container.AddMethod (d);
|
||||
}
|
||||
}
|
||||
@@ -1896,6 +1912,12 @@ 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
|
||||
@@ -1913,7 +1935,7 @@ add_accessor_declaration
|
||||
}
|
||||
block
|
||||
{
|
||||
$$ = new Accessor ((Block) $4, (Attributes) $1, lexer.Location);
|
||||
$$ = new Accessor ((ToplevelBlock) $4, 0, (Attributes) $1, lexer.Location);
|
||||
lexer.EventParsing = true;
|
||||
}
|
||||
| opt_attributes ADD error {
|
||||
@@ -1937,7 +1959,7 @@ remove_accessor_declaration
|
||||
}
|
||||
block
|
||||
{
|
||||
$$ = new Accessor ((Block) $4, (Attributes) $1, lexer.Location);
|
||||
$$ = new Accessor ((ToplevelBlock) $4, 0, (Attributes) $1, lexer.Location);
|
||||
lexer.EventParsing = true;
|
||||
}
|
||||
| opt_attributes REMOVE error {
|
||||
@@ -2566,7 +2588,7 @@ base_access
|
||||
$$ = new BaseIndexerAccess ((ArrayList) $3, lexer.Location);
|
||||
}
|
||||
| BASE error {
|
||||
Report.Error (175, "Use of keyword `base' is not valid in this context");
|
||||
Report.Error (175, lexer.Location, "Use of keyword `base' is not valid in this context");
|
||||
$$ = null;
|
||||
}
|
||||
;
|
||||
@@ -2610,6 +2632,11 @@ 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");
|
||||
@@ -2751,25 +2778,32 @@ anonymous_method_expression
|
||||
: DELEGATE opt_anonymous_method_signature {
|
||||
oob_stack.Push (current_local_parameters);
|
||||
current_local_parameters = (Parameters)$2;
|
||||
create_toplevel_block = true;
|
||||
|
||||
// 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;
|
||||
} block {
|
||||
if (true){
|
||||
Report.Error (-213, lexer.Location, "Anonymous methods are not supported in this branch");
|
||||
$$ = null;
|
||||
} else {
|
||||
create_toplevel_block = false;
|
||||
Location loc = (Location) oob_stack.Pop ();
|
||||
top_current_block = (Block) oob_stack.Pop ();
|
||||
current_block = (Block) oob_stack.Pop ();
|
||||
if (RootContext.Version == LanguageVersion.ISO_1){
|
||||
Report.FeatureIsNotStandardized (lexer.Location, "anonymous methods");
|
||||
$$ = null;
|
||||
} else
|
||||
$$ = new AnonymousMethod ((Parameters) $2, (Block) $4, lexer.Location);
|
||||
current_local_parameters = (Parameters) oob_stack.Pop ();
|
||||
} else {
|
||||
ToplevelBlock anon_block = (ToplevelBlock) $4;
|
||||
|
||||
anon_block.Parent = current_block;
|
||||
$$ = new AnonymousMethod ((Parameters) $2, (ToplevelBlock) top_current_block,
|
||||
anon_block, loc);
|
||||
}
|
||||
current_local_parameters = (Parameters) oob_stack.Pop ();
|
||||
}
|
||||
;
|
||||
|
||||
opt_anonymous_method_signature
|
||||
: /* empty */ { $$ = Parameters.EmptyReadOnlyParameters; }
|
||||
: /* empty */ { $$ = null; }
|
||||
| anonymous_method_signature
|
||||
;
|
||||
|
||||
@@ -2809,7 +2843,11 @@ anonymous_method_parameter_list
|
||||
|
||||
anonymous_method_parameter
|
||||
: opt_parameter_modifier type IDENTIFIER {
|
||||
$$ = new Parameter ((Expression) $2, (string) $2, (Parameter.Modifier) $1, null);
|
||||
$$ = 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;
|
||||
}
|
||||
;
|
||||
|
||||
@@ -3325,8 +3363,9 @@ type_parameter_constraint
|
||||
block
|
||||
: OPEN_BRACE
|
||||
{
|
||||
if (current_block == null || create_toplevel_block){
|
||||
current_block = new ToplevelBlock (current_local_parameters, lexer.Location);
|
||||
if (current_block == null){
|
||||
current_block = new ToplevelBlock ((ToplevelBlock) top_current_block, current_local_parameters, lexer.Location);
|
||||
top_current_block = current_block;
|
||||
} else {
|
||||
current_block = new Block (current_block, current_local_parameters,
|
||||
lexer.Location, Location.Null);
|
||||
@@ -3339,6 +3378,8 @@ block
|
||||
$$ = current_block;
|
||||
current_block.SetEndLocation (lexer.Location);
|
||||
current_block = current_block.Parent;
|
||||
if (current_block == null)
|
||||
top_current_block = null;
|
||||
}
|
||||
;
|
||||
|
||||
@@ -4016,7 +4057,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, lexer.Location);
|
||||
$$ = new Try ((Block) $2, c, g, null, ((Block) $2).loc);
|
||||
}
|
||||
| TRY block opt_catch_clauses FINALLY block
|
||||
{
|
||||
@@ -4033,7 +4074,7 @@ try_statement
|
||||
}
|
||||
}
|
||||
|
||||
$$ = new Try ((Block) $2, s, g, (Block) $5, lexer.Location);
|
||||
$$ = new Try ((Block) $2, s, g, (Block) $5, ((Block) $2).loc);
|
||||
}
|
||||
| TRY block error
|
||||
{
|
||||
@@ -4110,7 +4151,7 @@ catch_clause
|
||||
}
|
||||
|
||||
|
||||
$$ = new Catch (type, id , (Block) $4, lexer.Location);
|
||||
$$ = new Catch (type, id , (Block) $4, ((Block) $4).loc);
|
||||
}
|
||||
;
|
||||
|
||||
@@ -4344,9 +4385,9 @@ public class InterfaceAccessorInfo {
|
||||
Attributes get_attrs, Attributes set_attrs, Location get_loc, Location set_loc)
|
||||
{
|
||||
if (has_get)
|
||||
Get = new Accessor (null, get_attrs, get_loc);
|
||||
Get = new Accessor (null, 0, get_attrs, get_loc);
|
||||
if (has_set)
|
||||
Set = new Accessor (null, set_attrs, set_loc);
|
||||
Set = new Accessor (null, 0, set_attrs, set_loc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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, "#endregion directive expected");
|
||||
Report.Error (1038, Location, "#endregion directive expected");
|
||||
else
|
||||
Report.Error (1027, "#endif directive expected");
|
||||
Report.Error (1027, Location, "#endif directive expected");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+88
-123
@@ -90,12 +90,16 @@ namespace Mono.CSharp {
|
||||
public string GetMethodName ()
|
||||
{
|
||||
if (Left != null)
|
||||
return Left.GetFullName () + "." + Name;
|
||||
return Left.GetPartialName () + "." + Name;
|
||||
else
|
||||
return Name;
|
||||
}
|
||||
|
||||
public string GetFullName ()
|
||||
///
|
||||
/// This returns exclusively the name as seen on the source code
|
||||
/// it is not the fully qualifed type after resolution
|
||||
///
|
||||
public string GetPartialName ()
|
||||
{
|
||||
string full_name;
|
||||
if (TypeArguments != null)
|
||||
@@ -103,7 +107,7 @@ namespace Mono.CSharp {
|
||||
else
|
||||
full_name = Name;
|
||||
if (Left != null)
|
||||
return Left.GetFullName () + "." + full_name;
|
||||
return Left.GetPartialName () + "." + full_name;
|
||||
else
|
||||
return full_name;
|
||||
}
|
||||
@@ -194,6 +198,9 @@ 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 + ">";
|
||||
@@ -311,6 +318,12 @@ 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
|
||||
//
|
||||
@@ -344,11 +357,8 @@ namespace Mono.CSharp {
|
||||
if (OptAttributes == null)
|
||||
return null;
|
||||
|
||||
// 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);
|
||||
Attribute obsolete_attr = OptAttributes.Search (
|
||||
TypeManager.obsolete_attribute_type, ds.EmitContext);
|
||||
if (obsolete_attr == null)
|
||||
return null;
|
||||
|
||||
@@ -401,9 +411,7 @@ namespace Mono.CSharp {
|
||||
bool GetClsCompliantAttributeValue (DeclSpace ds)
|
||||
{
|
||||
if (OptAttributes != null) {
|
||||
EmitContext ec = new EmitContext (ds.Parent, ds, ds.Location,
|
||||
null, null, ds.ModFlags, false);
|
||||
Attribute cls_attribute = OptAttributes.GetClsCompliantAttribute (ec);
|
||||
Attribute cls_attribute = OptAttributes.GetClsCompliantAttribute (ds.EmitContext);
|
||||
if (cls_attribute != null) {
|
||||
caching_flags |= Flags.HasClsCompliantAttribute;
|
||||
return cls_attribute.GetClsCompliantAttributeValue (ds);
|
||||
@@ -491,6 +499,13 @@ 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
|
||||
//
|
||||
@@ -527,7 +542,7 @@ namespace Mono.CSharp {
|
||||
/// </summary>
|
||||
protected bool AddToContainer (MemberCore symbol, bool is_method, string fullname, string basename)
|
||||
{
|
||||
if (basename == Basename) {
|
||||
if (basename == Basename && !(this is Interface)) {
|
||||
Report.SymbolRelatedToPreviousError (this);
|
||||
Report.Error (542, "'{0}': member names cannot be the same as their enclosing type", symbol.Location, symbol.GetSignatureForError ());
|
||||
return false;
|
||||
@@ -671,31 +686,17 @@ 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);
|
||||
if (d == null)
|
||||
return null;
|
||||
|
||||
return ResolveType (d, loc);
|
||||
return d == null ? null : d.Type;
|
||||
}
|
||||
|
||||
public Type ResolveType (TypeExpr d, Location loc)
|
||||
public Type ResolveNestedType (Type t, 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) {
|
||||
@@ -707,10 +708,14 @@ namespace Mono.CSharp {
|
||||
return null;
|
||||
}
|
||||
|
||||
ConstructedType ctype = new ConstructedType (
|
||||
t, TypeParameters, loc);
|
||||
TypeParameter[] args;
|
||||
if (this is GenericMethod)
|
||||
args = Parent.TypeParameters;
|
||||
else
|
||||
args = TypeParameters;
|
||||
|
||||
t = ctype.ResolveType (type_resolve_ec);
|
||||
ConstructedType ctype = new ConstructedType (t, args, loc);
|
||||
t = ctype.ResolveType (ec);
|
||||
}
|
||||
|
||||
return t;
|
||||
@@ -718,7 +723,7 @@ namespace Mono.CSharp {
|
||||
|
||||
// <summary>
|
||||
// Resolves the expression `e' for a type, and will recursively define
|
||||
// types.
|
||||
// types. This should only be used for resolving base types.
|
||||
// </summary>
|
||||
public TypeExpr ResolveTypeExpr (Expression e, bool silent, Location loc)
|
||||
{
|
||||
@@ -730,50 +735,13 @@ namespace Mono.CSharp {
|
||||
else
|
||||
type_resolve_ec.ContainerType = TypeBuilder;
|
||||
|
||||
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;
|
||||
return e.ResolveAsTypeTerminal (type_resolve_ec, silent);
|
||||
}
|
||||
|
||||
public bool CheckAccessLevel (Type check_type)
|
||||
{
|
||||
TypeBuilder tb;
|
||||
if (this is GenericMethod)
|
||||
if ((this is GenericMethod) || (this is Iterator))
|
||||
tb = Parent.TypeBuilder;
|
||||
else
|
||||
tb = TypeBuilder;
|
||||
@@ -788,7 +756,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
|
||||
@@ -803,37 +771,21 @@ namespace Mono.CSharp {
|
||||
|
||||
case TypeAttributes.NotPublic:
|
||||
|
||||
// In same cases is null.
|
||||
if (TypeBuilder == null)
|
||||
return true;
|
||||
|
||||
//
|
||||
// This test should probably use the declaringtype.
|
||||
//
|
||||
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.
|
||||
//
|
||||
return check_type.Assembly == TypeBuilder.Assembly;
|
||||
|
||||
case TypeAttributes.NestedPublic:
|
||||
return true;
|
||||
|
||||
case TypeAttributes.NestedPrivate:
|
||||
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;
|
||||
return NestedAccessible (tb, check_type);
|
||||
|
||||
case TypeAttributes.NestedFamily:
|
||||
//
|
||||
@@ -858,24 +810,31 @@ namespace Mono.CSharp {
|
||||
|
||||
}
|
||||
|
||||
protected bool FamilyAccessible (TypeBuilder tb, Type check_type)
|
||||
protected bool NestedAccessible (Type tb, Type check_type)
|
||||
{
|
||||
Type declaring = check_type.DeclaringType;
|
||||
if (tb.IsSubclassOf (declaring))
|
||||
return true;
|
||||
|
||||
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 ('+');
|
||||
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 + "+"))
|
||||
// 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)
|
||||
{
|
||||
Type declaring = check_type.DeclaringType;
|
||||
if (tb == declaring || TypeManager.IsFamilyAccessible (tb, declaring))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return NestedAccessible (tb, check_type);
|
||||
}
|
||||
|
||||
// Access level of a type.
|
||||
@@ -1113,7 +1072,7 @@ namespace Mono.CSharp {
|
||||
return null;
|
||||
|
||||
if ((t != null) && containing_ds.CheckAccessLevel (t))
|
||||
return t;
|
||||
return ResolveNestedType (t, loc);
|
||||
|
||||
current_type = current_type.BaseType;
|
||||
}
|
||||
@@ -1241,8 +1200,6 @@ 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;
|
||||
@@ -1683,7 +1640,7 @@ namespace Mono.CSharp {
|
||||
/// <summary>
|
||||
/// Create a new MemberCache for the given IMemberContainer `container'.
|
||||
/// </summary>
|
||||
public MemberCache (IMemberContainer container)
|
||||
public MemberCache (IMemberContainer container, bool setup_inherited_interfaces)
|
||||
{
|
||||
this.Container = container;
|
||||
|
||||
@@ -1700,8 +1657,8 @@ namespace Mono.CSharp {
|
||||
if (Container.ParentContainer != null)
|
||||
parent = Container.ParentContainer.MemberCache;
|
||||
else
|
||||
parent = TypeHandle.ObjectType.MemberCache;
|
||||
member_hash = SetupCacheForInterface (parent);
|
||||
parent = null;
|
||||
member_hash = SetupCacheForInterface (parent, setup_inherited_interfaces);
|
||||
} else if (Container.ParentContainer != null)
|
||||
member_hash = SetupCache (Container.ParentContainer.MemberCache);
|
||||
else
|
||||
@@ -1727,11 +1684,13 @@ 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;
|
||||
}
|
||||
@@ -1762,9 +1721,13 @@ 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)
|
||||
Hashtable SetupCacheForInterface (MemberCache parent, bool deep_setup)
|
||||
{
|
||||
Hashtable hash = SetupCache (parent);
|
||||
|
||||
if (!deep_setup)
|
||||
return hash;
|
||||
|
||||
Type [] ifaces = TypeManager.GetInterfaces (Container.Type);
|
||||
|
||||
foreach (Type itype in ifaces) {
|
||||
@@ -1786,8 +1749,10 @@ 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.
|
||||
AddMembers (MemberTypes.Constructor, container);
|
||||
AddMembers (MemberTypes.Field, container);
|
||||
if (!container.IsInterface) {
|
||||
AddMembers (MemberTypes.Constructor, container);
|
||||
AddMembers (MemberTypes.Field, container);
|
||||
}
|
||||
AddMembers (MemberTypes.Method, container);
|
||||
AddMembers (MemberTypes.Property, container);
|
||||
AddMembers (MemberTypes.Event, container);
|
||||
@@ -1939,7 +1904,7 @@ namespace Mono.CSharp {
|
||||
/// number to speed up the searching process.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
protected enum EntryType {
|
||||
protected internal enum EntryType {
|
||||
None = 0x000,
|
||||
|
||||
Instance = 0x001,
|
||||
@@ -1962,7 +1927,7 @@ namespace Mono.CSharp {
|
||||
MaskType = Constructor|Event|Field|Method|Property|NestedType
|
||||
}
|
||||
|
||||
protected struct CacheEntry {
|
||||
protected internal struct CacheEntry {
|
||||
public readonly IMemberContainer Container;
|
||||
public readonly EntryType EntryType;
|
||||
public readonly MemberInfo Member;
|
||||
@@ -2287,7 +2252,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 == 1)
|
||||
if (arg_types.Length > 0)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
+38
-26
@@ -142,8 +142,7 @@ namespace Mono.CSharp {
|
||||
{
|
||||
MethodAttributes mattr;
|
||||
int i;
|
||||
EmitContext ec = new EmitContext (this, this, Location, null,
|
||||
null, ModFlags, false);
|
||||
ec = new EmitContext (this, this, Location, null, null, ModFlags, false);
|
||||
|
||||
if (IsGeneric) {
|
||||
foreach (TypeParameter type_param in TypeParameters)
|
||||
@@ -171,8 +170,10 @@ 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 (null, null, Parameter.Modifier.NONE, null);
|
||||
fixed_pars [1] = new Parameter (null, null, Parameter.Modifier.NONE, null);
|
||||
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);
|
||||
Parameters const_parameters = new Parameters (fixed_pars, null, Location);
|
||||
|
||||
TypeManager.RegisterMethod (
|
||||
@@ -189,10 +190,10 @@ namespace Mono.CSharp {
|
||||
// First, call the `out of band' special method for
|
||||
// defining recursively any types we need:
|
||||
|
||||
if (!Parameters.ComputeAndDefineParameterTypes (this))
|
||||
if (!Parameters.ComputeAndDefineParameterTypes (ec))
|
||||
return false;
|
||||
|
||||
param_types = Parameters.GetParameterInfo (this);
|
||||
param_types = Parameters.GetParameterInfo (ec);
|
||||
if (param_types == null)
|
||||
return false;
|
||||
|
||||
@@ -213,7 +214,7 @@ namespace Mono.CSharp {
|
||||
return false;
|
||||
}
|
||||
|
||||
ReturnType = ResolveTypeExpr (ReturnType, false, Location);
|
||||
ReturnType = ReturnType.ResolveAsTypeTerminal (ec, false);
|
||||
if (ReturnType == null)
|
||||
return false;
|
||||
|
||||
@@ -272,7 +273,7 @@ namespace Mono.CSharp {
|
||||
InvokeBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
|
||||
|
||||
TypeManager.RegisterMethod (InvokeBuilder,
|
||||
new InternalParameters (Parent, Parameters),
|
||||
new InternalParameters (param_types, Parameters),
|
||||
param_types);
|
||||
|
||||
//
|
||||
@@ -335,11 +336,10 @@ namespace Mono.CSharp {
|
||||
Parameter.Modifier.NONE, null);
|
||||
|
||||
Parameters async_parameters = new Parameters (async_params, null, Location);
|
||||
async_parameters.ComputeAndDefineParameterTypes (this);
|
||||
async_parameters.ComputeAndDefineParameterTypes (ec);
|
||||
|
||||
async_parameters.ComputeAndDefineParameterTypes (this);
|
||||
TypeManager.RegisterMethod (BeginInvokeBuilder,
|
||||
new InternalParameters (Parent, async_parameters),
|
||||
new InternalParameters (async_param_types, async_parameters),
|
||||
async_param_types);
|
||||
|
||||
//
|
||||
@@ -380,11 +380,11 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
Parameters end_parameters = new Parameters (end_params, null, Location);
|
||||
end_parameters.ComputeAndDefineParameterTypes (this);
|
||||
end_parameters.ComputeAndDefineParameterTypes (ec);
|
||||
|
||||
TypeManager.RegisterMethod (
|
||||
EndInvokeBuilder,
|
||||
new InternalParameters (Parent, end_parameters),
|
||||
new InternalParameters (end_param_types, end_parameters),
|
||||
end_param_types);
|
||||
|
||||
return true;
|
||||
@@ -393,8 +393,6 @@ 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);
|
||||
}
|
||||
@@ -423,6 +421,25 @@ 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.
|
||||
@@ -430,19 +447,14 @@ namespace Mono.CSharp {
|
||||
public static MethodBase VerifyMethod (EmitContext ec, Type delegate_type, MethodBase mb,
|
||||
Location loc)
|
||||
{
|
||||
Expression ml = Expression.MemberLookup (
|
||||
ec, delegate_type, "Invoke", loc);
|
||||
|
||||
if (!(ml is MethodGroupExpr)) {
|
||||
Report.Error (-100, loc, "Internal error: could not find Invoke method!");
|
||||
MethodGroupExpr mg = GetInvokeMethod (ec, delegate_type, loc);
|
||||
if (mg == null)
|
||||
return null;
|
||||
}
|
||||
|
||||
MethodBase invoke_mb = ((MethodGroupExpr) ml).Methods [0];
|
||||
|
||||
MethodBase invoke_mb = mg.Methods [0];
|
||||
ParameterData invoke_pd = Invocation.GetParameterData (invoke_mb);
|
||||
|
||||
if (!((MethodGroupExpr) ml).HasTypeArguments &&
|
||||
if (!mg.HasTypeArguments &&
|
||||
!Invocation.InferTypeArguments (ec, invoke_pd, ref mb))
|
||||
return null;
|
||||
|
||||
@@ -501,8 +513,8 @@ namespace Mono.CSharp {
|
||||
|
||||
if (!params_method && pd_count != arg_count) {
|
||||
Report.Error (1593, loc,
|
||||
"Delegate '" + delegate_type.ToString ()
|
||||
+ "' does not take '" + arg_count + "' arguments");
|
||||
"Delegate '{0}' does not take {1} arguments",
|
||||
delegate_type.ToString (), arg_count);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1675,7 +1675,7 @@ namespace Mono.CSharp
|
||||
margs [1] = spec.Substring (0, cp);
|
||||
} else {
|
||||
margs [1] = spec;
|
||||
margs [0] = spec.Replace ('/','.').Replace ('\\', '.');
|
||||
margs [0] = Path.GetFileName (spec);
|
||||
}
|
||||
|
||||
if (File.Exists ((string) margs [1]))
|
||||
|
||||
+54
-39
@@ -272,9 +272,24 @@ namespace Mono.CSharp {
|
||||
// value will be returned if the expression is not a type
|
||||
// reference
|
||||
//
|
||||
public TypeExpr ResolveAsTypeTerminal (EmitContext ec)
|
||||
public TypeExpr ResolveAsTypeTerminal (EmitContext ec, bool silent)
|
||||
{
|
||||
return ResolveAsTypeStep (ec) as TypeExpr;
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -496,7 +511,9 @@ namespace Mono.CSharp {
|
||||
Constant e = Constantify (v, real_type);
|
||||
|
||||
return new EnumConstant (e, t);
|
||||
} else
|
||||
} else if (v == null && !TypeManager.IsValueType (t))
|
||||
return NullLiteral.Null;
|
||||
else
|
||||
throw new Exception ("Unknown type for constant (" + t +
|
||||
"), details: " + v);
|
||||
}
|
||||
@@ -909,7 +926,7 @@ namespace Mono.CSharp {
|
||||
/// </summary>
|
||||
public static object ConvertIntLiteral (Constant c, Type target_type, Location loc)
|
||||
{
|
||||
if (!Convert.ImplicitStandardConversionExists (c, target_type)){
|
||||
if (!Convert.ImplicitStandardConversionExists (Convert.ConstantEC, c, target_type)){
|
||||
Convert.Error_CannotImplicitConversion (loc, c.Type, target_type);
|
||||
return null;
|
||||
}
|
||||
@@ -2060,7 +2077,7 @@ namespace Mono.CSharp {
|
||||
|
||||
TypeParameterExpr generic_type = ds.LookupGeneric (Name, loc);
|
||||
if (generic_type != null)
|
||||
return generic_type.ResolveAsTypeTerminal (ec);
|
||||
return generic_type.ResolveAsTypeTerminal (ec, false);
|
||||
|
||||
if (ec.ResolvingTypeTree){
|
||||
int errors = Report.Errors;
|
||||
@@ -2080,10 +2097,10 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// First, the using aliases
|
||||
//
|
||||
if (alias_value != null){
|
||||
if ((t = RootContext.LookupType (ds, Name, true, loc)) != null)
|
||||
return t;
|
||||
|
||||
if (alias_value != null) {
|
||||
if (alias_value.IsType)
|
||||
return alias_value.Type;
|
||||
if ((t = RootContext.LookupType (ds, alias_value.Name, true, loc)) != null)
|
||||
@@ -2093,14 +2110,6 @@ 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;
|
||||
@@ -2171,21 +2180,12 @@ namespace Mono.CSharp {
|
||||
return var.Resolve (ec);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
ParameterReference pref = current_block.GetParameterReference (Name, loc);
|
||||
if (pref != null) {
|
||||
if (right_side != null)
|
||||
return param.ResolveLValue (ec, right_side);
|
||||
return pref.ResolveLValue (ec, right_side);
|
||||
else
|
||||
return param.Resolve (ec);
|
||||
return pref.Resolve (ec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2322,7 +2322,7 @@ namespace Mono.CSharp {
|
||||
|
||||
override public Expression DoResolve (EmitContext ec)
|
||||
{
|
||||
return ResolveAsTypeTerminal (ec);
|
||||
return ResolveAsTypeTerminal (ec, false);
|
||||
}
|
||||
|
||||
override public void Emit (EmitContext ec)
|
||||
@@ -2379,7 +2379,7 @@ namespace Mono.CSharp {
|
||||
|
||||
public virtual Type ResolveType (EmitContext ec)
|
||||
{
|
||||
TypeExpr t = ResolveAsTypeTerminal (ec);
|
||||
TypeExpr t = ResolveAsTypeTerminal (ec, false);
|
||||
if (t == null)
|
||||
return null;
|
||||
|
||||
@@ -2532,7 +2532,7 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
ConstructedType ctype = new ConstructedType (type, args, loc);
|
||||
return ctype.ResolveAsTypeTerminal (ec);
|
||||
return ctype.ResolveAsTypeTerminal (ec, false);
|
||||
} 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);
|
||||
TypeExpr t = ResolveAsTypeTerminal (ec, false);
|
||||
if (t == null)
|
||||
return null;
|
||||
|
||||
@@ -2932,6 +2932,16 @@ 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))
|
||||
@@ -3364,11 +3374,6 @@ 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;
|
||||
}
|
||||
|
||||
@@ -3431,6 +3436,11 @@ 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;
|
||||
|
||||
@@ -3473,6 +3483,11 @@ 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;
|
||||
|
||||
|
||||
+6
-8
@@ -36,12 +36,15 @@ namespace Mono.CSharp {
|
||||
public override void ApplyAttributeBuilder(Attribute a, CustomAttributeBuilder cb)
|
||||
{
|
||||
if (a.Type == TypeManager.marshal_as_attr_type) {
|
||||
UnmanagedMarshal marshal = a.GetMarshal ();
|
||||
UnmanagedMarshal marshal = a.GetMarshal (this);
|
||||
if (marshal != null) {
|
||||
builder.SetMarshal (marshal);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Report.Warning (-24, a.Location, "The Microsoft Runtime cannot set this marshal info. Please use the Mono runtime instead.");
|
||||
|
||||
if (a.Type.IsSubclassOf (TypeManager.security_attr_type)) {
|
||||
a.Error_InvalidSecurityParent ();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -615,9 +618,7 @@ namespace Mono.CSharp {
|
||||
if (TypeBuilder == null)
|
||||
return false;
|
||||
|
||||
EmitContext ec = new EmitContext (this, this, Location, null,
|
||||
UnderlyingType, ModFlags, false);
|
||||
|
||||
ec = new EmitContext (this, this, Location, null, UnderlyingType, ModFlags, false);
|
||||
|
||||
object default_value = 0;
|
||||
|
||||
@@ -676,9 +677,6 @@ 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);
|
||||
}
|
||||
|
||||
+355
-218
File diff suppressed because it is too large.
Load diff
+26
-19
@@ -372,8 +372,8 @@ namespace Mono.CSharp {
|
||||
Type t2 = constraints.ClassConstraint;
|
||||
TypeExpr e2 = constraints.class_constraint;
|
||||
|
||||
if (!Convert.ImplicitReferenceConversionExists (e1, t2) &&
|
||||
!Convert.ImplicitReferenceConversionExists (e2, t1)) {
|
||||
if (!Convert.ImplicitReferenceConversionExists (ec, e1, t2) &&
|
||||
!Convert.ImplicitReferenceConversionExists (ec, e2, t1)) {
|
||||
Report.Error (455, loc,
|
||||
"Type parameter `{0}' inherits " +
|
||||
"conflicting constraints `{1}' and `{2}'",
|
||||
@@ -533,10 +533,13 @@ namespace Mono.CSharp {
|
||||
throw new InvalidOperationException ();
|
||||
|
||||
this.type = type;
|
||||
Type[] ifaces = null;
|
||||
TypeManager.AddTypeParameter (type, this);
|
||||
}
|
||||
|
||||
public void DefineConstraints ()
|
||||
{
|
||||
if (constraints != null)
|
||||
constraints.Define (type);
|
||||
TypeManager.AddTypeParameter (type, this);
|
||||
}
|
||||
|
||||
public bool DefineType (EmitContext ec)
|
||||
@@ -834,6 +837,11 @@ 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");
|
||||
@@ -946,8 +954,7 @@ namespace Mono.CSharp {
|
||||
atypes = new Type [count];
|
||||
|
||||
for (int i = 0; i < count; i++){
|
||||
TypeExpr te = ds.ResolveTypeExpr (
|
||||
(Expression) args [i], false, Location);
|
||||
TypeExpr te = ((Expression) args [i]).ResolveAsTypeTerminal (ec, false);
|
||||
if (te == null) {
|
||||
ok = false;
|
||||
continue;
|
||||
@@ -1070,7 +1077,7 @@ namespace Mono.CSharp {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Convert.ImplicitStandardConversionExists (expr, ctype);
|
||||
return Convert.ImplicitStandardConversionExists (ec, expr, ctype);
|
||||
}
|
||||
|
||||
protected bool CheckConstraints (EmitContext ec, int index)
|
||||
@@ -1169,8 +1176,10 @@ namespace Mono.CSharp {
|
||||
|
||||
public override TypeExpr DoResolveAsTypeStep (EmitContext ec)
|
||||
{
|
||||
if (gt != null)
|
||||
if (type != null)
|
||||
return this;
|
||||
if (gt != null)
|
||||
return DoResolveType (ec);
|
||||
|
||||
//
|
||||
// First, resolve the generic type.
|
||||
@@ -1188,14 +1197,14 @@ namespace Mono.CSharp {
|
||||
new_args.Add (args);
|
||||
|
||||
args = new_args;
|
||||
return this;
|
||||
return DoResolveType (ec);
|
||||
}
|
||||
|
||||
Type t;
|
||||
int num_args;
|
||||
|
||||
SimpleName sn = new SimpleName (name, loc);
|
||||
TypeExpr resolved = sn.ResolveAsTypeTerminal (ec);
|
||||
TypeExpr resolved = sn.ResolveAsTypeTerminal (ec, true);
|
||||
if ((resolved == null) || (resolved.Type == null)) {
|
||||
Report.Error (246, loc,
|
||||
"The type or namespace name `{0}<...>' "+
|
||||
@@ -1220,16 +1229,11 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
gt = t.GetGenericTypeDefinition ();
|
||||
return this;
|
||||
return DoResolveType (ec);
|
||||
}
|
||||
|
||||
public override Type ResolveType (EmitContext ec)
|
||||
TypeExpr DoResolveType (EmitContext ec)
|
||||
{
|
||||
if (type != null)
|
||||
return type;
|
||||
if (DoResolveAsTypeStep (ec) == null)
|
||||
return null;
|
||||
|
||||
//
|
||||
// Resolve the arguments.
|
||||
//
|
||||
@@ -1257,7 +1261,7 @@ namespace Mono.CSharp {
|
||||
// Now bind the parameters.
|
||||
//
|
||||
type = gt.BindGenericParameters (atypes);
|
||||
return type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Expression GetSimpleName (EmitContext ec)
|
||||
@@ -1345,7 +1349,7 @@ namespace Mono.CSharp {
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Define (MethodBuilder mb)
|
||||
public bool Define (MethodBuilder mb, Type return_type)
|
||||
{
|
||||
if (!Define ())
|
||||
return false;
|
||||
@@ -1356,6 +1360,9 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
+36
-24
@@ -51,9 +51,8 @@ namespace Mono.CSharp {
|
||||
"catch clause");
|
||||
return false;
|
||||
}
|
||||
if (ec.InAnonymousMethod){
|
||||
Report.Error (1621, loc, "yield statement can not appear " +
|
||||
"inside an anonymoud method");
|
||||
if (ec.CurrentAnonymousMethod != null){
|
||||
Report.Error (1621, loc, "yield statement can not appear inside an anonymoud method");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -112,9 +111,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;
|
||||
@@ -134,6 +133,8 @@ namespace Mono.CSharp {
|
||||
// Context from the original method
|
||||
//
|
||||
TypeContainer container;
|
||||
TypeExpr current_type;
|
||||
Type this_type;
|
||||
Type return_type;
|
||||
Type [] param_types;
|
||||
InternalParameters parameters;
|
||||
@@ -223,6 +224,7 @@ 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];
|
||||
@@ -246,6 +248,7 @@ namespace Mono.CSharp {
|
||||
ig.EndExceptionBlock ();
|
||||
ig.Emit (OpCodes.Br, end);
|
||||
}
|
||||
ec.RemapToProxy = false;
|
||||
|
||||
ig.MarkLabel (dispatcher);
|
||||
ig.Emit (OpCodes.Ldarg_0);
|
||||
@@ -355,7 +358,7 @@ namespace Mono.CSharp {
|
||||
//
|
||||
public Iterator (TypeContainer container, string name, Type return_type,
|
||||
Type [] param_types, InternalParameters parameters,
|
||||
int modifiers, Block block, Location loc)
|
||||
int modifiers, ToplevelBlock block, Location loc)
|
||||
: base (container.NamespaceEntry, container, MakeProxyName (name),
|
||||
Modifiers.PRIVATE, null, loc)
|
||||
{
|
||||
@@ -365,7 +368,7 @@ namespace Mono.CSharp {
|
||||
this.parameters = parameters;
|
||||
this.original_name = name;
|
||||
this.original_block = block;
|
||||
this.block = new Block (null);
|
||||
this.block = new ToplevelBlock (loc);
|
||||
|
||||
fields = new Hashtable ();
|
||||
|
||||
@@ -374,6 +377,8 @@ 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,
|
||||
@@ -393,6 +398,11 @@ 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));
|
||||
|
||||
@@ -432,6 +442,11 @@ 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);
|
||||
@@ -464,7 +479,7 @@ namespace Mono.CSharp {
|
||||
|
||||
ArrayList args = new ArrayList ();
|
||||
if (!is_static) {
|
||||
Type t = container.TypeBuilder;
|
||||
Type t = this_type;
|
||||
args.Add (new Argument (
|
||||
new ThisParameterReference (t, 0, Location)));
|
||||
}
|
||||
@@ -477,8 +492,7 @@ namespace Mono.CSharp {
|
||||
new SimpleParameterReference (t, first + i, Location)));
|
||||
}
|
||||
|
||||
Expression new_expr = new New (
|
||||
new TypeExpression (TypeBuilder, Location), args, Location);
|
||||
Expression new_expr = new New (current_type, args, Location);
|
||||
|
||||
block.AddStatement (new NoCheckReturn (new_expr, Location));
|
||||
}
|
||||
@@ -499,8 +513,7 @@ namespace Mono.CSharp {
|
||||
|
||||
if (!is_static) {
|
||||
this_field = new Field (
|
||||
this,
|
||||
new TypeExpression (container.TypeBuilder, Location),
|
||||
this, new TypeExpression (this_type, loc),
|
||||
Modifiers.PRIVATE, "this", null, null, loc);
|
||||
AddField (this_field);
|
||||
}
|
||||
@@ -526,7 +539,7 @@ namespace Mono.CSharp {
|
||||
|
||||
if (!is_static)
|
||||
list.Add (new Parameter (
|
||||
new TypeExpression (container.TypeBuilder, Location),
|
||||
new TypeExpression (this_type, Location),
|
||||
"this", Parameter.Modifier.NONE, null));
|
||||
list.Add (new Parameter (
|
||||
TypeManager.system_boolean_expr, "initialized",
|
||||
@@ -550,10 +563,10 @@ namespace Mono.CSharp {
|
||||
Location);
|
||||
AddConstructor (ctor);
|
||||
|
||||
Block block = ctor.Block = new Block (null);
|
||||
ToplevelBlock block = ctor.Block = new ToplevelBlock (Location);
|
||||
|
||||
if (!is_static) {
|
||||
Type t = container.TypeBuilder;
|
||||
Type t = this_type;
|
||||
|
||||
Assign assign = new Assign (
|
||||
new FieldExpression (this_field),
|
||||
@@ -618,7 +631,7 @@ namespace Mono.CSharp {
|
||||
|
||||
MemberName name = new MemberName (left, "Current", null);
|
||||
|
||||
Block get_block = new Block (null);
|
||||
ToplevelBlock get_block = new ToplevelBlock (Location);
|
||||
|
||||
get_block.AddStatement (new If (
|
||||
new Binary (
|
||||
@@ -630,7 +643,7 @@ namespace Mono.CSharp {
|
||||
new FieldExpression (current_field), Location),
|
||||
Location));
|
||||
|
||||
Accessor getter = new Accessor (get_block, null, Location);
|
||||
Accessor getter = new Accessor (get_block, 0, null, Location);
|
||||
|
||||
Property current = new Property (
|
||||
this, type, 0, false, name, null, getter, null, Location);
|
||||
@@ -646,7 +659,7 @@ namespace Mono.CSharp {
|
||||
Location.Null);
|
||||
AddMethod (move_next);
|
||||
|
||||
Block block = move_next.Block = new Block (null);
|
||||
ToplevelBlock block = move_next.Block = new ToplevelBlock (Location);
|
||||
|
||||
MoveNextMethod inline = new MoveNextMethod (this, Location);
|
||||
block.AddStatement (inline);
|
||||
@@ -674,7 +687,7 @@ namespace Mono.CSharp {
|
||||
Location.Null);
|
||||
AddMethod (get_enumerator);
|
||||
|
||||
get_enumerator.Block = new Block (null);
|
||||
get_enumerator.Block = new ToplevelBlock (Location);
|
||||
|
||||
Expression ce = new MemberAccess (
|
||||
new SimpleName ("System.Threading.Interlocked", Location),
|
||||
@@ -707,8 +720,7 @@ namespace Mono.CSharp {
|
||||
args.Add (new Argument (
|
||||
new FieldExpression (parameter_fields [i])));
|
||||
|
||||
Expression new_expr = new New (
|
||||
new TypeExpression (TypeBuilder, Location), args, Location);
|
||||
Expression new_expr = new New (current_type, args, Location);
|
||||
get_enumerator.Block.AddStatement (new Return (new_expr, Location));
|
||||
}
|
||||
|
||||
@@ -891,7 +903,7 @@ namespace Mono.CSharp {
|
||||
Parameters.EmptyReadOnlyParameters, null, Location);
|
||||
AddMethod (reset);
|
||||
|
||||
reset.Block = new Block (null);
|
||||
reset.Block = new ToplevelBlock (Location);
|
||||
reset.Block.AddStatement (Create_ThrowNotSupported ());
|
||||
}
|
||||
|
||||
@@ -903,11 +915,11 @@ namespace Mono.CSharp {
|
||||
Parameters.EmptyReadOnlyParameters, null, Location);
|
||||
AddMethod (dispose);
|
||||
|
||||
dispose.Block = new Block (null);
|
||||
dispose.Block = new ToplevelBlock (Location);
|
||||
dispose.Block.AddStatement (new DisposeMethod (this, Location));
|
||||
}
|
||||
|
||||
public Block Block {
|
||||
public ToplevelBlock Block {
|
||||
get { return block; }
|
||||
}
|
||||
|
||||
|
||||
+9
-11
@@ -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, false, Location);
|
||||
null, alias, Alias.CountTypeArguments, true, Location);
|
||||
|
||||
NamespaceEntry curr_ns = NamespaceEntry.Parent;
|
||||
|
||||
while ((curr_ns != null) && (resolved == null)) {
|
||||
resolved = curr_ns.Lookup (
|
||||
null, alias, Alias.CountTypeArguments,
|
||||
false, false, Location);
|
||||
false, Location);
|
||||
|
||||
if (resolved == null)
|
||||
curr_ns = curr_ns.Parent;
|
||||
@@ -365,12 +365,11 @@ namespace Mono.CSharp {
|
||||
if (using_clauses == null)
|
||||
using_clauses = new ArrayList ();
|
||||
|
||||
if (RootContext.WarningLevel >= 3) {
|
||||
foreach (UsingEntry old_entry in using_clauses){
|
||||
if (old_entry.Name == ns){
|
||||
foreach (UsingEntry old_entry in using_clauses) {
|
||||
if (old_entry.Name == ns) {
|
||||
if (RootContext.WarningLevel >= 3)
|
||||
Report.Warning (105, loc, "The using directive for '{0}' appeared previously in this namespace", ns);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,7 +419,7 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
public IAlias Lookup (DeclSpace ds, string name, int num_type_params,
|
||||
bool ignore_using, bool silent, Location loc)
|
||||
bool ignore_using, Location loc)
|
||||
{
|
||||
IAlias o;
|
||||
Namespace ns;
|
||||
@@ -433,7 +432,7 @@ namespace Mono.CSharp {
|
||||
string first = name.Substring (0, pos);
|
||||
string last = name.Substring (pos + 1);
|
||||
|
||||
o = Lookup (ds, first, 0, ignore_using, silent, loc);
|
||||
o = Lookup (ds, first, 0, ignore_using, loc);
|
||||
if (o == null)
|
||||
return null;
|
||||
|
||||
@@ -481,8 +480,7 @@ namespace Mono.CSharp {
|
||||
match = using_ns.Lookup (ds, name, loc);
|
||||
if ((match != null) && match.IsType){
|
||||
if (t != null) {
|
||||
if (!silent)
|
||||
DeclSpace.Error_AmbiguousTypeReference (loc, name, t.Name, match.Name);
|
||||
DeclSpace.Error_AmbiguousTypeReference (loc, name, t.Name, match.Name);
|
||||
return null;
|
||||
} else {
|
||||
t = match;
|
||||
@@ -629,7 +627,7 @@ namespace Mono.CSharp {
|
||||
continue;
|
||||
}
|
||||
|
||||
error246 (entry.Location, entry.Alias.ToString ());
|
||||
error246 (entry.Location, entry.Alias.GetPartialName ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+48
-73
@@ -31,12 +31,15 @@ namespace Mono.CSharp {
|
||||
public override void ApplyAttributeBuilder (Attribute a, CustomAttributeBuilder cb)
|
||||
{
|
||||
if (a.Type == TypeManager.marshal_as_attr_type) {
|
||||
UnmanagedMarshal marshal = a.GetMarshal ();
|
||||
UnmanagedMarshal marshal = a.GetMarshal (this);
|
||||
if (marshal != null) {
|
||||
builder.SetMarshal (marshal);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
Report.Warning (-24, a.Location, "The Microsoft Runtime cannot set this marshal info. Please use the Mono runtime instead.");
|
||||
|
||||
if (a.Type.IsSubclassOf (TypeManager.security_attr_type)) {
|
||||
a.Error_InvalidSecurityParent ();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -136,7 +139,7 @@ namespace Mono.CSharp {
|
||||
|
||||
static string[] attribute_targets = new string [] { "param" };
|
||||
|
||||
public readonly Expression TypeName;
|
||||
public Expression TypeName;
|
||||
public readonly Modifier ModFlags;
|
||||
public readonly string Name;
|
||||
GenericConstraints constraints;
|
||||
@@ -162,9 +165,9 @@ namespace Mono.CSharp {
|
||||
// <summary>
|
||||
// Resolve is used in method definitions
|
||||
// </summary>
|
||||
public bool Resolve (DeclSpace ds, Location l)
|
||||
public bool Resolve (EmitContext ec, Location l)
|
||||
{
|
||||
TypeExpr texpr = ds.ResolveTypeExpr (TypeName, false, l);
|
||||
TypeExpr texpr = TypeName.ResolveAsTypeTerminal (ec, false);
|
||||
if (texpr == null)
|
||||
return false;
|
||||
|
||||
@@ -172,8 +175,8 @@ namespace Mono.CSharp {
|
||||
if (tparam != null)
|
||||
constraints = tparam.TypeParameter.Constraints;
|
||||
|
||||
parameter_type = ds.ResolveType (texpr, l);
|
||||
|
||||
parameter_type = texpr.ResolveType (ec);
|
||||
|
||||
if (parameter_type.IsAbstract && parameter_type.IsSealed) {
|
||||
Report.Error (721, l, "'{0}': static types cannot be used as parameters", GetSignatureForError ());
|
||||
return false;
|
||||
@@ -244,10 +247,10 @@ namespace Mono.CSharp {
|
||||
/// Returns the signature for this parameter evaluating it on the
|
||||
/// @tc context
|
||||
/// </summary>
|
||||
public string GetSignature (DeclSpace ds, Location loc)
|
||||
public string GetSignature (EmitContext ec, Location loc)
|
||||
{
|
||||
if (parameter_type == null){
|
||||
if (!Resolve (ds, loc))
|
||||
if (!Resolve (ec, loc))
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -256,8 +259,15 @@ namespace Mono.CSharp {
|
||||
|
||||
public string GetSignatureForError ()
|
||||
{
|
||||
string typeName = TypeManager.CSharpName (parameter_type);
|
||||
switch (ModFlags & ~Modifier.ISBYREF) {
|
||||
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)) {
|
||||
case Modifier.OUT:
|
||||
return "out " + typeName;
|
||||
case Modifier.PARAMS:
|
||||
@@ -340,14 +350,14 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public void ComputeSignature (DeclSpace ds)
|
||||
public void ComputeSignature (EmitContext ec)
|
||||
{
|
||||
signature = "";
|
||||
if (FixedParameters != null){
|
||||
for (int i = 0; i < FixedParameters.Length; i++){
|
||||
Parameter par = FixedParameters [i];
|
||||
|
||||
signature += par.GetSignature (ds, loc);
|
||||
signature += par.GetSignature (ec, loc);
|
||||
}
|
||||
}
|
||||
//
|
||||
@@ -372,9 +382,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;
|
||||
@@ -392,13 +402,13 @@ namespace Mono.CSharp {
|
||||
|
||||
/// <summary>
|
||||
/// Returns the signature of the Parameters evaluated in
|
||||
/// the @tc environment
|
||||
/// the @ec EmitContext
|
||||
/// </summary>
|
||||
public string GetSignature (DeclSpace ds)
|
||||
public string GetSignature (EmitContext ec)
|
||||
{
|
||||
if (signature == null){
|
||||
VerifyArgs ();
|
||||
ComputeSignature (ds);
|
||||
ComputeSignature (ec);
|
||||
}
|
||||
|
||||
return signature;
|
||||
@@ -432,7 +442,14 @@ namespace Mono.CSharp {
|
||||
return null;
|
||||
}
|
||||
|
||||
bool ComputeParameterTypes (DeclSpace ds)
|
||||
public Parameter GetParameterByName (string name)
|
||||
{
|
||||
int idx;
|
||||
|
||||
return GetParameterByName (name, out idx);
|
||||
}
|
||||
|
||||
bool ComputeParameterTypes (EmitContext ec)
|
||||
{
|
||||
int extra = (ArrayParameter != null) ? 1 : 0;
|
||||
int i = 0;
|
||||
@@ -455,7 +472,7 @@ namespace Mono.CSharp {
|
||||
foreach (Parameter p in FixedParameters){
|
||||
Type t = null;
|
||||
|
||||
if (p.Resolve (ds, loc))
|
||||
if (p.Resolve (ec, loc))
|
||||
t = p.ExternalType ();
|
||||
else
|
||||
failed = true;
|
||||
@@ -466,7 +483,7 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
if (extra > 0){
|
||||
if (ArrayParameter.Resolve (ds, loc))
|
||||
if (ArrayParameter.Resolve (ec, loc))
|
||||
types [i] = ArrayParameter.ExternalType ();
|
||||
else
|
||||
failed = true;
|
||||
@@ -484,55 +501,13 @@ namespace Mono.CSharp {
|
||||
// This variant is used by Delegates, because they need to
|
||||
// resolve/define names, instead of the plain LookupType
|
||||
//
|
||||
public bool ComputeAndDefineParameterTypes (DeclSpace ds)
|
||||
public bool ComputeAndDefineParameterTypes (EmitContext ec)
|
||||
{
|
||||
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;
|
||||
bool old_type_resolving = ec.ResolvingTypeTree;
|
||||
ec.ResolvingTypeTree = true;
|
||||
bool retval = ComputeParameterTypes (ec);
|
||||
ec.ResolvingTypeTree = old_type_resolving;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -540,7 +515,7 @@ namespace Mono.CSharp {
|
||||
/// </summary>
|
||||
static Type [] no_types = new Type [0];
|
||||
|
||||
public Type [] GetParameterInfo (DeclSpace ds)
|
||||
public Type [] GetParameterInfo (EmitContext ec)
|
||||
{
|
||||
if (types != null)
|
||||
return types;
|
||||
@@ -548,7 +523,7 @@ namespace Mono.CSharp {
|
||||
if (FixedParameters == null && ArrayParameter == null)
|
||||
return no_types;
|
||||
|
||||
if (ComputeParameterTypes (ds) == false){
|
||||
if (ComputeParameterTypes (ec) == false){
|
||||
types = null;
|
||||
return null;
|
||||
}
|
||||
@@ -563,7 +538,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 (DeclSpace ds, int idx, out Parameter.Modifier mod)
|
||||
public Type GetParameterInfo (EmitContext ec, int idx, out Parameter.Modifier mod)
|
||||
{
|
||||
mod = Parameter.Modifier.NONE;
|
||||
|
||||
@@ -576,7 +551,7 @@ namespace Mono.CSharp {
|
||||
return null;
|
||||
|
||||
if (types == null)
|
||||
if (ComputeParameterTypes (ds) == false)
|
||||
if (ComputeParameterTypes (ec) == false)
|
||||
return null;
|
||||
|
||||
//
|
||||
|
||||
+2
-2
@@ -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 (string feature)
|
||||
static public void RuntimeMissingSupport (Location loc, string feature)
|
||||
{
|
||||
Report.Error (-88, "Your .NET Runtime does not support '{0}'. Please use the latest Mono runtime instead.", feature);
|
||||
Report.Error (-88, loc, "Your .NET Runtime does not support '{0}'. Please use the latest Mono runtime instead.", feature);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -379,13 +379,15 @@ 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.MarshalByRefObject",
|
||||
"System.Security.CodeAccessPermission"
|
||||
};
|
||||
|
||||
// We must store them here before calling BootstrapCorlib_ResolveDelegate.
|
||||
@@ -487,13 +489,13 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
static TypeExpr NamespaceLookup (DeclSpace ds, string name,
|
||||
int num_type_args, bool silent, Location loc)
|
||||
int num_type_args, 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, silent, loc);
|
||||
IAlias result = ns.Lookup (ds, name, num_type_args, false, loc);
|
||||
|
||||
if (result == null)
|
||||
continue;
|
||||
@@ -545,6 +547,7 @@ 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;
|
||||
@@ -556,7 +559,7 @@ namespace Mono.CSharp {
|
||||
containing_ds = containing_ds.Parent;
|
||||
}
|
||||
|
||||
t = NamespaceLookup (ds, name, num_type_params, silent, loc);
|
||||
t = NamespaceLookup (ds, name, num_type_params, loc);
|
||||
if (t != null){
|
||||
ds.Cache [name] = t;
|
||||
return t;
|
||||
|
||||
+350
-67
@@ -6,6 +6,7 @@
|
||||
// Martin Baulig ([email protected])
|
||||
//
|
||||
// (C) 2001, 2002, 2003 Ximian, Inc.
|
||||
// (C) 2003, 2004 Novell, Inc.
|
||||
//
|
||||
|
||||
using System;
|
||||
@@ -558,7 +559,12 @@ namespace Mono.CSharp {
|
||||
public override bool Resolve (EmitContext ec)
|
||||
{
|
||||
if (ec.ReturnType == null){
|
||||
if (Expr != 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"));
|
||||
}
|
||||
Error (127, "Return with a value not allowed here");
|
||||
return false;
|
||||
}
|
||||
@@ -598,6 +604,9 @@ namespace Mono.CSharp {
|
||||
} else
|
||||
vector.CheckOutParameters (ec.CurrentBranching);
|
||||
|
||||
if (in_exc)
|
||||
ec.NeedReturnLabel ();
|
||||
|
||||
ec.CurrentBranching.CurrentUsageVector.Return ();
|
||||
return true;
|
||||
}
|
||||
@@ -611,14 +620,12 @@ namespace Mono.CSharp {
|
||||
ec.ig.Emit (OpCodes.Stloc, ec.TemporaryReturn ());
|
||||
}
|
||||
|
||||
if (in_exc) {
|
||||
ec.NeedReturnLabel ();
|
||||
if (in_exc)
|
||||
ec.ig.Emit (OpCodes.Leave, ec.ReturnLabel);
|
||||
} else {
|
||||
else
|
||||
ec.ig.Emit (OpCodes.Ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Goto : Statement {
|
||||
string target;
|
||||
@@ -755,7 +762,7 @@ namespace Mono.CSharp {
|
||||
/// </summary>
|
||||
public class GotoCase : Statement {
|
||||
Expression expr;
|
||||
Label label;
|
||||
SwitchLabel sl;
|
||||
|
||||
public GotoCase (Expression e, Location l)
|
||||
{
|
||||
@@ -785,7 +792,7 @@ namespace Mono.CSharp {
|
||||
if (val == null)
|
||||
return false;
|
||||
|
||||
SwitchLabel sl = (SwitchLabel) ec.Switch.Elements [val];
|
||||
sl = (SwitchLabel) ec.Switch.Elements [val];
|
||||
|
||||
if (sl == null){
|
||||
Report.Error (
|
||||
@@ -794,15 +801,13 @@ 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, label);
|
||||
ec.ig.Emit (OpCodes.Br, sl.GetILLabelCode (ec));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -891,6 +896,9 @@ namespace Mono.CSharp {
|
||||
|
||||
crossing_exc = ec.CurrentBranching.BreakCrossesTryCatchBoundary ();
|
||||
|
||||
if (!crossing_exc)
|
||||
ec.NeedReturnLabel ();
|
||||
|
||||
ec.CurrentBranching.CurrentUsageVector.Break ();
|
||||
return true;
|
||||
}
|
||||
@@ -902,7 +910,6 @@ namespace Mono.CSharp {
|
||||
if (crossing_exc)
|
||||
ig.Emit (OpCodes.Leave, ec.LoopEnd);
|
||||
else {
|
||||
ec.NeedReturnLabel ();
|
||||
ig.Emit (OpCodes.Br, ec.LoopEnd);
|
||||
}
|
||||
}
|
||||
@@ -945,13 +952,17 @@ 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. The context of the field will
|
||||
// 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
|
||||
// be stored in the EmitContext
|
||||
//
|
||||
//
|
||||
@@ -969,7 +980,8 @@ namespace Mono.CSharp {
|
||||
Used = 1,
|
||||
ReadOnly = 2,
|
||||
Pinned = 4,
|
||||
IsThis = 8
|
||||
IsThis = 8,
|
||||
Captured = 16
|
||||
}
|
||||
|
||||
Flags flags;
|
||||
@@ -1010,8 +1022,15 @@ namespace Mono.CSharp {
|
||||
|
||||
public bool Resolve (EmitContext ec)
|
||||
{
|
||||
if (VariableType == null)
|
||||
VariableType = ec.DeclSpace.ResolveType (Type, false, Location);
|
||||
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 == TypeManager.void_type) {
|
||||
Report.Error (1547, Location,
|
||||
@@ -1019,9 +1038,6 @@ 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;
|
||||
@@ -1045,6 +1061,16 @@ 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})",
|
||||
@@ -1056,7 +1082,7 @@ namespace Mono.CSharp {
|
||||
return (flags & Flags.Used) != 0;
|
||||
}
|
||||
set {
|
||||
flags = value ? (flags | Flags.Used) : (flags & ~Flags.Used);
|
||||
flags = value ? (flags | Flags.Used) : (unchecked (flags & ~Flags.Used));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1065,7 +1091,7 @@ namespace Mono.CSharp {
|
||||
return (flags & Flags.ReadOnly) != 0;
|
||||
}
|
||||
set {
|
||||
flags = value ? (flags | Flags.ReadOnly) : (flags & ~Flags.ReadOnly);
|
||||
flags = value ? (flags | Flags.ReadOnly) : (unchecked (flags & ~Flags.ReadOnly));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1107,19 +1133,21 @@ namespace Mono.CSharp {
|
||||
/// they contain extra information that is not necessary on normal blocks.
|
||||
/// </remarks>
|
||||
public class Block : Statement {
|
||||
public readonly Block Parent;
|
||||
public Block Parent;
|
||||
public readonly Location StartLocation;
|
||||
public Location EndLocation = Location.Null;
|
||||
|
||||
[Flags]
|
||||
public enum Flags : byte {
|
||||
public enum Flags {
|
||||
Implicit = 1,
|
||||
Unchecked = 2,
|
||||
BlockUsed = 4,
|
||||
VariablesInitialized = 8,
|
||||
HasRet = 16,
|
||||
IsDestructor = 32,
|
||||
HasVarargs = 64
|
||||
HasVarargs = 64,
|
||||
IsToplevel = 128,
|
||||
Unsafe = 256
|
||||
}
|
||||
Flags flags;
|
||||
|
||||
@@ -1138,6 +1166,15 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public bool Unsafe {
|
||||
get {
|
||||
return (flags & Flags.Unsafe) != 0;
|
||||
}
|
||||
set {
|
||||
flags |= Flags.Unsafe;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasVarargs {
|
||||
get {
|
||||
if (Parent != null)
|
||||
@@ -1179,12 +1216,17 @@ 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;
|
||||
|
||||
static int id;
|
||||
protected static int id;
|
||||
|
||||
int this_id;
|
||||
|
||||
@@ -1553,14 +1595,76 @@ namespace Mono.CSharp {
|
||||
return e != null;
|
||||
}
|
||||
|
||||
Parameters parameters = null;
|
||||
public Parameters Parameters {
|
||||
get {
|
||||
//
|
||||
// Returns a `ParameterReference' for the given name, or null if there
|
||||
// is no such parameter
|
||||
//
|
||||
public ParameterReference GetParameterReference (string name, Location loc)
|
||||
{
|
||||
Block b = this;
|
||||
while (b.Parent != null)
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
b = b.Parent;
|
||||
return b.parameters;
|
||||
} while (b != null);
|
||||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
// 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>
|
||||
@@ -1611,7 +1715,7 @@ namespace Mono.CSharp {
|
||||
public VariableMap ParameterMap {
|
||||
get {
|
||||
if ((flags & Flags.VariablesInitialized) == 0)
|
||||
throw new Exception ();
|
||||
throw new Exception ("Variables have not been initialized yet");
|
||||
|
||||
return param_map;
|
||||
}
|
||||
@@ -1620,17 +1724,12 @@ namespace Mono.CSharp {
|
||||
public VariableMap LocalMap {
|
||||
get {
|
||||
if ((flags & Flags.VariablesInitialized) == 0)
|
||||
throw new Exception ();
|
||||
throw new Exception ("Variables have not been initialized yet");
|
||||
|
||||
return local_map;
|
||||
}
|
||||
}
|
||||
|
||||
public bool LiftVariable (LocalInfo local_info)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Emits the variable declarations and labels.
|
||||
/// </summary>
|
||||
@@ -1638,10 +1737,16 @@ namespace Mono.CSharp {
|
||||
/// tc: is our typecontainer (to resolve type references)
|
||||
/// ig: is the code generator:
|
||||
/// </remarks>
|
||||
public void EmitMeta (EmitContext ec, InternalParameters ip)
|
||||
public void ResolveMeta (ToplevelBlock toplevel, 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.
|
||||
//
|
||||
@@ -1669,7 +1774,6 @@ namespace Mono.CSharp {
|
||||
|
||||
bool old_check_state = ec.ConstantCheckState;
|
||||
ec.ConstantCheckState = (flags & Flags.Unchecked) == 0;
|
||||
bool remap_locals = ec.RemapToProxy;
|
||||
|
||||
//
|
||||
// Process this block variables
|
||||
@@ -1695,6 +1799,7 @@ namespace Mono.CSharp {
|
||||
continue;
|
||||
}
|
||||
|
||||
#if false
|
||||
if (remap_locals)
|
||||
vi.FieldBuilder = ec.MapVariable (name, vi.VariableType);
|
||||
else if (vi.Pinned)
|
||||
@@ -1705,6 +1810,7 @@ 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;
|
||||
@@ -1743,7 +1849,46 @@ namespace Mono.CSharp {
|
||||
//
|
||||
if (children != null){
|
||||
foreach (Block b in children)
|
||||
b.EmitMeta (ec, ip);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1914,28 +2059,128 @@ 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, parameters, start, Location.Null)
|
||||
base (null, Flags.IsToplevel, parameters, start, Location.Null)
|
||||
{
|
||||
}
|
||||
|
||||
public ToplevelBlock (Flags flags, Parameters parameters, Location start) :
|
||||
base (null, flags, parameters, start, Location.Null)
|
||||
base (null, flags | Flags.IsToplevel, 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;
|
||||
public Label ILLabel;
|
||||
public Label ILLabelCode;
|
||||
|
||||
Label il_label;
|
||||
bool il_label_set;
|
||||
Label il_label_code;
|
||||
bool il_label_code_set;
|
||||
|
||||
//
|
||||
// if expr == null, then it is the default case.
|
||||
@@ -1958,15 +2203,30 @@ 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;
|
||||
|
||||
@@ -1983,7 +2243,6 @@ namespace Mono.CSharp {
|
||||
if (e is StringConstant || e is NullLiteral){
|
||||
if (required_type == TypeManager.string_type){
|
||||
converted = e;
|
||||
ILLabel = ec.ig.DefineLabel ();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2450,7 +2709,7 @@ namespace Mono.CSharp {
|
||||
ig.Emit (OpCodes.Ldloc, val);
|
||||
EmitObjectInteger (ig, key);
|
||||
SwitchLabel sl = (SwitchLabel) Elements [key];
|
||||
ig.Emit (OpCodes.Beq, sl.ILLabel);
|
||||
ig.Emit (OpCodes.Beq, sl.GetILLabel (ec));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2506,7 +2765,7 @@ namespace Mono.CSharp {
|
||||
if (System.Convert.ToInt64 (key) == kb.nFirst + iJump)
|
||||
{
|
||||
SwitchLabel sl = (SwitchLabel) Elements [key];
|
||||
rgLabels [iJump] = sl.ILLabel;
|
||||
rgLabels [iJump] = sl.GetILLabel (ec);
|
||||
iKey++;
|
||||
}
|
||||
else
|
||||
@@ -2534,8 +2793,8 @@ namespace Mono.CSharp {
|
||||
{
|
||||
foreach (SwitchLabel sl in ss.Labels)
|
||||
{
|
||||
ig.MarkLabel (sl.ILLabel);
|
||||
ig.MarkLabel (sl.ILLabelCode);
|
||||
ig.MarkLabel (sl.GetILLabel (ec));
|
||||
ig.MarkLabel (sl.GetILLabelCode (ec));
|
||||
if (sl.Label == null)
|
||||
{
|
||||
ig.MarkLabel (lblDefault);
|
||||
@@ -2593,7 +2852,7 @@ namespace Mono.CSharp {
|
||||
null_found = false;
|
||||
for (int label = 0; label < label_count; label++){
|
||||
SwitchLabel sl = (SwitchLabel) ss.Labels [label];
|
||||
ig.MarkLabel (sl.ILLabel);
|
||||
ig.MarkLabel (sl.GetILLabel (ec));
|
||||
|
||||
if (!first_test){
|
||||
ig.MarkLabel (next_test);
|
||||
@@ -2635,7 +2894,7 @@ namespace Mono.CSharp {
|
||||
ig.MarkLabel (null_target);
|
||||
ig.MarkLabel (sec_begin);
|
||||
foreach (SwitchLabel sl in ss.Labels)
|
||||
ig.MarkLabel (sl.ILLabelCode);
|
||||
ig.MarkLabel (sl.GetILLabelCode (ec));
|
||||
|
||||
if (mark_default)
|
||||
ig.MarkLabel (default_target);
|
||||
@@ -2973,6 +3232,7 @@ namespace Mono.CSharp {
|
||||
public Unsafe (Block b)
|
||||
{
|
||||
Block = b;
|
||||
Block.Unsafe = true;
|
||||
}
|
||||
|
||||
public override bool Resolve (EmitContext ec)
|
||||
@@ -3030,10 +3290,12 @@ namespace Mono.CSharp {
|
||||
return false;
|
||||
}
|
||||
|
||||
expr_type = ec.DeclSpace.ResolveType (type, false, loc);
|
||||
if (expr_type == null)
|
||||
TypeExpr texpr = type.ResolveAsTypeTerminal (ec, false);
|
||||
if (texpr == null)
|
||||
return false;
|
||||
|
||||
expr_type = texpr.ResolveType (ec);
|
||||
|
||||
CheckObsolete (expr_type);
|
||||
|
||||
if (ec.RemapToProxy){
|
||||
@@ -3297,10 +3559,12 @@ namespace Mono.CSharp {
|
||||
public override bool Resolve (EmitContext ec)
|
||||
{
|
||||
if (type_expr != null) {
|
||||
type = ec.DeclSpace.ResolveType (type_expr, false, loc);
|
||||
if (type == null)
|
||||
TypeExpr te = type_expr.ResolveAsTypeTerminal (ec, false);
|
||||
if (te == null)
|
||||
return false;
|
||||
|
||||
type = te.ResolveType (ec);
|
||||
|
||||
CheckObsolete (type);
|
||||
|
||||
if (type != TypeManager.exception_type && !type.IsSubclassOf (TypeManager.exception_type)){
|
||||
@@ -3499,12 +3763,14 @@ namespace Mono.CSharp {
|
||||
//
|
||||
bool ResolveLocalVariableDecls (EmitContext ec)
|
||||
{
|
||||
expr_type = ec.DeclSpace.ResolveType (expr, false, loc);
|
||||
int i = 0;
|
||||
|
||||
if (expr_type == null)
|
||||
TypeExpr texpr = expr.ResolveAsTypeTerminal (ec, false);
|
||||
if (texpr == null)
|
||||
return false;
|
||||
|
||||
expr_type = texpr.ResolveType (ec);
|
||||
|
||||
//
|
||||
// The type must be an IDisposable or an implicit conversion
|
||||
// must exist.
|
||||
@@ -3774,10 +4040,12 @@ namespace Mono.CSharp {
|
||||
if (expr == null)
|
||||
return false;
|
||||
|
||||
var_type = ec.DeclSpace.ResolveType (type, false, loc);
|
||||
if (var_type == null)
|
||||
TypeExpr texpr = type.ResolveAsTypeTerminal (ec, false);
|
||||
if (texpr == null)
|
||||
return false;
|
||||
|
||||
|
||||
var_type = texpr.ResolveType (ec);
|
||||
|
||||
//
|
||||
// We need an instance variable. Not sure this is the best
|
||||
// way of doing this.
|
||||
@@ -3822,6 +4090,8 @@ 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;
|
||||
@@ -3951,6 +4221,8 @@ namespace Mono.CSharp {
|
||||
|
||||
static bool GetEnumeratorFilter (MemberInfo m, object criteria)
|
||||
{
|
||||
Report.Debug (64, "GET ENUMERATOR FILTER", m, criteria);
|
||||
|
||||
if (m == null)
|
||||
return false;
|
||||
|
||||
@@ -4083,9 +4355,15 @@ 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;){
|
||||
if (TryType (tt, hm))
|
||||
Report.Debug (64, "PROBE COLLECTION TYPE #1", t, tt);
|
||||
|
||||
if (TryType (tt, hm)) {
|
||||
Report.Debug (64, "PROBE COLLECTION TYPE #2", t, tt);
|
||||
return hm;
|
||||
}
|
||||
tt = tt.BaseType;
|
||||
}
|
||||
|
||||
@@ -4095,9 +4373,14 @@ namespace Mono.CSharp {
|
||||
while (t != null){
|
||||
Type [] ifaces = t.GetInterfaces ();
|
||||
|
||||
Report.Debug (64, "PROBE COLLECTION TYPE #3", t, ifaces);
|
||||
|
||||
foreach (Type i in ifaces){
|
||||
if (TryType (i, hm))
|
||||
Report.Debug (64, "PROBE COLLECTION TYPE #4", t, ifaces, i);
|
||||
if (TryType (i, hm)) {
|
||||
Report.Debug (64, "PROBE COLLECTION TYPE #5", t, ifaces, i);
|
||||
return hm;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -4179,7 +4462,7 @@ namespace Mono.CSharp {
|
||||
|
||||
if (ec.InIterator){
|
||||
conv.Emit (ec);
|
||||
ig.Emit (OpCodes.Stfld, ((FieldExpr) variable).FieldInfo);
|
||||
ig.Emit (OpCodes.Stfld, ((LocalVariableReference) variable).local_info.FieldBuilder);
|
||||
} else
|
||||
((IAssignMethod)variable).EmitAssign (ec, conv, false, false);
|
||||
|
||||
@@ -4288,7 +4571,7 @@ namespace Mono.CSharp {
|
||||
ArrayAccess.EmitLoadOpcode (ig, element_type);
|
||||
if (ec.InIterator){
|
||||
conv.Emit (ec);
|
||||
ig.Emit (OpCodes.Stfld, ((FieldExpr) variable).FieldInfo);
|
||||
ig.Emit (OpCodes.Stfld, ((LocalVariableReference) variable).local_info.FieldBuilder);
|
||||
} else
|
||||
((IAssignMethod)variable).EmitAssign (ec, conv, false, false);
|
||||
|
||||
@@ -4368,7 +4651,7 @@ namespace Mono.CSharp {
|
||||
ig.Emit (OpCodes.Call, get);
|
||||
if (ec.InIterator){
|
||||
conv.Emit (ec);
|
||||
ig.Emit (OpCodes.Stfld, ((FieldExpr) variable).FieldInfo);
|
||||
ig.Emit (OpCodes.Stfld, ((LocalVariableReference) variable).local_info.FieldBuilder);
|
||||
} else
|
||||
((IAssignMethod)variable).EmitAssign (ec, conv, false, false);
|
||||
statement.Emit (ec);
|
||||
|
||||
+6
-7
@@ -140,10 +140,13 @@ 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)
|
||||
@@ -174,11 +177,7 @@ 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)
|
||||
@@ -187,9 +186,9 @@ namespace Mono.CSharp {
|
||||
count = param_types.Length;
|
||||
}
|
||||
|
||||
public InternalParameters (DeclSpace ds, Parameters parameters,
|
||||
public InternalParameters (Type [] param_types, Parameters parameters,
|
||||
TypeParameter [] type_params)
|
||||
: this (ds, parameters)
|
||||
: this (param_types, parameters)
|
||||
{
|
||||
this.TypeParameters = type_params;
|
||||
}
|
||||
|
||||
+107
-5
@@ -89,12 +89,14 @@ 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;
|
||||
@@ -121,6 +123,7 @@ 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
|
||||
@@ -361,6 +364,7 @@ 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 ()
|
||||
@@ -505,6 +509,54 @@ 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) {
|
||||
@@ -1177,6 +1229,7 @@ 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
|
||||
@@ -1270,6 +1323,11 @@ 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);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1944,6 +2002,48 @@ 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);
|
||||
@@ -2832,7 +2932,7 @@ public class TypeManager {
|
||||
|
||||
if (ma == MethodAttributes.Private)
|
||||
return private_ok ||
|
||||
IsEqual (invocation_type, mb.DeclaringType) ||
|
||||
IsPrivateAccessible (invocation_type, mb.DeclaringType) ||
|
||||
IsNestedChildOf (invocation_type, mb.DeclaringType);
|
||||
|
||||
//
|
||||
@@ -2883,7 +2983,7 @@ public class TypeManager {
|
||||
|
||||
if (fa == FieldAttributes.Private)
|
||||
return private_ok ||
|
||||
IsEqual (invocation_type, fi.DeclaringType) ||
|
||||
IsPrivateAccessible (invocation_type, fi.DeclaringType) ||
|
||||
IsNestedChildOf (invocation_type, fi.DeclaringType);
|
||||
|
||||
//
|
||||
@@ -2944,7 +3044,7 @@ public class TypeManager {
|
||||
|
||||
if (((qualifier_type == null) || (qualifier_type == invocation_type)) &&
|
||||
(invocation_type != null) &&
|
||||
IsEqual (m.DeclaringType, invocation_type))
|
||||
IsPrivateAccessible (m.DeclaringType, invocation_type))
|
||||
return true;
|
||||
|
||||
//
|
||||
@@ -3106,8 +3206,10 @@ 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)
|
||||
@@ -3312,7 +3414,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);
|
||||
this.member_cache = new MemberCache (this, true);
|
||||
}
|
||||
|
||||
// IMemberContainer methods
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
|
||||
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
@@ -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_token (m, mh->clauses[i].token_or_filter);
|
||||
dis_stringify_object_with_class (m, mh->clauses[i].data.catch_class);
|
||||
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 == 1 && ptr == start + mh->clauses[i].token_or_filter) {
|
||||
if (mh->clauses[i].flags == MONO_EXCEPTION_CLAUSE_FILTER && ptr == start + mh->clauses[i].data.filter_offset) {
|
||||
fprintf (output, "\t%s%s {\n", indent, clause_names[1]);
|
||||
CODE_INDENT;
|
||||
}
|
||||
|
||||
+1
-1
@@ -703,7 +703,7 @@ dis_stringify_function_ptr (MonoImage *m, MonoMethodSignature *method)
|
||||
return retval;
|
||||
}
|
||||
|
||||
static char *
|
||||
char *
|
||||
dis_stringify_object_with_class (MonoImage *m, MonoClass *c)
|
||||
{
|
||||
/* FIXME: handle MONO_TYPE_OBJECT ... */
|
||||
|
||||
@@ -8,6 +8,7 @@ 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);
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
|
||||
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
|
||||
|
||||
@@ -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, mono_class_get (method->klass->image, clause->token_or_filter))) {
|
||||
if (mono_object_isinst ((MonoObject*)frame->ex, clause->data.catch_class)) {
|
||||
/*
|
||||
* OK, we found an handler, now we need to execute the finally
|
||||
* and fault blocks before branching to the handler code.
|
||||
|
||||
@@ -1,3 +1,60 @@
|
||||
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):
|
||||
|
||||
@@ -132,25 +132,17 @@ 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)
|
||||
return FALSE;
|
||||
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_tok_value && !r->public_tok_value)
|
||||
if (!l->public_key_token [0] || !r->public_key_token [0])
|
||||
return TRUE;
|
||||
|
||||
if ((l->public_tok_value && !r->public_tok_value) || (!l->public_tok_value && r->public_tok_value))
|
||||
if (strcmp (l->public_key_token, r->public_key_token))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (l->public_tok_value, r->public_tok_value))
|
||||
return FALSE;
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -339,10 +339,11 @@ struct _MonoGenericContext {
|
||||
|
||||
struct _MonoGenericContainer {
|
||||
MonoGenericContainer *parent;
|
||||
MonoGenericContext *context;
|
||||
MonoClass *klass;
|
||||
MonoMethod *method;
|
||||
MonoMethodSignature *signature;
|
||||
int type_argc;
|
||||
int type_argc : 6;
|
||||
int is_method : 1;
|
||||
int is_signature : 1;
|
||||
MonoGenericParam *type_params;
|
||||
};
|
||||
|
||||
|
||||
@@ -398,6 +398,7 @@ 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))
|
||||
@@ -415,11 +416,10 @@ mono_class_inflate_generic_method (MonoMethod *method, MonoGenericContext *conte
|
||||
mono_method_get_header (method), context);
|
||||
|
||||
if (klass)
|
||||
result->nmethod.method.klass = klass;
|
||||
rklass = result->nmethod.method.klass = klass;
|
||||
else {
|
||||
MonoType *declaring = mono_class_inflate_generic_type (
|
||||
&method->klass->byval_arg, context);
|
||||
result->nmethod.method.klass = mono_class_from_mono_type (declaring);
|
||||
MonoType *declaring = mono_class_inflate_generic_type (&method->klass->byval_arg, context);
|
||||
rklass = 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 = result->nmethod.method.klass->generic_inst;
|
||||
result->context->ginst = rklass->generic_inst;
|
||||
|
||||
mono_stats.generics_metadata_size += sizeof (MonoGenericContext);
|
||||
} else
|
||||
result->context = result->nmethod.method.klass->generic_inst->context;
|
||||
} else if (rklass->generic_inst)
|
||||
result->context = rklass->generic_inst->context;
|
||||
|
||||
if (method->signature->is_inflated)
|
||||
result->declaring = ((MonoMethodInflated *) method)->declaring;
|
||||
|
||||
@@ -39,7 +39,7 @@ typedef struct {
|
||||
gpointer try_end;
|
||||
gpointer handler_start;
|
||||
union {
|
||||
guint32 token;
|
||||
MonoClass *catch_class;
|
||||
gpointer filter;
|
||||
} data;
|
||||
} MonoJitExceptionInfo;
|
||||
|
||||
+5
-30
@@ -254,12 +254,6 @@ 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: \
|
||||
@@ -1752,9 +1746,7 @@ ves_icall_MonoType_GetGenericArguments (MonoReflectionType *type)
|
||||
|
||||
klass = mono_class_from_mono_type (type->type);
|
||||
|
||||
if (type->type->byref) {
|
||||
res = mono_array_new (mono_object_domain (type), mono_defaults.monotype_class, 0);
|
||||
} else if (klass->generic_container) {
|
||||
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) {
|
||||
@@ -1779,8 +1771,6 @@ 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;
|
||||
@@ -1792,8 +1782,6 @@ 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 */
|
||||
@@ -1818,9 +1806,6 @@ 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);
|
||||
|
||||
@@ -1840,8 +1825,6 @@ 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;
|
||||
}
|
||||
@@ -1851,8 +1834,6 @@ 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;
|
||||
@@ -1896,8 +1877,6 @@ 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;
|
||||
@@ -1909,8 +1888,6 @@ 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;
|
||||
@@ -1921,8 +1898,6 @@ 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;
|
||||
@@ -2154,9 +2129,6 @@ 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;
|
||||
@@ -4886,7 +4858,10 @@ 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;
|
||||
|
||||
memcpy (dest_buf, src_buf, count);
|
||||
if (src != dest)
|
||||
memcpy (dest_buf, src_buf, count);
|
||||
else
|
||||
memmove (dest_buf, src_buf, count); /* Source and dest are the same array */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
+21
-10
@@ -423,11 +423,11 @@ method_from_memberref (MonoImage *image, guint32 idx, MonoGenericContext *contex
|
||||
}
|
||||
|
||||
static MonoMethod *
|
||||
method_from_methodspec (MonoImage *image, MonoGenericContainer *generic_container, guint32 idx)
|
||||
method_from_methodspec (MonoImage *image, MonoGenericContext *context, guint32 idx)
|
||||
{
|
||||
MonoMethod *method, *inflated;
|
||||
MonoTableInfo *tables = image->tables;
|
||||
MonoGenericContext *context;
|
||||
MonoGenericContext *new_context = NULL;
|
||||
MonoGenericMethod *gmethod;
|
||||
MonoGenericContainer *container = NULL;
|
||||
const char *ptr;
|
||||
@@ -454,9 +454,15 @@ method_from_methodspec (MonoImage *image, MonoGenericContainer *generic_containe
|
||||
container = ((MonoMethodNormal *) ((MonoMethodInflated *) method)->declaring)->generic_container;
|
||||
else
|
||||
container = ((MonoMethodNormal *) method)->generic_container;
|
||||
g_assert (container && container->method);
|
||||
if (generic_container)
|
||||
container->parent = 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;
|
||||
}
|
||||
|
||||
gmethod = g_new0 (MonoGenericMethod, 1);
|
||||
gmethod->container = container;
|
||||
@@ -471,15 +477,20 @@ method_from_methodspec (MonoImage *image, MonoGenericContainer *generic_containe
|
||||
gmethod->is_open = mono_class_is_open_constructed_type (gmethod->mtype_argv [i]);
|
||||
}
|
||||
|
||||
context = g_new0 (MonoGenericContext, 1);
|
||||
context->gmethod = gmethod;
|
||||
if (!context) {
|
||||
new_context = g_new0 (MonoGenericContext, 1);
|
||||
new_context->gmethod = gmethod;
|
||||
|
||||
context = new_context;
|
||||
}
|
||||
|
||||
mono_stats.generics_metadata_size += sizeof (MonoGenericMethod) +
|
||||
sizeof (MonoGenericContext) + param_count * sizeof (MonoType);
|
||||
|
||||
inflated = mono_class_inflate_generic_method (method, context, NULL);
|
||||
|
||||
context->ginst = inflated->klass->generic_inst;
|
||||
if (new_context)
|
||||
context->ginst = inflated->klass->generic_inst;
|
||||
return inflated;
|
||||
}
|
||||
|
||||
@@ -794,7 +805,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, generic_container, idx);
|
||||
return method_from_methodspec (image, context, idx);
|
||||
if (table != MONO_TABLE_MEMBERREF)
|
||||
g_print("got wrong token: 0x%08x\n", token);
|
||||
g_assert (table == MONO_TABLE_MEMBERREF);
|
||||
@@ -826,7 +837,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->method = result;
|
||||
generic_container->is_method = 1;
|
||||
container = generic_container;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2434,7 +2434,7 @@ handle_enum:
|
||||
clause->try_len = mb->pos;
|
||||
|
||||
/* filter code */
|
||||
clause->token_or_filter = mb->pos;
|
||||
clause->data.filter_offset = mb->pos;
|
||||
|
||||
mono_mb_emit_byte (mb, CEE_POP);
|
||||
mono_mb_emit_byte (mb, CEE_LDARG_2);
|
||||
|
||||
+28
-24
@@ -1450,10 +1450,13 @@ 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->method)) {
|
||||
if (gen_param_count && (!generic_container || !generic_container->is_method)) {
|
||||
container = g_new0 (MonoGenericContainer, 1);
|
||||
container->parent = generic_container;
|
||||
container->signature = method;
|
||||
container->is_signature = 1;
|
||||
|
||||
container->context = g_new0 (MonoGenericContext, 1);
|
||||
container->context->container = container;
|
||||
|
||||
container->type_argc = gen_param_count;
|
||||
container->type_params = g_new0 (MonoGenericParam, gen_param_count);
|
||||
@@ -1623,12 +1626,12 @@ mono_metadata_parse_generic_param (MonoImage *m, MonoGenericContainer *generic_c
|
||||
*/
|
||||
generic_container = generic_container->parent;
|
||||
}
|
||||
g_assert (generic_container && !generic_container->method);
|
||||
g_assert (generic_container && !generic_container->is_method);
|
||||
g_assert (index < generic_container->type_argc);
|
||||
|
||||
return &generic_container->type_params [index];
|
||||
} else {
|
||||
g_assert (generic_container && (generic_container->method || generic_container->signature));
|
||||
g_assert (generic_container && (generic_container->is_method || generic_container->is_signature));
|
||||
g_assert (index < generic_container->type_argc);
|
||||
|
||||
return &generic_container->type_params [index];
|
||||
@@ -1731,6 +1734,11 @@ 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)
|
||||
@@ -1777,7 +1785,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 (MonoMethodHeader *mh, const unsigned char *ptr)
|
||||
parse_section_data (MonoImage *m, MonoMethodHeader *mh, const unsigned char *ptr)
|
||||
{
|
||||
unsigned char sect_data_flags;
|
||||
const unsigned char *sptr;
|
||||
@@ -1815,9 +1823,8 @@ parse_section_data (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);
|
||||
@@ -1828,7 +1835,7 @@ parse_section_data (MonoMethodHeader *mh, const unsigned char *ptr)
|
||||
p += 4;
|
||||
ec->handler_len = read32 (p);
|
||||
p += 4;
|
||||
ec->token_or_filter = read32 (p);
|
||||
tof_value = read32 (p);
|
||||
p += 4;
|
||||
} else {
|
||||
ec->flags = read16 (p);
|
||||
@@ -1841,9 +1848,16 @@ parse_section_data (MonoMethodHeader *mh, const unsigned char *ptr)
|
||||
p += 2;
|
||||
ec->handler_len = *p;
|
||||
++p;
|
||||
ec->token_or_filter = read32 (p);
|
||||
tof_value = 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); */
|
||||
}
|
||||
|
||||
@@ -1958,7 +1972,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 (mh, (const unsigned char*)ptr);
|
||||
parse_section_data (m, mh, (const unsigned char*)ptr);
|
||||
return mh;
|
||||
}
|
||||
|
||||
@@ -2694,16 +2708,6 @@ 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.
|
||||
@@ -3596,7 +3600,6 @@ 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)
|
||||
@@ -3605,6 +3608,7 @@ 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)
|
||||
@@ -3638,11 +3642,11 @@ mono_metadata_load_generic_params (MonoImage *image, guint32 token)
|
||||
container->type_argc = n;
|
||||
container->type_params = params;
|
||||
|
||||
context = g_new0 (MonoGenericContext, 1);
|
||||
context->container = container;
|
||||
container->context = g_new0 (MonoGenericContext, 1);
|
||||
container->context->container = container;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
params [i].constraints = get_constraints (image, i + 1, context);
|
||||
params [i].constraints = get_constraints (image, i + 1, container->context);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
@@ -268,7 +268,10 @@ typedef struct {
|
||||
guint32 try_len;
|
||||
guint32 handler_offset;
|
||||
guint32 handler_len;
|
||||
guint32 token_or_filter;
|
||||
union {
|
||||
guint32 filter_offset;
|
||||
MonoClass *catch_class;
|
||||
} data;
|
||||
} MonoExceptionClause;
|
||||
|
||||
typedef struct _MonoType MonoType;
|
||||
|
||||
+48
-27
@@ -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) {
|
||||
mono_g_hash_table_insert (assembly->tokens,
|
||||
GUINT_TO_POINTER (clause->token_or_filter), 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;
|
||||
}
|
||||
finally_start = ex_block->start + ex_block->len;
|
||||
|
||||
@@ -981,7 +981,6 @@ 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;
|
||||
@@ -989,7 +988,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 *= sizeof (MonoExceptionClause);
|
||||
num_exception *= 6 * sizeof (guint32);
|
||||
num_exception += 4; /* include the size of the header */
|
||||
sheader [1] = num_exception & 0xff;
|
||||
sheader [2] = (num_exception >> 8) & 0xff;
|
||||
@@ -1002,23 +1001,37 @@ 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);
|
||||
clause.flags = GUINT32_TO_LE (ex_block->type);
|
||||
clause.try_offset = GUINT32_TO_LE (ex_info->start);
|
||||
/* 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));
|
||||
/* need fault, too, probably */
|
||||
if (ex_block->type == MONO_EXCEPTION_CLAUSE_FINALLY)
|
||||
clause.try_len = GUINT32_TO_LE (finally_start - ex_info->start);
|
||||
val = GUINT32_TO_LE (finally_start - ex_info->start);
|
||||
else
|
||||
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);
|
||||
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));
|
||||
finally_start = ex_block->start + 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;
|
||||
clause.token_or_filter = GUINT32_TO_LE (clause.token_or_filter);
|
||||
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));
|
||||
/*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);
|
||||
@@ -7315,6 +7328,9 @@ 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;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -7784,18 +7800,24 @@ do_mono_reflection_bind_generic_parameters (MonoReflectionType *type, int type_a
|
||||
|
||||
ginst = g_new0 (MonoGenericInst, 1);
|
||||
|
||||
if (!klass->generic_inst) {
|
||||
ginst->type_argc = type_argc;
|
||||
ginst->type_argv = types;
|
||||
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;
|
||||
} else {
|
||||
ginst->generic_type = &klass->byval_arg;
|
||||
|
||||
if (klass->generic_inst) {
|
||||
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);
|
||||
@@ -7803,8 +7825,7 @@ 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];
|
||||
|
||||
if (t->type == MONO_TYPE_VAR)
|
||||
t = types [t->data.generic_param->num];
|
||||
t = mono_class_inflate_generic_type (t, oginst->context);
|
||||
|
||||
if (!ginst->is_open)
|
||||
ginst->is_open = mono_class_is_open_constructed_type (t);
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
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.
|
||||
|
||||
+7
-3
@@ -387,6 +387,8 @@ 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 *
|
||||
@@ -469,6 +471,8 @@ 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;
|
||||
@@ -560,7 +564,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.token = *(guint32*)info;
|
||||
ei->data.catch_class = ec->data.catch_class;
|
||||
info += 4;
|
||||
ei->try_start = code + *(guint32*)info;
|
||||
info += 4;
|
||||
@@ -1065,8 +1069,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
|
||||
/* fixme: tokens are not global */
|
||||
fprintf (tmpfp, "\t.long %d\n", ei->data.token);
|
||||
/* the class is loaded from the header: optimize away later */
|
||||
fprintf (tmpfp, "\t.long %d\n", 0);
|
||||
|
||||
fprintf (tmpfp, "\t.long %d\n", (gint)((guint8*)ei->try_start - code));
|
||||
fprintf (tmpfp, "\t.long %d\n", (gint)((guint8*)ei->try_end - code));
|
||||
|
||||
@@ -446,7 +446,7 @@ rem_un_imm: dest:i src1:i src2:i len:24
|
||||
rename:
|
||||
ret:
|
||||
retarg:
|
||||
rethrow:
|
||||
rethrow: src1:i len:8
|
||||
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
|
||||
|
||||
@@ -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, mono_class_get (ji->method->klass->image, ei->data.token))) || filtered) {
|
||||
mono_object_isinst (obj, ei->data.catch_class)) || filtered) {
|
||||
if (test_only) {
|
||||
if (mono_ex) {
|
||||
trace_ips = g_list_reverse (trace_ips);
|
||||
|
||||
+42
-10
@@ -42,7 +42,8 @@
|
||||
|
||||
#define S390_THROWSTACK_ACCPRM S390_MINIMAL_STACK_SIZE
|
||||
#define S390_THROWSTACK_FPCPRM S390_THROWSTACK_ACCPRM+sizeof(gpointer)
|
||||
#define S390_THROWSTACK_INTREGS S390_THROWSTACK_FPCPRM+sizeof(gulong)
|
||||
#define S390_THROWSTACK_RETHROW S390_THROWSTACK_FPCPRM+sizeof(gulong)
|
||||
#define S390_THROWSTACK_INTREGS S390_THROWSTACK_RETHROW+sizeof(gboolean)
|
||||
#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)))
|
||||
@@ -258,7 +259,8 @@ 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)
|
||||
gulong *int_regs, gdouble *fp_regs, gulong *acc_regs,
|
||||
guint fpc, gboolean rethrow)
|
||||
{
|
||||
static void (*restore_context) (MonoContext *);
|
||||
MonoContext ctx;
|
||||
@@ -284,7 +286,8 @@ throw_exception (MonoObject *exc, unsigned long ip, unsigned long sp,
|
||||
|
||||
if (mono_object_isinst (exc, mono_defaults.exception_class)) {
|
||||
MonoException *mono_ex = (MonoException*)exc;
|
||||
mono_ex->stack_trace = NULL;
|
||||
if (!rethrow)
|
||||
mono_ex->stack_trace = NULL;
|
||||
}
|
||||
mono_arch_handle_exception (&ctx, exc, FALSE);
|
||||
setcontext(&ctx);
|
||||
@@ -296,7 +299,7 @@ throw_exception (MonoObject *exc, unsigned long ip, unsigned long sp,
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* Name - arch_get_throw_exception_generic */
|
||||
/* Name - get_throw_exception_generic */
|
||||
/* */
|
||||
/* Function - Return a function pointer which can be used to */
|
||||
/* raise exceptions. The returned function has the */
|
||||
@@ -307,7 +310,8 @@ throw_exception (MonoObject *exc, unsigned long ip, unsigned long sp,
|
||||
/*------------------------------------------------------------------*/
|
||||
|
||||
static gpointer
|
||||
mono_arch_get_throw_exception_generic (guint8 *start, int size, int by_name)
|
||||
get_throw_exception_generic (guint8 *start, int size,
|
||||
int by_name, gboolean rethrow)
|
||||
{
|
||||
guint8 *code;
|
||||
int alloc_size, pos, i, offset;
|
||||
@@ -367,6 +371,8 @@ mono_arch_get_throw_exception_generic (guint8 *start, int size, int by_name)
|
||||
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 */
|
||||
@@ -391,12 +397,38 @@ mono_arch_get_throw_exception_generic (guint8 *start, int size, int by_name)
|
||||
gpointer
|
||||
mono_arch_get_throw_exception (void)
|
||||
{
|
||||
static guint8 start [256];
|
||||
static guint8 start [384];
|
||||
static int inited = 0;
|
||||
|
||||
if (inited)
|
||||
return start;
|
||||
mono_arch_get_throw_exception_generic (start, sizeof (start), FALSE);
|
||||
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);
|
||||
inited = 1;
|
||||
return start;
|
||||
}
|
||||
@@ -417,12 +449,12 @@ mono_arch_get_throw_exception (void)
|
||||
gpointer
|
||||
mono_arch_get_throw_exception_by_name (void)
|
||||
{
|
||||
static guint8 start [160];
|
||||
static guint8 start [384];
|
||||
static int inited = 0;
|
||||
|
||||
if (inited)
|
||||
return start;
|
||||
mono_arch_get_throw_exception_generic (start, sizeof (start), TRUE);
|
||||
get_throw_exception_generic (start, sizeof (start), TRUE, FALSE);
|
||||
inited = 1;
|
||||
return start;
|
||||
}
|
||||
@@ -870,7 +902,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, mono_class_get (ji->method->klass->image, ei->data.token))) ||
|
||||
(mono_object_isinst (obj, ei->data.catch_class)) ||
|
||||
(filtered)) {
|
||||
if (test_only) {
|
||||
if (mono_ex) {
|
||||
|
||||
@@ -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, mono_class_get (ji->method->klass->image, ei->data.token))) ||
|
||||
mono_object_isinst (obj, ei->data.catch_class)) ||
|
||||
((ei->flags == MONO_EXCEPTION_CLAUSE_FILTER &&
|
||||
call_filter (ctx, ei->data.filter, obj)))) {
|
||||
if (test_only) {
|
||||
|
||||
@@ -585,8 +585,9 @@ 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_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);
|
||||
tree->inst_offset = state->tree->inst_offset;
|
||||
tree->inst_basereg = tmpr;
|
||||
}
|
||||
@@ -614,9 +615,11 @@ 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_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, tmpr,
|
||||
state->left->tree->inst_offset);
|
||||
tree->inst_offset = 0;
|
||||
|
||||
@@ -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,6 +209,11 @@ 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);
|
||||
|
||||
@@ -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, mono_class_get (ji->method->klass->image, ei->data.token))) || filtered) {
|
||||
mono_object_isinst (obj, ei->data.catch_class)) || filtered) {
|
||||
if (test_only) {
|
||||
if (mono_ex) {
|
||||
trace_ips = g_list_reverse (trace_ips);
|
||||
|
||||
+83
-72
@@ -98,19 +98,19 @@ if (ins->flags & MONO_INST_BRLABEL) { \
|
||||
|
||||
#undef DEBUG
|
||||
#define DEBUG(a) if (cfg->verbose_level > 1) a
|
||||
#define reg_is_freeable(r) ((r) >= 3 && (r) <= 10)
|
||||
|
||||
/*----------------------------------------*/
|
||||
/* 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 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,8 +930,11 @@ 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;
|
||||
}
|
||||
|
||||
@@ -1021,10 +1024,12 @@ GList *
|
||||
mono_arch_get_global_int_regs (MonoCompile *cfg)
|
||||
{
|
||||
GList *regs = NULL;
|
||||
int i, top = 12;
|
||||
int i, top = 13;
|
||||
|
||||
for (i = 3; i < top; ++i)
|
||||
regs = g_list_prepend (regs, GUINT_TO_POINTER (i));
|
||||
for (i = 8; i < top; ++i) {
|
||||
if (cfg->frame_reg != i)
|
||||
regs = g_list_prepend (regs, GUINT_TO_POINTER (i));
|
||||
}
|
||||
|
||||
return regs;
|
||||
}
|
||||
@@ -1357,7 +1362,7 @@ enum_retvalue:
|
||||
/*------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
mono_arch_allocate_vars (MonoCompile *m)
|
||||
mono_arch_allocate_vars (MonoCompile *cfg)
|
||||
{
|
||||
MonoMethodSignature *sig;
|
||||
MonoMethodHeader *header;
|
||||
@@ -1368,7 +1373,7 @@ mono_arch_allocate_vars (MonoCompile *m)
|
||||
int frame_reg = STK_BASE;
|
||||
int sArg, eArg;
|
||||
|
||||
header = mono_method_get_header (m->method);
|
||||
header = mono_method_get_header (cfg->method);
|
||||
|
||||
/*---------------------------------------------------------*/
|
||||
/* We use the frame register also for any method that has */
|
||||
@@ -1380,29 +1385,29 @@ mono_arch_allocate_vars (MonoCompile *m)
|
||||
/* before stack unwinding happens) when the filter code */
|
||||
/* would call any method. */
|
||||
/*---------------------------------------------------------*/
|
||||
if ((m->flags & MONO_CFG_HAS_ALLOCA) || header->num_clauses)
|
||||
if ((cfg->flags & MONO_CFG_HAS_ALLOCA) || header->num_clauses)
|
||||
frame_reg = s390_r11;
|
||||
|
||||
m->frame_reg = frame_reg;
|
||||
cfg->frame_reg = frame_reg;
|
||||
|
||||
if (frame_reg != STK_BASE)
|
||||
m->used_int_regs |= 1 << frame_reg;
|
||||
cfg->used_int_regs |= 1 << frame_reg;
|
||||
|
||||
sig = m->method->signature;
|
||||
sig = cfg->method->signature;
|
||||
|
||||
cinfo = calculate_sizes (sig, &sz, sig->pinvoke);
|
||||
|
||||
if (cinfo->struct_ret) {
|
||||
m->ret->opcode = OP_REGVAR;
|
||||
m->ret->inst_c0 = s390_r2;
|
||||
cfg->ret->opcode = OP_REGVAR;
|
||||
cfg->ret->inst_c0 = s390_r2;
|
||||
} else {
|
||||
/* FIXME: handle long and FP values */
|
||||
switch (sig->ret->type) {
|
||||
case MONO_TYPE_VOID:
|
||||
break;
|
||||
default:
|
||||
m->ret->opcode = OP_REGVAR;
|
||||
m->ret->dreg = s390_r2;
|
||||
cfg->ret->opcode = OP_REGVAR;
|
||||
cfg->ret->dreg = s390_r2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1414,10 +1419,10 @@ mono_arch_allocate_vars (MonoCompile *m)
|
||||
/* to point at the local variables. */
|
||||
/* add parameter area size for called functions */
|
||||
/*--------------------------------------------------------------*/
|
||||
offset = (m->param_area + S390_MINIMAL_STACK_SIZE);
|
||||
offset = (cfg->param_area + S390_MINIMAL_STACK_SIZE);
|
||||
|
||||
if (cinfo->struct_ret) {
|
||||
inst = m->ret;
|
||||
inst = cfg->ret;
|
||||
offset = S390_ALIGN(offset, sizeof(gpointer));
|
||||
inst->inst_offset = offset;
|
||||
inst->opcode = OP_REGOFFSET;
|
||||
@@ -1426,7 +1431,7 @@ mono_arch_allocate_vars (MonoCompile *m)
|
||||
}
|
||||
|
||||
if (sig->hasthis) {
|
||||
inst = m->varinfo [0];
|
||||
inst = cfg->varinfo [0];
|
||||
if (inst->opcode != OP_REGVAR) {
|
||||
inst->opcode = OP_REGOFFSET;
|
||||
inst->inst_basereg = frame_reg;
|
||||
@@ -1442,7 +1447,7 @@ mono_arch_allocate_vars (MonoCompile *m)
|
||||
eArg = sig->param_count + sArg;
|
||||
|
||||
for (iParm = sArg; iParm < eArg; ++iParm) {
|
||||
inst = m->varinfo [curinst];
|
||||
inst = cfg->varinfo [curinst];
|
||||
if (inst->opcode != OP_REGVAR) {
|
||||
switch (cinfo->args[iParm].regtype) {
|
||||
case RegTypeStructByAddr :
|
||||
@@ -1485,10 +1490,11 @@ mono_arch_allocate_vars (MonoCompile *m)
|
||||
curinst++;
|
||||
}
|
||||
|
||||
curinst = m->locals_start;
|
||||
for (iVar = curinst; iVar < m->num_varinfo; ++iVar) {
|
||||
inst = m->varinfo [iVar];
|
||||
if (inst->opcode == OP_REGVAR)
|
||||
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))
|
||||
continue;
|
||||
|
||||
/*--------------------------------------------------*/
|
||||
@@ -1506,25 +1512,25 @@ mono_arch_allocate_vars (MonoCompile *m)
|
||||
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 (m))
|
||||
if (mono_jit_trace_calls != NULL && mono_trace_eval (cfg))
|
||||
offset += S390_TRACE_STACK_SIZE;
|
||||
|
||||
/*------------------------------------------------------*/
|
||||
/* Reserve space to save LMF and caller saved registers */
|
||||
/*------------------------------------------------------*/
|
||||
if (m->method->save_lmf)
|
||||
if (cfg->method->save_lmf)
|
||||
offset += sizeof (MonoLMF);
|
||||
|
||||
/*------------------------------------------------------*/
|
||||
/* align the offset */
|
||||
/*------------------------------------------------------*/
|
||||
m->stack_offset = S390_ALIGN(offset, S390_STACK_ALIGNMENT);
|
||||
cfg->stack_offset = S390_ALIGN(offset, S390_STACK_ALIGNMENT);
|
||||
|
||||
}
|
||||
|
||||
@@ -1568,7 +1574,7 @@ mono_arch_call_opcode (MonoCompile *cfg, MonoBasicBlock* bb,
|
||||
cfg->flags |= MONO_CFG_HAS_CALLS;
|
||||
|
||||
if (cinfo->struct_ret)
|
||||
call->used_iregs |= 1 << cinfo->struct_ret;
|
||||
call->used_iregs |= 1 << cinfo->ret.reg;
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
ainfo = cinfo->args + i;
|
||||
@@ -2579,10 +2585,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;
|
||||
@@ -2615,7 +2621,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 eax:edx, the virtual register is allocated sequentially */
|
||||
/* result in R2/R3, 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)
|
||||
@@ -2764,7 +2770,10 @@ 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);
|
||||
}
|
||||
@@ -2797,7 +2806,6 @@ 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);
|
||||
@@ -2922,16 +2930,6 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -3067,49 +3065,49 @@ guint8 cond;
|
||||
|
||||
switch (ins->opcode) {
|
||||
case OP_STOREI1_MEMBASE_IMM: {
|
||||
s390_lhi (code, s390_r14, ins->inst_imm);
|
||||
s390_lhi (code, s390_r0, ins->inst_imm);
|
||||
if (s390_is_uimm12(ins->inst_offset))
|
||||
s390_stc (code, s390_r14, 0, ins->inst_destbasereg, ins->inst_offset);
|
||||
s390_stc (code, s390_r0, 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_r14, s390_r13, ins->inst_destbasereg, 0);
|
||||
s390_stc (code, s390_r0, s390_r13, ins->inst_destbasereg, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OP_STOREI2_MEMBASE_IMM: {
|
||||
s390_lhi (code, s390_r14, ins->inst_imm);
|
||||
s390_lhi (code, s390_r0, ins->inst_imm);
|
||||
if (s390_is_uimm12(ins->inst_offset)) {
|
||||
s390_sth (code, s390_r14, 0, ins->inst_destbasereg, ins->inst_offset);
|
||||
s390_sth (code, s390_r0, 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_r14, s390_r13, ins->inst_destbasereg, 0);
|
||||
s390_sth (code, s390_r0, 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_r14, ins->inst_imm);
|
||||
s390_lhi (code, s390_r0, ins->inst_imm);
|
||||
} else {
|
||||
s390_basr (code, s390_r13, 0);
|
||||
s390_j (code, 4);
|
||||
s390_word (code, ins->inst_imm);
|
||||
s390_l (code, s390_r14, 0, s390_r13, 4);
|
||||
s390_l (code, s390_r0, 0, s390_r13, 4);
|
||||
}
|
||||
if (s390_is_uimm12(ins->inst_offset)) {
|
||||
s390_st (code, s390_r14, 0, ins->inst_destbasereg, ins->inst_offset);
|
||||
s390_st (code, s390_r0, 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_r14, s390_r13, ins->inst_destbasereg, 0);
|
||||
s390_st (code, s390_r0, s390_r13, ins->inst_destbasereg, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -3797,16 +3795,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_srl (code, s390_r14, 0, 31);
|
||||
s390_a (code, s390_r14, 0, ins->sreg1, 0);
|
||||
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_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_r14, s390_r13);
|
||||
s390_st (code, s390_r14, 0, ins->dreg, 0);
|
||||
s390_ar (code, s390_r0, s390_r13);
|
||||
s390_st (code, s390_r0, 0, ins->dreg, 0);
|
||||
s390_st (code, s390_r1, 0, ins->dreg, 4);
|
||||
}
|
||||
break;
|
||||
@@ -3991,6 +3989,13 @@ 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,
|
||||
@@ -4443,6 +4448,7 @@ 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);
|
||||
@@ -4456,6 +4462,7 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5245,11 +5252,15 @@ 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,
|
||||
@@ -5286,7 +5297,7 @@ guint32
|
||||
mono_arch_regalloc_cost (MonoCompile *cfg, MonoMethodVar *vmv)
|
||||
{
|
||||
/* FIXME: */
|
||||
return 3;
|
||||
return 2;
|
||||
}
|
||||
|
||||
/*========================= End of Function ========================*/
|
||||
|
||||
+10
-12
@@ -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->token_or_filter) &&
|
||||
(offset < (clause->token_or_filter + filter_lengths [i])))
|
||||
if ((clause->flags == MONO_EXCEPTION_CLAUSE_FILTER) && (offset >= clause->data.filter_offset) &&
|
||||
(offset < (clause->data.filter_offset + filter_lengths [i])))
|
||||
return ((i + 1) << 8) | MONO_REGION_FILTER | clause->flags;
|
||||
|
||||
if (MONO_OFFSET_IN_HANDLER (clause, offset)) {
|
||||
@@ -2803,10 +2803,8 @@ 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 = g_new0 (MonoGenericContext, 1);
|
||||
generic_context->container = generic_container;
|
||||
}
|
||||
else if (generic_container)
|
||||
generic_context = generic_container->context;
|
||||
|
||||
if (cfg->method == method) {
|
||||
real_offset = 0;
|
||||
@@ -2883,8 +2881,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->token_or_filter);
|
||||
tblock->real_offset = clause->token_or_filter;
|
||||
GET_BBLOCK (cfg, bbhash, tblock, ip + clause->data.filter_offset);
|
||||
tblock->real_offset = clause->data.filter_offset;
|
||||
tblock->in_scount = 1;
|
||||
tblock->in_stack = mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*));
|
||||
tblock->in_stack [0] = cfg->exvar;
|
||||
@@ -5585,13 +5583,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->token_or_filter > nearest->token_or_filter))) {
|
||||
(!nearest || (clause->data.filter_offset > nearest->data.filter_offset))) {
|
||||
nearest = clause;
|
||||
nearest_num = cc;
|
||||
}
|
||||
}
|
||||
g_assert (nearest);
|
||||
filter_lengths [nearest_num] = (ip - header->code) - nearest->token_or_filter;
|
||||
filter_lengths [nearest_num] = (ip - header->code) - nearest->data.filter_offset;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -7849,11 +7847,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->token_or_filter);
|
||||
tblock = g_hash_table_lookup (cfg->bb_hash, ip + ec->data.filter_offset);
|
||||
g_assert (tblock);
|
||||
ei->data.filter = cfg->native_code + tblock->native_offset;
|
||||
} else {
|
||||
ei->data.token = ec->token_or_filter;
|
||||
ei->data.catch_class = ec->data.catch_class;
|
||||
}
|
||||
|
||||
tblock = g_hash_table_lookup (cfg->bb_hash, ip + ec->try_offset);
|
||||
|
||||
+13
-5
@@ -169,6 +169,8 @@ 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);
|
||||
@@ -179,7 +181,9 @@ 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);
|
||||
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);
|
||||
|
||||
opcode = *((unsigned short *) (code - 6));
|
||||
switch (opcode) {
|
||||
@@ -195,15 +199,19 @@ 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);
|
||||
code = base + displace;
|
||||
s390_patch(code, addr);
|
||||
if (mono_method_same_domain (codeJi, addrJi)) {
|
||||
code = base + displace;
|
||||
s390_patch(code, addr);
|
||||
}
|
||||
break;
|
||||
case 0xc0e5 :
|
||||
/* This is the 'brasl' instruction */
|
||||
code -= 4;
|
||||
displace = ((gint32) addr - (gint32) (code - 2)) / 2;
|
||||
s390_patch (code, displace);
|
||||
mono_arch_flush_icache (code, 4);
|
||||
if (mono_method_same_domain (codeJi, addrJi)) {
|
||||
s390_patch (code, displace);
|
||||
mono_arch_flush_icache (code, 4);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
g_error("Unable to patch instruction prior to %p",code);
|
||||
|
||||
Reference in new issue
Block a user