svn path=/old-code/; revision=152777
This commit is contained in:
Miguel de Icaza 2010-03-02 02:39:41 +00:00
Родитель 67e6f28e31
Коммит e8e419460e
1437 изменённых файлов: 324321 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,57 @@
//
// AssemblyInfo.cs
//
// Author:
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2003 Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
using System.Resources;
[assembly: AssemblyVersion (Consts.VsVersion)]
#if (NET_2_0)
// [assembly: CLSCompliant (true)]
#else
[assembly: SatelliteContractVersion (Consts.VsVersion)]
#endif
#if (ONLY_1_1)
[assembly: TypeLibVersion(7, 1)]
#endif
[assembly: AssemblyTitle ("Microsoft.JScript")]
[assembly: AssemblyDescription("Microsoft.JScript.dll")]
[assembly: AssemblyCompany("MONO development team")]
[assembly: AssemblyCopyright("(c) 2003 Various Authors")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AllowPartiallyTrustedCallers()]
[assembly: AssemblyDelaySign(true)]
[assembly: AssemblyKeyFile("../msfinal.pub")]

Просмотреть файл

@ -0,0 +1,10 @@
2005-05-18 Marek Safar <marek.safar@seznam.cz>
* AssemblyInfo.cs: Fixed attributes.
2004-04-28 Sebastien Pouliot <sebastien@ximian.com>
* AssemblyInfo.cs: Added
* ChangeLog: Added
* Locale.cs: Added
* TODOAttribute.cs: Added

152
Microsoft.JScript/ChangeLog Normal file
Просмотреть файл

@ -0,0 +1,152 @@
2006-07-26 César Octavio López Natarén <cesar.nataren@gmail.com>
* Microsoft.JScript.dll.sources: Added JScriptCodeCompiler.cs from
Akiramei (mei@work.email.ne.jp) to the build.
2006-01-08 Cesar Lopez Nataren <cnataren@novell.com>
* Makefile: No longer reference the C# compiler for namespace
lookup.
2005-10-21 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* SemanticAnalizer.cs, Import.cs: Update calls to the
latest changes in namespace.cs. Keep the old calls for
2.0 profile, and update them as soon as these changes are
merged to gmcs.
2005-09-15 Raja R Harinath <rharinath@novell.com>
* Makefile (COMPILER): New. Points to mcs.exe or gmcs.exe
depending on the profile.
(LIB_MCS_FLAGS): Pick the profile dependent compiler.
2005-09-14 Ritvik Mayank <mritvik@novell.com>
* Makefile : Added mcs.exe path
2005-08-08 Florian Gross <flgr@ccan.de>
* Imported Test/Mozilla
2005-05-18 Marek Safar <marek.safar@seznam.cz>
* Microsoft.JScript.dll.sources: Added JScriptCodeGenerator.cs
2005-05-07 Cesar Lopez Nataren <cnataren@novell.com>
* COMFieldInfo.cs, COMMethodInfo.cs, JSMethod.cs: added to the
build.
2005-05-06 Cesar Lopez Nataren <cnataren@novell.com>
* Add ArgumentsObject.cs to the build is used on code generated
when the implicit arguments object is used inside a method.
2005-05-03 Cesar Lopez Nataren <cnataren@novell.com>
* Microsoft.JScript.dll.sources: IWrappedMember.cs,
IVsaScriptCodeItem.cs, IDebugType.cs, IDefineEvent.cs,
IEngine2.cs, IMethodsCompletionInfo.cs, INeedEngine.cs,
IObjectCompletionInfo.cs, ISite2.cs, MemberInfoInitializer.cs, VSAITEMTYPE2.cs
added to the build.
2005-05-02 Cesar Lopez Nataren <cnataren@novell.com>
* Microsoft.JScript.dll.sources: COMMemberInfo.cs,
IAuthorServices.cs, IColorizeText.cs, IDebugConvert.cs,
IDebuggerObject.cs, IDebugScriptScope.cs, IErrorHandler.cs,
IParseText.cs, ITokenColorInfo.cs, ITokenEnumerator.cs,
IVsaFullErrorInfo.cs, SourceState.cs, TokenColor.cs added to the
build. These are missing interfaces for COM interop.
2005-02-05 Cesar Lopez Nataren <cnataren@novell.com>
* Microsoft.JScript.dll.sources: Nuke SymbolTable.cs
2004-12-10 Cesar Lopez Nataren <cesar@ciencias.unam.mx>
* Microsoft.JScript.dll.sources: add JSPropertyInfo.cs
2004-10-11 Cesar Lopez Nataren <cesar@ciencias.unam.mx>
* Microsoft.JScript.dll.sources: add TypeMananger.cs
2004-09-20 Cesar Lopez Nataren <cesar@ciencias.unam.mx>
* Antlr.Runtime/[antlr, antlr.collections, antlr.collections.impl,
antlr.debug, antlr.debug.misc]: Good bye antlr.
* Microsoft.JScript.dll.sources: dropped antlr dependency.
2004-08-22 Cesar Lopez Nataren <cesar@ciencias.unam.mx>
* Microsoft.JScript.dll.sources: added In.cs, Token.cs,
TokenStream.cs and Parser.cs to the build. Don't build
JScriptLexer.cs and JScriptParser.cs
2004-04-28 Sebastien Pouliot <sebastien@ximian.com>
* Microsoft.JScript.dll.sources: Added Assembly/AssemblyInfo.cs and
Locale.cs to the build.
2004-01-16 Cesar Lopez Nataren <cesar@ciencias.unam.mx>
* Microsoft.JScript.dll.sources: added VsaScriptScope to the build.
2003-11-10 <cesar@ciencias.unam.mx>
* Microsoft.JScript.dll.sources: don't build Visitor.cs.
2003-11-03 <cesar@ciencias.unam.mx>
* Microsoft.JScript.dll.sources: Added IdentificationTable.cs,
SemanticAnalizer.cs and SymbolTable.cs to the build.
2003-09-29 <cesar@ciencias.unam.mx>
* Makefile: Set TEST_MCS_FLAGS.
* Microsoft.JScript_test.dll.sources: deleted the building of my
local test BaseVsaEngineTest.
* Added Microsoft.JScript_test.dll.sources
* Makefile: allow test build.
* Microsoft.JScript.dll.sources: Added VsaItem.cs, VsaItems.cs,
VsaGlobalItem.cs, VsaReferenceItem.cs , VsaCodeItem.cs to the build.
2003-09-24 <cesar@ciencias.unam.mx>
* Microsoft.JScript/: Deleted VsaEngine.cs and BaseVsaEngine.cs
* Microsoft.JScript.dll.sources: Changed the namespaces for VsaEngine and BaseVsaEngine.
2003-07-22 Cesar Lopez Nataren <cesar@ciencias.unam.mx>
* Added the new files to the build.
2003-06-09 Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
* Added FormalParameterList, Statement, VariableDeclaration,
VariableStatement and Visitor files to the unix.args.
2003-04-21 Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
* Added Antlr.Runtime, it contains the files needed for compiling
the files generated by antlr.
* Added Antlr.Runtime/antlr, Antlr.Runtime/antlr.collections,
Antlr.Runtime/antlr.collections.impl, Antlr.Runtime/antlr.debug,
Antlr.Runtime/antlr.debug.misc.
* makefile.gnu: Added some more references to the compilation.
* unix.args: Erased some newlines and tabs that were confusing
mcs.
* ScriptObject.cs: Commented "public Object this [params ...]" temp.
2003-04-20 Cesar Octavio Lopez Nataren <cesar@ciencias.unam.mx>
* ChangeLog: Added this file.
* Added makefile.gnu and unix.args.

Просмотреть файл

@ -0,0 +1,10 @@
thisdir = class/Microsoft.JScript
SUBDIRS =
include ../../build/rules.make
LIBRARY = Microsoft.JScript.dll
LIB_MCS_FLAGS = -r:System.dll -r:Microsoft.Vsa.dll -debug+
TEST_MCS_FLAGS = $(LIB_MCS_FLAGS) -nowarn:0618 -nowarn:219 -nowarn:169
include ../../build/library.make

Просмотреть файл

@ -0,0 +1,41 @@
2006-01-11 Evan Briones <evan@evanbriones.com>
* VsaEngine.cs: Fixed out compiler flag
2005-10-11 Cesar Lopez Nataren <cnataren@novell.com>
* VsaEngine.cs: Parse all the files.
2005-09-13 Cesar Lopez Nataren <cnataren@novell.com>
* VsaEngine.cs: Override method Compile and SetOption from BaseVsaEngine,
2005-08-31 Cesar Lopez Nataren <cnataren@novell.com>
* VsaEngine.cs: Added method GetParser, eval needs it.
2005-07-09 Cesar Lopez Nataren <cnataren@novell.com>
* VsaEngine.cs: Return proper constructors.
2005-07-05 Cesar Lopez Nataren <cnataren@novell.com>
* VsaEngine.cs: Implemented GetOriginalRegExpConstructor.
2005-03-29 Cesar Lopez Nataren <cnataren@novell.com>
* VsaEngine.cs: Return top of the stack casted to a ScriptObject.
2004-01-16 Cesar Lopez Nataren <cesar@ciencias.unam.mx>
* VsaEngine.cs: added an Stack, a VsaScriptScope, do not throw exceptions for:
CreateEngineAndgetGlobalScope, GetGlobalScope, InitVsaEngine,
PopScriptObject, PushScriptObject, the reason is for being able to
run the tests at jtests. Be aware that this must get implemented yet.
2003-09-29 <cesar@ciencias.unam.mx>
* VsaEngine.cs: uncommented inheritance from BaseVsaEngine (thanks
goes to jackson). Added constructor, added InitOptions,
GetSpecificOption, SetSpecificOption.

Просмотреть файл

@ -0,0 +1,312 @@
//
// VsaEngine.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
// Copyright (C) 2005 Novell, Inc (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using Microsoft.Vsa;
using System.Collections;
namespace Microsoft.JScript.Vsa {
public class VsaEngine : BaseVsaEngine, IRedirectOutput {
static private Hashtable options;
internal VsaScriptScope global_scope;
internal Stack globals;
public VsaEngine ()
: this (true)
{
InitOptions ();
}
public VsaEngine (bool b)
: base ("JScript", "0.0.1", true)
{
globals = new Stack (4);
}
public virtual IVsaEngine Clone (AppDomain appDom)
{
throw new NotImplementedException ();
}
public virtual bool CompileEmpty ()
{
throw new NotImplementedException ();
}
public override bool Compile ()
{
ArrayList code_items = new ArrayList ();
foreach (IVsaItem item in Items) {
if (item is IVsaCodeItem)
code_items.Add (item);
else if (item is IVsaReferenceItem)
continue;
else
throw new Exception ("FIXME: VsaItemType.AppGlobal");
}
Parser parser = new Parser (code_items);
ScriptBlock [] blocks = parser.ParseAll ();
if (blocks != null) {
SemanticAnalyser.Run (blocks, (Assembly []) GetOption ("assemblies"));
object outfile = GetOption ("out");
if (outfile == null)
CodeGenerator.Run ((string) GetOption ("first_source"), blocks);
else
CodeGenerator.Run ((string) outfile, blocks);
Console.WriteLine ("Compilation succeeded");
}
return false;
}
public virtual void ConectEvents ()
{
throw new NotImplementedException ();
}
public static GlobalScope CreateEngineAndGetGlobalScope (bool fast, string [] assembly_names)
{
int i, n;
GlobalScope scope;
VsaEngine engine = new VsaEngine (fast);
engine.InitVsaEngine ("JScript.Vsa.VsaEngine://Microsoft.JScript.VsaEngine.Vsa",
new DefaultVsaSite ());
n = assembly_names.Length;
for (i = 0; i < n; i++) {
string assembly_name = assembly_names [i];
VsaReferenceItem r = (VsaReferenceItem) engine.Items.CreateItem (assembly_name,
VsaItemType.Reference,
VsaItemFlag.None);
r.AssemblyName = assembly_name;
}
scope = (GlobalScope) engine.GetGlobalScope ().GetObject ();
return scope;
}
public static GlobalScope CreateEngineAndGetGlobalScopeWithType (bool b, string [] assemblyNames,
RuntimeTypeHandle callTypeHandle)
{
throw new NotImplementedException ();
}
public static VsaEngine CreateEngine ()
{
throw new NotImplementedException ();
}
public static VsaEngine CreateEngineWithType (RuntimeTypeHandle callTypeHandle)
{
throw new NotImplementedException ();
}
public virtual void DisconnectEvents ()
{
throw new NotImplementedException ();
}
public virtual Assembly GetAssembly ()
{
throw new NotImplementedException ();
}
public virtual IVsaScriptScope GetGlobalScope ()
{
if (global_scope == null) {
global_scope = new VsaScriptScope (this, "Global", null);
}
return global_scope;
}
public virtual GlobalScope GetMainScope ()
{
throw new NotImplementedException ();
}
public virtual Module GetModule ()
{
throw new NotImplementedException ();
}
public ArrayConstructor GetOriginalArrayConstructor ()
{
return ArrayConstructor.Ctr;
}
public ObjectConstructor GetOriginalObjectConstructor ()
{
return ObjectConstructor.Ctr;
}
public RegExpConstructor GetOriginalRegExpConstructor ()
{
return RegExpConstructor.Ctr;
}
public void InitVsaEngine (string moniker, IVsaSite site)
{
RootMoniker = moniker;
Site = site;
InitNewCalled = true;
RootNamespace = "JScript.DefaultNamespace";
IsDirty = true;
compiled = false;
}
public virtual void Interrupt ()
{
throw new NotImplementedException ();
}
public override bool IsValidIdentifier (string ident)
{
throw new NotImplementedException ();
}
public LenientGlobalObject LenientGlobalObject {
get { throw new NotImplementedException (); }
}
public ScriptObject PopScriptObject ()
{
ScriptObject script_obj = null;
try {
script_obj = (ScriptObject) globals.Pop ();
} catch (NullReferenceException) {
}
return script_obj;
}
public void PushScriptObject (ScriptObject obj)
{
try {
globals.Push (obj);
} catch (NullReferenceException) {
}
}
public virtual void RegisterEventSource (string name)
{
throw new NotImplementedException ();
}
public override void Reset ()
{
throw new NotImplementedException ();
}
public virtual void Restart ()
{
throw new NotImplementedException ();
}
public virtual void RunEmpty ()
{
throw new NotImplementedException ();
}
public virtual void Run (AppDomain appDom)
{
throw new NotImplementedException ();
}
public ScriptObject ScriptObjectStackTop ()
{
return (ScriptObject) globals.Peek ();
}
public virtual void SetOutputStream (IMessageReceiver output)
{
throw new NotImplementedException ();
}
internal static void InitOptions ()
{
options = new Hashtable ();
options.Add ("AlwaysGenerateIL", false);
options.Add ("CLSCompliant", false);
options.Add ("DebugDirectory", "");
options.Add ("Defines", new Hashtable ());
options.Add ("Fast", true);
// FIXME: "ManagedResources"
options.Add ("Print", true);
options.Add ("UseContextRelativeStatics", false);
options.Add ("VersionSafe", false);
options.Add ("WarnAsError", false);
options.Add ("WarningLevel", 1);
options.Add ("Win32Resource", "");
}
protected override object GetSpecificOption (string name)
{
object opt;
try {
opt = options [name];
} catch (NotSupportedException) {
throw new VsaException (VsaError.OptionNotSupported);
}
return opt;
}
public override void SetOption (string name, object value)
{
SetSpecificOption (name, value);
}
protected override void SetSpecificOption (string name, object val)
{
try {
options [name] = val;
} catch (NotSupportedException) {
throw new VsaException (VsaError.OptionNotSupported);
}
}
internal Parser GetParser ()
{
return new Parser ();
}
}
class DefaultVsaSite : BaseVsaSite {
}
}

Просмотреть файл

@ -0,0 +1,204 @@
Assembly/AssemblyInfo.cs
../../build/common/Consts.cs
../../build/common/Locale.cs
Microsoft.JScript/ast.cs
Microsoft.JScript/ASTList.cs
Microsoft.JScript/ActivationObject.cs
Microsoft.JScript/ActiveXObjectConstructor.cs
Microsoft.JScript/ArgumentsObject.cs
Microsoft.JScript/ArrayConstructor.cs
Microsoft.JScript/ArrayLiteral.cs
Microsoft.JScript/ArrayObject.cs
Microsoft.JScript/ArrayPrototype.cs
Microsoft.JScript/ArrayWrapper.cs
Microsoft.JScript/AssemblyCustomAttributeList.cs
Microsoft.Vsa/BaseVsaEngine.cs
Microsoft.JScript/BinaryOp.cs
Microsoft.JScript/Binding.cs
Microsoft.JScript/BitwiseBinary.cs
Microsoft.JScript/Block.cs
Microsoft.JScript/BlockScope.cs
Microsoft.JScript/BooleanConstructor.cs
Microsoft.JScript/BooleanObject.cs
Microsoft.JScript/BooleanPrototype.cs
Microsoft.JScript/BreakOutOfFinally.cs
Microsoft.JScript/Closure.cs
Microsoft.JScript/CmdLineException.cs
Microsoft.JScript/CmdLineError.cs
Microsoft.JScript/CmdLineOptionParser.cs
Microsoft.JScript/CodeGenerator.cs
Microsoft.JScript/COMFieldInfo.cs
Microsoft.JScript/COMMethodInfo.cs
Microsoft.JScript/COMMemberInfo.cs
Microsoft.JScript/Context.cs
Microsoft.JScript/ContinueOutOfFinally.cs
Microsoft.JScript/Convert.cs
Microsoft.JScript/DateConstructor.cs
Microsoft.JScript/DateObject.cs
Microsoft.JScript/DatePrototype.cs
Microsoft.JScript/DebugBreak.cs
Microsoft.JScript/Decompiler.cs
Microsoft.JScript/DocumentContext.cs
Microsoft.JScript/Empty.cs
Microsoft.JScript/Enum.cs
Microsoft.JScript/EnumeratorConstructor.cs
Microsoft.JScript/EnumeratorObject.cs
Microsoft.JScript/EnumeratorPrototype.cs
Microsoft.JScript/Equality.cs
Microsoft.JScript/ErrorConstructor.cs
Microsoft.JScript/ErrorObject.cs
Microsoft.JScript/ErrorPrototype.cs
Microsoft.JScript/Eval.cs
Microsoft.JScript/EvalErrorObject.cs
Microsoft.JScript/Expando.cs
Microsoft.JScript/FieldAccessor.cs
Microsoft.JScript/ForIn.cs
Microsoft.JScript/FormalParameterList.cs
Microsoft.JScript/FunctionConstructor.cs
Microsoft.JScript/FunctionDeclaration.cs
Microsoft.JScript/FunctionExpression.cs
Microsoft.JScript/FunctionObject.cs
Microsoft.JScript/FunctionPrototype.cs
Microsoft.JScript/FunctionWrapper.cs
Microsoft.JScript/GlobalObject.cs
Microsoft.JScript/Globals.cs
Microsoft.JScript/GlobalScope.cs
Microsoft.JScript/IdentificationTable.cs
Microsoft.JScript/IActivationObject.cs
Microsoft.JScript/IAuthorServices.cs
Microsoft.JScript/IColorizeText.cs
Microsoft.JScript/IDebugConvert.cs
Microsoft.JScript/IDebuggerObject.cs
Microsoft.JScript/IDebugScriptScope.cs
Microsoft.JScript/IDebugType.cs
Microsoft.JScript/IDebugVsaScriptCodeItem.cs
Microsoft.JScript/IDefineEvent.cs
Microsoft.JScript/IEngine2.cs
Microsoft.JScript/IErrorHandler.cs
Microsoft.JScript/IMethodsCompletionInfo.cs
Microsoft.JScript/INeedEngine.cs
Microsoft.JScript/IObjectCompletionInfo.cs
Microsoft.JScript/IParseText.cs
Microsoft.JScript/IRedirectOutput.cs
Microsoft.JScript/ISite2.cs
Microsoft.JScript/ITokenColorInfo.cs
Microsoft.JScript/ITokenEnumerator.cs
Microsoft.JScript/IVsaFullErrorInfo.cs
Microsoft.JScript/IVsaScriptCodeItem.cs
Microsoft.JScript/IVsaScriptScope.cs
Microsoft.JScript/InstanceOf.cs
Microsoft.JScript/Import.cs
Microsoft.JScript/In.cs
Microsoft.JScript/IWrappedMember.cs
Microsoft.JScript/JSBuiltIn.cs
Microsoft.JScript/JSConstructor.cs
Microsoft.JScript/JSError.cs
Microsoft.JScript/JSField.cs
Microsoft.JScript/JSFieldInfo.cs
Microsoft.JScript/JSFunctionAttribute.cs
Microsoft.JScript/JSFunctionAttributeEnum.cs
Microsoft.JScript/JSLocalField.cs
Microsoft.JScript/JSMethod.cs
Microsoft.JScript/JSMethodInfo.cs
Microsoft.JScript/JSObject.cs
Microsoft.JScript/JSParser.cs
Microsoft.JScript/JSPrototypeObject.cs
Microsoft.JScript/JSPropertyInfo.cs
Microsoft.JScript/JSScanner.cs
Microsoft.JScript/JSToken.cs
Microsoft.JScript/JSVariableField.cs
Microsoft.JScript/JScriptCodeProvider.cs
Microsoft.JScript/JScriptCodeGenerator.cs
Microsoft.JScript/JScriptCodeCompiler.cs
Microsoft.JScript/JScriptException.cs
Microsoft.JScript/LateBinding.cs
Microsoft.JScript/LenientArrayPrototype.cs
Microsoft.JScript/LenientBooleanPrototype.cs
Microsoft.JScript/LenientDateConstructor.cs
Microsoft.JScript/LenientDatePrototype.cs
Microsoft.JScript/LenientEnumeratorPrototype.cs
Microsoft.JScript/LenientErrorPrototype.cs
Microsoft.JScript/LenientFunctionPrototype.cs
Microsoft.JScript/LenientGlobalObject.cs
Microsoft.JScript/LenientMathObject.cs
Microsoft.JScript/LenientNumberPrototype.cs
Microsoft.JScript/LenientObjectPrototype.cs
Microsoft.JScript/LenientRegExpPrototype.cs
Microsoft.JScript/LenientStringConstructor.cs
Microsoft.JScript/LenientStringPrototype.cs
Microsoft.JScript/LenientVBArrayPrototype.cs
Microsoft.JScript/Literal.cs
Microsoft.JScript/MathObject.cs
Microsoft.JScript/MemberInfoList.cs
Microsoft.JScript/MemberInfoInitializer.cs
Microsoft.JScript/MethodInvoker.cs
Microsoft.JScript/Missing.cs
Microsoft.JScript/Namespace.cs
Microsoft.JScript/NotRecommendedAttribute.cs
Microsoft.JScript/NumberConstructor.cs
Microsoft.JScript/NumberObject.cs
Microsoft.JScript/NumberPrototype.cs
Microsoft.JScript/NumericBinary.cs
Microsoft.JScript/NumericUnary.cs
Microsoft.JScript/ObjectConstructor.cs
Microsoft.JScript/ObjectPrototype.cs
Microsoft.JScript/Package.cs
Microsoft.JScript/Plus.cs
Microsoft.JScript/PostOrPrefixOperator.cs
Microsoft.JScript/Print.cs
Microsoft.JScript/RangeErrorObject.cs
Microsoft.JScript/ReferenceAttribute.cs
Microsoft.JScript/ReferenceErrorObject.cs
Microsoft.JScript/RegExpConstructor.cs
Microsoft.JScript/RegExpObject.cs
Microsoft.JScript/RegExpPrototype.cs
Microsoft.JScript/RegExpMatch.cs
Microsoft.JScript/Relational.cs
Microsoft.JScript/ResInfo.cs
Microsoft.JScript/ReturnOutOfFinally.cs
Microsoft.JScript/ScriptBlock.cs
Microsoft.JScript/ScriptFunction.cs
Microsoft.JScript/ScriptObject.cs
Microsoft.JScript/ScriptStream.cs
Microsoft.JScript/SemanticAnalizer.cs
Microsoft.JScript/SimpleHashtable.cs
Microsoft.JScript/SourceState.cs
Microsoft.JScript/StackFrame.cs
Microsoft.JScript/Statement.cs
Microsoft.JScript/StrictEquality.cs
Microsoft.JScript/StringConstructor.cs
Microsoft.JScript/StringLiteral.cs
Microsoft.JScript/StringObject.cs
Microsoft.JScript/StringPrototype.cs
Microsoft.JScript/SuperTypeMembersSorter.cs
Microsoft.JScript/SyntaxErrorObject.cs
../../build/common/MonoTODOAttribute.cs
Microsoft.JScript/Throw.cs
Microsoft.JScript/Try.cs
Microsoft.JScript/TypedArray.cs
Microsoft.JScript/TypeErrorObject.cs
Microsoft.JScript/TypeOf.cs
Microsoft.JScript/TypeReflector.cs
Microsoft.JScript/UnaryOp.cs
Microsoft.JScript/URIErrorObject.cs
Microsoft.JScript/VariableDeclaration.cs
Microsoft.JScript/VariableStatement.cs
Microsoft.JScript/VBArrayConstructor.cs
Microsoft.JScript/VBArrayObject.cs
Microsoft.JScript/VBArrayPrototype.cs
Microsoft.JScript/VersionableAttribute.cs
Microsoft.JScript/VSAITEMTYPE2.cs
Microsoft.JScript.Vsa/VsaEngine.cs
Microsoft.JScript/With.cs
Microsoft.JScript/VsaCodeItem.cs
Microsoft.JScript/VsaItem.cs
Microsoft.JScript/VsaItems.cs
Microsoft.JScript/VsaGlobalItem.cs
Microsoft.JScript/VsaReferenceItem.cs
Microsoft.JScript/VsaScriptScope.cs
Microsoft.JScript/expression.cs
Microsoft.JScript/Token.cs
Microsoft.JScript/TokenColor.cs
Microsoft.JScript/TokenStream.cs
Microsoft.JScript/Parser.cs
Microsoft.JScript/TypeManager.cs

Просмотреть файл

@ -0,0 +1,68 @@
//
// ASTList.cs: Representation of a collection of source elements
// that form an Ecmascript program.
//
// Author:
// Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.Text;
using System;
namespace Microsoft.JScript {
public sealed class ASTList : AST {
internal ArrayList elems;
internal ASTList (AST parent, Location location)
: base (parent, location)
{
elems = new ArrayList ();
}
internal ASTList Add (AST elem)
{
elems.Add (elem);
return this;
}
internal int Size {
get { return elems.Count; }
}
internal override bool Resolve (Environment env)
{
throw new NotImplementedException ();
}
internal override void Emit (EmitContext ec)
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,86 @@
//
// ActivationObject.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Diagnostics;
using System.Collections;
namespace Microsoft.JScript {
public abstract class ActivationObject : ScriptObject, IActivationObject {
protected ArrayList field_table;
protected virtual JSVariableField CreateField (string name, FieldAttributes attrFlags, object value)
{
throw new NotImplementedException ();
}
public virtual FieldInfo GetField (string name, int lexLevel)
{
throw new NotImplementedException ();
}
public virtual Object GetDefaultThisObject ()
{
throw new NotImplementedException ();
}
public virtual GlobalScope GetGlobalScope ()
{
throw new NotImplementedException ();
}
public virtual FieldInfo GetLocalField (string name)
{
throw new NotImplementedException ();
}
public override MemberInfo [] GetMember (string name, BindingFlags bindFlags)
{
throw new NotImplementedException ();
}
public override MemberInfo [] GetMembers (BindingFlags bindFlags)
{
throw new NotImplementedException ();
}
[DebuggerStepThroughAttribute]
[DebuggerHiddenAttribute]
public Object GetMemberValue (string name, int lexLevel)
{
FieldInfo field = GetField (name);
if (field == null)
return null;
return field.GetValue (name);
}
}
}

Просмотреть файл

@ -0,0 +1,53 @@
//
// ActiveXObjectConstructor.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class ActiveXObjectConstructor : ScriptFunction {
internal static ActiveXObjectConstructor Ctr = new ActiveXObjectConstructor ();
internal ActiveXObjectConstructor ()
{
name = "ActiveXObject";
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasVarArgs)]
public new Object CreateInstance (params Object [] args)
{
throw new NotImplementedException ();
}
public Object Invoke ()
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,39 @@
//
// ArgumentsObject.cs:
//
// Author:
// Cesar Lopez Nataren (cnataren@novell.com)
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Microsoft.JScript {
public sealed class ArgumentsObject : JSObject {
public object callee;
public object caller;
public object length;
}
}

Просмотреть файл

@ -0,0 +1,70 @@
//
// ArrayConstructor.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
namespace Microsoft.JScript {
public class ArrayConstructor : ScriptFunction {
internal static ArrayConstructor Ctr = new ArrayConstructor ();
internal ArrayConstructor ()
{
_prototype = ArrayPrototype.Proto;
_length = 1;
name = "Array";
}
public ArrayObject ConstructArray (Object [] args)
{
throw new NotImplementedException ();
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasVarArgs)]
public new ArrayObject CreateInstance (params Object [] args)
{
if (args == null || args.Length == 0)
return new ArrayObject ();
else if (args.Length == 1)
return new ArrayObject (args [0]);
else
return new ArrayObject (args);
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasVarArgs)]
public ArrayObject Invoke (params Object [] args)
{
return CreateInstance (args);
}
}
}

Просмотреть файл

@ -0,0 +1,100 @@
//
// ArrayLiteral.cs:
//
// Author:
// Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.Reflection;
using System.Reflection.Emit;
namespace Microsoft.JScript {
public class ArrayLiteral : AST, ICanLookupPrototype {
internal ASTList elems;
int skip_count;
public ArrayLiteral (Context context, ASTList elems)
: base (null, null)
{
this.elems = elems;
}
internal ArrayLiteral (Context context, ASTList elems, int skip_count, Location location)
: this (context, elems)
{
this.skip_count = skip_count;
this.location = location;
}
internal override bool Resolve (Environment env)
{
bool r = true;
foreach (AST ast in elems.elems)
if (ast != null)
r &= ast.Resolve (env);
return r;
}
bool ICanLookupPrototype.ResolveFieldAccess (AST ast)
{
if (ast is Identifier) {
Identifier name = (Identifier) ast;
Type prototype = typeof (StringPrototype);
MemberInfo [] members = prototype.GetMember (name.name.Value);
return members.Length > 0;
} else
return false;
}
internal override void Emit (EmitContext ec)
{
int i = 0;
ILGenerator ig = ec.ig;
ArrayList exps = elems.elems;
FieldInfo missing = null;
if (skip_count != 0)
missing = typeof (Missing).GetField ("Value");
ig.Emit (OpCodes.Ldc_I4, elems.Size);
ig.Emit (OpCodes.Newarr, typeof (object));
foreach (AST ast in exps) {
ig.Emit (OpCodes.Dup);
ig.Emit (OpCodes.Ldc_I4, i);
if (ast != null) {
ast.Emit (ec);
CodeGenerator.EmitBox (ig, ast);
} else
ig.Emit (OpCodes.Ldsfld, missing);
ig.Emit (OpCodes.Stelem_Ref);
i++;
}
ig.Emit (OpCodes.Call, typeof (Globals).GetMethod ("ConstructArrayLiteral"));
}
}
}

