Author: olivier
Date: 2007-06-03 06:24:55 -0400 (Sun, 03 Jun 2007)
New Revision: 78490
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/ChangeLog
trunk/olive/class/Microsoft.JScript.Compiler/Makefile
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.csproj
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.dll.sources
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.sln
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.suo
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/OptionsParser.cs
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/SplayTree.cs
Log:
2007-06-03 Olivier Dufour <[EMAIL PROTECTED]>
* Make it compilable on linux
* SplayTree implementation of Marek Sieradzki
TODO : unit test for Splay tree and all other class
Modified: trunk/olive/class/Microsoft.JScript.Compiler/ChangeLog
===================================================================
--- trunk/olive/class/Microsoft.JScript.Compiler/ChangeLog 2007-06-03
10:22:53 UTC (rev 78489)
+++ trunk/olive/class/Microsoft.JScript.Compiler/ChangeLog 2007-06-03
10:24:55 UTC (rev 78490)
@@ -1,3 +1,9 @@
+2007-06-03 Olivier Dufour <[EMAIL PROTECTED]>
+
+ * Make it compilable on linux
+ * SplayTree implementation of Marek Sieradzki
+ TODO : unit test for Splay tree and all other class
+
2007-06-01 Olivier Dufour <[EMAIL PROTECTED]>
* Fill a lot of Parse function
Modified: trunk/olive/class/Microsoft.JScript.Compiler/Makefile
===================================================================
--- trunk/olive/class/Microsoft.JScript.Compiler/Makefile 2007-06-03
10:22:53 UTC (rev 78489)
+++ trunk/olive/class/Microsoft.JScript.Compiler/Makefile 2007-06-03
10:24:55 UTC (rev 78490)
@@ -1,8 +1,22 @@
thisdir = class/Microsoft.JScript.Compiler
+SUBDIRS =
include ../../build/rules.make
LIBRARY = Microsoft.JScript.Compiler.dll
LIB_MCS_FLAGS = -r:Microsoft.Scripting.dll -r:System.dll
+TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
+
+EXTRA_DISTFILES = $(RESOURCE_FILES)
+
+# This is a Silverlight assembly
+VALID_PROFILE := $(filter net_3_0, $(PROFILE))
+ifndef VALID_PROFILE
+LIBRARY_NAME = dummy-Microsoft.Scripting.Silverlight.dll
+NO_INSTALL = yes
+NO_SIGN_ASSEMBLY = yes
+NO_TEST = yes
+endif
+
include ../../build/library.make
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/OptionsParser.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/OptionsParser.cs
2007-06-03 10:22:53 UTC (rev 78489)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/OptionsParser.cs
2007-06-03 10:24:55 UTC (rev 78490)
@@ -42,8 +42,7 @@
set { throw new NotImplementedException(); }
}
- public override Microsoft.Scripting.EngineOptions EngineOptions
- {
+ public override Microsoft.Scripting.EngineOptions EngineOptions
{
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/SplayTree.cs
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/SplayTree.cs
2007-06-03 10:22:53 UTC (rev 78489)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler/SplayTree.cs
2007-06-03 10:24:55 UTC (rev 78490)
@@ -2,43 +2,168 @@
using System.Collections.Generic;
using System.Text;
-namespace Mono.JScript.Compiler
-{
- public class SplayTree
- {
- public SplayTree()
+namespace Mono.JScript.Compiler {
+ public class SplayTree {
+
+ private SplayTree left;
+ private SplayTree right;
+ private SplayTree parent;
+
+ public SplayTree ()
{
- throw new NotImplementedException();
}
- public void AddAsLeftChild(SplayTree Child)
+ public void AddAsLeftChild (SplayTree Child)
{
- this.left = Child;
+ this.Left = Child;
+ Child.Parent = this;
}
- public void AddAsRightChild(SplayTree Child)
+ public void AddAsRightChild (SplayTree Child)
{
- this.right = Child;
+ this.Right = Child;
+ Child.Parent = this;
}
- public void SplayToRoot()
+ public void SplayToRoot ()
{
- throw new NotImplementedException();
+ SplayTree x = this;
+
+ while (x.Parent != null) {
+ if (x.HasGrandParent) {
+ if (SameDirection (x))
+ x = ZigZig (x);
+ else
+ x = ZigZag (x);
+ } else if (x.HasParent) {
+ x = Zig (x);
+ }
+ }
}
- public static void Validate()
+ public static void Validate ()
{
- throw new NotImplementedException();
+ throw new NotImplementedException ();
}
- private SplayTree left;
- private SplayTree right;
+ // assumption: x.Parent != null
+ SplayTree Zig (SplayTree x)
+ {
+ if (x.Parent.Left == x)
+ return RightRotate (x.Parent);
+ else
+ return LeftRotate (x.Parent);
+ }
+ // assumption: x != null && x.Parent != null && x.GrandParent
!= null
+ SplayTree ZigZig (SplayTree x)
+ {
+ if (x.Parent.Left == x) {
+ RightRotate (x.GrandParent);
+ x = RightRotate (x.Parent);
+ } else {
+ LeftRotate (x.GrandParent);
+ x = LeftRotate (x.Parent);
+ }
+ return x;
+ }
+
+ // assumption: x != null && x.Parent != null && x.GrandParent
!= null
+ SplayTree ZigZag (SplayTree x)
+ {
+ if (x.Parent.Left == x) {
+ x = RightRotate (x.Parent);
+ x = LeftRotate (x.Parent);
+ } else {
+ x = LeftRotate (x.Parent);
+ x = RightRotate (x.Parent);
+ }
+ return x;
+ }
+
+ // assumption: x != null && x.Parent != null && x.GrandParent
!= null
+ bool SameDirection (SplayTree x)
+ {
+ if (x.Parent.Left == x)
+ return (x.GrandParent.Left == x.Parent);
+ else
+ return (x.GrandParent.Right == x.Parent);
+ }
+
+ // assumption: x != null && x.Right != null
+ // return value: node that is where rotated node (x) was
+ SplayTree LeftRotate (SplayTree x)
+ {
+ SplayTree y = x.Right;
+
+ x.Right = y.Left;
+ if (y.Left != null)
+ y.Left.Parent = x;
+ y.Parent = x.Parent;
+
+ if (x.HasParent) {
+ if (x == x.Parent.Left)
+ x.Parent.Left = y;
+ else
+ x.Parent.Right = y;
+ }
+
+ y.Left = x;
+ x.Parent = y;
+
+ return y;
+ }
+
+ // assumption: y != null && y.Left != null
+ // return value: node that is where rotated node (y) was
+ SplayTree RightRotate (SplayTree y)
+ {
+ SplayTree x = y.Left;
+
+ y.Left = x.Right;
+ if (x.Right != null)
+ x.Right.Parent = y;
+ x.Parent = y.Parent;
+
+ if (y.HasParent) {
+ if (y == y.Parent.Left)
+ y.Parent.Left = x;
+ else
+ y.Parent.Right = x;
+ }
+
+ x.Right = y;
+ y.Parent = x;
+
+ return x;
+ }
+
public SplayTree Left {
get { return left; }
+ private set { left = value; }
}
+
public SplayTree Right {
get { return right; }
+ private set { right = value; }
}
+
+ SplayTree Parent {
+ get { return parent; }
+ set { parent = value; }
+ }
+
+ SplayTree GrandParent {
+ get { return Parent.Parent; }
+ }
+
+ bool HasParent {
+ get { return parent != null; }
+ }
+
+ bool HasGrandParent {
+ get { return parent != null && parent.parent != null; }
+ }
+
}
}
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.csproj
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.csproj
2007-06-03 10:22:53 UTC (rev 78489)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.csproj
2007-06-03 10:24:55 UTC (rev 78490)
@@ -125,10 +125,12 @@
<Compile Include="Microsoft.JScript.Compiler\Token.cs" />
</ItemGroup>
<ItemGroup>
- <Reference Include="Microsoft.Scripting, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>C:\Program Files\Microsoft
Silverlight\Microsoft.Scripting.dll</HintPath>
- </Reference>
<Reference Include="System" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference
Include="..\Microsoft.Scripting\Microsoft.Scripting.csproj">
+ <Project>{162ED7C8-3FA6-49CE-A7EF-C1A11FFFCCE5}</Project>
+ <Name>Microsoft.Scripting</Name>
+ </ProjectReference>
+ </ItemGroup>
</Project>
\ No newline at end of file
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.dll.sources
===================================================================
---
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.dll.sources
2007-06-03 10:22:53 UTC (rev 78489)
+++
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.dll.sources
2007-06-03 10:24:55 UTC (rev 78490)
@@ -1,3 +1,7 @@
+../../build/common/Consts.cs
+../../build/common/Locale.cs
+../../build/common/MonoTODOAttribute.cs
+Assembly/AssemblyInfo.cs
Microsoft.JScript.Compiler/BadToken.cs
Microsoft.JScript.Compiler/Comment.cs
Microsoft.JScript.Compiler/Compiler.cs
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.sln
===================================================================
--- trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.sln
2007-06-03 10:22:53 UTC (rev 78489)
+++ trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.sln
2007-06-03 10:24:55 UTC (rev 78490)
@@ -5,6 +5,8 @@
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") =
"Microsoft.JScript.Compiler", "Microsoft.JScript.Compiler.csproj",
"{03952B85-C1DB-4253-B822-AF37BD6B1C66}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Scripting",
"..\Microsoft.Scripting\Microsoft.Scripting.csproj",
"{162ED7C8-3FA6-49CE-A7EF-C1A11FFFCCE5}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -19,6 +21,10 @@
{03952B85-C1DB-4253-B822-AF37BD6B1C66}.Debug|Any CPU.Build.0 =
Debug|Any CPU
{03952B85-C1DB-4253-B822-AF37BD6B1C66}.Release|Any
CPU.ActiveCfg = Release|Any CPU
{03952B85-C1DB-4253-B822-AF37BD6B1C66}.Release|Any CPU.Build.0
= Release|Any CPU
+ {162ED7C8-3FA6-49CE-A7EF-C1A11FFFCCE5}.Debug|Any CPU.ActiveCfg
= Debug|Any CPU
+ {162ED7C8-3FA6-49CE-A7EF-C1A11FFFCCE5}.Debug|Any CPU.Build.0 =
Debug|Any CPU
+ {162ED7C8-3FA6-49CE-A7EF-C1A11FFFCCE5}.Release|Any
CPU.ActiveCfg = Release|Any CPU
+ {162ED7C8-3FA6-49CE-A7EF-C1A11FFFCCE5}.Release|Any CPU.Build.0
= Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Modified:
trunk/olive/class/Microsoft.JScript.Compiler/Microsoft.JScript.Compiler.suo
===================================================================
(Binary files differ)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches