Skip to content

Commit

Permalink
Moved various enums and constants into the runtime library.
Browse files Browse the repository at this point in the history
  • Loading branch information
otac0n committed Jul 5, 2011
1 parent 4f5a65b commit 66e4415
Show file tree
Hide file tree
Showing 16 changed files with 131 additions and 64 deletions.
8 changes: 8 additions & 0 deletions Src/IronJS.Runtime/ArgumentsLinkArray.cs
@@ -0,0 +1,8 @@
namespace IronJS.Runtime
{
public enum ArgumentsLinkArray : byte
{
Locals = 0,
ClosedOver = 1
}
}
19 changes: 19 additions & 0 deletions Src/IronJS.Runtime/BoxFields.cs
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IronJS.Runtime
{
public static class BoxFields
{
public const string Bool = "Bool";
public const string Number = "Number";
public const string Clr = "Clr";
public const string Undefined = "Clr";
public const string String = "String";
public const string SuffixString = "SuffixString";
public const string Object = "Object";
public const string Function = "Func";
}
}
9 changes: 9 additions & 0 deletions Src/IronJS.Runtime/DefaultValueHint.cs
@@ -0,0 +1,9 @@
namespace IronJS.Runtime
{
public enum DefaultValueHint
{
None = 0,
String = 1,
Number = 2
}
}
9 changes: 9 additions & 0 deletions Src/IronJS.Runtime/FunctionType.cs
@@ -0,0 +1,9 @@
namespace IronJS.Runtime
{
public enum FunctionType
{
UserDefined,
NativeConstructor,
NativeFunction
}
}
8 changes: 8 additions & 0 deletions Src/IronJS.Runtime/IronJS.Runtime.CLR2.csproj
Expand Up @@ -41,12 +41,20 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ArgumentsLinkArray.cs" />
<Compile Include="BoxFields.cs" />
<Compile Include="DefaultValueHint.cs" />
<Compile Include="DescriptorAttrs.cs" />
<Compile Include="Errors.cs" />
<Compile Include="FunctionType.cs" />
<Compile Include="Legacy.cs" />
<Compile Include="MarshalModes.cs" />
<Compile Include="ParameterStorageType.cs" />
<Compile Include="ParamsMode.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SplayTree.cs" />
<Compile Include="SuffixString.cs" />
<Compile Include="TypeTags.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
8 changes: 8 additions & 0 deletions Src/IronJS.Runtime/IronJS.Runtime.csproj
Expand Up @@ -41,12 +41,20 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ArgumentsLinkArray.cs" />
<Compile Include="BoxFields.cs" />
<Compile Include="DefaultValueHint.cs" />
<Compile Include="DescriptorAttrs.cs" />
<Compile Include="Errors.cs" />
<Compile Include="FunctionType.cs" />
<Compile Include="Legacy.cs" />
<Compile Include="MarshalModes.cs" />
<Compile Include="ParameterStorageType.cs" />
<Compile Include="ParamsMode.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SplayTree.cs" />
<Compile Include="SuffixString.cs" />
<Compile Include="TypeTags.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
9 changes: 9 additions & 0 deletions Src/IronJS.Runtime/MarshalModes.cs
@@ -0,0 +1,9 @@
namespace IronJS.Runtime
{
public enum MarshalModes
{
Default = 2,
This = 1,
Function = 0
}
}
8 changes: 8 additions & 0 deletions Src/IronJS.Runtime/ParameterStorageType.cs
@@ -0,0 +1,8 @@
namespace IronJS.Runtime
{
public enum ParameterStorageType
{
Private,
Shared
}
}
9 changes: 9 additions & 0 deletions Src/IronJS.Runtime/ParamsMode.cs
@@ -0,0 +1,9 @@
namespace IronJS.Runtime
{
public enum ParamsModes : byte
{
NoParams = 0,
ObjectParams = 1,
BoxParams = 2
}
}
38 changes: 38 additions & 0 deletions Src/IronJS.Runtime/TypeTags.cs
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IronJS.Runtime
{
public static class TypeTags
{
public const uint Box = 0x00000000u;
public const uint Bool = 0xFFFFFF01u;
public const uint Number = 0xFFFFFF02u;
public const uint Clr = 0xFFFFFF03u;
public const uint String = 0xFFFFFF04u;
public const uint SuffixString = 0xFFFFFF05u;
public const uint Undefined = 0xFFFFFF06u;
public const uint Object = 0xFFFFFF07u;
public const uint Function = 0xFFFFFF08u;

private static readonly Dictionary<uint, string> names = new Dictionary<uint, string>
{
{ Box, "internal" },
{ Bool, "boolean" },
{ Number, "number" },
{ Clr, "clr" },
{ String, "string" },
{ SuffixString, "string" },
{ Undefined, "undefined" },
{ Object, "object" },
{ Function, "function" }
};

public static string GetName(uint tag)
{
return names[tag];
}
}
}
1 change: 1 addition & 0 deletions Src/IronJS/Compiler.Function.fs
Expand Up @@ -3,6 +3,7 @@
open System

open IronJS
open IronJS.Runtime
open IronJS.Compiler
open IronJS.Dlr.Operators
open IronJS.Support.CustomOperators
Expand Down
1 change: 1 addition & 0 deletions Src/IronJS/Compiler.Object.fs
Expand Up @@ -5,6 +5,7 @@ open IronJS
open IronJS.Dlr
open IronJS.Dlr.Operators
open IronJS.Dlr.ExtensionMethods
open IronJS.Runtime
open IronJS.Support.CustomOperators
open IronJS.Compiler
open IronJS.Compiler.Utils
Expand Down
1 change: 1 addition & 0 deletions Src/IronJS/Compiler.Operators.fs
Expand Up @@ -3,6 +3,7 @@
open IronJS
open IronJS.Compiler
open IronJS.Dlr.Operators
open IronJS.Runtime
open IronJS.Support.CustomOperators
open IronJS.Support.Aliases

Expand Down
1 change: 1 addition & 0 deletions Src/IronJS/Compiler.Utils.fs
Expand Up @@ -3,6 +3,7 @@
open System

open IronJS
open IronJS.Runtime
open IronJS.Dlr.Operators

///
Expand Down
3 changes: 2 additions & 1 deletion Src/IronJS/Operators.fs
Expand Up @@ -2,6 +2,7 @@

open System
open IronJS
open IronJS.Runtime
open IronJS.Support.Aliases

(*
Expand Down Expand Up @@ -51,7 +52,7 @@ type Operators =
static member typeOf (o:BV) =
if o.IsNumber then "number"
elif o.IsNull then "object"
else TypeTags.Names.[o.Tag]
else TypeTags.GetName(o.Tag)

static member typeOf expr = Dlr.callStaticT<Operators> "typeOf" [expr]

Expand Down
63 changes: 0 additions & 63 deletions Src/IronJS/Runtime.fs
Expand Up @@ -17,73 +17,10 @@ open System.Runtime.InteropServices
open System.Globalization
open System.Text.RegularExpressions

module TypeTags =
let [<Literal>] Box = 0x00000000u
let [<Literal>] Bool = 0xFFFFFF01u
let [<Literal>] Number = 0xFFFFFF02u
let [<Literal>] Clr = 0xFFFFFF03u
let [<Literal>] String = 0xFFFFFF04u
let [<Literal>] SuffixString = 0xFFFFFF05u
let [<Literal>] Undefined = 0xFFFFFF06u
let [<Literal>] Object = 0xFFFFFF07u
let [<Literal>] Function = 0xFFFFFF08u

let Names =
Map.ofList [
(Box, "internal")
(Bool, "boolean")
(Number, "number")
(Clr, "clr")
(String, "string")
(SuffixString, "string")
(Undefined, "undefined")
(Object, "object")
(Function, "function")]

let getName (tag:uint32) = Names.[tag]

module BoxFields =
let [<Literal>] Bool = "Bool"
let [<Literal>] Number = "Number"
let [<Literal>] Clr = "Clr"
let [<Literal>] Undefined = "Clr"
let [<Literal>] String = "String"
let [<Literal>] SuffixString = "SuffixString"
let [<Literal>] Object = "Object"
let [<Literal>] Function = "Func"

module ParamsModes =
let [<Literal>] NoParams = 0uy
let [<Literal>] ObjectParams = 1uy
let [<Literal>] BoxParams = 2uy

type DefaultValueHint
= None = 0
| String = 1
| Number = 2

module MarshalModes =
let [<Literal>] Default = 2
let [<Literal>] This = 1
let [<Literal>] Function = 0

module Array =
let [<Literal>] DenseMaxIndex = 2147483646u
let [<Literal>] DenseMaxSize = 2147483647u

module ArgumentsLinkArray =
let [<Literal>] Locals = 0uy
let [<Literal>] ClosedOver = 1uy

type ParameterStorageType
= Private
| Shared

type FunctionType
= UserDefined
| NativeConstructor
| NativeFunction

module Markers =
let [<Literal>] Number = 0xFFF8us
let [<Literal>] Tagged = 0xFFF9us
Expand Down

0 comments on commit 66e4415

Please sign in to comment.