本文整理汇总了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;
}
示例2: FunctionDefinition
public FunctionDefinition(string name, Parameter[] parameters, SourceUnit sourceUnit)
: this(name, parameters, null, sourceUnit) {
}
示例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;
}
示例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;
}
示例5: arguments
internal arguments(Parameter[] parameters)
: this(parameters as IList<Parameter>) {
}
示例6: PostWalk
public override void PostWalk(Parameter node)
{
}
示例7: Walk
public override bool Walk(Parameter node)
{
Content(node.Name);
Define(node.Name);
return false;
}
示例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;
}
示例9: GetGeneratorDelegateType
private static Type GetGeneratorDelegateType(Parameter[] parameters, bool wrapper) {
return PythonCallTargets.GetGeneratorTargetType(wrapper, parameters.Length);
}
示例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;
}
示例11: Walk
public override bool Walk(Parameter node) {
node.Variable = _binder.DefineParameter(node.Name);
return false;
}
示例12: Walk
public override bool Walk(Parameter node) {
_fc.Define(node.Name);
return true;
}
示例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;
}
示例14: Walk
// Parameter
public override bool Walk(Parameter node) {
node.Parent = _currentScope;
return base.Walk(node);
}
示例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;
}