Просмотреть файл

@ -0,0 +1,112 @@
//
// ArrayObject.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
// (C) 2005, Novell Inc, (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
namespace Microsoft.JScript {
public class ArrayObject : JSObject {
private object _length;
public virtual object length {
get { return _length; }
set {
uint new_length = Convert.ToUint32 (value);
uint old_length = (uint) _length;
for (uint i = new_length; i < old_length; i++)
if (elems.ContainsKey (i))
elems.Remove (i);
_length = new_length;
}
}
internal ArrayObject ()
{
_length = (uint) 0;
}
internal ArrayObject (object o)
{
IConvertible ic = o as IConvertible;
TypeCode tc = Convert.GetTypeCode (o, ic);
try {
if (Convert.IsNumberTypeCode (tc)) {
uint size = Convert.ToUint32 (o);
if (size >= 0) {
_length = size;
return;
} else {
Console.WriteLine ("size = {0}", size);
throw new JScriptException (JSError.ArrayLengthConstructIncorrect);
}
}
} catch (FormatException) { /* OK */ }
elems = new Hashtable ();
_length = (uint) 1;
elems.Add (0, o);
}
internal ArrayObject (params object [] args)
{
if (args != null) {
uint size = (uint) args.Length;
_length = size;
elems = new Hashtable ();
uint idx = 0;
foreach (object o in args) {
elems.Add (idx, o);
idx++;
}
} else
throw new Exception ("args can't be null");
}
internal Hashtable Elements {
get { return elems; }
}
protected void SpliceSlowly (uint start, uint deleteCount, object [] args, ArrayObject outArray, uint oldLength, uint newLength)
{
ArrayPrototype.splice (outArray, null, start, deleteCount, args);
}
internal override object GetDefaultValue (Type hint, bool avoid_toString)
{
return ArrayPrototype.toString (this);
}
}
}

Просмотреть файл

@ -0,0 +1,488 @@
//
// ArrayPrototype.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
// (C) 2005, Novell Inc, (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.Text;
using Microsoft.JScript.Vsa;
using System.Globalization;
namespace Microsoft.JScript {
public class ArrayPrototype : ArrayObject {
internal static ArrayPrototype Proto = new ArrayPrototype ();
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject | JSFunctionAttributeEnum.HasEngine |
JSFunctionAttributeEnum.HasVarArgs, JSBuiltin.Array_concat)]
public static ArrayObject concat (object thisObj, VsaEngine engine,
params object [] args)
{
uint i = 0;
ArrayObject result = new ArrayObject ();
int arg_idx = -1;
int arg_count = args.Length;
// TODO: Shouldn't this be generic!?
SemanticAnalyser.assert_type (thisObj, typeof (ArrayObject));
object cur_obj = thisObj;
ArrayObject cur_ary;
while (cur_obj != null) {
if (cur_obj is ArrayObject) {
cur_ary = (ArrayObject) cur_obj;
uint n = (uint) cur_ary.length;
for (uint j = 0; j < n; j++, i++)
result.elems [i] = cur_ary.elems [j];
} else
result.elems [i++] = cur_obj;
arg_idx++;
cur_obj = arg_idx < arg_count ? args [arg_idx] : null;
}
result.length = i;
return result;
}
public static ArrayConstructor constructor {
get { return ArrayConstructor.Ctr; }
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Array_join)]
public static string join (object thisObj, object separator)
{
// TODO: Shouldn't this be generic!?
SemanticAnalyser.assert_type (thisObj, typeof (ArrayObject));
ArrayObject array_obj = (ArrayObject) thisObj;
string _separator;
if (separator == null)
_separator = ",";
else
_separator = Convert.ToString (separator);
Hashtable elems = array_obj.elems;
uint n = (uint) array_obj.length;
StringBuilder str = new StringBuilder ();
bool first = true;
for (uint i = 0; i < n; i++) {
if (!first)
str.Append (_separator);
first = false;
object elem = elems [i];
if (elem != null)
str.Append (Convert.ToString (elem));
}
return str.ToString ();
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Array_pop)]
public static object pop (object thisObj)
{
// TODO: Shouldn't this be generic!?
SemanticAnalyser.assert_type (thisObj, typeof (ArrayObject));
ArrayObject array_obj = (ArrayObject) thisObj;
Hashtable elems = array_obj.elems;
uint n = (uint) array_obj.length;
object result = null;
if (n > 0) {
uint new_len = n - 1;
if (elems.ContainsKey (new_len))
result = elems [new_len];
// Element gets removed automatically
array_obj.length = new_len;
}
return result;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject | JSFunctionAttributeEnum.HasVarArgs, JSBuiltin.Array_push)]
public static long push (object thisObj, params object [] args)
{
// TODO: Shouldn't this be generic!?
SemanticAnalyser.assert_type (thisObj, typeof (ArrayObject));
ArrayObject array_obj = (ArrayObject) thisObj;
Hashtable elems = array_obj.elems;
uint i = (uint) array_obj.length;
long n = i + args.Length;
for (uint j = 0; i < n; i++, j++)
elems [i] = args [j];
array_obj.length = n;
return n;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Array_reverse)]
public static object reverse (object thisObj)
{
// TODO: Shouldn't this be generic!?
SemanticAnalyser.assert_type (thisObj, typeof (ArrayObject));
ArrayObject array_obj = (ArrayObject) thisObj;
Hashtable elems = array_obj.elems;
uint n = (uint) array_obj.length;
uint half_n = n / 2;
uint j = n - 1;
object temp;
for (uint i = 0; i < half_n; i++, j--) {
temp = elems [i];
elems [i] = elems [j];
elems [j] = temp;
}
return array_obj;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Array_shift)]
public static object shift (object thisObj)
{
// TODO: Shouldn't this be generic!?
SemanticAnalyser.assert_type (thisObj, typeof (ArrayObject));
ArrayObject array_obj = (ArrayObject) thisObj;
Hashtable elems = array_obj.elems;
uint n = (uint) array_obj.length;
object result = null;
if (n > 0) {
if (elems.ContainsKey ((uint) 0)) {
result = elems [(uint) 0];
elems.Remove ((uint) 0);
for (uint i = 1; i < n; i++)
elems [i - 1] = elems [i];
}
// Last element gets removed automatically
array_obj.length = n - 1;
}
return result;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject | JSFunctionAttributeEnum.HasEngine, JSBuiltin.Array_slice)]
public static ArrayObject slice (object thisObj, VsaEngine engine, double start, object end)
{
// TODO: Shouldn't this be generic!?
SemanticAnalyser.assert_type (thisObj, typeof (ArrayObject));
ArrayObject array_obj = (ArrayObject) thisObj;
uint array_len = (uint) array_obj.length;
uint _start, _end;
if (start > array_len)
_start = array_len;
else {
_start = (uint) start;
if (_start < 0)
_start += array_len;
}
if (end == null)
_end = array_len;
else {
_end = Convert.ToUint32 (end);
if (_end < 0)
_end += array_len;
else if (_end > array_len)
_end = array_len;
}
if (_end < _start)
_end = _start;
ArrayObject result = new ArrayObject();
result.length = _end - _start;
for (uint i = _start; i < _end; i++)
result.elems [i - _start] = array_obj.elems [i];
return result;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Array_sort)]
public static object sort (object thisObj, object function)
{
// TODO: Shouldn't this be generic?
SemanticAnalyser.assert_type (thisObj, typeof (ArrayObject));
ArrayObject array_obj = (ArrayObject) thisObj;
ScriptFunction fun = function as ScriptFunction;
uint n = (uint) array_obj.length;
if (n > 1)
SortHelper.qsort (array_obj.elems, 0, n - 1, SortHelper.CompareDelegateFor (fun));
return array_obj;
}
private class SortHelper {
internal delegate sbyte CompareDelegate (Hashtable elems, bool b1, object o1, uint i2);
private ScriptFunction cmp;
internal static CompareDelegate CompareDelegateFor (ScriptFunction fun) {
if (fun == null)
return new CompareDelegate (SortHelper.nativeCompare);
SortHelper helper = new SortHelper (fun);
return new CompareDelegate (helper.userCompare);
}
internal SortHelper (ScriptFunction cmp)
{
this.cmp = cmp;
}
// Calls a user supplied compare ScriptFunction
internal sbyte userCompare (Hashtable elems, bool b1, object o1, uint i2)
{
bool b2 = !elems.ContainsKey (i2);
if (b1 && b2)
return 0;
else if (b1)
return 1;
else if (b2)
return -1;
object o2 = elems [i2];
if (o1 == null && o2 == null)
return 0;
if (o1 == null)
return 1;
else if (o2 == null)
return -1;
int res = Convert.ToInt32 (cmp.Invoke (null, o1, o2));
if (res < 0)
return -1;
else if (res > 0)
return 1;
else
return 0;
}
// Uses a built-in compare function
internal static sbyte nativeCompare (Hashtable elems, bool b1, object o1_, uint i2)
{
bool b2 = !elems.ContainsKey (i2);
if (b1 && b2)
return 0;
else if (b1)
return 1;
else if (b2)
return -1;
IComparable o1 = o1_ as IComparable;
IComparable o2 = elems [i2] as IComparable;
if (o1 == null && o2 == null)
return 0;
if (o1 == null)
return 1;
else if (o2 == null)
return -1;
return (sbyte) Relational.JScriptCompare (o1, o2);
}
internal static void swap (Hashtable elems, uint i1, uint i2)
{
object temp = elems [i1];
elems [i1] = elems [i2];
elems [i2] = temp;
}
internal static uint partition (Hashtable elems, uint left, uint right, CompareDelegate cmp)
{
uint pivotIndex = left + (uint) MathObject.random_gen.Next ((int) right - (int) left + 1);
bool pivotMissing = !elems.ContainsKey (pivotIndex);
object pivotValue = elems [pivotIndex];
swap (elems, pivotIndex, right);
uint storeIndex = left;
for (uint i = left; i < right; i++)
if (cmp (elems, pivotMissing, pivotValue, i) >= 0)
swap (elems, storeIndex++, i);
swap (elems, right, storeIndex);
return storeIndex;
}
internal static void qsort (Hashtable elems, uint beg, uint end, CompareDelegate cmp)
{
if (end > beg) {
uint index = partition (elems, beg, end, cmp);
if (index > 0)
qsort (elems, beg, index - 1, cmp);
qsort (elems, index + 1, end, cmp);
}
}
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject | JSFunctionAttributeEnum.HasVarArgs | JSFunctionAttributeEnum.HasEngine, JSBuiltin.Array_splice)]
public static ArrayObject splice (object thisObj, VsaEngine engine,
double start, double deleteCnt,
params object [] args)
{
// TODO: Shouldn't this be generic!?
SemanticAnalyser.assert_type (thisObj, typeof (ArrayObject));
ArrayObject array_obj = (ArrayObject) thisObj;
ArrayObject result = new ArrayObject ();
Hashtable elems = array_obj.elems;
Hashtable del_elems = result.elems;
uint old_length = (uint) array_obj.length;
start = (long) start;
if (start < 0)
start = Math.Max (start + old_length, 0);
else
start = Math.Min (old_length, start);
deleteCnt = (long) deleteCnt;
deleteCnt = Math.Min (Math.Max (deleteCnt, 0), old_length - start);
uint arg_length = (uint) args.Length;
long add_length = (long) ((long) arg_length - (uint) deleteCnt);
add_length = (long) Math.Max (add_length, -((long) old_length));
long del_length = -add_length;
uint new_length = (uint) ((long) old_length + add_length);
long i, j, m;
// First let's make some free space for the new items (if needed)
if (add_length > 0) {
i = (long) old_length - 1;
j = (uint) (i + add_length);
for (; i >= start; i--, j--)
elems [(uint) j] = elems [(uint) i];
}
// Then insert the new items in the now free space / replace existing ones
j = m = 0;
long old_start = (long) (start + add_length);
for (i = (long) start; j < arg_length; i++, j++) {
if (i >= old_start && elems.ContainsKey ((uint) i)) {
del_elems [(uint) m] = elems [(uint) i];
m++;
elems.Remove ((uint) i);
}
if (j < arg_length)
elems [(uint) i] = args [(uint) j];
}
// Finally, delete elements which have no replacement elements
if (add_length < 0) {
uint last_elem_idx = (uint) (i + del_length);
for (uint k = 0; k < del_length; i++, j++, k++) {
if (elems.ContainsKey ((uint) i)) {
del_elems [(uint) m] = elems [(uint) i];
m++;
elems.Remove ((uint) i);
}
}
// And move up trailing elements
uint l = (uint) (last_elem_idx - del_length);
for (uint k = last_elem_idx; l < old_length; k++, l++) {
if (elems.ContainsKey (k))
elems [l] = elems [k];
else if (elems.ContainsKey (l))
elems.Remove (l);
}
}
array_obj.length = new_length;
result.length = (uint) deleteCnt;
return result;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Array_toLocaleString)]
public static string toLocaleString (object thisObj)
{
// TODO: Shouldn't this be generic!?
SemanticAnalyser.assert_type (thisObj, typeof (ArrayObject));
ArrayObject array_obj = (ArrayObject) thisObj;
string separator = CultureInfo.CurrentCulture.TextInfo.ListSeparator + " ";
Hashtable elems = array_obj.elems;
uint n = (uint) array_obj.length;
StringBuilder str = new StringBuilder ();
bool first = true;
for (uint i = 0; i < n; i++) {
ScriptObject elem = (ScriptObject) Convert.ToObject (elems [i], null);
if (!first && elem != null)
str.Append (separator);
first = false;
if (elem != null)
str.Append (Convert.ToString (elem.CallMethod ("toLocaleString", new object [] { } )));
}
return str.ToString ();
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Array_toString)]
public static string toString (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (ArrayObject));
return ArrayPrototype.join (thisObj, null);
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject | JSFunctionAttributeEnum.HasVarArgs, JSBuiltin.Array_unshift)]
public static object unshift (object thisObj, params object [] args)
{
// TODO: Shouldn't this be generic!?
SemanticAnalyser.assert_type (thisObj, typeof (ArrayObject));
ArrayObject array_obj = (ArrayObject) thisObj;
Hashtable elems = array_obj.elems;
uint old_length = (uint) array_obj.length;
uint arg_length = (uint) args.Length;
uint new_length = old_length + arg_length;
if (arg_length > 0) {
// First let's make some free space for the new items
long i = (long) old_length - 1;
long j = i + (long) arg_length;
for (; i >= 0; i--, j--)
elems [(uint) j] = elems [(uint) i];
// Then insert the new items in the now free space
for (; j >= 0; j--)
elems [(uint) j] = args [(uint) j];
}
//
// NOTE: MSC returns the new array, but
// ECMA-262 says to return the new length. We
// conform to the standard.
//
array_obj.length = new_length;
return new_length;
}
}
}

Просмотреть файл

@ -0,0 +1,54 @@
//
// ArrayWrapper.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class ArrayWrapper : ArrayObject
{
public new Type GetType ()
{
throw new NotImplementedException ();
}
public override object length {
get { throw new NotImplementedException (); }
set {}
}
public int Compare (object x, object y)
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,33 @@
//
// AssemblyCustomAttributeList.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Microsoft.JScript {
public class AssemblyCustomAttributeList
{}
}

Просмотреть файл

@ -0,0 +1,67 @@
//
// BinaryOp.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
namespace Microsoft.JScript {
public abstract class BinaryOp : Exp {
protected AST operand1, operand2;
protected MethodInfo operatorMeth;
protected JSToken operatorTok;
protected Type type1, type2;
protected MethodInfo GetOperator (IReflect ir1, IReflect ir2)
{
throw new NotImplementedException ();
}
internal BinaryOp (AST parent, AST left, AST right, JSToken op, Location location)
: base (parent, location)
{
operand1 = left;
operand2 = right;
operatorTok = op;
}
internal JSToken op {
get { return operatorTok; }
}
internal AST left {
get { return operand1; }
set { operand1 = value; }
}
internal AST right {
get { return operand2; }
set { operand2 = value; }
}
}
}

Просмотреть файл

@ -0,0 +1,67 @@
//
// Binding.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Reflection.Emit;
namespace Microsoft.JScript {
public abstract class Binding : AST {
protected MemberInfo defaultMember;
protected bool isAssignmentToDefaultIndexedProperty;
protected bool isFullyResolved;
protected bool isNonVirtual;
protected string name;
protected abstract Object GetObject ();
protected abstract void HandleNoSuchMemberError ();
private Binding ()
: base (null, null)
{
}
protected void ResolveRHValue ()
{
throw new NotImplementedException ();
}
protected abstract void TranslateToILObject (ILGenerator il, Type obtype, bool noValue);
protected abstract void TranslateToILWithDupOfThisOb (ILGenerator il);
public static bool IsMissing (Object value)
{
// FIXME
return false;
}
}
}

Просмотреть файл

@ -0,0 +1,89 @@
//
// BitwiseBinary.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Diagnostics;
namespace Microsoft.JScript {
public sealed class BitwiseBinary : BinaryOp {
public BitwiseBinary (int operatorTok)
: base (null, null, null, (JSToken) operatorTok, null)
{
}
[DebuggerStepThroughAttribute]
[DebuggerHiddenAttribute]
public object EvaluateBitwiseBinary (object v1, object v2)
{
int num1 = Convert.ToInt32 (v1);
int num2 = Convert.ToInt32 (v2);
switch (operatorTok) {
case JSToken.BitwiseAnd:
return num1 & num2;
case JSToken.BitwiseXor:
return num1 ^ num2;
case JSToken.BitwiseOr:
return num1 | num2;
case JSToken.LeftShift:
return num1 << num2;
case JSToken.RightShift:
return num1 >> num2;
case JSToken.UnsignedRightShift:
return UnsignedRightShift (num1, num2);
}
Console.WriteLine ("EvaluateBitwiseBinary: operatorTok = {0}", operatorTok);
throw new NotImplementedException ();
}
internal static uint UnsignedRightShift (int num1, int num2)
{
return (uint) num1 >> num2;
}
internal override bool Resolve (Environment env)
{
throw new NotImplementedException ();
}
internal override bool Resolve (Environment env, bool no_effect)
{
throw new NotImplementedException ();
}
internal override void Emit (EmitContext ec)
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,143 @@
//
// Block.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.Text;
using System;
namespace Microsoft.JScript {
public class Block : AST, ICanModifyContext {
internal ArrayList elems;
internal Block (AST parent, Location location)
: base (parent, location)
{
elems = new ArrayList ();
}
internal void Add (AST e)
{
if (e != null)
elems.Add (e);
}
void ICanModifyContext.EmitDecls (EmitContext ec)
{
//
// Emit variable declarations and function's closure first
// because of posible free occurrences inside a method.
//
foreach (AST ast in elems)
if (ast is FunctionDeclaration)
((FunctionDeclaration) ast).create_closure (ec);
else if (ast is ICanModifyContext)
((ICanModifyContext) ast).EmitDecls (ec);
}
internal override void Emit (EmitContext ec)
{
int n = elems.Count;
object e;
//
// Emit the rest of expressions and statements.
//
for (int i = 0; i < n; i++) {
e = elems [i];
((AST) e).Emit (ec);
}
}
void ICanModifyContext.PopulateContext (Environment env, string ns)
{
AST ast;
for (int i = 0; i < elems.Count; i++) {
ast = (AST) elems [i];
if (ast is FunctionDeclaration) {
string name = ((FunctionDeclaration) ast).func_obj.name;
AST binding = (AST) env.Get (ns, Symbol.CreateSymbol (name));
if (binding == null)
SemanticAnalyser.Ocurrences.Enter (ns, Symbol.CreateSymbol (name), new DeleteInfo (i, this));
else {
DeleteInfo delete_info = (DeleteInfo) SemanticAnalyser.Ocurrences.Get (ns, Symbol.CreateSymbol (name));
if (delete_info != null) {
delete_info.Block.elems.RemoveAt (delete_info.Index);
SemanticAnalyser.Ocurrences.Remove (ns, Symbol.CreateSymbol (name));
if (delete_info.Block == this)
if (delete_info.Index < i)
i--;
SemanticAnalyser.Ocurrences.Enter (ns, Symbol.CreateSymbol (name), new DeleteInfo (i, this));
}
}
}
if (ast is ICanModifyContext)
((ICanModifyContext) ast).PopulateContext (env, ns);
}
}
internal override bool Resolve (Environment env)
{
AST e;
bool r = true;
int i, n = elems.Count;
for (i = 0; i < n; i++) {
e = (AST) elems [i];
if (e is Exp)
r &= ((Exp) e).Resolve (env, true);
else
r &= e.Resolve (env);
}
return r;
}
}
internal class DeleteInfo {
private int index;
private Block block;
internal DeleteInfo (int index, Block block)
{
this.index = index;
this.block = block;
}
internal int Index {
get { return index; }
}
internal Block Block {
get { return block; }
}
}
}

Просмотреть файл

@ -0,0 +1,48 @@
//
// BlockScope.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
namespace Microsoft.JScript {
public class BlockScope : ActivationObject
{
public BlockScope (ScriptObject parent, string name, int scopeId)
{
throw new NotImplementedException ();
}
protected override JSVariableField CreateField (string name, FieldAttributes attrFlags, object value)
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,59 @@
//
// BooleanConstructor.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class BooleanConstructor : ScriptFunction {
internal static BooleanConstructor Ctr = new BooleanConstructor ();
internal BooleanConstructor ()
{
_prototype = BooleanPrototype.Proto;
_length = 1;
name = "Boolean";
}
[JSFunctionAttribute(JSFunctionAttributeEnum.HasVarArgs)]
public new BooleanObject CreateInstance (params Object [] args)
{
if (args == null || args.Length == 0)
return new BooleanObject ();
else
return new BooleanObject (args [0]);
}
public bool Invoke (Object arg)
{
return Convert.ToBoolean (arg);
}
}
}

Просмотреть файл

@ -0,0 +1,67 @@
//
// BooleanObject.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
// (C) 2005, Novell, Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class BooleanObject : JSObject {
internal bool value;
internal BooleanObject ()
{
this.value = false;
}
internal BooleanObject (object value)
{
this.value = Convert.ToBoolean (value);
}
public new Type GetType ()
{
throw new NotImplementedException ();
}
protected BooleanObject (ScriptObject prototype, Type subType)
{
throw new NotImplementedException ();
}
internal override object GetDefaultValue (Type hint, bool avoid_toString)
{
if (hint == typeof (string))
return BooleanPrototype.toString (this);
else
return value;
}
}
}

Просмотреть файл

@ -0,0 +1,75 @@
//
// BooleanPrototype.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class BooleanPrototype : BooleanObject {
internal static BooleanPrototype Proto = new BooleanPrototype (null, null);
public static BooleanConstructor constructor {
get { return BooleanConstructor.Ctr; }
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Boolean_toString)]
public static string toString (object thisObj)
{
if (!Convert.IsBoolean (thisObj))
throw new JScriptException (JSError.BooleanExpected);
if (thisObj is bool)
return (bool) thisObj ? "true" : "false";
BooleanObject bo = thisObj as BooleanObject;
return bo.value ? "true" : "false";
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Boolean_valueOf)]
public static object valueOf (object thisObj)
{
if (!Convert.IsBoolean (thisObj))
throw new JScriptException (JSError.BooleanExpected);
if (thisObj is bool)
return thisObj;
BooleanObject bo = thisObj as BooleanObject;
return bo.value;
}
protected BooleanPrototype (ObjectPrototype prototype, Type baseType)
{
}
}
}

Просмотреть файл

@ -0,0 +1,44 @@
//
// BreakOutOfFinally.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public sealed class BreakOutOfFinally : ApplicationException
{
public int target;
public BreakOutOfFinally (int target)
{
this.target = target;
}
}
}

Просмотреть файл

@ -0,0 +1,110 @@
//
// COMFieldInfo.cs:
//
// Author:
// Cesar Lopez Nataren (cnataren@novell.com)
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Globalization;
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("CA0F511A-FAF2-4942-B9A8-17D5E46514E8")]
[ComVisibleAttribute (true)]
public class COMFieldInfo : FieldInfo, MemberInfoInitializer {
public COMFieldInfo ()
{
throw new NotImplementedException ();
}
public COMMemberInfo GetCOMMemberInfo ()
{
throw new NotImplementedException ();
}
public void Initialize (string name, COMMemberInfo dispatch)
{
throw new NotImplementedException ();
}
public override FieldAttributes Attributes {
get { throw new NotImplementedException (); }
}
public override Type DeclaringType {
get { throw new NotImplementedException (); }
}
public override RuntimeFieldHandle FieldHandle {
get { throw new NotImplementedException (); }
}
public override Type FieldType {
get { throw new NotImplementedException (); }
}
public override Object [] GetCustomAttributes (Type t, bool inherit)
{
throw new NotImplementedException ();
}
public override Object [] GetCustomAttributes (bool inherit)
{
throw new NotImplementedException ();
}
public override bool IsDefined (Type type, bool inherit)
{
throw new NotImplementedException ();
}
public override MemberTypes MemberType {
get { throw new NotImplementedException (); }
}
public override string Name {
get { throw new NotImplementedException (); }
}
public override Type ReflectedType {
get { throw new NotImplementedException (); }
}
public override object GetValue (object obj)
{
throw new NotImplementedException ();
}
public override void SetValue (object obj, object val, BindingFlags invokeAttr, System.Reflection.Binder binder, CultureInfo culture)
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,48 @@
//
// COMMemberInfo.cs:
//
// Author:
// Cesar Lopez Nataren
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Globalization;
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("84BCEB62-16EB-4e1c-975C-FCB40D331043")]
[ComVisibleAttribute (true)]
public interface COMMemberInfo {
object Call (BindingFlags invokeAttr, System.Reflection.Binder binder, object [] args, CultureInfo _culture);
object GetValue (BindingFlags invokeAttr, System.Reflection.Binder binder, object [] index, CultureInfo culture);
void SetValue (object value, BindingFlags invokeAttr, System.Reflection.Binder binder, object [] index, CultureInfo culture);
}
}

Просмотреть файл

@ -0,0 +1,121 @@
//
// COMMethodInfo.cs:
//
// Author:
// Cesar Lopez Nataren (cnataren@novell.com)
//
// Copyright (C) 2005 Novell, Inc (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Globalization;
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("C7B9C313-2FD4-4384-8571-7ABC08BD17E5")]
[ComVisibleAttribute (true)]
public class COMMethodInfo : JSMethod, MemberInfoInitializer {
public COMMemberInfo GetCOMMemberInfo ()
{
throw new NotImplementedException ();
}
public void Initialize (string name, COMMemberInfo dispatch)
{
throw new NotImplementedException ();
}
public override Type ReturnType {
get { throw new NotImplementedException (); }
}
public override ICustomAttributeProvider ReturnTypeCustomAttributes {
get { throw new NotImplementedException (); }
}
public override MethodInfo GetBaseDefinition ()
{
throw new NotImplementedException ();
}
public override MethodImplAttributes GetMethodImplementationFlags ()
{
throw new NotImplementedException ();
}
public override ParameterInfo [] GetParameters ()
{
throw new NotImplementedException ();
}
public override Object Invoke (object obj, BindingFlags invokeAttr,
System.Reflection.Binder binder, object [] parameters, CultureInfo culture)
{
throw new NotImplementedException ();
}
public override RuntimeMethodHandle MethodHandle {
get { throw new NotImplementedException (); }
}
public override MethodAttributes Attributes {
get { throw new NotImplementedException (); }
}
public override Type DeclaringType {
get { throw new NotImplementedException (); }
}
public override MemberTypes MemberType {
get { throw new NotImplementedException (); }
}
public override string Name {
get { throw new NotImplementedException (); }
}
public override Type ReflectedType {
get { throw new NotImplementedException (); }
}
public override string ToString ()
{
throw new NotImplementedException ();
}
protected COMMemberInfo _comObject;
protected string _name;
protected static readonly ParameterInfo [] EmptyParams;
#if NET_2_0
public sealed override Type [] GetGenericArguments ()
{
throw new NotImplementedException ();
}
#endif
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,53 @@
//
// Closure.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class Closure : ScriptFunction {
public object arguments;
public object caller;
internal FunctionObject func;
public Closure (FunctionObject func)
{
this._prototype = func._prototype;
this.method = func.method;
this.vsa_engine = func.vsa_engine;
this.func = func;
}
public override string ToString ()
{
return func.ToString ();
}
}
}

Просмотреть файл

@ -0,0 +1,74 @@
//
// CmdLineError.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Microsoft.JScript {
public enum CmdLineError {
AssemblyNotFound,
CannotCreateEngine,
CompilerConstant,
DuplicateFileAsSourceAndAssembly,
DuplicateResourceFile,
DuplicateResourceName,
DuplicateSourceFile,
ErrorSavingCompiledState,
IncompatibleTargets,
InvalidAssembly,
InvalidCharacters,
InvalidCodePage,
InvalidDefinition,
InvalidForCompilerOptions,
InvalidLocaleID,
InvalidTarget,
InvalidSourceFile,
InvalidVersion,
InvalidWarningLevel,
ManagedResourceNotFound,
MissingDefineArgument,
MissingExtension,
MissingLibArgument,
MissingReference,
MissingVersionInfo,
MultipleOutputNames,
MultipleTargets,
MultipleWin32Resources,
NestedResponseFiles,
NoCodePage,
NoFileName,
NoInputSourcesSpecified,
NoLocaleID,
NoWarningLevel,
ResourceNotFound,
SourceFileTooBig,
SourceNotFound,
UnknownOption,
Unspecified,
LAST
}
}

Просмотреть файл

@ -0,0 +1,61 @@
//
// CmdLineException.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Globalization;
namespace Microsoft.JScript {
public class CmdLineException : Exception
{
public CmdLineException (CmdLineError errorCode, CultureInfo culture)
{
throw new NotImplementedException ();
}
public CmdLineException (CmdLineError errorCode, string context,
CultureInfo culture)
{
throw new NotImplementedException ();
}
public override string Message {
get { throw new NotImplementedException (); }
}
public string ResourceKey (CmdLineError errorCode)
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,68 @@
//
// CmdLineOptionParser.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class CmdLineOptionParser
{
public static bool IsSimpleOption (string option, string prefix)
{
throw new NotImplementedException ();
}
public static string IsArgumentOption (string option, string prefix)
{
throw new NotImplementedException ();
}
public static string IsArgumentOption (string option, string shortPrefix,
string longPrefix)
{
throw new NotImplementedException ();
}
public static object IsBooleanOption (string option, string prefix)
{
throw new NotImplementedException ();
}
public static object IsBooleanOption (string option, string shortPrefix,
string longPrefix)
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,734 @@
//
// CodeGenerator.cs
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, 2004 Cesar Lopez Nataren
// (C) 2005, Novell, Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;
using Microsoft.JScript.Vsa;
using System.Collections;
namespace Microsoft.JScript {
internal class EmitContext {
internal TypeBuilder type_builder;
internal ILGenerator ig;
internal ModuleBuilder mod_builder;
internal MethodBuilder global_code;
internal Label LoopBegin, LoopEnd;
internal EmitContext (TypeBuilder type_builder, ModuleBuilder mod_builder, ILGenerator ig)
{
this.type_builder = type_builder;
this.mod_builder = mod_builder;
this.ig = ig;
}
}
internal class CodeGenerator {
private static string MODULE = "JScript Module";
private static string CORLIB = typeof (object).Assembly.FullName;
internal static string mod_name;
internal static AppDomain app_domain;
internal static AssemblyName assembly_name;
internal static AssemblyBuilder assembly_builder;
internal static ModuleBuilder module_builder;
private static int next_type = 0;
private static ArrayList global_types = new ArrayList ();
private static Hashtable global_methods = new Hashtable ();
private static Hashtable source_file_to_type = new Hashtable ();
private static string NextType {
get { return "JScript " + next_type++; }
}
internal static string Basename (string name)
{
int pos = name.LastIndexOf ('/');
if (pos != -1)
return name.Substring (pos + 1);
pos = name.LastIndexOf ('\\');
if (pos != -1)
return name.Substring (pos + 1);
return name;
}
internal static string Dirname (string name)
{
int pos = name.LastIndexOf ('/');
if (pos != -1)
return name.Substring (0, pos);
pos = name.LastIndexOf ('\\');
if (pos != -1)
return name.Substring (0, pos);
return ".";
}
internal static void Init (string file_name)
{
app_domain = Thread.GetDomain ();
assembly_name = new AssemblyName ();
assembly_name.Name = Path.GetFileNameWithoutExtension (file_name);
mod_name = MODULE;
assembly_builder = app_domain.DefineDynamicAssembly (
assembly_name,
AssemblyBuilderAccess.RunAndSave,
Dirname (file_name));
ConstructorInfo ctr_info = typeof (Microsoft.JScript.ReferenceAttribute).GetConstructor (new Type [] { typeof (string) });
assembly_builder.SetCustomAttribute (new CustomAttributeBuilder (ctr_info, new object [] {CORLIB}));
module_builder = assembly_builder.DefineDynamicModule (
mod_name,
Basename (assembly_name.Name + ".exe"),
false);
}
internal static string trim_extension (string file_name)
{
int index = file_name.LastIndexOf ('.');
if (index < 0)
return file_name;
else
return file_name.Substring (0, index);
}
internal static void Save (string target_name)
{
assembly_builder.Save (CodeGenerator.Basename (target_name));
}
internal static void EmitDecls (ScriptBlock prog)
{
if (prog == null)
return;
string next_type = CodeGenerator.NextType;
prog.InitTypeBuilder (module_builder, next_type);
prog.InitGlobalCode ();
global_types.Add (next_type);
global_methods.Add (next_type, prog.GlobalCode);
source_file_to_type.Add (prog.Location.SourceName, next_type);
prog.EmitDecls (module_builder);
}
internal static void emit_jscript_main (TypeBuilder tb)
{
emit_jscript_main_constructor (tb);
emit_jscript_main_entry_point (tb);
}
internal static void emit_jscript_main_constructor (TypeBuilder tb)
{
ConstructorBuilder cons = tb.DefineConstructor (MethodAttributes.Public,
CallingConventions.Standard,
new Type [] {});
ILGenerator ig = cons.GetILGenerator ();
ig.Emit (OpCodes.Ldarg_0);
ig.Emit (OpCodes.Call, typeof (Object).GetConstructor (new Type [] {}));
ig.Emit (OpCodes.Ret);
}
internal static void emit_jscript_main_entry_point (TypeBuilder tb)
{
MethodBuilder method;
method = tb.DefineMethod ("Main",
MethodAttributes.Public | MethodAttributes.Static,
typeof (void), new Type [] {typeof (String [])});
method.SetCustomAttribute (new CustomAttributeBuilder
(typeof (STAThreadAttribute).GetConstructor (
new Type [] {}),
new object [] {}));
ILGenerator ig = method.GetILGenerator ();
ig.DeclareLocal (typeof (GlobalScope));
ig.Emit (OpCodes.Ldc_I4_1);
ig.Emit (OpCodes.Ldc_I4_1);
ig.Emit (OpCodes.Newarr, typeof (string));
ig.Emit (OpCodes.Dup);
ig.Emit (OpCodes.Ldc_I4_0);
ig.Emit (OpCodes.Ldstr, CORLIB);
ig.Emit (OpCodes.Stelem_Ref);
ig.Emit (OpCodes.Call,
typeof (VsaEngine).GetMethod ("CreateEngineAndGetGlobalScope",
new Type [] {typeof (bool),
typeof (string [])}));
ig.Emit (OpCodes.Stloc_0);
foreach (string type_name in global_types) {
ig.Emit (OpCodes.Ldloc_0);
ig.Emit (OpCodes.Newobj, assembly_builder.GetType (type_name).GetConstructor (
new Type [] {typeof (GlobalScope)}));
ig.Emit (OpCodes.Call, (MethodInfo) global_methods [type_name]);
ig.Emit (OpCodes.Pop);
}
ig.Emit (OpCodes.Ret);
assembly_builder.SetEntryPoint (method);
}
public static void Run (string file_name, ScriptBlock [] blocks)
{
CodeGenerator.Init (file_name);
//
// Emit first all the declarations (function and variables)
//
foreach (ScriptBlock script_block in blocks)
CodeGenerator.EmitDecls (script_block);
//
// emit everything that's not a declaration
//
foreach (ScriptBlock script_block in blocks)
script_block.Emit ();
//
// Create the types ('JScript N')
//
foreach (ScriptBlock script_block in blocks)
script_block.CreateType ();
//
// Build the default 'JScript Main' class
//
TypeBuilder main_type_builder = module_builder.DefineType ("JScript Main");
emit_jscript_main (main_type_builder);
main_type_builder.CreateType ();
CodeGenerator.Save (trim_extension (file_name) + ".exe");
}
static void emit_default_case (EmitContext ec, AST ast, OpCode op, Label lbl)
{
ast.Emit (ec);
if (need_convert_to_boolean (ast))
emit_to_boolean (ast, ec.ig, 0);
ec.ig.Emit (op, lbl);
}
static void ft_binary_recursion (EmitContext ec, AST ast, Label lbl)
{
ILGenerator ig = ec.ig;
if (ast is Binary) {
Binary b = ast as Binary;
switch (b.op) {
case JSToken.LogicalOr:
Label ftLb = ig.DefineLabel ();
fall_false (ec, b.left, ftLb);
fall_true (ec, b.right, lbl);
ig.MarkLabel (ftLb);
break;
case JSToken.LogicalAnd:
fall_true (ec, b.left, lbl);
fall_true (ec, b.right, lbl);
break;
case JSToken.LessThan:
ig.Emit (OpCodes.Ldc_I4_0);
ig.Emit (OpCodes.Conv_R8);
ig.Emit (OpCodes.Blt, lbl);
break;
default:
ast.Emit (ec);
ig.Emit (OpCodes.Ldc_I4_1);
ig.Emit (OpCodes.Call, typeof (Convert).GetMethod ("ToBoolean", new Type [] {typeof (object), typeof (bool)}));
ig.Emit (OpCodes.Brfalse, lbl);
break;
}
}
}
static void ft_emit_equality (EmitContext ec, AST ast, Label lbl)
{
ILGenerator ig = ec.ig;
BinaryOp eq = null;
if (ast is Equality)
eq = (Equality) ast;
else if (ast is StrictEquality)
eq = (StrictEquality) ast;
eq.Emit (ec);
switch (eq.op) {
case JSToken.NotEqual:
case JSToken.StrictNotEqual:
ig.Emit (OpCodes.Brtrue, lbl);
break;
case JSToken.Equal:
case JSToken.StrictEqual:
ig.Emit (OpCodes.Brfalse, lbl);
break;
}
}
internal static void fall_true (EmitContext ec, AST ast, Label lbl)
{
Type type = ast.GetType ();
if (type == typeof (Expression)) {
Expression exp = ast as Expression;
AST last_exp = (AST) exp.exprs [exp.exprs.Count - 1];
if (exp.exprs.Count >= 2)
exp.Emit (ec);
fall_true (ec, last_exp, lbl);
} else if (type == typeof (Binary))
ft_binary_recursion (ec, ast, lbl);
else if (type == typeof (Equality) || type == typeof (StrictEquality))
ft_emit_equality (ec, ast, lbl);
else if (type == typeof (Relational))
ft_emit_relational (ec, (Relational) ast, lbl);
else
emit_default_case (ec, ast, OpCodes.Brfalse, lbl);
}
static void ff_emit_relational (EmitContext ec, AST ast, Label lbl)
{
ILGenerator ig = ec.ig;
Relational r = ast as Relational;
r.Emit (ec);
OpCode opcode;
switch (r.op) {
case JSToken.LessThan:
opcode = OpCodes.Blt;
break;
case JSToken.GreaterThan:
opcode = OpCodes.Bgt;
break;
case JSToken.LessThanEqual:
opcode = OpCodes.Ble;
break;
case JSToken.GreaterThanEqual:
opcode = OpCodes.Bge;
break;
default:
throw new Exception ("unexpected token");
}
ig.Emit (OpCodes.Ldc_I4_0);
ig.Emit (OpCodes.Conv_R8);
ig.Emit (opcode, lbl);
}
static void ft_emit_relational (EmitContext ec, Relational re, Label lbl)
{
ILGenerator ig = ec.ig;
re.Emit (ec);
JSToken op = re.op;
OpCode opcode;
switch (op) {
case JSToken.LessThan:
opcode = OpCodes.Bge_Un;
break;
case JSToken.GreaterThan:
opcode = OpCodes.Ble_Un;
break;
case JSToken.LessThanEqual:
opcode = OpCodes.Bgt_Un;
break;
case JSToken.GreaterThanEqual:
opcode = OpCodes.Blt_Un;
break;
default:
Console.WriteLine (re.Location.LineNumber);
throw new NotImplementedException ();
}
ig.Emit (OpCodes.Ldc_I4_0);
ig.Emit (OpCodes.Conv_R8);
ig.Emit (opcode, lbl);
}
static void ff_binary_recursion (EmitContext ec, AST ast, Label lbl)
{
ILGenerator ig = ec.ig;
Binary b = ast as Binary;
switch (b.op) {
case JSToken.LogicalOr:
fall_false (ec, b.left, lbl);
fall_false (ec, b.right, lbl);
break;
case JSToken.LogicalAnd:
Label ftLb = ig.DefineLabel ();
fall_true (ec, b.left, ftLb);
fall_false (ec, b.right, lbl);
ig.MarkLabel (ftLb);
break;
}
}
static void ff_emit_equality_cond (EmitContext ec, AST ast, Label lbl)
{
ILGenerator ig = ec.ig;
Equality eq = ast as Equality;
eq.Emit (ec);
switch (eq.op) {
case JSToken.NotEqual:
case JSToken.Equal:
ig.Emit (OpCodes.Brfalse, lbl);
break;
}
}
internal static void fall_false (EmitContext ec, AST ast, Label lbl)
{
Type type = ast.GetType ();
if (type == typeof (Expression)) {
Expression exp = ast as Expression;
if (exp.Size > 1)
exp.Emit (ec);
AST last_exp = (AST) exp.exprs [exp.exprs.Count - 1];
if (last_exp is Relational)
ff_emit_relational (ec, last_exp, lbl);
else if (last_exp is Binary)
ff_binary_recursion (ec, last_exp, lbl);
else if (last_exp is Identifier || last_exp is BooleanConstant)
emit_default_case (ec, last_exp, OpCodes.Brtrue, lbl);
else if (last_exp is Equality)
ff_emit_equality_cond (ec, last_exp, lbl);
else {
Console.WriteLine ("WARNING: fall_false, last_exp.GetType () == {0}, {1}", last_exp, ast.Location.LineNumber);
}
} else if (type == typeof (Binary))
ff_binary_recursion (ec, ast, lbl);
else if (type == typeof (Relational))
ff_emit_relational (ec, ast, lbl);
else
emit_default_case (ec, ast, OpCodes.Brtrue, lbl);
}
internal static void emit_to_boolean (AST ast, ILGenerator ig, int i)
{
ig.Emit (OpCodes.Ldc_I4, i);
ig.Emit (OpCodes.Call, typeof (Convert).GetMethod ("ToBoolean",
new Type [] { typeof (object), typeof (Boolean)}));
}
internal static bool need_convert_to_boolean (AST ast)
{
if (ast == null)
return false;
if (ast is Identifier)
return true;
else if (ast is Expression) {
Expression exp = ast as Expression;
int n = exp.exprs.Count - 1;
AST tmp = (AST) exp.exprs [n];
if (tmp is Equality || tmp is Relational || tmp is BooleanConstant)
return false;
else
return true;
} else
return false;
}
//
// Loads a current VsaEngine
//
internal static void load_engine (bool in_function, ILGenerator ig)
{
//
// If we are in a function declaration at global level,
// we must load the engine associated to the current 'JScript N' instance,
// otherwise pick up the engine at second place in method's signature.
//
if (in_function)
ig.Emit (OpCodes.Ldarg_1);
else {
ig.Emit (OpCodes.Ldarg_0);
ig.Emit (OpCodes.Ldfld, typeof (ScriptObject).GetField ("engine"));
}
}
internal static void emit_get_default_this (ILGenerator ig, bool inFunction)
{
CodeGenerator.load_engine (inFunction, ig);
ig.Emit (OpCodes.Call, typeof (VsaEngine).GetMethod ("ScriptObjectStackTop"));
Type iact_obj = typeof (IActivationObject);
ig.Emit (OpCodes.Castclass, iact_obj);
ig.Emit (OpCodes.Callvirt, iact_obj.GetMethod ("GetDefaultThisObject"));
}
internal static object variable_defined_in_current_scope (string id)
{
return TypeManager.defined_in_current_scope (id);
}
internal static void load_local_vars (ILGenerator ig, bool inFunction)
{
int n = 0;
Type stack_frame = typeof (StackFrame);
CodeGenerator.load_engine (inFunction, ig);
ig.Emit (OpCodes.Call, typeof (VsaEngine).GetMethod ("ScriptObjectStackTop"));
ig.Emit (OpCodes.Castclass, stack_frame);
ig.Emit (OpCodes.Ldfld, stack_frame.GetField ("localVars"));
object [] locals = TypeManager.CurrentLocals;
n = locals != null ? locals.Length : 0;
object local = null;
for (int i = 0; i < n; i++) {
local = locals [i];
if (local is LocalBuilder) {
ig.Emit (OpCodes.Dup);
ig.Emit (OpCodes.Ldc_I4, i);
ig.Emit (OpCodes.Ldloc, (LocalBuilder) local);
ig.Emit (OpCodes.Stelem_Ref);
}
}
ig.Emit (OpCodes.Pop);
}
internal static void locals_to_stack_frame (ILGenerator ig, int lexical_depth, int lexical_difference, bool inFunction)
{
CodeGenerator.emit_parents (inFunction, lexical_difference, ig);
ig.Emit (OpCodes.Dup);
Type stack_frame = typeof (StackFrame);
ig.Emit (OpCodes.Castclass, stack_frame);
ig.Emit (OpCodes.Ldfld, stack_frame.GetField ("localVars"));
DictionaryEntry [] locals = TypeManager.LocalsAtDepth (lexical_depth);
int i = 0;
foreach (DictionaryEntry entry in locals) {
if (entry.Value is LocalBuilder) {
ig.Emit (OpCodes.Dup);
ig.Emit (OpCodes.Ldc_I4, i);
ig.Emit (OpCodes.Ldloc, (short) i++);
ig.Emit (OpCodes.Stelem_Ref);
}
}
ig.Emit (OpCodes.Pop);
//
// FIXME: what determine this?
//
ig.Emit (OpCodes.Call, typeof (ScriptObject).GetMethod ("GetParent"));
ig.Emit (OpCodes.Pop);
}
internal static void emit_parents (bool inFunction, int lexical_difference, ILGenerator ig)
{
CodeGenerator.load_engine (inFunction, ig);
ig.Emit (OpCodes.Call, typeof (VsaEngine).GetMethod ("ScriptObjectStackTop"));
for (int i = 0; i < lexical_difference; i++)
ig.Emit (OpCodes.Call, typeof (ScriptObject).GetMethod ("GetParent"));
}
internal static void EmitBox (ILGenerator ig, object obj)
{
if (obj == null)
return;
Type box_type = GetBoxType (obj);
if (box_type != null)
ig.Emit (OpCodes.Box, box_type);
}
internal static void EmitConv (ILGenerator ig, Type type)
{
TypeCode tc = Type.GetTypeCode (type);
switch (tc) {
case TypeCode.Double:
ig.Emit (OpCodes.Conv_R8);
break;
default:
throw new NotImplementedException ();
}
}
private static Type GetBoxType (object obj)
{
if (obj is ByteConstant || obj is ShortConstant || obj is IntConstant)
return typeof (int);
else if (obj is LongConstant)
return typeof (long);
else if (obj is FloatConstant || obj is DoubleConstant)
return typeof (double);
else if (obj is BooleanConstant || obj is StrictEquality || obj is Equality)
return typeof (bool);
else if (obj is Unary) {
Unary unary = (Unary) obj;
JSToken oper = unary.oper;
AST operand = unary.operand;
if (oper == JSToken.Minus || oper == JSToken.Plus ||
oper == JSToken.Increment || oper == JSToken.Decrement ||
oper == JSToken.BitwiseNot)
return GetBoxType (operand);
else if (oper == JSToken.LogicalNot || oper == JSToken.Delete)
return typeof (bool);
} else if (obj is Identifier) {
Identifier id = (Identifier) obj;
string name = id.name.Value;
if (name == "NaN" || name == "Infinity")
return typeof (double);
} else if (obj is Binary) {
Binary bin = obj as Binary;
if (bin.AccessField && !bin.LateBinding) {
MemberInfo binding = bin.Binding;
MemberTypes member_type = binding.MemberType;
if (member_type == MemberTypes.Property)
return ((PropertyInfo) binding).PropertyType;
}
} else if (obj is Relational) {
Relational re = (Relational) obj;
if (re.op == JSToken.In)
return typeof (bool);
}
return null;
}
internal static void emit_default_value (ILGenerator ig, ParameterInfo param)
{
Type param_type = param.ParameterType;
if (param_type == typeof (Double))
ig.Emit (OpCodes.Ldc_R8, GlobalObject.NaN);
else if (param_type == typeof (object))
ig.Emit (OpCodes.Ldsfld, typeof (Missing).GetField ("Value"));
else
throw new NotImplementedException ();
}
internal static void EmitRelationalComp (ILGenerator ig, Relational re)
{
JSToken op = re.op;
if (op == JSToken.Instanceof)
return;
else if (op == JSToken.In) {
ig.Emit (OpCodes.Box, typeof (bool));
return;
}
Label true_case = ig.DefineLabel ();
Label box_to_bool = ig.DefineLabel ();
ig.Emit (OpCodes.Ldc_I4_0);
ig.Emit (OpCodes.Conv_R8);
OpCode opcode;
switch (op) {
case JSToken.LessThan:
opcode = OpCodes.Blt;
break;
case JSToken.LessThanEqual:
opcode = OpCodes.Ble;
break;
case JSToken.GreaterThan:
opcode = OpCodes.Bgt;
break;
case JSToken.GreaterThanEqual:
opcode = OpCodes.Bge;
break;
default:
Console.WriteLine (re.Location.LineNumber);
throw new NotImplementedException ();
}
ig.Emit (opcode, true_case);
ig.Emit (OpCodes.Ldc_I4_0);
ig.Emit (OpCodes.Br, box_to_bool);
ig.MarkLabel (true_case);
ig.Emit (OpCodes.Ldc_I4_1);
ig.MarkLabel (box_to_bool);
ig.Emit (OpCodes.Box, typeof (bool));
}
internal static string GetTypeName (string srcName)
{
return (string) source_file_to_type [srcName];
}
internal static void EmitAssignAsExp (EmitContext ec, AST ast)
{
Assign assign = (Assign) ast;
LocalBuilder builder = assign.EmitAndReturnBuilder (ec);
ec.ig.Emit (OpCodes.Ldloc, builder);
}
}
}

Просмотреть файл

@ -0,0 +1,73 @@
//
// Context.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class Context {
internal DocumentContext Document;
public int EndColumn {
get { throw new NotImplementedException (); }
}
public int EndLine {
get { throw new NotImplementedException (); }
}
public int EndPosition {
get { throw new NotImplementedException (); }
}
public string GetCode ()
{
throw new NotImplementedException ();
}
public JSToken GetToken ()
{
throw new NotImplementedException ();
}
public int StartColumn {
get { throw new NotImplementedException (); }
}
public int StartLine {
get { throw new NotImplementedException (); }
}
public int StartPosition {
get { throw new NotImplementedException (); }
}
}
}

Просмотреть файл

@ -0,0 +1,44 @@
//
// ContinueOutOfFinally.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public sealed class ContinueOutOfFinally : ApplicationException
{
public int target;
public ContinueOutOfFinally (int target)
{
this.target = target;
}
}
}

Просмотреть файл

@ -0,0 +1,508 @@
//
// Convert.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
// (C) 2005, Novell Inc, (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Diagnostics;
using Microsoft.JScript.Vsa;
using System.Globalization;
using System.Collections;
namespace Microsoft.JScript {
public sealed class Convert {
public static bool IsBadIndex (AST ast)
{
throw new NotImplementedException ();
}
internal static bool IsBoolean (object value)
{
IConvertible ic = value as IConvertible;
TypeCode tc = Convert.GetTypeCode (value, ic);
switch (tc) {
case TypeCode.Boolean:
return true;
case TypeCode.Object:
if (value is BooleanObject)
return true;
break;
}
return false;
}
internal static bool IsNumber (object value)
{
IConvertible ic = value as IConvertible;
TypeCode tc = Convert.GetTypeCode (value, ic);
switch (tc) {
case TypeCode.Char:
case TypeCode.Byte:
case TypeCode.SByte:
case TypeCode.UInt16:
case TypeCode.UInt32:
case TypeCode.Int16:
case TypeCode.Int32:
case TypeCode.Single:
case TypeCode.Double:
return true;
case TypeCode.Object:
if (value is NumberObject)
return true;
break;
}
return false;
}
internal static bool IsString (object value)
{
IConvertible ic = value as IConvertible;
TypeCode tc = Convert.GetTypeCode (value, ic);
switch (tc) {
case TypeCode.String:
return true;
case TypeCode.Object:
if (value is StringObject)
return true;
break;
}
return false;
}
internal static bool IsNumberTypeCode (TypeCode tc)
{
switch (tc) {
case TypeCode.Byte:
case TypeCode.Char:
case TypeCode.Decimal:
case TypeCode.Double:
case TypeCode.Int16:
case TypeCode.Int32:
case TypeCode.Int64:
case TypeCode.SByte:
case TypeCode.Single:
case TypeCode.UInt16:
case TypeCode.UInt32:
case TypeCode.UInt64:
return true;
default:
return false;
}
}
internal static bool IsFloatTypeCode (TypeCode tc)
{
switch (tc) {
case TypeCode.Decimal:
case TypeCode.Double:
case TypeCode.Single:
return true;
default:
return false;
}
}
public static double CheckIfDoubleIsInteger (double d)
{
if (d == Math.Round (d))
return d;
throw new NotImplementedException ();
}
public static Single CheckIfSingleIsInteger (Single s)
{
if (s == Math.Round (s))
return s;
throw new NotImplementedException ();
}
public static object Coerce (object value, object type)
{
throw new NotImplementedException ();
}
public static object CoerceT (object value, Type t, bool explicitOK)
{
throw new NotImplementedException ();
}
public static object Coerce2 (object value, TypeCode target,
bool truncationPermitted)
{
throw new NotImplementedException ();
}
[DebuggerStepThroughAttribute]
[DebuggerHiddenAttribute]
public static void ThrowTypeMismatch (object val)
{
throw new NotImplementedException ();
}
internal static object ToPrimitive (object value, Type hint)
{
IConvertible ic = value as IConvertible;
TypeCode tc = Convert.GetTypeCode (value, ic);
switch (tc) {
case TypeCode.Object:
if (value is JSObject)
return ((JSObject) value).GetDefaultValue (hint);
else if (value is GlobalScope)
return "[object global]";
else {
Console.WriteLine ("value = {0} ({1})", value, value.GetType ());
throw new NotImplementedException ();
}
default:
return value;
}
}
public static bool ToBoolean (double d)
{
return Convert.ToBoolean (d, true);
}
[DebuggerStepThroughAttribute]
[DebuggerHiddenAttribute]
public static bool ToBoolean (object value)
{
return Convert.ToBoolean (value, true);
}
[DebuggerStepThroughAttribute]
[DebuggerHiddenAttribute]
public static bool ToBoolean (object value, bool explicitConversion)
{
IConvertible ic = value as IConvertible;
TypeCode tc = Convert.GetTypeCode (value, ic);
switch (tc) {
case TypeCode.Empty:
case TypeCode.DBNull:
return false;
case TypeCode.Boolean:
return ic.ToBoolean (null);
case TypeCode.String:
string str = ic.ToString (null);
return str.Length != 0;
case TypeCode.Object:
return true;
default:
if (IsNumberTypeCode (tc)) {
double num = ic.ToDouble (null);
return !double.IsNaN (num) && (num != 0.0);
}
Console.WriteLine ("\nToBoolean: tc = {0}", tc);
break;
}
throw new NotImplementedException ();
}
public static object ToForInObject (object value, VsaEngine engine)
{
if (value == null)
throw new NullReferenceException ("value is null");
return GlobalObject.Object.CreateInstance (value);
}
public static int ToInt32 (object value)
{
IConvertible ic = value as IConvertible;
TypeCode tc = Convert.GetTypeCode (value, ic);
switch (tc) {
case TypeCode.Empty:
case TypeCode.DBNull:
return 0;
case TypeCode.String:
return (int) Math.Floor (GlobalObject.parseFloat (ic.ToString ()));
default:
if (IsFloatTypeCode (tc))
return (int) Math.Floor ((double) value);
else if (IsNumberTypeCode (tc))
return (int) value;
Console.WriteLine ("\nToInt32: value.GetType = {0}", value.GetType ());
break;
}
throw new NotImplementedException ();
}
internal static uint ToUint16 (object value)
{
double val = Convert.ToNumber (value);
if (Double.IsInfinity (val) || double.IsNaN (val))
return 0;
else
return (uint) (val % 65536);
}
internal static uint ToUint32 (object value)
{
double val = Convert.ToNumber (value);
if (Double.IsInfinity (val) || double.IsNaN (val))
return 0;
else
return (uint) (val % 4294967296);
}
public static double ToNumber (object value)
{
IConvertible ic = value as IConvertible;
TypeCode tc = Convert.GetTypeCode (value, ic);
switch (tc) {
case TypeCode.Empty:
return Double.NaN;
case TypeCode.DBNull:
return 0;
case TypeCode.Boolean:
if (ic.ToBoolean (null))
return 1;
return 0;
case TypeCode.String:
return ToNumber ((string) value);
case TypeCode.Object:
if (value is NumberObject)
return ((NumberObject) value).value;
else if (value is BooleanObject)
return ((BooleanObject) value).value ? 1 : 0;
else if (value is StringObject)
return ToNumber (((StringObject) value).value);
else if (value is DateObject)
return ((DateObject) value).ms;
else if (value is ArrayObject) {
ArrayObject ary = (ArrayObject) value;
Hashtable elems = ary.elems;
uint n = (uint) ary.length;
uint i = n - 1;
if (elems.ContainsKey (i))
return Convert.ToNumber (elems [i]);
}
return Double.NaN;
default:
if (IsFloatTypeCode (tc))
return (double) value;
else if (IsNumberTypeCode (tc))
return ic.ToDouble (null);
break;
}
Console.WriteLine ("\nToNumber: value.GetType = {0}", value.GetType ());
throw new NotImplementedException ();
}
public static double ToNumber (string str)
{
if (str == "")
return 0;
if (str.IndexOfAny (new char [] { 'x', 'X' }) != -1)
return GlobalObject.parseInt (str, null);
else
return GlobalObject.parseFloat (str);
}
public static object ToNativeArray (object value, RuntimeTypeHandle handle)
{
ArrayObject ary = null;
if (value is ArrayObject)
ary = (ArrayObject) value;
else
ary = Convert.ToArray (value);
Hashtable elems = ary.elems;
uint n = (uint) ary.length;
object [] result = new object [n];
for (uint i = 0; i < n; i++)
result [i] = elems [i];
return result;
}
private static ArrayObject ToArray (object value)
{
throw new Exception ("The method or operation is not implemented.");
}
public static object ToObject (object value, VsaEngine engine)
{
IConvertible ic = value as IConvertible;
TypeCode tc = Convert.GetTypeCode (value, ic);
switch (tc) {
case TypeCode.DBNull:
case TypeCode.Empty:
throw new JScriptException (JSError.TypeMismatch, "value is null or undefined");
case TypeCode.Boolean:
return new BooleanObject (ic.ToBoolean (null));
case TypeCode.String:
return new StringObject (ic.ToString (null));
case TypeCode.Object:
return value;
default:
if (IsNumberTypeCode (tc))
return new NumberObject (ic.ToDouble (null));
Console.WriteLine ("\nToObject: value.GetType = {0}", value.GetType ());
break;
}
throw new NotImplementedException ();
}
public static object ToObject2 (object value, VsaEngine engine)
{
return ToObject (value, engine);
}
internal static RegExpObject ToRegExp (object regExp)
{
if (regExp is RegExpObject)
return (RegExpObject) regExp;
else
return RegExpConstructor.Ctr.Invoke (regExp);
}
internal static string ToString (object obj)
{
return Convert.ToString (obj, true);
}
[DebuggerStepThroughAttribute]
[DebuggerHiddenAttribute]
public static string ToString (object value, bool explicitOK)
{
IConvertible ic = value as IConvertible;
TypeCode tc = Convert.GetTypeCode (value, ic);
switch (tc) {
case TypeCode.Empty:
return "undefined";
case TypeCode.DBNull:
return "null";
case TypeCode.Boolean:
bool r = (bool) value;
if (r)
return "true";
else
return "false";
case TypeCode.Char:
return ic.ToInt16 (null).ToString ();
case TypeCode.String:
return ic.ToString (null);
case TypeCode.Object:
if (value is StringObject)
return ((StringObject) value).value;
else if (value is ScriptObject) {
ScriptObject obj_value = (ScriptObject) value;
if (obj_value.HasMethod ("toString"))
return (string) obj_value.CallMethod ("toString");
else
return (string) ObjectPrototype.smartToString ((JSObject) obj_value);
}
Console.WriteLine ("value.GetType = {0}", value.GetType ());
throw new NotImplementedException ();
default:
if (IsNumberTypeCode (tc)) {
double val = ic.ToDouble (null);
return ToString (val);
}
Console.WriteLine ("tc = {0}", tc);
throw new NotImplementedException ();
}
}
public static string ToString (bool b)
{
return b ? "true" : "false";
}
public static string ToString (double d)
{
double exp = Math.Log10 (d);
if (exp > -6 && exp < 1)
return d.ToString ("0.##########", CultureInfo.InvariantCulture);
else
return d.ToString ("g21", CultureInfo.InvariantCulture);
}
//
// Utility methods
//
internal static TypeCode GetTypeCode (object obj, IConvertible ic)
{
if (obj == null)
return TypeCode.Empty;
else if (ic == null)
return TypeCode.Object;
else
return ic.GetTypeCode ();
}
}
}

