当前位置: 首页>>代码示例>>C#>>正文


C# RubyScope.GetInnerMostClosureScope方法代码示例

本文整理汇总了C#中IronRuby.Runtime.RubyScope.GetInnerMostClosureScope方法的典型用法代码示例。如果您正苦于以下问题:C# RubyScope.GetInnerMostClosureScope方法的具体用法?C# RubyScope.GetInnerMostClosureScope怎么用?C# RubyScope.GetInnerMostClosureScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IronRuby.Runtime.RubyScope的用法示例。


在下文中一共展示了RubyScope.GetInnerMostClosureScope方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Scan

        public static object/*!*/ Scan(RubyScope/*!*/ scope, [NotNull]BlockParam/*!*/ block, MutableString/*!*/ self, [DefaultProtocol, NotNull]RubyRegex regex) {
            var matchScope = scope.GetInnerMostClosureScope();
            
            MatchCollection matches = regex.Matches(self);
            if (matches.Count == 0) {
                matchScope.CurrentMatch = null;
                return self;
            } 

            foreach (Match match in matches) {
                var currentMatch = new MatchData(match, self);

                matchScope.CurrentMatch = currentMatch;

                object blockResult;
                if (block.Yield(MatchToScanResult(scope, self, regex, match), out blockResult)) {
                    return blockResult;
                }

                // resets the $~ scope variable to the last match (skipd if block jumped):
                matchScope.CurrentMatch = currentMatch;
            }
            return self;
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:24,代码来源:MutableStringOps.cs

示例2: SetValue

        public override void SetValue(RubyContext/*!*/ context, RubyScope scope, string/*!*/ name, object value) {
            switch (_id) {
                // regex:
                case GlobalVariableId.MatchData:
                    if (scope == null) {
                        throw ReadOnlyError(name);
                    }

                    scope.GetInnerMostClosureScope().CurrentMatch = (value != null) ? RequireType<MatchData>(value, name, "MatchData") : null;
                    return;

                case GlobalVariableId.MatchLastGroup:
                case GlobalVariableId.MatchPrefix:
                case GlobalVariableId.MatchSuffix:
                case GlobalVariableId.EntireMatch:
                    throw ReadOnlyError(name);
                
                
                // exceptions:
                case GlobalVariableId.CurrentException:
                    context.SetCurrentException(value);
                    return;

                case GlobalVariableId.CurrentExceptionBacktrace:
                    context.SetCurrentExceptionBacktrace(value);
                    return;


                // input:
                case GlobalVariableId.LastInputLine:
                    if (scope == null) {
                        throw ReadOnlyError(name);
                    }
                    scope.GetInnerMostClosureScope().LastInputLine = value;
                    return;

                case GlobalVariableId.LastInputLineNumber:
                    context.InputProvider.LastInputLineNumber = RequireType<int>(value, name, "Fixnum");
                    return;

                case GlobalVariableId.CommandLineArguments:
                case GlobalVariableId.InputFileName:
                    throw ReadOnlyError(name);

                // output:
                case GlobalVariableId.OutputStream:
                    context.StandardOutput = RequireWriteProtocol(context, value, name);
                    return;

                case GlobalVariableId.ErrorOutputStream:
                    context.StandardErrorOutput = RequireWriteProtocol(context, value, name);
                    break;

                case GlobalVariableId.InputStream:
                    context.StandardInput = value;
                    return;

                // separators:
                case GlobalVariableId.InputContent:
                    throw ReadOnlyError(name);

                case GlobalVariableId.InputSeparator:
                    context.InputSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
                    return;

                case GlobalVariableId.OutputSeparator:
                    context.OutputSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
                    return;

                case GlobalVariableId.StringSeparator:
                    // type not enforced:
                    context.StringSeparator = value;
                    return;

                case GlobalVariableId.ItemSeparator:
                    context.ItemSeparator = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
                    return;


                // loader:
                case GlobalVariableId.LoadedFiles:
                case GlobalVariableId.LoadPath:
                    throw ReadOnlyError(name);


                // misc:
                case GlobalVariableId.SafeLevel:
                    context.SetSafeLevel(RequireType<int>(value, name, "Fixnum"));
                    return;

                case GlobalVariableId.Verbose:
                    context.Verbose = value;
                    return;

                case GlobalVariableId.CommandLineProgramPath:
                    context.CommandLineProgramPath = (value != null) ? RequireType<MutableString>(value, name, "String") : null;
                    return;
                
                case GlobalVariableId.KCode:
#if !SILVERLIGHT
//.........这里部分代码省略.........
开发者ID:toddb,项目名称:ironruby,代码行数:101,代码来源:SpecialGlobalVariableInfo.cs

示例3: ReplaceAll

        private static MutableString ReplaceAll(RubyScope/*!*/ scope, MutableString/*!*/ input, MutableString/*!*/ replacement, 
            RubyRegex/*!*/ regex) {
            var matchScope = scope.GetInnerMostClosureScope();
            
            // case of all
            MatchCollection matches = regex.Matches(input);
            if (matches.Count == 0) {
                matchScope.CurrentMatch = null;
                return null;
            }

            MutableString result = input.CreateInstance().TaintBy(input).TaintBy(replacement);

            int offset = 0;
            foreach (Match match in matches) {
                result.Append(input, offset, match.Index - offset);
                AppendReplacementExpression(input, match, result, replacement);
                offset = match.Index + match.Length;
            }

            result.Append(input, offset, input.Length - offset);

            matchScope.CurrentMatch = new MatchData(matches[matches.Count - 1], input);
            return result;
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:25,代码来源:MutableStringOps.cs

示例4: ReverseIndex

        public static object ReverseIndex(RubyScope/*!*/ scope, MutableString/*!*/ self, 
            [NotNull]RubyRegex/*!*/ regex, [DefaultProtocol]int start) {

            start = NormalizeIndex(self, start);
            if (start < 0) {
                return null;
            }
            start = (start > self.Length) ? self.Length : start;

            var matchScope = scope.GetInnerMostClosureScope();
            
            Match match = regex.ReverseMatch(self, start);
            if (match.Success) {
                matchScope.CurrentMatch = new MatchData(match, self);
                return ScriptingRuntimeHelpers.Int32ToObject(match.Index);
            } else {
                matchScope.CurrentMatch = null;
                return null;
            }
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:20,代码来源:MutableStringOps.cs

示例5: BlockReplaceAll

        // returns true if block jumped
        // "result" will be null if there is no successful match
        private static bool BlockReplaceAll(ConversionStorage<MutableString>/*!*/ tosConversion, 
            RubyScope/*!*/ scope, MutableString/*!*/ input, BlockParam/*!*/ block,
            RubyRegex/*!*/ regex, out object blockResult, out MutableString result) {

            var matchScope = scope.GetInnerMostClosureScope();

            var matches = regex.Matches(tosConversion.Context.KCode, input);
            if (matches.Count == 0) {
                result = null;
                blockResult = null;
                matchScope.CurrentMatch = null;
                return false;
            }

            // create an empty result:
            result = input.CreateInstance().TaintBy(input);
            
            int offset = 0;
            foreach (MatchData match in matches) {
                matchScope.CurrentMatch = match;

                input.TrackChanges();
                if (block.Yield(match.GetValue(), out blockResult)) {
                    return true;
                }
                if (input.HasChanged) {
                    return false;
                }

                // resets the $~ scope variable to the last match (skipd if block jumped):
                matchScope.CurrentMatch = match;

                MutableString replacement = Protocols.ConvertToString(tosConversion, blockResult);
                result.TaintBy(replacement);

                // prematch:
                result.Append(input, offset, match.Index - offset);

                // replacement (unlike ReplaceAll, don't interpolate special sequences like \1 in block return value):
                result.Append(replacement);

                offset = match.Index + match.Length;
            }

            // post-last-match:
            result.Append(input, offset, input.Length - offset);

            blockResult = null;
            return false;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:52,代码来源:MutableStringOps.cs

示例6: BlockReplaceFirst

        // returns true if block jumped
        // "result" will be null if there is no successful match
        private static bool BlockReplaceFirst(RubyScope/*!*/ scope, MutableString/*!*/ input, BlockParam/*!*/ block,
            RubyRegex/*!*/ pattern, out object blockResult, out MutableString result) {

            var matchScope = scope.GetInnerMostClosureScope();
            MatchData match = RegexpOps.Match(scope, pattern, input);
            if (match == null || !match.Success) {
                result = null;
                blockResult = null;
                matchScope.CurrentMatch = null;
                return false;
            }

            // copy upfront so that no modifications to the input string are included in the result:
            result = input.Clone();
            matchScope.CurrentMatch = match;

            if (block.Yield(MutableString.Create(match.Value), out blockResult)) {
                return true;
            }

            // resets the $~ scope variable to the last match (skipd if block jumped):
            matchScope.CurrentMatch = match;

            MutableString replacement = Protocols.ConvertToString(scope.RubyContext, blockResult);
            result.TaintBy(replacement);

            // Note - we don't interpolate special sequences like \1 in block return value
            result.Replace(match.Index, match.Length, replacement);

            blockResult = null;
            return false;
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:34,代码来源:MutableStringOps.cs

示例7: GetCurrentMatchPrefix

 [Emitted] //RegexMatchReference:
 public static MutableString GetCurrentMatchPrefix(RubyScope/*!*/ scope) {
     MatchData match = scope.GetInnerMostClosureScope().CurrentMatch;
     if (match == null) {
         return null;
     }
     return match.OriginalString.GetSlice(0, match.Index).TaintBy(match.OriginalString);
 }
开发者ID:teejayvanslyke,项目名称:ironruby,代码行数:8,代码来源:RubyOps.cs

示例8: GetCurrentMatchSuffix

 [Emitted] //RegexMatchReference:
 public static MutableString GetCurrentMatchSuffix(RubyScope/*!*/ scope) {
     MatchData match = scope.GetInnerMostClosureScope().CurrentMatch;
     if (match == null) {
         return null;
     }
     return match.OriginalString.GetSlice(match.Index + match.Length);
 }
开发者ID:teejayvanslyke,项目名称:ironruby,代码行数:8,代码来源:RubyOps.cs

示例9: GetCurrentMatchData

 [Emitted] //RegexMatchReference:
 public static MatchData GetCurrentMatchData(RubyScope/*!*/ scope) {
     return scope.GetInnerMostClosureScope().CurrentMatch;
 }
开发者ID:teejayvanslyke,项目名称:ironruby,代码行数:4,代码来源:RubyOps.cs

示例10: GetCurrentMatchLastGroup

 [Emitted] //RegexMatchReference:
 public static MutableString GetCurrentMatchLastGroup(RubyScope/*!*/ scope) {
     return scope.GetInnerMostClosureScope().GetCurrentMatchLastGroup();
 }
开发者ID:teejayvanslyke,项目名称:ironruby,代码行数:4,代码来源:RubyOps.cs

示例11: GetCurrentMatchGroup

 [Emitted] //RegexMatchReference:
 public static MutableString GetCurrentMatchGroup(RubyScope/*!*/ scope, int index) {
     Debug.Assert(index >= 0);
     return scope.GetInnerMostClosureScope().GetCurrentMatchGroup(index);
 }
开发者ID:teejayvanslyke,项目名称:ironruby,代码行数:5,代码来源:RubyOps.cs

示例12: Index

 public static object Index(RubyScope/*!*/ scope, MutableString/*!*/ self, 
     [NotNull]RubyRegex/*!*/ regex, [DefaultProtocol, Optional]int start)
 {
     MatchData match = regex.Match(self, start, true);
     scope.GetInnerMostClosureScope().CurrentMatch = match;
     return (match != null) ? ScriptingRuntimeHelpers.Int32ToObject(match.Index) : null;
 }
开发者ID:TerabyteX,项目名称:main,代码行数:7,代码来源:MutableStringOps.cs

示例13: ImplicitMatch

 public static object ImplicitMatch(RubyScope/*!*/ scope, RubyRegex/*!*/ self) {
     return MatchIndex(scope, self, Protocols.CastToString(scope.RubyContext, scope.GetInnerMostClosureScope().LastInputLine));
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:3,代码来源:RubyRegexOps.cs

示例14: Print

 public static void Print(BinaryOpStorage/*!*/ writeStorage, RubyScope/*!*/ scope, object self) {
     Print(writeStorage, self, scope.GetInnerMostClosureScope().LastInputLine);
 }
开发者ID:m4dc4p,项目名称:ironruby,代码行数:3,代码来源:IoOps.cs

示例15: MatchLastInputLine

 [Emitted] //RegularExpression:
 public static bool MatchLastInputLine(RubyRegex/*!*/ regex, RubyScope/*!*/ scope) {
     var str = scope.GetInnerMostClosureScope().LastInputLine as MutableString;
     return (str != null) ? RubyRegex.SetCurrentMatchData(scope, regex, str) != null : false;
 }
开发者ID:teejayvanslyke,项目名称:ironruby,代码行数:5,代码来源:RubyOps.cs


注:本文中的IronRuby.Runtime.RubyScope.GetInnerMostClosureScope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。