[svn] r7144: nemerle/trunk: macros/Util.n macros/compiler.n
ncc/completion/CodeCompletionEngine.n ncc/hier...
VladD2
svnadmin at nemerle.org
Sun Dec 24 19:48:48 CET 2006
Log:
Fix and refactoring of relocation. (fix: propagate IsGenerated bit in relocation algorithm).
Author: VladD2
Date: Sun Dec 24 19:48:46 2006
New Revision: 7144
Modified:
nemerle/trunk/macros/Util.n
nemerle/trunk/macros/compiler.n
nemerle/trunk/ncc/completion/CodeCompletionEngine.n
nemerle/trunk/ncc/hierarchy/ClassMembers.n
nemerle/trunk/ncc/hierarchy/TypeBuilder.n
Modified: nemerle/trunk/macros/Util.n
==============================================================================
--- nemerle/trunk/macros/Util.n (original)
+++ nemerle/trunk/macros/Util.n Sun Dec 24 19:48:46 2006
@@ -392,6 +392,5 @@
head
]>
}
-
}
}
Modified: nemerle/trunk/macros/compiler.n
==============================================================================
--- nemerle/trunk/macros/compiler.n (original)
+++ nemerle/trunk/macros/compiler.n Sun Dec 24 19:48:46 2006
@@ -357,11 +357,11 @@
| _ is TypeBuilder =>
unless (code.IsEmpty)
{
- //tb.Define (<[ decl: public override RelocateImpl (_info : RelocationInfo) : void {}]>);
+ //tb.Define (<[ decl: internal override RelocateImpl (_info : RelocationInfo) : void {}]>);
tb.Define (
<[ decl:
[System.Runtime.CompilerServices.CompilerGenerated]
- public override RelocateImpl (info : RelocationInfo/*, ident : string*/) : void
+ internal override RelocateImpl (info : RelocationInfo/*, ident : string*/) : void
{
//info.NodeCount++;
unless (info.VisitedObjects.ContainsKey (this))
@@ -383,20 +383,20 @@
| _ =>
if (code.IsEmpty)
{
- //tb.Define (<[ decl: public virtual RelocateImpl (_info : RelocationInfo, _ident : string) : void { } ]>);
+ //tb.Define (<[ decl: internal virtual RelocateImpl (_info : RelocationInfo, _ident : string) : void { } ]>);
tb.Define (<[ decl:
[System.Runtime.CompilerServices.CompilerGenerated]
- public virtual RelocateImpl (_info : RelocationInfo) : void { }
+ internal virtual RelocateImpl (_info : RelocationInfo) : void { }
]>);
}
else
{
- //tb.Define (<[ decl: public virtual RelocateImpl (_info : RelocationInfo) : void {}]>);
+ //tb.Define (<[ decl: internal virtual RelocateImpl (_info : RelocationInfo) : void {}]>);
tb.Define (
<[ decl:
[System.Runtime.CompilerServices.CompilerGenerated]
- public virtual RelocateImpl (info : RelocationInfo/*, ident : string*/) : void
+ internal virtual RelocateImpl (info : RelocationInfo/*, ident : string*/) : void
{
//info.NodeCount++;
unless (info.VisitedObjects.ContainsKey (this))
Modified: nemerle/trunk/ncc/completion/CodeCompletionEngine.n
==============================================================================
--- nemerle/trunk/ncc/completion/CodeCompletionEngine.n (original)
+++ nemerle/trunk/ncc/completion/CodeCompletionEngine.n Sun Dec 24 19:48:46 2006
@@ -125,17 +125,17 @@
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);
+ Location (loc, newLn, newCh, newEndLn, newEndCh);
}
else
loc
}
/// Shift Location.
- public Relocate (loc : Location, fileIndex : int, line : int, ch : int, lineOffset : int, chOffset : int) : Location
+ public RelocateFile (loc : Location, info : RelocationInfo) : Location
{
- if (loc.FileIndex == fileIndex)
- Relocate (loc, line, ch, lineOffset, chOffset)
+ if (loc.FileIndex == info.FileIndex)
+ Relocate (loc, info)
else
loc
}
Modified: nemerle/trunk/ncc/hierarchy/ClassMembers.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/ClassMembers.n (original)
+++ nemerle/trunk/ncc/hierarchy/ClassMembers.n Sun Dec 24 19:48:46 2006
@@ -26,6 +26,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System;
using Nemerle.Collections;
using Nemerle.Utility;
using Nemerle.Compiler.Typedtree;
@@ -132,6 +133,8 @@
is_obsolete = modifiers.FindAttribute (InternalType.Obsolete_tc, par.GlobalEnv).IsSome;
}
+ public virtual ResetCodeCache () : void { }
+
public virtual BodyLocation : Location
{
get { loc }
@@ -428,6 +431,8 @@
{
base (par, fieldAst);
+ _initializerLocation = fieldAst.BodyLocation;
+
// check if field's type is valid
match (fieldAst.ty) {
| <[ _ ]> => Message.Error ("type inference for fields is available only when assigning literal value to them")
@@ -444,6 +449,77 @@
ty.CheckAccessibility (this, accessibility);
}
+ ///////////////////////////////////////////////////////////////////////////
+ // Initializer info
+
+ [Accessor] mutable _initializerLocation : Location;
+
+ private IsInitializerPresent : bool
+ {
+ get { InitializerLocation.FileIndex != 0 }
+ }
+
+ public EnsureCompiled() : void
+ {
+ LookupInitializerMethod().EnsureCompiled();
+ }
+
+ public LookupInitializerMethod() : MethodBuilder
+ {
+ if (IsInitializerPresent)
+ {
+ Trace.Assert(DeclaringType.LookupMemberAvailable);
+ def members = DeclaringType.LookupMemberImpl("_N_field_initialiser__" + Name);
+ match (members)
+ {
+ | [method is MethodBuilder] => method
+ | _ => throw ApplicationException($"Initialiser for $Name not found.");
+ }
+ }
+ else
+ {
+ Trace.Assert(IsInitializerPresent);
+ throw ApplicationException("IsInitializerPresent == false");
+ }
+ }
+
+ public InitializerMessages : SCG.List[CompilerMessage]
+ {
+ get { LookupInitializerMethod().BodyMessages }
+ }
+
+ public override ResetCodeCache () : void
+ {
+ LookupInitializerMethod().ResetCodeCache();
+ }
+
+ public InitializerTokens : Token.BracesGroup
+ {
+ get
+ {
+ LookupInitializerMethod().BodyTokens;
+ }
+ }
+
+ public InitializerParsed : PT.PExpr
+ {
+ get
+ {
+ LookupInitializerMethod().BodyParsed;
+ }
+ }
+
+ public BodyTyped : TExpr
+ {
+ get
+ {
+ LookupInitializerMethod().BodyTyped;
+ }
+ }
+
+ //
+ //////////////////////////////////////////////////////////////////////////
+
public IsMutable : bool
{
get { attributes %&& NemerleAttributes.Mutable }
@@ -782,7 +858,7 @@
}
}
- public ResetBody () : void
+ public override ResetCodeCache () : void
{
when (_bodyMessages != null)
_bodyMessages.Clear();
@@ -819,7 +895,7 @@
_bodyTokens
}
- set { ResetBody(); _bodyTokens = value; }
+ set { ResetCodeCache(); _bodyTokens = value; }
}
mutable _bodyParsed : PT.PExpr;
Modified: nemerle/trunk/ncc/hierarchy/TypeBuilder.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/TypeBuilder.n (original)
+++ nemerle/trunk/ncc/hierarchy/TypeBuilder.n Sun Dec 24 19:48:46 2006
@@ -2658,17 +2658,9 @@
FullName)
}
- public Relocate(
- fileIndex : int,
- line : int,
- ch : int,
- lineOffset : int,
- chOffset : int
- )
- : void
+ public Relocate(info : RelocationInfo) : void
{
//def timer = System.Diagnostics.Stopwatch.StartNew();
- def info = RelocationInfo (fileIndex, line, ch, lineOffset, chOffset);
// The RelocateImpl() is autogenerated by SupportRelocation macro.
RelocateImpl (info/*, ""*/);
More information about the svn
mailing list