Просмотреть файл

@ -0,0 +1,748 @@
//
// DateConstructor.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class DateConstructor : ScriptFunction {
internal const double SECONDS_PER_MINUTE = 60.0;
internal const double HOURS_PER_DAY = 24.0;
internal const double MINUTES_PER_HOUR = 60.0;
internal const double MINUTES_PER_DAY = HOURS_PER_DAY * MINUTES_PER_HOUR;
internal const double SECONDS_PER_HOUR = MINUTES_PER_HOUR * SECONDS_PER_MINUTE;
internal const double SECONDS_PER_DAY = MINUTES_PER_DAY * SECONDS_PER_MINUTE;
internal const double MS_PER_SECOND = 1000.0;
internal const double MS_PER_MINUTE = SECONDS_PER_MINUTE * MS_PER_SECOND;
internal const double MS_PER_HOUR = SECONDS_PER_HOUR * MS_PER_SECOND;
internal const double MS_PER_DAY = SECONDS_PER_DAY * MS_PER_SECOND;
internal static DateConstructor Ctr = new DateConstructor ();
internal DateConstructor ()
{
_prototype = DatePrototype.Proto;
_length = 7;
name = "Date";
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasVarArgs)]
public new DateObject CreateInstance (params object [] args)
{
int argc = args.Length;
double year = 0, month = 0, date = 1, hours = 0, minutes = 0, seconds = 0, ms = 0;
double result;
if (argc == 0) {
DateTime now = DateTime.Now;
year = now.Year;
month = now.Month - 1;
date = now.Day;
hours = now.Hour;
minutes = now.Minute;
seconds = now.Second;
ms = now.Millisecond;
goto done;
} else if (argc == 1) {
object value = Convert.ToPrimitive (args [0], null);
if (value.GetType () == typeof (string))
result = parse ((string) value);
else {
result = Convert.ToNumber (value);
if (Double.IsNaN (result) || Double.IsInfinity (result))
result = Double.NaN;
else
result = Math.Round (result);
}
return new DateObject (result);
}
year = Convert.ToNumber (args [0]);
--argc;
month = Convert.ToNumber (args [1]);
if (--argc == 0)
goto done;
date = Convert.ToNumber (args [2]);
if (--argc == 0)
goto done;
hours = Convert.ToNumber (args [3]);
if (--argc == 0)
goto done;
minutes = Convert.ToNumber (args [4]);
if (--argc == 0)
goto done;
seconds = Convert.ToNumber (args [5]);
if (--argc == 0)
goto done;
ms = Convert.ToNumber (args [6]);
done:
if (!Double.IsNaN (year) && year >= 0 && year <= 99)
year += 1900;
double utc_off = 0;
try {
DateTime dt = new DateTime ((int) year, (int) month + 1, (int) date,
(int) hours, (int) minutes, (int) seconds);
utc_off = TimeZone.CurrentTimeZone.GetUtcOffset (dt).TotalMilliseconds;
} catch (ArgumentOutOfRangeException) { /* OK */ }
result = msec_from_date (year, month, date, hours, minutes, seconds, ms - utc_off);
return new DateObject (result);
}
public String Invoke ()
{
return DatePrototype.toString (CreateInstance ());
}
[JSFunctionAttribute(0, JSBuiltin.Date_parse)]
public static double parse (String str)
{
int year = -1;
int mon = -1;
int mday = -1;
int hour = -1;
int min = -1;
int sec = -1;
char c = '0';
char si = '0';
int i = 0;
int n = -1;
double tzoffset = -1;
char prevc = '0';
int limit = 0;
bool seenplusminus = false;
limit = str.Length;
while (i < limit) {
c = str [i];
i++;
if (c <= ' ' || c == ',' || c == '-') {
if (i < limit) {
si = str [i];
if (c == '-' && '0' <= si && si <= '9')
prevc = c;
}
continue;
}
if (c == '(') { /* comments) */
int depth = 1;
while (i < limit) {
c = str [i];
i++;
if (c == '(')
depth++;
else if (c == ')')
if (--depth <= 0)
break;
}
continue;
}
if ('0' <= c && c <= '9') {
n = c - '0';
while (i < limit && '0' <= (c = str [i]) && c <= '9') {
n = n * 10 + c - '0';
i++;
}
/* allow TZA before the year, so
* 'Wed Nov 05 21:49:11 GMT-0800 1997'
* works */
/* uses of seenplusminus allow : in TZA, so Java
* no-timezone style of GMT+4:30 works
*/
if ((prevc == '+' || prevc == '-') /* && year >= 0 */) {
/* make ':' case below change tzoffset */
seenplusminus = true;
/* offset */
if (n < 24)
n = n * 60; /* EG. "GMT-3" */
else
n = n % 100 + n / 100 * 60; /* eg "GMT-0430" */
if (prevc == '+') /* plus means east of GMT */
n = -n;
if (tzoffset != 0 && tzoffset != -1)
return Double.NaN;
tzoffset = n;
} else if (n >= 70 || (prevc == '/' && mon >= 0 && mday >= 0 && year < 0)) {
if (year >= 0)
return Double.NaN;
else if (c <= ' ' || c == ',' || c == '/' || i >= limit)
year = n < 100 ? n + 1900 : n;
else
return Double.NaN;
} else if (c == ':') {
if (hour < 0)
hour = /* byte */ n;
else if (min < 0)
min = /* byte */ n;
else
return Double.NaN;
} else if (c == '/') {
if (mon < 0)
mon = /* byte */ n - 1;
else if (mday < 0)
mday = /* byte */ n;
else
return Double.NaN;
} else if (i < limit && c != ',' && c > ' ' && c != '-')
return Double.NaN;
else if (seenplusminus && n < 60) { /* handle GMT-3:30 */
if (tzoffset < 0)
tzoffset -= n;
else
tzoffset += n;
} else if (hour >= 0 && min < 0)
min = /* byte */ n;
else if (min >= 0 && sec < 0)
sec = /* byte */ n;
else if (mday < 0)
mday = /* byte */ n;
else
return Double.NaN;
prevc = '0';
} else if (c == '/' || c == ':' || c == '+' || c == '-')
prevc = c;
else {
int st = i - 1;
while (i < limit) {
c = str [i];
if (!(('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')))
break;
i++;
}
int letterCount = i - st;
if (letterCount < 2)
return Double.NaN;
/*
* Use ported code from jsdate.c rather than the locale-specific
* date-parsing code from Java, to keep js and rhino consistent.
* Is this the right strategy?
*/
string wtb = "am;pm;"
+ "monday;tuesday;wednesday;thursday;friday;"
+ "saturday;sunday;"
+ "january;february;march;april;may;june;"
+ "july;august;september;october;november;december;"
+ "gmt;ut;utc;est;edt;cst;cdt;mst;mdt;pst;pdt;";
int index = 0;
for (int wtbOffset = 0;;) {
int wtbNext = wtb.IndexOf (';', wtbOffset);
if (wtbNext < 0)
return Double.NaN;
if (String.Compare (wtb, wtbOffset, str, st, letterCount, true) == 0)
break;
wtbOffset = wtbNext + 1;
++index;
}
if (index < 2) {
/*
* AM/PM. Count 12:30 AM as 00:30, 12:30 PM as
* 12:30, instead of blindly adding 12 if PM.
*/
if (hour > 12 || hour < 0)
return Double.NaN;
else if (index == 0) {
// AM
if (hour == 12)
hour = 0;
} else {
// PM
if (hour != 12)
hour += 12;
}
} else if ((index -= 2) < 7) {
// ignore week days
} else if ((index -= 7) < 12) {
// month
if (mon < 0)
mon = index;
else
return Double.NaN;
} else {
index -= 12;
// timezones
switch (index) {
case 0 /* gmt */:
tzoffset = 0;
break;
case 1 /* ut */:
tzoffset = 0;
break;
case 2 /* utc */:
tzoffset = 0;
break;
case 3 /* est */:
tzoffset = 5 * 60;
break;
case 4 /* edt */:
tzoffset = 4 * 60;
break;
case 5 /* cst */:
tzoffset = 6 * 60;
break;
case 6 /* cdt */:
tzoffset = 5 * 60;
break;
case 7 /* mst */:
tzoffset = 7 * 60;
break;
case 8 /* mdt */:
tzoffset = 6 * 60;
break;
case 9 /* pst */:
tzoffset = 8 * 60;
break;
case 10 /* pdt */:
tzoffset = 7 * 60;
break;
}
}
}
}
if (year < 0 || mon < 0 || mday < 0)
return Double.NaN;
if (sec < 0)
sec = 0;
if (min < 0)
min = 0;
if (hour < 0)
hour = 0;
double msec = msec_from_date (year, mon, mday, hour, min, sec, 0);
if (tzoffset == -1) { // no time zone specified, have to use local
DateTime dt = new DateTime (year, mon + 1, mday, hour, min, sec);
tzoffset = TimeZone.CurrentTimeZone.GetUtcOffset (dt).TotalHours;
}
return msec + tzoffset * MS_PER_MINUTE;
}
//
// find UTC time from given date... no 1900 correction!
//
internal static double msec_from_date (double year, double mon, double mday, double hour, double min, double sec, double msec)
{
double day, time, result;
day = MakeDay (year, mon, mday);
time = MakeTime (hour, min, sec, msec);
result = MakeDate (day, time);
return result;
}
internal static double MakeDay (double year, double month, double date)
{
year += Math.Floor (month / 12);
month = DateMod (month, 12);
if (month < 0)
month += 12;
double year_day = Math.Floor (TimeFromYear (year) / MS_PER_DAY);
double month_day = DayFromMonth ((int) month, (int) year);
return year_day + month_day + date - 1;
}
internal static double MakeTime (double hour, double min, double sec, double ms)
{
return ((hour * MINUTES_PER_HOUR + min) * SECONDS_PER_MINUTE + sec) * MS_PER_SECOND + ms;
}
internal static double MakeDate (double day, double time)
{
return day * MS_PER_DAY + time;
}
internal static double TimeFromYear (double y)
{
return DayFromYear (y) * MS_PER_DAY;
}
internal static double DayFromYear (double y)
{
return ((365 * ((y) - 1970) +
Math.Floor (((y) - 1969) / 4.0) -
Math.Floor (((y) - 1901) / 100.0) +
Math.Floor (((y) - 1601) / 400.0)));
}
internal static double DayFromMonth (int m, int year)
{
int day = m * 30;
if (m >= 7)
day += m / 2 - 1;
else if (m >= 2)
day += (m - 1) / 2 - 1;
else
day += m;
if (m >= 2 && IsLeapYear (year))
++day;
return day;
}
internal static bool IsLeapYear (int year)
{
return DateMod (year, 4) == 0 && (DateMod (year, 100) != 0 || DateMod (year, 400) == 0);
}
[JSFunctionAttribute(0, JSBuiltin.Date_UTC)]
public static double UTC (Object year, Object month, Object date,
Object hours, Object minutes, Object seconds, Object ms)
{
double _year = 0, _month = 0, _date = 1, _hours = 0, _minutes = 0, _seconds = 0, _ms = 0;
if (year == null && month == null) {
DateTime now = DateTime.Now;
_year = now.Year;
_month = now.Month - 1;
_date = now.Day;
_hours = now.Hour;
_minutes = now.Minute;
_seconds = now.Second;
_ms = now.Millisecond;
_ms -= TimeZone.CurrentTimeZone.GetUtcOffset (now).TotalMilliseconds;
goto done;
}
_year = Convert.ToNumber (year);
if (month != null)
_month = Convert.ToNumber (month);
if (date != null)
_date = Convert.ToNumber (date);
if (hours != null)
_hours = Convert.ToNumber (hours);
if (minutes != null)
_minutes = Convert.ToNumber (minutes);
if (seconds != null)
_seconds = Convert.ToNumber (seconds);
if (ms != null)
_ms = Convert.ToNumber (ms);
if (!Double.IsNaN (_year) && _year >= 0 && _year <= 99)
_year += 1900;
done:
return TimeClip (msec_from_date (_year, _month, _date, _hours, _minutes, _seconds, _ms));
}
internal static double TimeClip (double p)
{
if (Double.IsInfinity (p) || Double.IsNaN (p) || Math.Abs (p) > 8.64e15)
return Double.NaN;
else
return p;
}
/* Ported from Rhino. */
internal static int YearFromTime (double t)
{
int lo = (int) Math.Floor ((t / MS_PER_DAY) / 366) + 1970;
int hi = (int) Math.Floor ((t / MS_PER_DAY) / 365) + 1970;
int mid;
/* above doesn't work for negative dates... */
if (hi < lo) {
int temp = lo;
lo = hi;
hi = temp;
}
/* Use a simple binary search algorithm to find the right
year. This seems like brute force... but the computation
of hi and lo years above lands within one year of the
correct answer for years within a thousand years of
1970; the loop below only requires six iterations
for year 270000. */
while (hi > lo) {
mid = (hi + lo) / 2;
if (TimeFromYear (mid) > t)
hi = mid - 1;
else {
lo = mid + 1;
if (TimeFromYear (lo) > t)
return mid;
}
}
return lo;
}
internal static int MonthFromTime (double t)
{
int year_days = DayWithinYear (t);
year_days -= 31;
if (year_days < 0)
return 0;
if (InLeapYear (t))
year_days--;
year_days -= 28;
if (year_days < 0)
return 1;
year_days -= 31;
if (year_days < 0)
return 2;
year_days -= 30;
if (year_days < 0)
return 3;
year_days -= 31;
if (year_days < 0)
return 4;
year_days -= 30;
if (year_days < 0)
return 5;
year_days -= 31;
if (year_days < 0)
return 6;
year_days -= 31;
if (year_days < 0)
return 7;
year_days -= 30;
if (year_days < 0)
return 8;
year_days -= 31;
if (year_days < 0)
return 9;
year_days -= 30;
if (year_days < 0)
return 10;
return 11;
}
private static bool InLeapYear (double t)
{
return DaysInYear (YearFromTime (t)) == 366;
}
private static int DaysInYear (int y)
{
if (DateMod (y, 4) != 0)
return 365;
else if (DateMod (y, 100) != 0)
return 366;
else if (DateMod (y, 400) != 0)
return 365;
else
return 366;
}
private static int DayWithinYear (double t)
{
int day = (int) Math.Floor (t / MS_PER_DAY);
int year_day = (int) DayFromYear (YearFromTime (t));
return day - year_day;
}
internal static int DateFromTime (double t)
{
int month = MonthFromTime (t);
int result = DayWithinYear (t) + 1;
if (month == 0)
return result;
result -= 31;
if (--month == 0)
return result;
if (InLeapYear (t))
result--;
result -= 28;
if (--month == 0)
return result;
result -= 31;
if (--month == 0)
return result;
result -= 30;
if (--month == 0)
return result;
result -= 31;
if (--month == 0)
return result;
result -= 30;
if (--month == 0)
return result;
result -= 31;
if (--month == 0)
return result;
result -= 31;
if (--month == 0)
return result;
result -= 30;
if (--month == 0)
return result;
result -= 31;
if (--month == 0)
return result;
result -= 30;
return result;
}
internal static int WeekDay (double t)
{
int day = (int) Math.Floor (t / MS_PER_DAY);
return (int) DateMod (day + 4, 7);
}
internal static int HourFromTime (double t)
{
int hour = (int) Math.Floor (t / MS_PER_HOUR);
return (int) DateMod (hour, (int) HOURS_PER_DAY);
}
internal static int MinFromTime (double t)
{
int min = (int) Math.Floor (t / MS_PER_MINUTE);
return (int) DateMod (min, (int) MINUTES_PER_HOUR);
}
internal static int SecFromTime (double t)
{
int sec = (int) Math.Floor (t / MS_PER_SECOND);
return (int) DateMod (sec, (int) SECONDS_PER_MINUTE);
}
internal static double DateMod (double x, double y)
{
return x - (y * Math.Floor (x / y));
}
internal static double msFromTime (double t)
{
return DateMod (t, MS_PER_SECOND);
}
internal static double LocalTime (double t)
{
int year = YearFromTime (t);
int month = MonthFromTime (t);
int date = DateFromTime (t);
int hours = HourFromTime (t);
int minutes = MinFromTime (t);
int seconds = SecFromTime (t);
double utc_off = 0;
try {
DateTime dt = new DateTime (year, month + 1, date, hours, minutes, seconds);
utc_off = TimeZone.CurrentTimeZone.GetUtcOffset (dt).TotalMilliseconds;
} catch (ArgumentOutOfRangeException) { /* OK */ }
return t + utc_off;
}
internal static double ToUTC (double t)
{
int year = YearFromTime (t);
int month = MonthFromTime (t);
int date = DateFromTime (t);
int hours = HourFromTime (t);
int minutes = MinFromTime (t);
int seconds = SecFromTime (t);
DateTime dt = new DateTime (year, month + 1, date, hours, minutes, seconds);
return t - TimeZone.CurrentTimeZone.GetUtcOffset (dt).TotalMilliseconds;
}
}
}

Просмотреть файл

@ -0,0 +1,41 @@
//
// DateObject.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Microsoft.JScript {
public class DateObject : JSObject
{
internal double ms;
internal DateObject (double ms)
{
this.ms = ms;
}
}
}

Просмотреть файл

@ -0,0 +1,812 @@
//
// DataPrototype.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Globalization;
namespace Microsoft.JScript {
public class DatePrototype : DateObject
{
internal DatePrototype ()
: base (Double.NaN)
{
}
internal static DatePrototype Proto = new DatePrototype ();
public static DateConstructor constructor {
get { return DateConstructor.Ctr; }
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getDate)]
public static double getDate (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.DateFromTime (DateConstructor.LocalTime (val));
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getDay)]
public static double getDay (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.WeekDay (DateConstructor.LocalTime (val));
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getFullYear)]
public static double getFullYear (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.YearFromTime (DateConstructor.LocalTime (val));
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getHours)]
public static double getHours (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.HourFromTime (DateConstructor.LocalTime (val));
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getMilliseconds)]
public static double getMilliseconds (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.msFromTime (DateConstructor.LocalTime (val));
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getMinutes)]
public static double getMinutes (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.MinFromTime (DateConstructor.LocalTime (val));
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getMonth)]
public static double getMonth (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.MonthFromTime (DateConstructor.LocalTime (val));
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getSeconds)]
public static double getSeconds (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.SecFromTime (DateConstructor.LocalTime (val));
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getTime)]
public static double getTime (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
return date.ms;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getTimezoneOffset)]
public static double getTimezoneOffset (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return (val - DateConstructor.LocalTime (val)) / DateConstructor.MS_PER_MINUTE;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getUTCDate)]
public static double getUTCDate (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.DateFromTime (val);
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getUTCDay)]
public static double getUTCDay (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.WeekDay (val);
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getUTCFullYear)]
public static double getUTCFullYear (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.YearFromTime (val);
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getUTCHours)]
public static double getUTCHours (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.HourFromTime (val);
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getUTCMilliseconds)]
public static double getUTCMilliseconds (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.msFromTime (val);
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getUTCMinutes)]
public static double getUTCMinutes (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.MinFromTime (val);
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getUTCMonth)]
public static double getUTCMonth (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.MonthFromTime (val);
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getUTCSeconds)]
public static double getUTCSeconds (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double val = date.ms;
if (Double.IsNaN (val))
return Double.NaN;
else
return DateConstructor.SecFromTime (val);
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getVarDate)]
public static object getVarDate (object thisObj)
{
//
// FIXME: This seems to handle the most simple
// cases, but surely we need to do more
// to comply with Microsoft's implementation.
//
return thisObj;
}
//
// Note: This method is obsolete, but users might
// accidently use it instead of getFullYear(). The
// standard says to return the year - 1900 (likely for
// compatibility), but in this case not confusing the
// user's expectations is more important than not
// breaking obsolete code.
//
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_getYear)]
public static double getYear (object thisObj)
{
return getFullYear (thisObj);
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_setDate)]
public static double setDate (object thisObj, double ddate)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double t = DateConstructor.LocalTime (date.ms);
double day = DateConstructor.MakeDay ((double) DateConstructor.YearFromTime (t),
(double) DateConstructor.MonthFromTime (t), ddate);
double new_val = DateConstructor.ToUTC (DateConstructor.MakeDate (day, t % DateConstructor.MS_PER_DAY));
date.ms = DateConstructor.TimeClip (new_val);
return date.ms;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_setFullYear)]
public static double setFullYear (object thisObj, double dyear,
object month, object date)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject dt = (DateObject) thisObj;
double t = DateConstructor.LocalTime (dt.ms);
if (Double.IsNaN (t))
t = 0;
double new_month;
if (month == null)
new_month = DateConstructor.MonthFromTime (t);
else
new_month = Convert.ToNumber (month);
double new_date;
if (date == null)
new_date = DateConstructor.DateFromTime (t);
else
new_date = Convert.ToNumber (date);
double day = DateConstructor.MakeDay (dyear, new_month, new_date);
double new_val = DateConstructor.ToUTC (DateConstructor.MakeDate (day, t % DateConstructor.MS_PER_DAY));
dt.ms = DateConstructor.TimeClip (new_val);
return dt.ms;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_setHours)]
public static double setHours (object thisObj, double dhour, object min,
object sec, object msec)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double t = DateConstructor.LocalTime (date.ms);
double new_min;
if (min == null)
new_min = DateConstructor.MinFromTime (t);
else
new_min = Convert.ToNumber (min);
double new_sec;
if (sec == null)
new_sec = DateConstructor.SecFromTime (t);
else
new_sec = Convert.ToNumber (sec);
double new_ms;
if (msec == null)
new_ms = DateConstructor.msFromTime (t);
else
new_ms = Convert.ToNumber (msec);
double time = DateConstructor.MakeTime (dhour, new_min, new_sec, new_ms);
double day = Math.Floor (t / DateConstructor.MS_PER_DAY);
double new_val = DateConstructor.ToUTC (DateConstructor.MakeDate (day, time));
date.ms = DateConstructor.TimeClip (new_val);
return date.ms;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_setMinutes)]
public static double setMinutes (object thisObj, double dmin,
object sec, object msec)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double t = DateConstructor.LocalTime (date.ms);
double new_sec;
if (sec == null)
new_sec = DateConstructor.SecFromTime (t);
else
new_sec = Convert.ToNumber (sec);
double new_ms;
if (msec == null)
new_ms = DateConstructor.msFromTime (t);
else
new_ms = Convert.ToNumber (msec);
double time = DateConstructor.MakeTime (DateConstructor.HourFromTime (t), dmin, new_sec, new_ms);
double day = Math.Floor (t / DateConstructor.MS_PER_DAY);
double new_val = DateConstructor.ToUTC (DateConstructor.MakeDate (day, time));
date.ms = DateConstructor.TimeClip (new_val);
return date.ms;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_setMilliseconds)]
public static double setMilliseconds (object thisObj, double dmsec)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double t = DateConstructor.LocalTime (date.ms);
double time = DateConstructor.MakeTime (DateConstructor.HourFromTime (t), DateConstructor.MinFromTime (t),
DateConstructor.SecFromTime (t), dmsec);
double day = Math.Floor (t / DateConstructor.MS_PER_DAY);
double new_val = DateConstructor.ToUTC (DateConstructor.MakeDate (day, time));
date.ms = DateConstructor.TimeClip (new_val);
return date.ms;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_setMonth)]
public static double setMonth (object thisObj, double dmonth,
object date)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject dt = (DateObject) thisObj;
double t = DateConstructor.LocalTime (dt.ms);
double new_date;
if (date == null)
new_date = DateConstructor.DateFromTime (t);
else
new_date = Convert.ToNumber (date);
double day = DateConstructor.MakeDay ((double) DateConstructor.YearFromTime (t),
dmonth, new_date);
double new_val = DateConstructor.ToUTC (DateConstructor.MakeDate (day, t % DateConstructor.MS_PER_DAY));
dt.ms = DateConstructor.TimeClip (new_val);
return dt.ms;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject,
JSBuiltin.Date_setSeconds)]
public static double setSeconds (object thisObj, double dsec, object msec)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double t = DateConstructor.LocalTime (date.ms);
double new_ms;
if (msec == null)
new_ms = DateConstructor.msFromTime (t);
else
new_ms = Convert.ToNumber (msec);
double time = DateConstructor.MakeTime (DateConstructor.HourFromTime (t), DateConstructor.MinFromTime (t),
dsec, new_ms);
double day = Math.Floor (t / DateConstructor.MS_PER_DAY);
double new_val = DateConstructor.ToUTC (DateConstructor.MakeDate (day, time));
date.ms = DateConstructor.TimeClip (new_val);
return date.ms;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_setTime)]
public static double setTime (object thisObj, double time)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
date.ms = DateConstructor.TimeClip (time);
return date.ms;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_setUTCDate)]
public static double setUTCDate (object thisObj, double ddate)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double t = date.ms;
double day = DateConstructor.MakeDay ((double) DateConstructor.YearFromTime (t),
(double) DateConstructor.MonthFromTime (t), ddate);
double new_val = DateConstructor.MakeDate (day, t % DateConstructor.MS_PER_DAY);
date.ms = DateConstructor.TimeClip (new_val);
return date.ms;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_setUTCFullYear)]
public static double setUTCFullYear (object thisObj, double dyear,
object month, object date)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject dt = (DateObject) thisObj;
double t = dt.ms;
if (Double.IsNaN (t))
t = 0;
double new_month;
if (month == null)
new_month = DateConstructor.MonthFromTime (t);
else
new_month = Convert.ToNumber (month);
double new_date;
if (date == null)
new_date = DateConstructor.DateFromTime (t);
else
new_date = Convert.ToNumber (date);
double day = DateConstructor.MakeDay (dyear, new_month, new_date);
double new_val = DateConstructor.MakeDate (day, t % DateConstructor.MS_PER_DAY);
dt.ms = DateConstructor.TimeClip (new_val);
return dt.ms;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_setUTCHours)]
public static double setUTCHours (object thisObj, double dhour,
object min, object sec, object msec)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double t = date.ms;
double new_min;
if (min == null)
new_min = DateConstructor.MinFromTime (t);
else
new_min = Convert.ToNumber (min);
double new_sec;
if (sec == null)
new_sec = DateConstructor.SecFromTime (t);
else
new_sec = Convert.ToNumber (sec);
double new_ms;
if (msec == null)
new_ms = DateConstructor.msFromTime (t);
else
new_ms = Convert.ToNumber (msec);
double time = DateConstructor.MakeTime (dhour, new_min, new_sec, new_ms);
double day = Math.Floor (t / DateConstructor.MS_PER_DAY);
double new_val = DateConstructor.MakeDate (day, time);
date.ms = DateConstructor.TimeClip (new_val);
return date.ms;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_setUTCMinutes)]
public static double setUTCMinutes (object thisObj, double dmin,
object sec, object msec)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double t = date.ms;
double new_sec;
if (sec == null)
new_sec = DateConstructor.SecFromTime (t);
else
new_sec = Convert.ToNumber (sec);
double new_ms;
if (msec == null)
new_ms = DateConstructor.msFromTime (t);
else
new_ms = Convert.ToNumber (msec);
double time = DateConstructor.MakeTime (DateConstructor.HourFromTime (t), dmin, new_sec, new_ms);
double day = Math.Floor (t / DateConstructor.MS_PER_DAY);
double new_val = DateConstructor.MakeDate (day, time);
date.ms = DateConstructor.TimeClip (new_val);
return date.ms;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_setUTCMilliseconds)]
public static double setUTCMilliseconds (object thisObj, double msec)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double t = date.ms;
double time = DateConstructor.MakeTime (DateConstructor.HourFromTime (t), DateConstructor.MinFromTime (t),
DateConstructor.SecFromTime (t), msec);
double day = Math.Floor (t / DateConstructor.MS_PER_DAY);
double new_val = DateConstructor.MakeDate (day, time);
date.ms = DateConstructor.TimeClip (new_val);
return date.ms;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_setUTCMonth)]
public static double setUTCMonth (object thisObj, double dmonth, object date)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject dt = (DateObject) thisObj;
double t = dt.ms;
double new_date;
if (date == null)
new_date = DateConstructor.DateFromTime (t);
else
new_date = Convert.ToNumber (date);
double day = DateConstructor.MakeDay ((double) DateConstructor.YearFromTime (t),
dmonth, new_date);
double new_val = DateConstructor.MakeDate (day, t % DateConstructor.MS_PER_DAY);
dt.ms = DateConstructor.TimeClip (new_val);
return dt.ms;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_setUTCSeconds)]
public static double setUTCSeconds (object thisObj, double dsec, object msec)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date = (DateObject) thisObj;
double t = date.ms;
double new_ms;
if (msec == null)
new_ms = DateConstructor.msFromTime (t);
else
new_ms = Convert.ToNumber (msec);
double time = DateConstructor.MakeTime (DateConstructor.HourFromTime (t), DateConstructor.MinFromTime (t),
dsec, new_ms);
double day = Math.Floor (t / DateConstructor.MS_PER_DAY);
double new_val = DateConstructor.MakeDate (day, time);
date.ms = DateConstructor.TimeClip (new_val);
return date.ms;
}
/* Note: See Note for GetYear() for an explanation why we do not emulate obsolete behavior here. */
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_setYear)]
public static double setYear (object thisObj, double dyear)
{
return setFullYear (thisObj, dyear, null, null);
}
internal const string InvalidDateString = "Invalid Date";
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_toDateString)]
public static string toDateString (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date_obj = (DateObject) thisObj;
double val = date_obj.ms;
double lv = DateConstructor.LocalTime (val);
int year = DateConstructor.YearFromTime (lv);
int month = DateConstructor.MonthFromTime (lv);
int date = DateConstructor.DateFromTime (lv);
DateTime dt;
try {
dt = new DateTime (year, month + 1, date);
} catch (ArgumentOutOfRangeException) {
return InvalidDateString;
}
return dt.ToString ("ddd MMM d yyyy", CultureInfo.InvariantCulture);
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_toGMTString)]
public static string toGMTString (object thisObj)
{
return toUTCString (thisObj);
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_toLocaleDateString)]
public static string toLocaleDateString (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date_obj = (DateObject) thisObj;
double val = date_obj.ms;
double lv = DateConstructor.LocalTime (val);
int year = DateConstructor.YearFromTime (lv);
int month = DateConstructor.MonthFromTime (lv);
int date = DateConstructor.DateFromTime (lv);
DateTime dt;
try {
dt = new DateTime (year, month + 1, date);
} catch (ArgumentOutOfRangeException) {
return InvalidDateString;
}
return dt.ToString ("D");
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_toLocaleString)]
public static string toLocaleString (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date_obj = (DateObject) thisObj;
double val = date_obj.ms;
double lv = DateConstructor.LocalTime (val);
int year = DateConstructor.YearFromTime (lv);
int month = DateConstructor.MonthFromTime (lv);
int date = DateConstructor.DateFromTime (lv);
int hour = DateConstructor.HourFromTime (lv);
int min = DateConstructor.MinFromTime (lv);
int sec = DateConstructor.SecFromTime (lv);
DateTime dt;
try {
dt = new DateTime (year, month + 1, date, hour, min, sec);
} catch (ArgumentOutOfRangeException) {
return InvalidDateString;
}
return dt.ToString ("F");
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_toLocaleTimeString)]
public static string toLocaleTimeString (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date_obj = (DateObject) thisObj;
double val = date_obj.ms;
double lv = DateConstructor.LocalTime (val);
int year = DateConstructor.YearFromTime (lv);
int month = DateConstructor.MonthFromTime (lv);
int date = DateConstructor.DateFromTime (lv);
int hour = DateConstructor.HourFromTime (lv);
int min = DateConstructor.MinFromTime (lv);
int sec = DateConstructor.SecFromTime (lv);
DateTime dt;
try {
dt = new DateTime (year, month + 1, date, hour, min, sec);
} catch (ArgumentOutOfRangeException) {
return InvalidDateString;
}
return dt.ToString ("T");
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_toString)]
public static string toString (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
string date_str = toDateString (thisObj);
if (date_str == InvalidDateString)
return date_str;
return date_str.Insert (date_str.LastIndexOf (' '), " " + toTimeString (thisObj));
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_toTimeString)]
public static string toTimeString (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date_obj = (DateObject) thisObj;
double val = date_obj.ms;
double lv = DateConstructor.LocalTime (val);
int hour = DateConstructor.HourFromTime (lv);
int min = DateConstructor.MinFromTime (lv);
int sec = DateConstructor.SecFromTime (lv);
double off = getTimezoneOffset (thisObj);
return String.Format (@"{0:00}:{1:00}:{2:00} UTC{3:\+0;\-0;\+0}", hour, min, sec, -off / 60);
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_toUTCString)]
public static string toUTCString (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (DateObject));
DateObject date_obj = (DateObject) thisObj;
double val = date_obj.ms;
int year = DateConstructor.YearFromTime (val);
int month = DateConstructor.MonthFromTime (val);
int date = DateConstructor.DateFromTime (val);
int hour = DateConstructor.HourFromTime (val);
int min = DateConstructor.MinFromTime (val);
int sec = DateConstructor.SecFromTime (val);
DateTime dt;
try {
dt = new DateTime (year, month + 1, date);
} catch (ArgumentOutOfRangeException) {
return InvalidDateString;
}
string date_string = dt.ToString ("ddd, d MMM yyyy ", CultureInfo.InvariantCulture);
string time_string = String.Format (@"{0:00}:{1:00}:{2:00} UTC", hour, min, sec);
return date_string + time_string;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Date_valueOf)]
public static double valueOf (object thisObj)
{
return getTime (thisObj);
}
}
}

