summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLlewellyn Pritchard <xacc.ide@gmail.com>2024-02-24 00:52:27 +0000
committerGitHub <noreply@github.com>2024-02-24 00:52:27 +0000
commitfea3cf7ed0d0d737958f43c02b2f4d0f22e79bb8 (patch)
treebe75457c2fb2bc88eebb6759fb0c6f298a8b40f9
parentd95c5d7f6d752edd01923037f02afcba1062a2c5 (diff)
parentec1db770973f00c10a4120b22d2c924cedb2fc38 (diff)
Merge ec1db770973f00c10a4120b22d2c924cedb2fc38 into d95c5d7f6d752edd01923037f02afcba1062a2c51.0.348
-rw-r--r--IronScheme/IronScheme.Tests/OtherTests.cs9
-rw-r--r--IronScheme/IronScheme.Tests/TestRunner.cs10
-rw-r--r--IronScheme/Microsoft.Scripting/Ast/ArgumentKind.cs26
-rw-r--r--IronScheme/Microsoft.Scripting/Ast/AstWriter.cs993
-rw-r--r--IronScheme/Microsoft.Scripting/Ast/CodeBlock.cs236
-rw-r--r--IronScheme/Microsoft.Scripting/Ast/CodeBlockExpression.cs3
-rw-r--r--IronScheme/Microsoft.Scripting/Ast/Node.cs18
-rw-r--r--IronScheme/Microsoft.Scripting/Generation/CodeGen.cs245
-rw-r--r--IronScheme/Microsoft.Scripting/Generation/CompilerHelpers.cs250
-rw-r--r--IronScheme/Microsoft.Scripting/Generation/ConstantPool.cs18
-rw-r--r--IronScheme/Microsoft.Scripting/Generation/DefaultArgBuilder.cs25
-rw-r--r--IronScheme/Microsoft.Scripting/Generation/ModuleGlobalSlot.cs9
-rw-r--r--IronScheme/Microsoft.Scripting/Generation/ReturnFixer.cs56
-rw-r--r--IronScheme/Microsoft.Scripting/Generation/Slots/ArgSlot.cs5
-rw-r--r--IronScheme/Microsoft.Scripting/Generation/Snippets.cs16
-rw-r--r--IronScheme/Microsoft.Scripting/Generation/TypeGen.cs58
-rw-r--r--IronScheme/Microsoft.Scripting/LanguageContext.cs141
-rw-r--r--IronScheme/Microsoft.Scripting/MethodBinder.cs15
-rw-r--r--IronScheme/Microsoft.Scripting/MethodCandidate.cs6
-rw-r--r--IronScheme/Microsoft.Scripting/ModuleContext.cs10
-rw-r--r--IronScheme/Microsoft.Scripting/ModuleGlobalCache.cs15
-rw-r--r--IronScheme/Microsoft.Scripting/ModuleGlobalWrapper.cs17
-rw-r--r--IronScheme/Microsoft.Scripting/OptimizedModuleGenerator.cs11
-rw-r--r--IronScheme/Microsoft.Scripting/Script.cs104
-rw-r--r--appveyor.yml3
25 files changed, 24 insertions, 2275 deletions
diff --git a/IronScheme/IronScheme.Tests/OtherTests.cs b/IronScheme/IronScheme.Tests/OtherTests.cs
index 6f91ebd7..0317c13f 100644
--- a/IronScheme/IronScheme.Tests/OtherTests.cs
+++ b/IronScheme/IronScheme.Tests/OtherTests.cs
@@ -1,8 +1,5 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using NUnit.Framework;
-using System.Diagnostics;
namespace IronScheme.Tests
{
@@ -20,7 +17,13 @@ namespace IronScheme.Tests
public void MiniKanren()
{
var r = RunIronSchemeTestWithInput(@"(include ""lib/minikanren/mktests.scm"")");
+ if (!Quiet)
+ {
+ Console.WriteLine("Output: " + r.Output);
+ }
+
Assert.True(r.Output.Contains("Ignoring divergent test 10.62"));
+
AssertError(r);
}
}
diff --git a/IronScheme/IronScheme.Tests/TestRunner.cs b/IronScheme/IronScheme.Tests/TestRunner.cs
index c4dcc22c..b1bac4c1 100644
--- a/IronScheme/IronScheme.Tests/TestRunner.cs
+++ b/IronScheme/IronScheme.Tests/TestRunner.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.Diagnostics;
@@ -12,14 +11,19 @@ namespace IronScheme.Tests
{
protected TestRunner()
{
- Quiet = Environment.GetEnvironmentVariable("QUIET") != null;
+ Quiet = Environment.GetEnvironmentVariable("QUIET") == "1";
TestCore = Environment.GetEnvironmentVariable("TESTCORE") == "1";
}
public bool TestCore { get; private set; }
- protected static void AssertError(TestResult tr)
+ protected void AssertError(TestResult tr)
{
+ if (!Quiet)
+ {
+ Console.WriteLine("Error output: " + tr.Error);
+ }
+
Assert.IsEmpty(tr.Error);
}
diff --git a/IronScheme/Microsoft.Scripting/Ast/ArgumentKind.cs b/IronScheme/Microsoft.Scripting/Ast/ArgumentKind.cs
deleted file mode 100644
index 25c34d06..00000000
--- a/IronScheme/Microsoft.Scripting/Ast/ArgumentKind.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation.
- *
- * This source code is subject to terms and conditions of the Microsoft Public License. A
- * copy of the license can be found in the License.html file at the root of this distribution. If
- * you cannot locate the Microsoft Public License, please send an email to
- * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
- * by the terms of the Microsoft Public License.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-#if FULL
-namespace Microsoft.Scripting.Ast {
- public enum ArgumentKind {
- Simple,
- Named,
- List,
- Dictionary,
- Instance,
- Block
- };
-}
-#endif \ No newline at end of file
diff --git a/IronScheme/Microsoft.Scripting/Ast/AstWriter.cs b/IronScheme/Microsoft.Scripting/Ast/AstWriter.cs
deleted file mode 100644
index 57bf0ad0..00000000
--- a/IronScheme/Microsoft.Scripting/Ast/AstWriter.cs
+++ /dev/null
@@ -1,993 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation.
- *
- * This source code is subject to terms and conditions of the Microsoft Public License. A
- * copy of the license can be found in the License.html file at the root of this distribution. If
- * you cannot locate the Microsoft Public License, please send an email to
- * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
- * by the terms of the Microsoft Public License.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System;
-using System.Diagnostics;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-
-using Microsoft.Scripting;
-using Microsoft.Scripting.Actions;
-using Microsoft.Scripting.Ast;
-using Microsoft.Scripting.Generation;
-
-#if DEBUG
-namespace Microsoft.Scripting.Ast {
- class AstWriter {
- [Flags]
- private enum Flow {
- None,
- Space,
- NewLine,
-
- Break = 0x8000 // newline if column > MaxColumn
- };
-
- private struct Block {
- CodeBlock _block;
- int _id;
-
- public Block(CodeBlock block, int id) {
- _block = block;
- _id = id;
- }
-
- public CodeBlock CodeBlock {
- get { return _block; }
- }
- public int Id {
- get { return _id; }
- }
- }
-
- private struct Alignment {
- private readonly Statement _statement;
- private readonly int _depth;
-
- public Alignment(Statement statement, int depth) {
- _statement = statement;
- _depth = depth;
- }
-
- public Statement Statement {
- get { return _statement; }
- }
- public int Depth {
- get { return _depth; }
- }
- }
-
- private const int Tab = 4;
- private const int MaxColumn = 80;
-
- private TextWriter _out;
- private int _column;
-
- private Queue<Block> _blocks;
- private int _blockid;
- private Stack<Alignment> _stack = new Stack<Alignment>();
- private int _delta;
- private Flow _flow;
-
- private AstWriter() {
- }
-
- private int Base {
- get {
- return _stack.Count > 0 ? _stack.Peek().Depth : 0;
- }
- }
-
- private int Delta {
- get { return _delta; }
- }
-
- private int Depth {
- get { return Base + Delta; }
- }
-
- private void Indent() {
- _delta += Tab;
- }
- private void Dedent() {
- _delta -= Tab;
- }
-
- private void NewLine() {
- _flow = Flow.NewLine;
- }
-
-#if !SILVERLIGHT
- private static ConsoleColor GetAstColor() {
- if (Console.BackgroundColor == ConsoleColor.White) {
- return ConsoleColor.DarkCyan;
- } else {
- return ConsoleColor.Cyan;
- }
- }
-#endif
-
- /// <summary>
- /// Write out the given AST (only if ShowASTs or DumpASTs is enabled)
- /// </summary>
- public static void Dump(CodeBlock/*!*/ block, string descr) {
- Debug.Assert(block != null);
-
- if (descr == null) {
- descr = "unknown_ast";
- }
-
- if (ScriptDomainManager.Options.ShowASTs) {
-#if !SILVERLIGHT
- ConsoleColor color = Console.ForegroundColor;
- try {
- Console.ForegroundColor = GetAstColor();
-#endif
- Dump(block, descr, System.Console.Out);
-#if !SILVERLIGHT
- } finally {
- Console.ForegroundColor = color;
- }
-#endif
- } else if (ScriptDomainManager.Options.DumpASTs) {
- StreamWriter sw = new StreamWriter(GetFilePath(descr), descr == "unknown_ast");
- using (sw) {
- Dump(block, descr, sw);
- }
- }
- }
-
- /// <summary>
- /// Write out the given AST
- /// </summary>
- internal static void Dump(Node/*!*/ node, string/*!*/ descr, TextWriter/*!*/ writer) {
- Debug.Assert(node != null);
- Debug.Assert(descr != null);
- Debug.Assert(writer != null);
-
- AstWriter dv = new AstWriter();
- dv.DoDump(node, descr, writer);
- }
-
- private static string GetFilePath(string/*!*/ path) {
- Debug.Assert(path != null);
-
-#if !SILVERLIGHT // GetInvalidFileNameChars does not exist in CoreCLR
- char[] invalid = System.IO.Path.GetInvalidFileNameChars();
- foreach (char ch in invalid) {
- path = path.Replace(ch, '_');
- }
-#endif
- return path + ".ast";
- }
-
- private void DoDump(Node node, string name, TextWriter outFile) {
- _out = outFile;
-
- WriteLine("//");
- WriteLine("// AST {0}", name);
- WriteLine("//");
- WriteLine();
-
- WalkNode(node);
- Debug.Assert(_stack.Count == 0);
-
- //while (_blocks != null && _blocks.Count > 0) {
- // Block b = _blocks.Dequeue();
- // WriteLine();
- // WriteLine("//");
- // WriteLine("// CODE BLOCK: {0} ({1})", b.CodeBlock.Name, b.Id);
- // WriteLine("//");
- // WriteLine();
-
- // WalkNode(b.CodeBlock);
-
- // Debug.Assert(_stack.Count == 0);
- //}
-
- WriteLine();
- }
-
- private int Enqueue(CodeBlock block) {
- if (_blocks == null) {
- _blocks = new Queue<Block>();
- }
- _blocks.Enqueue(new Block(block, ++_blockid));
- return _blockid;
- }
-
- #region The printing code
-
- private void Out(string s) {
- Out(Flow.None, s, Flow.None);
- }
-
- private void Out(Flow before, string s) {
- Out(before, s, Flow.None);
- }
-
- private void Out(string s, Flow after) {
- Out(Flow.None, s, after);
- }
-
- private void Out(Flow before, string s, Flow after) {
- switch (GetFlow(before)) {
- case Flow.None:
- break;
- case Flow.Space:
- Write(" ");
- break;
- case Flow.NewLine:
- WriteLine();
- Write(new String(' ', Depth));
- break;
- }
- Write(s);
- _flow = after;
- }
-
- private void WriteLine() {
- _out.WriteLine();
- _column = 0;
- }
- private void WriteLine(string s) {
- _out.WriteLine(s);
- _column = 0;
- }
- private void WriteLine(string format, object arg0) {
- string s = String.Format(format, arg0);
- WriteLine(s);
- }
- private void WriteLine(string format, object arg0, object arg1) {
- string s = String.Format(format, arg0, arg1);
- WriteLine(s);
- }
- private void Write(string s) {
- _out.Write(s);
- _column += s.Length;
- }
-
- private Flow GetFlow(Flow flow) {
- Flow last;
-
- last = CheckBreak(_flow);
- flow = CheckBreak(flow);
-
- // Get the biggest flow that is requested None < Space < NewLine
- return (Flow)System.Math.Max((int)last, (int)flow);
- }
-
- private Flow CheckBreak(Flow flow) {
- if ((flow & Flow.Break) != 0) {
- if (_column > (MaxColumn + Depth)) {
- flow = Flow.NewLine;
- } else {
- flow &= ~Flow.Break;
- }
- }
- return flow;
- }
-
- #endregion
-
- #region The AST Output
-
- private void WalkNode(Node node) {
- if (node == null) {
- return;
- }
-
- switch (node.NodeType) {
- case AstNodeType.Add:
- case AstNodeType.AddChecked:
- case AstNodeType.And:
- case AstNodeType.AndAlso:
- case AstNodeType.Divide:
- case AstNodeType.Equal:
- case AstNodeType.ExclusiveOr:
- case AstNodeType.GreaterThan:
- case AstNodeType.GreaterThanOrEqual:
- case AstNodeType.LeftShift:
- case AstNodeType.LessThan:
- case AstNodeType.LessThanOrEqual:
- case AstNodeType.Modulo:
- case AstNodeType.Multiply:
- case AstNodeType.MultiplyChecked:
- case AstNodeType.NotEqual:
- case AstNodeType.Or:
- case AstNodeType.OrElse:
- case AstNodeType.RightShift:
- case AstNodeType.Subtract:
- case AstNodeType.SubtractChecked:
- Dump((BinaryExpression)node);
- break;
- case AstNodeType.Call:
- Dump((MethodCallExpression)node);
- break;
- case AstNodeType.Conditional:
- Dump((ConditionalExpression)node);
- break;
- case AstNodeType.Constant:
- Dump((ConstantExpression)node);
- break;
- case AstNodeType.Convert:
- case AstNodeType.Negate:
- case AstNodeType.Not:
- case AstNodeType.OnesComplement:
- Dump((UnaryExpression)node);
- break;
- case AstNodeType.New:
- Dump((NewExpression)node);
- break;
- case AstNodeType.TypeIs:
- Dump((TypeBinaryExpression)node);
- break;
-
- case AstNodeType.ArrayIndexAssignment:
- Dump((ArrayIndexAssignment)node);
- break;
- case AstNodeType.ArrayIndexExpression:
- Dump((ArrayIndexExpression)node);
- break;
- case AstNodeType.BlockStatement:
- Dump((BlockStatement)node);
- break;
- case AstNodeType.BoundAssignment:
- Dump((BoundAssignment)node);
- break;
- case AstNodeType.WriteStatement:
- Dump((WriteStatement)node);
- break;
- case AstNodeType.BoundExpression:
- Dump((BoundExpression)node);
- break;
- case AstNodeType.BreakStatement:
- Dump((BreakStatement)node);
- break;
- case AstNodeType.CodeBlock:
- Dump((CodeBlock)node);
- break;
- case AstNodeType.CodeBlockExpression:
- Dump((CodeBlockExpression)node);
- break;
- case AstNodeType.CodeContextExpression:
- Dump((CodeContextExpression)node);
- break;
- case AstNodeType.CommaExpression:
- Dump((CommaExpression)node);
- break;
- case AstNodeType.ContinueStatement:
- Dump((ContinueStatement)node);
- break;
- case AstNodeType.DebugStatement:
- Dump((DebugStatement)node);
- break;
- case AstNodeType.DeleteStatement:
- Dump((DeleteStatement)node);
- break;
- case AstNodeType.DeleteUnboundExpression:
- Dump((DeleteUnboundExpression)node);
- break;
- case AstNodeType.DoStatement:
- Dump((DoStatement)node);
- break;
- case AstNodeType.EmptyStatement:
- Dump((EmptyStatement)node);
- break;
- case AstNodeType.EnvironmentExpression:
- Dump((EnvironmentExpression)node);
- break;
- case AstNodeType.ExpressionStatement:
- Dump((ExpressionStatement)node);
- break;
- case AstNodeType.GeneratorCodeBlock:
- Dump((GeneratorCodeBlock)node);
- break;
- case AstNodeType.IfStatement:
- Dump((IfStatement)node);
- break;
- case AstNodeType.LabeledStatement:
- Dump((LabeledStatement)node);
- break;
- case AstNodeType.LoopStatement:
- Dump((LoopStatement)node);
- break;
- case AstNodeType.MemberAssignment:
- Dump((MemberAssignment)node);
- break;
- case AstNodeType.MemberExpression:
- Dump((MemberExpression)node);
- break;
- case AstNodeType.NewArrayExpression:
- Dump((NewArrayExpression)node);
- break;
- case AstNodeType.ParamsExpression:
- Dump((ParamsExpression)node);
- break;
- case AstNodeType.ParenthesizedExpression:
- Dump((ParenthesizedExpression)node);
- break;
- case AstNodeType.ReturnStatement:
- Dump((ReturnStatement)node);
- break;
- case AstNodeType.ScopeStatement:
- Dump((ScopeStatement)node);
- break;
- case AstNodeType.SwitchStatement:
- Dump((SwitchStatement)node);
- break;
- case AstNodeType.ThrowStatement:
- Dump((ThrowStatement)node);
- break;
- case AstNodeType.TryStatement:
- Dump((TryStatement)node);
- break;
- case AstNodeType.UnboundAssignment:
- Dump((UnboundAssignment)node);
- break;
- case AstNodeType.UnboundExpression:
- Dump((UnboundExpression)node);
- break;
- case AstNodeType.VoidExpression:
- Dump((VoidExpression)node);
- break;
- case AstNodeType.YieldStatement:
- Dump((YieldStatement)node);
- break;
-
- // These are handled within their respective statements
- case AstNodeType.CatchBlock:
- case AstNodeType.IfStatementTest:
- case AstNodeType.SwitchCase:
- default:
- throw new InvalidOperationException("Unexpected node type: " + node.NodeType.ToString());
- }
- }
-
-
-
- // ArrayIndexAssignment
- private void Dump(ArrayIndexAssignment node) {
- WalkNode(node.Array);
- Out("[");
- WalkNode(node.Index);
- Out("] = ");
- WalkNode(node.Value);
- }
-
- // ArrayIndexExpression
- private void Dump(ArrayIndexExpression node) {
- WalkNode(node.Array);
- Out("[");
- WalkNode(node.Index);
- Out("]");
- }
-
- // BinaryExpression
- private void Dump(BinaryExpression node) {
- WalkNode(node.Left);
- string op;
- switch (node.NodeType) {
- case AstNodeType.Equal: op = "=="; break;
- case AstNodeType.NotEqual: op = "!="; break;
- case AstNodeType.AndAlso: op = "&&"; break;
- case AstNodeType.OrElse: op = "||"; break;
- case AstNodeType.GreaterThan: op = ">"; break;
- case AstNodeType.LessThan: op = "<"; break;
- case AstNodeType.GreaterThanOrEqual: op = ">="; break;
- case AstNodeType.LessThanOrEqual: op = "<="; break;
- case AstNodeType.AddChecked:
- case AstNodeType.Add: op = "+"; break;
- case AstNodeType.SubtractChecked:
- case AstNodeType.Subtract: op = "-"; break;
- case AstNodeType.Divide: op = "/"; break;
- case AstNodeType.Modulo: op = "%"; break;
- case AstNodeType.MultiplyChecked:
- case AstNodeType.Multiply: op = "*"; break;
- case AstNodeType.LeftShift: op = "<<"; break;
- case AstNodeType.RightShift: op = ">>"; break;
- case AstNodeType.And: op = "&"; break;
- case AstNodeType.Or: op = "|"; break;
- case AstNodeType.ExclusiveOr: op = "^"; break;
- default:
- throw new InvalidOperationException();
- }
- Out(Flow.Space, op, Flow.Space | Flow.Break);
- WalkNode(node.Right);
- }
-
- // BoundAssignment
- private void Dump(BoundAssignment node) {
- Out("(.bound " + SymbolTable.IdToString(node.Variable.Name) + ") = ");
- WalkNode(node.Value);
- }
-
- // WriteStatement
- private void Dump(WriteStatement node)
- {
- Out("(.bound " + SymbolTable.IdToString(node.Variable.Name) + ") = ");
- WalkNode(node.Value);
- Out(";");
- }
-
- // BoundExpression
- private void Dump(BoundExpression node) {
- Out("(.bound ");
- Out(SymbolTable.IdToString(node.Name));
- Out(")");
- }
-
- // CodeBlockExpression
- private void Dump(CodeBlockExpression node) {
- int id = Enqueue(node.Block);
- Out(String.Format(".block ({0} #{1}", node.Block.Name, id));
- Indent();
- bool nl = false;
- if (node.ForceWrapperMethod) { nl = true; Out(Flow.NewLine, "ForceWrapper"); }
- if (node.IsStronglyTyped) { nl = true; Out(Flow.NewLine, "StronglyTyped"); }
- if (node.IsDeclarative) { nl = true; Out(Flow.NewLine, "Declarative"); }
- Dedent();
- Out(nl ? Flow.NewLine : Flow.None, ")");
- }
-
- // CodeContextExpression
- private void Dump(CodeContextExpression node) {
- Out(".context");
- }
-
- // CommaExpression
- private void Dump(CommaExpression node) {
- Out(String.Format(".comma ({0}) {{", node.ValueIndex), Flow.NewLine);
- Indent();
- for (int i = 0; i < node.Expressions.Count; i++) {
- WalkNode(node.Expressions[i]);
- Out(",", Flow.NewLine);
- }
- Dedent();
- Out("}", Flow.NewLine);
- }
-
- // ConditionalExpression
- private void Dump(ConditionalExpression node) {
- Out("(");
- WalkNode(node.Test);
- Out(" ? ");
- WalkNode(node.IfTrue);
- Out(" : ");
- WalkNode(node.IfFalse);
- Out(")");
- }
-
- private static string Constant(object value) {
- if (value == null) {
- return ".null";
- }
-
- CompilerConstant cc;
- if ((cc = value as CompilerConstant) != null) {
- value = cc.Create();
- }
-
- Type t;
- if ((t = value as Type) != null) {
- return "((Type)" + t.Name + ")";
- }
- string s;
- if ((s = value as string) != null) {
- return "\"" + s + "\"";
- }
- if (value is int || value is double) {
- return String.Format("{0:G}", value);
- }
- return "(" + value.GetType().Name + ")" + value.ToString();
- }
-
- // ConstantExpression
- private void Dump(ConstantExpression node) {
- Out(Constant(node.Value));
- }
-
- // DeleteUnboundExpression
- private void Dump(DeleteUnboundExpression node) {
- Out(String.Format(".delname({0})", SymbolTable.IdToString(node.Name)));
- }
-
- // EnvironmentExpression
- private void Dump(EnvironmentExpression node) {
- Out(".env");
- }
-
- // MemberAssignment
- private void Dump(MemberAssignment node) {
- WalkNode(node.Expression);
- Out(".");
- Out(node.Member.Name);
- Out(" = ");
- WalkNode(node.Value);
- }
-
- // MemberExpression
- private void Dump(MemberExpression node) {
- WalkNode(node.Expression);
- Out(".");
- Out(node.Member.Name);
- }
-
- // MethodCallExpression
- private void Dump(MethodCallExpression node) {
- if (node.Instance != null) {
- Out("(");
- WalkNode(node.Instance);
- Out(").");
- }
- Out("(" + (node.TailCall ? "*" : "") + node.Method.ReflectedType.Name + "." + node.Method.Name + ")(");
- if (node.Arguments != null && node.Arguments.Count > 0) {
- NewLine(); Indent();
- foreach (Expression e in node.Arguments) {
- WalkNode(e);
- Out(",", Flow.NewLine);
- }
- Dedent();
- }
- Out(")");
- }
-
- // NewArrayExpression
- private void Dump(NewArrayExpression node) {
- Out(".new " + node.Type.Name + " = {");
- if (node.Expressions != null && node.Expressions.Count > 0) {
- NewLine(); Indent();
- foreach (Expression e in node.Expressions) {
- WalkNode(e);
- Out(",", Flow.NewLine);
- }
- Dedent();
- }
- Out("}");
- }
-
- // NewExpression
- private void Dump(NewExpression node) {
- Out(".new " + node.Type.Name + "(");
- if (node.Arguments != null && node.Arguments.Count > 0) {
- NewLine(); Indent();
- foreach (Expression e in node.Arguments) {
- WalkNode(e);
- Out(",", Flow.NewLine);
- }
- Dedent();
- }
- Out(")");
- }
-
- // ParamsExpression
- private void Dump(ParamsExpression node) {
- Out(".params");
- }
-
- // ParenthesizedExpression
- private void Dump(ParenthesizedExpression node) {
- Out("(");
- WalkNode(node.Expression);
- Out(")");
- }
-
- // TypeBinaryExpression
- private void Dump(TypeBinaryExpression node) {
- WalkNode(node.Expression);
- Out(Flow.Space, ".is", Flow.Space);
- Out(node.TypeOperand.Name);
- }
-
- // UnaryExpression
- private void Dump(UnaryExpression node) {
- switch (node.NodeType) {
- case AstNodeType.Convert:
- Out("(" + node.Type.Name + ")");
- break;
- case AstNodeType.Not:
- Out(node.Type == typeof(bool) ? "!" : "~");
- break;
- case AstNodeType.Negate:
- Out("-");
- break;
- case AstNodeType.OnesComplement:
- Out("~");
- break;
- }
-
- WalkNode(node.Operand);
- }
-
- // UnboundAssignment
- private void Dump(UnboundAssignment node) {
- Out(SymbolTable.IdToString(node.Name));
- Out(" := ");
- WalkNode(node.Value);
- }
-
- // UnboundExpression
- private void Dump(UnboundExpression node) {
- Out(".unbound " + SymbolTable.IdToString(node.Name));
- }
-
- // VoidExpression
- private void Dump(VoidExpression node) {
- Out(".void {");
- Indent();
- WalkNode(node.Statement);
- Dedent();
- Out("}");
- }
-
- // BlockStatement
- private void Dump(BlockStatement node) {
- Out("{");
- NewLine(); Indent();
- foreach (Statement s in node.Statements) {
- WalkNode(s);
- NewLine();
- }
- Dedent();
- Out("}", Flow.NewLine);
- }
-
- // BreakStatement
- private void Dump(BreakStatement node) {
- Out(".break;", Flow.NewLine);
- }
-
- // ContinueStatement
- private void Dump(ContinueStatement node) {
- Out(".continue;", Flow.NewLine);
- }
-
- // DebugStatement
- private void Dump(DebugStatement node) {
- Out(".debug(" + node.Marker + ");", Flow.NewLine);
- }
-
- // DeleteStatement
- private void Dump(DeleteStatement node) {
- Out(".del");
- if (node.Variable != null) {
- Out(Flow.Space, SymbolTable.IdToString(node.Variable.Name));
- }
- NewLine();
- }
-
- // DoStatement
- private void Dump(DoStatement node) {
- Out(".do {", Flow.NewLine);
- Indent();
- WalkNode(node.Body);
- Dedent();
- Out(Flow.NewLine, "} .while (");
- WalkNode(node.Test);
- Out(");");
- }
-
- // EmptyStatement
- private void Dump(EmptyStatement node) {
- Out(";", Flow.NewLine);
- }
-
- // ExpressionStatement
- private void Dump(ExpressionStatement node) {
- WalkNode(node.Expression);
- Out(";", Flow.NewLine);
- }
-
- // IfStatement
- private void Dump(IfStatement node) {
- for (int i = 0; i < node.Tests.Count; i++) {
- IfStatementTest test = node.Tests[i];
- Out(i == 0 ? ".if (" : "} .elif (");
- WalkNode(test.Test);
- Out(") {", Flow.NewLine);
- Indent();
- WalkNode(test.Body);
- Dedent();
- }
-
- if (node.ElseStatement != null) {
- Out("} .else {", Flow.NewLine);
- Indent();
- WalkNode(node.ElseStatement);
- Dedent();
- }
- Out("}", Flow.NewLine);
- }
-
- // LabeledStatement
- private void Dump(LabeledStatement node) {
- Out(".labeled {", Flow.NewLine);
- Indent();
- WalkNode(node.Statement);
- Dedent();
- Out(Flow.NewLine, "}");
- }
-
- // LoopStatement
- private void Dump(LoopStatement node) {
- Out(".for (; ");
- WalkNode(node.Test);
- Out("; ");
- WalkNode(node.Increment);
- Out(") {", Flow.NewLine);
- Indent();
- WalkNode(node.Body);
- Dedent();
- Out(Flow.NewLine, "}");
- }
-
- // ReturnStatement
- private void Dump(ReturnStatement node) {
- Out(".return", Flow.Space);
- WalkNode(node.Expression);
- Out(";", Flow.NewLine);
- }
-
- // ScopeStatement
- private void Dump(ScopeStatement node) {
- Out(".scope (");
- WalkNode(node.Scope);
- Out(") {", Flow.NewLine);
- Indent();
- WalkNode(node.Body);
- Dedent();
- Out("}", Flow.NewLine);
- }
-
- // SwitchStatement
- private void Dump(SwitchStatement node) {
- Out(".switch (");
- WalkNode(node.TestValue);
- Out(") {", Flow.NewLine);
- foreach (SwitchCase sc in node.Cases) {
- if (sc.IsDefault) {
- Out(".default");
- } else {
- Out(".case " + sc.Value);
- }
- Out(":", Flow.NewLine);
- Indent(); Indent();
- WalkNode(sc.Body);
- Dedent(); Dedent();
- NewLine();
- }
- Out("}", Flow.NewLine);
- }
-
- // ThrowStatement
- private void Dump(ThrowStatement node) {
- Out(Flow.NewLine, ".throw (");
- WalkNode(node.Exception);
- Out(")", Flow.NewLine);
- }
-
- // TryStatement
- private void Dump(TryStatement node) {
- Out(".try {", Flow.NewLine);
- Indent();
- WalkNode(node.Body);
- Dedent();
- if (node.Handlers != null && node.Handlers.Count > 0) {
- foreach (CatchBlock cb in node.Handlers) {
- Out("} .catch ( " + cb.Test.Name);
- if (cb.Variable != null) {
- Out(Flow.Space, SymbolTable.IdToString(cb.Variable.Name));
- }
- Out(") {", Flow.NewLine);
- Indent();
- WalkNode(cb.Body);
- Dedent();
- }
- }
- if (node.FinallyStatement != null) {
- Out("} .finally {", Flow.NewLine);
- Indent();
- WalkNode(node.FinallyStatement);
- Dedent();
- }
- Out("}", Flow.NewLine);
- }
-
- // YieldStatement
- private void Dump(YieldStatement node) {
- Out(".yield ");
- WalkNode(node.Expression);
- Out(";", Flow.NewLine);
- }
-
- private static string GetCodeBlockInfo(CodeBlock block) {
- string info = String.Format("{0} {1} (", block.ReturnType.Name, block.Name);
- if (block.IsGlobal) {
- info += " global,";
- }
- if (!block.IsVisible) {
- info += " hidden,";
- }
- if (block.IsClosure) {
- info += " closure,";
- }
- if (block.ParameterArray) {
- info += " param array,";
- }
- if (block.HasEnvironment) {
- info += " environment,";
- }
- if (block.EmitLocalDictionary) {
- info += " local dict";
- }
- info += ")";
- return info;
- }
-
- private void DumpVariable(Variable v) {
- string descr = String.Format("{2} {0} ({1}", SymbolTable.IdToString(v.Name), v.Kind.ToString(), v.Type.Name);
- if (v.Lift) {
- descr += ",Lift";
- }
- if (v.InParameterArray) {
- descr += ",InParameterArray";
- }
- descr += ")";
- Out(descr);
- if (v.DefaultValue != null) {
- Out(" = ");
- WalkNode(v.DefaultValue);
- }
- NewLine();
- }
-
- private void DumpBlock(CodeBlock node) {
- Out(GetCodeBlockInfo(node));
- Out("(");
- Indent();
- foreach (Variable v in node.Parameters) {
- Out(Flow.NewLine, ".arg", Flow.Space);
- DumpVariable(v);
- }
- Dedent();
- Out(") {");
- Indent();
- foreach (Variable v in node.Variables) {
- Out(Flow.NewLine, ".var", Flow.Space);
- DumpVariable(v);
- }
- Out(Flow.NewLine, "", Flow.NewLine);
- WalkNode(node.Body);
- Dedent();
- Out("}");
- }
-
- // CodeBlock
- private void Dump(CodeBlock node) {
- Out(".codeblock", Flow.Space);
- DumpBlock(node);
- }
-
- // GeneratorCodeBlock
- private void Dump(GeneratorCodeBlock node) {
- Out(".generator", Flow.Space);
- DumpBlock(node);
- }
-
- #endregion
- }
-}
-#endif
diff --git a/IronScheme/Microsoft.Scripting/Ast/CodeBlock.cs b/IronScheme/Microsoft.Scripting/Ast/CodeBlock.cs
index 8b956248..73016dc3 100644
--- a/IronScheme/Microsoft.Scripting/Ast/CodeBlock.cs
+++ b/IronScheme/Microsoft.Scripting/Ast/CodeBlock.cs
@@ -14,22 +14,17 @@
* ***************************************************************************/
using System;
-
-using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using System.Diagnostics;
-using System.Text;
using System.Threading;
-using System.IO;
using Microsoft.Scripting.Generation;
-using Microsoft.Scripting.Hosting;
-using Microsoft.Scripting.Actions;
using Microsoft.Scripting.Utils;
-namespace Microsoft.Scripting.Ast {
+namespace Microsoft.Scripting.Ast
+{
/// <summary>
/// This captures a block of code that should correspond to a .NET method body. It takes
@@ -69,7 +64,6 @@ namespace Microsoft.Scripting.Ast {
private bool _hasEnvironment;
private bool _emitLocalDictionary;
private bool _isGlobal;
- private bool _visibleScope = true;
private bool _parameterArray;
internal bool Checked = false;
bool inlined = false;
@@ -82,10 +76,6 @@ namespace Microsoft.Scripting.Ast {
public object Source { get; set; }
public bool IsRest { get; set; }
-
- // Profile-driven compilation support
- private int _callCount = 0;
- private const int _maxInterpretedCalls = 2;
/// <summary>
/// True, if the block is referenced by a declarative reference (CodeBlockExpression).
@@ -115,10 +105,6 @@ namespace Microsoft.Scripting.Ast {
get { return _start; }
}
- public SourceLocation End {
- get { return _end; }
- }
-
public SourceSpan Span {
get {
return new SourceSpan(_start, _end);
@@ -210,10 +196,6 @@ namespace Microsoft.Scripting.Ast {
set { _parent = value; }
}
- public bool IsVisible {
- get { return _visibleScope; }
- set { _visibleScope = value; }
- }
public Statement Body {
get { return _body; }
set { _body = value; }
@@ -257,7 +239,6 @@ namespace Microsoft.Scripting.Ast {
return v;
}
-
public Type EnvironmentType {
get {
Debug.Assert(_environmentFactory != null);
@@ -285,13 +266,6 @@ namespace Microsoft.Scripting.Ast {
return variable;
}
- public Variable CreateParameter(SymbolId name, Type type, bool inParameterArray) {
- Variable variable = Variable.Parameter(this, name, type, inParameterArray);
- _parameters.Add(variable);
- _parametersmap.Add(variable.Name, variable);
- return variable;
- }
-
public Variable CreateVariable(SymbolId name, Variable.VariableKind kind, Type type) {
return CreateVariable(name, kind, type, null);
}
@@ -322,68 +296,6 @@ namespace Microsoft.Scripting.Ast {
return variable;
}
- public Variable CreateGeneratorTempVariable(SymbolId name, Type type) {
- Variable variable = Variable.GeneratorTemp(name, this, type);
- _variables.Add(variable);
- Debug.Assert(!_variablesmap.ContainsKey(name));
- _variablesmap.Add(variable.Name, variable);
- return variable;
- }
-
- private void EmitEnvironmentIDs(CodeGen cg) {
- int size = 0;
- foreach (Variable prm in _parameters) {
- if (prm.Lift) size++;
- }
- foreach (Variable var in _variables) {
- if (var.Lift) size++;
- }
-
- if (!cg.IsDynamicMethod) {
- Debug.Assert(cg.TypeGen != null);
-
- CodeGen cctor = cg.TypeGen.TypeInitializer;
-
- EmitEnvironmentIdArray(cctor, size);
- Slot fields = cg.TypeGen.AddStaticField(typeof(SymbolId[]), "__symbolIds$" + _name + "$" + Interlocked.Increment(ref _Counter));
- fields.EmitSet(cctor);
- fields.EmitGet(cg);
-
- } else {
- EmitEnvironmentIdArray(cg, size);
- }
- }
-
-
- private void EmitEnvironmentIdArray(CodeGen cg, int size) {
- // Create the array for the names
- cg.EmitInt(size);
- cg.Emit(OpCodes.Newarr, typeof(SymbolId));
-
- int index = 0;
-
- foreach (Variable prm in _parameters) {
- if (prm.Lift) {
- EmitSetVariableName(cg, index++, prm.Name);
- }
- }
-
- foreach (Variable var in _variables) {
- if (var.Lift) {
- EmitSetVariableName(cg, index++, var.Name);
- }
- }
- }
-
- private static void EmitSetVariableName(CodeGen cg, int index, SymbolId name) {
- cg.Emit(OpCodes.Dup);
- cg.EmitInt(index);
- cg.Emit(OpCodes.Ldelema, typeof(SymbolId));
- cg.EmitSymbolId(name);
- cg.EmitUnbox(typeof(SymbolId));
- cg.Emit(OpCodes.Call, typeof(SymbolId).GetConstructor(new Type[] { typeof(SymbolId) }));
- }
-
internal void CreateEnvironmentFactory(bool generator, CodeGen cg) {
if (HasEnvironment) {
// Get the environment size
@@ -524,7 +436,6 @@ namespace Microsoft.Scripting.Ast {
CreateScopeAccessSlots(cg);
}
-
int depth = -1;
int GetDepth()
@@ -686,52 +597,6 @@ namespace Microsoft.Scripting.Ast {
else return null;
}
- private bool ShouldCompile() {
- return _callCount++ > _maxInterpretedCalls;
- }
-
- public void Update()
- {
- FlowChecker.Check(this);
- }
-
- protected Delegate GetCompiledDelegate(CompilerContext context, Type delegateType, bool forceWrapperMethod) {
-
- if (_compiled != null)
- {
- return _compiled;
- }
- bool createWrapperMethod = !_parameterArray && (forceWrapperMethod || NeedsWrapperMethod(false));
- bool hasThis = HasThis();
-
- CodeGen cg = CreateInterprettedMethod(context, delegateType, hasThis);
- EmitFunctionImplementation(cg);
-
- cg.Finish();
-
- if (delegateType == null) {
- if (createWrapperMethod) {
- CodeGen wrapper = MakeWrapperMethodN(null, cg, hasThis);
- wrapper.Finish();
- delegateType =
- typeof(CallTargetWithContextN);
- return wrapper.CreateDelegate(delegateType);
- //throw new NotImplementedException("Wrapper methods not implemented for code blocks in FastEval mode");
- } else if (_parameterArray) {
- delegateType =
- typeof(CallTargetWithContextN);
- return cg.CreateDelegate(delegateType);
- //throw new NotImplementedException("Parameter arrays not implemented for code blocks in FastEval mode");
- } else {
- delegateType = CallTargets.GetTargetType(true, _parameters.Count - (HasThis() ? 1 : 0), HasThis());
- return _compiled = cg.CreateDelegate(delegateType);
- }
- } else {
- return _compiled = cg.CreateDelegate(delegateType);
- }
- }
-
- Delegate _compiled;
MethodInfo _impl;
internal void EmitDirectCall(CodeGen cg, bool forceWrapperMethod, bool stronglyTyped, Type delegateType, bool tailcall)
@@ -837,19 +702,6 @@ namespace Microsoft.Scripting.Ast {
}
}
- private Type[] GetParameterTypes(bool hasContextParameter) {
- Type[] result = new Type[_parameters.Count + (hasContextParameter ? 1 : 0)];
- int j = 0;
- if (hasContextParameter) {
- result[j++] = typeof(CodeContext);
- }
-
- for (int i = 0; i < _parameters.Count; i++) {
- result[j++] = _parameters[i].Type;
- }
- return result;
- }
-
int ComputeSignature(bool hasContextParameter, bool hasThis, out List<Type> paramTypes, out List<SymbolId> paramNames, out string implName) {
paramTypes = new List<Type>();
@@ -891,19 +743,6 @@ namespace Microsoft.Scripting.Ast {
return parameterIndex;
}
- private int ComputeDelegateSignature(Type delegateType, out List<Type> paramTypes, out List<SymbolId> paramNames, out string implName) {
- implName = GetGeneratedName();
- MethodInfo invoke = delegateType.GetMethod("Invoke");
- ParameterInfo[] pis = invoke.GetParameters();
- paramNames = new List<SymbolId>();
- paramTypes = new List<Type>();
- foreach (ParameterInfo pi in pis) {
- paramTypes.Add(pi.ParameterType);
- paramNames.Add(SymbolTable.StringToId(pi.Name));
- }
- return -1;
- }
-
private string GetGeneratedName() {
if (_name == "anon" || string.IsNullOrEmpty(_name) || _name.Contains("#") || _name.EndsWith("dummy"))
{
@@ -1004,44 +843,6 @@ namespace Microsoft.Scripting.Ast {
return impl;
}
- private CodeGen CreateInterprettedMethod(CompilerContext context, Type delegateType, bool hasThis) {
- List<Type> paramTypes;
- List<SymbolId> paramNames;
- CodeGen impl;
- string implName;
-
- int lastParamIndex;
-
- if (delegateType == null) {
- lastParamIndex = ComputeSignature(true, hasThis, out paramTypes, out paramNames, out implName);
- } else {
- Debug.Assert(!_parameterArray);
- lastParamIndex = ComputeDelegateSignature(delegateType, out paramTypes, out paramNames, out implName);
- }
-
- impl = CompilerHelpers.CreateDynamicCodeGenerator(
- implName,
- typeof(object),
- paramTypes.ToArray(),
- new ConstantPool());
- impl.InterpretedMode = true;
- impl.ContextSlot = impl.ArgumentSlots[0];
- impl.Context = context;
- impl.EnvironmentSlot = new EnvironmentSlot(
- new PropertySlot(
- new PropertySlot(impl.ContextSlot,
- typeof(CodeContext).GetProperty("Scope")),
- typeof(Scope).GetProperty("Dict"))
- );
- if (_parameterArray) {
- impl.ParamsSlot = impl.GetArgumentSlot(lastParamIndex);
- }
-
- impl.Allocator = CompilerHelpers.CreateLocalStorageAllocator(null, impl);
-
- return impl;
- }
-
private CodeGen CreateWrapperCodeGen(CodeGen outer, string implName, List<Type> paramTypes, ConstantPool staticData) {
if (outer == null) {
return CompilerHelpers.CreateDynamicCodeGenerator(implName, typeof(object), paramTypes, staticData);
@@ -1223,7 +1024,6 @@ namespace Microsoft.Scripting.Ast {
}
}
-
// This is used for compiling the toplevel CodeBlock object.
internal T CreateDelegate<T>(CompilerContext context)
where T : class {
@@ -1262,7 +1062,6 @@ namespace Microsoft.Scripting.Ast {
return new ClassEnvironmentFactory(storageType, envType);
}
-
static int closure_counter = 0;
static Type GenerateStorageType(List<Variable> vars, CodeGen cg, Type parentType)
@@ -1302,7 +1101,6 @@ namespace Microsoft.Scripting.Ast {
get { return _parameters.Count; }
}
-
public void RemoveVariables(List<Variable> toremove)
{
foreach (var v in toremove)
@@ -1312,7 +1110,6 @@ namespace Microsoft.Scripting.Ast {
}
}
-
internal void ResetBindings()
{
foreach (var v in Parameters)
@@ -1348,39 +1145,10 @@ namespace Microsoft.Scripting.Ast {
return CodeBlock(span, name, typeof(object));
}
- public static CodeBlock CodeBlock(SymbolId name) {
- return CodeBlock(SourceSpan.None, SymbolTable.IdToString(name), typeof(object));
- }
-
- public static CodeBlock CodeBlock(SymbolId name, Type returnType) {
- return CodeBlock(SourceSpan.None, SymbolTable.IdToString(name), returnType);
- }
-
- public static CodeBlock CodeBlock(SourceSpan span, SymbolId name) {
- return CodeBlock(span, SymbolTable.IdToString(name), typeof(object));
- }
-
public static CodeBlock CodeBlock(SourceSpan span, string name, Type returnType) {
Contract.RequiresNotNull(name, "name");
Contract.RequiresNotNull(returnType, "returnType");
return new CodeBlock(AstNodeType.CodeBlock, span, name, returnType);
}
-
- public static CodeBlock EventHandlerBlock(string name, EventInfo eventInfo) {
- Contract.RequiresNotNull(name, "name");
- Contract.RequiresNotNull(eventInfo, "eventInfo");
-
- ParameterInfo returnInfo;
- ParameterInfo[] parameterInfos;
-
- ReflectionUtils.GetDelegateSignature(eventInfo.EventHandlerType, out parameterInfos, out returnInfo);
-
- CodeBlock result = Ast.CodeBlock(name, returnInfo.ParameterType);
- for (int i = 0; i < parameterInfos.Length; i++) {
- result.AddParameter(Variable.Parameter(result, SymbolTable.StringToId("$" + i), parameterInfos[i].ParameterType));
- }
-
- return result;
- }
}
}
diff --git a/IronScheme/Microsoft.Scripting/Ast/CodeBlockExpression.cs b/IronScheme/Microsoft.Scripting/Ast/CodeBlockExpression.cs
index 9898d853..34f8851c 100644
--- a/IronScheme/Microsoft.Scripting/Ast/CodeBlockExpression.cs
+++ b/IronScheme/Microsoft.Scripting/Ast/CodeBlockExpression.cs
@@ -51,9 +51,6 @@ namespace Microsoft.Scripting.Ast {
}
#endif
- internal Type DelegateType {
- get { return _delegateType; }
- }
/// <summary>
/// Whether this expression declares the block. If so, the declaring code's variable are accessible from within the block (a closure is created).
diff --git a/IronScheme/Microsoft.Scripting/Ast/Node.cs b/IronScheme/Microsoft.Scripting/Ast/Node.cs
index a9d6899a..ce2155e9 100644
--- a/IronScheme/Microsoft.Scripting/Ast/Node.cs
+++ b/IronScheme/Microsoft.Scripting/Ast/Node.cs
@@ -13,11 +13,8 @@
*
* ***************************************************************************/
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Generation;
-
-namespace Microsoft.Scripting.Ast {
+namespace Microsoft.Scripting.Ast
+{
public abstract class Node {
private readonly AstNodeType _nodeType;
@@ -42,17 +39,6 @@ namespace Microsoft.Scripting.Ast {
var en = (uint)((end.Line << 10) | (end.Column));
return (long) (((ulong)en) << 32 | st);
}
-
-#if DEBUG
- public string Dump {
- get {
- using (System.IO.StringWriter writer = new System.IO.StringWriter()) {
- AstWriter.Dump(this, GetType().Name, writer);
- return writer.ToString();
- }
- }
- }
-#endif
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")]
diff --git a/IronScheme/Microsoft.Scripting/Generation/CodeGen.cs b/IronScheme/Microsoft.Scripting/Generation/CodeGen.cs
index 33d6b300..85821126 100644
--- a/IronScheme/Microsoft.Scripting/Generation/CodeGen.cs
+++ b/IronScheme/Microsoft.Scripting/Generation/CodeGen.cs
@@ -80,10 +80,6 @@ namespace Microsoft.Scripting.Generation {
private Slot _contextSlot; // code context
private Slot _paramsSlot; // slot for the parameter array, if any
- // Runtime line # tracking
- private Slot _currentLineSlot; // used to track the current line # at runtime
- private int _currentLine; // last line number emitted to avoid dupes
-
private Slot[] _argumentSlots;
private CompilerContext _context;
private ActionBinder _binder;
@@ -143,22 +139,7 @@ namespace Microsoft.Scripting.Generation {
ILDebug = assemblyGen.ILDebug;
// this is a bit more tricky than i would think :|
//CacheConstants = true;
-
-#if !DEBUG
- }
-#else
-
- }
-
- private string GetPerfTrackName(MethodBase mi) {
- for (int i = 0; i < mi.Name.Length; i++) {
- if (!Char.IsLetter(mi.Name[i]) && mi.Name[i] != '.') {
- return mi.Name.Substring(0, i);
- }
- }
- return mi.Name;
}
-#endif
public override string ToString() {
return _methodInfo.ToString();
@@ -198,10 +179,6 @@ namespace Microsoft.Scripting.Generation {
}
}
- public bool HasContext {
- get { return _context != null; }
- }
-
public ActionBinder Binder {
get {
if (_binder == null) {
@@ -256,10 +233,6 @@ namespace Microsoft.Scripting.Generation {
}
}
- public void PushTryBlock() {
- PushExceptionBlock(TargetBlockType.Try, null);
- }
-
public void PushTargets(Nullable<Label> breakTarget, Nullable<Label> continueTarget, Statement statement) {
if (_targets.Count == 0) {
_targets.Push(new Targets(breakTarget, continueTarget, BlockType, null, statement));
@@ -825,14 +798,6 @@ namespace Microsoft.Scripting.Generation {
}
}
- internal Slot DupAndStoreInTemp(Type type) {
- Debug.Assert(type != typeof(void));
- this.Emit(OpCodes.Dup);
- Slot ret = GetLocalTmp(type);
- ret.EmitSet(this);
- return ret;
- }
-
internal ScopeAllocator Allocator {
get {
Debug.Assert(_allocator != null);
@@ -884,37 +849,6 @@ namespace Microsoft.Scripting.Generation {
EmitCall(typeof(Debug), "WriteLine", new Type[] { typeof(string) });
}
- [Conditional("DEBUG")]
- public void EmitAssertNotNull() {
- EmitAssertNotNull("Accessing null reference.");
- }
-
- /// <summary>
- /// asserts the value at the top of the stack is not null
- /// </summary>
- [Conditional("DEBUG")]
- public void EmitAssertNotNull(string message) {
- Emit(OpCodes.Dup);
- Emit(OpCodes.Ldnull);
- Emit(OpCodes.Ceq);
- Emit(OpCodes.Ldc_I4_0);
- Emit(OpCodes.Ceq);
-
- if (message == null) {
- EmitCall(typeof(Debug), "Assert", new Type[] { typeof(bool) });
- } else {
- EmitString(message);
- EmitCall(typeof(Debug), "Assert", new Type[] { typeof(bool), typeof(string) });
- }
- }
-
- public void SetCustomAttribute(CustomAttributeBuilder cab) {
- MethodBuilder builder = _methodInfo as MethodBuilder;
- if (builder != null) {
- builder.SetCustomAttribute(cab);
- }
- }
-
public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, string strParamName) {
MethodBuilder builder = _methodInfo as MethodBuilder;
if (builder != null) {
@@ -943,28 +877,6 @@ namespace Microsoft.Scripting.Generation {
}
}
- public virtual void EmitGetCurrentLine() {
- if (_currentLineSlot != null) {
- _currentLineSlot.EmitGet(this);
- } else {
- EmitInt(0);
- }
- }
-
- public virtual void EmitCurrentLine(int line) {
- if (!EmitLineInfo || !HasContext) return;
-
- line = _context.SourceUnit.MapLine(line);
- if (line != _currentLine && line != SourceLocation.None.Line) {
- if (_currentLineSlot == null) {
- _currentLineSlot = GetNamedLocal(typeof(int), "$line");
- }
-
- EmitInt(_currentLine = line);
- _currentLineSlot.EmitSet(this);
- }
- }
-
private void EnsureReturnBlock() {
if (!_returnBlock.HasValue) {
ReturnBlock val = new ReturnBlock();
@@ -1004,11 +916,6 @@ namespace Microsoft.Scripting.Generation {
ContextSlot.EmitGet(this);
}
- public void EmitLanguageContext() {
- EmitCodeContext();
- EmitPropertyGet(typeof(CodeContext), "LanguageContext");
- }
-
public void EmitEnvironmentOrNull() {
if (_environmentSlot != null) {
_environmentSlot.EmitGet(this);
@@ -1048,10 +955,6 @@ namespace Microsoft.Scripting.Generation {
}
}
- public void EmitTuple(Type tupleType, int count, EmitArrayHelper emit) {
- EmitTuple(tupleType, 0, count, emit);
- }
-
private void EmitTuple(Type tupleType, int start, int end, EmitArrayHelper emit) {
int size = end - start;
@@ -1094,7 +997,6 @@ namespace Microsoft.Scripting.Generation {
}
}
-
/// <summary>
/// Emits an array of values of count size. The items are emitted via the callback
/// which is provided with the current item index to emit.
@@ -1173,19 +1075,6 @@ namespace Microsoft.Scripting.Generation {
}
}
- public void EmitSymbolIdId(SymbolId id) {
- if (DynamicMethod) {
- EmitInt(id.Id);
- } else {
- EmitSymbolId(id);
- Slot slot = GetLocalTmp(typeof(SymbolId));
- slot.EmitSet(this);
- slot.EmitGetAddr(this);
- EmitPropertyGet(typeof(SymbolId), "Id");
- FreeLocalTmp(slot);
- }
- }
-
public void EmitPropertyGet(Type type, string name) {
Contract.RequiresNotNull(type, "type");
Contract.RequiresNotNull(name, "name");
@@ -1287,7 +1176,7 @@ namespace Microsoft.Scripting.Generation {
}
}
- public void EmitCall(MethodInfo mi, bool tailcall)
+ public void EmitCall(MethodInfo mi, bool tailcall)
{
Contract.RequiresNotNull(mi, "mi");
@@ -1299,16 +1188,6 @@ namespace Microsoft.Scripting.Generation {
EmitCall(mi);
}
- public void EmitCall(Type type, String name, bool tailcall)
- {
- Contract.RequiresNotNull(type, "type");
- Contract.RequiresNotNull(name, "name");
- if (!type.IsVisible) throw new ArgumentException(String.Format(Resources.TypeMustBeVisible, type.FullName));
-
- EmitCall(type.GetMethod(name), tailcall);
- }
-
-
public void EmitCall(Type type, String name) {
Contract.RequiresNotNull(type, "type");
Contract.RequiresNotNull(name, "name");
@@ -1325,12 +1204,6 @@ namespace Microsoft.Scripting.Generation {
EmitCall(type.GetMethod(name, paramTypes));
}
- public void EmitName(SymbolId name) {
- if (name == SymbolId.Empty) throw new ArgumentException(Resources.EmptySymbolId, "name");
-
- EmitString(SymbolTable.IdToString(name));
- }
-
public void EmitType(Type type) {
Contract.RequiresNotNull(type, "type");
if (!(type is TypeBuilder) && !type.IsGenericParameter && !type.IsVisible) {
@@ -1379,50 +1252,6 @@ namespace Microsoft.Scripting.Generation {
}
/// <summary>
- /// Emits a Ldind* instruction for the appropriate type
- /// </summary>
- public void EmitLoadValueIndirect(Type type) {
- Contract.RequiresNotNull(type, "type");
-
- if (type.IsValueType) {
- if (type == typeof(int)) Emit(OpCodes.Ldind_I4);
- else if (type == typeof(uint)) Emit(OpCodes.Ldind_U4);
- else if (type == typeof(short)) Emit(OpCodes.Ldind_I2);
- else if (type == typeof(ushort)) Emit(OpCodes.Ldind_U2);
- else if (type == typeof(long) || type == typeof(ulong)) Emit(OpCodes.Ldind_I8);
- else if (type == typeof(char)) Emit(OpCodes.Ldind_I2);
- else if (type == typeof(bool)) Emit(OpCodes.Ldind_I1);
- else if (type == typeof(float)) Emit(OpCodes.Ldind_R4);
- else if (type == typeof(double)) Emit(OpCodes.Ldind_R8);
- else Emit(OpCodes.Ldobj, type);
- } else {
- Emit(OpCodes.Ldind_Ref);
- }
-
- }
-
- /// <summary>
- /// Emits a Stind* instruction for the appropriate type.
- /// </summary>
- public void EmitStoreValueIndirect(Type type) {
- Contract.RequiresNotNull(type, "type");
-
- if (type.IsValueType) {
- if (type == typeof(int)) Emit(OpCodes.Stind_I4);
- else if (type == typeof(short)) Emit(OpCodes.Stind_I2);
- else if (type == typeof(long) || type == typeof(ulong)) Emit(OpCodes.Stind_I8);
- else if (type == typeof(char)) Emit(OpCodes.Stind_I2);
- else if (type == typeof(bool)) Emit(OpCodes.Stind_I1);
- else if (type == typeof(float)) Emit(OpCodes.Stind_R4);
- else if (type == typeof(double)) Emit(OpCodes.Stind_R8);
- else Emit(OpCodes.Stobj, type);
- } else {
- Emit(OpCodes.Stind_Ref);
- }
-
- }
-
- /// <summary>
/// Emits the Ldelem* instruction for the appropriate type
/// </summary>
/// <param name="type"></param>
@@ -1895,13 +1724,6 @@ namespace Microsoft.Scripting.Generation {
}
}
- public Delegate CreateDelegate(Type delegateType, object target) {
- Contract.RequiresNotNull(delegateType, "delegateType");
- Debug.Assert(!ConstantPool.IsBound);
-
- return ReflectionUtils.CreateDelegate(CreateDelegateMethodInfo(), delegateType, target);
- }
-
public CodeGen DefineMethod(string name, Type retType, IList<Type> paramTypes, string[] paramNames, ConstantPool constantPool) {
Contract.RequiresNotNullItems(paramTypes, "paramTypes");
//Contract.RequiresNotNull(paramNames, "paramNames");
@@ -1933,10 +1755,6 @@ namespace Microsoft.Scripting.Generation {
return _ilg.BeginExceptionBlock();
}
- public void BeginFaultBlock() {
- _ilg.BeginFaultBlock();
- }
-
public void BeginFinallyBlock() {
_ilg.BeginFinallyBlock();
}
@@ -2001,23 +1819,11 @@ namespace Microsoft.Scripting.Generation {
public void Emit(OpCode opcode, MethodInfo meth) {
_ilg.Emit(opcode, meth);
}
-
- [CLSCompliant(false)]
- public void Emit(OpCode opcode, sbyte arg)
- {
- _ilg.Emit(opcode, arg);
- }
-
+
public void Emit(OpCode opcode, short arg) {
_ilg.Emit(opcode, arg);
}
-#if !SILVERLIGHT
- public void Emit(OpCode opcode, SignatureHelper signature) {
- _ilg.Emit(opcode, signature);
- }
-#endif
-
public void Emit(OpCode opcode, string str) {
_ilg.Emit(opcode, str);
}
@@ -2026,10 +1832,6 @@ namespace Microsoft.Scripting.Generation {
_ilg.Emit(opcode, cls);
}
- public void EmitCall(OpCode opcode, MethodInfo methodInfo, Type[] optionalParameterTypes) {
- _ilg.EmitCall(opcode, methodInfo, optionalParameterTypes);
- }
-
public void EndExceptionBlock() {
if (_targets.Count > 0) {
Targets t = _targets.Peek();
@@ -2069,11 +1871,6 @@ namespace Microsoft.Scripting.Generation {
PAL.MarkSequencePoint(_ilg, document, startLine, startColumn, endLine, endColumn);
}
}
-
- public void EmitWriteLine(string value) {
- _ilg.EmitWriteLine(value);
- }
-
#endregion
#region IDisposable Members
@@ -2183,25 +1980,6 @@ namespace Microsoft.Scripting.Generation {
public Label returnStart;
}
- private bool CanUseFastSite() {
- // TypeGen is required for fast sites.
- if (_typeGen == null) {
- return false;
- }
-
- // Fast sites are disabled for dynamic methods
- if (DynamicMethod) {
- return false;
- }
-
- // Fast sites only possible with global constext
- if (!(this.ContextSlot is StaticFieldSlot)) {
- return false;
- }
-
- return true;
- }
-
internal Slot GetTemporarySlot(Type type) {
Slot temp;
@@ -2216,12 +1994,6 @@ namespace Microsoft.Scripting.Generation {
return temp;
}
- internal void FreeTemporarySlot(Slot temp) {
- if (!IsGenerator) {
- FreeLocalTmp(temp);
- }
- }
-
readonly internal static Dictionary<string, ISymbolDocumentWriter> SymbolWriters = new Dictionary<string, ISymbolDocumentWriter>();
static string GetFilename(ISymbolDocumentWriter w)
@@ -2236,19 +2008,6 @@ namespace Microsoft.Scripting.Generation {
return null;
}
- internal CodeGen ProvideAbstractCodeBlock(CodeBlock block, bool hasContextParameter, bool hasThis)
- {
- Assert.NotNull(block);
- CodeGen impl = null;
-
- if (!hasContextParameter)
- {
- impl = block.CreateMethod(this, hasContextParameter, hasThis);
- }
-
- return impl;
- }
-
static readonly ConstructorInfo NRC = typeof(IronScheme.Runtime.NonRecursiveAttribute).GetConstructor(Type.EmptyTypes);
static readonly CustomAttributeBuilder CAB = new CustomAttributeBuilder(NRC, new object[0]);
diff --git a/IronScheme/Microsoft.Scripting/Generation/CompilerHelpers.cs b/IronScheme/Microsoft.Scripting/Generation/CompilerHelpers.cs
index e44170a4..74db53c3 100644
--- a/IronScheme/Microsoft.Scripting/Generation/CompilerHelpers.cs
+++ b/IronScheme/Microsoft.Scripting/Generation/CompilerHelpers.cs
@@ -31,33 +31,11 @@ namespace Microsoft.Scripting.Generation {
public static class CompilerHelpers {
public static readonly MethodAttributes PublicStatic = MethodAttributes.Public | MethodAttributes.Static;
- public static string[] GetArgumentNames(ParameterInfo[] parameterInfos) {
- string[] ret = new string[parameterInfos.Length];
- for (int i = 0; i < parameterInfos.Length; i++) ret[i] = parameterInfos[i].Name;
- return ret;
- }
-
- public static Type[] GetTypesWithThis(MethodBase mi) {
- Type[] types = ReflectionUtils.GetParameterTypes(mi.GetParameters());
- if (IsStatic(mi)) {
- return types;
- }
-
- return ArrayUtils.Insert(mi.DeclaringType, types);
- }
-
-
public static Type GetReturnType(MethodBase mi) {
if (mi.IsConstructor) return mi.DeclaringType;
else return ((MethodInfo)mi).ReturnType;
}
- public static int GetStaticNumberOfArgs(MethodBase method) {
- if (IsStatic(method)) return method.GetParameters().Length;
-
- return method.GetParameters().Length + 1;
- }
-
public static bool IsParamsMethod(MethodBase method) {
return IsParamsMethod(method.GetParameters());
}
@@ -79,22 +57,6 @@ namespace Microsoft.Scripting.Generation {
return (pi.Attributes & (ParameterAttributes.Out | ParameterAttributes.In)) == ParameterAttributes.Out;
}
- private static int GetMandatoryParameterCount(ParameterInfo[] parameters) {
- Assert.NotNull(parameters);
- int lastMandatory = parameters.Length - 1;
- while (lastMandatory >= 0 && !IsMandatoryParameter(parameters[lastMandatory])) lastMandatory--;
- return (lastMandatory >= 0 && IsParamArray(parameters[lastMandatory])) ? lastMandatory : lastMandatory + 1;
- }
-
- public static int GetOutAndByRefParameterCount(MethodBase method) {
- int res = 0;
- ParameterInfo[] pis = method.GetParameters();
- for (int i = 0; i < pis.Length; i++) {
- if (IsByRefParameter(pis[i])) res++;
- }
- return res;
- }
-
/// <summary>
/// Returns <c>true</c> if the specified parameter is mandatory, i.e. is not optional and doesn't have a default value.
/// </summary>
@@ -106,13 +68,6 @@ namespace Microsoft.Scripting.Generation {
return (pi.Attributes & ParameterAttributes.HasDefault) != 0;
}
- public static bool IsByRefParameter(ParameterInfo pi) {
- // not using IsIn/IsOut properties as they are not available in Silverlight:
- if (pi.ParameterType.IsByRef) return true;
-
- return (pi.Attributes & (ParameterAttributes.Out)) == ParameterAttributes.Out;
- }
-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
public static object GetMissingValue(Type type) {
Contract.RequiresNotNull(type, "type");
@@ -167,16 +122,6 @@ namespace Microsoft.Scripting.Generation {
}
/// <summary>
- /// A helper routine to check if a type can be treated as sealed - i.e. there
- /// can never be a subtype of this given type. This corresponds to a type
- /// that is either declared "Sealed" or is a ValueType and thus unable to be
- /// extended.
- /// </summary>
- public static bool IsSealed(Type type) {
- return type.IsSealed || type.IsValueType;
- }
-
- /// <summary>
/// Will create storage allocator which allocates locals on the CLR stack (in the context of the codeGen).
/// This doesn't set up allocator for globals. Further initialization needed.
/// </summary>
@@ -283,55 +228,6 @@ namespace Microsoft.Scripting.Generation {
#endregion
- public static Operators OperatorToReverseOperator(Operators op) {
- switch (op) {
- case Operators.LessThan: return Operators.GreaterThan;
- case Operators.LessThanOrEqual: return Operators.GreaterThanOrEqual;
- case Operators.GreaterThan: return Operators.LessThan;
- case Operators.GreaterThanOrEqual: return Operators.LessThanOrEqual;
- case Operators.Equals: return Operators.Equals;
- case Operators.NotEquals: return Operators.NotEquals;
- default:
- if (op >= Operators.Add && op <= Operators.Xor) {
- return (Operators)((int)op + (int)Operators.ReverseAdd - (int)Operators.Add);
- }
- return Operators.None;
- }
- }
-
- public static Operators InPlaceOperatorToOperator(Operators op) {
- switch (op) {
- case Operators.InPlaceAdd: return Operators.Add;
- case Operators.InPlaceBitwiseAnd: return Operators.BitwiseAnd;
- case Operators.InPlaceBitwiseOr: return Operators.BitwiseOr;
- case Operators.InPlaceDivide: return Operators.Divide;
- case Operators.InPlaceFloorDivide: return Operators.FloorDivide;
- case Operators.InPlaceLeftShift: return Operators.LeftShift;
- case Operators.InPlaceMod: return Operators.Mod;
- case Operators.InPlaceMultiply: return Operators.Multiply;
- case Operators.InPlacePower: return Operators.Power;
- case Operators.InPlaceRightShift: return Operators.RightShift;
- case Operators.InPlaceSubtract: return Operators.Subtract;
- case Operators.InPlaceTrueDivide: return Operators.TrueDivide;
- case Operators.InPlaceXor: return Operators.Xor;
- case Operators.InPlaceRightShiftUnsigned: return Operators.RightShiftUnsigned;
- default: return Operators.None;
- }
-
- }
- public static bool IsComparisonOperator(Operators op) {
- switch (op) {
- case Operators.LessThan: return true;
- case Operators.LessThanOrEqual: return true;
- case Operators.GreaterThan: return true;
- case Operators.GreaterThanOrEqual: return true;
- case Operators.Equals: return true;
- case Operators.NotEquals: return true;
- case Operators.Compare: return true;
- }
- return false;
- }
-
/// <summary>
/// Returns the System.Type for any object, including null. The type of null
/// is represented by None.Type and all other objects just return the
@@ -352,17 +248,6 @@ namespace Microsoft.Scripting.Generation {
return types;
}
- public static bool CanOptimizeMethod(MethodBase method) {
- if (method.ContainsGenericParameters ||
- method.IsFamily ||
- method.IsPrivate ||
- method.IsFamilyOrAssembly ||
- !method.DeclaringType.IsVisible) {
- return false;
- }
- return true;
- }
-
/// <summary>
/// Given a MethodInfo which may be declared on a non-public type this attempts to
/// return a MethodInfo which will dispatch to the original MethodInfo but is declared
@@ -390,35 +275,6 @@ namespace Microsoft.Scripting.Generation {
return method;
}
- /// <summary>
- /// Given a MethodInfo which may be declared on a non-public type this attempts to
- /// return a MethodInfo which will dispatch to the original MethodInfo but is declared
- /// on a public type.
- ///
- /// Throws InvalidOperationException if the method cannot be obtained.
- /// </summary>
- public static MethodInfo GetCallableMethod(MethodInfo method) {
- MethodInfo mi = TryGetCallableMethod(method);
- if (mi == null) {
- if (!ScriptDomainManager.Options.PrivateBinding) {
- throw new InvalidOperationException(String.Format("{0}.{1} has no publiclly visible method", method.DeclaringType, method.Name));
- }
- }
- return mi;
- }
-
- public static bool CanOptimizeField(FieldInfo fi) {
- return fi.IsPublic && fi.DeclaringType.IsVisible;
- }
-
- internal static void CreateYieldLabels(CodeGen cg, List<YieldTarget> targets) {
- if (targets != null) {
- foreach (YieldTarget yt in targets) {
- yt.EnsureLabel(cg);
- }
- }
- }
-
public static Type GetVisibleType(object value) {
return GetVisibleType(GetType(value));
}
@@ -429,111 +285,5 @@ namespace Microsoft.Scripting.Generation {
}
return t;
}
-
- public static MethodBase[] GetConstructors(Type t) {
- if (t.IsArray) {
- // The JIT verifier doesn't like new int[](3) even though it appears as a ctor.
- // We could do better and return newarr in the future.
- return new MethodBase[] { GetArrayCtor(t) };
- }
-
- BindingFlags bf = BindingFlags.Instance | BindingFlags.Public;
- if (ScriptDomainManager.Options.PrivateBinding) {
- bf |= BindingFlags.NonPublic;
- }
-
- ConstructorInfo[] ci = t.GetConstructors(bf);
-
- if (t.IsValueType) {
- // structs don't define a parameterless ctor, add a generic method for that.
- return ArrayUtils.Insert<MethodBase>(GetStructDefaultCtor(t), ci);
- }
-
- if (typeof(Delegate).IsAssignableFrom(t)) {
- return ArrayUtils.Insert<MethodBase>(GetDelegateCtor(t), ci);
- }
-
- return ci;
- }
-
- private static MethodBase GetStructDefaultCtor(Type t) {
- return typeof(BinderOps).GetMethod("CreateInstance").MakeGenericMethod(t);
- }
-
- private static MethodBase GetArrayCtor(Type t) {
- return typeof(BinderOps).GetMethod("CreateArray").MakeGenericMethod(t.GetElementType());
- }
-
- private static MethodBase GetDelegateCtor(Type t) {
- return typeof(BinderOps).GetMethod("CreateDelegate").MakeGenericMethod(t);
- }
-
- public static bool HasImplicitConversion(Type fromType, Type toType) {
- if (CompilerHelpers.HasImplicitConversion(fromType, toType, toType.GetMember("op_Implicit"))) {
- return true;
- }
-
- Type curType = fromType;
- do {
- if (CompilerHelpers.HasImplicitConversion(fromType, toType, curType.GetMember("op_Implicit"))) {
- return true;
- }
- curType = curType.BaseType;
- } while (curType != null);
-
- return false;
- }
-
- public static bool TryImplicitConversion(Object value, Type to, out object result) {
- if (CompilerHelpers.TryImplicitConvert(value, to, to.GetMember("op_Implicit"), out result)) {
- return true;
- }
-
- Type curType = CompilerHelpers.GetType(value);
- do {
- if (CompilerHelpers.TryImplicitConvert(value, to, curType.GetMember("op_Implicit"), out result)) {
- return true;
- }
- curType = curType.BaseType;
- } while (curType != null);
-
- return false;
- }
-
- private static bool TryImplicitConvert(Object value, Type to, MemberInfo[] implicitConv, out object result) {
- foreach (MethodInfo mi in implicitConv) {
- if (to.IsValueType == mi.ReturnType.IsValueType && to.IsAssignableFrom(mi.ReturnType)) {
- if (mi.IsStatic) {
- result = mi.Invoke(null, new object[] { value });
- } else {
- result = mi.Invoke(value, ArrayUtils.EmptyObjects);
- }
- return true;
- }
- }
-
- result = null;
- return false;
- }
-
- private static bool HasImplicitConversion(Type fromType, Type to, MemberInfo[] implicitConv) {
- foreach (MethodInfo mi in implicitConv) {
- if (mi.ReturnType == to && mi.GetParameters()[0].ParameterType.IsAssignableFrom(fromType)) {
- return true;
- }
- }
-
- return false;
- }
-
- public static bool IsStrongBox(object target) {
- Type t = CompilerHelpers.GetType(target);
-
- return IsStrongBox(t);
- }
-
- public static bool IsStrongBox(Type t) {
- return t.IsGenericType && t.GetGenericTypeDefinition() == typeof(StrongBox<>);
- }
}
}
diff --git a/IronScheme/Microsoft.Scripting/Generation/ConstantPool.cs b/IronScheme/Microsoft.Scripting/Generation/ConstantPool.cs
index a77c3586..328a6415 100644
--- a/IronScheme/Microsoft.Scripting/Generation/ConstantPool.cs
+++ b/IronScheme/Microsoft.Scripting/Generation/ConstantPool.cs
@@ -116,23 +116,5 @@ namespace Microsoft.Scripting.Generation {
return _staticData.Count - 1;
}
}
-
- public static object GetConstantData(int index) {
- lock (_staticData) {
- object res = _staticData[index];
- _staticData[index] = null;
- _empties++;
- Debug.Assert(res != null);
- return res == _nullVal ? null : res;
- }
- }
-
- public static object GetConstantDataReusable(int index) {
- lock (_staticData) {
- object res = _staticData[index];
- Debug.Assert(res != null);
- return res == _nullVal ? null : res;
- }
- }
}
}
diff --git a/IronScheme/Microsoft.Scripting/Generation/DefaultArgBuilder.cs b/IronScheme/Microsoft.Scripting/Generation/DefaultArgBuilder.cs
index 125a02d4..e9206ea1 100644
--- a/IronScheme/Microsoft.Scripting/Generation/DefaultArgBuilder.cs
+++ b/IronScheme/Microsoft.Scripting/Generation/DefaultArgBuilder.cs
@@ -81,31 +81,6 @@ namespace Microsoft.Scripting.Generation {
return _defaultValue;
}
- private static void EmitDefaultValue(CodeGen cg, object value, Type type) {
- if (value is Missing) {
- cg.EmitMissingValue(type);
- } else {
- cg.EmitConstant(value);
- //TODO This should turn into cg.EmitConvert(value.GetType(), type)
- if (type.IsValueType) {
- if (value == null) cg.EmitTypeError("Cannot cast None to {0}", type);
- else if (value.GetType() != type) cg.EmitTypeError("Cannot cast {0} to {1}", value, type);
- } else {
- // null is any reference type
- if (value != null) {
- Type from = value.GetType();
- if (!type.IsAssignableFrom(from)) {
- cg.EmitTypeError("Cannot cast {0} to {1}", value, type);
- } else {
- if (from.IsValueType) {
- cg.Emit(OpCodes.Box, from);
- }
- }
- }
- }
- }
- }
-
internal override Expression ToExpression(MethodBinderContext context, Expression[] parameters) {
object val = _defaultValue;
if(val is Missing) {
diff --git a/IronScheme/Microsoft.Scripting/Generation/ModuleGlobalSlot.cs b/IronScheme/Microsoft.Scripting/Generation/ModuleGlobalSlot.cs
index fb2f85a3..7c29bdc0 100644
--- a/IronScheme/Microsoft.Scripting/Generation/ModuleGlobalSlot.cs
+++ b/IronScheme/Microsoft.Scripting/Generation/ModuleGlobalSlot.cs
@@ -48,11 +48,6 @@ namespace Microsoft.Scripting.Generation {
cg.EmitPropertySet(typeof(ModuleGlobalWrapper), "CurrentValue");
}
- public void EmitGetRaw(CodeGen cg) {
- _wrapper.EmitGet(cg);
- cg.EmitPropertyGet(typeof(ModuleGlobalWrapper), "RawValue");
- }
-
public override void EmitCheck(CodeGen cg, SymbolId name) {
// checks are handled in the get_CurrentValue
}
@@ -61,10 +56,6 @@ namespace Microsoft.Scripting.Generation {
_wrapper.EmitGetAddr(cg);
}
- public void EmitWrapper(CodeGen cg) {
- _wrapper.EmitGet(cg);
- }
-
public override void EmitGetAddr(CodeGen cg) {
throw new NotSupportedException("Can't get address of module global.");
}
diff --git a/IronScheme/Microsoft.Scripting/Generation/ReturnFixer.cs b/IronScheme/Microsoft.Scripting/Generation/ReturnFixer.cs
deleted file mode 100644
index b45dcf65..00000000
--- a/IronScheme/Microsoft.Scripting/Generation/ReturnFixer.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation.
- *
- * This source code is subject to terms and conditions of the Microsoft Public License. A
- * copy of the license can be found in the License.html file at the root of this distribution. If
- * you cannot locate the Microsoft Public License, please send an email to
- * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
- * by the terms of the Microsoft Public License.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System;
-using System.Diagnostics;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting.Generation {
- public sealed class ReturnFixer {
- private readonly Slot _argSlot;
- private readonly Slot _refSlot;
-
- private ReturnFixer(Slot refSlot, Slot argSlot) {
- Debug.Assert(refSlot.Type.IsGenericType && refSlot.Type.GetGenericTypeDefinition() == typeof(StrongBox<>));
- Debug.Assert(argSlot.Type.IsByRef);
- this._refSlot = refSlot;
- this._argSlot = argSlot;
- }
-
- public static ReturnFixer EmitArgument(CodeGen cg, Slot argSlot) {
- argSlot.EmitGet(cg);
- if (argSlot.Type.IsByRef) {
- Type elementType = argSlot.Type.GetElementType();
- Type concreteType = typeof(StrongBox<>).MakeGenericType(elementType);
- Slot refSlot = cg.GetLocalTmp(concreteType);
- cg.EmitLoadValueIndirect(elementType);
- cg.EmitNew(concreteType, new Type[] { elementType });
- refSlot.EmitSet(cg);
- refSlot.EmitGet(cg);
- return new ReturnFixer(refSlot, argSlot);
- } else {
- cg.EmitBoxing(argSlot.Type);
- return null;
- }
- }
-
- public void FixReturn(CodeGen cg) {
- _argSlot.EmitGet(cg);
- _refSlot.EmitGet(cg);
- cg.EmitCall(typeof(BinderOps).GetMethod("GetBox").MakeGenericMethod(_argSlot.Type.GetElementType()));
- cg.EmitStoreValueIndirect(_argSlot.Type.GetElementType());
- }
- }
-}
diff --git a/IronScheme/Microsoft.Scripting/Generation/Slots/ArgSlot.cs b/IronScheme/Microsoft.Scripting/Generation/Slots/ArgSlot.cs
index a438e782..16305aa8 100644
--- a/IronScheme/Microsoft.Scripting/Generation/Slots/ArgSlot.cs
+++ b/IronScheme/Microsoft.Scripting/Generation/Slots/ArgSlot.cs
@@ -34,11 +34,6 @@ namespace Microsoft.Scripting.Generation {
this._codeGen = codeGen;
}
- public void SetName(string name) {
- _codeGen.DefineParameter(_index, ParameterAttributes.None, name);
- }
-
-
public override void EmitGet(CodeGen cg) {
Contract.RequiresNotNull(cg, "cg");
Debug.Assert(cg == this._codeGen);
diff --git a/IronScheme/Microsoft.Scripting/Generation/Snippets.cs b/IronScheme/Microsoft.Scripting/Generation/Snippets.cs
index 157ec308..6475dd00 100644
--- a/IronScheme/Microsoft.Scripting/Generation/Snippets.cs
+++ b/IronScheme/Microsoft.Scripting/Generation/Snippets.cs
@@ -96,22 +96,6 @@ namespace Microsoft.Scripting.Generation {
return new AssemblyGen(name, null, name + ".dll", attrs);
}
- public void Dump() {
- Dump(null);
- }
-
- public void Dump(string fileName) {
- if (_assembly != null && _assembly.SaveAndReloadAssemblies) {
- _assembly.Dump(fileName);
- _assembly = null;
- }
-
- if (_debugAssembly != null && _debugAssembly.SaveAndReloadAssemblies) {
- _debugAssembly.Dump();
- _debugAssembly = null;
- }
- }
-
public TypeGen DefineDebuggableType(string typeName, SourceUnit sourceUnit) {
typeName = typeName.Replace(Type.Delimiter, '_'); // '.' is for separating the namespace and the type name.
DebugAssembly.SetSourceUnit(sourceUnit);
diff --git a/IronScheme/Microsoft.Scripting/Generation/TypeGen.cs b/IronScheme/Microsoft.Scripting/Generation/TypeGen.cs
index 2cd034ce..3d7375ef 100644
--- a/IronScheme/Microsoft.Scripting/Generation/TypeGen.cs
+++ b/IronScheme/Microsoft.Scripting/Generation/TypeGen.cs
@@ -44,8 +44,6 @@ namespace Microsoft.Scripting.Generation {
public int ConstantCounter = 0;
public List<object> SerializedConstants = new List<object>();
- private static readonly Type[] SymbolIdIntCtorSig = new Type[] { typeof(int) };
-
public TypeGen(AssemblyGen myAssembly, TypeBuilder myType) {
this._myAssembly = myAssembly;
this._myType = myType;
@@ -103,26 +101,6 @@ namespace Microsoft.Scripting.Generation {
}
}
- public ActionBinder Binder {
- get {
- return _binder;
- }
- set {
- _binder = value;
- }
- }
-
- public TypeGen DefineNestedType(string name, Type parent) {
- TypeBuilder tb = _myType.DefineNestedType(name, TypeAttributes.NestedPublic);
- tb.SetParent(parent);
- TypeGen ret = new TypeGen(_myAssembly, tb);
- _nestedTypeGens.Add(ret);
-
- ret.AddCodeContextField();
-
- return ret;
- }
-
public void AddCodeContextField() {
FieldBuilder contextField = _myType.DefineField(CodeContext.ContextFieldName,
typeof(CodeContext),
@@ -131,12 +109,7 @@ namespace Microsoft.Scripting.Generation {
_contextSlot = new StaticFieldSlot(contextField);
}
- public Slot AddField(Type fieldType, string name)
- {
- return AddField(fieldType, name, FieldAttributes.Public);
- }
-
- public Slot AddField(Type fieldType, string name, FieldAttributes attributes)
+ public Slot AddField(Type fieldType, string name, FieldAttributes attributes)
{
FieldBuilder fb = _myType.DefineField(name, fieldType, attributes);
return new FieldSlot(new ThisSlot(_myType), fb);
@@ -169,10 +142,6 @@ namespace Microsoft.Scripting.Generation {
return ret;
}
- public PropertyBuilder DefineProperty(string name, PropertyAttributes attrs, Type returnType) {
- return _myType.DefineProperty(name, attrs, returnType, ArrayUtils.EmptyTypes);
- }
-
private const MethodAttributes MethodAttributesToEraseInOveride =
MethodAttributes.Abstract | MethodAttributes.ReservedMask;
@@ -250,27 +219,6 @@ namespace Microsoft.Scripting.Generation {
return CreateCodeGen(cb, cb.GetILGenerator(), paramTypes);
}
- public CodeGen DefineStaticConstructor() {
- ConstructorBuilder cb = _myType.DefineTypeInitializer();
- return CreateCodeGen(cb, cb.GetILGenerator(), ArrayUtils.EmptyTypes);
- }
-
- public void SetCustomAttribute(Type type, object[] values) {
- Contract.RequiresNotNull(type, "type");
-
- Type[] types = new Type[values.Length];
- for (int i = 0; i < types.Length; i++) {
- if (values[i] != null) {
- types[i] = values[i].GetType();
- } else {
- types[i] = typeof(object);
- }
- }
- CustomAttributeBuilder cab = new CustomAttributeBuilder(type.GetConstructor(types), values);
-
- _myType.SetCustomAttribute(cab);
- }
-
/// <summary>
/// Constants
/// </summary>
@@ -349,9 +297,5 @@ namespace Microsoft.Scripting.Generation {
public TypeBuilder TypeBuilder {
get { return _myType; }
}
-
- public Slot ContextSlot {
- get { return _contextSlot; }
- }
}
}
diff --git a/IronScheme/Microsoft.Scripting/LanguageContext.cs b/IronScheme/Microsoft.Scripting/LanguageContext.cs
index b2e4ef65..ecf8fd9c 100644
--- a/IronScheme/Microsoft.Scripting/LanguageContext.cs
+++ b/IronScheme/Microsoft.Scripting/LanguageContext.cs
@@ -14,23 +14,19 @@
* ***************************************************************************/
using System;
-using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Globalization;
using Microsoft.Scripting.Ast;
-using Microsoft.Scripting.Shell;
using Microsoft.Scripting.Actions;
using Microsoft.Scripting.Hosting;
-using Microsoft.Scripting.Generation;
-using System.Runtime.CompilerServices;
using System.Reflection;
using Microsoft.Scripting.Utils;
-using System.Diagnostics;
using System.IO;
-namespace Microsoft.Scripting {
+namespace Microsoft.Scripting
+{
/// <summary>
/// Provides language specific facilities which are typicalled called by the runtime.
/// </summary>
@@ -68,11 +64,6 @@ namespace Microsoft.Scripting {
}
#region Module Context
-
- public ModuleContext GetModuleContext(ScriptModule module) {
- Contract.RequiresNotNull(module, "module");
- return module.GetModuleContext(ContextId);
- }
public ModuleContext EnsureModuleContext(ScriptModule module) {
Contract.RequiresNotNull(module, "module");
@@ -133,10 +124,6 @@ namespace Microsoft.Scripting {
context.SourceUnit.CodeProperties = (block != null) ? SourceCodeProperties.None : SourceCodeProperties.IsInvalid;
}
}
-
- public ScriptCode CompileSourceCode(SourceUnit sourceUnit) {
- return CompileSourceCode(sourceUnit, null, null);
- }
public ScriptCode CompileSourceCode(SourceUnit sourceUnit, CompilerOptions options) {
return CompileSourceCode(sourceUnit, options, null);
@@ -146,7 +133,6 @@ namespace Microsoft.Scripting {
{
CompilerContext context = new CompilerContext(SourceUnit.CreateSnippet(Engine, string.Empty), GetCompilerOptions(), Engine.GetCompilerErrorSink());
AnalyzeBlock(block);
- DumpBlock(block, null);
return new ScriptCode(block, Engine.GetLanguageContext(context.Options), context);
}
@@ -154,7 +140,6 @@ namespace Microsoft.Scripting {
{
CompilerContext context = new CompilerContext(SourceUnit.CreateFileUnit(Engine, sourcefile), GetCompilerOptions(), Engine.GetCompilerErrorSink());
AnalyzeBlock(block);
- DumpBlock(block, null);
return new ScriptCode(block, Engine.GetLanguageContext(context.Options), context);
}
@@ -172,23 +157,12 @@ namespace Microsoft.Scripting {
throw new SyntaxErrorException("invalid syntax|" + sourceUnit.GetCode().Trim());
}
- //DumpBlock(block, sourceUnit.Id);
-
AnalyzeBlock(block);
- DumpBlock(block, sourceUnit.Id);
-
// TODO: ParseSourceCode can update CompilerContext.Options
return new ScriptCode(block, Engine.GetLanguageContext(context.Options), context);
}
- [Conditional("DEBUG")]
- private static void DumpBlock(CodeBlock block, string id) {
-#if DEBUG
- AstWriter.Dump(block, id);
-#endif
- }
-
public static void AnalyzeBlock(CodeBlock block)
{
ClosureBinder.Bind(block);
@@ -249,13 +223,6 @@ namespace Microsoft.Scripting {
}
/// <summary>
- /// Attempts to remove the name from the provided scope using the current language's semantics.
- /// </summary>
- public virtual bool RemoveName(CodeContext context, SymbolId name) {
- return context.Scope.RemoveName(this, name);
- }
-
- /// <summary>
/// Attemps to lookup a global variable using the language's semantics called from
/// the provided Scope. The default implementation will attempt to lookup the variable
/// at the host level.
@@ -293,120 +260,16 @@ namespace Microsoft.Scripting {
return _noCache;
}
- #region ICloneable Members
-
- public virtual object Clone() {
- return MemberwiseClone();
- }
-
- #endregion
-
public virtual bool IsTrue(object obj) {
return false;
}
/// <summary>
- /// Calls the function with given arguments
- /// </summary>
- /// <param name="context"></param>
- /// <param name="function">The function to call</param>
- /// <param name="args">The argumetns with which to call the function.</param>
- /// <returns></returns>
- public virtual object Call(CodeContext context, object function, object[] args) {
- return null;
- }
-
- /// <summary>
- /// Calls the function with instance as the "this" value.
- /// </summary>
- /// <param name="context"></param>
- /// <param name="function">The function to call</param>
- /// <param name="instance">The instance to pass as "this".</param>
- /// <param name="args">The rest of the arguments.</param>
- /// <returns></returns>
- public virtual object CallWithThis(CodeContext context, object function, object instance, object[] args) {
- return null;
- }
-
- /// <summary>
- /// Calls the function with arguments, extra arguments in tuple and dictionary of keyword arguments
- /// </summary>
- /// <param name="context"></param>
- /// <param name="func">The function to call</param>
- /// <param name="args">The arguments</param>
- /// <param name="names">Argument names</param>
- /// <param name="argsTuple">tuple of extra arguments</param>
- /// <param name="kwDict">keyword dictionary</param>
- /// <returns>The result of the function call.</returns>
- public virtual object CallWithArgsKeywordsTupleDict(CodeContext context, object func, object[] args, string[] names, object argsTuple, object kwDict) {
- return null;
- }
-
- /// <summary>
- /// Calls function with arguments and additional arguments in the tuple
- /// </summary>
- /// <param name="context"></param>
- /// <param name="func">The function to call</param>
- /// <param name="args">Argument array</param>
- /// <param name="argsTuple">Tuple with extra arguments</param>
- /// <returns>The result of calling the function "func"</returns>
- public virtual object CallWithArgsTuple(CodeContext context, object func, object[] args, object argsTuple) {
- return null;
- }
-
- /// <summary>
- /// Calls the function with arguments, some of which are keyword arguments.
- /// </summary>
- /// <param name="context"></param>
- /// <param name="func">Function to call</param>
- /// <param name="args">Argument array</param>
- /// <param name="names">Names for some of the arguments</param>
- /// <returns>The result of calling the function "func"</returns>
- public virtual object CallWithKeywordArgs(CodeContext context, object func, object[] args, string[] names) {
- return null;
- }
-
- // used only by ReflectedEvent.HandlerList
- public virtual bool EqualReturnBool(CodeContext context, object x, object y) {
- return false;
- }
-
- /// <summary>
/// Gets the value or throws an exception when the provided MethodCandidate cannot be called.
/// </summary>
/// <returns></returns>
public virtual object GetNotImplemented(params MethodCandidate []candidates) {
throw new MissingMemberException("the specified operator is not implemented");
}
-
-
- // used by DynamicHelpers.GetDelegate
- /// <summary>
- /// Checks whether the target is callable with given number of arguments.
- /// </summary>
- public void CheckCallable(object target, int argumentCount) {
- int min, max;
- if (!IsCallable(target, argumentCount, out min, out max)) {
- if (min == max) {
- throw RuntimeHelpers.SimpleTypeError(String.Format("expected compatible function, but got parameter count mismatch (expected {0} args, target takes {1})", argumentCount, min));
- } else {
- throw RuntimeHelpers.SimpleTypeError(String.Format("expected compatible function, but got parameter count mismatch (expected {0} args, target takes at least {1} and at most {2})", argumentCount, min, max));
- }
- }
- }
-
- public virtual bool IsCallable(object target, int argumentCount, out int min, out int max) {
- min = max = 0;
- return true;
- }
-
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.Reflection.Assembly.LoadFile")]
- public virtual Assembly LoadAssemblyFromFile(string file) {
-#if SILVERLIGHT
- return null;
-#else
- return Assembly.LoadFile(file);
-#endif
- }
}
}
diff --git a/IronScheme/Microsoft.Scripting/MethodBinder.cs b/IronScheme/Microsoft.Scripting/MethodBinder.cs
index 761d772f..a1ee7119 100644
--- a/IronScheme/Microsoft.Scripting/MethodBinder.cs
+++ b/IronScheme/Microsoft.Scripting/MethodBinder.cs
@@ -50,10 +50,6 @@ namespace Microsoft.Scripting {
return (method.CallingConvention & CallingConventions.VarArgs) != 0 || method.ContainsGenericParameters;
}
- public static MethodBinder MakeBinder(ActionBinder binder, string name, IList<MethodBase> mis, BinderType binderType, SymbolId[] keywordArgs) {
- return new MethodBinder(binder, name, mis, binderType, keywordArgs);
- }
-
public static MethodBinder MakeBinder(ActionBinder binder, string name, IList<MethodBase> mis, BinderType binderType) {
return new MethodBinder(binder, name, mis, binderType, SymbolId.EmptySymbols);
}
@@ -157,10 +153,6 @@ namespace Microsoft.Scripting {
return null;
}
- public object CallInstanceReflected(CodeContext context, object instance, params object[] args) {
- return CallReflected(context, CallType.ImplicitInstance, ArrayUtils.Insert(instance, args));
- }
-
public object CallReflected(CodeContext context, CallType callType, params object[] args) {
TargetSet ts = GetTargetSet(args.Length);
if (ts != null) return ts.CallReflected(context, callType, args, _kwArgs);
@@ -316,7 +308,6 @@ namespace Microsoft.Scripting {
parameters);
}
-
private MethodCandidate MakeByRefReducedMethodTarget(MethodBase method) {
List<ParameterWrapper> parameters = new List<ParameterWrapper>();
int argIndex = 0;
@@ -474,12 +465,6 @@ namespace Microsoft.Scripting {
}
return string.Join(Environment.NewLine, res.ToArray());
}
-
- public string Name {
- get {
- return _name;
- }
- }
}
public class TargetSet {
diff --git a/IronScheme/Microsoft.Scripting/MethodCandidate.cs b/IronScheme/Microsoft.Scripting/MethodCandidate.cs
index 26283106..1b84124c 100644
--- a/IronScheme/Microsoft.Scripting/MethodCandidate.cs
+++ b/IronScheme/Microsoft.Scripting/MethodCandidate.cs
@@ -219,12 +219,6 @@ namespace Microsoft.Scripting {
return buf.ToString(); //@todo add helper info for more interesting signatures
}
- public NarrowingLevel NarrowingLevel {
- get {
- return _narrowingLevel;
- }
- }
-
internal IList<ParameterWrapper> Parameters {
get {
return _parameters;
diff --git a/IronScheme/Microsoft.Scripting/ModuleContext.cs b/IronScheme/Microsoft.Scripting/ModuleContext.cs
index dffc6d7e..7b67c09d 100644
--- a/IronScheme/Microsoft.Scripting/ModuleContext.cs
+++ b/IronScheme/Microsoft.Scripting/ModuleContext.cs
@@ -72,16 +72,6 @@ namespace Microsoft.Scripting {
_module = module;
}
- /// <summary>
- /// Copy constructor.
- /// </summary>
- protected ModuleContext(ModuleContext context) {
- Contract.RequiresNotNull(context, "context");
- _module = context._module;
- _showCls = context._showCls;
- _compilerContext = context._compilerContext;
- }
-
internal protected virtual void ModuleReloading() {
_showCls = false;
}
diff --git a/IronScheme/Microsoft.Scripting/ModuleGlobalCache.cs b/IronScheme/Microsoft.Scripting/ModuleGlobalCache.cs
index a0c42def..1a2ad856 100644
--- a/IronScheme/Microsoft.Scripting/ModuleGlobalCache.cs
+++ b/IronScheme/Microsoft.Scripting/ModuleGlobalCache.cs
@@ -67,20 +67,5 @@ namespace Microsoft.Scripting {
_value = value;
}
}
-
- /// <summary>
- /// Event handler for when the value has changed. Language implementors should call this when
- /// the cached value is invalidated.
- /// </summary>
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers")]
- public void Changed(object sender, ModuleChangeEventArgs e) {
- Contract.RequiresNotNull(e, "e");
-
- switch (e.ChangeType) {
- case ModuleChangeType.Delete: Value = Uninitialized.Instance; break;
- case ModuleChangeType.Set: Value = e.Value; break;
- default: Debug.Assert(false, "unknown ModuleChangeType"); break;
- }
- }
}
}
diff --git a/IronScheme/Microsoft.Scripting/ModuleGlobalWrapper.cs b/IronScheme/Microsoft.Scripting/ModuleGlobalWrapper.cs
index 4317feff..06be03d4 100644
--- a/IronScheme/Microsoft.Scripting/ModuleGlobalWrapper.cs
+++ b/IronScheme/Microsoft.Scripting/ModuleGlobalWrapper.cs
@@ -104,23 +104,6 @@ namespace Microsoft.Scripting {
}
}
- public string Display {
- get {
- if (_value != Uninitialized.Instance) return GetStringDisplay(_value);
-
- if (_global.IsCaching && _global.HasValue) return GetStringDisplay(_global.Value);
- object value;
- if (_context.LanguageContext.TryLookupGlobal(_context, _name, out value))
- return GetStringDisplay(value);
-
- return GetStringDisplay(Uninitialized.Instance);
- }
- }
-
- private string GetStringDisplay(object val) {
- return val == null ? "(null)" : val.ToString();
- }
-
public override string ToString() {
return String.Format("ModuleGlobal: {0} Value: {1} ({2})",
_name,
diff --git a/IronScheme/Microsoft.Scripting/OptimizedModuleGenerator.cs b/IronScheme/Microsoft.Scripting/OptimizedModuleGenerator.cs
index ab3828dc..c4df1a05 100644
--- a/IronScheme/Microsoft.Scripting/OptimizedModuleGenerator.cs
+++ b/IronScheme/Microsoft.Scripting/OptimizedModuleGenerator.cs
@@ -526,17 +526,6 @@ namespace Microsoft.Scripting.Generation {
#endregion
- /// <summary>
- /// Creates a new assembly for generating a module, ensuring a unique filename like "filename.N.exe" for the generated assembly
- /// </summary>
- AssemblyGen CreateModuleAssembly(ScriptCode scriptCode)
- {
- var su = scriptCode.CompilerContext.SourceUnit;
- var ag = CreateModuleAssembly(su.Id);
- ag.SetSourceUnit(su);
- return ag;
- }
-
private TypeGen GenerateModuleGlobalsType(AssemblyGen ag, ScriptCode sc)
{
var n = sc.CodeBlock.Name;
diff --git a/IronScheme/Microsoft.Scripting/Script.cs b/IronScheme/Microsoft.Scripting/Script.cs
deleted file mode 100644
index f2602d7f..00000000
--- a/IronScheme/Microsoft.Scripting/Script.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-/* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation.
- *
- * This source code is subject to terms and conditions of the Microsoft Public License. A
- * copy of the license can be found in the License.html file at the root of this distribution. If
- * you cannot locate the Microsoft Public License, please send an email to
- * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
- * by the terms of the Microsoft Public License.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Microsoft.Scripting.Hosting;
-using System.IO;
-using Microsoft.Scripting.Utils;
-
-namespace Microsoft.Scripting {
-
- /// <summary>
- ///
- /// NOTE: Local hosting only.
- /// </summary>
- public static class Script {
-
- /// <exception cref="ArgumentNullException"><paramref name="languageId"/>, <paramref name="code"/></exception>
- /// <exception cref="ArgumentException">no language registered</exception>
- /// <exception cref="MissingTypeException"><paramref name="languageId"/></exception>
- /// <exception cref="InvalidImplementationException">The language provider's implementation failed to instantiate.</exception>
- public static void Execute(string languageId, string code) {
- Contract.RequiresNotNull(languageId, "languageId");
- Contract.RequiresNotNull(code, "code");
-
- ScriptDomainManager.CurrentManager.GetLanguageProvider(languageId).GetEngine().Execute(code);
- }
-
- /// <exception cref="ArgumentNullException"><paramref name="languageId"/>, <paramref name="code"/></exception>
- /// <exception cref="ArgumentException">no language registered</exception>
- /// <exception cref="MissingTypeException"><paramref name="languageId"/></exception>
- /// <exception cref="InvalidImplementationException">The language provider's implementation failed to instantiate.</exception>
- public static object Evaluate(string languageId, string expression) {
- Contract.RequiresNotNull(languageId, "languageId");
- Contract.RequiresNotNull(expression, "expression");
-
- return ScriptDomainManager.CurrentManager.GetLanguageProvider(languageId).GetEngine().Evaluate(expression);
- }
-
- // TODO: file IO exceptions
- /// <exception cref="ArgumentNullException"><paramref name="path"/></exception>
- /// <exception cref="ArgumentException">no language registered</exception>
- /// <exception cref="ArgumentException"><paramref name="path"/> is not a valid path.</exception>
- /// <exception cref="MissingTypeException"><paramref name="languageId"/></exception>
- /// <exception cref="InvalidImplementationException">The language provider's implementation failed to instantiate.</exception>
- public static void ExecuteFile(string path) {
- Contract.RequiresNotNull(path, "path");
- ScriptDomainManager.CurrentManager.GetLanguageProviderByFileExtension(Path.GetExtension(path)).GetEngine().ExecuteFile(path);
- }
-
- // TODO: file IO exceptions
- /// <exception cref="ArgumentNullException"><paramref name="path"/></exception>
- /// <exception cref="ArgumentException">no language registered</exception>
- /// <exception cref="MissingTypeException"><paramref name="languageId"/></exception>
- /// <exception cref="InvalidImplementationException">The language provider's implementation failed to instantiate.</exception>
- public static void ExecuteFileContent(string path) {
- Contract.RequiresNotNull(path, "path");
- ScriptDomainManager.CurrentManager.GetLanguageProviderByFileExtension(Path.GetExtension(path)).GetEngine().ExecuteFileContent(path);
- }
-
- public static void SetVariable(string name, object value) {
- ScriptDomainManager.CurrentManager.Host.DefaultModule.SetVariable(name, value);
- }
-
- public static object GetVariable(string name) {
- return ScriptDomainManager.CurrentManager.Host.DefaultModule.LookupVariable(name);
- }
-
- public static bool VariableExists(string name) {
- return ScriptDomainManager.CurrentManager.Host.DefaultModule.VariableExists(name);
- }
-
- public static bool RemoveVariable(string name) {
- return ScriptDomainManager.CurrentManager.Host.DefaultModule.RemoveVariable(name);
- }
-
- public static void ClearVariables() {
- ScriptDomainManager.CurrentManager.Host.DefaultModule.ClearVariables();
- }
-
- /// <exception cref="ArgumentNullException"><paramref name="languageId"/></exception>
- /// <exception cref="ArgumentException">no language registered</exception>
- /// <exception cref="MissingTypeException"><paramref name="languageId"/></exception>
- /// <exception cref="InvalidImplementationException">The language provider's implementation failed to instantiate.</exception>
- public static IScriptEngine GetEngine(string languageId) {
- Contract.RequiresNotNull(languageId, "languageId");
-
- return ScriptDomainManager.CurrentManager.GetLanguageProvider(languageId).GetEngine();
- }
- }
-}
diff --git a/appveyor.yml b/appveyor.yml
index 460b3446..d4b25b2f 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -32,6 +32,7 @@ build_script:
msbuild "IronScheme\IronSchemeCore.sln" /v:m /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /p:Configuration=Release
test_script:
- cmd: |
+ set QUIET=
cd IronScheme\IronScheme.Console\bin\Release\net20
rem these have to be in order
nunit-console IronScheme.Tests.dll /nologo /labels /run:IronScheme.Tests.Debug
@@ -40,7 +41,7 @@ test_script:
nunit-console IronScheme.Tests.dll /nologo /labels /run:IronScheme.Tests.SRFI
nunit-console IronScheme.Tests.dll /nologo /labels /run:IronScheme.Tests.Other
nunit-console IronScheme.Tests.dll /nologo /labels /run:IronScheme.Tests.Teardown
- set QUIET=
+
set TESTCORE=1
cd ..\netcoreapp2.1