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


C# Ast.Parameter类代码示例

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


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


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