Просмотреть файл

@ -0,0 +1,51 @@
//
// DebugBreak.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class DebugBreak : AST {
private DebugBreak ()
: base (null, null)
{
}
internal override bool Resolve (Environment env)
{
throw new NotImplementedException ();
}
internal override void Emit (EmitContext ec)
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,839 @@
//
// Decompiler.cs: Port to C# of Mozilla's Rhino decompiler.
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Rhino code, released
* May 6, 1999.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Mike Ang
* Igor Bukanov
* Mike McCabe
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
* provisions of the GPL are applicable instead of those above.
* If you wish to allow use of your version of this file only
* under the terms of the GPL and not to allow others to use your
* version of this file under the NPL, indicate your decision by
* deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the NPL or the GPL.
*/
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//
// The following class save decompilation information about the source.
// Source information is returned from the parser as a String
// associated with function nodes and with the toplevel script. When
// saved in the constant pool of a class, this string will be UTF-8
// encoded, and token values will occupy a single byte.
//
// Source is saved (mostly) as token numbers. The tokens saved pretty
// much correspond to the token stream of a 'canonical' representation
// of the input program, as directed by the parser. (There were a few
// cases where tokens could have been left out where decompiler could
// easily reconstruct them, but I left them in for clarity). (I also
// looked adding source collection to TokenStream instead, where I
// could have limited the changes to a few lines in getToken... but
// this wouldn't have saved any space in the resulting source
// representation, and would have meant that I'd have to duplicate
// parser logic in the decompiler to disambiguate situations where
// newlines are important.) The function decompile expands the
// tokens back into their string representations, using simple
// lookahead to correct spacing and indentation.
//
// Assignments are saved as two-token pairs (Token.ASSIGN, op). Number tokens
// are stored inline, as a NUMBER token, a character representing the type, and
// either 1 or 4 characters representing the bit-encoding of the number. String
// types NAME, STRING and OBJECT are currently stored as a token type,
// followed by a character giving the length of the string (assumed to
// be less than 2^16), followed by the characters of the string
// inlined into the source string. Changing this to some reference to
// to the string in the compiled class' constant pool would probably
// save a lot of space... but would require some method of deriving
// the final constant pool entry from information available at parse
// time.
//
// Author:
// Cesar Lopez Nataren (cnataren@novell.com)
//
using System;
using System.Text;
namespace Microsoft.JScript {
internal class Decompiler {
//
// Flag to indicate that the decompilation should omit the
// function header and trailing brace.
//
internal const int ONLY_BODY_FLAG = 1 << 0;
//
// Flag to indicate that the decompilation generates toSource result.
//
internal const int TO_SOURCE_FLAG = 1 << 1;
//
// Decompilation property to specify initial ident value.
//
internal const int INITIAL_INDENT_PROP = 0;
//
// Decompilation property to specify default identation offset.
//
internal const int INDENT_GAP_PROP = 4;
//
// Decompilation property to specify identation offset for case labels.
//
internal const int CASE_GAP_PROP = 3;
// Marker to denote the last RC of function so it can be distinguished from
// the last RC of object literals in case of function expressions
private static readonly int FUNCTION_END = Token.LAST_TOKEN + 1;
private char [] sourceBuffer = new char [128];
// Per script/function source buffer top: parent source does not include a
// nested functions source and uses function index as a reference instead.
private int sourceTop;
// whether to do a debug print of the source information, when decompiling.
private const bool printSource = false;
internal string GetEncodedSource ()
{
return SourceToString (0);
}
internal int GetCurrentOffset ()
{
return sourceTop;
}
internal int MarkFunctionStart (int functionType)
{
int savedOffset = GetCurrentOffset ();
AddToken (Token.FUNCTION);
Append ((char) functionType);
return savedOffset;
}
internal int MarkFunctionEnd (int functionStart)
{
int offset = GetCurrentOffset ();
Append ((char) FUNCTION_END);
return offset;
}
internal void AddToken (int token)
{
if (!(0 <= token && token <= Token.LAST_TOKEN))
throw new Exception ("Illegal argument");
Append ((char) token);
}
internal void AddEOL (int token)
{
if (!(0 <= token && token <= Token.LAST_TOKEN))
throw new Exception ("Illegal argument");
if (sourceTop > 0 && sourceBuffer [sourceTop - 1] != Token.SEMI)
Append ((char) token);
Append ((char) Token.EOL);
}
internal void AddName (string str)
{
AddToken (Token.NAME);
AppendString (str);
}
internal void AddString (string str)
{
AddToken (Token.STRING);
AppendString (str);
}
internal void AddRegexp (string regexp, string flags)
{
AddToken (Token.REGEXP);
AppendString ('/' + regexp + '/' + flags);
}
internal void AddAssignOp (int op)
{
if (!(0 <= op && op <= Token.LAST_TOKEN))
throw new Exception ("Illegal argument");
Append ((char) Token.ASSIGNOP);
Append ((char) op);
}
internal void AddNumber (double n)
{
AddToken (Token.NUMBER);
// encode the number in the source stream.
// Save as NUMBER type (char | char char char char)
// where type is
// 'D' - double, 'S' - short, 'J' - long.
//
// We need to retain float vs. integer type info to keep the
// behavior of liveconnect type-guessing the same after
// decompilation. (Liveconnect tries to present 1.0 to Java
// as a float/double)
// OPT: This is no longer true. We could compress the format.
// This may not be the most space-efficient encoding;
// the chars created below may take up to 3 bytes in
// constant pool UTF-8 encoding, so a Double could take
// up to 12 bytes.
long lbits = (long) n;
if (lbits != n) {
// if it's floating point, save as a Double bit pattern.
// (12/15/97 our scanner only returns Double for f.p.)
lbits = BitConverter.DoubleToInt64Bits (n);
Append ('D');
Append ((char) (lbits >> 48));
Append ((char) (lbits >> 32));
Append ((char) (lbits >> 16));
Append ((char) lbits);
} else {
// we can ignore negative values, bc they're already prefixed
// by NEG
#if false
if (lbits < 0)
;
#endif
// will it fit in a char?
// this gives a short encoding for integer values up to 2^16.
if (lbits <= Char.MaxValue) {
Append ('S');
Append ((char) lbits);
} else { // Integral, but won't fit in a char. Store as a long.
Append ('J');
Append ((char) (lbits >> 48));
Append ((char) (lbits >> 32));
Append ((char) (lbits >> 16));
Append ((char) lbits);
}
}
}
private void AppendString (string str)
{
int L = str.Length;
int lengthEncodingSize = 1;
if (L >= 0x8000)
lengthEncodingSize = 2;
int nextTop = sourceTop + lengthEncodingSize + L;
if (nextTop > sourceBuffer.Length)
IncreaseSourceCapacity (nextTop);
if (L >= 0x8000) {
// Use 2 chars to encode strings exceeding 32K, were the highest
// bit in the first char indicates presence of the next byte
sourceBuffer [sourceTop] = (char) (0x8000 | BitwiseBinary.UnsignedRightShift (L, 16));
++sourceTop;
}
sourceBuffer [sourceTop] = (char) L;
++sourceTop;
str.CopyTo (0, sourceBuffer, sourceTop, L);
sourceTop = nextTop;
}
private void Append (char c)
{
if (sourceTop == sourceBuffer.Length)
IncreaseSourceCapacity (sourceTop + 1);
sourceBuffer [sourceTop] = c;
++sourceTop;
}
private void IncreaseSourceCapacity (int minimalCapacity)
{
// Call this only when capacity increase is must
if (minimalCapacity <= sourceBuffer.Length)
Console.WriteLine ("Warning: capacity increase is must");
int newCapacity = sourceBuffer.Length * 2;
if (newCapacity < minimalCapacity)
newCapacity = minimalCapacity;
char [] tmp = new char [newCapacity];
Array.Copy (sourceBuffer, 0, tmp, 0, sourceTop);
sourceBuffer = tmp;
}
internal string SourceToString (int offset)
{
if (offset < 0 || sourceTop < offset)
throw new Exception ("SourceToString: offset < 0 || sourceTop < offset");
return new string (sourceBuffer, offset, sourceTop - offset);
}
///
/// <remarks>
/// Decompile the source information associated with this js
/// function/script back into a string. For the most part, this
/// just means translating tokens back to their string
/// representations; there's a little bit of lookahead logic to
/// decide the proper spacing/indentation. Most of the work in
/// mapping the original source to the prettyprinted decompiled
/// version is done by the parser.
/// </remarks>
///
/// <param name="source"> encoded source tree presentation </param>
///
/// <param name="flags"> flags to select output format </param>
///
///
internal static string Decompile (string source, int flags)
{
return Decompile (source, flags, INITIAL_INDENT_PROP);
}
internal static string Decompile (string source, int flags, int indentCount)
{
int length = source.Length;
if (length == 0)
return "";
int indent = indentCount * INDENT_GAP_PROP;
if (indent < 0)
throw new Exception ("Illegal argument");
int indentGap = INDENT_GAP_PROP;
if (indentGap < 0)
throw new Exception ("Illegal argument");
int caseGap = CASE_GAP_PROP;
if (caseGap < 0)
throw new Exception ("Illegal argument");
StringBuilder result = new StringBuilder ();
bool justFunctionBody = (0 != (flags & Decompiler.ONLY_BODY_FLAG));
bool toSource = (0 != (flags & Decompiler.TO_SOURCE_FLAG));
// Spew tokens in source, for debugging.
// as TYPE number char
if (printSource) {
Console.WriteLine ("length:" + length);
for (int j = 0; j < length; ++j) {
// Note that tokenToName will fail unless Context.printTrees
// is true.
string tokenname = null;
if (Token.PrintNames)
tokenname = Token.Name (source [j], true);
if (tokenname == null)
tokenname = "---";
string pad = tokenname.Length > 7
? "\t"
: "\t\t";
Console.WriteLine (tokenname
+ pad + (int) source [j]
+ "\t'" + EscapeString (source.Substring (j, 1))
+ "'");
}
Console.WriteLine ();
}
int braceNesting = 0;
bool afterFirstEOL = false;
int i = 0;
int topFunctionType;
if (source [i] == Token.SCRIPT) {
++i;
topFunctionType = -1;
} else {
topFunctionType = source [i + 1];
}
if (!toSource) {
// add an initial newline to exactly match js.
result.Append ('\n');
for (int j = 0; j < indent; j++)
result.Append (' ');
} else {
if (topFunctionType == (int) FunctionType.Expression) {
result.Append ('(');
}
}
int t;
while (i < length) {
t = source [i];
if (t == Token.NAME || t == Token.REGEXP) {
// re-wrapped in '/'s in parser...
i = PrintSourceString (source, i + 1, false, result);
continue;
} else if (t == Token.STRING) {
i = PrintSourceString (source, i + 1, true, result);
continue;
} else if (t == Token.NUMBER) {
i = PrintSourceNumber (source, i + 1, result);
continue;
} else if (t == Token.TRUE)
result.Append ("true");
else if (t == Token.FALSE)
result.Append ("false");
else if (t == Token.NULL)
result.Append ("null");
else if (t == Token.THIS)
result.Append ("this");
else if (t == Token.FUNCTION) {
++i; // skip function type
result.Append ("function ");
} else if (t == FUNCTION_END) {
// Do nothing
} else if (t == Token.COMMA)
result.Append (", ");
else if (t == Token.LC) {
++braceNesting;
if (Token.EOL == GetNext (source, length, i))
indent += indentGap;
result.Append ('{');
} else if (t == Token.RC) {
--braceNesting;
/* don't print the closing RC if it closes the
* toplevel function and we're called from
* decompileFunctionBody.
*/
if (!(justFunctionBody && braceNesting == 0)) {
result.Append ('}');
int tt = GetNext (source, length, i);
if (tt == Token.EOL || tt == FUNCTION_END)
indent -= indentGap;
else if (tt == Token.WHILE || tt == Token.ELSE) {
indent -= indentGap;
result.Append (' ');
}
}
} else if (t == Token.LP)
result.Append ('(');
else if (t == Token.RP) {
result.Append (')');
if (Token.LC == GetNext (source, length, i))
result.Append (' ');
} else if (t == Token.LB)
result.Append ('[');
else if (t == Token.RB)
result.Append (']');
else if (t == Token.EOL) {
if (!toSource) {
bool newLine = true;
if (!afterFirstEOL) {
afterFirstEOL = true;
if (justFunctionBody) {
/* throw away just added 'function name(...) {'
* and restore the original indent
*/
result.Length = 0;
indent -= indentGap;
newLine = false;
}
}
if (newLine)
result.Append ('\n');
/* add indent if any tokens remain,
* less setback if next token is
* a label, case or default.
*/
if (i + 1 < length) {
int less = 0;
int nextToken = source [i + 1];
if (nextToken == Token.CASE
|| nextToken == Token.DEFAULT) {
less = indentGap - caseGap;
} else if (nextToken == Token.RC) {
less = indentGap;
}
/* elaborate check against label... skip past a
* following inlined NAME and look for a COLON.
*/
else if (nextToken == Token.NAME) {
int afterName = GetSourceStringEnd (source, i + 2);
if (source [afterName] == Token.COLON)
less = indentGap;
}
for (; less < indent; less++)
result.Append (' ');
}
}
} else if (t == Token.DOT)
result.Append ('.');
else if (t == Token.NEW)
result.Append ("new ");
else if (t == Token.DELPROP)
result.Append ("delete ");
else if (t == Token.IF)
result.Append ("if ");
else if (t == Token.ELSE)
result.Append ("else ");
else if (t == Token.FOR)
result.Append ("for ");
else if (t == Token.IN)
result.Append (" in ");
else if (t == Token.WITH)
result.Append ("with ");
else if (t == Token.WHILE)
result.Append ("while ");
else if (t == Token.DO)
result.Append ("do ");
else if (t == Token.TRY)
result.Append ("try ");
else if (t == Token.CATCH)
result.Append ("catch ");
else if (t == Token.FINALLY)
result.Append ("finally ");
else if (t == Token.THROW)
result.Append ("throw ");
else if (t == Token.SWITCH)
result.Append ("switch ");
else if (t == Token.BREAK) {
result.Append ("break");
if (Token.NAME == GetNext (source, length, i))
result.Append (' ');
} else if (t == Token.CONTINUE) {
result.Append ("continue");
if (Token.NAME == GetNext (source, length, i))
result.Append (' ');
} else if (t == Token.CASE)
result.Append ("case ");
else if (t == Token.DEFAULT)
result.Append ("default");
else if (t == Token.RETURN) {
result.Append ("return");
if (Token.SEMI != GetNext (source, length, i))
result.Append (' ');
} else if (t == Token.VAR)
result.Append ("var ");
else if (t == Token.SEMI) {
result.Append (';');
if (Token.EOL != GetNext (source, length, i)) {
// separators in FOR
result.Append (' ');
}
} else if (t == Token.ASSIGN)
result.Append (" = ");
else if (t == Token.ASSIGNOP) {
i++;
int op = source [i];
if (op == Token.ADD)
result.Append (" += ");
else if (op == Token.SUB)
result.Append (" -= ");
else if (op == Token.MUL)
result.Append (" *= ");
else if (op == Token.DIV)
result.Append (" /= ");
else if (op == Token.MOD)
result.Append (" %= ");
else if (op == Token.BITOR)
result.Append (" |= ");
else if (op == Token.BITXOR)
result.Append (" ^= ");
else if (op == Token.BITAND)
result.Append (" &= ");
else if (op == Token.LSH)
result.Append (" <<= ");
else if (op == Token.RSH)
result.Append (" >>= ");
else if (op == Token.URSH)
result.Append (" >>>= ");
} else if (t == Token.HOOK)
result.Append (" ? ");
else if (t == Token.OBJECTLIT) {
// pun OBJECTLIT to mean colon in objlit property
// initialization.
// This needs to be distinct from COLON in the general case
// to distinguish from the colon in a ternary... which needs
// different spacing.
result.Append (':');
} else if (t == Token.COLON) {
if (Token.EOL == GetNext(source, length, i))
// it's the end of a label
result.Append (':');
else
// it's the middle part of a ternary
result.Append (" : ");
} else if (t == Token.OR)
result.Append (" || ");
else if (t == Token.AND)
result.Append (" && ");
else if (t == Token.BITOR)
result.Append (" | ");
else if (t == Token.BITXOR)
result.Append (" ^ ");
else if (t == Token.BITAND)
result.Append (" & ");
else if (t == Token.SHEQ)
result.Append (" === ");
else if (t == Token.SHNE)
result.Append (" !== ");
else if (t == Token.EQ)
result.Append (" == ");
else if (t == Token.NE)
result.Append (" != ");
else if (t == Token.LE)
result.Append (" <= ");
else if (t == Token.LT)
result.Append (" < ");
else if (t == Token.GE)
result.Append (" >= ");
else if (t == Token.GT)
result.Append (" > ");
else if (t == Token.INSTANCEOF)
result.Append (" instanceof ");
else if (t == Token.LSH)
result.Append (" << ");
else if (t == Token.RSH)
result.Append (" >> ");
else if (t == Token.URSH)
result.Append (" >>> ");
else if (t == Token.TYPEOF)
result.Append ("typeof ");
else if (t == Token.VOID)
result.Append ("void ");
else if (t == Token.NOT)
result.Append ('!');
else if (t == Token.BITNOT)
result.Append ('~');
else if (t == Token.POS)
result.Append ('+');
else if (t == Token.NEG)
result.Append ('-');
else if (t == Token.INC)
result.Append ("++");
else if (t == Token.DEC)
result.Append ("--");
else if (t == Token.ADD)
result.Append (" + ");
else if (t == Token.SUB)
result.Append (" - ");
else if (t == Token.MUL)
result.Append (" * ");
else if (t == Token.DIV)
result.Append (" / ");
else if (t == Token.MOD)
result.Append (" % ");
else {
// If we don't know how to decompile it, raise an exception.
throw new Exception ("If we don't know how to decompile it, raise an exception.");
}
++i;
}
if (!toSource) {
// add that trailing newline if it's an outermost function.
if (!justFunctionBody)
result.Append ('\n');
} else {
if (topFunctionType == (int) FunctionType.Expression)
result.Append (')');
}
return result.ToString ();
}
private static int GetNext (string source, int length, int i)
{
return (i + 1 < length) ? source [i + 1] : Token.EOF;
}
private static int GetSourceStringEnd (string source, int offset)
{
return PrintSourceString (source, offset, false, null);
}
private static int PrintSourceString (string source, int offset, bool asQuotedString, StringBuilder sb)
{
int length = source [offset];
++offset;
if ((0x8000 & length) != 0) {
length = ((0x7FFF & length) << 16) | source [offset];
++offset;
}
if (sb != null) {
string str = source.Substring (offset, length);
if (!asQuotedString) {
sb.Append (str);
} else {
sb.Append ('"');
sb.Append (EscapeString (str));
sb.Append ('"');
}
}
return offset + length;
}
private static int PrintSourceNumber (string source, int offset, StringBuilder sb)
{
double number = 0.0;
char type = source [offset];
++offset;
if (type == 'S') {
if (sb != null) {
int ival = source [offset];
number = ival;
}
++offset;
} else if (type == 'J' || type == 'D') {
if (sb != null) {
long lbits;
lbits = (long)source [offset] << 48;
lbits |= (long)source [offset + 1] << 32;
lbits |= (long)source [offset + 2] << 16;
lbits |= (long)source [offset + 3];
if (type == 'J') {
number = lbits;
} else {
number = BitConverter.Int64BitsToDouble (lbits);
}
}
offset += 4;
} else {
// Bad source
throw new Exception("Runtime exception");
}
if (sb != null) {
string str = Convert.ToString (number);
sb.Append (str);
bool forceDouble = offset < source.Length && source [offset] == Token.DOT;
if (forceDouble && str.IndexOf ('.') == -1)
sb.Append (".0");
}
return offset;
}
internal static string EscapeString (string s)
{
return EscapeString (s, '"');
}
/**
* For escaping strings printed by object and array literals; not quite
* the same as 'escape.'
*/
internal static string EscapeString (string s, char escapeQuote)
{
if (!(escapeQuote == '"' || escapeQuote == '\''))
throw new Exception ("Debug");
StringBuilder sb = null;
for(int i = 0, L = s.Length; i != L; ++i) {
int c = s [i];
if (' ' <= c && c <= '~' && c != escapeQuote && c != '\\') {
// an ordinary print character (like C isprint()) and not "
// or \ .
if (sb != null)
sb.Append ((char) c);
continue;
}
if (sb == null) {
sb = new StringBuilder (L + 3);
sb.Append (s);
sb.Length = i;
}
int escape = -1;
switch (c) {
case '\b': escape = 'b'; break;
case '\f': escape = 'f'; break;
case '\n': escape = 'n'; break;
case '\r': escape = 'r'; break;
case '\t': escape = 't'; break;
case 0xb: escape = 'v'; break; // Java lacks \v.
case ' ': escape = ' '; break;
case '\\': escape = '\\'; break;
}
if (escape >= 0) {
// an \escaped sort of character
sb.Append ('\\');
sb.Append ((char) escape);
} else if (c == escapeQuote) {
sb.Append ('\\');
sb.Append (escapeQuote);
} else {
int hexSize;
if (c < 256) {
// 2-digit hex
sb.Append ("\\x");
hexSize = 2;
} else {
// Unicode.
sb.Append ("\\u");
hexSize = 4;
}
// append hexadecimal form of c left-padded with 0
for (int shift = (hexSize - 1) * 4; shift >= 0; shift -= 4) {
int digit = 0xf & (c >> shift);
int hc = (digit < 10) ? '0' + digit : 'a' - 10 + digit;
sb.Append ((char) hc);
}
}
}
return (sb == null) ? s : sb.ToString ();
}
}
}

Просмотреть файл

@ -0,0 +1,42 @@
//
// DocumentContext.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Microsoft.JScript {
public class DocumentContext {
internal string Name;
internal DocumentContext (string filename)
{
Name = filename;
}
}
}

Просмотреть файл

@ -0,0 +1,54 @@
//
// Empty.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
// Copyright (C) 2006 Novell Inc (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Microsoft.JScript {
public class Empty {
public static readonly Empty Value = null;
}
internal class EmptyAST : AST {
internal EmptyAST ()
: base (null, null)
{
}
internal override bool Resolve (Environment env)
{
return true;
}
internal override void Emit (EmitContext ec)
{
}
}
}

Просмотреть файл

