0

此代码在 C# 中运行良好:

Expression.Lambda(LambdaBody);

但是 IronRuby 似乎没有一种构建 AST 的方法。我需要 Microsoft.Scripting.Core 和 Microsoft.Scripting 库。我需要别的东西吗?这是 IronRuby 代码:

require 'C:\reorganize\software\ironruby-1.0rc3\ironruby\bin\microsoft.scripting.core'
require 'C:\reorganize\software\ironruby-1.0rc3\ironruby\bin\microsoft.dynamic'
require 'C:\reorganize\software\ironruby-1.0rc3\ironruby\bin\microsoft.scripting'
include Microsoft::Scripting::Ast
p Expression.Lambda(lambda_body) #i have already constructed the lambda body

给出:

undefined method `Lambda' for #<TypeGroup: Microsoft::Scripting::Ast::Expression, Microsoft::Scripting::Ast::Expression[TDelegate]> (NoMethodError)
    from -e:1:in `load'
    from -e:1
4

1 回答 1

1

Microsoft.Scripting.Ast 命名空间中似乎有两个Expression类:一个泛型和一个非泛型。尝试使用以下命令强制非泛型.of()

Expression.of().Lambda(lambda_body)
于 2010-04-07T13:55:29.267 回答