本文整理汇总了C#中IronPython.Compiler.Ast.FunctionDefinition类的典型用法代码示例。如果您正苦于以下问题:C# FunctionDefinition类的具体用法?C# FunctionDefinition怎么用?C# FunctionDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FunctionDefinition类属于IronPython.Compiler.Ast命名空间,在下文中一共展示了FunctionDefinition类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: PostWalk
public override void PostWalk(FunctionDefinition node)
{
if (node.Body != null && node.Name != null) {
_scopes.Pop();
_scopeTree.Pop();
_curUnit = _analysisStack.Pop();
}
}
开发者ID:TerabyteX,项目名称:main,代码行数:8,代码来源:OverviewWalker.cs
示例2: PythonMethod
public PythonMethod(IClass declaringType, FunctionDefinition methodDefinition, string name)
: base(declaringType, name)
{
ReturnType = new DefaultReturnType(declaringType);
Modifiers = ModifierEnum.Public;
GetMethodRegions(methodDefinition);
AddParameters(methodDefinition);
declaringType.Methods.Add(this);
}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:11,代码来源:PythonMethod.cs
示例3: Walk
public override bool Walk(FunctionDefinition node)
{
if (IsInitializeComponentMethod(node)) {
Type type = GetComponentType();
component = componentCreator.CreateComponent(type, componentName);
IResourceReader reader = componentCreator.GetResourceReader(CultureInfo.InvariantCulture);
if (reader != null) {
reader.Dispose();
}
node.Body.Walk(this);
}
return false;
}
开发者ID:rbrunhuber,项目名称:SharpDevelop,代码行数:13,代码来源:PythonComponentWalker.cs
示例4: Walk
public override bool Walk(FunctionDefinition functionDefinition)
{
if (functionDefinition.Body == null) {
return false;
}
IClass c = GetClassBeingWalked();
PythonMethodDefinition methodDefinition = new PythonMethodDefinition(functionDefinition);
PythonMethod method = methodDefinition.CreateMethod(c);
if (method is PythonConstructor) {
FindFields(c, functionDefinition);
}
return false;
}
开发者ID:siegfriedpammer,项目名称:SharpDevelop,代码行数:15,代码来源:PythonAstWalker.cs
示例5: GetImageListKind
private static ImageListKind GetImageListKind(FunctionDefinition funcDef)
{
ImageListKind imageKind = ImageListKind.Method;
if (funcDef.Decorators != null && funcDef.Decorators.Count == 1) {
foreach (var decorator in funcDef.Decorators) {
NameExpression nameExpr = decorator as NameExpression;
if (nameExpr != null) {
if (nameExpr.Name == "property") {
imageKind = ImageListKind.Property;
break;
} else if (nameExpr.Name == "staticmethod") {
imageKind = ImageListKind.StaticMethod;
break;
} else if (nameExpr.Name == "classmethod") {
imageKind = ImageListKind.ClassMethod;
break;
}
}
}
}
return imageKind;
}
开发者ID:TerabyteX,项目名称:main,代码行数:22,代码来源:DropDownBarClient.cs
示例6: 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
示例7: PushFunction
private void PushFunction(FunctionDefinition function) {
if (_functions == null) {
_functions = new Stack<FunctionDefinition>();
}
_functions.Push(function);
}
开发者ID:bdoot,项目名称:IronLanguages,代码行数:6,代码来源:Parser.cs
示例8: PythonMethodDefinition
public PythonMethodDefinition(FunctionDefinition methodDefinition)
{
this.methodDefinition = methodDefinition;
}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:4,代码来源:PythonMethodDefinition.cs
示例9: ParseLambdaHelperEnd
private Expression ParseLambdaHelperEnd(FunctionDefinition func, Expression expr) {
// Pep 342 in Python 2.5 allows Yield Expressions, which can occur inside a Lambda body.
// In this case, the lambda is a generator and will yield it's final result instead of just return it.
Statement body;
if (func.IsGenerator) {
YieldExpression y = new YieldExpression(expr);
y.SetLoc(_globalParent, expr.IndexSpan);
body = new ExpressionStatement(y);
} else {
body = new ReturnStatement(expr);
}
body.SetLoc(_globalParent, expr.StartIndex, expr.EndIndex);
FunctionDefinition func2 = PopFunction();
System.Diagnostics.Debug.Assert(func == func2);
func.Body = body;
func.EndIndex = GetEnd();
LambdaExpression ret = new LambdaExpression(func);
func.SetLoc(_globalParent, func.IndexSpan);
ret.SetLoc(_globalParent, func.IndexSpan);
return ret;
}
开发者ID:bdoot,项目名称:IronLanguages,代码行数:24,代码来源:Parser.cs
示例10: Walk
public override bool Walk(FunctionDefinition node)
{
// Do not recurse into nested functions
return node == func;
}
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:5,代码来源:FuncDef.cs
示例11: FindNames
public static string[] FindNames(FunctionDefinition function) {
var parameters = function.Parameters;
if (parameters.Count > 0) {
SelfNameFinder finder = new SelfNameFinder(function, parameters[0]);
function.Body.Walk(finder);
return ArrayUtils.ToArray(finder._names.Keys);
} else {
// no point analyzing function with no parameters
return ArrayUtils.EmptyStrings;
}
}
开发者ID:CookieEaters,项目名称:FireHTTP,代码行数:12,代码来源:ClassDefinition.cs
示例12: GetMethodRegions
void GetMethodRegions(FunctionDefinition methodDefinition)
{
GetBodyRegion(methodDefinition);
GetMethodRegion(methodDefinition);
}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:5,代码来源:PythonMethod.cs
示例13: GetMethodRegion
/// <summary>
/// Gets the region of a method. This does not include the body.
/// </summary>
void GetMethodRegion(FunctionDefinition methodDefinition)
{
SourceLocation start = methodDefinition.Start;
SourceLocation end = methodDefinition.Header;
Region = new DomRegion(start.Line, start.Column, end.Line, end.Column + 1);
}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:9,代码来源:PythonMethod.cs
示例14: PostWalk
// FunctionDefinition
public override void PostWalk(FunctionDefinition node)
{
Debug.Assert(_currentScope == node);
PopScope();
}
开发者ID:TerabyteX,项目名称:main,代码行数:6,代码来源:PythonNameBinder.cs
示例15: Walk
// FunctionDefinition
public override bool Walk(FunctionDefinition node)
{
node._nameVariable = _globalScope.EnsureGlobalVariable("__name__");
// Name is defined in the enclosing context
if (!node.IsLambda) {
node.PythonVariable = DefineName(node.Name);
}
// process the default arg values in the outer context
foreach (Parameter p in node.Parameters) {
if (p.DefaultValue != null) {
p.DefaultValue.Walk(this);
}
}
// process the decorators in the outer context
if (node.Decorators != null) {
foreach (Expression dec in node.Decorators) {
dec.Walk(this);
}
}
PushScope(node);
foreach (Parameter p in node.Parameters) {
p.Walk(_parameter);
}
node.Body.Walk(this);
return false;
}
开发者ID:TerabyteX,项目名称:main,代码行数:32,代码来源:PythonNameBinder.cs
示例16: FunctionDefinitionInfo
public FunctionDefinitionInfo(IronPython.Compiler.Ast.FunctionDefinition function)
{
this.function = function;
}
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:4,代码来源:Inferred.cs
示例17: YieldLabelBuilder
private YieldLabelBuilder(FunctionDefinition func, CodeGen cg)
{
this.func = func;
this.cg = cg;
this.topYields = new YieldTarget[func.YieldCount];
}
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:6,代码来源:FuncDef.cs
示例18: IsInitializeComponentMethod
static bool IsInitializeComponentMethod(FunctionDefinition node)
{
string name = node.Name.ToString().ToLowerInvariant();
return name == "initializecomponent" || name == "initializecomponents";
}
开发者ID:rbrunhuber,项目名称:SharpDevelop,代码行数:5,代码来源:PythonComponentWalker.cs
示例19: AddParameters
void AddParameters(FunctionDefinition methodDefinition, bool ignoreFirstMethodParameter)
{
foreach (IParameter parameter in ConvertParameters(methodDefinition.Parameters, ignoreFirstMethodParameter)) {
Parameters.Add(parameter);
}
}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:6,代码来源:PythonMethod.cs
示例20: FunctionDef
internal FunctionDef(FunctionDefinition def)
: this() {
_name = def.Name;
_args = new arguments(def.Parameters);
_body = ConvertStatements(def.Body);
if (def.Decorators != null) {
_decorators = PythonOps.MakeEmptyList(def.Decorators.Count);
foreach (Compiler.Ast.Expression expr in def.Decorators)
_decorators.Add(Convert(expr));
} else
_decorators = PythonOps.MakeEmptyList(0);
}
开发者ID:rchandrashekara,项目名称:main,代码行数:13,代码来源:_ast.cs
注:本文中的IronPython.Compiler.Ast.FunctionDefinition类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论