@ -0,0 +1,101 @@
//
// Enum.cs: AST representation of a enum_statement.
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Text;
using System.Collections;
namespace Microsoft.JScript {
internal class Enum : AST {
private ArrayList modifiers;
private string name;
private string type;
private ArrayList pairs;
internal Enum (AST parent, Location location)
: base (parent, location)
{
Modifiers = new ArrayList ();
Pairs = new ArrayList ();
}
internal ArrayList Modifiers {
get { return modifiers; }
set { modifiers = value; }
}
internal string Name {
get { return name; }
set { name = value; }
}
internal string Type {
get { return type; }
set { type = value; }
}
internal ArrayList Pairs {
get { return pairs; }
set { pairs = value; }
}
public override string ToString ()
{
StringBuilder sb = new StringBuilder ();
foreach (string modifier in Modifiers)
sb.Append (modifier + "\n");
sb.Append (name + "\n");
sb.Append (type + "\n");
foreach (BinaryOp bop in Pairs)
sb.Append (bop.ToString () + "\n");
return sb.ToString ();
}
internal override bool Resolve (Environment env)
{
throw new NotImplementedException ();
}
internal override void Emit (EmitContext ec)
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,55 @@
//
// EnumeratorConstructor.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class EnumeratorConstructor : ScriptFunction {
internal static EnumeratorConstructor Ctr = new EnumeratorConstructor ();
internal EnumeratorConstructor ()
{
name = "Enumerator";
_prototype = EnumeratorPrototype.Proto;
}
[JSFunctionAttribute(JSFunctionAttributeEnum.HasVarArgs)]
public new EnumeratorObject CreateInstance (params Object [] args)
{
throw new NotImplementedException ();
}
public Object Invoke ()
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,43 @@
//
// EnumeratorObject.cs
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
namespace Microsoft.JScript {
public class EnumeratorObject : JSObject {
protected IEnumerator enumerator;
protected void LoadObject()
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,68 @@
//
// EnumeratorPrototype.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class EnumeratorPrototype : JSObject {
internal static EnumeratorPrototype Proto = new EnumeratorPrototype ();
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Enumerator_atEnd)]
public static bool atEnd (object thisObj)
{
throw new NotImplementedException ();
}
public static EnumeratorConstructor constructor {
get { return EnumeratorConstructor.Ctr; }
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Enumerator_item)]
public static object item (object thisObj)
{
throw new NotImplementedException ();
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Enumerator_moveFirst)]
public static void moveFirst (object thisObj)
{
throw new NotImplementedException ();
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Enumerator_moveNext)]
public static void moveNext (object thisObj)
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,210 @@
//
// Equality.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, 2004 Cesar Lopez Nataren
// (C) 2005, Novell Inc, (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Text;
using System.Diagnostics;
using System.Reflection.Emit;
namespace Microsoft.JScript {
public class Equality : BinaryOp {
internal Equality (AST parent, AST left, AST right, JSToken op, Location location)
: base (parent, left, right, op, location)
{
}
public Equality (int i)
: base (null, null, null, (JSToken) i, null)
{
}
[DebuggerStepThroughAttribute]
[DebuggerHiddenAttribute]
public bool EvaluateEquality (object v1, object v2)
{
IConvertible ic1 = v1 as IConvertible;
IConvertible ic2 = v2 as IConvertible;
TypeCode tc1 = Convert.GetTypeCode (v1, ic1);
TypeCode tc2 = Convert.GetTypeCode (v2, ic2);
bool both_numbers = Convert.IsNumberTypeCode (tc1) && Convert.IsNumberTypeCode (tc2);
if ((tc1 == tc2) || both_numbers) {
switch (tc1) {
case TypeCode.DBNull:
case TypeCode.Empty:
return true;
case TypeCode.Boolean:
return ic1.ToBoolean (null) == ic2.ToBoolean (null);
case TypeCode.String:
return ic1.ToString (null) == ic2.ToString (null);
case TypeCode.Object:
if (v1 is ScriptFunction && v2 is ScriptFunction)
return v1 == v2 || v1.Equals (v2);
else
return v1 == v2;
default:
if (both_numbers) {
double num1;
if (Convert.IsFloatTypeCode (tc1))
num1 = ic1.ToDouble (null);
else
num1 = (double) ic1.ToInt64 (null);
double num2;
if (Convert.IsFloatTypeCode (tc2))
num2 = ic2.ToDouble (null);
else
num2 = (double) ic2.ToInt64 (null);
return num1 == num2;
} else
return false;
}
} else {
bool swapped = false;
redo:
switch (tc1) {
case TypeCode.DBNull:
if (tc2 == TypeCode.Empty)
return true;
break;
case TypeCode.String:
if (Convert.IsNumberTypeCode (tc2))
return EvaluateEquality (Convert.ToNumber (v1), v2);
break;
case TypeCode.Boolean:
return EvaluateEquality (Convert.ToNumber (v1), v2);
case TypeCode.Object:
if (tc2 == TypeCode.String || Convert.IsNumberTypeCode (tc2))
return EvaluateEquality (Convert.ToPrimitive (v1, null), v2);
break;
}
if (!swapped) {
swapped = true;
object vt = v1;
v1 = v2;
v2 = vt;
ic1 = v1 as IConvertible;
ic2 = v2 as IConvertible;
tc1 = Convert.GetTypeCode (v1, ic1);
tc2 = Convert.GetTypeCode (v2, ic2);
goto redo;
} else
return false;
}
}
public static bool JScriptEquals (object v1, object v2)
{
throw new NotImplementedException ();
}
internal override bool Resolve (Environment env)
{
bool r = true;
if (left != null)
r &= left.Resolve (env);
if (right != null)
r &= right.Resolve (env);
return r;
}
internal override bool Resolve (Environment env, bool no_effect)
{
this.no_effect = no_effect;
return Resolve (env);
}
internal override void Emit (EmitContext ec)
{
ILGenerator ig = ec.ig;
LocalBuilder local_builder;
if (op != JSToken.None) {
Type t = typeof (Equality);
local_builder = ig.DeclareLocal (t);
if (op == JSToken.Equal)
ig.Emit (OpCodes.Ldc_I4_S, (byte) 53);
else if (op == JSToken.NotEqual)
ig.Emit (OpCodes.Ldc_I4_S, (byte) 54);
ig.Emit (OpCodes.Newobj, t.GetConstructor (new Type [] { typeof (int) }));
ig.Emit (OpCodes.Stloc, local_builder);
ig.Emit (OpCodes.Ldloc, local_builder);
}
if (left != null) {
left.Emit (ec);
CodeGenerator.EmitBox (ig, left);
}
if (right != null) {
right.Emit (ec);
CodeGenerator.EmitBox (ig, right);
}
if (op == JSToken.Equal || op == JSToken.NotEqual) {
ig.Emit (OpCodes.Call, typeof (Equality).GetMethod ("EvaluateEquality"));
if (no_effect) {
Label t_lbl = ig.DefineLabel ();
Label f_lbl = ig.DefineLabel ();
if (op == JSToken.Equal)
ig.Emit (OpCodes.Brtrue_S, t_lbl);
else if (op == JSToken.NotEqual)
ig.Emit (OpCodes.Brfalse_S, t_lbl);
ig.Emit (OpCodes.Ldc_I4_0);
ig.Emit (OpCodes.Br_S, f_lbl);
ig.MarkLabel (t_lbl);
ig.Emit (OpCodes.Ldc_I4_1);
ig.MarkLabel (f_lbl);
ig.Emit (OpCodes.Pop);
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,132 @@
//
// ErrorConstructor.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
namespace Microsoft.JScript {
public enum ErrorType : int {
OtherError,
EvalError,
RangeError,
ReferenceError,
SyntaxError,
TypeError,
URIError
};
public class ErrorConstructor : ScriptFunction {
ErrorType error_type;
internal static ErrorConstructor Ctr = new ErrorConstructor ();
internal static ErrorConstructor EvalErrorCtr = new ErrorConstructor (ErrorType.EvalError);
internal static ErrorConstructor RangeErrorCtr = new ErrorConstructor (ErrorType.RangeError);
internal static ErrorConstructor ReferenceErrorCtr = new ErrorConstructor (ErrorType.ReferenceError);
internal static ErrorConstructor SyntaxErrorCtr = new ErrorConstructor (ErrorType.SyntaxError);
internal static ErrorConstructor TypeErrorCtr = new ErrorConstructor (ErrorType.TypeError);
internal static ErrorConstructor URIErrorCtr = new ErrorConstructor (ErrorType.URIError);
static Type ErrorTypeToClass (ErrorType type)
{
switch (type) {
case ErrorType.EvalError:
return typeof (EvalErrorObject);
case ErrorType.RangeError:
return typeof (RangeErrorObject);
case ErrorType.ReferenceError:
return typeof (ReferenceErrorObject);
case ErrorType.SyntaxError:
return typeof (SyntaxErrorObject);
case ErrorType.TypeError:
return typeof (TypeErrorObject);
case ErrorType.URIError:
return typeof (URIErrorObject);
}
Console.WriteLine ("ErrorTypeToClass: unknown type {0}", type);
throw new NotImplementedException ();
}
static string ErrorTypeToName (ErrorType type)
{
switch (type) {
case ErrorType.EvalError:
return "EvalError";
case ErrorType.OtherError:
return "Error"; // TODO: Is this correct?
case ErrorType.RangeError:
return "RangeError";
case ErrorType.ReferenceError:
return "ReferenceError";
case ErrorType.SyntaxError:
return "SyntaxError";
case ErrorType.TypeError:
return "TypeError";
case ErrorType.URIError:
return "URIError";
}
Console.WriteLine ("ErrorTypeToName: unknown type {0}", type);
throw new NotImplementedException ();
}
internal ErrorConstructor ()
{
name = "Error";
_prototype = ErrorPrototype.Proto;
_length = 1;
}
internal ErrorConstructor (ErrorType errorType)
{
error_type = errorType;
name = ErrorTypeToName (errorType);
_prototype = ErrorPrototype.Proto;
_length = 1;
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasVarArgs)]
public new ErrorObject CreateInstance (params Object [] args)
{
string message = "";
if (args.Length >= 1)
message = Convert.ToString (args[0]);
Type type = ErrorTypeToClass (error_type);
return (ErrorObject) Activator.CreateInstance (type, new object [] { message });
}
[JSFunctionAttribute(JSFunctionAttributeEnum.HasVarArgs)]
public Object Invoke (params Object [] args)
{
return CreateInstance (args);
}
}
}

Просмотреть файл

@ -0,0 +1,55 @@
//
// ErrorObject.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class ErrorObject : JSObject {
public Object message;
public Object number;
public Object description;
public static explicit operator Exception (ErrorObject errObj)
{
throw new NotImplementedException ();
}
internal ErrorObject (string message)
{
this.message = message;
}
internal override object GetDefaultValue (Type hint, bool avoid_toString)
{
return ErrorPrototype.toString (this);
}
}
}

Просмотреть файл

@ -0,0 +1,53 @@
//
// ErrorPrototype.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class ErrorPrototype : JSObject {
internal static ErrorPrototype Proto = new ErrorPrototype ();
public readonly string name;
public ErrorConstructor constructor {
get { return ErrorConstructor.Ctr; }
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Error_toString)]
public static string toString (object thisObj)
{
SemanticAnalyser.assert_type (thisObj, typeof (ErrorObject));
ErrorObject error = (ErrorObject) thisObj;
return error.message.ToString ();
}
}
}

Просмотреть файл

@ -0,0 +1,65 @@
//
// Eval.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
// (C) 2005, Novell Inc, (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using Microsoft.JScript.Vsa;
namespace Microsoft.JScript {
public class Eval : AST {
private Eval ()
: base (null, null)
{
}
public static object JScriptEvaluate (object src, VsaEngine engine)
{
throw new NotImplementedException ();
}
#if NET_1_1 || NET_2_0
public static object JScriptEvaluate (object source, object unsafeOption, VsaEngine engine)
{
throw new NotImplementedException ();
}
#endif
internal override bool Resolve (Environment env)
{
throw new NotImplementedException ();
}
internal override void Emit (EmitContext ec)
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,40 @@
//
// EvalErrorObject.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Microsoft.JScript {
public sealed class EvalErrorObject : ErrorObject {
internal EvalErrorObject (string message)
: base (message)
{
}
}
}

Просмотреть файл

@ -0,0 +1,40 @@
//
// Expando.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class Expando : Attribute
{
public Expando ()
{}
}
}

Просмотреть файл

@ -0,0 +1,40 @@
//
// FieldAccessor.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Microsoft.JScript {
public abstract class FieldAccessor
{
public abstract object GetValue (object thisObj);
public abstract void SetValue (object thisObj, object value);
}
}

Просмотреть файл

@ -0,0 +1,170 @@
//
// ForIn.cs:
//
// Author:
// Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.Reflection.Emit;
namespace Microsoft.JScript {
public class ForIn : AST, ICanModifyContext {
AST lhs, obj, body;
internal ForIn (AST parent, AST lhs, AST obj, AST body, Location location)
: base (parent, location)
{
this.lhs = lhs;
this.obj = obj;
this.body = body;
}
public static IEnumerator JScriptGetEnumerator (object coll)
{
IEnumerable e = coll as IEnumerable;
if (e == null)
throw new JScriptException(JSError.NotCollection);
return e.GetEnumerator();
}
void ICanModifyContext.PopulateContext (Environment env, string ns)
{
if (lhs is ICanModifyContext)
((ICanModifyContext) lhs).PopulateContext (env, ns);
if (body is ICanModifyContext)
((ICanModifyContext) body).PopulateContext (env, ns);
}
void ICanModifyContext.EmitDecls (EmitContext ec)
{
if (lhs is ICanModifyContext)
((ICanModifyContext) lhs).EmitDecls (ec);
if (body is ICanModifyContext)
((ICanModifyContext) body).EmitDecls (ec);
}
internal override bool Resolve (Environment env)
{
bool r = true;
if (lhs != null)
if (lhs is VariableStatement)
((ICanModifyContext) lhs).PopulateContext (env, String.Empty);
else
r &= lhs.Resolve (env);
if (obj != null)
r &= obj.Resolve (env);
if (body != null) {
if (body is Exp)
r &= ((Exp) body).Resolve (env, true);
else
r &= body.Resolve (env);
}
return r;
}
internal override void Emit (EmitContext ec)
{
ILGenerator ig = ec.ig;
bool varStm = lhs is VariableStatement;
object var = null;
if (varStm) {
VariableStatement stm = (VariableStatement) lhs;
ig.Emit (OpCodes.Ldnull);
var = TypeManager.Get (((VariableDeclaration) stm.var_decls [0]).id);
set_builder (ig, var);
}
if (obj != null)
obj.Emit (ec);
CodeGenerator.load_engine (InFunction, ig);
Type convert = typeof (Convert);
ig.Emit (OpCodes.Call, convert.GetMethod ("ToForInObject"));
ig.Emit (OpCodes.Call, typeof (ForIn).GetMethod ("JScriptGetEnumerator"));
Type ienumerator = typeof (IEnumerator);
LocalBuilder iter = ig.DeclareLocal (ienumerator);
LocalBuilder current = ig.DeclareLocal (typeof (object));
ig.Emit (OpCodes.Stloc, iter);
Label init_loop = ig.DefineLabel ();
Label move_next = ig.DefineLabel ();
Label exit = ig.DefineLabel ();
ig.Emit (OpCodes.Br, move_next);
ig.MarkLabel (init_loop);
if (body != null)
body.Emit (ec);
ig.MarkLabel (move_next);
ig.Emit (OpCodes.Ldloc, iter);
ig.Emit (OpCodes.Callvirt, ienumerator.GetMethod ("MoveNext"));
ig.Emit (OpCodes.Brfalse, exit);
ig.Emit (OpCodes.Ldloc, iter);
ig.Emit (OpCodes.Callvirt, ienumerator.GetProperty ("Current").GetGetMethod ());
ig.Emit (OpCodes.Stloc, current);
ig.Emit (OpCodes.Ldloc, current);
if (varStm)
set_builder (ig, var);
else {
if (lhs is Expression) {
AST ast = ((Expression) lhs).Last;
if (ast is Identifier)
((Identifier) ast).EmitStore (ec);
else
throw new NotImplementedException ();
} else
throw new NotImplementedException ();
}
ig.Emit (OpCodes.Br, init_loop);
ig.MarkLabel (exit);
}
void set_builder (ILGenerator ig, object builder)
{
if (builder is FieldBuilder)
ig.Emit (OpCodes.Stsfld, (FieldBuilder) builder);
else if (builder is LocalBuilder)
ig.Emit (OpCodes.Stloc, (LocalBuilder) builder);
}
}
}

Просмотреть файл

@ -0,0 +1,140 @@
//
// FormalParameterList.cs: A list of identifiers.
//
// Author:
// Cesar Lopez Nataren
//
// (C) 2003, Cesar Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Reflection.Emit;
using System.Collections;
using System.Text;
using System;
namespace Microsoft.JScript {
internal class FormalParam : AST {
internal string id;
internal string type_annot;
internal byte pos;
//
// FIXME:
// Must perform semantic analysis on type_annot,
// and assign that type value to 'type' if valid.
//
internal Type type = typeof (Object);
internal FormalParam (string id, string type_annot, Location location)
: base (null, location)
{
this.id = id;
this.type_annot = type_annot;
}
public override string ToString ()
{
return id + " " + type_annot;
}
internal override void Emit (EmitContext ec)
{
}
internal override bool Resolve (Environment env)
{
env.Enter (String.Empty, Symbol.CreateSymbol (id), this);
return true;
}
}
internal class FormalParameterList : AST {
internal ArrayList ids;
internal FormalParameterList (Location location)
: base (null, location)
{
ids = new ArrayList ();
}
internal void Add (string id, string type_annot, Location location)
{
FormalParam p = new FormalParam (id, type_annot, location);
ids.Add (p);
}
public override string ToString ()
{
StringBuilder sb = new StringBuilder ();
foreach (FormalParam f in ids)
sb.Append (f.ToString () + " ");
return sb.ToString ();
}
internal override bool Resolve (Environment env)
{
FormalParam f;
int i, n = ids.Count;
for (i = 0; i < n; i++) {
f = (FormalParam) ids [i];
f.pos = (byte) (i + 2);
f.Resolve (env);
}
return true;
}
internal override void Emit (EmitContext ec)
{
int n = ids.Count;
ILGenerator ig = ec.ig;
ig.Emit (OpCodes.Ldc_I4, n);
ig.Emit (OpCodes.Newarr, typeof (string));
for (int i = 0; i < n; i++) {
ig.Emit (OpCodes.Dup);
ig.Emit (OpCodes.Ldc_I4, i);
ig.Emit (OpCodes.Ldstr, ((FormalParam) ids [i]).id);
ig.Emit (OpCodes.Stelem_Ref);
}
}
internal int size {
get { return ids.Count; }
}
internal FormalParam get_element (int i)
{
if (i >= 0 && i < size)
return (FormalParam) ids [i];
else
throw new IndexOutOfRangeException ();
}
}
}

Просмотреть файл

@ -0,0 +1,58 @@
//
// FunctionConstructor.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
namespace Microsoft.JScript {
public class FunctionConstructor : ScriptFunction {
internal static FunctionConstructor Ctr = new FunctionConstructor ();
internal FunctionConstructor ()
{
_prototype = FunctionPrototype.Proto;
_length = 1;
name = "Function";
}
[JSFunctionAttribute(JSFunctionAttributeEnum.HasVarArgs)]
public new ScriptFunction CreateInstance (params Object [] args)
{
throw new NotImplementedException ();
}
[JSFunctionAttribute(JSFunctionAttributeEnum.HasVarArgs)]
public ScriptFunction Invoke(params Object [] args)
{
return CreateInstance (args);
}
}
}

Просмотреть файл

@ -0,0 +1,279 @@
//
// FunctionDeclaration.cs:
//
// Author:
// Cesar Octavio Lopez Nataren
//
// (C) 2003, 2004 Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
// (C) 2005 Novell Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Text;
using System.Reflection;
using System.Reflection.Emit;
using Microsoft.JScript.Vsa;
using System.Collections;
namespace Microsoft.JScript {
public class FunctionDeclaration : Function, ICanModifyContext {
private int lexical_depth;
internal FunctionDeclaration ()
: base (null, null)
{
}
internal FunctionDeclaration (AST parent, string name, Location location)
: this (parent, name, null, String.Empty, null, location)
{
}
internal FunctionDeclaration (AST parent, string name,
FormalParameterList p,
string return_type,
Block body, Location location)
: base (parent, location)
{
set_prefix ();
func_obj = new FunctionObject (name, p, return_type, body, location);
}
public static Closure JScriptFunctionDeclaration (RuntimeTypeHandle handle, string name,
string methodName, string [] formalParameters,
JSLocalField [] fields, bool mustSaveStackLocals,
bool hasArgumentsObjects, string text,
Object declaringObject, VsaEngine engine)
{
FunctionObject f = new FunctionObject (name, null, null, null, null);
f.source = text;
MethodInfo method = engine.ScriptObjectStackTop ().GetType ().GetMethod (methodName);
f.method = method;
f.vsa_engine = engine;
return new Closure (f);
}
internal void create_closure (EmitContext ec)
{
string name = func_obj.name;
string full_name;
TypeBuilder type = ec.type_builder;
ILGenerator ig = ec.ig;
if (prefix == String.Empty)
full_name = name;
else
full_name = prefix + "." + name;
MethodBuilder method_builder = type.DefineMethod (full_name, func_obj.attr, HandleReturnType,
func_obj.params_types ());
MethodBuilder tmp = (MethodBuilder) TypeManager.Get (name);
if (tmp == null)
TypeManager.Add (name, method_builder);
else
TypeManager.Set (name, method_builder);
set_custom_attr (method_builder);
this.ig = method_builder.GetILGenerator ();
if (parent == null || parent.GetType () == typeof (ScriptBlock))
type.DefineField (name, typeof (Microsoft.JScript.ScriptFunction),
FieldAttributes.Public | FieldAttributes.Static);
else {
local_func = ig.DeclareLocal (typeof (Microsoft.JScript.ScriptFunction));
TypeManager.AddLocalScriptFunction (name, local_func);
}
build_closure (ec, full_name, func_obj.source);
}
internal override void Emit (EmitContext ec)
{
TypeManager.BeginScope ();
ILGenerator old_ig = ec.ig;
ec.ig = this.ig;
((ICanModifyContext) func_obj.body).EmitDecls (ec);
func_obj.body.Emit (ec);
string func_name = func_obj.name;
if (SemanticAnalyser.MethodContainsEval (func_name))
CodeGenerator.load_local_vars (ec.ig, true);
else {
VariableDeclaration decl = SemanticAnalyser.OutterScopeVar (func_name);
if (decl == null) {
decl = SemanticAnalyser.VarUsedNested (func_name);
if (decl != null)
CodeGenerator.load_local_vars (ec.ig, InFunction);
} else
CodeGenerator.locals_to_stack_frame (ec.ig, decl.lexical_depth, lexical_depth - decl.lexical_depth, true);
}
this.ig.Emit (OpCodes.Ret);
ec.ig = old_ig;
TypeManager.EndScope ();
}
internal void build_closure (EmitContext ec, string full_name, string encodedSource)
{
ILGenerator ig = ec.ig;
string name = func_obj.name;
Type t = ec.mod_builder.GetType (CodeGenerator.GetTypeName (Location.SourceName));
ig.Emit (OpCodes.Ldtoken, t);
ig.Emit (OpCodes.Ldstr, name);
ig.Emit (OpCodes.Ldstr, full_name);
func_obj.parameters.Emit (ec);
build_local_fields (ig);
//
// If we have en eval method call, we have to
// save the loca vars in the stack
//
if (SemanticAnalyser.MethodContainsEval (name) ||
SemanticAnalyser.MethodVarsUsedNested (name))
ig.Emit (OpCodes.Ldc_I4_1);
else
ig.Emit (OpCodes.Ldc_I4_0);
ig.Emit (OpCodes.Ldc_I4_0); // FIXME: this hard coded for now.
ig.Emit (OpCodes.Ldstr, Decompiler.Decompile (encodedSource, 0, 0).Trim ());
ig.Emit (OpCodes.Ldnull); // FIXME: this hard coded for now.
CodeGenerator.load_engine (InFunction, ig);
ig.Emit (OpCodes.Call, typeof (FunctionDeclaration).GetMethod ("JScriptFunctionDeclaration"));
if (parent == null || parent.GetType () == typeof (ScriptBlock))
ig.Emit (OpCodes.Stsfld, t.GetField (name));
else
ig.Emit (OpCodes.Stloc, local_func);
}
internal void build_local_fields (ILGenerator ig)
{
object e;
int n;
if (locals == null)
n = 0;
else
n = locals.Length;
Type t = typeof (JSLocalField);
ConstructorInfo ctr_info = t.GetConstructor (new Type [] {
typeof (string), typeof (RuntimeTypeHandle), typeof (Int32) });
if (not_void_return)
ig.Emit (OpCodes.Ldc_I4, n + 1);
else
ig.Emit (OpCodes.Ldc_I4, n);
ig.Emit (OpCodes.Newarr, t);
for (int i = 0; i < n; i++) {
ig.Emit (OpCodes.Dup);
ig.Emit (OpCodes.Ldc_I4, i);
e = locals [i];
ig.Emit (OpCodes.Ldstr, GetName (e));
if (e is VariableDeclaration)
ig.Emit (OpCodes.Ldtoken, ((VariableDeclaration) e).type);
else if (e is FormalParam)
ig.Emit (OpCodes.Ldtoken, ((FormalParam) e).type);
else if (e is FunctionDeclaration)
ig.Emit (OpCodes.Ldtoken, typeof (ScriptFunction));
else if (e is FunctionExpression)
ig.Emit (OpCodes.Ldtoken, typeof (object));
ig.Emit (OpCodes.Ldc_I4, i);
ig.Emit (OpCodes.Newobj, ctr_info);
ig.Emit (OpCodes.Stelem_Ref);
}
if (not_void_return)
emit_return_local_field (ig, ctr_info, n);
}
void ICanModifyContext.PopulateContext (Environment env, string ns)
{
//
// In the case of function
// declarations we add
// function's name to the
// table but we resolve its
// body until later, as free
// variables can be referenced
// in function's body.
//
string name = func_obj.name;
AST binding = (AST) env.Get (String.Empty, Symbol.CreateSymbol (name));
if (binding == null)
env.Enter (String.Empty, Symbol.CreateSymbol (name), this);
else if (binding is FunctionDeclaration || binding is VariableDeclaration) {
Console.WriteLine ("{0}({1},0) : warning JS1111: '{2}' is already defined",
Location.SourceName, Location.LineNumber, name);
}
if (binding is VariableDeclaration) {
VariableDeclaration var_decl = (VariableDeclaration) binding;
string error_msg = Location.SourceName + "(" + var_decl.Location.LineNumber + ",0) : "
+ "error JS5040: '" + var_decl.id + "' is read-only";
throw new Exception (error_msg);
}
}
void ICanModifyContext.EmitDecls (EmitContext ec)
{
((ICanModifyContext) func_obj.body).EmitDecls (ec);
}
internal override bool Resolve (Environment env)
{
set_function_type ();
env.BeginScope (String.Empty);
lexical_depth = env.Depth (String.Empty);
((ICanModifyContext) func_obj).PopulateContext (env, String.Empty);
FormalParameterList p = func_obj.parameters;
if (p != null)
p.Resolve (env);
Block body = func_obj.body;
if (body != null)
body.Resolve (env);
locals = env.CurrentLocals (String.Empty);
env.EndScope (String.Empty);
return true;
}
}
}

Просмотреть файл

@ -0,0 +1,261 @@
//
// FunctionExpression.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, 2004, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Collections;
using System.Reflection.Emit;
using Microsoft.JScript.Vsa;
namespace Microsoft.JScript {
public class FunctionExpression : Function, ICanModifyContext {
internal LocalBuilder local_script_func;
internal FieldBuilder field;
internal FunctionExpression (AST parent, string name, Location location)
: this (parent, name, null, String.Empty, null, location)
{
this.location = location;
}
internal FunctionExpression (AST parent, string name,
FormalParameterList p,
string return_type, Block body, Location location)
: base (parent, location)
{
func_obj = new FunctionObject (name, p, return_type, body, location);
}
public static FunctionObject JScriptFunctionExpression (RuntimeTypeHandle handle, string name,
string methodName, string [] formalParams,
JSLocalField [] fields, bool mustSaveStackLocals,
bool hasArgumentsObject, string text,
VsaEngine engine)
{
MethodInfo method = engine.ScriptObjectStackTop ().GetType ().GetMethod (methodName);
FunctionObject fun = new FunctionObject (method);
fun.source = text;
fun.vsa_engine = engine;
return fun;
}
void ICanModifyContext.PopulateContext (Environment env, string ns)
{
//
// In the case of function
// expressions we add
// function's name to the
// table but we resolve its
// body until later, as free
// variables can be referenced
// in function's body.
//
string name = func_obj.name;
AST binding = null;
if (name != null && name != String.Empty)
binding = (AST) env.Get (ns, Symbol.CreateSymbol (name));
if (binding == null)
env.Enter (ns, Symbol.CreateSymbol (name), new FunctionDeclaration ());
else {
Console.WriteLine ("repeated functions are not handled yet");
throw new NotImplementedException ();
}
}
void ICanModifyContext.EmitDecls (EmitContext ec)
{
((ICanModifyContext) func_obj.body).EmitDecls (ec);
}
internal override bool Resolve (Environment env)
{
set_prefix ();
set_function_type ();
if (func_obj.name != null && func_obj.name != String.Empty)
env.Enter (String.Empty, Symbol.CreateSymbol (func_obj.name), this);
env.BeginScope (String.Empty);
((ICanModifyContext) func_obj).PopulateContext (env, String.Empty);
FormalParameterList p = func_obj.parameters;
if (p != null)
p.Resolve (env);
Block body = func_obj.body;
if (body != null)
body.Resolve (env);
locals = env.CurrentLocals (String.Empty);
env.EndScope (String.Empty);
return true;
}
internal override void Emit (EmitContext ec)
{
TypeManager.BeginScope ();
string name = func_obj.name;
string full_name;
TypeBuilder type = ec.type_builder;
ILGenerator ig = ec.ig;
if (prefix == null || prefix == String.Empty) {
if (name == String.Empty)
full_name = SemanticAnalyser.NextAnonymousMethod;
else
full_name = name;
} else {
if (name == String.Empty)
full_name = prefix + "." + SemanticAnalyser.NextAnonymousMethod;
else
full_name = prefix + "." + name;
}
MethodBuilder method_builder = type.DefineMethod (full_name, func_obj.attr,
HandleReturnType,
func_obj.params_types ());
MethodBuilder tmp = (MethodBuilder) TypeManager.Get (name);
if (tmp == null)
TypeManager.Add (name, method_builder);
else
TypeManager.Set (name, method_builder);
set_custom_attr (method_builder);
EmitContext new_ec = new EmitContext (ec.type_builder, ec.mod_builder,
method_builder.GetILGenerator ());
if (InFunction) {
local_script_func = ig.DeclareLocal (typeof (ScriptFunction));
local_func = ig.DeclareLocal (typeof (FunctionObject));
} else {
if (name != String.Empty) {
field = type.DefineField (name, typeof (object), FieldAttributes.Public | FieldAttributes.Static);
local_func = ig.DeclareLocal (typeof (FunctionObject));
} else
local_func = ig.DeclareLocal (typeof (FunctionObject));
}
build_closure (ec, full_name, func_obj.source);
func_obj.body.Emit (new_ec);
new_ec.ig.Emit (OpCodes.Ret);
TypeManager.EndScope ();
}
internal void build_closure (EmitContext ec, string full_name, string encodedSource)
{
ILGenerator ig = ec.ig;
string name = func_obj.name;
Type t = ec.mod_builder.GetType (CodeGenerator.GetTypeName (Location.SourceName));
ig.Emit (OpCodes.Ldtoken, t);
if (name != String.Empty)
ig.Emit (OpCodes.Ldstr, name);
else
ig.Emit (OpCodes.Ldstr, SemanticAnalyser.CurrentAnonymousMethod);
ig.Emit (OpCodes.Ldstr, full_name);
func_obj.parameters.Emit (ec);
build_local_fields (ig);
ig.Emit (OpCodes.Ldc_I4_0); // FIXME: this hard coded for now.
ig.Emit (OpCodes.Ldc_I4_0); // FIXME: this hard coded for now.
ig.Emit (OpCodes.Ldstr, Decompiler.Decompile (encodedSource, 0, 0).Trim ());
CodeGenerator.load_engine (InFunction, ig);
ig.Emit (OpCodes.Call, typeof (FunctionExpression).GetMethod ("JScriptFunctionExpression"));
ig.Emit (OpCodes.Stloc, local_func);
ig.Emit (OpCodes.Ldloc, local_func);
ig.Emit (OpCodes.Newobj, typeof (Closure).GetConstructor (new Type [] {typeof (FunctionObject)}));
if (name != String.Empty) {
ig.Emit (OpCodes.Dup);
if (parent == null || parent.GetType () == typeof (ScriptBlock))
ig.Emit (OpCodes.Stsfld, field);
else if (parent != null &&
(parent.GetType () == typeof (FunctionDeclaration)
|| parent.GetType () == typeof (FunctionExpression)))
ig.Emit (OpCodes.Stloc, local_script_func);
} else {
if (parent != null &&
(parent.GetType () == typeof (FunctionDeclaration)
|| parent.GetType () == typeof (FunctionExpression))) {
ig.Emit (OpCodes.Dup);
ig.Emit (OpCodes.Stloc, local_script_func);
}
}
}
internal void build_local_fields (ILGenerator ig)
{
object e;
int n;
if (locals == null)
n = 0;
else
n = locals.Length;
Type t = typeof (JSLocalField);
ConstructorInfo ctr_info = t.GetConstructor (new Type [] {
typeof (string), typeof (RuntimeTypeHandle), typeof (Int32) });
if (not_void_return)
ig.Emit (OpCodes.Ldc_I4, n + 1);
else
ig.Emit (OpCodes.Ldc_I4, n);
ig.Emit (OpCodes.Newarr, t);
for (int i = 0; i < n; i++) {
ig.Emit (OpCodes.Dup);
ig.Emit (OpCodes.Ldc_I4, i);
e = locals [i];
ig.Emit (OpCodes.Ldstr, GetName (e));
if (e is VariableDeclaration)
ig.Emit (OpCodes.Ldtoken, ((VariableDeclaration) e).type);
else if (e is FormalParam)
ig.Emit (OpCodes.Ldtoken, ((FormalParam) e).type);
else if (e is FunctionDeclaration)
ig.Emit (OpCodes.Ldtoken, typeof (ScriptFunction));
else if (e is FunctionExpression)
ig.Emit (OpCodes.Ldtoken, typeof (object));
ig.Emit (OpCodes.Ldc_I4, i);
ig.Emit (OpCodes.Newobj, ctr_info);
ig.Emit (OpCodes.Stelem_Ref);
}
if (not_void_return)
emit_return_local_field (ig, ctr_info, n);
}
}
}

Просмотреть файл

