[svn] r7755: nemerle/trunk/ncc: generation/DecisionTreeCompiler.n
generation/ILEmitter.n generation/Typer3...
IT
svnadmin at nemerle.org
Tue Aug 7 06:16:47 CEST 2007
Log:
DeWorking on debugging.
Author: IT
Date: Tue Aug 7 06:16:39 2007
New Revision: 7755
Modified:
nemerle/trunk/ncc/generation/DecisionTreeCompiler.n
nemerle/trunk/ncc/generation/ILEmitter.n
nemerle/trunk/ncc/generation/Typer3.n
nemerle/trunk/ncc/hierarchy/ClassMembers.n
nemerle/trunk/ncc/parsing/AST.n
nemerle/trunk/ncc/parsing/MainParser.n
nemerle/trunk/ncc/typing/TypedTree.n
nemerle/trunk/ncc/typing/Typer-CallTyper.n
nemerle/trunk/ncc/typing/Typer-PatternTyper.n
nemerle/trunk/ncc/typing/Typer.n
nemerle/trunk/ncc/typing/Typer2.n
Modified: nemerle/trunk/ncc/generation/DecisionTreeCompiler.n
==============================================================================
--- nemerle/trunk/ncc/generation/DecisionTreeCompiler.n (original)
+++ nemerle/trunk/ncc/generation/DecisionTreeCompiler.n Tue Aug 7 06:16:39 2007
@@ -138,8 +138,7 @@
"$(get_stats (decision))\n");
// IT.TEMP ???
- debug_mode = //false;
- if (cases.Length <= 2) false else Manager.Options.EmitDebug;
+ debug_mode = false; //if (cases.Length <= 2) false else Manager.Options.EmitDebug;
collect_effects_and_guards ()
}
Modified: nemerle/trunk/ncc/generation/ILEmitter.n
==============================================================================
--- nemerle/trunk/ncc/generation/ILEmitter.n (original)
+++ nemerle/trunk/ncc/generation/ILEmitter.n Tue Aug 7 06:16:39 2007
@@ -100,6 +100,8 @@
public Run () : void
{
+ _ilg.SetDocument (_debug_doc);
+
_method_start_label = _ilg.DefineLabel ();
_ilg.MarkLabel (_method_start_label);
@@ -111,8 +113,7 @@
when (IsDebugEnabled) {
Mark (beginLocation (_method_builder.BodyLocation));
- //IT.TEMP
- _ilg.Emit (OpCodes.Nop);
+ //IT.TEMP _ilg.Emit (OpCodes.Nop);
}
emit (body);
@@ -204,8 +205,7 @@
when (IsDebugEnabled && loc.Line != 0 && !debug_tmp_disabled && !prev_location.Contains(loc)) {
prev_location = loc;
Util.cassert (loc.Line <= loc.EndLine, "spoiled location " + loc.File + " " + loc.ToString ());
- //IT.TEMP
- _ilg.MarkSequencePoint (_debug_doc, loc.Line, loc.Column, loc.EndLine, loc.EndColumn);
+ //IT.TEMP _ilg.MarkSequencePoint (_debug_doc, loc.Line, loc.Column, loc.EndLine, loc.EndColumn);
}
}
@@ -455,15 +455,16 @@
static skipped (expr : TExpr) : void
{
- unless (expr is TExpr.Goto ||
- expr is TExpr.Literal (Literal.Void) ||
- expr is TExpr.Label (_, Literal (Void))) {
+ | TExpr.Goto
+ | TExpr.Literal (Literal.Void)
+ | TExpr.Label (_, Literal (Void))
+ | TExpr.DebugInfo (Literal (Void), null) => ()
+ | _ =>
Message.Warning (expr.Location,
"this expression has been skipped in code "
"generation because of unreachable code");
//Message.Warning (expr.loc, expr.ToString ());
}
- }
static no_cast_needed (src_type : System.Type, target_type : System.Type) : bool
{
@@ -1546,9 +1547,9 @@
}
else if (l is Literal.Void) {
// IT.TEMP ???
- when (IsDebugEnabled) {
- _ilg.Emit (OpCodes.Nop);
- }
+ //when (IsDebugEnabled) {
+ // _ilg.Emit (OpCodes.Nop);
+ //}
} else
emit_literal (l);
@@ -1684,9 +1685,6 @@
def emit_debug (line, col, eline, ecol)
{
_ilg.MarkSequencePoint (_debug_doc, line, col, eline, ecol);
- _ilg.Emit (OpCodes.Nop);
- //_ilg.MarkSequencePoint (_debug_doc, 0xFeeFee, 0, 0xFeeFee, 0);
- //_ilg.Emit (OpCodes.Nop);
}
def l = di.Location;
@@ -2309,12 +2307,19 @@
class NemerleGenerator
{
+ private _ilg : ILGenerator;
+
public this(ilg : ILGenerator)
{
_ilg = ilg;
}
- private _ilg : ILGenerator;
+ private mutable _document : ISymbolDocumentWriter;
+
+ public SetDocument (document : ISymbolDocumentWriter) : void
+ {
+ _document = document;
+ }
public BeginCatchBlock (tp : Type) : void { _ilg.BeginCatchBlock(tp) }
public BeginExceptFilterBlock () : void { _ilg.BeginExceptFilterBlock() }
@@ -2333,30 +2338,30 @@
public DefineLabel () : Label { _ilg.DefineLabel() }
- public Emit (opcode : OpCode) : void { Emited(); _ilg.Emit(opcode) }
- public Emit (opcode : OpCode, arg : byte) : void { Emited(); _ilg.Emit(opcode, arg) }
- public Emit (opcode : OpCode, con : ConstructorInfo) : void { Emited(); _ilg.Emit(opcode, con) }
- public Emit (opcode : OpCode, arg : double ) : void { Emited(); _ilg.Emit(opcode, arg) }
- public Emit (opcode : OpCode, field : FieldInfo ) : void { Emited(); _ilg.Emit(opcode, field) }
- public Emit (opcode : OpCode, arg : float) : void { Emited(); _ilg.Emit(opcode, arg) }
- public Emit (opcode : OpCode, arg : int) : void { Emited(); _ilg.Emit(opcode, arg) }
- public Emit (opcode : OpCode, label : Label) : void { Emited(); _ilg.Emit(opcode, label) }
- public Emit (opcode : OpCode, labels : array[Label]) : void { Emited(); _ilg.Emit(opcode, labels) }
- public Emit (opcode : OpCode, local : LocalBuilder) : void { Emited(); _ilg.Emit(opcode, local) }
- public Emit (opcode : OpCode, arg : long) : void { Emited(); _ilg.Emit(opcode, arg) }
- public Emit (opcode : OpCode, meth : MethodInfo) : void { Emited(); _ilg.Emit(opcode, meth) }
- public Emit (opcode : OpCode, arg : sbyte) : void { Emited(); _ilg.Emit(opcode, arg) }
- public Emit (opcode : OpCode, arg : short) : void { Emited(); _ilg.Emit(opcode, arg) }
- public Emit (opcode : OpCode, signature : SignatureHelper) : void { Emited(); _ilg.Emit(opcode, signature) }
- public Emit (opcode : OpCode, str : string) : void { Emited(); _ilg.Emit(opcode, str) }
- public Emit (opcode : OpCode, cls : Type) : void { Emited(); _ilg.Emit(opcode, cls) }
+ public Emit (opcode : OpCode) : void { Emited(opcode); _ilg.Emit(opcode) }
+ public Emit (opcode : OpCode, arg : byte) : void { Emited(opcode); _ilg.Emit(opcode, arg) }
+ public Emit (opcode : OpCode, con : ConstructorInfo) : void { Emited(opcode); _ilg.Emit(opcode, con) }
+ public Emit (opcode : OpCode, arg : double ) : void { Emited(opcode); _ilg.Emit(opcode, arg) }
+ public Emit (opcode : OpCode, field : FieldInfo ) : void { Emited(opcode); _ilg.Emit(opcode, field) }
+ public Emit (opcode : OpCode, arg : float) : void { Emited(opcode); _ilg.Emit(opcode, arg) }
+ public Emit (opcode : OpCode, arg : int) : void { Emited(opcode); _ilg.Emit(opcode, arg) }
+ public Emit (opcode : OpCode, label : Label) : void { Emited(opcode); _ilg.Emit(opcode, label) }
+ public Emit (opcode : OpCode, labels : array[Label]) : void { Emited(opcode); _ilg.Emit(opcode, labels) }
+ public Emit (opcode : OpCode, local : LocalBuilder) : void { Emited(opcode); _ilg.Emit(opcode, local) }
+ public Emit (opcode : OpCode, arg : long) : void { Emited(opcode); _ilg.Emit(opcode, arg) }
+ public Emit (opcode : OpCode, meth : MethodInfo) : void { Emited(opcode); _ilg.Emit(opcode, meth) }
+ public Emit (opcode : OpCode, arg : sbyte) : void { Emited(opcode); _ilg.Emit(opcode, arg) }
+ public Emit (opcode : OpCode, arg : short) : void { Emited(opcode); _ilg.Emit(opcode, arg) }
+ public Emit (opcode : OpCode, signature : SignatureHelper) : void { Emited(opcode); _ilg.Emit(opcode, signature) }
+ public Emit (opcode : OpCode, str : string) : void { Emited(opcode); _ilg.Emit(opcode, str) }
+ public Emit (opcode : OpCode, cls : Type) : void { Emited(opcode); _ilg.Emit(opcode, cls) }
public EmitCall (opcode : OpCode, methodInfo : MethodInfo , optionalParameterTypes : array[Type]) : void
- { _ilg.EmitCall(opcode, methodInfo, optionalParameterTypes) }
+ { Emited(opcode); _ilg.EmitCall(opcode, methodInfo, optionalParameterTypes) }
public EmitCalli (opcode : OpCode, unmanagedCallConv : CallingConvention, returnType : Type, parameterTypes : array[Type]) : void
- { _ilg.EmitCalli(opcode, unmanagedCallConv, returnType, parameterTypes) }
+ { Emited(opcode); _ilg.EmitCalli(opcode, unmanagedCallConv, returnType, parameterTypes) }
public EmitCalli (opcode : OpCode, callingConvention : CallingConventions, returnType : Type, parameterTypes : array[Type], optionalParameterTypes : array[Type]) : void
- { _ilg.EmitCalli(opcode, callingConvention, returnType, parameterTypes, optionalParameterTypes) }
+ { Emited(opcode); _ilg.EmitCalli(opcode, callingConvention, returnType, parameterTypes, optionalParameterTypes) }
public EmitWriteLine (fld : FieldInfo) : void { _ilg.EmitWriteLine(fld) }
public EmitWriteLine (localBuilder : LocalBuilder) : void { _ilg.EmitWriteLine(localBuilder) }
@@ -2374,23 +2379,40 @@
_ilg.Emit (OpCodes.Nop);
}
+ _throw = false;
+
_ilg.MarkLabel(loc);
}
+ private mutable _throw : bool;
private mutable _marked : bool;
- private mutable _document : ISymbolDocumentWriter;
+ private mutable _first_code = true;
public MarkSequencePoint (document : ISymbolDocumentWriter, startLine : int, startColumn : int, endLine : int, endColumn : int) : void
{
- _ilg.MarkSequencePoint (document, startLine, startColumn, endLine, endColumn);
- _document = document;
+ unless (_throw)
+ {
_marked = true;
+
+ _ilg.MarkSequencePoint (document, startLine, startColumn, endLine, endColumn);
+ _ilg.Emit (OpCodes.Nop);
+ }
}
public UsingNamespace (usingNamespace : string) : void { _ilg.UsingNamespace(usingNamespace) }
- private Emited() : void
+ private Emited(opcode : OpCode) : void
+ {
+ when (_first_code)
{
+ _first_code = false;
+
+ when (_document != null && !_marked)
+ _ilg.MarkSequencePoint (_document, 0xFeeFee, 0, 0xFeeFee, 0);
+ }
+
+ when (opcode == OpCodes.Throw || opcode == OpCodes.Rethrow)
+ _throw = true;
}
}
Modified: nemerle/trunk/ncc/generation/Typer3.n
==============================================================================
--- nemerle/trunk/ncc/generation/Typer3.n (original)
+++ nemerle/trunk/ncc/generation/Typer3.n Tue Aug 7 06:16:39 2007
@@ -2016,14 +2016,14 @@
expr.Location = m.Location;
//IT.TEMP
- //when (Manager.Options.EmitDebug && !m.Location.IsGeneratedOrEmpty)
- //{
- // def l = m.Location;
- // def dl = Location (l.FileIndex, l.EndLine, l.EndColumn - 1, l.EndLine, l.EndColumn);
- // def di = TExpr.DebugInfo (dl, null, TExpr.Literal (dl, InternalType.Void, Literal.Void ()), null);
+ when (Manager.Options.EmitDebug && !m.Location.IsGeneratedOrEmpty)
+ {
+ def l = m.Location;
+ def dl = Location (l.FileIndex, l.EndLine, l.EndColumn - 1, l.EndLine, l.EndColumn);
+ def di = TExpr.DebugInfo (dl, null, TExpr.Literal (dl, InternalType.Void, Literal.Void ()), null);
- // expr = TExpr.Sequence (l, expr.Type, expr, di);
- //}
+ expr = TExpr.Sequence (l, expr.Type, expr, di);
+ }
Walk (expr)
}
@@ -2069,7 +2069,8 @@
}
// handled by Typer2.LambdaTransform
- | TExpr.MethodRef => assert (false)
+ | TExpr.MethodRef =>
+ assert (false)
| TExpr.Call (TExpr.StaticRef (_, m is IMethod, _) as sr, [parm], _)
when
Modified: nemerle/trunk/ncc/hierarchy/ClassMembers.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/ClassMembers.n (original)
+++ nemerle/trunk/ncc/hierarchy/ClassMembers.n Tue Aug 7 06:16:39 2007
@@ -810,6 +810,11 @@
internal set { is_extension = value }
}
+ public IsConstructor : bool
+ {
+ get { method_base != null && method_base.IsConstructor }
+ }
+
/// Exclusive methode body location.
[Accessor (flags = Override)]
protected mutable _bodyLocation : Location;
Modified: nemerle/trunk/ncc/parsing/AST.n
==============================================================================
--- nemerle/trunk/ncc/parsing/AST.n (original)
+++ nemerle/trunk/ncc/parsing/AST.n Tue Aug 7 06:16:39 2007
@@ -87,17 +87,25 @@
/// This operator is not commutative!
public static @+ (x : Location, y : Location) : Location
{
- if (x.FileIndex == y.FileIndex)
- Location(x._fileIndex, x.Line, x.Column, y.EndLine, y.EndColumn)
+ if (x.FileIndex == y.FileIndex && x.IsGenerated == y.IsGenerated)
+ {
+ def genmask = if (x.IsGenerated) GeneratedMask else 0;
+ Location(
+ x._fileIndex | genmask,
+ x.Line,
+ x.Column,
+ if (y.EndLine > x.EndLine) y.EndLine else x.EndLine,
+ if (y.EndColumn > x.EndColumn) y.EndColumn else x.EndColumn);
+ }
else
{
//throw System.ArgumentException ($"Combinig locations of different files ($x and $y)");
//System.Console.WriteLine($">>>> Combinig locations of different files ($x and $y)\n $(System.Diagnostics.StackTrace())");
- if (x == Default)
- y
- else
+ if (y == Default || y.IsGenerated)
x
+ else
+ y
}
}
@@ -206,7 +214,10 @@
""
else
if (EndLine != 0)
- $"$File:$Line:$Column:$EndLine:$EndColumn: "
+ {
+ def gen = if (IsGeneratedOrEmpty) "" else "+";
+ $"$File:$Line:$Column:$EndLine:$EndColumn:$gen "
+ }
else if (Line != 0)
$"$File:$Line:$Column: "
else
@@ -488,6 +499,9 @@
set
{
#if DEBUG
+ when (this is Nemerle.Compiler.Typedtree.Pattern.As)
+ ();
+
when (this is Nemerle.Compiler.Typedtree.TExpr.DebugInfo)
assert(!value.IsGeneratedOrEmpty);
#endif
Modified: nemerle/trunk/ncc/parsing/MainParser.n
==============================================================================
--- nemerle/trunk/ncc/parsing/MainParser.n (original)
+++ nemerle/trunk/ncc/parsing/MainParser.n Tue Aug 7 06:16:39 2007
@@ -206,7 +206,8 @@
{
def parser = MainParser(env);
parser.push_stream(round_group);
- parser.parse_parameters()
+ def (parms, _) = parser.parse_parameters();
+ parms
}
public static ParseTyVars(
@@ -822,7 +823,7 @@
| Token.Operator ("$") | Token.Identifier =>
def id = get_splicable_id ();
mutable is_property = false;
- def (tyvars, parms) =
+ def (tyvars, (parms, parmsloc)) =
match ((peek_token (), peek_second_token ())) {
| (Token.SquareGroup, Token.SquareGroup) =>
is_property = true;
@@ -840,7 +841,7 @@
| _ =>
is_property = true; // most probably it is a field or property
- ((null, null), [])
+ ((null, null), ([], Location.Default))
}
def ret_type = parse_return_type (true);
@@ -849,7 +850,7 @@
if (is_property)
parse_property (start_tok.Location, mods, customs, id, ret_type, parms, typarms)
else {
- def header = Fun_header (start_tok.Location + ret_type.Location,
+ def header = Fun_header (start_tok.Location + parmsloc + ret_type.Location,
name = id,
ret_type = ret_type,
parms = parms,
@@ -861,8 +862,7 @@
| Token.Keyword ("this") =>
shift ();
- def paramsLoc = peek_token ().Location;
- def parms = parse_parameters ();
+ def (parms, paramsLoc) = parse_parameters ();
def header = Fun_header (start_tok.Location + paramsLoc,
name = Splicable.Name (tok.Location, mkname (".ctor")),
ret_type = PExpr.Void (),
@@ -1517,11 +1517,11 @@
{
when (name == null) name = get_splicable_id ();
def tyvars = parse_tyvars ();
- def parms = parse_parameters (allow_patterns = allow_patterns);
+ def (parms, parmsloc) = parse_parameters (allow_patterns = allow_patterns);
def ret_type = parse_return_type (true);
def typarms = parse_where_constraints (tyvars);
- Fun_header (name.Location + ret_type.Location,
+ Fun_header (name.Location + parmsloc + ret_type.Location,
name = name,
ret_type = ret_type,
parms = parms,
@@ -1579,8 +1579,9 @@
}
/// parameters of (a:foo,b,c) or [a,b:foo,c] kind
- parse_parameters (allow_patterns = false, allow_omit = false) : list [Fun_parm] {
+ parse_parameters (allow_patterns = false, allow_omit = false) : list [Fun_parm] * Location {
def group = get_token ();
+ (
match (group) {
| Token.RoundGroup (null) | Token.SquareGroup (null) => []
| Token.RoundGroup (child)
@@ -1600,7 +1601,9 @@
else
Error (group, "expecting function parameters");
[]
- }
+ },
+ group.Location
+ )
}
parse_return_type (allow_inference : bool) : PExpr {
@@ -2023,7 +2026,7 @@
| [] => fatal_error (last_tok, "match case body cannot be empty")
| l =>
def loc = l.Tail.FoldLeft(l.Head.Location, (e, loc) => loc.Combine(e.Location));
- PExpr.Sequence (loc, l)
+ PExpr.Sequence (loc.AsGenerated(), l)
};
MatchCase (pats, expr)
@@ -2153,11 +2156,11 @@
| Token.Keyword ("fun") =>
def tyvars = parse_tyvars ();
- def parms = parse_parameters (allow_patterns = true, allow_omit = true);
+ def (parms, parmsloc) = parse_parameters (allow_patterns = true, allow_omit = true);
def ret_type = parse_return_type (true);
def typarms = parse_where_constraints (tyvars);
- def h = Fun_header (loc + ret_type.Location,
+ def h = Fun_header (loc + parmsloc + ret_type.Location,
name = Splicable.Name (mkname ("")),
ret_type = ret_type,
parms = parms,
Modified: nemerle/trunk/ncc/typing/TypedTree.n
==============================================================================
--- nemerle/trunk/ncc/typing/TypedTree.n (original)
+++ nemerle/trunk/ncc/typing/TypedTree.n Tue Aug 7 06:16:39 2007
@@ -436,8 +436,8 @@
| HasType
| Wildcard => pat
- | As (pat, decl) =>
- As (pat.Location, walk (pat), decl)
+ | As (p, decl) =>
+ As (pat.Location, walk (p), decl)
| Tuple (args) =>
Tuple (pat.Location, args.Map (walk))
Modified: nemerle/trunk/ncc/typing/Typer-CallTyper.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer-CallTyper.n (original)
+++ nemerle/trunk/ncc/typing/Typer-CallTyper.n Tue Aug 7 06:16:39 2007
@@ -72,7 +72,7 @@
solver = typer.solver;
messenger = typer.messenger;
- function_called = fnc;
+ function_called = match (fnc) { | DebugInfo (fnc, _) => fnc | _ => fnc }
call_parms = parms;
orig_parms = parms;
reordered_parms = parms;
Modified: nemerle/trunk/ncc/typing/Typer-PatternTyper.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer-PatternTyper.n (original)
+++ nemerle/trunk/ncc/typing/Typer-PatternTyper.n Tue Aug 7 06:16:39 2007
@@ -387,6 +387,7 @@
name : PT.PExpr, pattern : PT.PExpr,
is_where : bool) : Pattern
{
+ def nameloc = name.Location;
def pat = match (Util.QidOfExpr (name)) {
| Some (([id], name)) when !is_where && (System.Char.IsLower (id [0]) || id [0] == '_') =>
match (pattern) {
@@ -432,7 +433,7 @@
if (matched_value_type.Require (fld.GetMemType () : MType)) {
def val = ConstantFolder.FieldValueAsPureLiteral (fld, typer.TriggerObsoleteWarning);
if (fld.DeclaringType.GetTydecl () is TypeDeclaration.Enum)
- Pattern.Enum (fld, val)
+ Pattern.Enum (nameloc, fld, val)
else
Pattern.Literal (val)
}
Modified: nemerle/trunk/ncc/typing/Typer.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer.n (original)
+++ nemerle/trunk/ncc/typing/Typer.n Tue Aug 7 06:16:39 2007
@@ -202,8 +202,15 @@
RunTyper ();
when (errcnt == Message.ErrorCount)
+ {
+ // IT.TEMP
+ Message.Warning ($"$(current_fun.body)");
+ def expr = match (current_fun.body) { | FunBody.Typed (e) => e | _ => null };
+ Message.Warning ($"$expr, $(expr.Location)");
+
Util.ice ($"hidden errors compiling $current_method_builder - $(Message.ErrorCount) vs $errcnt: $(e.StackTrace)");
}
+ }
} catch {
| _ is SwitchToYielding =>
messenger.InErrorMode = false;
@@ -314,6 +321,18 @@
else
MakeImplicitBlockJumpOut ("_N_return", current_fun.ret_type);
def e' = TypeExpr (e);
+ // Set break point for variant option ctor.
+ def e' =
+ if (Manager.Options.EmitDebug &&
+ CurrentType.IsVariantOption && !CurrentType.Location.IsGeneratedOrEmpty &&
+ CurrentMethodBuilder.Location.IsGenerated && CurrentMethodBuilder.IsConstructor)
+ {
+ def l = CurrentType.Location;
+ def l = Location (l.FileIndex, l.Line, l.Column, l.Line, l.Column + CurrentType.Name.Length);
+ TExpr.DebugInfo (l, e'.ty, e', null);
+ }
+ else
+ e';
messenger.CleanLocalError ();
def e' = AddCastTo (e', current_fun.ret_type, "function return value");
def e' =
@@ -1088,11 +1107,11 @@
| (e, Some ((orig, im))) =>
log (MACRO_EXPANSIONS, e.loc, $ "after expansion: $e");
- def debugLocation =
+ def (pexpr, debugLocation) =
if (Manager.Options.EmitDebug && !expr.Location.IsGeneratedOrEmpty)
GetDebugLocation(expr);
else
- Location.Default;
+ (null, Location.Default);
def res = TypeExpr (e, expected, is_toplevel_in_seq);
@@ -1105,7 +1124,7 @@
if (debugLocation.IsEmpty)
res
else
- TExpr.DebugInfo (debugLocation, res.ty, res, expr);
+ TExpr.DebugInfo (debugLocation, res.ty, res, pexpr);
}
}
} catch {
@@ -1181,7 +1200,7 @@
Manager.Complete (expression, expected, this, env);
}
- def debugLocation = GetDebugLocation(expression);
+ def (pexpr, debugLocation) = GetDebugLocation(expression);
def texpr = match (expression)
{
@@ -1762,6 +1781,7 @@
| PT.PExpr.TypedPattern =>
Util.ice ("typed pattern in raw expr")
+
| PT.PExpr.ToComplete =>
Util.ice ("The completion tokens allowed only if Manager.IsCompletionInProgress is true.")
}
@@ -1769,25 +1789,83 @@
when (expression.typed_object == null)
expression.typed_object = texpr;
- if (debugLocation.IsEmpty)
+ def skip = match (texpr)
+ {
+ //| StaticRef
+ //| Sequence
+ //| LocalFunRef
+ //| MethodRef
+ //| Delayed
+ //| DebugInfo
+ // => true;
+
+ /*
+ | LocalFunRef
+ | MethodRef
+ | ImplicitValueTypeCtor
+ | FieldMember
+ | Call
+ | Assign
+ | DefValIn
+ | Throw
+ | TryFinally
+ | Try
+ | Literal
+ | This
+ | Base
+ | TypeConversion
+ | Tuple
+ | Array
+ | TypeOf
+ | ArrayIndexer
+ | TupleIndexer
+ | OpCode
+ | MacroEnvelope
+ | PropertyMember
+ | StaticPropertyRef
+ | EventMember
+ | StaticEventRef
+ | ConstantObjectRef
+ | Block
+ | Cache
+ | CacheRef
+ | Error
+ | DefFunctionsIn
+ | Match
+ | SelfTailCall
+ | MethodAddress
+ | MultipleAssign
+ | Label
+ | Goto
+ | DefaultValue
+ | If
+ | HasType
+ | Switch
+ | LocalRef
+ */
+ | _ => false;
+
+ }
+
+ if (debugLocation.IsEmpty || skip)
texpr
else
- TExpr.DebugInfo (debugLocation, texpr.ty, texpr, expression)
+ TExpr.DebugInfo (debugLocation, texpr.ty, texpr, pexpr)
}
private mutable debugInfos : list[Location * PT.PExpr] = [];
+ private mutable firstExpr = true;
- private GetDebugLocation(pexpr : PT.PExpr) : Location
+ private GetDebugLocation(mutable pexpr : PT.PExpr) : PT.PExpr * Location
{
def skip(l)
{
debugInfos.Exists((loc, _) => loc.Contains(l));
}
- //IT.TEMP
- _ =
+ //IT.TEMP _ =
if (!Manager.Options.EmitDebug || pexpr.Location.IsGeneratedOrEmpty || skip(pexpr.Location))
- Location.Default
+ (null, Location.Default)
else
{
mutable loc = pexpr.Location;
@@ -1811,10 +1889,17 @@
match (info.Node)
{
- | PT.PExpr.Sequence as s when !s.Location.IsGeneratedOrEmpty =>
- truncate(s.Location.Line, s.Location.Column, true);
+ | PT.PExpr.Lambda as e
+ | PT.PExpr.Call (Ref (name = (idl = "=>")), _) as e
+ | PT.PExpr.Sequence as e =>
+
+ unless (e.Location.IsGeneratedOrEmpty)
+ truncate(e.Location.Line, e.Location.Column, true);
+
| PT.PExpr.Match(_, _, l) when !l.IsGeneratedOrEmpty =>
+
truncate(l.EndLine, l.EndColumn, false);
+
| _ => ()
}
});
@@ -1860,7 +1945,27 @@
loc = nm.Location;
+ | DefFunctions (funs) =>
+
+ loc = Location.Default;
+ funs.Iter (f => {
+ unless (f.header.Location.IsGeneratedOrEmpty)
+ debugInfos ::= (f.header.Location, pexpr);
+ });
+
+ | PT.PExpr.Match when !pexpr.Location.IsGeneratedOrEmpty && firstExpr =>
+
+ // It happens for match-methods:
+ // foo (i : int) : void
+ // {
+ // | 0 => ()
+ // }
+ // This code substitutes match with sequence in DebugInfo.
+ loc = pexpr.Location;
+ pexpr = PT.PExpr.Sequence (loc, []);
+
| _ =>
+
truncateLoc();
unless (loc.IsEmpty)
{
@@ -1871,10 +1976,10 @@
}
}
- loc;
+ firstExpr = false;
+ (pexpr, loc);
}
- //IT.TEMP
- Location.Default;
+ //IT.TEMP Location.Default;
}
#endregion
@@ -2901,6 +3006,9 @@
| TExpr.Delayed (susp) =>
susp.ApplyGenericSpecifier (gen_parms);
+ | TExpr.DebugInfo (e, _) =>
+ ApplyGenericSpecifier (e, gen_parms);
+
| _ =>
ReportError (messenger,
$ "don't know how to apply generic specifier to $expr");
@@ -3158,6 +3266,8 @@
def res =
match (fnc) {
+ // IT.TEMP
+ | TExpr.DebugInfo (TExpr.Delayed ((CanSetCallExpr = true) as dt) as expr, _)
| TExpr.Delayed ((CanSetCallExpr = true) as dt) as expr =>
log (TYPING, $"result is delayed: $dt");
def expr = TExpr.Call (expected, expr, parameters, false);
Modified: nemerle/trunk/ncc/typing/Typer2.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer2.n (original)
+++ nemerle/trunk/ncc/typing/Typer2.n Tue Aug 7 06:16:39 2007
@@ -212,6 +212,8 @@
tc.GetMemType ().Equals (from) &&
AreSelfMethodTyParms (meth, typarms)
+ // IT.TEMP
+ //| TExpr.DebugInfo (TExpr.MethodRef (th, meth : IMethod, typarms, _), _)
| TExpr.MethodRef (th, meth : IMethod, typarms, _) =>
(!(meth.Attributes %&& NemerleAttributes.Virtual) || meth.Attributes %&& NemerleAttributes.Sealed) &&
meth.GetHeader ().id == current_fun.id &&
@@ -986,6 +988,8 @@
TExpr.Error ()
}
+ // IT.TEMP
+ //| TExpr.DebugInfo (TExpr.MethodRef (obj, meth, type_parms, notvirt), _)
| TExpr.MethodRef (obj, meth, type_parms, notvirt) =>
MarkAsUsed (meth, expr.Location);
def is_base = IsBaseRef (obj);
@@ -1014,6 +1018,8 @@
| _ => Util.ice ()
}
+ // IT.TEMP
+ //| TExpr.DebugInfo (MethodRef (_, IMethod where (BuiltinKind = ExtensionMethod), _, _), _)
| TExpr.MethodRef (_, IMethod where (BuiltinKind = ExtensionMethod), _, _) =>
{}
@@ -1062,6 +1068,8 @@
ivtc.ty = expr.ty;
ivtc
+ // IT.TEMP
+ //| TExpr.DebugInfo (MethodRef (obj, IMethod where (BuiltinKind = ExtensionMethod (impl)) as im, type_parms, _) as func, _)
| TExpr.MethodRef (obj, IMethod where (BuiltinKind = ExtensionMethod (impl)) as im, type_parms, _) as func =>
//Message.Debug ($"expand to $impl");
def from = impl.DeclaringType.GetMemType ();
More information about the svn
mailing list