[svn] r6779: nemerle/trunk: . Build-1-phase.cmd Build.cmd
BuildAndReg-Release.cmd BuildAndReg.cmd NCC.npro...
VladD2
svnadmin at nemerle.org
Tue Oct 24 14:05:42 CEST 2006
Log:
Relocation code auto generation.
Author: VladD2
Date: Tue Oct 24 14:05:01 2006
New Revision: 6779
Added:
nemerle/trunk/Build-1-phase.cmd
nemerle/trunk/Build.cmd
nemerle/trunk/BuildAndReg-Release.cmd
nemerle/trunk/BuildAndReg.cmd
nemerle/trunk/Reg.cmd
Modified:
nemerle/trunk/ (props changed)
nemerle/trunk/NCC.nproj
nemerle/trunk/Nemerle.Compiler.nproj
nemerle/trunk/Nemerle.Macros.nproj
nemerle/trunk/Nemerle.nproj
nemerle/trunk/boot/ (props changed)
nemerle/trunk/boot/Nemerle.Compiler.dll
nemerle/trunk/boot/Nemerle.MSBuild.Tasks.dll
nemerle/trunk/boot/Nemerle.Macros.dll
nemerle/trunk/boot/Nemerle.dll
nemerle/trunk/boot/ncc.exe
nemerle/trunk/lib/narray.n
nemerle/trunk/lib/oldapi.n
nemerle/trunk/lib/stack.n
nemerle/trunk/macros/compiler.n
nemerle/trunk/ncc/completion/CodeCompletionEngine.n
nemerle/trunk/ncc/external/InternalTypes.n
nemerle/trunk/ncc/external/LibrariesLoader.n
nemerle/trunk/ncc/generation/HierarchyEmitter.n
nemerle/trunk/ncc/hierarchy/DelegateClassGen.n
nemerle/trunk/ncc/hierarchy/NamespaceTree.n
nemerle/trunk/ncc/hierarchy/TypeBuilder.n
nemerle/trunk/ncc/parsing/AST.n
nemerle/trunk/ncc/parsing/ParseTree.n
nemerle/trunk/ncc/parsing/PreParser.n
nemerle/trunk/ncc/passes.n
nemerle/trunk/ncc/typing/TypedTree.n
nemerle/trunk/ncc/typing/Typer-CallTyper.n
Added: nemerle/trunk/Build-1-phase.cmd
==============================================================================
--- (empty file)
+++ nemerle/trunk/Build-1-phase.cmd Tue Oct 24 14:05:01 2006
@@ -0,0 +1,5 @@
+ at echo off
+
+set SkipPhase2=true
+
+call Build.cmd
\ No newline at end of file
Added: nemerle/trunk/Build.cmd
==============================================================================
--- (empty file)
+++ nemerle/trunk/Build.cmd Tue Oct 24 14:05:01 2006
@@ -0,0 +1,64 @@
+ at echo off
+
+set MSBuild=%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe
+ at echo MSBuild=%MSBuild%
+
+IF "%Type%"=="" set Type=Debug
+
+ at echo ### Backup initials boot files #########################
+IF EXIST boot\old\ RMDIR /S /Q boot\old
+
+MKDIR boot\old\
+
+IF errorlevel 1 goto Error
+copy /Y boot\*.dll boot\old
+IF errorlevel 1 goto Error
+copy /Y boot\*.exe boot\old
+IF errorlevel 1 goto Error
+copy /Y boot\*.pdb boot\old
+
+ at echo !!! Backup success !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ at echo ### Phase 1 ############################################
+%MSBuild% Nemerle.sln /p:Configuration=%Type%
+
+IF errorlevel 1 goto Error
+ at echo !!! Phase 1 success !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ at echo ### Phase 2 ############################################
+ at echo ### Copy new binaries to boot
+copy /Y bin\%Type%\*.dll boot
+IF errorlevel 1 goto Error
+copy /Y bin\%Type%\*.exe boot
+IF errorlevel 1 goto Error
+copy /Y bin\%Type%\*.pdb boot
+ at echo !!! Copy success!
+
+ at echo ### Build solution (phase 2)
+%MSBuild% Nemerle.sln /p:Configuration=%Type%
+IF errorlevel 1 goto Error
+ at echo !!! Build solution (phase 2) success!
+
+copy /Y bin\%Type%\*.dll boot
+IF errorlevel 1 goto Error
+copy /Y bin\%Type%\*.exe boot
+IF errorlevel 1 goto Error
+copy /Y bin\%Type%\*.pdb boot
+
+ at echo !!! Phase 2 success !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+goto Success
+
+ at echo Phase 1 failed!
+goto Error
+
+:Error
+ at echo !!! Build FAILED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+copy /Y boot\old\*.dll boot
+copy /Y boot\old\*.exe boot
+copy /Y boot\old\*.pdb boot
+pause
+exit /b 1
+
+:Success
+
+IF NOT "%NoPause%"=="true" pause
\ No newline at end of file
Added: nemerle/trunk/BuildAndReg-Release.cmd
==============================================================================
--- (empty file)
+++ nemerle/trunk/BuildAndReg-Release.cmd Tue Oct 24 14:05:01 2006
@@ -0,0 +1,6 @@
+ at echo off
+
+set Type=Release
+
+call BuildAndReg.cmd
+
Added: nemerle/trunk/BuildAndReg.cmd
==============================================================================
--- (empty file)
+++ nemerle/trunk/BuildAndReg.cmd Tue Oct 24 14:05:01 2006
@@ -0,0 +1,13 @@
+ at echo off
+
+set NoPause=true
+
+IF "%Type%"=="" set Type=Debug
+
+call Build.cmd
+
+ at echo ERRORLEVEL
+
+IF NOT ERRORLEVEL 1 call Reg.cmd
+
+
Modified: nemerle/trunk/NCC.nproj
==============================================================================
--- nemerle/trunk/NCC.nproj (original)
+++ nemerle/trunk/NCC.nproj Tue Oct 24 14:05:01 2006
@@ -17,7 +17,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<OutputPath>bin\Debug\</OutputPath>
- <DocumentationFile>bin\Debug\NCC.XML</DocumentationFile>
+ <!-- <DocumentationFile>bin\Debug\NCC.XML</DocumentationFile> -->
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
Modified: nemerle/trunk/Nemerle.Compiler.nproj
==============================================================================
--- nemerle/trunk/Nemerle.Compiler.nproj (original)
+++ nemerle/trunk/Nemerle.Compiler.nproj Tue Oct 24 14:05:01 2006
@@ -18,7 +18,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
- <DocumentationFile>bin\Debug\Nemerle.Compiler.XML</DocumentationFile>
+ <!-- <DocumentationFile>bin\Debug\Nemerle.Compiler.XML</DocumentationFile> -->
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
Modified: nemerle/trunk/Nemerle.Macros.nproj
==============================================================================
--- nemerle/trunk/Nemerle.Macros.nproj (original)
+++ nemerle/trunk/Nemerle.Macros.nproj Tue Oct 24 14:05:01 2006
@@ -18,7 +18,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
- <DocumentationFile>bin\Debug\Nemerle.Macros.XML</DocumentationFile>
+ <!-- <DocumentationFile>bin\Debug\Nemerle.Macros.XML</DocumentationFile> -->
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
Modified: nemerle/trunk/Nemerle.nproj
==============================================================================
--- nemerle/trunk/Nemerle.nproj (original)
+++ nemerle/trunk/Nemerle.nproj Tue Oct 24 14:05:01 2006
@@ -20,7 +20,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
- <DocumentationFile>bin\Debug\Nemerle.XML</DocumentationFile>
+ <!-- <DocumentationFile>bin\Debug\Nemerle.XML</DocumentationFile> -->
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<OutputPath>bin\Release\</OutputPath>
Added: nemerle/trunk/Reg.cmd
==============================================================================
--- (empty file)
+++ nemerle/trunk/Reg.cmd Tue Oct 24 14:05:01 2006
@@ -0,0 +1,58 @@
+ at echo off
+
+IF "%Type%"=="" set Type=Debug
+
+set NemerleBin=%~dp0\bin\%Type%
+set GacUtil="%VS80COMNTOOLS%..\..\SDK\v2.0\Bin\gacutil.exe"
+set NemerleInstall=%ProgramFiles%\Nemerle
+set NGen="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\ngen.exe"
+
+ at echo NemerleInstall=%NemerleInstall%
+ at echo VS80COMNTOOLS=%VS80COMNTOOLS%
+ at echo GacUtil=%GacUtil%
+ at echo NGen=%NGen%
+ at echo NemerleBin=%NemerleBin%
+
+cd /D "%NemerleInstall%"
+
+%GacUtil% /u Nemerle
+%GacUtil% /u Nemerle.Compiler
+%GacUtil% /u Nemerle.MSBuild.Tasks
+%GacUtil% /u Nemerle.Macros
+
+%NGen% uninstall "%NemerleInstall%\Nemerle.dll"
+%NGen% uninstall "%NemerleInstall%\Nemerle.Compiler.dll"
+%NGen% uninstall "%NemerleInstall%\Nemerle.Macros.dll"
+%NGen% uninstall "%NemerleInstall%\Nemerle.MSBuild.Tasks.dll"
+%NGen% uninstall "%NemerleInstall%\ncc.exe"
+
+ at echo errorlevel=%errorlevel%
+set errorlevel=0
+
+copy /Y "%NemerleBin%\*.dll" "%NemerleInstall%\*.dll"
+
+if not errorlevel 0 (
+ at echo errorlevel=%errorlevel%
+ at echo !!! ERORR: copy files !!!
+pause
+exit /b 1
+)
+
+copy /Y "%NemerleBin%\*.exe" "%NemerleInstall%\*.exe"
+
+if not errorlevel 0 (
+ at echo !!! ERORR: copy files !!!
+pause
+exit /b 1
+)
+
+copy /Y "%NemerleBin%\*.pdb" "%NemerleInstall%\*.pdb"
+copy /Y "%NemerleBin%\*.xml" "%NemerleInstall%\*.xml"
+
+%NGen% install "%NemerleInstall%\Nemerle.dll"
+%NGen% install "%NemerleInstall%\Nemerle.Compiler.dll"
+%NGen% install "%NemerleInstall%\Nemerle.Macros.dll"
+%NGen% install "%NemerleInstall%\Nemerle.MSBuild.Tasks.dll"
+%NGen% install "%NemerleInstall%\ncc.exe"
+
+pause
Modified: nemerle/trunk/boot/Nemerle.Compiler.dll
==============================================================================
Binary files. No diff available.
Modified: nemerle/trunk/boot/Nemerle.MSBuild.Tasks.dll
==============================================================================
Binary files. No diff available.
Modified: nemerle/trunk/boot/Nemerle.Macros.dll
==============================================================================
Binary files. No diff available.
Modified: nemerle/trunk/boot/Nemerle.dll
==============================================================================
Binary files. No diff available.
Modified: nemerle/trunk/boot/ncc.exe
==============================================================================
Binary files. No diff available.
Modified: nemerle/trunk/lib/narray.n
==============================================================================
--- nemerle/trunk/lib/narray.n (original)
+++ nemerle/trunk/lib/narray.n Tue Oct 24 14:05:01 2006
@@ -194,6 +194,21 @@
{
MapToArrayFiltered(source, isMatch, f)
}
+
+ public Map[From, To] (this source : SCG.IEnumerable [From], f : From -> To) : list [To]
+ {
+ match (source)
+ {
+ | null => [];
+ | _ =>
+ mutable dest = [];
+
+ foreach (elem in source)
+ dest ::= f (elem);
+
+ dest
+ }
+ }
}
/**
@@ -531,7 +546,7 @@
/**
* Filter elements to list.
*/
- public Filter [T] (ary : array [T], predicate : T -> bool) : list [T]
+ public Filter [T] (this ary : array [T], predicate : T -> bool) : list [T]
{
$[ x | x in ary, predicate (x) ]
}
Modified: nemerle/trunk/lib/oldapi.n
==============================================================================
--- nemerle/trunk/lib/oldapi.n (original)
+++ nemerle/trunk/lib/oldapi.n Tue Oct 24 14:05:01 2006
@@ -52,6 +52,16 @@
public RemoveLast () : void {
RemoveAt (Count - 1)
}
+
+ public Map[To] (f : 'a -> To) : Vector [To]
+ {
+ def result = Vector (Count);
+
+ for (mutable i = 0; i < Count; ++i)
+ result.Add(f (this [i]));
+
+ result
+ }
}
/** OBSOLETE
Modified: nemerle/trunk/lib/stack.n
==============================================================================
--- nemerle/trunk/lib/stack.n (original)
+++ nemerle/trunk/lib/stack.n Tue Oct 24 14:05:01 2006
@@ -33,11 +33,19 @@
*/
public class Stack ['a] : System.Collections.Generic.Stack ['a]
{
+ public RemoveLast () : void {
+ _ = Pop ()
+ }
+
+ public Add (x : 'a) : void {
+ Push (x)
+ }
+
/* -- PUBLIC CONSTRUCTORS ----------------------------------------------- */
public this () { base () }
- public this (size : int) { base (size) }
+ public this (capacity : int) { base (capacity) }
public this (enu : System.Collections.Generic.IEnumerable ['a]) { base (enu) }
@@ -60,7 +68,6 @@
get { Count }
}
-
/**
* An alias for `Count'.
*/
Modified: nemerle/trunk/macros/compiler.n
==============================================================================
--- nemerle/trunk/macros/compiler.n (original)
+++ nemerle/trunk/macros/compiler.n Tue Oct 24 14:05:01 2006
@@ -29,6 +29,7 @@
/* Macros used only inside the compiler. */
using Nemerle.Compiler;
+using System.Diagnostics;
namespace Nemerle.Compiler.Util
{
@@ -67,6 +68,12 @@
namespace Nemerle.Compiler
{
+ using Nemerle.Collections;
+ using Nemerle.Utility;
+ using SCG = System.Collections.Generic;
+ using Attr = NemerleAttributes;
+ using Member = Parsetree.ClassMember;
+
[Nemerle.MacroUsage (Nemerle.MacroPhase.BeforeInheritance,
Nemerle.MacroTargets.Class)]
macro ManagerAccess (tb : TypeBuilder, params options : list [PExpr])
@@ -102,6 +109,311 @@
}
]>);
}
+
+ module Helpers
+ {
+ public IsRelocatedType (tb : TypeBuilder) : bool
+ {
+ !(tb.Attributes %&& (Attr.Static | Attr.Struct) // | Attr.Sealed
+ || tb.IsValueType || tb.IsInterface || tb.IsDelegate || tb.IsAlias
+ )
+ }
+ }
+
+ /// Add Relocate() method to class and all class referenced dy it fields.
+ [Nemerle.MacroUsage (Nemerle.MacroPhase.BeforeInheritance,
+ Nemerle.MacroTargets.Class)]
+ macro SupportRelocation (typeBuilder : TypeBuilder)
+ {
+ //def wl(x : object) { System.Console.WriteLine(x); }
+ //wl("vvvvvvv SupportRelocation (BeforeInheritance).");
+
+ def env = typeBuilder.GlobalEnv;
+ def nameTree = env.NameTree;
+ def nsRoot = nameTree.NamespaceTree;
+ def typeBuilders = nsRoot.GetTypeBuilders();
+
+ foreach (tb when Helpers.IsRelocatedType (tb) && !tb.IsVariantOption in typeBuilders)
+ {
+ ////wl($"$(tb.Name) tb.IsDelegate= $(tb.IsDelegate)");
+ System.Diagnostics.Trace.Assert(tb.Name != "InitDelegate");
+ tb.AddImplementedInterface (<[ Nemerle.Compiler.ISupportRelocation ]>);
+ }
+ //wl("^^^^^^^ SupportRelocation (BeforeInheritance).");
+ }
+
+ /// Add Relocate() method to class and all class referenced dy it fields.
+ [Nemerle.MacroUsage (Nemerle.MacroPhase.BeforeTypedMembers,
+ Nemerle.MacroTargets.Class)]
+ macro SupportRelocation (typeBuilder : TypeBuilder)
+ {
+ //def wl(x : object) { System.Console.WriteLine(x); }
+ //wl("vvvvvvv SupportRelocation (BeforeTypedMembers).");
+
+ /////////////////////////////////////////////////////////////////////////
+ // 0. Init variables.
+ //wl("vvvvvvv 0. Init variables for SupportRelocation macro.");
+
+ def error (loc, msg) { when (Nemerle.Macros.ImplicitCTX ().InErrorMode) Message.Error (loc, msg); }
+ def errorLocationFieldCanNotBeImmutable (field)
+ {
+ error (field.Location, $"Location field $(field.Name) can't be immutable!");
+ }
+ def env = typeBuilder.GlobalEnv;
+ def manager = env.Manager;
+ def nameTree = env.NameTree;
+ def nsRoot = nameTree.NamespaceTree;
+
+ /// Type info variables:
+ def tyVarTyInfo = manager.Lookup ("Nemerle.Compiler.TyVar") :> TypeBuilder;
+ def locationTyInfo = manager.Lookup ("Nemerle.Compiler.Location");
+ def iMacroTyInfo = manager.Lookup ("Nemerle.Compiler.IMacro");
+ def stackTyInfo = manager.Lookup ("Nemerle.Collections.Vector");
+ def nodeTyInfo = manager.Lookup ("Nemerle.Compiler.NamespaceTree.Node");
+ def managerClassTyInfo = manager.Lookup ("Nemerle.Compiler.ManagerClass");
+ def globalEnvTyInfo = manager.Lookup ("Nemerle.Compiler.GlobalEnv");
+ def optinTyInfo = manager.InternalType.Nemerle_option_tc;
+ def listTyInfo = manager.InternalType.Nemerle_list_tc;
+ /// The ignore list of some types.
+ def ignoreTypeList = manager.Lookup ("Nemerle.Compiler.TypeBuilder")
+ :: manager.Lookup ("Nemerle.Compiler.TypeInfo")
+ :: tyVarTyInfo :: nodeTyInfo
+ :: managerClassTyInfo :: globalEnvTyInfo
+ :: manager.Lookup ("Nemerle.Compiler.TypesManager")
+ :: tyVarTyInfo.GetAllSubTypes().Map(_ : TypeInfo);
+
+ //wl("ignoreTypeList:");
+ //wl(ignoreTypeList);
+
+ def isTypedInstanceField (field)
+ {
+ !(field.ty is <[ _ ]> || field.modifiers.mods %&& Attr.Static)
+ }
+
+ def isMutable (field) { field.modifiers.mods %&& Attr.Mutable }
+
+ /// True if we need visite property of this type
+ /// (ignore: Alias, Delegate, ValueType and Static types).
+ def isStepInto (tb : TypeBuilder) : bool
+ {
+ !(tb.Attributes %&& (Attr.Static | Attr.Struct)
+ || tb.IsValueType || tb.IsDelegate || tb.IsAlias
+ )
+ }
+
+ def equalsAny(ty, types) { types.Exists(_.Equals(ty)) }
+
+ //wl("^^^^^^^ 0. Init variables for SupportRelocation macro.");
+ // End 0.
+ /////////////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////////////
+ // 1. Make relocation code.
+ //wl("vvvvvvv 1. Make relocation code.");
+
+ // Key - type
+ // Value - code of relocation and recusion walk into fields.
+ def relocationCode = Hashtable() : Hashtable[TypeBuilder, list [Parsetree.PExpr]];
+
+ // For each class defined in project...
+ foreach (tb when Helpers.IsRelocatedType (tb) in nsRoot.GetTypeBuilders())
+ {
+ def fields = tb.GetParsedMembers (true);
+ // The constructing expression.
+ mutable exprs = [] : list[Parsetree.PExpr];
+
+ // For each instance field which type explicit assign...
+ foreach (field is Member.Field when isTypedInstanceField (field) in fields)
+ {
+ // Manually calculate type of field.
+ def ty = tb.MonoBindType (field.ty);
+ // Make field name
+ def n = Macros.UseSiteSymbol (field.Name);
+
+ //def s = field.Name;
+
+ match (ty)
+ {
+ // Ignore property of some types. It prevent unproductive recursion.
+ | Class (t is TypeBuilder, []) when equalsAny(t, ignoreTypeList)
+ && t.DeclaringType : object != tb
+ => ()
+
+ // Skip IMacro members.
+ | Class (t, []) when t.Equals(iMacroTyInfo)
+ | Class (_, [MType.Class(t, [])]) when t.Equals(iMacroTyInfo) => ()
+
+ // Process 'collection[Location]' fields (make relocation code for it).
+ | Class (tc, [MType.Class(ti, [])]) when ti.Equals(locationTyInfo) =>
+ if (isMutable (field))
+ if (tc.Equals(listTyInfo) || tc.Equals(stackTyInfo))
+ exprs ::= <[
+ def x = this.$(n : name);
+ when (x != null)
+ this.$(n : name) = x.Map(Completion.Relocate(_, info)) ]>;
+ else
+ error (field.Location, $"The 'unknown type'[Location] ($tc[$ti]) not suported!");
+ else
+ errorLocationFieldCanNotBeImmutable (field);
+
+ // Process 'Location' fields (make relocation code for it).
+ | Class (tc, []) when tc.Equals(locationTyInfo) =>
+ if (isMutable (field))
+ exprs ::= <[ this.$(n : name) = Completion.Relocate(this.$(n : name), info); ]>;
+ else
+ errorLocationFieldCanNotBeImmutable (field);
+
+ // Below reference fields processed...
+
+ // 1. Is optional field of reference type defined in this project.
+ | Class (tc, [MType.Class(t is TypeBuilder, _)]) when tc.Equals(optinTyInfo) =>
+ exprs ::= if (t.IsInterface)
+ <[
+ match (this.$(n : name))
+ {
+ | Some(x is ISupportRelocation) =>
+ //System.Diagnostics.Trace.WriteLine(ident + $(s : string));
+ x.RelocateImpl (info/*, ident*/);
+ | _ => ()
+ }
+ ]>
+ else
+ <[
+ match (this.$(n : name))
+ {
+ | Some(x) =>
+ //System.Diagnostics.Trace.WriteLine(ident + $(s : string));
+ x.RelocateImpl (info/*, ident*/);
+ | _ => ()
+ }
+ ]>;
+
+ // 2. Is collection of reference type defined in this project.
+ | Class (_, [MType.Class(t is TypeBuilder, _)]) when isStepInto (t) =>
+ exprs ::= if (t.IsInterface)
+ <[
+ def x = this.$(n : name);
+ when (x != null)
+ {
+ //System.Diagnostics.Trace.WriteLine(ident + $(s : string));
+ foreach (elem :> ISupportRelocation in x)
+ elem.RelocateImpl (info/*, ident*/);
+ }
+ ]>
+ else
+ <[
+ def x = this.$(n : name);
+ when (x != null)
+ foreach (elem in x)
+ elem.RelocateImpl (info/*, ident*/);
+ ]>;
+
+ // 3. Is field of reference type defined in this project (represent as TypeBuilder).
+ | Class (t is TypeBuilder, _) when isStepInto (t) =>
+ if (ty.IsInterface)
+ exprs ::= <[
+ def x = this.$(n : name);
+ when (x != null)
+ {
+ //System.Diagnostics.Trace.WriteLine(ident + $(s : string));
+ (x :> ISupportRelocation).RelocateImpl (info/*, ident*/);
+ }
+ ]>;
+ else
+ exprs ::= <[
+ def x = this.$(n : name);
+ when (x != null)
+ {
+ //System.Diagnostics.Trace.WriteLine(ident + $(s : string));
+ x.RelocateImpl (info/*, ident*/);
+ }
+ ]>;
+
+ // 3. Process other fields.
+ | Class (t, tArgs) =>
+ // Check for Location type...
+ when (t.Equals(locationTyInfo) || tArgs.Exists (_.Equals(locationTyInfo)))
+ error (field.Location, $"The $t$tArgs not handled in relocation algorithm!");
+
+ | _ => ()
+ }
+ }
+
+ relocationCode.Add (tb, exprs);
+ }
+
+ //wl("^^^^^^^ 1. Make relocation code.");
+ // End 1.
+ /////////////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////////////
+ // 2. Generate "RelocateImpl (info : RelocationInfo) : void" methods.
+ //wl("vvvvvvv 2. Generate RelocateImpl (info : RelocationInfo) : void methods.");
+
+ foreach ((tb, code) in relocationCode.KeyValuePairs)
+ {
+ match (tb.BaseType)
+ {
+ | _ is TypeBuilder =>
+ unless (code.IsEmpty)
+ {
+ //tb.Define (<[ decl: public override RelocateImpl (_info : RelocationInfo) : void {}]>);
+ tb.Define (
+ <[ decl:
+ public override RelocateImpl (info : RelocationInfo/*, ident : string*/) : void
+ {
+ //info.NodeCount++;
+ unless (info.VisitedObjects.ContainsKey (this))
+ {
+ //System.Diagnostics.Trace.WriteLine(ident + "obj:" + this.GetType().FullName + " (" + $(tb.FullName : string) + ")");
+ //info.VisitCount++;
+ //System.Diagnostics.Trace.WriteLine(ident + "---> base");
+ base.RelocateImpl (info/*, ident*/);
+ //System.Diagnostics.Trace.WriteLine(ident + "<--- base");
+ //def ident = ident + " ";
+ info.VisitedObjects[this] = 0;
+ { ..$code }
+ //ignore(ident);
+ }
+ }
+ ]>);
+ }
+
+ | _ =>
+ if (code.IsEmpty)
+ {
+ //tb.Define (<[ decl: public virtual RelocateImpl (_info : RelocationInfo, _ident : string) : void { } ]>);
+ tb.Define (<[ decl: public virtual RelocateImpl (_info : RelocationInfo) : void { } ]>);
+ }
+ else
+ {
+ //tb.Define (<[ decl: public virtual RelocateImpl (_info : RelocationInfo) : void {}]>);
+
+ tb.Define (
+ <[ decl:
+ public virtual RelocateImpl (info : RelocationInfo/*, ident : string*/) : void
+ {
+ //info.NodeCount++;
+ unless (info.VisitedObjects.ContainsKey (this))
+ {
+ //System.Diagnostics.Trace.WriteLine(ident + "obj:" + this.GetType().FullName + " (" + $(tb.FullName : string) + ")");
+ //def ident = ident + " ";
+ //info.VisitCount++;
+ info.VisitedObjects[this] = 0;
+ { ..$code }
+ //ignore(ident);
+ }
+ }
+ ]>);
+ }
+ }
+ }
+
+ //wl("^^^^^^^ 2. Generate RelocateImpl (info : RelocationInfo) : void methods.");
+ // End 2.
+ /////////////////////////////////////////////////////////////////////////
+ //wl("^^^^^^^ SupportRelocation (BeforeTypedMembers).");
+ }
}
namespace Nemerle.Compiler.SolverMacros
Modified: nemerle/trunk/ncc/completion/CodeCompletionEngine.n
==============================================================================
--- nemerle/trunk/ncc/completion/CodeCompletionEngine.n (original)
+++ nemerle/trunk/ncc/completion/CodeCompletionEngine.n Tue Oct 24 14:05:01 2006
@@ -48,35 +48,79 @@
namespace Nemerle.Compiler
{
- [Record]
- public struct Relocation
+ public interface ISupportRelocation
{
+ RelocateImpl (info : RelocationInfo/*, ident : string*/) : void;
+ }
+
+ //[Record(Exclude = [VisitedObjects])]
+ public class RelocationInfo
+ {
+ public this(fileIndex : int, line : int, ch : int, lineOffset : int, charOffset : int)
+ {
+ this.VisitedObjects = Hashtable();
+ this.CharOffset = charOffset;
+ this.LineOffset = lineOffset;
+ this.Char = ch;
+ this.Line = line;
+ this.FileIndex = fileIndex;
+ }
+
+ public VisitedObjects : Hashtable[object, byte];
+ public FileIndex : int;
public Line : int;
- public Column : int;
+ public Char : int;
public LineOffset : int;
- public ColumnOffset : int;
+ public CharOffset : int;
+
+ //public mutable VisitCount : int;
+ //public mutable NodeCount : int;
override public ToString() : string
{
- $"Line=$Line Column=$Column LineOffset=$LineOffset ColumnOffset=$ColumnOffset"
+ $"FileIndex=$FileIndex Line=$Line Char=$(this.Char) LineOffset=$LineOffset CharOffset=$CharOffset"
}
}
public module Completion
{
/// Shift Location.
- public Relocate(loc : Location, fileIndex : int, line : int, ch : int, lineOffset : int, chOffset : int) : Location
+ public Relocate (loc : Location, info : RelocationInfo) : Location
+ {
+ def relocatePoint (oldLn, oldCh, info, ch)
+ {
+ if (oldLn > info.Line)
+ (oldLn + info.LineOffset, oldCh)
+ else if (oldLn == info.Line && oldCh >= ch)
+ (oldLn + info.LineOffset, oldCh + info.CharOffset)
+ else
+ (oldLn, oldCh)
+ }
+
+ if (loc.FileIndex == info.FileIndex)
+ {
+ def (newLn, newCh) = relocatePoint(loc.Line, loc.Column, info, info.Char + 1);
+ def (newEndLn, newEndCh) = relocatePoint(loc.EndLine, loc.EndColumn, info, info.Char);
+
+ Location (loc.FileIndex, newLn, newCh, newEndLn, newEndCh);
+ }
+ else
+ loc
+ }
+
+ /// Shift Location.
+ public Relocate (loc : Location, fileIndex : int, line : int, ch : int, lineOffset : int, chOffset : int) : Location
{
if (loc.FileIndex == fileIndex)
- Relocate(loc, line, ch, lineOffset, chOffset)
+ Relocate (loc, line, ch, lineOffset, chOffset)
else
loc
}
/// Shift Location.
- public Relocate(loc : Location, line : int, ch : int, lineOffset : int, chOffset : int) : Location
+ public Relocate (loc : Location, line : int, ch : int, lineOffset : int, chOffset : int) : Location
{
- def relocatePoint(oldLn, oldCh, ch)
+ def relocatePoint (oldLn, oldCh, ch)
{
if (oldLn > line)
(oldLn + lineOffset, oldCh)
@@ -89,7 +133,7 @@
def (newLn, newCh) = relocatePoint(loc.Line, loc.Column, ch + 1);
def (newEndLn, newEndCh) = relocatePoint(loc.EndLine, loc.EndColumn, ch);
- Location(loc.FileIndex, newLn, newCh, newEndLn, newEndCh);
+ Location (loc.FileIndex, newLn, newCh, newEndLn, newEndCh);
}
CmpOptins = System.StringComparison.InvariantCultureIgnoreCase;
Modified: nemerle/trunk/ncc/external/InternalTypes.n
==============================================================================
--- nemerle/trunk/ncc/external/InternalTypes.n (original)
+++ nemerle/trunk/ncc/external/InternalTypes.n Tue Oct 24 14:05:01 2006
@@ -530,21 +530,14 @@
array_types [dims]
}
-
lookup (type_name : string) : TypeInfo
{
- match (Manager.NameTree.LookupExactType (type_name)) {
- | Some (t) => t
- | None => Util.ice ("internal type " + type_name + " not found")
- }
+ Manager.Lookup (type_name)
}
lookup (type_name : string, args_count : int) : TypeInfo
{
- match (Manager.NameTree.LookupExactType (type_name, args_count)) {
- | Some (t) => t
- | None => Util.ice ("internal type " + type_name + " not found")
- }
+ Manager.Lookup (type_name, args_count)
}
internal InitSystemTypes () : void
Modified: nemerle/trunk/ncc/external/LibrariesLoader.n
==============================================================================
--- nemerle/trunk/ncc/external/LibrariesLoader.n (original)
+++ nemerle/trunk/ncc/external/LibrariesLoader.n Tue Oct 24 14:05:01 2006
@@ -533,7 +533,7 @@
/**
* The location of this library
*/
- private _location : Location;
+ private mutable _location : Location;
/**
* If set to true, the current assembly declares itself
Modified: nemerle/trunk/ncc/generation/HierarchyEmitter.n
==============================================================================
--- nemerle/trunk/ncc/generation/HierarchyEmitter.n (original)
+++ nemerle/trunk/ncc/generation/HierarchyEmitter.n Tue Oct 24 14:05:01 2006
@@ -877,6 +877,8 @@
/* add the method to the type builder */
mutable pinvoke = false;
+ try
+ {
if (fun_header.typarms.IsEmpty) {
def parm_types_array = param_types ();
@@ -890,13 +892,18 @@
else {
method_builder = tb.DefineMethod (Name, attrs);
- def names = fun_header.typarms.MapToArray (fun (x) { x.Name });
+ def names = fun_header.typarms.MapToArray (_.Name);
def generic_parms = method_builder.DefineGenericParameters (names);
- fun_header.typarms.IterI (0, fun (idx, x) {
- x.SetGenericBuilder (generic_parms [idx]);
- });
- foreach (gp in fun_header.typarms) gp.UpdateConstraints ();
+ fun_header.typarms.IterI (0, (idx, x) => x.SetGenericBuilder (generic_parms [idx]));
+ foreach (gp in fun_header.typarms)
+ gp.UpdateConstraints ();
+ }
+ }
+ catch
+ {
+ | e => throw System.ApplicationException (
+ $"Can't define method '$Name' (attrs: $attrs) in type '$tb'.\nError: $(e.Message)", e);
}
method_builder.SetSignature (
Modified: nemerle/trunk/ncc/hierarchy/DelegateClassGen.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/DelegateClassGen.n (original)
+++ nemerle/trunk/ncc/hierarchy/DelegateClassGen.n Tue Oct 24 14:05:01 2006
@@ -80,7 +80,7 @@
| parent => parent.DefineNestedType (pt_decl);
};
- td.MarkWithSpecialName ();
+ td.MarkAsDeledate ();
td.Compile ();
td
})
Modified: nemerle/trunk/ncc/hierarchy/NamespaceTree.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/NamespaceTree.n (original)
+++ nemerle/trunk/ncc/hierarchy/NamespaceTree.n Tue Oct 24 14:05:01 2006
@@ -71,7 +71,9 @@
Value = v;
}
- public EnsureCached() : void
+ /// Ensure type information loaded from external assemblies.
+ /// Note: Types inforamtion loading in lazy way. You must call EnsureCached() for use it.
+ public EnsureCached () : void
{
match (Value)
{
@@ -83,6 +85,61 @@
}
}
+ /// Retrieve a top types defined in the compile project (parsed from source files).
+ public GetTopLevelTypeBuilders () : array [TypeBuilder]
+ {
+ GetTypeBuilders (true)
+ }
+
+ /// Retrieve a types defined in the compile project (parsed from source files).
+ public GetTypeBuilders () : array [TypeBuilder]
+ {
+ GetTypeBuilders (false)
+ }
+
+ /// Retrieve a types defined in the compile project (parsed from source files).
+ public GetTypeBuilders (onlyTopDeclarations : bool) : array [TypeBuilder]
+ {
+ def scan (node : NamespaceTree.Node, result) : void
+ {
+ when (node.Children != null)
+ foreach (elem in node.Children)
+ {
+ //def name = elem.Key;
+ def node = elem.Value;
+
+ match (node.Value)
+ {
+ | NamespaceReference => scan (node, result);
+ | Cached (tycon is TypeBuilder) => result.Add (tycon);
+ | CachedAmbiguous (elems) =>
+ foreach (elem is TypeBuilder in elems)
+ result.Add (elem);
+
+ | _ => ()
+ }
+ }
+ }
+
+ def result = SCG.List();
+ scan (this, result);
+
+ def getNestedTypes(sec : SCG.IEnumerable[TypeBuilder])
+ {
+ foreach (tb in sec)
+ {
+ def result2 = tb.DeclaredNestedTypes;
+ result.AddRange (result2);
+ getNestedTypes (result2);
+ }
+ }
+
+ unless (onlyTopDeclarations)
+ getNestedTypes (result.ToArray());
+
+ result.ToArray ();
+ }
+
[Nemerle.OverrideObjectEquals]
public Equals (other : Node) : bool {
if (other == null) false
Modified: nemerle/trunk/ncc/hierarchy/TypeBuilder.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/TypeBuilder.n (original)
+++ nemerle/trunk/ncc/hierarchy/TypeBuilder.n Tue Oct 24 14:05:01 2006
@@ -34,9 +34,11 @@
using Nemerle.Compiler.Typedtree;
using PT = Nemerle.Compiler.Parsetree;
+using SCG = System.Collections.Generic;
namespace Nemerle.Compiler {
+[Nemerle.Compiler.SupportRelocation]
public partial class TypeBuilder : TypeInfo
{
type Subinfo = Map [TypeInfo, TypeInfo * list [MType]];
@@ -51,6 +53,7 @@
internal mutable forced_typarms : list [StaticTyVar];
internal mutable reflection_inheritance_emitted : bool;
mutable t_implements : list [MType.Class];
+ [Accessor (DeclaredNestedTypes)]
mutable contained_types : list [TypeBuilder] = [];
mutable variant_options : list [TypeBuilder] = [];
mutable supertypes : Map [TypeInfo, TypeInfo * list [MType]];
@@ -76,6 +79,7 @@
mutable additional_decls : list [PT.ClassMember] = [];
mutable partial_parts : list [PT.TopDeclaration] = [];
+ [Accessor (flags = Override)]
is_enum : bool;
[Accessor (flags = WantSetter)]
mutable is_finalized : bool;
@@ -85,6 +89,8 @@
mutable instance_ctor_occured : bool;
/// Marker for [TypeBuilder.Iter].
internal mutable phase : int;
+ [Accessor (flags = Override)]
+ mutable is_delegate : bool;
public TyManager : TypesManager;
@@ -211,15 +217,6 @@
get { attributes %&& NemerleAttributes.Abstract }
}
- public override IsDelegate : bool
- {
- get
- {
- parent_type != null &&
- parent_type.tycon.FullName == "System.MulticastDelegate"
- }
- }
-
public override IsInterface : bool
{
get { if (TyManager.run_phase <= 2)
@@ -248,6 +245,12 @@
get { IsStruct || is_enum }
}
+ //TODO: Move it member to parent class
+ public /*override*/ IsVariantOption : bool
+ {
+ get { pt_tydecl is PT.TopDeclaration.VariantOption }
+ }
+
public override GetModifiers () : Modifiers
{
modifiers
@@ -378,7 +381,10 @@
| PT.TopDeclaration.Class as td => td.t_extends += [t]
| PT.TopDeclaration.Interface as td => td.t_extends += [t]
| PT.TopDeclaration.Variant as td => td.t_extends += [t]
- | _ => Message.Error ("cannot add interface to this kind of type")
+ | _ =>
+ Message.Error (pt_tydecl.Location,
+ $"cannot add interface to $(pt_tydecl.GetType().Name.ToLower())"
+ " ($(pt_tydecl.Name)).")
}
}
@@ -554,6 +560,12 @@
attributes |= NemerleAttributes.SpecialName
}
+ internal MarkAsDeledate () : void
+ {
+ is_delegate = true;
+ MarkWithSpecialName ();
+ }
+
/**
* Return list of types that we directly subtype.
*
@@ -1052,7 +1064,8 @@
| PT.TopDeclaration.Variant (t_extends = hd :: tl)
| PT.TopDeclaration.Enum (t_extends = hd :: tl) =>
def hd' = bind_to_class (hd);
- if (hd'.tycon.IsInterface) {
+ if (hd'.tycon.IsInterface)
+ {
this.t_implements = [hd'];
this.parent_type = null
}
@@ -1210,7 +1223,8 @@
false
}
};
- unless (List.ForAll2 (args, args', check_eq)) {
+ unless (List.ForAll2 (args, args', check_eq))
+ {
Message.Error ($ "type `$(subtyped)' is implemented by type "
"`$(FullName)' twice under different "
"instantiations");
@@ -1361,7 +1375,7 @@
BindType (tenv, t)
}
- internal MonoBindType (t : PT.PExpr) : MType
+ public MonoBindType (t : PT.PExpr) : MType
{
MonoBindType (tenv, t)
}
@@ -1374,7 +1388,7 @@
other_tenv.Bind (this.GlobalEnv, this, t, allow_tyvars = true, check_parms = true)
}
- internal MonoBindType (other_tenv : TyVarEnv, t : PT.PExpr) : MType
+ public MonoBindType (other_tenv : TyVarEnv, t : PT.PExpr) : MType
{
other_tenv.MonoBind (this.GlobalEnv, this, t, check_parms = true)
}
@@ -2277,7 +2291,7 @@
{
foreach (meth in meths)
// the word ``method'' comes from meth.ToString
- Message.Error ($ "unimplemented interface $(meth)")
+ Message.Error ($ "unimplemented interface $(meth) (in $(this.FullName) type)")
}
iface_methods.Iter (scream_about_unimplemented);
@@ -2606,13 +2620,66 @@
)
: void
{
- loc = Completion.Relocate(loc, fileIndex, line, ch, lineOffset, chOffset);
- parts_location = parts_location.Map(Completion.Relocate(_, fileIndex, line, ch, lineOffset, chOffset));
+ //def timer = System.Diagnostics.Stopwatch.StartNew();
+ def info = RelocationInfo (fileIndex, line, ch, lineOffset, chOffset);
+ // The RelocateImpl() is autogenerated by SupportRelocation macro.
+ RelocateImpl (info/*, ""*/);
+
+ //System.Diagnostics.Trace.WriteLine($"builder.Relocate() took: $(timer.Elapsed)");
+ //System.Diagnostics.Trace.WriteLine($"info.VisitCount=$(info.VisitCount) info.NodeCount=$(info.NodeCount)");
+ }
+
+
+ /// Get direct (derived directly) subtypes of given type.
+ public GetDirectSubTypes() : list[TypeBuilder]
+ {
+ def nameTree = this.GlobalEnv.NameTree;
+ def nsRoot = nameTree.NamespaceTree;
+ def typeBuilders = nsRoot.GetTypeBuilders();
+
+ $[ t | t in typeBuilders, t.BaseType : object == this ]
+ }
+
+ /// Get all subtypes of given type.
+ public GetAllSubTypes() : list[TypeBuilder]
+ {
+ def nameTree = this.GlobalEnv.NameTree;
+ def nsRoot = nameTree.NamespaceTree;
+ def typeBuilders = nsRoot.GetTypeBuilders();
+
+ def subTypes = Hashtable();
+
+ def getDirectSubTypes(ty)
+ {
+ def subTypes1 = SCG.List();
+ foreach (t when t.BaseType : object == ty in typeBuilders)
+ unless (subTypes.ContainsKey (t))
+ {
+ subTypes[t] = 0 : byte;
+ subTypes1.Add(t);
+ }
+
+ foreach (subType in subTypes1)
+ getDirectSubTypes(subType)
+ }
+
+ def isImplementInterface(t)
+ {
+ //System.Diagnostics.Trace.Assert(t.Name != "MemberBuilder");
+ t.t_implements.Exists(x => x.tycon : object == this)
+ }
+
+ when (IsInterface)
+ foreach (t when t.t_implements != null && isImplementInterface (t) in typeBuilders)
+ unless (subTypes.ContainsKey (t))
+ {
+ subTypes[t] = 0 : byte;
+ getDirectSubTypes(t);
+ }
+
+ getDirectSubTypes(this);
- // IT:
- // There is a bug here. The member can an inner type.
- foreach (member :> MemberBuilder in member_list)
- member.Relocate(fileIndex, line, ch, lineOffset, chOffset);
+ subTypes.Keys.ToList()
}
}
} // ns
Modified: nemerle/trunk/ncc/parsing/AST.n
==============================================================================
--- nemerle/trunk/ncc/parsing/AST.n (original)
+++ nemerle/trunk/ncc/parsing/AST.n Tue Oct 24 14:05:01 2006
@@ -214,13 +214,13 @@
| SpecialName = 0x08000
| Partial = 0x10000
| Extern = 0x20000
- | CompilerMutable = 0x40000 // field is immutable, but compiler overrides it and can assign something
+ /// field is immutable, but compiler overrides it and can assign something
+ | CompilerMutable = 0x40000
| VirtualityModifiers = New %| Abstract %| Virtual %| Override
| AccessModifiers = Public %| Private %| Protected %| Internal
}
-
public partial class Modifiers
{
public mutable mods : NemerleAttributes;
Modified: nemerle/trunk/ncc/parsing/ParseTree.n
==============================================================================
--- nemerle/trunk/ncc/parsing/ParseTree.n (original)
+++ nemerle/trunk/ncc/parsing/ParseTree.n Tue Oct 24 14:05:01 2006
@@ -128,6 +128,37 @@
}
}
}
+
+ public IsMutable () : bool { modifiers.mods %&& NemerleAttributes.Mutable }
+
+ public override ToString() : string
+ {
+ def attrs1 = Attributes.ToString().ToLower().Replace(",", "");
+ def attrs = if (attrs1 == "") attrs1 else (attrs1 + " ");
+ def ifMutable () { if (IsMutable ()) "mutable " else "" }
+ def prefix() { $"$(attrs)$(ifMutable())" }
+ def name = this.Name;
+
+ match (this)
+ {
+ | TypeDeclaration(td) => $"TopDeclaration: $(prefix())Name=$name ($td)"
+ | Field(ty) => $"Field: $(prefix())$name : $ty;"
+ | Function(header, _, _) => $"Function: $(prefix())$header;"
+ | Property(ty, _, dims, get, set) =>
+ def getSet = match ((get, set))
+ {
+ | (Some, Some) => " { get; set; }"
+ | (None, Some) => " { set; }"
+ | (Some, None) => " { get; }"
+ | (None, None) => ";"
+ }
+
+ $"Property: $(prefix())$name : $ty" + (if (dims.IsEmpty) "" else dims.ToString()) + getSet
+
+ | Event(ty, _, _, _) => $"Event: $(prefix())$name : $ty;"
+ | EnumOption(value) => $"$name" + match (value) { | Some(v) => $" = $v" | None => "" }
+ }
+ }
}
[Record]
@@ -172,6 +203,11 @@
public constraints : list [Constraint];
public static Empty : Typarms = Typarms ([], []);
+
+ public override ToString() : string
+ {
+ if (tyvars.IsEmpty) "" else ("[" + tyvars.Map(_.ToString()).ToString(", ") + "]")
+ }
}
/** class encapsulating name of variable for purpose of
@@ -385,6 +421,11 @@
| _ => throw System.ArgumentException ($"incorrect expression supplied for parameter creation: $from")
}
}
+
+ public override ToString() : string
+ {
+ $"$(this.Name) : $ty"
+ }
}
public class Fun_header : Located
@@ -420,6 +461,12 @@
this (loc, name, ret_type, parms);
this.typarms = typarms;
}
+
+ public override ToString() : string
+ {
+ def parms = parms.ToString (", ");
+ $"$name$typarms($parms) : $ret_type"
+ }
}
[Record]
Modified: nemerle/trunk/ncc/parsing/PreParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/PreParser.n (original)
+++ nemerle/trunk/ncc/parsing/PreParser.n Tue Oct 24 14:05:01 2006
@@ -29,16 +29,19 @@
using Nemerle.Compiler;
using Nemerle.Collections;
using Nemerle.Compiler.Parsetree;
+using Nemerle.Utility;
using SCG = System.Collections.Generic;
namespace Nemerle.Compiler
{
- class PreParserException : System.Exception {
- public Location : Location;
+ class PreParserException : System.Exception
+ {
+ [Accessor]
+ public mutable _location : Location;
- public this (loc : Location, msg : string) {
+ public this (location : Location, msg : string) {
base (msg);
- this.Location = loc;
+ _location = location;
}
}
Modified: nemerle/trunk/ncc/passes.n
==============================================================================
--- nemerle/trunk/ncc/passes.n (original)
+++ nemerle/trunk/ncc/passes.n Tue Oct 24 14:05:01 2006
@@ -29,6 +29,7 @@
using SCG = System.Collections.Generic;
using Nemerle.Collections;
using Nemerle.Compiler.Parsetree;
+using Nemerle.Utility;
namespace Nemerle.Compiler
{
@@ -105,7 +106,8 @@
internal mutable Message_emitted_hints : Hashtable [string, int] = Hashtable ();
protected internal mutable Message_output : System.IO.TextWriter;
- public LocationStack : Vector [Location] = Vector (32);
+ [Accessor]
+ private mutable _locationStack : Vector [Location] = Vector (32);
/** Called by parser when simple "using" directive parsed .
* name : list [string] - qualified identifier/
@@ -431,5 +433,21 @@
Hierarchy.RemoveProgramTypes();
}
}
+
+ public Lookup (type_name : string) : TypeInfo
+ {
+ match (NameTree.LookupExactType (type_name)) {
+ | Some (t) => t
+ | None => Util.ice ("internal type " + type_name + " not found")
+ }
+ }
+
+ public Lookup (type_name : string, args_count : int) : TypeInfo
+ {
+ match (NameTree.LookupExactType (type_name, args_count)) {
+ | Some (t) => t
+ | None => Util.ice ("internal type " + type_name + " not found")
+ }
+ }
}
}
Modified: nemerle/trunk/ncc/typing/TypedTree.n
==============================================================================
--- nemerle/trunk/ncc/typing/TypedTree.n (original)
+++ nemerle/trunk/ncc/typing/TypedTree.n Tue Oct 24 14:05:01 2006
@@ -278,7 +278,7 @@
public override ToString () : string
{
- name
+ $"$name($(parms.ToString(\", \"))) : $ret_type"
}
public GetRetTypeRequiredModifiers () : array [System.Type]
Modified: nemerle/trunk/ncc/typing/Typer-CallTyper.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer-CallTyper.n (original)
+++ nemerle/trunk/ncc/typing/Typer-CallTyper.n Tue Oct 24 14:05:01 2006
@@ -393,7 +393,8 @@
// handled already in DeduceFunctionType
ReportError (messenger, $ "wrong number of parameters in "
"call, needed $formal_count, got "
- "$actual_count");
+ "$actual_count"
+ + (if (header != null) $" (in '$header')" else ""));
}
}
}
More information about the svn
mailing list