@ -0,0 +1,133 @@
//
// FunctionObject.cs:
//
// Author:
// Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Text;
using System.Reflection;
using System.Collections;
namespace Microsoft.JScript {
public class FunctionObject : ScriptFunction, ICanModifyContext {
internal string type_annot;
internal Block body;
internal Location location;
internal FunctionObject (string name)
{
this._prototype = ObjectConstructor.Ctr.ConstructObject ();
this.name = name;
}
internal FunctionObject (MethodInfo info)
{
this._prototype = ObjectConstructor.Ctr.ConstructObject ();
this.method = info;
this.name = info.Name;
this.attr = info.Attributes;
this.return_type = info.ReturnType;
}
internal FunctionObject (string name, FormalParameterList p, string ret_type, Block body, Location location)
{
this._prototype = ObjectConstructor.Ctr.ConstructObject ();
//
// FIXME
// 1) Must collect the attributes given.
// 2) Check if they are semantically correct.
// 3) Assign those values to 'attr'.
//
this.attr = MethodAttributes.Public | MethodAttributes.Static;
this.name = name;
this.parameters = p;
this.type_annot = ret_type;
//
// FIXME: Must check that return_type it's a valid type,
// and assign that to 'return_type' field.
//
this.return_type = typeof (void);
this.body = body;
this.location = location;
}
public override int length {
get {
if (this.parameters != null)
return this.parameters.ids.Count;
else
return base.length;
}
set { base.length = value; }
}
internal FunctionObject ()
{
this.parameters = new FormalParameterList (location);
}
internal Type [] params_types ()
{
if (parameters == null)
return
new Type [] {typeof (Object), typeof (Microsoft.JScript.Vsa.VsaEngine)};
else {
int i, size;
ArrayList p = parameters.ids;
size = p.Count + 2;
Type [] types = new Type [size];
types [0] = typeof (Object);
types [1] = typeof (Microsoft.JScript.Vsa.VsaEngine);
for (i = 2; i < size; i++)
types [i] = ((FormalParam) p [i - 2]).type;
return types;
}
}
void ICanModifyContext.PopulateContext (Environment env, string ns)
{
((ICanModifyContext) body).PopulateContext (env, ns);
}
void ICanModifyContext.EmitDecls (EmitContext ec)
{
((ICanModifyContext) body).EmitDecls (ec);
}
}
}

Просмотреть файл

@ -0,0 +1,67 @@
//
// FunctionPrototype.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public class FunctionPrototype : ScriptFunction {
internal static FunctionPrototype Proto = new FunctionPrototype ();
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Function_apply)]
public static object apply (object thisObj, object thisArg, object argArray)
{
object [] args = (object []) Convert.ToNativeArray (argArray, typeof (object).TypeHandle);
return call (thisObj, thisArg, args);
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject | JSFunctionAttributeEnum.HasVarArgs, JSBuiltin.Function_call)]
public static object call (object thisObj, object thisArg, params object [] args)
{
SemanticAnalyser.assert_type (thisObj, typeof (ScriptFunction));
ScriptFunction fun = (ScriptFunction) thisObj;
return fun.Invoke (thisArg, args);
}
public static FunctionConstructor constructor {
get { return FunctionConstructor.Ctr; }
}
[JSFunctionAttribute (JSFunctionAttributeEnum.HasThisObject, JSBuiltin.Function_toString)]
public static string toString (object thisObj)
{
if (thisObj is ScriptFunction)
return (((ScriptFunction) thisObj).ToString ());
throw new JScriptException (JSError.FunctionExpected);
}
}
}

Просмотреть файл

@ -0,0 +1,42 @@
//
// FunctionWrapper.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public sealed class FunctionWrapper : ScriptFunction
{
public override string ToString ()
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,650 @@
//
// GlobalObject.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Text;
using System.Globalization;
using System.Text.RegularExpressions;
namespace Microsoft.JScript {
public class GlobalObject {
public const double Infinity = Double.PositiveInfinity;
public const double NaN = Double.NaN;
public static readonly Empty undefined = null;
protected ActiveXObjectConstructor originalActiveXObjectField;
protected ArrayConstructor originalArrayField;
protected BooleanConstructor originalBooleanField;
protected DateConstructor originalDateField;
protected EnumeratorConstructor originalEnumeratorField;
protected ErrorConstructor originalErrorField;
protected ErrorConstructor originalEvalErrorField;
protected FunctionConstructor originalFunctionField;
protected NumberConstructor originalNumberField;
protected ObjectConstructor originalObjectField;
protected ObjectPrototype originalObjectPrototypeField;
protected ErrorConstructor originalRangeErrorField;
protected ErrorConstructor originalReferenceErrorField;
protected RegExpConstructor originalRegExpField;
protected StringConstructor originalStringField;
protected ErrorConstructor originalSyntaxErrorField;
protected ErrorConstructor originalTypeErrorField;
protected ErrorConstructor originalURIErrorField;
protected VBArrayConstructor originalVBArrayField;
public static ActiveXObjectConstructor ActiveXObject {
get { return ActiveXObjectConstructor.Ctr; }
}
public static ArrayConstructor Array {
get { return ArrayConstructor.Ctr; }
}
public static BooleanConstructor Boolean {
get { return BooleanConstructor.Ctr; }
}
public static Type boolean {
get { throw new NotImplementedException (); }
}
public static Type @byte {
get { throw new NotImplementedException (); }
}
public static Type @char {
get { throw new NotImplementedException (); }
}
[JSFunctionAttribute (0, JSBuiltin.Global_CollectGarbage)]
public static void CollectGarbage ()
{
GC.Collect ();
}
public static DateConstructor Date {
get { return DateConstructor.Ctr; }
}
public static Type @decimal {
get { throw new NotImplementedException (); }
}
//
// ECMA 3, 15.1.3 URI handling Function Properties
//
// The following are implementations of the algorithms
// given in the ECMA specification for the hidden functions
// 'Encode' and 'Decode'.
//
static string encode (string str, bool full_uri)
{
byte [] utf8_buf = null;
StringBuilder sb = null;
for (int k = 0, length = str.Length; k != length; ++k) {
char c = str [k];
if (encode_unescaped (c, full_uri)) {
if (sb != null)
sb.Append (c);
} else {
if (sb == null) {
sb = new StringBuilder (length + 3);
sb.Append (str);
sb.Length = k;
utf8_buf = new byte [6];
}
if (0xDC00 <= c && c <= 0xDFFF)
throw new Exception ("msg.bad.uri");
int v;
if (c < 0xD800 || 0xDBFF < c)
v = c;
else {
k++;
if (k == length)
throw new Exception ("msg.bad.uri");
char c2 = str [k];
if (!(0xDC00 <= c2 && c2 <= 0xDFFF))
throw new Exception ("msg.bad.uri");
v = ((c - 0xD800) << 10) + (c2 - 0xDC00) + 0x10000;;
}
int L = one_ucs4_to_utf8_char (utf8_buf, v);
for (int j = 0; j < L; j++) {
int d = 0xff & utf8_buf [j];
sb.Append ('%');
sb.Append (to_hex_char (d >> 4));
sb.Append (to_hex_char (d & 0xf));
}
}
}
return (sb == null) ? str : sb.ToString ();
}
static char to_hex_char (int i)
{
if (i >> 4 != 0)
throw new Exception ("to_hex_char, code bug");
return (char) ((i < 10) ? i + '0' : i - 10 + 'a');
}
static readonly string URI_DECODE_RESERVED = ";/?:@&=+$,#";
//
// Convert one UCS-4 char and write it into a UTF-8 buffer, which must be
// at least 6 bytes long. Return the number of UTF-8 bytes of data written.
//
static int one_ucs4_to_utf8_char (byte [] utf8_buf, int ucs4char)
{
int utf8_length = 1;
if ((ucs4char & ~0x7f) == 0)
utf8_buf [0] = (byte) ucs4char;
else {
int i;
int a = ucs4char >> 11;
utf8_length = 2;
while (a != 0) {
a >>= 5;
utf8_length++;
}
i = utf8_length;
while (--i > 0) {
utf8_buf [i] = (byte) ((ucs4char & 0x3F) | 0x80);
ucs4char >>= 6;
}
utf8_buf [0] = (byte) (0x100 - (1 << (8 - utf8_length)) + ucs4char);
}
return utf8_length;
}
static bool encode_unescaped (char c, bool fullUri)
{
if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || ('0' <= c && c <= '9'))
return true;
if ("-_.!~*'()".IndexOf (c) >= 0)
return true;
if (fullUri)
return URI_DECODE_RESERVED.IndexOf (c) >= 0;
return false;
}
static string decode (string str, bool fullUri)
{
char [] buf = null;
int buf_top = 0;
for (int k = 0, length = str.Length; k != length; ) {
char c = str [k];
if (c != '%') {
if (buf != null)
buf [buf_top++] = c;
++k;
} else {
if (buf != null) {
// decode always compress so result can not be bigger then
// str.length()
buf = new char [length];
str.CopyTo (0, buf, 0, k);
buf_top = k;
}
int start = k;
if (k + 3 > length)
throw new Exception ("msg.bad.uri");
int b = un_hex (str [k + 1], str [k + 2]);
if (b < 0)
throw new Exception ("msg.bad.uri");
k += 3;
if ((b & 0x80) == 0)
c = (char) b;
else {
// Decode UTF-8 sequence into ucs4Char and encode it into
// UTF-16
int utf8_tail, ucs4char, min_ucs4_char;
if ((b & 0xC0) == 0x80) {
// First UTF-8 should be ouside 0x80..0xBF
throw new Exception ("msg.bad.uri");
} else if ((b & 0x20) == 0) {
utf8_tail = 1;
ucs4char = b & 0x1F;
min_ucs4_char = 0x80;
} else if ((b & 0x10) == 0) {
utf8_tail = 2;
ucs4char = b & 0x0F;
min_ucs4_char = 0x800;
} else if ((b & 0x08) == 0) {
utf8_tail = 3;
ucs4char = b & 0x07;
min_ucs4_char = 0x10000;
} else if ((b & 0x04) == 0) {
utf8_tail = 4;
ucs4char = b & 0x03;
min_ucs4_char = 0x200000;
} else if ((b & 0x02) == 0) {
utf8_tail = 5;
ucs4char = b & 0x01;
min_ucs4_char = 0x4000000;
} else {
// First UTF-8 can not be 0xFF or 0xFE
throw new Exception ("msg.bad.uri");
}
if (k + 3 * utf8_tail > length)
throw new Exception ("msg.bad.uri");
for (int j = 0; j != utf8_tail; j++) {
if (str [k] != '%')
throw new Exception ("msg.bad.uri");
b = un_hex (str [k + 1], str [k + 2]);
if (b < 0 || (b & 0xC0) != 0x80)
throw new Exception ("msg.bad.uri");
ucs4char = (ucs4char << 6) | (b & 0x3F);
k += 3;
}
// Check for overlongs and other should-not-present codes
if (ucs4char < min_ucs4_char || ucs4char == 0xFFFE || ucs4char == 0xFFFF)
ucs4char = 0xFFFD;
if (ucs4char >= 0x10000) {
ucs4char -= 0x10000;
if (ucs4char > 0xFFFFF)
throw new Exception ("msg.bad.uri");
char h = (char) ((ucs4char >> 10) + 0xD800);
c = (char) ((ucs4char & 0x3FF) + 0xDC00);
buf [buf_top++] = h;
} else
c = (char) ucs4char;
}
if (fullUri && URI_DECODE_RESERVED.IndexOf (c) >= 0)
for (int x = start; x != k; x++)
buf [buf_top++] = str [x];
else
buf [buf_top++] = c;
}
}
return (buf == null) ? str : new string (buf, 0, buf_top);
}
static int un_hex (char c1, char c2)
{
int i1 = un_hex (c1);
int i2 = un_hex (c2);
if (i1 >= 0 && i2 >= 0)
return (i1 << 4) | i2;
return -1;
}
static int un_hex (char c)
{
if ('A' <= c && c <= 'F')
return c - 'A' + 10;
else if ('a' <= c && c <= 'f')
return c - 'a' + 10;
else if ('0' <= c && c <= '9')
return c - '0';
else
return -1;
}
[JSFunctionAttribute (0, JSBuiltin.Global_decodeURI)]
public static String decodeURI (Object encodedURI)
{
string encoded_uri_str = Convert.ToString (encodedURI, true);
return decode (encoded_uri_str, true);
}
[JSFunctionAttribute (0, JSBuiltin.Global_decodeURIComponent)]
public static String decodeURIComponent (Object encodedURI)
{
string encoded_uri_str = Convert.ToString (encodedURI, true);
return decode (encoded_uri_str, false);
}
public static Type @double {
get { throw new NotImplementedException (); }
}
[JSFunctionAttribute (0, JSBuiltin.Global_encodeURI)]
public static String encodeURI (Object uri)
{
string uri_str = Convert.ToString (uri, true);
return encode (uri_str, true);
}
[JSFunctionAttribute (0, JSBuiltin.Global_encodeURIComponent)]
public static String encodeURIComponent (Object uriComponent)
{
string uri_str = Convert.ToString (uriComponent, true);
return encode (uri_str, false);
}
public static EnumeratorConstructor Enumerator {
get { return EnumeratorConstructor.Ctr; }
}
public static ErrorConstructor Error {
get { return ErrorConstructor.Ctr; }
}
internal const string no_escape_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@*_+-./";
[JSFunctionAttribute (0, JSBuiltin.Global_escape)]
public static String escape (Object @string)
{
string str = Convert.ToString (@string);
StringBuilder sb = new StringBuilder ();
int n = str.Length;
char c;
for (int i = 0; i < n; i++) {
c = str [i];
if (no_escape_chars.IndexOf (c) != -1)
sb.Append (c);
else if (c < 256) {
sb.Append ("%");
sb.Append (((int) c).ToString ("X2"));
} else {
sb.Append ("%u");
sb.Append (((int) c).ToString ("X4"));
}
}
return sb.ToString ();
}
[JSFunctionAttribute (0, JSBuiltin.Global_eval)]
public static Object eval (Object x)
{
throw new NotImplementedException ();
}
public static ErrorConstructor EvalError {
get { return ErrorConstructor.EvalErrorCtr; }
}
public static Type @float {
get { throw new NotImplementedException (); }
}
public static FunctionConstructor Function {
get { return FunctionConstructor.Ctr; }
}
[JSFunctionAttribute (0, JSBuiltin.Global_GetObject)]
public static Object GetObject (Object moniker, Object progId)
{
throw new NotImplementedException ();
}
public static Type @int {
get { throw new NotImplementedException (); }
}
[JSFunctionAttribute (0, JSBuiltin.Global_isNaN)]
public static bool isNaN (Object num)
{
double number = Convert.ToNumber (num);
return Double.IsNaN (number);
}
[JSFunctionAttribute(0, JSBuiltin.Global_isFinite)]
public static bool isFinite (double number)
{
return !Double.IsInfinity (number) && !Double.IsNaN (number);
}
public static Type @long {
get { throw new NotImplementedException (); }
}
public static MathObject Math {
get { return MathObject.Object; }
}
public static NumberConstructor Number {
get { return NumberConstructor.Ctr; }
}
public static ObjectConstructor Object {
get { return ObjectConstructor.Ctr; }
}
internal static Regex float_re = new Regex (@"[\d+\-.eE]+");
[JSFunctionAttribute (0, JSBuiltin.Global_parseFloat)]
public static double parseFloat (Object @string)
{
string string_obj = Convert.ToString (@string).Trim ();
if (string_obj.StartsWith ("Infinity") || string_obj.StartsWith ("+Infinity"))
return Double.PositiveInfinity;
else if (string_obj.StartsWith ("-Infinity"))
return Double.NegativeInfinity;
if (string_obj.Trim () == "")
return 0;
// Would return an empty string if regular expression match returned 0.
object o = float_re.Match (string_obj).Value;
if (o is string){
string os = (string) o;
if (o != "")
string_obj = os;
}
double result;
if (Double.TryParse (string_obj, NumberStyles.Float, CultureInfo.InvariantCulture, out result))
return result;
else
return Double.NaN;
}
[JSFunctionAttribute (0, JSBuiltin.Global_parseInt)]
public static double parseInt(Object @string, Object radix)
{
String string_obj = Convert.ToString (@string).TrimStart (null).
ToLower (CultureInfo.InvariantCulture);
double result = 0;
int _radix = 0;
short sign = +1;
if (radix != null)
_radix = Convert.ToInt32 (radix);
if ((_radix != 0) && ((_radix < 2) || (_radix > 36)))
return Double.NaN;
if (string_obj.Length == 0)
return Double.NaN;
else if (string_obj.Length > 1) {
char first = string_obj [0];
if (first == '+' || first == '-') {
string_obj = string_obj.Substring (1);
if (first == '-')
sign = -1;
}
}
if ((_radix == 0 || _radix == 16) && string_obj.StartsWith ("0x")) {
string_obj = string_obj.Substring (2);
_radix = 16;
}
if (_radix == 0 && string_obj.StartsWith ("0"))
_radix = 8;
if (_radix == 0)
_radix = 10;
bool has_result = false;
for (int i = 0; i < string_obj.Length; i++) {
char digit = string_obj [i];
int digit_value = System.Array.IndexOf (NumberPrototype.Digits, digit);
if (digit_value == -1 || digit_value >= _radix)
break;
result = (result * _radix) + digit_value;
has_result = true;
}
if (!has_result)
return Double.NaN;
return result * sign;
}
public static ErrorConstructor RangeError {
get { return ErrorConstructor.RangeErrorCtr; }
}
public static ErrorConstructor ReferenceError {
get { return ErrorConstructor.ReferenceErrorCtr; }
}
public static RegExpConstructor RegExp {
get { return RegExpConstructor.Ctr; }
}
[JSFunctionAttribute (0, JSBuiltin.Global_ScriptEngine)]
public static String ScriptEngine ()
{
return "JScript";
}
[JSFunctionAttribute (0, JSBuiltin.Global_ScriptEngineBuildVersion)]
public static int ScriptEngineBuildVersion ()
{
return 0;
}
[JSFunctionAttribute(0, JSBuiltin.Global_ScriptEngineMajorVersion)]
public static int ScriptEngineMajorVersion ()
{
return 8;
}
[JSFunctionAttribute (0, JSBuiltin.Global_ScriptEngineMinorVersion)]
public static int ScriptEngineMinorVersion ()
{
return 0;
}
public static Type @sbyte {
get { throw new NotImplementedException (); }
}
public static Type @short {
get { throw new NotImplementedException (); }
}
public static StringConstructor String {
get { return StringConstructor.Ctr; }
}
public static ErrorConstructor SyntaxError {
get { return ErrorConstructor.SyntaxErrorCtr; }
}
public static ErrorConstructor TypeError {
get { return ErrorConstructor.TypeErrorCtr; }
}
[JSFunctionAttribute (0, JSBuiltin.Global_unescape)]
public static String unescape (Object @string)
{
string str = Convert.ToString (@string);
StringBuilder sb = new StringBuilder ();
int n = str.Length;
char c;
string d;
int s;
for (int i = 0; i < n; i++) {
c = str [i];
if (c != '%' || i == n - 1)
sb.Append (c);
else {
i++;
if (str [i] == 'u' && i < n - 4) {
i++;
s = 4;
} else if (i <= n - 2)
s = 2;
else
s = 0;
d = str.Substring (i, s);
i += s - 1;
char res = (char) parseInt (d, 16);
if (((int) res).ToString ("X" + s) == d)
sb.Append ((char) res);
else {
sb.Append ('%');
if (s == 4)
sb.Append ('u');
sb.Append (d);
}
}
}
return sb.ToString ();
}
public static ErrorConstructor URIError {
get { return ErrorConstructor.URIErrorCtr; }
}
public static VBArrayConstructor VBArray {
get { return VBArrayConstructor.Ctr; }
}
public static Type @void {
get { throw new NotImplementedException (); }
}
public static Type @uint {
get { throw new NotImplementedException (); }
}
public static Type @ulong {
get { throw new NotImplementedException (); }
}
public static Type @ushort {
get { throw new NotImplementedException (); }
}
}
}

Просмотреть файл

@ -0,0 +1,114 @@
//
// GlobalScope.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Reflection;
using System;
using System.Runtime.InteropServices.Expando;
using Microsoft.JScript.Vsa;
using System.Collections;
namespace Microsoft.JScript {
public class GlobalScope : ActivationObject, IExpando {
public GlobalScope (GlobalScope parent, VsaEngine engine)
: this (parent, engine, engine != null)
{
this.elems = new Hashtable ();
this.property_cache = new Hashtable ();
}
internal GlobalScope (GlobalScope parent, VsaEngine engine, bool is_comp_scope)
{
this.elems = new Hashtable ();
this.parent = parent;
this.engine = engine;
}
PropertyInfo IExpando.AddProperty (string name)
{
throw new NotImplementedException ();
}
MethodInfo IExpando.AddMethod (string name, Delegate method)
{
throw new NotImplementedException ();
}
void IExpando.RemoveMember (MemberInfo m)
{
throw new NotImplementedException ();
}
public override Object GetDefaultThisObject ()
{
return this;
}
public override FieldInfo GetField (string name, int lexLevel)
{
return GetField (name);
}
public override FieldInfo [] GetFields (BindingFlags bidFlags)
{
throw new NotImplementedException ();
}
public override GlobalScope GetGlobalScope ()
{
return this;
}
public override FieldInfo GetLocalField (string name)
{
throw new NotImplementedException ();
}
public override MemberInfo [] GetMember (string name, BindingFlags bindFlags)
{
throw new NotImplementedException ();
}
public override MemberInfo [] GetMembers (BindingFlags bindFlags)
{
throw new NotImplementedException ();
}
public override MethodInfo [] GetMethods (BindingFlags bindFlags)
{
throw new NotImplementedException ();
}
public override PropertyInfo [] GetProperties (BindingFlags bindFlags)
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,51 @@
//
// Globals.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using Microsoft.JScript.Vsa;
namespace Microsoft.JScript {
public sealed class Globals {
public static VsaEngine contextEngine;
public static ArrayObject ConstructArray (params object [] args)
{
throw new NotImplementedException ();
}
public static ArrayObject ConstructArrayLiteral (object [] args)
{
return new ArrayObject (args);
}
}
}

Просмотреть файл

@ -0,0 +1,43 @@
//
// IActivationObject.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
namespace Microsoft.JScript {
public interface IActivationObject {
Object GetDefaultThisObject ();
GlobalScope GetGlobalScope ();
FieldInfo GetLocalField (string name);
Object GetMemberValue (string name, int lexLevel);
FieldInfo GetField (string name, int lexLevel);
}
}

Просмотреть файл

@ -0,0 +1,41 @@
//
// IAuthorServices.cs:
//
// Author:
// Cesar Lopez Nataren
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("9E2B453C-6EAA-4329-A619-62E4889C8C8A")]
[ComVisibleAttribute (true)]
public interface IAuthorServices {
IParseText GetCodeSense ();
IColorizeText GetColorizer ();
}
}

Просмотреть файл

@ -0,0 +1,41 @@
//
// IColorizeText.cs:
//
// Author:
// Cesar Lopez Nataren
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("DB283E60-7ADB-4cf6-9758-2931893A12FC")]
[ComVisibleAttribute (true)]
public interface IColorizeText {
ITokenEnumerator Colorize (string sourceCode, SourceState state);
SourceState GetStateForText (string sourceCode, SourceState currentState);
}
}

Просмотреть файл

@ -0,0 +1,62 @@
//
// IDebugConvert.cs:
//
// Author:
// Cesar Lopez Nataren
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using Microsoft.Vsa;
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("AA51516D-C0F2-49fe-9D38-61D20456904C")]
[ComVisibleAttribute (true)]
public interface IDebugConvert {
string BooleanToString (bool value);
string ByteToString (byte value, int radix);
string DoubleToDateString (double value);
string DoubleToString (double value);
string GetErrorMessageForHR (int hr, IVsaEngine engine);
object GetManagedCharObject (ushort i);
object GetManagedInt64Object (long i);
object GetManagedObject (object value);
object GetManagedUInt64Object (ulong i);
string Int16ToString (short value, int radix);
string Int32ToString (int value, int radix);
string Int64ToString (long value, int radix);
string RegexpToString (string source, bool ignoreCase, bool global, bool multiline);
string SByteToString (sbyte value, int radix);
string SingleToString (float value);
string StringToPrintable (string source);
object ToPrimitive (object value, TypeCode typeCode, bool truncationPermitted);
string UInt16ToString (ushort value, int radix);
string UInt32ToString (uint value, int radix);
string UInt64ToString (ulong value, int radix);
}
}

Просмотреть файл

@ -0,0 +1,40 @@
//
// IDebugScriptScope.cs:
//
// Author:
// Cesar Lopez Nataren
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("59447635-3E26-4873-BF26-05F173B80F5E")]
[ComVisibleAttribute (true)]
public interface IDebugScriptScope {
void SetThisValue (object thisValue);
}
}

Просмотреть файл

@ -0,0 +1,40 @@
//
// IDebugType.cs:
//
// Author:
// Cesar Lopez Nataren (cnataren@novell.com)
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("613CC05D-05F4-4969-B369-5AEEF56E32D0")]
[ComVisibleAttribute (true)]
public interface IDebugType {
bool HasInstance (object o);
}
}

Просмотреть файл

@ -0,0 +1,42 @@
//
// IDebugVsaScriptCodeItem.cs:
//
// Author:
// Cesar Lopez Nataren (cnataren@novell.com)
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("6DFE759A-CB8B-4ca0-A973-1D04E0BF0B53")]
[ComVisibleAttribute (true)]
public interface IDebugVsaScriptCodeItem {
object Evaluate ();
bool ParseNamedBreakPoint(string input, out string functionName, out int nargs, out string arguments,
out string returnType, out ulong offset);
}
}

Просмотреть файл

@ -0,0 +1,44 @@
//
// IDebuggerObject.cs:
//
// Author:
// Cesar Lopez Nataren
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("8E93D770-6168-4b68-B896-A71B74C7076A")]
[ComVisibleAttribute (true)]
public interface IDebuggerObject {
bool HasEnumerableMember (string name);
bool IsCOMObject ();
bool IsEqual(IDebuggerObject o);
bool IsScriptFunction ();
bool IsScriptObject ();
}
}

Просмотреть файл

@ -0,0 +1,40 @@
//
// IDefineEvent.cs:
//
// Author:
// Cesar Lopez Nataren (cnataren@novell.com)
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("D1A19408-BB6B-43eb-BB6F-E7CF6AF047D7")]
[ComVisibleAttribute (true)]
public interface IDefineEvent {
object AddEvent(string code, int startLine);
}
}

Просмотреть файл

@ -0,0 +1,56 @@
//
// IEngine2.cs:
//
// Author:
// Cesar Lopez Nataren (cnataren@novell.com)
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using Microsoft.Vsa;
using System.Reflection;
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("BFF6C97F-0705-4394-88B8-A03A4B8B4CD7")]
[ComVisibleAttribute (true)]
public interface IEngine2 {
IVsaEngine Clone (AppDomain domain);
bool CompileEmpty ();
void ConnectEvents ();
void DisconnectEvents ();
Assembly GetAssembly ();
IVsaScriptScope GetGlobalScope ();
Module GetModule ();
void InitVsaEngine (string rootMoniker, IVsaSite site);
void Interrupt ();
void RegisterEventSource (string name);
void Restart ();
void Run (AppDomain domain);
void RunEmpty ();
}
}

Просмотреть файл

@ -0,0 +1,40 @@
//
// IErrorHandler.cs:
//
// Author:
// Cesar Lopez Nataren
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[ComVisibleAttribute (true)]
[GuidAttribute ("E93D012C-56BB-4f32-864F-7C75EDA17B14")]
public interface IErrorHandler {
bool OnCompilerError (IVsaFullErrorInfo error);
}
}

Просмотреть файл

@ -0,0 +1,39 @@
//
// IMethodsCompletionInfo.cs:
//
// Author:
// Cesar Lopez Nataren (cnataren@novell.com)
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[ComVisibleAttribute (true)]
[GuidAttribute ("E0BCF37B-1C24-451c-AC43-40FF86839117")]
public interface IMethodsCompletionInfo {
}
}

Просмотреть файл

@ -0,0 +1,39 @@
//
// INeedEngine.cs:
//
// Author:
// Cesar Lopez Nataren (cnataren@novell.com)
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using Microsoft.JScript.Vsa;
namespace Microsoft.JScript {
public interface INeedEngine {
VsaEngine GetEngine ();
void SetEngine (VsaEngine engine);
}
}

Просмотреть файл

@ -0,0 +1,41 @@
//
// IObjectCompletionInfo.cs:
//
// Author:
// Cesar Lopez Nataren (cnataren@novell.com)
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("052019B5-704B-4b99-AEF8-25A11A922B2E")]
[ComVisibleAttribute (true)]
public interface IObjectCompletionInfo {
}
}

Просмотреть файл

@ -0,0 +1,40 @@
//
// IParseText.cs:
//
// Author:
// Cesar Lopez Nataren
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("C1468187-3DA1-49df-ADF8-5F8600E59EA8")]
[ComVisibleAttribute (true)]
public interface IParseText {
void Parse (string code, IErrorHandler error);
}
}

Просмотреть файл

@ -0,0 +1,108 @@
//
// IRedirectOutput.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute("5B807FA1-00CD-46ee-A493-FD80AC944715")]
[ComVisibleAttribute (true)]
public interface IRedirectOutput
{
void SetOutputStream (IMessageReceiver output);
}
[GuidAttribute ("F062C7FB-53BF-4f0d-B0F6-D66C5948E63F")]
[ComVisibleAttribute (true)]
public interface IMessageReceiver
{
void Message (string strValue);
}
public class COMCharStream : Stream {
public COMCharStream (IMessageReceiver messageReceiver)
{
throw new NotImplementedException ();
}
public override bool CanWrite {
get { throw new NotImplementedException (); }
}
public override bool CanRead {
get { throw new NotImplementedException (); }
}
public override bool CanSeek {
get { throw new NotImplementedException (); }
}
public override long Length {
get { throw new NotImplementedException (); }
}
public override long Position {
get { throw new NotImplementedException (); }
set { throw new NotImplementedException (); }
}
public override void Close ()
{
throw new NotImplementedException ();
}
public override void Flush ()
{
throw new NotImplementedException ();
}
public override int Read (byte [] buffer, int offset, int count)
{
throw new NotImplementedException ();
}
public override long Seek (long offset, SeekOrigin origin)
{
throw new NotImplementedException ();
}
public override void SetLength (long value)
{
throw new NotImplementedException ();
}
public override void Write (byte [] buffer, int offset, int cont)
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,41 @@
//
// ISite2.cs:
//
// Author:
// Cesar Lopez Nataren (cnataren@novell.com)
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("BFF6C980-0705-4394-88B8-A03A4B8B4CD7")]
[InterfaceTypeAttribute (ComInterfaceType.InterfaceIsIUnknown)]
[ComVisibleAttribute (true)]
public interface ISite2 {
object [] GetParentChain (object obj);
}
}

Просмотреть файл

@ -0,0 +1,42 @@
//
// ITokenColorInfo.cs:
//
// Author:
// Cesar Lopez Nataren
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[ComVisibleAttribute (true)]
[GuidAttribute ("0F20D5C8-CBDB-4b64-AB7F-10B158407323")]
public interface ITokenColorInfo {
TokenColor Color { get; }
int EndPosition { get; }
int StartPosition { get; }
}
}

Просмотреть файл

@ -0,0 +1,41 @@
//
// ITokenEnumerator.cs:
//
// Author:
// Cesar Lopez Nataren
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("556BA9E0-BD6A-4837-89F0-C79B14759181")]
[ComVisibleAttribute (true)]
public interface ITokenEnumerator {
ITokenColorInfo GetNext ();
void Reset ();
}
}

Просмотреть файл

