[svn] r7303: vs-plugin/trunk/Nemerle.Compiler.Utils:
Nemerle.Compiler.Utils.csproj Nemerle.Completion2/Cod...
VladD2
svnadmin at nemerle.org
Sat Jan 20 14:13:41 CET 2007
Log:
Sync with compiler.
1. Move IntelliSense related code into Nemerle.VSIP\Nemerle.VsIntegration.Tests project.
2. Some refactoring.
Author: VladD2
Date: Sat Jan 20 14:13:39 2007
New Revision: 7303
Added:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompilerConcreteDefinitions/
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompilerConcreteDefinitions/Factories/
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompilerConcreteDefinitions/Factories/Factories.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompilerConcreteDefinitions/IntelliSenseModeMethodBuilder.n
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Refactoring.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-overrides.n
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj Sat Jan 20 14:13:39 2007
@@ -191,6 +191,10 @@
<ItemGroup>
<Compile Include="Nemerle.Completion2\Engine\Engine-overrides.n" />
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="Nemerle.Completion2\CompilerConcreteDefinitions\Factories\Factories.n" />
+ <Compile Include="Nemerle.Completion2\CompilerConcreteDefinitions\IntelliSenseModeMethodBuilder.n" />
+ </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Refactoring.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Refactoring.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.Refactoring.n Sat Jan 20 14:13:39 2007
@@ -253,7 +253,7 @@
and chainInsideType(typeBuilder)
{
def member = typeBuilder.GetMemberByLocation(fileIndex, line, column);
- [member.Location] + chainInsideMember(typeBuilder.GetMemberByLocation(fileIndex, line, column));
+ member.Location :: chainInsideMember(typeBuilder.GetMemberByLocation(fileIndex, line, column));
}
and chainInsideMember(member : IMember)
{
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompilerConcreteDefinitions/Factories/Factories.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompilerConcreteDefinitions/Factories/Factories.n Sat Jan 20 14:13:39 2007
@@ -0,0 +1,8 @@
+using Nemerle.Compiler;
+using Nemerle.DesignPatterns;
+
+namespace Nemerle.Completion2.Factories
+{
+ [AbstractFactory(Override(IntelliSenseModeMethodBuilder, MethodBuilder))]
+ public class IntelliSenseModeCompilerComponentsFactory : CompilerComponentsFactory { }
+}
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompilerConcreteDefinitions/IntelliSenseModeMethodBuilder.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CompilerConcreteDefinitions/IntelliSenseModeMethodBuilder.n Sat Jan 20 14:13:39 2007
@@ -0,0 +1,182 @@
+using System;
+using Nemerle.Assertions;
+using Nemerle.Compiler;
+using Nemerle.Utility;
+using Nemerle.Collections;
+using Nemerle.Compiler.Parsetree;
+using Nemerle.Compiler.Typedtree;
+using System.Diagnostics;
+
+using Typed = Nemerle.Compiler.Typedtree;
+using SR = System.Reflection;
+using SCG = System.Collections.Generic;
+
+namespace Nemerle.Completion2.Factories
+{
+ public class IntelliSenseModeMethodBuilder : MethodBuilder
+ {
+ protected new Manager : Engine { get { base.Manager :> Engine } }
+
+ public this (par : TypeBuilder, functionAst : ClassMember.Function)
+ {
+ this (par, functionAst, false);
+ }
+
+ public this (par : TypeBuilder, functionAst : ClassMember.Function, is_property : bool)
+ {
+ base (par, functionAst, is_property);
+ _bodyTokens = functionAst.Tokens;
+ }
+
+ public override EnsureCompiled() : void
+ {
+ unless (BodyLocation.FileIndex > 0 && this.Attributes %&& NemerleAttributes.Abstract)
+ _ = BodyTyped;
+ }
+
+ mutable _bodyMessages : SCG.List[CompilerMessage];
+ public override BodyMessages : SCG.List[CompilerMessage]
+ {
+ get
+ {
+ Trace.Assert(!(Attributes %&& NemerleAttributes.Abstract || BodyLocation.FileIndex <= 0));
+ when (_bodyMessages == null)
+ _bodyMessages = SCG.List();
+
+ _bodyMessages
+ }
+ }
+
+ public override ResetCodeCache () : void
+ {
+ when (_bodyMessages != null)
+ _bodyMessages.Clear();
+
+ _bodyTokens = null;
+ _bodyParsed = null;
+ _bodyTyped = null;
+ fun_header.body = null;
+ }
+
+ mutable _bodyTokens : Token.BracesGroup;
+
+ //mutable _indent : string = "";
+
+ /// The method body tokens.
+ public override BodyTokens : Token.BracesGroup
+ {
+ get
+ {
+ //Trace.WriteLine($"$_indent>>>> ##### BodyTokens ($Name)!");
+ Trace.Assert(!(Attributes %&& NemerleAttributes.Abstract || BodyLocation.FileIndex <= 0));
+ when (_bodyTokens == null)
+ {
+ //def indent = _indent; _indent += " ";
+ Manager.SetCompiletMessages (BodyMessages);
+ _bodyTokens = PreParseMethodBody (this);
+ //_indent = indent;
+ }
+
+ //Trace.WriteLine($"$_indent<<<< ##### BodyTokens ($Name)!");
+ _bodyTokens
+ }
+
+ set { ResetCodeCache(); _bodyTokens = value; }
+ }
+
+ mutable _bodyParsed : PExpr;
+
+ /// The method body parsed expressions.
+ public override BodyParsed : PExpr
+ {
+ get
+ {
+ //Trace.WriteLine($"$_indent>>>> ##### BodyParsed ($Name)!");
+ Trace.Assert(!(Attributes %&& NemerleAttributes.Abstract || BodyLocation.FileIndex <= 0));
+ when (_bodyParsed == null)
+ {
+ //def indent = _indent; _indent += " ";
+ Manager.SetCompiletMessages (BodyMessages);
+ _bodyParsed = MainParser.ParseFunctionBody (Env, Ast.header, BodyTokens);
+ fun_header.body = FunBody.Parsed (_bodyParsed);
+ //_indent = indent;
+ }
+
+ //Trace.WriteLine($"$_indent<<<< ##### BodyParsed ($Name)!");
+ _bodyParsed
+ }
+ }
+
+ public override IsBodyCompilable : bool
+ {
+ get
+ {
+ def res = HasAbstractBody || BodyLocation.IsGenerated
+ || BodyLocation.FileIndex <= 0
+ || Attributes %&& NemerleAttributes.SpecialName;
+ !res
+ }
+ }
+
+ mutable _bodyTyped : TExpr;
+
+ /// The method body parsed expressions.
+ public override BodyTyped : TExpr
+ {
+ get
+ {
+ Manager.CheckSolver();
+ //Trace.WriteLine($"$_indent>>>> ##### BodyTyped ($Name)!");
+ Trace.Assert(!(Attributes %&& NemerleAttributes.Abstract || BodyLocation.FileIndex <= 0));
+ when (_bodyTyped == null)
+ {
+ //def indent = _indent; _indent += " ";
+ Manager.SetCompiletMessages (BodyMessages);
+ try
+ {
+ _ = BodyParsed; // Use side affect
+ RunBodyTyper();
+ _bodyTyped = (fun_header.body :> FunBody.Typed).expr;
+ }
+ finally { Manager.SetCompiletMessages (null); }
+ //_indent = indent;
+ }
+
+ //Trace.WriteLine($"$_indent<<<< ##### BodyTyped ($Name)!");
+ _bodyTyped
+ }
+ }
+
+ PreParseMethodBody (method : MethodBuilder) : Token.BracesGroup
+ {
+ def reportError(e, msg)
+ {
+ Trace.WriteLine($"$msg method body of:");
+ Trace.WriteLine($"\t$method");
+ Trace.WriteLine($"\tfailed.");
+ Trace.WriteLine($"\tError: $(e.Message)");
+ }
+
+ def loc = method.BodyLocation;
+ def engine = Manager;
+ def bodyCode =
+ if (loc == Location.Default)
+ "{}"
+ else try { engine.ProjectSources.GetSource(loc.File).GetRegion(loc); }
+ catch { e => reportError(e, "Try get"); "{}" }; // return empty body!
+
+ try
+ {
+ def lexer = LexerString(engine, bodyCode, loc);
+ def preparser = PreParser(lexer, method.Env);
+
+ preparser.PreParse()
+ }
+ catch
+ { e =>
+ reportError(e, "Try to compile");
+ Token.BracesGroup(null)
+ } // return empty body!
+ }
+ } // class
+} // namespace
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-overrides.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-overrides.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Engine/Engine-overrides.n Sat Jan 20 14:13:39 2007
@@ -14,40 +14,15 @@
{
public partial class Engine
{
- protected override SetCompiletMessages (messages : SCG.List[CompilerMessage]) : void
+ protected override CreateComponentsFactory () : CompilerComponentsFactory
{
- _currentMessages = messages;
+ // Provide Abstract Factory to MethodBuilder and other compiler classes.
+ Factories.IntelliSenseModeCompilerComponentsFactory ()
}
- protected override PreParseMethodBody (method : MethodBuilder) : Token.BracesGroup
- {
- def reportError(e, msg)
+ internal SetCompiletMessages (messages : SCG.List[CompilerMessage]) : void
{
- Trace.WriteLine($"$msg method body of:");
- Trace.WriteLine($"\t$method");
- Trace.WriteLine($"\tfailed.");
- Trace.WriteLine($"\tError: $(e.Message)");
- }
-
- def loc = method.BodyLocation;
- def bodyCode =
- if (loc == Location.Default)
- "{}"
- else try { ProjectSources.GetSource(loc.File).GetRegion(loc); }
- catch { e => reportError(e, "Try get"); "{}" }; // return empty body!
-
- try
- {
- def lexer = LexerString(this, bodyCode, loc);
- def preparser = PreParser(lexer, method.Env);
-
- preparser.PreParse()
- }
- catch
- { e =>
- reportError(e, "Try to compile");
- Token.BracesGroup(null)
- } // return empty body!
+ _currentMessages = messages;
}
/// Return true if 'method' is extension method.
More information about the svn
mailing list