本文整理汇总了C#中ICSharpCode.NRefactory.MonoCSharp.ResolveContext类的典型用法代码示例。如果您正苦于以下问题:C# ResolveContext类的具体用法?C# ResolveContext怎么用?C# ResolveContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResolveContext类属于ICSharpCode.NRefactory.MonoCSharp命名空间,在下文中一共展示了ResolveContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ImplicitConversionRequired
public Constant ImplicitConversionRequired (ResolveContext ec, TypeSpec type)
{
Constant c = ConvertImplicitly (type);
if (c == null)
Error_ValueCannotBeConverted (ec, type, false);
return c;
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:8,代码来源:constant.cs
示例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 ());
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:8,代码来源:complete.cs
示例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);
}
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:11,代码来源:constant.cs
示例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;
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:17,代码来源:cfold.cs
示例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;
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:27,代码来源:cfold.cs
示例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);
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:17,代码来源:literal.cs
示例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;
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:45,代码来源:lambda.cs
示例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);
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:20,代码来源:enum.cs
示例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);
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:21,代码来源:lambda.cs
示例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;
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:15,代码来源:dynamic.cs
示例11: CreateIsFalse
public static DynamicUnaryConversion CreateIsFalse (ResolveContext rc, Arguments args, Location loc)
{
return new DynamicUnaryConversion ("IsFalse", args, loc) { type = rc.BuiltinTypes.Bool };
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:4,代码来源:dynamic.cs
示例12: CreateCallSiteBinder
protected abstract Expression CreateCallSiteBinder (ResolveContext ec, Arguments args, bool isSet);
开发者ID:furesoft,项目名称:NRefactory,代码行数:1,代码来源:dynamic.cs
示例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;
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:7,代码来源:dynamic.cs
示例14: DoResolve
protected override Expression DoResolve (ResolveContext rc)
{
if (DoResolveCore (rc))
binder_expr = binder.CreateCallSiteBinder (rc, arguments);
return this;
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:7,代码来源:dynamic.cs
示例15: CreateExpressionTree
public override Expression CreateExpressionTree (ResolveContext ec)
{
return condition.CreateExpressionTree (ec);
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:4,代码来源:dynamic.cs
示例16: Error_CompileTimeOverflow
internal static void Error_CompileTimeOverflow (ResolveContext rc, Location loc)
{
rc.Report.Error (220, loc, "The operation overflows at compile time in checked mode");
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:4,代码来源:cfold.cs
示例17: DoResolveCore
protected bool DoResolveCore (ResolveContext rc)
{
foreach (var arg in arguments) {
if (arg.Type == InternalType.VarOutType) {
// Should be special error message about dynamic dispatch
rc.Report.Error (8047, arg.Expr.Location, "Declaration expression cannot be used in this context");
}
}
if (rc.CurrentTypeParameters != null && rc.CurrentTypeParameters[0].IsMethodTypeParameter)
context_mvars = rc.CurrentTypeParameters;
int errors = rc.Report.Errors;
var pt = rc.Module.PredefinedTypes;
binder_type = pt.Binder.Resolve ();
pt.CallSite.Resolve ();
pt.CallSiteGeneric.Resolve ();
eclass = ExprClass.Value;
if (type == null)
type = rc.BuiltinTypes.Dynamic;
if (rc.Report.Errors == errors)
return true;
rc.Report.Error (1969, loc,
"Dynamic operation cannot be compiled without `Microsoft.CSharp.dll' assembly reference");
return false;
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:31,代码来源:dynamic.cs
示例18: Emit
public override void Emit (EmitContext ec)
{
var rc = new ResolveContext (ec.MemberContext);
var expr = new Conditional (new BooleanExpression (condition), invoke, assign, loc).Resolve (rc);
expr.Emit (ec);
}
开发者ID:furesoft,项目名称:NRefactory,代码行数:6,代码来源:dynamic.cs
示例19: CreateHoistedBaseCallProxy
//
// Creates a proxy base method call inside this container for hoisted base member calls
//
public MethodSpec CreateHoistedBaseCallProxy (ResolveContext rc, MethodSpec method)
{
Method proxy_method;
//
// One proxy per base method is enough
//
if (hoisted_base_call_proxies == null) {
hoisted_base_call_proxies = new Dictionary<MethodSpec, Method> ();
proxy_method = null;
} else {
hoisted_base_call_proxies.TryGetValue (method, out proxy_method);
}
if (proxy_method == null) {
string name = CompilerGeneratedContainer.MakeName (method.Name, null, "BaseCallProxy", hoisted_base_call_proxies.Count);
MemberName member_name;
TypeArguments targs = null;
TypeSpec return_type = method.ReturnType;
var local_param_types = method.Parameters.Types;
if (method.IsGeneric) {
//
// Copy all base generic method type parameters info
//
var hoisted_tparams = method.GenericDefinition.TypeParameters;
var tparams = new TypeParameters ();
targs = new TypeArguments ();
targs.Arguments = new TypeSpec[hoisted_tparams.Length];
for (int i = 0; i < hoisted_tparams.Length; ++i) {
var tp = hoisted_tparams[i];
var local_tp = new TypeParameter (tp, null, new MemberName (tp.Name, Location), null);
tparams.Add (local_tp);
targs.Add (new SimpleName (tp.Name, Location));
targs.Arguments[i] = local_tp.Type;
}
member_name = new MemberName (name, tparams, Location);
//
// Mutate any method type parameters from original
// to newly created hoisted version
//
var mutator = new TypeParameterMutator (hoisted_tparams, tparams);
return_type = mutator.Mutate (return_type);
local_param_types = mutator.Mutate (local_param_types);
} else {
member_name = new MemberName (name);
}
var base_parameters = new Parameter[method.Parameters.Count];
for (int i = 0; i < base_parameters.Length; ++i) {
var base_param = method.Parameters.FixedParameters[i];
base_parameters[i] = new Parameter (new TypeExpression (local_param_types [i], Location),
base_param.Name, base_param.ModFlags, null, Location);
base_parameters[i].Resolve (this, i);
}
var cloned_params = ParametersCompiled.CreateFullyResolved (base_parameters, method.Parameters.Types);
if (method.Parameters.HasArglist) {
cloned_params.FixedParameters[0] = new Parameter (null, "__arglist", Parameter.Modifier.NONE, null, Location);
cloned_params.Types[0] = Module.PredefinedTypes.RuntimeArgumentHandle.Resolve ();
}
// Compiler generated proxy
proxy_method = new Method (this, new TypeExpression (return_type, Location),
Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN,
member_name, cloned_params, null);
var block = new ToplevelBlock (Compiler, proxy_method.ParameterInfo, Location) {
IsCompilerGenerated = true
};
var mg = MethodGroupExpr.CreatePredefined (method, method.DeclaringType, Location);
mg.InstanceExpression = new BaseThis (method.DeclaringType, Location);
if (targs != null)
mg.SetTypeArguments (rc, targs);
// Get all the method parameters and pass them as arguments
var real_base_call = new Invocation (mg, block.GetAllParametersArguments ());
Statement statement;
if (method.ReturnType.Kind == MemberKind.Void)
statement = new StatementExpression (real_base_call);
else
statement = new Return (real_base_call, Location);
block.AddStatement (statement);
proxy_method.Block = block;
members.Add (proxy_method);
proxy_method.Define ();
proxy_method.PrepareEmit ();
hoisted_base_call_proxies.Add (method, proxy_method);
//.........这里部分代码省略.........
开发者ID:0xd4d,项目名称:NRefactory,代码行数:101,代码来源:class.cs
示例20: BinaryFold
/// <summary>
/// Constant expression folder for binary operations.
///
/// Returns null if the expression can not be folded.
/// </summary>
static public Constant BinaryFold (ResolveContext ec, Binary.Operator oper,
Constant left, Constant right, Location loc)
{
Constant result = null;
if (left is EmptyConstantCast)
return BinaryFold (ec, oper, ((EmptyConstantCast)left).child, right, loc);
if (left is SideEffectConstant) {
result = BinaryFold (ec, oper, ((SideEffectConstant) left).value, right, loc);
if (result == null)
return null;
return new SideEffectConstant (result, left, loc);
}
if (right is EmptyConstantCast)
return BinaryFold (ec, oper, left, ((EmptyConstantCast)right).child, loc);
if (right is SideEffectConstant) {
result = BinaryFold (ec, oper, left, ((SideEffectConstant) right).value, loc);
if (result == null)
return null;
return new SideEffectConstant (result, right, loc);
}
TypeSpec lt = left.Type;
TypeSpec rt = right.Type;
bool bool_res;
if (lt.BuiltinType == BuiltinTypeSpec.Type.Bool && lt == rt) {
bool lv = (bool) left.GetValue ();
bool rv = (bool) right.GetValue ();
switch (oper) {
case Binary.Operator.BitwiseAnd:
case Binary.Operator.LogicalAnd:
return new BoolConstant (ec.BuiltinTypes, lv && rv, left.Location);
case Binary.Operator.BitwiseOr:
case Binary.Operator.LogicalOr:
return new BoolConstant (ec.BuiltinTypes, lv || rv, left.Location);
case Binary.Operator.ExclusiveOr:
return new BoolConstant (ec.BuiltinTypes, lv ^ rv, left.Location);
case Binary.Operator.Equality:
return new BoolConstant (ec.BuiltinTypes, lv == rv, left.Location);
case Binary.Operator.Inequality:
return new BoolConstant (ec.BuiltinTypes, lv != rv, left.Location);
}
return null;
}
//
// During an enum evaluation, none of the rules are valid
// Not sure whether it is bug in csc or in documentation
//
if (ec.HasSet (ResolveContext.Options.EnumScope)){
if (left is EnumConstant)
left = ((EnumConstant) left).Child;
if (right is EnumConstant)
right = ((EnumConstant) right).Child;
} else if (left is EnumConstant && rt == lt) {
switch (oper){
///
/// E operator |(E x, E y);
/// E operator &(E x, E y);
/// E operator ^(E x, E y);
///
case Binary.Operator.BitwiseOr:
case Binary.Operator.BitwiseAnd:
case Binary.Operator.ExclusiveOr:
result = BinaryFold (ec, oper, ((EnumConstant)left).Child, ((EnumConstant)right).Child, loc);
if (result != null)
result = result.Reduce (ec, lt);
return result;
///
/// U operator -(E x, E y);
///
case Binary.Operator.Subtraction:
result = BinaryFold (ec, oper, ((EnumConstant)left).Child, ((EnumConstant)right).Child, loc);
if (result != null)
result = result.Reduce (ec, EnumSpec.GetUnderlyingType (lt));
return result;
///
/// bool operator ==(E x, E y);
/// bool operator !=(E x, E y);
/// bool operator <(E x, E y);
/// bool operator >(E x, E y);
/// bool operator <=(E x, E y);
/// bool operator >=(E x, E y);
///
case Binary.Operator.Equality:
case Binary.Operator.Inequality:
case Binary.Operator.LessThan:
case Binary.Operator.GreaterThan:
//.........这里部分代码省略.........
开发者ID:furesoft,项目名称:NRefactory,代码行数:101,代码来源:cfold.cs
注:本文中的ICSharpCode.NRefactory.MonoCSharp.ResolveContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论