* *.cs: Sync with the latest gmcs.
svn path=/trunk/mcs/; revision=156166
expr = new Compiler.Binary (oper, left, right, Compiler.Location.Null);
}
- expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+ expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
if ((flags & CSharpBinderFlags.CheckedContext) != 0)
expr = new Compiler.CheckedExpr (expr, Compiler.Location.Null);
Expression res;
try {
- var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, callingType), ResolveOptions);
+ var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, TypeImporter.Import (callingType)), ResolveOptions);
// Static typemanager and internal caches are not thread-safe
lock (resolver) {
return new Compiler.NullLiteral (Compiler.Location.Null);
InitializeCompiler (null);
- return Compiler.Constant.CreateConstantFromValue (value.LimitType, null, Compiler.Location.Null);
+ return Compiler.Constant.CreateConstantFromValue (TypeImporter.Import (value.LimitType), null, Compiler.Location.Null);
}
bool is_compile_time;
if (info != null) {
if ((info.Flags & CSharpArgumentInfoFlags.Constant) != 0) {
InitializeCompiler (null);
- return Compiler.Constant.CreateConstantFromValue (value.LimitType, value.Value, Compiler.Location.Null);
+ return Compiler.Constant.CreateConstantFromValue (TypeImporter.Import (value.LimitType), value.Value, Compiler.Location.Null);
}
if ((info.Flags & CSharpArgumentInfoFlags.IsStaticType) != 0)
- return new Compiler.TypeExpression ((Type) value.Value, Compiler.Location.Null);
+ return new Compiler.TypeExpression (TypeImporter.Import ((Type) value.Value), Compiler.Location.Null);
is_compile_time = (info.Flags & CSharpArgumentInfoFlags.UseCompileTimeType) != 0;
} else {
is_compile_time = false;
}
- return new Compiler.RuntimeValueExpression (value, is_compile_time);
+ return new Compiler.RuntimeValueExpression (value, TypeImporter.Import (is_compile_time ? value.LimitType : value.RuntimeType));
}
public static Compiler.Arguments CreateCompilerArguments (IEnumerable<CSharpArgumentInfo> info, DynamicMetaObject[] args)
public static void InitializeCompiler (Compiler.CompilerContext ctx)
{
- if (Compiler.TypeManager.object_type != null)
+ if (TypeImporter.Predefined == null)
return;
lock (compiler_initializer) {
- if (Compiler.TypeManager.object_type != null)
+ if (TypeImporter.Predefined == null)
return;
// I don't think dynamically loaded assemblies can be used as dynamic
- // expression without static type be loaded first
+ // expression without static type to be loaded first
// AppDomain.CurrentDomain.AssemblyLoad += (sender, e) => { throw new NotImplementedException (); };
// Import all currently loaded assemblies
- foreach (System.Reflection.Assembly a in AppDomain.CurrentDomain.GetAssemblies ())
- Compiler.GlobalRootNamespace.Instance.AddAssemblyReference (a);
+ var ns = Compiler.GlobalRootNamespace.Instance;
+ foreach (System.Reflection.Assembly a in AppDomain.CurrentDomain.GetAssemblies ()) {
+ ns.AddAssemblyReference (a);
+ ns.ImportAssembly (a);
+ }
if (ctx == null)
ctx = CreateDefaultCompilerContext ();
- Compiler.TypeManager.InitCoreTypes (ctx);
+ Compiler.TypeManager.InitCoreTypes (ctx, TypeImporter.Predefined);
+ TypeImporter.Predefined = null;
+
Compiler.TypeManager.InitOptionalCoreTypes (ctx);
}
}
}
+
+ static class TypeImporter
+ {
+ static object lock_object;
+ public static IList<Compiler.PredefinedTypeSpec> Predefined;
+
+ static TypeImporter ()
+ {
+ lock_object = new object ();
+ Predefined = Compiler.TypeManager.InitCoreTypes ();
+ Compiler.Import.Initialize ();
+ }
+
+ public static Compiler.TypeSpec Import (Type type)
+ {
+ lock (lock_object) {
+ return Compiler.Import.ImportType (type);
+ }
+ }
+ }
}
var expr = CSharpBinder.CreateCompilerExpression (null, target);
if (Explicit)
- expr = new Compiler.Cast (new Compiler.TypeExpression (Type, Compiler.Location.Null), expr);
+ expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (Type), Compiler.Location.Null), expr);
else
- expr = new Compiler.ImplicitCast (expr, Type, (flags & CSharpBinderFlags.ConvertArrayIndex) != 0);
+ expr = new Compiler.ImplicitCast (expr, TypeImporter.Import (Type), (flags & CSharpBinderFlags.ConvertArrayIndex) != 0);
if ((flags & CSharpBinderFlags.CheckedContext) != 0)
expr = new Compiler.CheckedExpr (expr, Compiler.Location.Null);
var expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
var args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), indexes);
expr = new Compiler.ElementAccess (expr, args);
- expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+ expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
var binder = new CSharpBinder (this, expr, errorSuggestion);
binder.AddRestrictions (target);
{
var expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
expr = new Compiler.MemberAccess (expr, Name);
- expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+ expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
var binder = new CSharpBinder (this, expr, errorSuggestion);
binder.AddRestrictions (target);
expr = new Compiler.Invocation (expr, c_args);
if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
- expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+ expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
else
- expr = new Compiler.DynamicResultCast (ReturnType, expr);
+ expr = new Compiler.DynamicResultCast (TypeImporter.Import (ReturnType), expr);
var binder = new CSharpBinder (this, expr, errorSuggestion);
binder.AddRestrictions (target);
public override DynamicMetaObject Bind (DynamicMetaObject target, DynamicMetaObject[] args)
{
var type = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
- target_return_type = type.Type;
+ target_return_type = type.Type.GetMetaInfo ();
var c_args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), args);
var c_args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), args);
var t_args = typeArguments == null ?
null :
- new Compiler.TypeArguments (typeArguments.Select (l => new Compiler.TypeExpression (l, Compiler.Location.Null)).ToArray ());
+ new Compiler.TypeArguments (typeArguments.Select (l => new Compiler.TypeExpression (TypeImporter.Import (l), Compiler.Location.Null)).ToArray ());
Compiler.Expression expr;
if ((flags & CSharpBinderFlags.InvokeSimpleName) != 0) {
expr = new Compiler.Invocation (expr, c_args);
if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
- expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+ expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
else
- expr = new Compiler.DynamicResultCast (ReturnType, expr);
+ expr = new Compiler.DynamicResultCast (TypeImporter.Import (ReturnType), expr);
var binder = new CSharpBinder (this, expr, errorSuggestion);
binder.AddRestrictions (target);
{
var ctx = CSharpBinder.CreateDefaultCompilerContext ();
CSharpBinder.InitializeCompiler (ctx);
+ var context = TypeImporter.Import (callingContext);
- var expr = Compiler.Expression.MemberLookup (ctx, callingContext, callingContext, name, Compiler.Location.Null);
+ var expr = Compiler.Expression.MemberLookup (ctx, context, context, name, 0, Compiler.BindingRestriction.None, Compiler.Location.Null);
var binder = new CSharpBinder (
this, new Compiler.BoolConstant (expr is Compiler.EventExpr, Compiler.Location.Null), null);
var source = CSharpBinder.CreateCompilerExpression (argumentInfo [indexes.Length + 1], value);
expr = new Compiler.SimpleAssign (expr, source);
- expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+ expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
var binder = new CSharpBinder (this, expr, errorSuggestion);
binder.AddRestrictions (target);
// Field assignment
expr = new Compiler.MemberAccess (expr, Name);
expr = new Compiler.SimpleAssign (expr, source);
- expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+ expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
var binder = new CSharpBinder (this, expr, errorSuggestion);
binder.AddRestrictions (target);
else
expr = new Compiler.Unary (GetOperator (), expr, Compiler.Location.Null);
- expr = new Compiler.Cast (new Compiler.TypeExpression (ReturnType, Compiler.Location.Null), expr);
+ expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr);
if ((flags & CSharpBinderFlags.CheckedContext) != 0)
expr = new Compiler.CheckedExpr (expr, Compiler.Location.Null);
+2010-05-27 Marek Safar <marek.safar@gmail.com>
+
+ * *.cs: Sync with the latest gmcs.
+
2010-02-10 Marek Safar <marek.safar@gmail.com>
* *.cs: Track RC API changes.
class RuntimeBinderContext : Compiler.IMemberContext
{
readonly Compiler.CompilerContext ctx;
- readonly Type currentType;
+ readonly Compiler.TypeSpec currentType;
- public RuntimeBinderContext (Compiler.CompilerContext ctx, Type currentType)
+ public RuntimeBinderContext (Compiler.CompilerContext ctx, Compiler.TypeSpec currentType)
{
this.ctx = ctx;
this.currentType = currentType;
#region IMemberContext Members
- public Type CurrentType {
+ public Compiler.TypeSpec CurrentType {
get { return currentType; }
}
get { throw new NotImplementedException (); }
}
- public Compiler.TypeContainer CurrentTypeDefinition {
+ public Compiler.MemberCore CurrentMemberDefinition {
get {
// For operators and methods
return new Compiler.ModuleContainer (currentType.Assembly);
}
}
+ public bool HasUnresolvedConstraints {
+ get {
+ return false;
+ }
+ }
+
public bool IsObsolete {
get {
// Always true to ignore obsolete attribute checks
throw new NotImplementedException ();
}
- public Compiler.ExtensionMethodGroupExpr LookupExtensionMethod (Type extensionType, string name, Mono.CSharp.Location loc)
+ public Compiler.ExtensionMethodGroupExpr LookupExtensionMethod (Compiler.TypeSpec extensionType, string name, int arity, Mono.CSharp.Location loc)
{
// No extension method lookup in this context
return null;
}
- public Compiler.FullNamedExpression LookupNamespaceOrType (string name, Mono.CSharp.Location loc, bool ignore_cs0104)
+ public Compiler.FullNamedExpression LookupNamespaceOrType (string name, int arity, Mono.CSharp.Location loc, bool ignore_cs0104)
{
throw new NotImplementedException ();
}