本文整理汇总了C#中ICSharpCode.NRefactory.MonoCSharp.ResolveContext类的典型用法代码示例。如果您正苦于以下问题:C# ResolveContext类的具体用法?C# ResolveContext怎么用?C# ResolveContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResolveContext类属于ICSharpCode.NRefactory.MonoCSharp命名空间,在下文中一共展示了ResolveContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImplicitConversionRequired
public Constant ImplicitConversionRequired (ResolveContext ec, TypeSpec type)
{
Constant c = ConvertImplicitly (type);
if (c == null)
Error_ValueCannotBeConverted (ec, type, false);
return c;
}
示例2: DoResolve
protected override Expression DoResolve (ResolveContext ec)
{
var results = new List<string> ();
ec.CurrentMemberDefinition.GetCompletionStartingWith (Prefix, results);
throw new CompletionResult (Prefix, results.Distinct ().Select (l => l.Substring (Prefix.Length)).ToArray ());
}
示例3: 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);
}
}
示例4: ConvertPromotion
static bool ConvertPromotion (ResolveContext rc, ref Constant prim, ref Constant second, TypeSpec type)
{
Constant c = prim.ConvertImplicitly (type);
if (c != null) {
prim = c;
return true;
}
if (type.BuiltinType == BuiltinTypeSpec.Type.UInt) {
type = rc.BuiltinTypes.Long;
prim = prim.ConvertImplicitly (type);
second = second.ConvertImplicitly (type);
return prim != null && second != null;
}
return false;
}
示例5: DoBinaryNumericPromotions
//
// Performs the numeric promotions on the left and right expresions
// and deposits the results on `lc' and `rc'.
//
// On success, the types of `lc' and `rc' on output will always match,
// and the pair will be one of:
//
// TODO: BinaryFold should be called as an optimization step only,
// error checking here is weak
//
static bool DoBinaryNumericPromotions (ResolveContext rc, ref Constant left, ref Constant right)
{
TypeSpec ltype = left.Type;
TypeSpec rtype = right.Type;
foreach (TypeSpec t in rc.BuiltinTypes.BinaryPromotionsTypes) {
if (t == ltype)
return t == rtype || ConvertPromotion (rc, ref right, ref left, t);
if (t == rtype)
return t == ltype || ConvertPromotion (rc, ref left, ref right, t);
}
left = left.ConvertImplicitly (rc.BuiltinTypes.Int);
right = right.ConvertImplicitly (rc.BuiltinTypes.Int);
return left != null && right != null;
}
示例6: Error_ValueCannotBeConverted
public override void Error_ValueCannotBeConverted (ResolveContext ec, TypeSpec t, bool expl)
{
if (t.IsGenericParameter) {
ec.Report.Error(403, loc,
"Cannot convert null to the type parameter `{0}' because it could be a value " +
"type. Consider using `default ({0})' instead", t.Name);
return;
}
if (TypeSpec.IsValueType (t)) {
ec.Report.Error(37, loc, "Cannot convert null to `{0}' because it is a value type",
t.GetSignatureForError ());
return;
}
base.Error_ValueCannotBeConverted (ec, t, expl);
}
示例7: ResolveParameters
protected override ParametersCompiled ResolveParameters (ResolveContext ec, TypeInferenceContext tic, TypeSpec delegateType)
{
if (!delegateType.IsDelegate)
return null;
AParametersCollection d_params = Delegate.GetParameters (delegateType);
if (HasExplicitParameters) {
if (!VerifyExplicitParameters (ec, tic, 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, tic, delegateType, d_params, ec.IsInProbingMode))
return null;
TypeSpec [] ptypes = new TypeSpec [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.RefOutMask) != 0)
return null;
TypeSpec d_param = d_params.Types [i];
//
// When type inference context exists try to apply inferred type arguments
//
if (tic != null) {
d_param = tic.InflateGenericArgument (ec, d_param);
}
ptypes [i] = d_param;
ImplicitLambdaParameter ilp = (ImplicitLambdaParameter) Parameters.FixedParameters [i];
ilp.SetParameterType (d_param);
ilp.Resolve (null, i);
}
Parameters.Types = ptypes;
return Parameters;
}
示例8: ConvertInitializer
public override Constant ConvertInitializer (ResolveContext rc, Constant expr)
{
if (expr is EnumConstant)
expr = ((EnumConstant) expr).Child;
var en = (Enum)Parent;
var underlying = en.UnderlyingType;
if (expr != null) {
expr = expr.ImplicitConversionRequired (rc, underlying);
if (expr != null && !IsValidEnumType (expr.Type)) {
en.Error_UnderlyingType (Location);
expr = null;
}
}
if (expr == null)
expr = New.Constantify (underlying, Location);
return new EnumConstant (expr, MemberType);
}
示例9: CreateExpressionTree
protected override Expression CreateExpressionTree (ResolveContext ec, TypeSpec delegate_type)
{
if (ec.IsInProbingMode)
return this;
BlockContext bc = new BlockContext (ec.MemberContext, ec.ConstructorBlock, ec.BuiltinTypes.Void) {
CurrentAnonymousMethod = ec.CurrentAnonymousMethod
};
Expression args = Parameters.CreateExpressionTree (bc, loc);
Expression expr = Block.CreateExpressionTree (ec);
if (expr == null)
return null;
Arguments arguments = new Arguments (2);
arguments.Add (new Argument (expr));
arguments.Add (new Argument (args));
return CreateExpressionFactoryCall (ec, "Lambda",
new TypeArguments (new TypeExpression (delegate_type, loc)),
arguments);
}
示例10: DoResolveLValue
public override Expression DoResolveLValue (ResolveContext rc, Expression right_side)
{
if (right_side == EmptyExpression.OutAccess) {
right_side.DoResolveLValue (rc, this);
return null;
}
if (DoResolveCore (rc)) {
setter_args = CreateSetterArguments (rc, right_side);
setter = CreateCallSiteBinder (rc, setter_args, true);
}
eclass = ExprClass.Variable;
return this;
}
示例11: CreateIsFalse
public static DynamicUnaryConversion CreateIsFalse (ResolveContext rc, Arguments args, Location loc)
{
return new DynamicUnaryConversion ("IsFalse", args, loc) { type = rc.BuiltinTypes.Bool };
}
示例12: CreateCallSiteBinder
protected abstract Expression CreateCallSiteBinder (ResolveContext ec, Arguments args, bool isSet);
示例13: CreateSetterArguments
protected virtual Arguments CreateSetterArguments (ResolveContext rc, Expression rhs)
{
var setter_args = new Arguments (Arguments.Count + 1);
setter_args.AddRange (Arguments);
setter_args.Add (new Argument (rhs));
return setter_args;
}
示例14: DoResolve
protected override Expression DoResolve (ResolveContext rc)
{
if (DoResolveCore (rc))
binder_expr = binder.CreateCallSiteBinder (rc, arguments);
return this;
}
示例15: CreateExpressionTree
public override Expression CreateExpressionTree (ResolveContext ec)
{
return condition.CreateExpressionTree (ec);
}