@ -0,0 +1,41 @@
//
// IVsaFullErrorInfo.cs:
//
// Author:
// Cesar Lopez Nataren
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using Microsoft.Vsa;
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[ComVisibleAttribute (true)]
[GuidAttribute ("DC3691BC-F188-4b67-8338-326671E0F3F6")]
public interface IVsaFullErrorInfo : IVsaError {
int EndLine { get; }
}
}

Просмотреть файл

@ -0,0 +1,44 @@
//
// IVsaScriptCodeItem.cs:
//
// Author:
// Cesar Lopez Nataren (cnataren@novell.com)
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Runtime.InteropServices;
using Microsoft.Vsa;
namespace Microsoft.JScript {
[InterfaceTypeAttribute (ComInterfaceType.InterfaceIsIUnknown)]
[GuidAttribute ("E0C0FFE8-7eea-4ee5-b7e4-0080c7eb0b74")]
[ComVisibleAttribute (true)]
public interface IVsaScriptCodeItem : IVsaCodeItem, IVsaItem {
object Execute ();
int StartColumn { get; set; }
int StartLine { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,62 @@
//
// IVsaScriptScope.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using Microsoft.Vsa;
using System.Runtime.InteropServices;
namespace Microsoft.JScript {
[GuidAttribute ("ED4BAE22-2F3C-419a-B487-CF869E716B95")]
[ComVisibleAttribute (true)]
public interface IVsaScriptScope : IVsaItem {
IVsaScriptScope Parent {
get;
}
IVsaItem AddItem (string itemName, VsaItemType type);
IVsaItem GetItem (string itemName);
void RemoveItem (string itemName);
void RemoveItem (IVsaItem item);
int GetItemCount ();
IVsaItem GetItemAtIndex (int index);
void RemoveItemAtIndex (int index);
Object GetObject ();
IVsaItem CreateDynamicItem (string itemName, VsaItemType type);
}
}

Просмотреть файл

@ -0,0 +1,36 @@
//
// IWrappedMember.cs:
//
// Author:
// Cesar Lopez Nataren (cnataren@novell.com)
//
// (C) 2005, Novell Inc. (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Microsoft.JScript {
public interface IWrappedMember {
object GetWrappedObject ();
}
}

Просмотреть файл

@ -0,0 +1,503 @@
//
// IdentificationTable.cs: Implementation of environments for jscript. Using a
// modified version of the algorithm and date structure presented by
// Andrew W. Appel in his book Modern compiler implementation in Java,
// second edition.
//
// Author:
// Cesar Lopez Nataren (cnataren@novell.com)
//
// (C) 2003, Cesar Lopez Nataren
// Copyright (C) 2005 Novell Inc (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Collections;
namespace Microsoft.JScript {
/// <summary>
/// Class that encapsulates a string id for faster hashing purposes.
/// </summary>
internal class Symbol {
private string name;
private static Hashtable dict = new Hashtable ();
internal string Value {
get { return name; }
}
private Symbol (string name)
{
this.name = name;
}
public override string ToString ()
{
return name;
}
/// <summary>
/// Return the unique symbol associated with a
/// string. Repeated calls to CreateSymbol will return the
/// same Symbol.
/// </summary>
internal static Symbol CreateSymbol (string n)
{
n = LateBinding.MapToInternalName (n);
string u = String.Intern (n);
Symbol s = (Symbol) dict [u];
if (s == null) {
s = new Symbol (u);
dict [u] = s;
}
return s;
}
}
/// <summary>
/// Associates a symbol to its declaring object.
/// </summary>
internal class Binder {
object value;
Symbol prev_top;
/// <remarks>
/// If the symbol is already in the environment, resolves
/// collisions with external chaining.
/// </remarks>
Binder tail;
internal object Value {
get { return value; }
set { this.value = value; }
}
internal Binder Tail {
get { return tail; }
}
internal Symbol PrevTop {
get { return prev_top; }
}
internal Binder (object value, Symbol prev_top, Binder tail)
{
this.value = value;
this.prev_top = prev_top;
this.tail = tail;
}
}
/// <summary>
/// Environment implementation, each key must be a Symbol and we take
/// care of scoping.
/// </summary>
internal class IdentificationTable {
private Hashtable dict = new Hashtable ();
private Symbol top;
private Binder marks;
private Stack locals;
private bool previous_scope = false;
private bool catch_scope = false;
internal bool CatchScope {
get { return catch_scope; }
}
internal int depth;
internal IdentificationTable ()
{
locals = new Stack ();
locals.Push (new Hashtable ());
depth = 0;
}
internal bool Contains (Symbol key)
{
Binder e = (Binder) dict [key];
return e != null;
}
/// <summary>
/// Gets the object associated to the symbol in the table
/// </summary>
internal object Get (Symbol key)
{
Binder e = (Binder) dict [key];
if (e == null)
return null;
else
return e.Value;
}
/// <summary>
/// Bind a key
/// </summary>
internal void Enter (Symbol key, object value)
{
Binder e = (Binder) dict [key];
/// <remarks>
/// If a Binder's Value is null means that it
/// represents a in-transit binding, we must
/// set its value to something useful.
/// </remarks>
if (e != null && e.Value == null)
e.Value = value;
else {
//
// If 'key' is already on the table we form a
// Binder's chain, otherwise we include the new key
// represented with its association object.
//
dict [key] = new Binder (value, top, (Binder) dict [key]);
//
// make 'key' the most recent symbol bound
//
top = key;
}
Hashtable top_ht = (Hashtable) locals.Peek ();
string val = key.Value;
top_ht[val] = value;
}
/// <summary>
/// Delete symbol from the table
/// </summary>
internal void Remove (Symbol key)
{
Binder e = (Binder) dict [key];
if (e != null)
if (e.Tail != null)
dict [key] = e.Tail;
else
dict.Remove (key);
}
internal void BeginScope ()
{
BeginScope (false);
}
/// <summary>
/// Remembers the current state of the table
/// </summary>
internal void BeginScope (bool catchScope)
{
previous_scope = catch_scope;
catch_scope = catchScope;
marks = new Binder (null, top, marks);
top = null;
locals.Push (new Hashtable ());
depth++;
}
/// <summary>
/// Restores the table to what it was at the most recent BeginScope
/// that has not already been ended
/// </summary>
internal void EndScope ()
{
//
// Delete all the elements until we find
// that top is null, that occurs when we find
// the scope marker.
//
while (top != null) {
Binder e = (Binder) dict [top];
//
// If there's a chain we delete the first
// element of it, otherwise remove the symbol
// from the table.
//
if (e.Tail != null)
dict [top] = e.Tail;
else
dict.Remove (top);
top = e.PrevTop;
}
//
// marks.PrevTop always contains the latest symbol
// which was bound before the new scope was created.
//
top = marks.PrevTop;
//
// delete the latest scope mark
//
marks = marks.Tail;
locals.Pop ();
depth--;
catch_scope = previous_scope;
}
internal object [] CurrentLocals {
get {
Stack stack = new Stack ();
Symbol _top = top;
while (_top != null) {
Binder e = (Binder) dict [_top];
stack.Push (e.Value);
_top = e.PrevTop;
}
if (stack.Count == 0)
return null;
object [] res = new object [stack.Count];
stack.CopyTo (res, 0);
return res;
}
}
internal bool InCurrentScope (Symbol id)
{
Hashtable hash = (Hashtable) locals.Peek ();
return hash.ContainsKey (id.Value) && hash [id.Value] != null;
}
internal void AddToCurrentLocals (string name, object o)
{
((Hashtable) locals.Peek ()).Add (name, o);
}
internal DictionaryEntry [] LocalsAtDepth (int depth)
{
object [] hashes = new object [locals.Count];
locals.CopyTo (hashes, 0);
Hashtable hash = (Hashtable) hashes [locals.Count - depth - 1];
DictionaryEntry [] _locals = new DictionaryEntry [hash.Count];
hash.CopyTo (_locals, 0);
return _locals;
}
}
//
// Lookup table with namespace context.
//
internal class Environment {
private Hashtable namespaces;
internal Environment ()
{
namespaces = new Hashtable ();
//
// global variables identification table
//
namespaces.Add (String.Empty, new IdentificationTable ());
}
internal Environment (ScriptBlock [] blocks)
: this ()
{
//
// FIXME: when we implement the package stm. For each package
// name we must add a identification table that will store
// id's defined inside it.
//
//
// integrate the builtin functions, objects, ...
//
BuildGlobalEnv ();
}
//
// retrieves the identification table for the ns namespace
//
internal IdentificationTable GetIdentificationTable (string ns)
{
return (IdentificationTable) namespaces [ns];
}
internal bool Contains (string ns, Symbol key)
{
IdentificationTable symbols = (IdentificationTable) namespaces [ns];
if (symbols == null)
return false;
return symbols.Contains (key);
}
internal object Get (string ns, Symbol key)
{
IdentificationTable symbols = (IdentificationTable) namespaces [ns];
if (symbols == null)
return null;
return symbols.Get (key);
}
internal void Enter (string ns, Symbol key, object value)
{
IdentificationTable symbols = (IdentificationTable) namespaces [ns];
if (symbols == null)
throw new Exception (ns + " does not exist");
symbols.Enter (key, value);
}
internal void Remove (string ns, Symbol key)
{
IdentificationTable symbols = (IdentificationTable) namespaces [ns];
if (symbols == null)
throw new Exception (ns + " does not exist");
symbols.Remove (key);
}
internal void BeginScope (string ns)
{
IdentificationTable symbols = (IdentificationTable) namespaces [ns];
if (symbols == null)
throw new Exception (ns + " does not exist");
symbols.BeginScope ();
}
internal void BeginScope (string ns, bool catchScope)
{
IdentificationTable symbols = (IdentificationTable) namespaces [ns];
if (symbols == null)
throw new Exception (ns + " does not exist");
symbols.BeginScope (catchScope);
}
internal void EndScope (string ns)
{
IdentificationTable symbols = (IdentificationTable) namespaces [ns];
if (symbols == null)
throw new Exception (ns + " does not exist");
symbols.EndScope ();
}
internal object [] CurrentLocals (string ns)
{
IdentificationTable symbols = (IdentificationTable) namespaces [ns];
if (symbols == null)
throw new Exception (ns + " does not exist");
return symbols.CurrentLocals;
}
internal int Depth (string ns)
{
IdentificationTable symbols = (IdentificationTable) namespaces [ns];
if (symbols == null)
throw new Exception (ns + " does not exist");
return symbols.depth;
}
internal bool InCurrentScope (string ns, Symbol id)
{
IdentificationTable symbols = (IdentificationTable) namespaces [ns];
if (symbols == null)
throw new Exception (ns + " does not exist");
return symbols.InCurrentScope (id);
}
internal bool CatchScope (string ns)
{
IdentificationTable symbols = (IdentificationTable) namespaces [ns];
if (symbols == null)
throw new Exception (ns + " does not exist");
return symbols.CatchScope;
}
internal void BuildGlobalEnv ()
{
//
// built in print function
//
if (SemanticAnalyser.print)
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("print"), new BuiltIn ("print", false, true));
/* value properties of the Global Object */
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("NaN"), new BuiltIn ("NaN", false, false));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("Infinity"), new BuiltIn ("Infinity", false, false));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("undefined"), new BuiltIn ("undefined", false, false));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("null"), new BuiltIn ("null", false, false));
/* function properties of the Global Object */
object [] custom_attrs;
Type global_object = typeof (GlobalObject);
MethodInfo [] methods = global_object.GetMethods (BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly);
foreach (MethodInfo mi in methods) {
custom_attrs = mi.GetCustomAttributes (typeof (JSFunctionAttribute), false);
foreach (JSFunctionAttribute attr in custom_attrs)
if (attr.IsBuiltIn)
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol (mi.Name), new BuiltIn (SemanticAnalyser.ImplementationName (attr.BuiltIn.ToString ()), false, true));
}
/* built in objects */
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("Object"), new BuiltIn ("Object", true, true));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("Function"), new BuiltIn ("Function", true, true));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("Array"), new BuiltIn ("Array", true, true));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("String"), new BuiltIn ("String", true, true));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("Boolean"), new BuiltIn ("Boolean", true, true));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("Number"), new BuiltIn ("Number", true, true));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("Math"), new BuiltIn ("Math", false, false));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("Date"), new BuiltIn ("Date", true, true));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("RegExp"), new BuiltIn ("RegExp", true, true));
/* built in Error objects */
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("Error"), new BuiltIn ("Error", true, true));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("EvalError"), new BuiltIn ("EvalError", true, true));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("RangeError"), new BuiltIn ("RangeError", true, true));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("ReferenceError"), new BuiltIn ("ReferenceError", true, true));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("SyntaxError"), new BuiltIn ("SyntaxError", true, true));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("TypeError"), new BuiltIn ("TypeError", true, true));
Enter (SemanticAnalyser.GlobalNamespace, Symbol.CreateSymbol ("URIError"), new BuiltIn ("URIError", true, true));
}
}
}

Просмотреть файл

@ -0,0 +1,69 @@
//
// Import.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
// Copyright (C) 2005 , Novell Inc (http://novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using Microsoft.JScript.Vsa;
using System.Reflection.Emit;
namespace Microsoft.JScript {
public class Import : AST {
string name;
internal Import (AST parent, string name, Location location)
: base (parent, location)
{
this.name = name;
}
public static void JScriptImport (string name, VsaEngine engine)
{
}
internal override bool Resolve (Environment env)
{
if (InFunction) {
string err = location.SourceName + "(" + location.LineNumber + ",0) : " +
"error JS1229: The import statement is not valid in this context";
throw new Exception (err);
}
return Namespace.IsNamespace (name);
}
internal override void Emit (EmitContext ec)
{
ILGenerator ig = ec.ig;
ig.Emit (OpCodes.Ldstr, name);
CodeGenerator.load_engine (false, ig);
ig.Emit (OpCodes.Call, GetType ().GetMethod ("JScriptImport"));
}
}
}

Просмотреть файл

@ -0,0 +1,66 @@
//
// In.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public sealed class In : BinaryOp {
internal In ()
: base (null, null, null, (JSToken) 0, null)
{
}
public static bool JScriptIn (object v1, object v2)
{
ScriptObject obj = v2 as ScriptObject;
if (obj == null)
return false;
string key = Convert.ToString (v1);
return LateBinding.HasObjectProperty (obj, key);
}
internal override bool Resolve (Environment env)
{
throw new NotImplementedException ();
}
internal override bool Resolve (Environment env, bool no_effect)
{
throw new NotImplementedException ();
}
internal override void Emit (EmitContext ec)
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,85 @@
//
// InstanceOf.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace Microsoft.JScript {
public sealed class Instanceof : BinaryOp {
internal Instanceof ()
: base (null, null, null, (JSToken) 0, null)
{
}
public static bool JScriptInstanceof (object v1, object v2)
{
if (v2 is ArrayConstructor)
return v1 is ArrayObject;
else if (v2 is BooleanConstructor)
return v1 is BooleanObject;
else if (v2 is DateConstructor)
return v1 is DateObject;
else if (v2 is EnumeratorConstructor)
return v1 is EnumeratorObject;
else if (v2 is ErrorConstructor)
return v1 is ErrorObject;
else if (v2 is FunctionConstructor)
return v1 is FunctionObject;
else if (v2 is NumberConstructor)
return v1 is NumberObject;
else if (v2 is ObjectConstructor)
return v1 is JSObject;
else if (v2 is RegExpConstructor)
return v1 is RegExpObject;
else if (v2 is StringConstructor)
return v1 is StringObject;
else if (v2 is ScriptFunction)
return false;
else
throw new JScriptException (JSError.TypeMismatch);
}
internal override bool Resolve (Environment env)
{
throw new NotImplementedException ();
}
internal override bool Resolve (Environment env, bool no_effect)
{
throw new NotImplementedException ();
}
internal override void Emit (EmitContext ec)
{
throw new NotImplementedException ();
}
}
}

Просмотреть файл

@ -0,0 +1,192 @@
//
// JSBuiltIn.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Microsoft.JScript {
public enum JSBuiltin {
Array_concat = 1,
Array_join,
Array_pop,
Array_push,
Array_reverse,
Array_shift,
Array_slice,
Array_sort,
Array_splice,
Array_toLocaleString,
Array_toString,
Array_unshift,
Boolean_toString,
Boolean_valueOf,
Date_getDate,
Date_getDay,
Date_getFullYear,
Date_getHours,
Date_getMilliseconds,
Date_getMinutes,
Date_getMonth,
Date_getSeconds,
Date_getTime,
Date_getTimezoneOffset,
Date_getUTCDate,
Date_getUTCDay,
Date_getUTCFullYear,
Date_getUTCHours,
Date_getUTCMilliseconds,
Date_getUTCMinutes,
Date_getUTCMonth,
Date_getUTCSeconds,
Date_getVarDate,
Date_getYear,
Date_parse,
Date_setDate,
Date_setFullYear,
Date_setHours,
Date_setMinutes,
Date_setMilliseconds,
Date_setMonth,
Date_setSeconds,
Date_setTime,
Date_setUTCDate,
Date_setUTCFullYear,
Date_setUTCHours,
Date_setUTCMinutes,
Date_setUTCMilliseconds,
Date_setUTCMonth,
Date_setUTCSeconds,
Date_setYear,
Date_toDateString,
Date_toGMTString,
Date_toLocaleDateString,
Date_toLocaleString,
Date_toLocaleTimeString,
Date_toString,
Date_toTimeString,
Date_toUTCString,
Date_UTC,
Date_valueOf,
Enumerator_atEnd,
Enumerator_item,
Enumerator_moveFirst,
Enumerator_moveNext,
Error_toString,
Function_apply,
Function_call,
Function_toString,
Global_CollectGarbage,
Global_decodeURI,
Global_decodeURIComponent,
Global_encodeURI,
Global_encodeURIComponent,
Global_escape,
Global_eval,
Global_GetObject,
Global_isNaN,
Global_isFinite,
Global_parseFloat,
Global_parseInt,
Global_ScriptEngine,
Global_ScriptEngineBuildVersion,
Global_ScriptEngineMajorVersion,
Global_ScriptEngineMinorVersion,
Global_unescape,
Math_abs,
Math_acos,
Math_asin,
Math_atan,
Math_atan2,
Math_ceil,
Math_cos,
Math_exp,
Math_floor,
Math_log,
Math_max,
Math_min,
Math_pow,
Math_random,
Math_round,
Math_sin,
Math_sqrt,
Math_tan,
Number_toExponential,
Number_toFixed,
Number_toLocaleString,
Number_toPrecision,
Number_toString,
Number_valueOf,
Object_hasOwnProperty,
Object_isPrototypeOf,
Object_propertyIsEnumerable,
Object_toLocaleString,
Object_toString,
Object_valueOf,
RegExp_compile,
RegExp_exec,
RegExp_test,
RegExp_toString,
String_anchor,
String_big,
String_blink,
String_bold,
String_charAt,
String_charCodeAt,
String_concat,
String_fixed,
String_fontcolor,
String_fontsize,
String_fromCharCode,
String_indexOf,
String_italics,
String_lastIndexOf,
String_link,
String_localeCompare,
String_match,
String_replace,
String_search,
String_slice,
String_small,
String_split,
String_strike,
String_sub,
String_substr,
String_substring,
String_sup,
String_toLocaleLowerCase,
String_toLocaleUpperCase,
String_toLowerCase,
String_toString,
String_toUpperCase,
String_valueOf,
VBArray_dimensions,
VBArray_getItem,
VBArray_lbound,
VBArray_toArray,
VBArray_ubound
}
}

Просмотреть файл

@ -0,0 +1,115 @@
//
// JSConstructor.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Diagnostics;
using System.Globalization;
namespace Microsoft.JScript {
public sealed class JSConstructor : ConstructorInfo
{
public override MethodAttributes Attributes {
get { throw new NotImplementedException (); }
}
public override string Name {
get { throw new NotImplementedException (); }
}
public override Type DeclaringType {
get { throw new NotImplementedException (); }
}
public override object [] GetCustomAttributes (Type t, bool inherit)
{
throw new NotImplementedException ();
}
public override object [] GetCustomAttributes (bool inherit)
{
throw new NotImplementedException ();
}
public override MethodImplAttributes GetMethodImplementationFlags ()
{
throw new NotImplementedException ();
}
public override ParameterInfo [] GetParameters ()
{
throw new NotImplementedException ();
}
[DebuggerStepThroughAttribute]
[DebuggerHiddenAttribute]
public override object Invoke (BindingFlags options, System.Reflection.Binder binder,
object [] parameters, CultureInfo culture)
{
throw new NotImplementedException ();
}
[DebuggerStepThroughAttribute]
[DebuggerHiddenAttribute]
public override object Invoke (object obj, BindingFlags options, System.Reflection.Binder binder,
object [] parameters, CultureInfo culture)
{
throw new NotImplementedException ();
}
public override bool IsDefined (Type type, bool inherit)
{
throw new NotImplementedException ();
}
public override MemberTypes MemberType {
get { throw new NotImplementedException (); }
}
public override RuntimeMethodHandle MethodHandle {
get { throw new NotImplementedException (); }
}
public override Type ReflectedType {
get { throw new NotImplementedException (); }
}
}
}

Просмотреть файл

@ -0,0 +1,277 @@
//
// JSError.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace Microsoft.JScript {
public enum JSError {
NoError,
InvalidCall,
OutOfMemory,
TypeMismatch,
OutOfStack,
InternalError,
FileNotFound,
NeedObject,
CantCreateObject,
OLENoPropOrMethod,
ActionNotSupported,
NotCollection,
SyntaxError,
NoColon,
NoSemicolon,
NoLeftParen,
NoRightParen,
NoRightBracket,
NoLeftCurly,
NoRightCurly,
NoIdentifier,
NoEqual,
IllegalChar,
UnterminatedString,
NoCommentEnd,
BadReturn,
BadBreak,
BadContinue,
BadHexDigit,
NoWhile,
BadLabel,
NoLabel,
DupDefault,
NoMemberIdentifier,
NoCcEnd,
CcOff,
NotConst,
NoAt,
NoCatch,
InvalidElse,
NoComma,
DupVisibility,
IllegalVisibility,
BadSwitch,
CcInvalidEnd,
CcInvalidElse,
CcInvalidElif,
ErrEOF,
IncompatibleVisibility,
ClassNotAllowed,
NeedCompileTimeConstant,
DuplicateName,
NeedType,
NotInsideClass,
InvalidPositionDirective,
MustBeEOL,
WrongDirective,
CannotNestPositionDirective,
CircularDefinition,
Deprecated,
IllegalUseOfThis,
NotAccessible,
CannotUseNameOfClass,
MustImplementMethod,
NeedInterface,
UnreachableCatch,
TypeCannotBeExtended,
UndeclaredVariable,
VariableLeftUninitialized,
KeywordUsedAsIdentifier,
NotAllowedInSuperConstructorCall,
NotMeantToBeCalledDirectly,
GetAndSetAreInconsistent,
InvalidCustomAttribute,
InvalidCustomAttributeArgument,
InvalidCustomAttributeClassOrCtor,
TooManyParameters,
AmbiguousBindingBecauseOfWith,
AmbiguousBindingBecauseOfEval,
NoSuchMember,
ItemNotAllowedOnExpandoClass,
MethodNotAllowedOnExpandoClass,
MethodClashOnExpandoSuperClass,
BaseClassIsExpandoAlready,
AbstractCannotBePrivate,
NotIndexable,
StaticMissingInStaticInit,
MissingConstructForAttributes,
OnlyClassesAllowed,
ExpandoClassShouldNotImpleEnumerable,
NonCLSCompliantMember,
NotDeletable,
PackageExpected,
UselessExpression,
HidesParentMember,
CannotChangeVisibility,
HidesAbstractInBase,
NewNotSpecifiedInMethodDeclaration,
MethodInBaseIsNotVirtual,
NoMethodInBaseToNew,
DifferentReturnTypeFromBase,
ClashWithProperty,
OverrideAndHideUsedTogether,
InvalidLanguageOption,
NoMethodInBaseToOverride,
NotValidForConstructor,
CannotReturnValueFromVoidFunction,
AmbiguousMatch,
AmbiguousConstructorCall,
SuperClassConstructorNotAccessible,
OctalLiteralsAreDeprecated,
VariableMightBeUnitialized,
NotOKToCallSuper,
IllegalUseOfSuper,
BadWayToLeaveFinally,
NoCommaOrTypeDefinitionError,
AbstractWithBody,
NoRightParenOrComma,
NoRightBracketOrComma,
ExpressionExpected,
UnexpectedSemicolon,
TooManyTokensSkipped,
BadVariableDeclaration,
BadFunctionDeclaration,
BadPropertyDeclaration,
DoesNotHaveAnAddress,
TooFewParameters,
UselessAssignment,
SuspectAssignment,
SuspectSemicolon,
ImpossibleConversion,
FinalPrecludesAbstract,
NeedInstance,
CannotBeAbstract,
InvalidBaseTypeForEnum,
CannotInstantiateAbstractClass,
ArrayMayBeCopied,
AbstractCannotBeStatic,
StaticIsAlreadyFinal,
StaticMethodsCannotOverride,
StaticMethodsCannotHide,
ExpandoPrecludesOverride,
IllegalParamArrayAttribute,
ExpandoPrecludesAbstract,
ShouldBeAbstract,
BadModifierInInterface,
VarIllegalInInterface,
InterfaceIllegalInInterface,
NoVarInEnum,
InvalidImport,
EnumNotAllowed,
InvalidCustomAttributeTarget,
PackageInWrongContext,
ConstructorMayNotHaveReturnType,
OnlyClassesAndPackagesAllowed,
InvalidDebugDirective,
CustomAttributeUsedMoreThanOnce,
NestedInstanceTypeCannotBeExtendedByStatic,
PropertyLevelAttributesMustBeOnGetter,
BadThrow,
ParamListNotLast,
NoSuchType,
BadOctalLiteral,
InstanceNotAccessibleFromStatic,
StaticRequiresTypeName,
NonStaticWithTypeName,
NoSuchStaticMember,
SuspectLoopCondition,
ExpectedAssembly,
AssemblyAttributesMustBeGlobal,
ExpandoPrecludesStatic,
DuplicateMethod,
NotAnExpandoFunction,
NotValidVersionString,
ExecutablesCannotBeLocalized,
StringConcatIsSlow,
CcInvalidInDebugger,
ExpandoMustBePublic,
DelegatesShouldNotBeExplicitlyConstructed,
ImplicitlyReferencedAssemblyNotFound,
PossibleBadConversion,
PossibleBadConversionFromString,
InvalidResource,
WrongUseOfAddressOf,
NonCLSCompliantType,
MemberTypeCLSCompliantMismatch,
TypeAssemblyCLSCompliantMismatch,
CantAssignThis,
NumberExpected,
FunctionExpected,
CannotAssignToFunctionResult,
StringExpected,
DateExpected,
ObjectExpected,
IllegalAssignment,
UndefinedIdentifier,
BooleanExpected,
VBArrayExpected,
EnumeratorExpected,
RegExpExpected,
RegExpSyntax,
UncaughtException,
InvalidPrototype,
URIEncodeError,
URIDecodeError,
FractionOutOfRange,
PrecisionOutOfRange,
ArrayLengthConstructIncorrect,
ArrayLengthAssignIncorrect,
NeedArrayObject,
NoConstructor,
IllegalEval,
NotYetImplemented,
MustProvideNameForNamedParameter,
DuplicateNamedParameter,
MissingNameParameter,
MoreNamedParametersThanArguments,
NonSupportedInDebugger,
AssignmentToReadOnly,
WriteOnlyProperty,
IncorrectNumberOfIndices,
RefParamsNonSupportedInDebugger,
CannotCallSecurityMethodLateBound,
CannotUseStaticSecurityAttribute,
FuncEvalAborted,
FuncEvalTimedout,
FuncEvalThreadSuspended,
FuncEvalThreadSleepWaitJoin,
FuncEvalBadThreadState,
FuncEvalBadThreadNotStarted,
NoFuncEvalAllowed,
FuncEvalBadLocation,
FuncEvalWebMethod,
StaticVarNotAvailable,
TypeObjectNotAvailable,
ExceptionFromHResult
}
}

Просмотреть файл

@ -0,0 +1,80 @@
//
// JSField.cs:
//
// Author: Cesar Octavio Lopez Nataren
//
// (C) 2003, Cesar Octavio Lopez Nataren, <cesar@ciencias.unam.mx>
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
namespace Microsoft.JScript {
public abstract class JSField : FieldInfo {
public override FieldAttributes Attributes {
get { throw new NotImplementedException (); }
}
public override Type DeclaringType {
get { throw new NotImplementedException (); }
}
public override RuntimeFieldHandle FieldHandle {
get { throw new NotImplementedException (); }
}
public override Type FieldType {
get { throw new NotImplementedException (); }
}
public override Object [] GetCustomAttributes (Type t, bool inherit)
{
throw new NotImplementedException ();
}
public override Object [] GetCustomAttributes (bool inherit)
{
throw new NotImplementedException ();
}
public override bool IsDefined (Type type, bool inherit)
{
throw new NotImplementedException ();
}
public override MemberTypes MemberType {
get { throw new NotImplementedException (); }
}
public override string Name {
get { throw new NotImplementedException (); }
}
public override Type ReflectedType {
get { throw new NotImplementedException (); }
}
}
}

Просмотреть файл

@ -0,0 +1,130 @@
//
// JSFieldInfo.cs:
//
// Author:
// Cesar Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) 2003, Cesar Lopez Nataren
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
using System.Globalization;
namespace Microsoft.JScript {
public sealed class JSFieldInfo : FieldInfo {
private FieldAttributes attr;
private string name;
private object value;
internal JSFieldInfo (string name)
{
this.name = name;
}
public override FieldAttributes Attributes {
get { return attr; }
}
public override Type DeclaringType {
get { throw new NotImplementedException (); }
}
public override RuntimeFieldHandle FieldHandle {
get { throw new NotImplementedException (); }
}
public override Type FieldType {
get { throw new NotImplementedException (); }
}
public override object [] GetCustomAttributes (Type t, bool inherit)
{
throw new NotImplementedException ();
}
public override object [] GetCustomAttributes (bool inherit)
{
throw new NotImplementedException ();
}
public override object GetValue (object obj)
{
string str_name = Convert.ToString (obj);
if (str_name == name)
return value;
else
throw new NotImplementedException ();
}
public override bool IsDefined (Type type, bool inherit)
{
throw new NotImplementedException ();
}
public override MemberTypes MemberType {
get { throw new NotImplementedException (); }
}
public override string Name {
get { return name; }
}
public override Type ReflectedType {
get { throw new NotImplementedException (); }
}
public new void SetValue (object obj, object value)
{
string str_name = Convert.ToString (obj);
if (str_name == name)
this.value = value;
else {
Console.WriteLine ("arg {0} != name {1}", str_name, name);
throw new NotImplementedException ();
}
}
public override void SetValue (object obj, object value, BindingFlags invokeAttr,
System.Reflection.Binder binder, CultureInfo culture)
{
SetValue (obj, value);
}
}
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше