private TryCatchAny ( System.Linq.Expressions tryBody, System.Linq.Expressions catchBody ) : |
||
tryBody | System.Linq.Expressions | |
catchBody | System.Linq.Expressions | |
return |
private MSA.Expression /*!*/ TransformRead(AstGenerator /*!*/ gen, int /*!*/ opKind) { MSA.Expression transformedName = TransformName(gen); MSA.Expression transformedQualifier; switch (TransformQualifier(gen, out transformedQualifier)) { case StaticScopeKind.Global: return((opKind == OpGet ? Methods.GetGlobalConstant : Methods.IsDefinedGlobalConstant). OpCall(gen.CurrentScopeVariable, transformedName)); case StaticScopeKind.EnclosingModule: return((opKind == OpGet ? Methods.GetUnqualifiedConstant : Methods.IsDefinedUnqualifiedConstant). OpCall(gen.CurrentScopeVariable, transformedName)); case StaticScopeKind.Explicit: if (opKind == OpGet) { return(Methods.GetQualifiedConstant.OpCall(AstFactory.Box(transformedQualifier), gen.CurrentScopeVariable, transformedName)); } else { return(gen.TryCatchAny( Methods.IsDefinedQualifiedConstant.OpCall(AstFactory.Box(transformedQualifier), gen.CurrentScopeVariable, transformedName), Ast.Constant(false) )); } } throw Assert.Unreachable; }
internal override MSA.Expression TransformDefinedCondition(AstGenerator /*!*/ gen) { // MRI doesn't evaluate the arguments MSA.Expression result = AstUtils.LightDynamic( RubyCallAction.Make(gen.Context, _methodName, RubyCallSignature.IsDefined(_target == null)), typeof(bool), gen.CurrentScopeVariable, (_target != null) ? AstUtils.Box(_target.TransformRead(gen)) : gen.CurrentSelfVariable ); return((_target != null) ? gen.TryCatchAny(result, AstFactory.False) : result); }
internal override MSA.Expression TransformDefinedCondition(AstGenerator /*!*/ gen) { if (_target != null) { return(gen.TryCatchAny( Methods.IsDefinedMethod.OpCall( AstFactory.Box(_target.TransformRead(gen)), gen.CurrentScopeVariable, AstUtils.Constant(_methodName) ), Ast.Constant(false) )); } else { return(Methods.IsDefinedMethod.OpCall(gen.CurrentSelfVariable, gen.CurrentScopeVariable, AstUtils.Constant(_methodName))); } }
internal override MSA.Expression TransformDefinedCondition(AstGenerator/*!*/ gen) { // MRI doesn't evaluate the arguments MSA.Expression result = AstUtils.LightDynamic( RubyCallAction.Make(gen.Context, _methodName, RubyCallSignature.IsDefined(_target == null)), typeof(bool), gen.CurrentScopeVariable, (_target != null) ? AstUtils.Box(_target.TransformRead(gen)) : gen.CurrentSelfVariable ); return (_target != null) ? gen.TryCatchAny(result, AstFactory.False) : result; }
internal override MSA.Expression TransformDefinedCondition(AstGenerator/*!*/ gen) { if (_target != null) { return gen.TryCatchAny( Methods.IsDefinedMethod.OpCall( AstFactory.Box(_target.TransformRead(gen)), gen.CurrentScopeVariable, AstUtils.Constant(_methodName) ), AstUtils.Constant(false) ); } else { return Methods.IsDefinedMethod.OpCall(gen.CurrentSelfVariable, gen.CurrentScopeVariable, AstUtils.Constant(_methodName)); } }
private MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen, int/*!*/ opKind) { MSA.Expression transformedName = TransformName(gen); MSA.Expression transformedQualifier; switch (TransformQualifier(gen, out transformedQualifier)) { case StaticScopeKind.Global: return (opKind == OpGet ? Methods.GetGlobalConstant : Methods.IsDefinedGlobalConstant). OpCall(gen.CurrentScopeVariable, transformedName); case StaticScopeKind.EnclosingModule: return (opKind == OpGet ? Methods.GetUnqualifiedConstant : Methods.IsDefinedUnqualifiedConstant). OpCall(gen.CurrentScopeVariable, transformedName); case StaticScopeKind.Explicit: if (opKind == OpGet) { return Methods.GetQualifiedConstant.OpCall(AstFactory.Box(transformedQualifier), gen.CurrentScopeVariable, transformedName); } else { return gen.TryCatchAny( Methods.IsDefinedQualifiedConstant.OpCall(AstFactory.Box(transformedQualifier), gen.CurrentScopeVariable, transformedName), AstUtils.Constant(false) ); } } throw Assert.Unreachable; }