Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/ironruby/ironruby
Browse files Browse the repository at this point in the history
Conflicts:
	Merlin/Main/Languages/Ruby/Samples/Tutorial/gui_tutorial.rb
	Merlin/Main/Languages/Ruby/Samples/Tutorial/tutorial.bat
  • Loading branch information
Shri Borde committed Jul 22, 2009
2 parents 0522ad7 + e488dec commit fd79351
Show file tree
Hide file tree
Showing 148 changed files with 2,254 additions and 2,202 deletions.
Expand Up @@ -43,7 +43,7 @@ public class RubyRepresenter : Representer {
public RubyRepresenter(RubyContext/*!*/ context, Serializer/*!*/ serializer, YamlOptions/*!*/ opts)
: base(serializer, opts) {
_context = context;
_objectToYamlMethod = context.GetClass(typeof(object)).ResolveMethod("to_yaml", RubyClass.IgnoreVisibility).Info;
_objectToYamlMethod = context.GetClass(typeof(object)).ResolveMethod("to_yaml", VisibilityContext.AllVisible).Info;

_TagUri =
CallSite<Func<CallSite, object, object>>.Create(
Expand Down Expand Up @@ -88,7 +88,7 @@ public RubyRepresenter(RubyContext/*!*/ context, Serializer/*!*/ serializer, Yam
#endregion

protected override Node CreateNode(object data) {
RubyMemberInfo method = _context.GetImmediateClassOf(data).ResolveMethodForSite("to_yaml", RubyClass.IgnoreVisibility).Info;
RubyMemberInfo method = _context.GetImmediateClassOf(data).ResolveMethodForSite("to_yaml", VisibilityContext.AllVisible).Info;

if (method == _objectToYamlMethod) {
return (Node)_ToYamlNode.Target(_ToYamlNode, data, this);
Expand Down
16 changes: 8 additions & 8 deletions Merlin/Main/Hosts/IronRuby.Rack/Application.cs
Expand Up @@ -12,20 +12,20 @@ public class Application {

private readonly object _app;
private readonly string _appRoot;
private readonly string _rackVersion;
private readonly string _rackVersion;
private readonly string _gemPath;

public object App {
get { return _app; }
}

private const string AppRootOptionName = "AppRoot";
private const string RackVersionOptionName = "RackVersion";
private const string RackVersionOptionName = "RackVersion";
private const string GemPathOptionName = "GemPath";

public Application(HttpContext context) {
_appRoot = GetRoot(context);
_rackVersion = GetRackVersion();
_rackVersion = GetRackVersion();
_gemPath = GetGemPath();

InitRack();
Expand All @@ -41,7 +41,7 @@ public class Application {
return RubyEngine.ExecuteMethod<RubyArray>(_app, "call", envHash);
}

private void InitRack() {
private void InitRack() {
Environment.SetEnvironmentVariable("GEM_PATH", _gemPath);

Utils.Log("=> Loading RubyGems");
Expand Down Expand Up @@ -83,10 +83,10 @@ public class Application {
}
}
return root;
}

private static string GetGemPath() {
return ConfigurationManager.AppSettings[GemPathOptionName] ?? "";
}

private static string GetGemPath() {
return ConfigurationManager.AppSettings[GemPathOptionName] ?? "";
}
}
}
20 changes: 10 additions & 10 deletions Merlin/Main/Hosts/IronRuby.Rack/RubyEngine.cs
Expand Up @@ -41,16 +41,16 @@ public static class RubyEngine {

public static object Execute(string code, ScriptScope aScope) {
return Engine.CreateScriptSourceFromString(code).Execute(aScope);
}

public static T Execute<T>(string code)
{
return Execute<T>(code, scope);
}

public static T Execute<T>(string code, ScriptScope aScope)
{
return (T)Engine.CreateScriptSourceFromString(code).Execute(aScope);
}

public static T Execute<T>(string code)
{
return Execute<T>(code, scope);
}

public static T Execute<T>(string code, ScriptScope aScope)
{
return (T)Engine.CreateScriptSourceFromString(code).Execute(aScope);
}

public static T ExecuteMethod<T>(object instance, string methodName, params object[] args)
Expand Down
14 changes: 7 additions & 7 deletions Merlin/Main/Hosts/IronRuby.Rack/Utils.cs
Expand Up @@ -45,13 +45,13 @@ public class Utils {
foreach (var path in RubyEngine.Engine.GetSearchPaths()) {
context.Response.Write(HttpUtility.HtmlEncode(path));
context.Response.Write("\r\n");
}
context.Response.Write("</pre>\r\n");
context.Response.Write("<h4>Gem paths</h4>\r\n");
context.Response.Write("<pre>\r\n");
foreach (var gempath in RubyEngine.Execute<RubyArray>("require 'rubygems'; Gem.path")) {
context.Response.Write(HttpUtility.HtmlEncode(((MutableString)gempath).ToString()));
context.Response.Write("\r\n");
}
context.Response.Write("</pre>\r\n");
context.Response.Write("<h4>Gem paths</h4>\r\n");
context.Response.Write("<pre>\r\n");
foreach (var gempath in RubyEngine.Execute<RubyArray>("require 'rubygems'; Gem.path")) {
context.Response.Write(HttpUtility.HtmlEncode(((MutableString)gempath).ToString()));
context.Response.Write("\r\n");
}
context.Response.Write("</pre>\r\n");
context.Response.Write("</html>\r\n");
Expand Down
Expand Up @@ -32,7 +32,7 @@ public class DynamicEngine {
public ScriptScope EntryPointScope { get; private set; }

public void Start() {
InitializeRuntime(Settings.Debug);
InitializeRuntime(Settings.Debug);
Run(Settings.GetEntryPoint(), Settings.ConsoleEnabled);
}

Expand Down Expand Up @@ -68,8 +68,8 @@ public class DynamicEngine {
private void Run(string entryPoint, bool consoleEnabled) {
string code = GetEntryPointContents();
Engine = Runtime.GetEngineByFileExtension(Path.GetExtension(entryPoint));
EntryPointScope = Engine.CreateScope();

EntryPointScope = Engine.CreateScope();

if (consoleEnabled) Repl.Show();

ScriptSource sourceCode = Engine.CreateScriptSourceFromString(code, entryPoint, SourceCodeKind.File);
Expand Down
Expand Up @@ -19,7 +19,7 @@
<SignAssembly Condition="'$(SignAssembly)' == '' And Exists('$(AssemblyOriginatorKeyFile)')">true</SignAssembly>
<SignedSym Condition="'$(SignAssembly)' == 'true'">SIGNED</SignedSym>
<DelaySign>true</DelaySign>
<SilverlightPath Condition="$(SilverlightPath) == ''">..\..\..\Utilities\Silverlight\x86ret\</SilverlightPath>
<SilverlightPath Condition="'$(SilverlightPath)' == ''">..\..\..\Utilities\Silverlight\x86ret\</SilverlightPath>
<BaseAddress>885063680</BaseAddress>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand Down Expand Up @@ -80,8 +80,8 @@
<HintPath>$(SilverlightPath)\System.Core.dll</HintPath>
<Aliases>systemcore</Aliases>
</Reference>
<Reference Include="System.Data" Condition=" $(SilverlightBuild) != 'true' " />
<Reference Include="System.Xml" Condition=" $(SilverlightBuild) != 'true' " />
<Reference Include="System.Data" Condition=" '$(SilverlightBuild)' != 'true' " />
<Reference Include="System.Xml" Condition=" '$(SilverlightBuild)' != 'true' " />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\Hosts\Silverlight\SilverlightVersion.cs" Condition=" '$(SilverlightBuild)' == 'true' ">
Expand Down
16 changes: 12 additions & 4 deletions Merlin/Main/Languages/IronPython/IronPython.Modules/_weakref.cs
Expand Up @@ -251,7 +251,7 @@ public @ref(object @object)
}

[PythonType, DynamicBaseTypeAttribute, PythonHidden]
public sealed partial class weakproxy : IPythonObject, ICodeFormattable, IProxyObject, IValueEquality, IMembersList {
public sealed partial class weakproxy : IPythonObject, ICodeFormattable, IProxyObject, IValueEquality, IPythonMembersList {
private readonly WeakHandle _target;
private readonly CodeContext/*!*/ _context;

Expand Down Expand Up @@ -406,7 +406,11 @@ public sealed partial class weakproxy : IPythonObject, ICodeFormattable, IProxyO
PythonOps.DeleteAttr(context, o, SymbolTable.StringToId(name));
}

IList<object> IMembersList.GetMemberNames(CodeContext/*!*/ context) {
IList<string> IMembersList.GetMemberNames() {
return PythonOps.GetStringMemberList(this);
}

IList<object> IPythonMembersList.GetMemberNames(CodeContext/*!*/ context) {
object o;
if (!TryGetObject(out o)) {
// if we've been disconnected return an empty list
Expand Down Expand Up @@ -456,7 +460,7 @@ public sealed partial class weakcallableproxy :
ICodeFormattable,
IProxyObject,
IValueEquality,
IMembersList {
IPythonMembersList {

private WeakHandle _target;
private readonly CodeContext/*!*/ _context;
Expand Down Expand Up @@ -625,7 +629,11 @@ public sealed partial class weakcallableproxy :
PythonOps.DeleteAttr(context, o, SymbolTable.StringToId(name));
}

IList<object> IMembersList.GetMemberNames(CodeContext/*!*/ context) {
IList<string> IMembersList.GetMemberNames() {
return PythonOps.GetStringMemberList(this);
}

IList<object> IPythonMembersList.GetMemberNames(CodeContext/*!*/ context) {
object o;
if (!TryGetObject(out o)) {
// if we've been disconnected return an empty list
Expand Down
Expand Up @@ -42,7 +42,7 @@ class ArrayGlobalAllocator : GlobalAllocator {
private readonly GlobalArrayConstant _array;
internal static readonly MSAst.ParameterExpression/*!*/ _globalContext = Ast.Parameter(typeof(CodeContext), "$globalContext");

public ArrayGlobalAllocator(LanguageContext/*!*/ context) {
public ArrayGlobalAllocator(PythonContext/*!*/ context) {
_globalArray = Ast.Parameter(typeof(PythonGlobal[]), "$globalArray");
_scope = new Scope(new PythonDictionary(new GlobalDictionaryStorage(_globalVals)));
_context = new CodeContext(_scope, context);
Expand Down
Expand Up @@ -71,7 +71,7 @@ internal class AstGenerator {
private Dictionary<int, bool> _handlerLocations; // list of all exception handlers and finallys. - used for debugging/tracing support to disallow jumping into handlers. Value is true if handler is finally

private static readonly Dictionary<string, MethodInfo> _HelperMethods = new Dictionary<string, MethodInfo>(); // cache of helper methods
private static readonly MethodInfo _UpdateStackTrace = typeof(ExceptionHelpers).GetMethod("UpdateStackTrace");
private static readonly MethodInfo _UpdateStackTrace = typeof(PythonOps).GetMethod("UpdateStackTrace");
private static readonly MSAst.Expression _GetCurrentMethod = Ast.Call(typeof(MethodBase).GetMethod("GetCurrentMethod"));
internal static readonly MSAst.Expression[] EmptyExpression = new MSAst.Expression[0];
internal static readonly MSAst.BlockExpression EmptyBlock = Ast.Block(AstUtils.Empty());
Expand Down Expand Up @@ -115,16 +115,15 @@ internal AstGenerator(CompilationMode mode, CompilerContext/*!*/ context, Source
_context = context;
_pythonContext = (PythonContext)context.SourceUnit.LanguageContext;
_document = _context.SourceUnit.Document ?? Ast.SymbolDocument(name, PyContext.LanguageGuid, PyContext.VendorGuid);

LanguageContext pc = context.SourceUnit.LanguageContext;

switch (mode) {
case CompilationMode.Collectable: _globals = new ArrayGlobalAllocator(pc); break;
case CompilationMode.Collectable: _globals = new ArrayGlobalAllocator(_pythonContext); break;
case CompilationMode.Lookup: _globals = new DictionaryGlobalAllocator(); break;
case CompilationMode.ToDisk: _globals = new SavableGlobalAllocator(pc); break;
case CompilationMode.Uncollectable: _globals = new StaticGlobalAllocator(pc, name); break;
case CompilationMode.ToDisk: _globals = new SavableGlobalAllocator(_pythonContext); break;
case CompilationMode.Uncollectable: _globals = new StaticGlobalAllocator(_pythonContext, name); break;
}

PythonOptions po = (pc.Options as PythonOptions);
PythonOptions po = (_pythonContext.Options as PythonOptions);
Assert.NotNull(po);
if (po.EnableProfiler && mode != CompilationMode.ToDisk) {
_profiler = Profiler.GetProfiler(PyContext);
Expand Down Expand Up @@ -638,7 +637,7 @@ internal AstGenerator(CompilationMode mode, CompilerContext/*!*/ context, Source
LineNumberUpdated
),
Ast.Call(
typeof(ExceptionHelpers).GetMethod("UpdateStackTrace"),
_UpdateStackTrace,
LocalContext,
_GetCurrentMethod,
AstUtils.Constant(Name),
Expand Down
Expand Up @@ -68,7 +68,7 @@ class OnDiskScriptCode : ScriptCode {
PythonGlobal[] globalArray = new PythonGlobal[optimizedCode.Names.Length];
Scope scope = new Scope(new PythonDictionary(new GlobalDictionaryStorage(globals, globalArray)));

CodeContext res = new CodeContext(scope, SourceUnit.LanguageContext);
CodeContext res = new CodeContext(scope, (PythonContext)SourceUnit.LanguageContext);

for (int i = 0; i < optimizedCode.Names.Length; i++) {
SymbolId name = SymbolTable.StringToId(optimizedCode.Names[i]);
Expand Down
Expand Up @@ -20,6 +20,7 @@
using Microsoft.Scripting.Ast;
using Microsoft.Scripting.Runtime;

using IronPython.Runtime;
using IronPython.Runtime.Operations;

using MSAst = System.Linq.Expressions;
Expand All @@ -30,7 +31,7 @@ namespace IronPython.Compiler.Ast {
class SavableGlobalAllocator : ArrayGlobalAllocator {
private readonly List<MSAst.Expression/*!*/>/*!*/ _constants;

public SavableGlobalAllocator(LanguageContext/*!*/ context)
public SavableGlobalAllocator(PythonContext/*!*/ context)
: base(context) {
_constants = new List<MSAst.Expression>();
}
Expand Down
Expand Up @@ -56,7 +56,7 @@ class StaticGlobalAllocator : GlobalAllocator {
private StrongBox<Type> _finalType = new StrongBox<Type>();
#endif

public StaticGlobalAllocator(LanguageContext/*!*/ context, string name) {
public StaticGlobalAllocator(PythonContext/*!*/ context, string name) {
_typeGen = Snippets.Shared.DefineType(name, typeof(object), false, false);

_codeContextField = _typeGen.AddStaticField(typeof(CodeContext), "__global_context");
Expand Down
Expand Up @@ -510,6 +510,13 @@ public class PythonCommandLine : CommandLine {
protected override void UnhandledException(Exception e) {
PythonOps.PrintException(new CodeContext(Scope, Language), e, Console);
}

private new PythonContext Language {
get {
return (PythonContext)base.Language;
}
}

}
#endif
}
Binary file modified Merlin/Main/Languages/IronPython/IronPython/IronPython.Build.csproj
Binary file not shown.
6 changes: 4 additions & 2 deletions Merlin/Main/Languages/IronPython/IronPython/IronPython.csproj
Expand Up @@ -80,7 +80,7 @@
<NoWarn>1591</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" Condition=" $(SilverlightBuild) != 'true' " />
<Reference Include="System" Condition=" '$(SilverlightBuild)' != 'true' " />
<Reference Include="mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" Condition=" '$(SilverlightBuild)' == 'true' ">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(SilverlightPath)\mscorlib.dll</HintPath>
Expand All @@ -90,7 +90,7 @@
<HintPath>$(SilverlightPath)\System.dll</HintPath>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" Condition=" $(SilverlightBuild) != 'true' " />
<Reference Include="System.Xml" Condition=" '$(SilverlightBuild)' != 'true' " />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\Hosts\SilverLight\SilverlightVersion.cs" Condition=" '$(SilverlightBuild)' == 'true' ">
Expand All @@ -103,6 +103,7 @@
<Compile Include="Compiler\Ast\AssignmentStatement.cs" />
<Compile Include="Compiler\Ast\AstGenerator.cs" />
<Compile Include="Modules\imp.cs" />
<Compile Include="Runtime\CodeContext.cs" />
<Compile Include="Runtime\DontMapIEnumerableToIterAttribute.cs" />
<Compile Include="Runtime\Binding\ContextArgBuilder.cs" />
<Compile Include="Runtime\Binding\IFastSettable.cs" />
Expand Down Expand Up @@ -247,6 +248,7 @@
<Compile Include="Runtime\Operations\IListOfByteOps.cs" />
<Compile Include="Runtime\BytesConversionAttribute.cs" />
<Compile Include="Runtime\Python3Warning.cs" />
<Compile Include="Runtime\PythonDynamicStackFrame.cs" />
<Compile Include="Runtime\PythonFunction.Generated.cs" />
<Compile Include="Runtime\PythonOptions.cs" />
<Compile Include="Runtime\CompiledLoader.cs" />
Expand Down
Expand Up @@ -853,7 +853,7 @@ public static partial class Builtin {
doc.AppendLine();
}

IList<object> names = ((IMembersList)oldClass).GetMemberNames(context);
IList<object> names = ((IPythonMembersList)oldClass).GetMemberNames(context);
List sortNames = new List(names);
sortNames.sort(context);
names = sortNames;
Expand Down
Expand Up @@ -214,7 +214,7 @@ class PythonConversionBinder : DynamicMetaObjectBinder, IPythonSite, IExpression
);
}

return res ?? EnsureReturnType(Context.Binder.ConvertTo(Type, ResultKind, self));
return res ?? EnsureReturnType(Context.Binder.ConvertTo(Type, ResultKind, self, _context.SharedOverloadResolverFactory));
}

private DynamicMetaObject EnsureReturnType(DynamicMetaObject dynamicMetaObject) {
Expand Down
Expand Up @@ -98,7 +98,7 @@ public MetaOldClass(Expression/*!*/ expression, BindingRestrictions/*!*/ restric
}

public override System.Collections.Generic.IEnumerable<string> GetDynamicMemberNames() {
foreach (object o in ((IMembersList)Value).GetMemberNames(DefaultContext.Default)) {
foreach (object o in ((IPythonMembersList)Value).GetMemberNames(DefaultContext.Default)) {
if (o is string) {
yield return (string)o;
}
Expand Down
Expand Up @@ -153,7 +153,7 @@ public MetaOldInstance(Expression/*!*/ expression, BindingRestrictions/*!*/ rest
}

public override System.Collections.Generic.IEnumerable<string> GetDynamicMemberNames() {
foreach (object o in ((IMembersList)Value).GetMemberNames(DefaultContext.Default)) {
foreach (object o in ((IPythonMembersList)Value).GetMemberNames(DefaultContext.Default)) {
if (o is string) {
yield return (string)o;
}
Expand Down

0 comments on commit fd79351

Please sign in to comment.