• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Ast.Parameter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IronPython.Compiler.Ast.Parameter的典型用法代码示例。如果您正苦于以下问题:C# Parameter类的具体用法?C# Parameter怎么用?C# Parameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Parameter类属于IronPython.Compiler.Ast命名空间,在下文中一共展示了Parameter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: FunctionDefinition

        public FunctionDefinition(string name, Parameter[] parameters, Statement body) {
            ContractUtils.RequiresNotNullItems(parameters, "parameters");

            if (name == null) {
                _name = "<lambda$" + Interlocked.Increment(ref _lambdaId) + ">";
                _isLambda = true;
            } else {
                _name = name;
            }

            _parameters = parameters;
            _body = body;
        }
开发者ID:mstram,项目名称:ironruby,代码行数:13,代码来源:FunctionDefinition.cs


示例2: FunctionDefinition

 public FunctionDefinition(string name, Parameter[] parameters, SourceUnit sourceUnit)
     : this(name, parameters, null, sourceUnit) {
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:3,代码来源:FunctionDefinition.cs


示例3: ParseGeneratorExpression

        //  genexpr_for  ::= "for" target_list "in" or_test [genexpr_iter]
        //  genexpr_iter ::= (genexpr_for | genexpr_if) *
        //
        //  "for" has NOT been eaten before entering this method
        private Expression ParseGeneratorExpression(Expression expr) {
            ForStatement root = ParseGenExprFor();
            Statement current = root;

            for (; ; ) {
                if (PeekToken(Tokens.KeywordForToken)) {
                    current = NestGenExpr(current, ParseGenExprFor());
                } else if (PeekToken(Tokens.KeywordIfToken)) {
                    current = NestGenExpr(current, ParseGenExprIf());
                } else {
                    // Generator Expressions have an implicit function definition and yield around their expression.
                    //  (x for i in R)
                    // becomes:
                    //   def f(): 
                    //     for i in R: yield (x)
                    ExpressionStatement ys = new ExpressionStatement(new YieldExpression(expr));
                    ys.Expression.SetLoc(_globalParent, expr.IndexSpan);
                    ys.SetLoc(_globalParent, expr.IndexSpan);
                    NestGenExpr(current, ys);
                    break;
                }
            }

            // We pass the outermost iterable in as a parameter because Python semantics
            // say that this one piece is computed at definition time rather than iteration time
            const string fname = "<genexpr>";
            Parameter parameter = new Parameter("__gen_$_parm__", 0);
            FunctionDefinition func = new FunctionDefinition(fname, new Parameter[] { parameter }, root);
            func.IsGenerator = true;
            func.SetLoc(_globalParent, root.StartIndex, GetEnd());
            func.HeaderIndex = root.EndIndex;

            //  Transform the root "for" statement
            Expression outermost = root.List;
            NameExpression ne = new NameExpression("__gen_$_parm__");
            ne.SetLoc(_globalParent, outermost.IndexSpan);
            root.List = ne;

            GeneratorExpression ret = new GeneratorExpression(func, outermost);
            ret.SetLoc(_globalParent, expr.StartIndex, GetEnd());
            return ret;
        }
开发者ID:bdoot,项目名称:IronLanguages,代码行数:46,代码来源:Parser.cs


示例4: ParseParameterName

 private Parameter ParseParameterName(HashSet<string> names, ParameterKind kind) {
     string name = ReadName();
     if (name != null) {
         CheckUniqueParameter(names, name);
     } else {
         return null;
     }
     Parameter parameter = new Parameter(name, kind);
     parameter.SetLoc(_globalParent, GetStart(), GetEnd());
     return parameter;
 }
开发者ID:bdoot,项目名称:IronLanguages,代码行数:11,代码来源:Parser.cs


示例5: arguments

 internal arguments(Parameter[] parameters)
     : this(parameters as IList<Parameter>) {
 }
开发者ID:rchandrashekara,项目名称:main,代码行数:3,代码来源:_ast.cs


示例6: PostWalk

 public override void PostWalk(Parameter node)
 {
 }
开发者ID:valdisz,项目名称:PyToJs,代码行数:3,代码来源:JavascriptGenerator.cs


示例7: Walk

        public override bool Walk(Parameter node)
        {
            Content(node.Name);
            Define(node.Name);

            return false;
        }
开发者ID:valdisz,项目名称:PyToJs,代码行数:7,代码来源:JavascriptGenerator.cs


示例8: ParseParameterName

 private Parameter ParseParameterName(Dictionary<SymbolId, object> names, ParameterKind kind) {
     SymbolId name = ReadName();
     if (name != SymbolId.Empty) {
         CheckUniqueParameter(names, name);
     } else {
         return null;
     }
     Parameter parameter = new Parameter(name, kind);
     parameter.SetLoc(GetStart(), GetEnd());
     return parameter;
 }
开发者ID:tnachen,项目名称:ironruby,代码行数:11,代码来源:Parser.cs


示例9: GetGeneratorDelegateType

 private static Type GetGeneratorDelegateType(Parameter[] parameters, bool wrapper) {
     return PythonCallTargets.GetGeneratorTargetType(wrapper, parameters.Length);
 }
开发者ID:octavioh,项目名称:ironruby,代码行数:3,代码来源:FunctionDefinition.cs


示例10: ComputeFlags

 private static FunctionAttributes ComputeFlags(Parameter[] parameters) {
     FunctionAttributes fa = FunctionAttributes.None;
     if (parameters != null) {
         int i;
         for (i = 0; i < parameters.Length; i++) {
             Parameter p = parameters[i];
             if (p.IsDictionary || p.IsList) break;
         }
         // Check for the list and dictionary parameters, which must be the last(two)
         if (i < parameters.Length && parameters[i].IsList) {
             i++;
             fa |= FunctionAttributes.ArgumentList;
         }
         if (i < parameters.Length && parameters[i].IsDictionary) {
             i++;
             fa |= FunctionAttributes.KeywordDictionary;
         }
         // All parameters must now be exhausted
         if (i < parameters.Length) {
             throw new ArgumentException(IronPython.Resources.InvalidParameters, "parameters");
         }
     }
     return fa;
 }
开发者ID:octavioh,项目名称:ironruby,代码行数:24,代码来源:FunctionDefinition.cs


示例11: Walk

 public override bool Walk(Parameter node) {
     node.Variable = _binder.DefineParameter(node.Name);
     return false;
 }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:4,代码来源:PythonNameBinder.cs


示例12: Walk

 public override bool Walk(Parameter node) {
     _fc.Define(node.Name);
     return true;
 }
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:4,代码来源:FlowChecker.cs


示例13: MakeParameterResult

        internal static ParameterResult MakeParameterResult(ProjectState state, Parameter curParam)
        {
            string name = curParam.Name;
            if (curParam.IsDictionary) {
                name = "**" + name;
            } else if (curParam.IsList) {
                name = "*" + curParam.Name;
            }

            if (curParam.DefaultValue != null) {
                // TODO: Support all possible expressions for default values, we should
                // probably have a PythonAst walker for expressions or we should add ToCodeString()
                // onto Python ASTs so they can round trip
                ConstantExpression defaultValue = curParam.DefaultValue as ConstantExpression;
                if (defaultValue != null) {
                    name = name + " = " + PythonOps.Repr(state.CodeContext, defaultValue.Value);
                }

                NameExpression nameExpr = curParam.DefaultValue as NameExpression;
                if (nameExpr != null) {
                    name = name + " = " + nameExpr.Name;
                }

                DictionaryExpression dict = curParam.DefaultValue as DictionaryExpression;
                if (dict != null) {
                    if (dict.Items.Count == 0) {
                        name = name + " = {}";
                    } else {
                        name = name + " = {...}";
                    }
                }

                ListExpression list = curParam.DefaultValue as ListExpression;
                if (list != null) {
                    if (list.Items.Count == 0) {
                        name = name + " = []";
                    } else {
                        name = name + " = [...]";
                    }
                }

                TupleExpression tuple = curParam.DefaultValue as TupleExpression;
                if (tuple != null) {
                    if (tuple.Items.Count == 0) {
                        name = name + " = ()";
                    } else {
                        name = name + " = (...)";
                    }
                }
            }

            var newParam = new ParameterResult(name);
            return newParam;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:54,代码来源:FunctionInfo.cs


示例14: Walk

 // Parameter
 public override bool Walk(Parameter node) {
     node.Parent = _currentScope;
     return base.Walk(node);
 }
开发者ID:paweljasinski,项目名称:ironpython3,代码行数:5,代码来源:PythonNameBinder.cs


示例15: ComputeFlags

 private static FunctionAttributes ComputeFlags(Parameter[] parameters) {
     FunctionAttributes fa = FunctionAttributes.None;
     if (parameters != null) {
         int i;
         for (i = 0; i < parameters.Length; i++) {
             Parameter p = parameters[i];
             if (p.IsDictionary || p.IsList) break;
         }
         // Check for the list and dictionary parameters, which must be the last(two)
         if (i < parameters.Length && parameters[i].IsList) {
             i++;
             fa |= FunctionAttributes.ArgumentList;
         }
         if (i < parameters.Length && parameters[i].IsDictionary) {
             i++;
             fa |= FunctionAttributes.KeywordDictionary;
         }
         
         // All parameters must now be exhausted
         Debug.Assert(i == parameters.Length);
     }
     return fa;
 }
开发者ID:m4dc4p,项目名称:ironruby,代码行数:23,代码来源:FunctionDefinition.cs


示例16: Revert

 internal Parameter[] Revert()
 {
     List<Parameter> parameters = new List<Parameter>();
     int argIdx = args.Count - 1;
     for (int defIdx = defaults.Count - 1; defIdx >= 0; defIdx--, argIdx--) {
         Name name = (Name)args[argIdx];
         Parameter p = new Parameter(name.id);
         p.DefaultValue = expr.Revert(defaults[defIdx]);
         parameters.Add(p);
     }
     while (argIdx >= 0) {
         Name name = (Name)args[argIdx--];
         parameters.Add(new Parameter(name.id));
     }
     parameters.Reverse();
     if (vararg != null)
         parameters.Add(new Parameter(vararg, ParameterKind.List));
     if (kwarg != null)
         parameters.Add(new Parameter(kwarg, ParameterKind.Dictionary));
     return parameters.ToArray();
 }
开发者ID:TerabyteX,项目名称:main,代码行数:21,代码来源:_ast.cs


示例17: Name

 internal Name(Parameter para)
     : this(para.Name, Param.Instance)
 {
     GetSourceLocation(para);
 }
开发者ID:TerabyteX,项目名称:main,代码行数:5,代码来源:_ast.cs


示例18: FunctionDefinition

 public FunctionDefinition(SymbolId name, Parameter[] parameters, SourceUnit sourceUnit)
     : this(name, parameters, null, sourceUnit) {
 }
开发者ID:octavioh,项目名称:ironruby,代码行数:3,代码来源:FunctionDefinition.cs


示例19: ParseParameter

        //  parameter ::=
        //      identifier | "(" sublist ")"
        Parameter ParseParameter(int position, Dictionary<SymbolId, object> names) {
            Token t = PeekToken();
            Parameter parameter = null;

            switch (t.Kind) {
                case TokenKind.LeftParenthesis: // sublist
                    NextToken();
                    Expression ret = ParseSublist(names);
                    Eat(TokenKind.RightParenthesis);
                    TupleExpression tret = ret as TupleExpression;

                    if (tret != null) {
                        parameter = new SublistParameter(position, tret);
                    } else {
                        parameter = new Parameter(((NameExpression)ret).Name);
                    }
                    parameter.SetLoc(ret.Span);
                    break;

                case TokenKind.Name:  // identifier
                    NextToken();
                    SymbolId name = FixName((SymbolId)t.Value);
                    parameter = new Parameter(name);
                    CompleteParameterName(parameter, name, names);
                    break;

                default:
                    ReportSyntaxError(_lookahead);
                    break;
            }

            return parameter;
        }
开发者ID:tnachen,项目名称:ironruby,代码行数:35,代码来源:Parser.cs


示例20: AddOptinonalParam

        private void AddOptinonalParam(StringBuilder sb, Parameter p)
        {
            JavascriptGenerator gen = new JavascriptGenerator(src, sink);
            p.DefaultValue.Walk(gen);

            sb.AppendFormat("{0}if (typeof({1}) == 'undefined') {{",
                Indent(),
                p.Name
            );
            sb.AppendLine();

            sb.AppendFormat("{0}{1} = {2};",
                Indent(indent + 1),
                p.Name,
                gen.ToString()
            );
            sb.AppendLine();

            sb.AppendFormat("{0}}}", Indent());
            sb.AppendLine();
        }
开发者ID:valdisz,项目名称:PyToJs,代码行数:21,代码来源:JavascriptGenerator.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Ast.PythonAst类代码示例发布时间:2022-05-26
下一篇:
C# Ast.Node类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap