4 // Author: Cesar Octavio Lopez Nataren
6 // (C) Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System
.Reflection
;
33 using System
.Collections
;
35 namespace Microsoft
.JScript
.Vsa
{
37 public class VsaEngine
: BaseVsaEngine
, IRedirectOutput
{
39 static private Hashtable options
;
40 internal VsaScriptScope global_scope
;
41 internal Stack globals
;
49 public VsaEngine (bool b
)
50 : base ("JScript", "0.0.1", true)
52 globals
= new Stack (4);
55 public virtual IVsaEngine
Clone (AppDomain appDom
)
57 throw new NotImplementedException ();
60 public virtual bool CompileEmpty ()
62 throw new NotImplementedException ();
65 public virtual void ConectEvents ()
67 throw new NotImplementedException ();
70 public static GlobalScope
CreateEngineAndGetGlobalScope (bool fast
, string [] assembly_names
)
75 VsaEngine engine
= new VsaEngine (fast
);
76 engine
.InitVsaEngine ("JScript.Vsa.VsaEngine://Microsoft.JScript.VsaEngine.Vsa",
77 new DefaultVsaSite ());
78 n
= assembly_names
.Length
;
80 for (i
= 0; i
< n
; i
++) {
81 string assembly_name
= assembly_names
[i
];
82 VsaReferenceItem r
= (VsaReferenceItem
) engine
.Items
.CreateItem (assembly_name
,
83 VsaItemType
.Reference
,
85 r
.AssemblyName
= assembly_name
;
87 scope
= (GlobalScope
) engine
.GetGlobalScope ().GetObject ();
91 public static GlobalScope
CreateEngineAndGetGlobalScopeWithType (bool b
, string [] assemblyNames
,
92 RuntimeTypeHandle callTypeHandle
)
94 throw new NotImplementedException ();
97 public static VsaEngine
CreateEngine ()
99 throw new NotImplementedException ();
102 public static VsaEngine
CreateEngineWithType (RuntimeTypeHandle callTypeHandle
)
104 throw new NotImplementedException ();
107 public virtual void DisconnectEvents ()
109 throw new NotImplementedException ();
112 public virtual Assembly
GetAssembly ()
114 throw new NotImplementedException ();
117 public virtual IVsaScriptScope
GetGlobalScope ()
119 if (global_scope
== null) {
120 global_scope
= new VsaScriptScope (this, "Global", null);
126 public virtual GlobalScope
GetMainScope ()
128 throw new NotImplementedException ();
131 public virtual Module
GetModule ()
133 throw new NotImplementedException ();
136 public ArrayConstructor
GetOriginalArrayConstructor ()
138 throw new NotImplementedException ();
141 public ObjectConstructor
GetOriginalObjectConstructor ()
143 throw new NotImplementedException ();
146 public RegExpConstructor
GetOriginalRegExpConstructor ()
148 throw new NotImplementedException ();
151 public void InitVsaEngine (string moniker
, IVsaSite site
)
153 RootMoniker
= moniker
;
155 InitNewCalled
= true;
156 RootNamespace
= "JScript.DefaultNamespace";
161 public virtual void Interrupt ()
163 throw new NotImplementedException ();
167 public override bool IsValidIdentifier (string ident
)
169 throw new NotImplementedException ();
173 public LenientGlobalObject LenientGlobalObject
{
174 get { throw new NotImplementedException (); }
177 public ScriptObject
PopScriptObject ()
179 ScriptObject script_obj
= null;
182 script_obj
= (ScriptObject
) globals
.Pop ();
183 } catch (NullReferenceException e
) {
188 public void PushScriptObject (ScriptObject obj
)
192 } catch (NullReferenceException e
) {
196 public virtual void RegisterEventSource (string name
)
198 throw new NotImplementedException ();
201 public override void Reset ()
203 throw new NotImplementedException ();
206 public virtual void Restart ()
208 throw new NotImplementedException ();
211 public virtual void RunEmpty ()
213 throw new NotImplementedException ();
216 public virtual void Run (AppDomain appDom
)
218 throw new NotImplementedException ();
221 public ScriptObject
ScriptObjectStackTop ()
223 throw new NotImplementedException ();
226 public virtual void SetOutputStream (IMessageReceiver output
)
228 throw new NotImplementedException ();
231 internal static void InitOptions ()
233 options
= new Hashtable ();
235 options
.Add ("AlwaysGenerateIL", false);
236 options
.Add ("CLSCompliant", false);
237 options
.Add ("DebugDirectory", "");
238 options
.Add ("Defines", new Hashtable ());
239 options
.Add ("Fast", true);
240 // FIXME: "ManagedResources"
241 options
.Add ("Print", true);
242 options
.Add ("UseContextRelativeStatics", false);
243 options
.Add ("VersionSafe", false);
244 options
.Add ("WarnAsError", false);
245 options
.Add ("WarningLevel", 1);
246 options
.Add ("Win32Resource", "");
249 protected override object GetSpecificOption (string name
)
254 opt
= options
[name
];
255 } catch (NotSupportedException e
) {
256 throw new VsaException (VsaError
.OptionNotSupported
);
261 protected override void SetSpecificOption (string name
, object val
)
264 options
[name
] = val
;
265 } catch (NotSupportedException e
) {
266 throw new VsaException (VsaError
.OptionNotSupported
);
271 class DefaultVsaSite
: BaseVsaSite
{