本文整理汇总了C#中Mono.CSharp.Invocation.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# Invocation.Resolve方法的具体用法?C# Invocation.Resolve怎么用?C# Invocation.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.Invocation
的用法示例。
在下文中一共展示了Invocation.Resolve方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Resolve
public override bool Resolve (BlockContext ec)
{
bool is_dynamic = expr.Type == InternalType.Dynamic;
if (is_dynamic)
expr = Convert.ImplicitConversionRequired (ec, expr, TypeManager.ienumerable_type, loc);
var get_enumerator_mg = ResolveGetEnumerator (ec);
if (get_enumerator_mg == null) {
return false;
}
var get_enumerator = get_enumerator_mg.BestCandidate;
var enumerator = new TemporaryVariable (get_enumerator.ReturnType, loc);
enumerator.Resolve (ec);
// Prepare bool MoveNext ()
var move_next_mg = ResolveMoveNext (ec, get_enumerator);
if (move_next_mg == null) {
return false;
}
move_next_mg.InstanceExpression = enumerator;
// Prepare ~T~ Current { get; }
var current_prop = ResolveCurrent (ec, get_enumerator);
if (current_prop == null) {
return false;
}
var current_pe = new PropertyExpr (current_prop, loc) { InstanceExpression = enumerator }.Resolve (ec);
if (current_pe == null)
return false;
VarExpr ve = var_type as VarExpr;
if (ve != null) {
// Infer implicitly typed local variable from foreach enumerable type
var_type = new TypeExpression (current_pe.Type, var_type.Location);
}
var_type = var_type.ResolveAsTypeTerminal (ec, false);
if (var_type == null)
return false;
var init = new Invocation (get_enumerator_mg, null);
init.Resolve (ec);
statement = new While (new BooleanExpression (new Invocation (move_next_mg, null)),
new Body (var_type.Type, variable, current_pe, statement, loc), loc);
var enum_type = enumerator.Type;
//
// Add Dispose method call when enumerator can be IDisposable
//
if (!enumerator.Type.ImplementsInterface (TypeManager.idisposable_type)) {
if (!enum_type.IsSealed && !TypeManager.IsValueType (enum_type)) {
//
// Runtime Dispose check
//
var tv = new LocalTemporary (TypeManager.idisposable_type);
statement = new Dispose (enumerator, tv, init, statement, loc);
} else {
//
// No Dispose call needed
//
this.init = new SimpleAssign (enumerator, init);
this.init.Resolve (ec);
}
} else {
//
// Static Dispose check
//
statement = new Dispose (enumerator, null, init, statement, loc);
}
return statement.Resolve (ec);
}
示例2: Emit
public override void Emit (EmitContext ec)
{
Expression concat = new Invocation (CreateConcatMemberExpression (), arguments, true);
concat = concat.Resolve (new ResolveContext (ec.MemberContext));
if (concat != null)
concat.Emit (ec);
}
示例3: DoResolve
protected override Expression DoResolve (ResolveContext ec)
{
if (ec.Target == Target.JavaScript) {
type = ec.BuiltinTypes.Dynamic;
eclass = ExprClass.Value;
return this;
}
if (Expr is ElementAccess) {
var elem_access = Expr as ElementAccess;
if (elem_access.Arguments.Count != 1) {
ec.Report.Error (7021, loc, "delete statement must have only one index argument.");
return null;
}
var expr = elem_access.Expr.Resolve (ec);
if (expr.Type == null) {
return null;
}
if (expr.Type.IsArray) {
ec.Report.Error (7021, loc, "delete statement not allowed on arrays.");
return null;
}
if (ec.Target == Target.JavaScript) {
Expr = Expr.Resolve(ec);
return this;
}
if (!expr.Type.IsAsDynamicClass && (expr.Type.BuiltinType != BuiltinTypeSpec.Type.Dynamic))
{
ec.Report.Error (7021, loc, "delete statement only allowed on dynamic types or dynamic classes");
return null;
}
// cast expression to IDynamicClass and invoke __DeleteDynamicValue
var dynClass = new Cast(new MemberAccess(new SimpleName("PlayScript", loc), "IDynamicClass", loc), expr, loc);
removeExpr = new Invocation (new MemberAccess (dynClass, "__DeleteDynamicValue", loc), elem_access.Arguments);
return removeExpr.Resolve (ec);
} else if (Expr is MemberAccess) {
if (ec.Target == Target.JavaScript) {
Expr = Expr.Resolve(ec);
return this;
}
var memb_access = Expr as MemberAccess;
var expr = memb_access.LeftExpression.Resolve (ec);
if (expr.Type == null) {
return null;
}
if (!expr.Type.IsAsDynamicClass && (expr.Type.BuiltinType != BuiltinTypeSpec.Type.Dynamic))
{
ec.Report.Error (7021, loc, "delete statement only allowed on dynamic types or dynamic classes");
return null;
}
// cast expression to IDynamicClass and invoke __DeleteDynamicValue
var dynClass = new Cast(new MemberAccess(new SimpleName("PlayScript", loc), "IDynamicClass", loc), expr, loc);
var args = new Arguments(1);
args.Add (new Argument(new StringLiteral(ec.BuiltinTypes, memb_access.Name, loc)));
removeExpr = new Invocation (new MemberAccess (dynClass, "__DeleteDynamicValue", loc), args);
return removeExpr.Resolve (ec);
} else {
// Error is reported elsewhere.
return null;
}
}
示例4: DoResolve
protected override Expression DoResolve (ResolveContext ec)
{
if (ec.Target == Target.JavaScript) {
type = ec.BuiltinTypes.Dynamic;
eclass = ExprClass.Value;
return this;
}
if (Expr is ElementAccess) {
var elem_access = Expr as ElementAccess;
if (elem_access.Arguments.Count != 1) {
ec.Report.Error (7021, loc, "delete statement must have only one index argument.");
return null;
}
var expr = elem_access.Expr.Resolve (ec);
if (expr.Type == null) {
return null;
}
if (expr.Type.IsArray) {
ec.Report.Error (7021, loc, "delete statement not allowed on arrays.");
return null;
}
if (ec.Target == Target.JavaScript) {
Expr = Expr.Resolve(ec);
return this;
}
removeExpr = new Invocation (new MemberAccess (expr, "Remove", loc), elem_access.Arguments);
return removeExpr.Resolve (ec);
} else if (Expr is MemberAccess) {
if (ec.Target == Target.JavaScript) {
Expr = Expr.Resolve(ec);
return this;
}
var memb_access = Expr as MemberAccess;
var expr = memb_access.LeftExpression.Resolve (ec);
if (expr.Type == null) {
return null;
}
var args = new Arguments(1);
args.Add (new Argument(new StringLiteral(ec.BuiltinTypes, memb_access.Name, loc)));
removeExpr = new Invocation (new MemberAccess (expr, "Remove", loc), args);
return removeExpr.Resolve (ec);
} else {
// Error is reported elsewhere.
return null;
}
}