本文整理汇总了C#中Mono.CSharp.ResolveContext类的典型用法代码示例。如果您正苦于以下问题:C# ResolveContext类的具体用法?C# ResolveContext怎么用?C# ResolveContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResolveContext类属于Mono.CSharp命名空间,在下文中一共展示了ResolveContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateExpressionTree
public virtual Expression CreateExpressionTree (ResolveContext ec)
{
if (ArgType == AType.Default)
ec.Report.Error (854, Expr.Location, "An expression tree cannot contain an invocation which uses optional parameter");
return Expr.CreateExpressionTree (ec);
}
开发者ID:pgoron,项目名称:monodevelop,代码行数:7,代码来源:argument.cs
示例2: Bind
public DynamicMetaObject Bind (DynamicContext ctx, Type callingType)
{
Expression res;
try {
var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, callingType), ResolveOptions);
// Static typemanager and internal caches are not thread-safe
lock (resolver) {
expr = expr.Resolve (rc, Compiler.ResolveFlags.VariableOrValue);
}
if (expr == null)
throw new RuntimeBinderInternalCompilerException ("Expression resolved to null");
res = expr.MakeExpression (new Compiler.BuilderContext ());
} catch (RuntimeBinderException e) {
if (errorSuggestion != null)
return errorSuggestion;
res = CreateBinderException (e.Message);
} catch (Exception) {
if (errorSuggestion != null)
return errorSuggestion;
throw;
}
return new DynamicMetaObject (res, restrictions);
}
开发者ID:bbqchickenrobot,项目名称:playscript-mono,代码行数:29,代码来源:CSharpBinder.cs
示例3: DoResolve
public override Expression DoResolve (ResolveContext ec)
{
//
// We are born fully resolved
//
return this;
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:expression.cs
示例4: CreateDelegateType
public static TypeSpec CreateDelegateType (ResolveContext rc, AParametersCollection parameters, TypeSpec returnType, Location loc)
{
Namespace type_ns = rc.Module.GlobalRootNamespace.GetNamespace ("System", true);
if (type_ns == null) {
return null;
}
if (returnType == rc.BuiltinTypes.Void) {
var actArgs = parameters.Types;
var actionSpec = type_ns.LookupType (rc.Module, "Action", actArgs.Length, LookupMode.Normal, loc).ResolveAsType(rc);
if (actionSpec == null) {
return null;
}
if (actArgs.Length == 0)
return actionSpec;
else
return actionSpec.MakeGenericType(rc, actArgs);
} else {
TypeSpec[] funcArgs = new TypeSpec[parameters.Types.Length + 1];
parameters.Types.CopyTo(funcArgs, 0);
funcArgs[parameters.Types.Length] = returnType;
var funcSpec = type_ns.LookupType (rc.Module, "Func", funcArgs.Length, LookupMode.Normal, loc).ResolveAsType(rc);
if (funcSpec == null)
return null;
return funcSpec.MakeGenericType(rc, funcArgs);
}
}
开发者ID:OpenFlex,项目名称:playscript-mono,代码行数:26,代码来源:delegate.cs
示例5: ExplicitConversion
/// <summary>
/// Performs an explicit conversion of the expression `expr' whose
/// type is expr.Type to `target_type'.
/// </summary>
public static Expression ExplicitConversion(ResolveContext ec, Expression expr,
TypeSpec target_type, Location loc)
{
Expression e = ExplicitConversionCore (ec, expr, target_type, loc);
if (e != null) {
//
// Don't eliminate explicit precission casts
//
if (e == expr) {
if (target_type.BuiltinType == BuiltinTypeSpec.Type.Float)
return new OpcodeCast (expr, target_type, OpCodes.Conv_R4);
if (target_type.BuiltinType == BuiltinTypeSpec.Type.Double)
return new OpcodeCast (expr, target_type, OpCodes.Conv_R8);
}
return e;
}
TypeSpec expr_type = expr.Type;
if (target_type.IsNullableType) {
TypeSpec target;
if (expr_type.IsNullableType) {
target = Nullable.NullableInfo.GetUnderlyingType (target_type);
Expression unwrap = Nullable.Unwrap.Create (expr);
e = ExplicitConversion (ec, unwrap, target, expr.Location);
if (e == null)
return null;
return new Nullable.LiftedConversion (e, unwrap, target_type).Resolve (ec);
}
if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Object) {
return new UnboxCast (expr, target_type);
}
target = TypeManager.GetTypeArguments (target_type) [0];
e = ExplicitConversionCore (ec, expr, target, loc);
if (e != null)
return TypeSpec.IsReferenceType (expr.Type) ? new UnboxCast (expr, target_type) : Nullable.Wrap.Create (e, target_type);
} else if (expr_type.IsNullableType) {
e = ImplicitBoxingConversion (expr, Nullable.NullableInfo.GetUnderlyingType (expr_type), target_type);
if (e != null)
return e;
e = Nullable.Unwrap.Create (expr, false);
e = ExplicitConversionCore (ec, e, target_type, loc);
if (e != null)
return EmptyCast.Create (e, target_type);
}
e = ExplicitUserConversion (ec, expr, target_type, loc);
if (e != null)
return e;
expr.Error_ValueCannotBeConverted (ec, target_type, true);
return null;
}
开发者ID:exodrifter,项目名称:mcs-ICodeCompiler,代码行数:63,代码来源:convert.cs
示例6: ImplicitConversionRequired
public Constant ImplicitConversionRequired (ResolveContext ec, TypeSpec type, Location loc)
{
Constant c = ConvertImplicitly (type);
if (c == null)
Error_ValueCannotBeConverted (ec, type, false);
return c;
}
开发者ID:rabink,项目名称:mono,代码行数:8,代码来源:constant.cs
示例7: CreateExpressionTree
public override Expression CreateExpressionTree (ResolveContext ec)
{
// HACK: avoid referencing mcs internal type
if (type == typeof (NullLiteral))
type = TypeManager.object_type;
return base.CreateExpressionTree (ec);
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:8,代码来源:literal.cs
示例8: ExplicitConversion
/// <summary>
/// Performs an explicit conversion of the expression `expr' whose
/// type is expr.Type to `target_type'.
/// </summary>
public static Expression ExplicitConversion(ResolveContext ec, Expression expr,
TypeSpec target_type, Location loc)
{
Expression e = ExplicitConversionCore (ec, expr, target_type, loc);
if (e != null) {
//
// Don't eliminate explicit precission casts
//
if (e == expr) {
if (target_type == TypeManager.float_type)
return new OpcodeCast (expr, target_type, OpCodes.Conv_R4);
if (target_type == TypeManager.double_type)
return new OpcodeCast (expr, target_type, OpCodes.Conv_R8);
}
return e;
}
TypeSpec expr_type = expr.Type;
if (TypeManager.IsNullableType (target_type)) {
if (TypeManager.IsNullableType (expr_type)) {
TypeSpec target = Nullable.NullableInfo.GetUnderlyingType (target_type);
Expression unwrap = Nullable.Unwrap.Create (expr);
e = ExplicitConversion (ec, unwrap, target, expr.Location);
if (e == null)
return null;
return new Nullable.Lifted (e, unwrap, target_type).Resolve (ec);
} else if (expr_type == TypeManager.object_type) {
return new UnboxCast (expr, target_type);
} else {
TypeSpec target = TypeManager.GetTypeArguments (target_type) [0];
e = ExplicitConversionCore (ec, expr, target, loc);
if (e != null)
return Nullable.Wrap.Create (e, target_type);
}
} else if (TypeManager.IsNullableType (expr_type)) {
bool use_class_cast;
if (ImplicitBoxingConversionExists (Nullable.NullableInfo.GetUnderlyingType (expr_type), target_type, out use_class_cast))
return new BoxedCast (expr, target_type);
e = Nullable.Unwrap.Create (expr, false);
e = ExplicitConversionCore (ec, e, target_type, loc);
if (e != null)
return EmptyCast.Create (e, target_type);
}
e = ExplicitUserConversion (ec, expr, target_type, loc);
if (e != null)
return e;
expr.Error_ValueCannotBeConverted (ec, loc, target_type, true);
return null;
}
开发者ID:speier,项目名称:shake,代码行数:60,代码来源:convert.cs
示例9: DoResolve
protected override Expression DoResolve(ResolveContext ec){
var e = base.DoResolve(ec);
if (e == null || e != this)
return e;
var fld = target as FieldExpr;
if (fld == null){
var access = target as MemberAccess;
if (access != null)
fld = access.LeftExpression as FieldExpr;
if (fld == null){
Expression simple = target as SimpleName;
simple = simple != null ? simple.Resolve(ec) : null;
fld = simple as FieldExpr;
}
if (fld == null)
return e;
}
if (!fld.IsRole)
return e;
//assigning to a role. Check that the contract is fullfilled
var contractName = CSharpParser.GetCurrentRoleContractName(fld.DeclaringType.Name, fld.Name);
if (CSharpParser.RoleContracts.ContainsKey(contractName)){
if (source.Type == null)
source = source.Resolve(ec);
var contract = CSharpParser.RoleContracts[contractName];
if (!source.Type.FullfillsContract(contract)){
var index = -1;
var current_class = contract.Parent;
if (current_class.IsGeneric)
{
var typeParameters = current_class.TypeParameters;
for (int i = 0; index < 0 && i < typeParameters.Length; i++)
{
var param = typeParameters[i];
if (target.Type.Name == param.Name)
{
index = i;
}
}
}
if (index < 0)
{
ec.Report.Error(10009, loc, "Assignment to role '{0}' does not full fill contract", fld.Name);
}
else
{
current_class.Spec.AddTypesAndContracts(index, contract);
}
}
}
return this;
}
开发者ID:runefs,项目名称:Marvin,代码行数:56,代码来源:RoleAssign.cs
示例10: DoResolve
protected override Expression DoResolve (ResolveContext ec)
{
var results = new List<string> ();
AppendResults (results, Prefix, ec.Module.Evaluator.GetVarNames ());
AppendResults (results, Prefix, ec.CurrentMemberDefinition.Parent.NamespaceEntry.CompletionGetTypesStartingWith (Prefix));
AppendResults (results, Prefix, ec.Module.Evaluator.GetUsingList ());
throw new CompletionResult (Prefix, results.ToArray ());
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:10,代码来源:complete.cs
示例11: DoResolve
public override Expression DoResolve (ResolveContext ec)
{
ArrayList results = new ArrayList ();
AppendResults (results, Prefix, Evaluator.GetVarNames ());
AppendResults (results, Prefix, ec.CurrentTypeDefinition.NamespaceEntry.CompletionGetTypesStartingWith (Prefix));
AppendResults (results, Prefix, Evaluator.GetUsingList ());
throw new CompletionResult (Prefix, (string []) results.ToArray (typeof (string)));
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:10,代码来源:complete.cs
示例12: CheckContext
public static bool CheckContext (ResolveContext ec, Location loc)
{
if (!ec.CurrentAnonymousMethod.IsIterator) {
ec.Report.Error (1621, loc,
"The yield statement cannot be used inside " +
"anonymous method blocks");
return false;
}
return true;
}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:11,代码来源:iterators.cs
示例13: CreateExpressionTree
public override Expression CreateExpressionTree (ResolveContext ec)
{
if (expr_tree != null)
return expr_tree (ec, mg);
Arguments args = Arguments.CreateForExpressionTree (ec, arguments,
new NullLiteral (loc),
mg.CreateExpressionTree (ec));
return CreateExpressionFactoryCall (ec, "Call", args);
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:11,代码来源:expression.cs
示例14: Error_ValueCannotBeConverted
public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec target, bool expl)
{
if (!expl && IsLiteral &&
BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (target) &&
BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (type)) {
ec.Report.Error (31, loc, "Constant value `{0}' cannot be converted to a `{1}'",
GetValueAsLiteral (), TypeManager.CSharpName (target));
} else {
base.Error_ValueCannotBeConverted (ec, target, expl);
}
}
开发者ID:rabink,项目名称:mono,代码行数:11,代码来源:constant.cs
示例15: Error_ValueCannotBeConverted
public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec target, bool expl)
{
if (!expl && IsLiteral && type.BuiltinType != BuiltinTypeSpec.Type.Double &&
BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (target) &&
BuiltinTypeSpec.IsPrimitiveTypeOrDecimal (type)) {
ec.Report.Error (31, loc, "Constant value `{0}' cannot be converted to a `{1}'",
GetValueAsLiteral (), target.GetSignatureForError ());
} else {
base.Error_ValueCannotBeConverted (ec, target, expl);
}
}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:11,代码来源:constant.cs
示例16: Error_ValueCannotBeConverted
public override void Error_ValueCannotBeConverted (ResolveContext ec, Location loc, TypeSpec target, bool expl)
{
if (!expl && IsLiteral &&
(TypeManager.IsPrimitiveType (target) || type == TypeManager.decimal_type) &&
(TypeManager.IsPrimitiveType (type) || type == TypeManager.decimal_type)) {
ec.Report.Error (31, loc, "Constant value `{0}' cannot be converted to a `{1}'",
AsString (), TypeManager.CSharpName (target));
} else {
base.Error_ValueCannotBeConverted (ec, loc, target, expl);
}
}
开发者ID:jdecuyper,项目名称:mono,代码行数:11,代码来源:constant.cs
示例17: Bind
public override DynamicMetaObject Bind (DynamicMetaObject target, DynamicMetaObject[] args)
{
var ctx = CSharpBinder.CreateDefaultCompilerContext ();
CSharpBinder.InitializeCompiler (ctx);
var context_type = TypeImporter.Import (callingContext);
var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, context_type), 0);
var expr = Compiler.Expression.MemberLookup (rc, context_type, context_type, name, 0, false, Compiler.Location.Null);
var binder = new CSharpBinder (
this, new Compiler.BoolConstant (expr is Compiler.EventExpr, Compiler.Location.Null), null);
binder.AddRestrictions (target);
return binder.Bind (callingContext, target);
}
开发者ID:afaerber,项目名称:mono,代码行数:15,代码来源:CSharpIsEventBinder.cs
示例18: CheckContext
public static bool CheckContext (ResolveContext ec, Location loc)
{
//
// We can't use `ec.InUnsafe' here because it's allowed to have an iterator
// inside an unsafe class. See test-martin-29.cs for an example.
//
if (!ec.CurrentAnonymousMethod.IsIterator) {
ec.Report.Error (1621, loc,
"The yield statement cannot be used inside " +
"anonymous method blocks");
return false;
}
return true;
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:15,代码来源:iterators.cs
示例19: Bind
public override DynamicMetaObject Bind (DynamicMetaObject target, DynamicMetaObject[] args)
{
var ctx = DynamicContext.Create ();
var context_type = ctx.ImportType (callingContext);
var queried_type = ctx.ImportType (target.LimitType);
var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, context_type), 0);
var expr = Compiler.Expression.MemberLookup (rc, context_type, queried_type, name, 0, false, Compiler.Location.Null);
var binder = new CSharpBinder (
this, new Compiler.BoolConstant (expr is Compiler.EventExpr, Compiler.Location.Null), null);
binder.AddRestrictions (target);
return binder.Bind (ctx, callingContext);
}
开发者ID:stabbylambda,项目名称:mono,代码行数:15,代码来源:CSharpIsEventBinder.cs
示例20: ResolveParameters
protected override ParametersCompiled ResolveParameters (ResolveContext ec, TypeInferenceContext tic, Type delegateType)
{
if (!TypeManager.IsDelegateType (delegateType))
return null;
AParametersCollection d_params = TypeManager.GetDelegateParameters (ec, delegateType);
if (HasExplicitParameters) {
if (!VerifyExplicitParameters (ec, delegateType, d_params))
return null;
return Parameters;
}
//
// If L has an implicitly typed parameter list we make implicit parameters explicit
// Set each parameter of L is given the type of the corresponding parameter in D
//
if (!VerifyParameterCompatibility (ec, delegateType, d_params, ec.IsInProbingMode))
return null;
Type [] ptypes = new Type [Parameters.Count];
for (int i = 0; i < d_params.Count; i++) {
// D has no ref or out parameters
if ((d_params.FixedParameters [i].ModFlags & Parameter.Modifier.ISBYREF) != 0)
return null;
Type d_param = d_params.Types [i];
#if MS_COMPATIBLE
// Blablabla, because reflection does not work with dynamic types
if (d_param.IsGenericParameter)
d_param = delegateType.GetGenericArguments () [d_param.GenericParameterPosition];
#endif
//
// When type inference context exists try to apply inferred type arguments
//
if (tic != null) {
d_param = tic.InflateGenericArgument (d_param);
}
ptypes [i] = d_param;
((ImplicitLambdaParameter) Parameters.FixedParameters [i]).Type = d_param;
}
Parameters.Types = ptypes;
return Parameters;
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:48,代码来源:lambda.cs
注:本文中的Mono.CSharp.ResolveContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论