[svn] r7754: nemerle/trunk/ncc: generation/DecisionTreeCompiler.n
generation/ILEmitter.n generation/Typer3...
IT
svnadmin at nemerle.org
Wed Aug 1 05:45:51 CEST 2007
Log:
Working on debugging in match.
Author: IT
Date: Wed Aug 1 05:45:43 2007
New Revision: 7754
Modified:
nemerle/trunk/ncc/generation/DecisionTreeCompiler.n
nemerle/trunk/ncc/generation/ILEmitter.n
nemerle/trunk/ncc/generation/Typer3.n
nemerle/trunk/ncc/generation/Typer4.n
nemerle/trunk/ncc/main.n
nemerle/trunk/ncc/misc/ExprWalker.n
nemerle/trunk/ncc/misc/PrettyPrint.n
nemerle/trunk/ncc/parsing/AST.n
nemerle/trunk/ncc/typing/DecisionTreeBuilder.n
nemerle/trunk/ncc/typing/TypedTree.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 Wed Aug 1 05:45:43 2007
@@ -138,7 +138,8 @@
"$(get_stats (decision))\n");
// IT.TEMP ???
- debug_mode = 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 ()
}
@@ -207,10 +208,9 @@
}
// check if node has already been compiled and either reuse
- // memoized TExpr or call compile2() to generate a new one
+ // memorized TExpr or call compile2() to generate a new one
compile (decision : Decision) : TExpr
{
- def expr = match (decision) {
// for effects SharedEffect class is used to detect reusable nodes
| Decision.Success => compile2 (decision)
@@ -228,18 +228,12 @@
| _ => Util.locate (decision.Location, compile2 (decision))
}
- if (Manager.Options.EmitDebug && !decision.Location.IsGeneratedOrEmpty)
- {
- TExpr.DebugInfo(decision.Location, null, expr, null)
- }
- else
- expr;
- }
-
compile2 (decision : Decision) : TExpr
{
- | Success (res_id) => effects [res_id] ()
+ | Success (res_id) =>
+ def expr = effects [res_id] ();
+ expr
| Failure => ThrowMatchFailure ()
@@ -254,7 +248,7 @@
Decision.Success (res_id) as if_true, if_false) =>
def true_expr = compile (if_true);
def false_expr = compile (if_false);
- If (guards [res_id], true_expr, false_expr)
+ If (guards [res_id], true_expr, false_expr, get_debug_loc (if_true), get_debug_loc (if_false))
| IfEq (path, con, if_true, if_false) =>
def path_expr = get_path_expression (path);
@@ -274,25 +268,33 @@
def sref = TExpr.StaticRef (from, from, field, []);
def cond = TExpr.Call (InternalType.Boolean, TExpr.OpCode ("==.ref"),
[Parm (path_expr), Parm (sref)], false);
- If (cond, true_expr, false_expr)
+ If (cond, true_expr, false_expr, get_debug_loc (if_true), get_debug_loc (if_false))
| None =>
def has_type_expr = HasType (path_expr, ti);
- If (has_type_expr, true_expr, false_expr)
+ If (has_type_expr, true_expr, false_expr, get_debug_loc (if_true), get_debug_loc (if_false))
}
| Lit (lit) =>
def cmp_expr = emit_compare_with (path_expr, lit);
- If (cmp_expr, true_expr, false_expr)
+ If (cmp_expr, true_expr, false_expr, get_debug_loc (if_true), get_debug_loc (if_false))
| Type (t) =>
def has_type_expr = TExpr.HasType (path_expr, t);
- If (has_type_expr, true_expr, false_expr)
+ If (has_type_expr, true_expr, false_expr, get_debug_loc (if_true), get_debug_loc (if_false))
| _ => assert (false);
}
}
+ get_debug_loc (decision : Decision) : Location
+ {
+ if (Manager.Options.EmitDebug && decision is Decision.Success && !decision.Location.IsGeneratedOrEmpty)
+ decision.Location;
+ else
+ Location.Default;
+ }
+
// memoize calls to build_path_expression ()
get_path_expression (path : Path) : TExpr
{
@@ -485,9 +487,9 @@
}
}
- static If (cond : TExpr, e1 : TExpr, e2 : TExpr) : TExpr
+ If (cond : TExpr, e1 : TExpr, e2 : TExpr, l1 : Location, l2 : Location) : TExpr
{
- TExpr.If (e1.Type, cond, e1, e2)
+ TExpr.If (e1.Type, cond, e1, e2, l1, l2)
}
static Cast (expr : TExpr, ty : TyVar) : TExpr
Modified: nemerle/trunk/ncc/generation/ILEmitter.n
==============================================================================
--- nemerle/trunk/ncc/generation/ILEmitter.n (original)
+++ nemerle/trunk/ncc/generation/ILEmitter.n Wed Aug 1 05:45:43 2007
@@ -149,7 +149,7 @@
{
| Literal (Literal.Bool (true)) => true
- | If (cond_expr, then_expr, else_expr) =>
+ | If (cond_expr, then_expr, else_expr, _, _) =>
def cond_always_true = is_always_true (cond_expr);
def cond_always_false = is_always_false (cond_expr);
def then_always_true = is_always_true (then_expr);
@@ -180,7 +180,7 @@
{
| Literal (Bool (false)) => true
- | If (cond_expr, then_expr, else_expr) =>
+ | If (cond_expr, then_expr, else_expr, _, _) =>
def cond_always_true = is_always_true (cond_expr);
def cond_always_false = is_always_false (cond_expr);
def then_always_false = is_always_false (then_expr);
@@ -204,7 +204,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
+ //IT.TEMP
_ilg.MarkSequencePoint (_debug_doc, loc.Line, loc.Column, loc.EndLine, loc.EndColumn);
}
}
@@ -645,13 +645,23 @@
/* -- CONDITIONAL CONSTRUCTIONS ------------------------------------ */
/* emits the if/then/else construction */
- | If (cond_expr, then_expr, else_expr) =>
- def emit_branch (expr : TExpr, else_label : Label) {
+ | If (cond_expr, then_expr, else_expr, then_debug_loc, else_debug_loc) =>
+
+ def emit_debug (loc)
+ {
+ // This code locates the debugger right after the condition gets successful or fails.
+ // Used to debug match cases.
+ //
+ unless (_debug_doc == null || loc.IsGeneratedOrEmpty)
+ emit_debug_info (TExpr.DebugInfo (loc, null, null, null));
+ }
+
+ def emit_branch (expr : TExpr, else_label : Label, _debug_loc: Location) {
MaybeMark (expr.Location);
match (expr) {
| Call (OpCode ("=="), [nested_cond,
Parm where (expr = TExpr.TypeConversion(TExpr.Literal(Literal.Bool(true)), _, _, _))], _) =>
- emit_branch(nested_cond.expr, else_label)
+ emit_branch(nested_cond.expr, else_label, Location.Default)
| Call (OpCode (opcode), parms, _) =>
emit_parms (parms);
@@ -686,15 +696,15 @@
_ilg.Emit (OpCodes.Isinst, ty.SystemType);
_ilg.Emit (OpCodes.Brfalse, else_label);
- | If (new_cond, new_then, new_else) =>
+ | If (new_cond, new_then, new_else, _, _) =>
def my_label_else = _ilg.DefineLabel ();
def my_label_fi = _ilg.DefineLabel ();
- emit_branch (new_cond, my_label_else);
- emit_branch (new_then, else_label);
+ emit_branch (new_cond, my_label_else, Location.Default);
+ emit_branch (new_then, else_label, Location.Default);
unless (new_then.Throws)
_ilg.Emit (OpCodes.Br, my_label_fi);
_ilg.MarkLabel (my_label_else);
- emit_branch (new_else, else_label);
+ emit_branch (new_else, else_label, Location.Default);
_ilg.MarkLabel (my_label_fi);
| e when is_always_true (e) => ()
@@ -707,8 +717,23 @@
limited_debug_nesting++;
emit (expr);
limited_debug_nesting--;
+
unless (expr.Throws)
+ {
+ //if (_debug_doc == null || debug_loc.IsGeneratedOrEmpty)
+ //{
_ilg.Emit (OpCodes.Brfalse, else_label);
+ //}
+ //else
+ //{
+ // def debug_label = _ilg.DefineLabel ();
+
+ // _ilg.Emit (OpCodes.Brtrue, debug_label);
+ // emit_debug (debug_loc);
+ // _ilg.Emit (OpCodes.Br, else_label);
+ // _ilg.MarkLabel (debug_label);
+ //}
+ }
}
}
@@ -731,9 +756,10 @@
}
limited_debug_nesting++;
- emit_branch (cond_expr, label_condition_else);
+ emit_branch (cond_expr, label_condition_else, else_debug_loc);
limited_debug_nesting--;
+ emit_debug (then_debug_loc);
emit (then_expr);
unless (then_expr.Throws)
_ilg.Emit (OpCodes.Br, label_condition_fi);
@@ -1519,6 +1545,7 @@
| _ => emit_literal (l);
}
else if (l is Literal.Void) {
+ // IT.TEMP ???
when (IsDebugEnabled) {
_ilg.Emit (OpCodes.Nop);
}
@@ -1654,24 +1681,28 @@
}
else
{
- def emit_debug(line, col, eline, ecol)
+ 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;
match (di.pexpr)
{
- | Sequence => emit_debug(l.Line, l.Column, l.Line, l.Column + 1);
- | _ => emit_debug(l.Line, l.Column, l.EndLine, l.EndColumn);
+ | Sequence => emit_debug (l.Line, l.Column, l.Line, l.Column + 1);
+ | _ => emit_debug (l.Line, l.Column, l.EndLine, l.EndColumn);
}
- emit(di.expr);
+ when (di.expr != null)
+ emit (di.expr);
match (di.pexpr)
{
- | Sequence => emit_debug(l.EndLine, l.EndColumn - 1, l.EndLine, l.EndColumn);
+ | Sequence => emit_debug (l.EndLine, l.EndColumn - 1, l.EndLine, l.EndColumn);
| _ => ()
}
}
@@ -2301,7 +2332,6 @@
public DeclareLocal (localType : Type, pinned : bool) : LocalBuilder { _ilg.DeclareLocal(localType, pinned) }
public DefineLabel () : Label { _ilg.DefineLabel() }
- public MarkLabel (loc : Label ) : void { _ilg.MarkLabel(loc) }
public Emit (opcode : OpCode) : void { Emited(); _ilg.Emit(opcode) }
public Emit (opcode : OpCode, arg : byte) : void { Emited(); _ilg.Emit(opcode, arg) }
@@ -2332,22 +2362,35 @@
public EmitWriteLine (localBuilder : LocalBuilder) : void { _ilg.EmitWriteLine(localBuilder) }
public EmitWriteLine (value : string) : void { _ilg.EmitWriteLine(value) }
- private mutable _justMarked : bool;
+ public MarkLabel (loc : Label ) : void
+ {
+ when (_marked)
+ {
+ _marked = false;
+
+ // Hide from the debugger.
+ //
+ _ilg.MarkSequencePoint (_document, 0xFeeFee, 0, 0xFeeFee, 0);
+ _ilg.Emit (OpCodes.Nop);
+ }
+
+ _ilg.MarkLabel(loc);
+ }
+
+ private mutable _marked : bool;
+ private mutable _document : ISymbolDocumentWriter;
public MarkSequencePoint (document : ISymbolDocumentWriter, startLine : int, startColumn : int, endLine : int, endColumn : int) : void
{
- when (_justMarked)
- Emit (OpCodes.Nop);
-
_ilg.MarkSequencePoint (document, startLine, startColumn, endLine, endColumn);
- _justMarked = true;
+ _document = document;
+ _marked = true;
}
public UsingNamespace (usingNamespace : string) : void { _ilg.UsingNamespace(usingNamespace) }
private Emited() : void
{
- _justMarked = false;
}
}
Modified: nemerle/trunk/ncc/generation/Typer3.n
==============================================================================
--- nemerle/trunk/ncc/generation/Typer3.n (original)
+++ nemerle/trunk/ncc/generation/Typer3.n Wed Aug 1 05:45:43 2007
@@ -772,7 +772,7 @@
Manager.MarkAsAssigned (fld);
def fldref = TExpr.FieldMember (InternalType.Boolean, thisref, fld);
def for_dispose =
- TExpr.If (InternalType.Void, fldref, handler, VoidLiteral ());
+ TExpr.If (InternalType.Void, fldref, handler, VoidLiteral (), Location.Default, Location.Default);
dispose_expr = TExpr.Sequence (dispose_expr.Type, for_dispose, dispose_expr);
BuildRevSequence (
@@ -1069,7 +1069,7 @@
| TExpr.TupleIndexer (a, _, _)
=> SimpleFlow (a)
- | TExpr.If (c, a, b)
+ | TExpr.If (c, a, b, _, _)
=> fork ( [c, a] :: [c, b] :: [] )
| TExpr.Switch (e, Some (c), cs)
=> fork ([e, c] :: List.Map (cs, x => [e, x[1]]))
@@ -1283,8 +1283,8 @@
| TExpr.TupleIndexer (a, z, x) =>
TExpr.TupleIndexer (o.Location, o.ty, inject (a), z, x)
- | TExpr.If (c, a, b) =>
- TExpr.If (o.Location, o.ty, inject (c), inject (a), inject (b))
+ | TExpr.If (c, a, b, l1, l2) =>
+ TExpr.If (o.Location, o.ty, inject (c), inject (a), inject (b), l1, l2)
| TExpr.Switch (e, Some (c), cs) =>
TExpr.Switch (o.Location, o.ty,
@@ -1987,7 +1987,7 @@
def match_comp = DecisionTreeCompiler.Run (m.Type, _, m.cases);
- def expr =
+ mutable expr =
match (m.cases) {
| [([(p1, TExpr.Literal (Bool (true)), [])], _, _),
([(p2, TExpr.Literal (Bool (true)), [])], _, _)]
@@ -2000,7 +2000,7 @@
});
}
- def expr =
+ expr =
vals.Fold (expr, fun (decl, expr) {
if (decl.InClosure)
expr
@@ -2012,7 +2012,19 @@
}
});
+ unless (expr is TExpr.DebugInfo)
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);
+
+ // expr = TExpr.Sequence (l, expr.Type, expr, di);
+ //}
+
Walk (expr)
}
#endregion
@@ -2150,7 +2162,7 @@
// optimize ifs
- | If (cond, e1, e2) =>
+ | If (cond, e1, e2, l1, l2) =>
match (Walk (cond)) {
| Literal (Bool (lit)) => Walk (if (lit) e1 else e2)
@@ -2163,7 +2175,7 @@
| (Literal (Bool (true)), Literal (Bool (false))) =>
cond
| (e1, e2) =>
- TExpr.If (cond, e1, e2)
+ TExpr.If (cond, e1, e2, l1, l2)
}
}
Modified: nemerle/trunk/ncc/generation/Typer4.n
==============================================================================
--- nemerle/trunk/ncc/generation/Typer4.n (original)
+++ nemerle/trunk/ncc/generation/Typer4.n Wed Aug 1 05:45:43 2007
@@ -272,7 +272,7 @@
else true
} else Throws (e2, allow_try, is_top)
- | If (cond, e1, e2) =>
+ | If (cond, e1, e2, _, _) =>
_ = Throws (cond, allow_try);
def th1 = Throws (e1, allow_try, is_top);
Throws (e2, allow_try, is_top) && th1;
Modified: nemerle/trunk/ncc/main.n
==============================================================================
Modified: nemerle/trunk/ncc/misc/ExprWalker.n
==============================================================================
--- nemerle/trunk/ncc/misc/ExprWalker.n (original)
+++ nemerle/trunk/ncc/misc/ExprWalker.n Wed Aug 1 05:45:43 2007
@@ -584,7 +584,7 @@
| Array (l1, l2) => Go(l1); Go(l2); // { args : list [TExpr]; dimensions : list [TExpr]; }
| DefFunctionsIn(lst, e) => Go(lst); Go(e); // { funs : list [Fun_header]; mutable body : TExpr; }
| Match (e, lst) => Go(e); Go(lst); // { expr : TExpr; cases : list [Match_case]; }
- | If (e1, e2, e3) => Go(e1); Go(e2); Go(e3); // { cond : TExpr; e_then : TExpr; e_else : TExpr; }
+ | If (e1, e2, e3, _, _) => Go(e1); Go(e2); Go(e3); // { cond : TExpr; e_then : TExpr; e_else : TExpr; }
| Switch (e, o, lst) => // { indexing_expr : TExpr; default : option [TExpr]; cases : list [int * TExpr]; }
Go(e);
Modified: nemerle/trunk/ncc/misc/PrettyPrint.n
==============================================================================
--- nemerle/trunk/ncc/misc/PrettyPrint.n (original)
+++ nemerle/trunk/ncc/misc/PrettyPrint.n Wed Aug 1 05:45:43 2007
@@ -993,7 +993,7 @@
| TT.TExpr.Switch (indexing, defl, cases) =>
append ($ "switch ($indexing) $defl $cases")
- | TT.TExpr.If (cond, e1, e2) =>
+ | TT.TExpr.If (cond, e1, e2, _, _) =>
append ("if.real (");
recurse (cond);
append (") {\n");
Modified: nemerle/trunk/ncc/parsing/AST.n
==============================================================================
--- nemerle/trunk/ncc/parsing/AST.n (original)
+++ nemerle/trunk/ncc/parsing/AST.n Wed Aug 1 05:45:43 2007
@@ -118,7 +118,7 @@
public IsGenerated : bool { get { _fileIndex %&& GeneratedMask } }
public MarkAsGenerated() : void { _fileIndex |= GeneratedMask; }
- public IsGeneratedOrEmpty : bool { get { IsGenerated || IsEmpty } }
+ public IsGeneratedOrEmpty : bool { get { IsGenerated || _line == 0 } }
public IsSourceAvailable : bool { get { _line > 0 } }
@@ -472,7 +472,13 @@
public class Located
{
public mutable loc : Location;
- public this () { loc = Location_stack.top (); }
+ public this () {
+ loc = Location_stack.top ();
+#if DEBUG
+ when (this is Nemerle.Compiler.Typedtree.TExpr.DebugInfo)
+ assert(!loc.IsGeneratedOrEmpty);
+#endif
+ }
public this (loc : Location) { this.loc = loc }
public IsGenerated : bool { get { loc.IsGenerated } }
@@ -481,11 +487,11 @@
get { loc }
set
{
-//#if DEBUG
-// when (this is Nemerle.Compiler.Typedtree.TExpr.DebugInfo)
-// assert(!Location.IsGeneratedOrEmpty);
-//#endif
- loc = value
+#if DEBUG
+ when (this is Nemerle.Compiler.Typedtree.TExpr.DebugInfo)
+ assert(!value.IsGeneratedOrEmpty);
+#endif
+ loc = value;
}
}
}
Modified: nemerle/trunk/ncc/typing/DecisionTreeBuilder.n
==============================================================================
--- nemerle/trunk/ncc/typing/DecisionTreeBuilder.n (original)
+++ nemerle/trunk/ncc/typing/DecisionTreeBuilder.n Wed Aug 1 05:45:43 2007
@@ -558,6 +558,7 @@
class TopLevelPattern {
has_guard : bool;
res_id : int;
+ mutable res_loc : Location;
continuation : list [Pattern * bool * int];
skel : Skeleton;
// used to detect shared nodes
@@ -571,7 +572,7 @@
match (continuation) {
| [] => Decision.Failure (Location.Default)
| (pat, has_guard, res_id) :: rest =>
- def p = TopLevelPattern (has_guard, res_id, rest, skel, nodes);
+ def p = TopLevelPattern (has_guard, res_id, pat.Location, rest, skel, nodes);
//Message.Debug ($ "build failure for $continuation ");
p.Build ([(Path.Here (pat.Type), skel, pat)])
}
@@ -584,10 +585,10 @@
{
if (has_guard)
Decision.IfEq (Location.Default, Path.Here (), Con.Guard (),
- Decision.Success (Location.Default, res_id),
+ Decision.Success (res_loc, res_id),
BuildFailure ())
else
- Decision.Success (Location.Default, res_id)
+ Decision.Success (res_loc, res_id)
}
@@ -755,7 +756,7 @@
| (pat, has_guard, res_id) :: rest =>
def skel = Skeleton.Empty ();
def nodes = Hashtable ();
- def p = TopLevelPattern (has_guard, res_id, rest, skel, nodes);
+ def p = TopLevelPattern (has_guard, res_id, pat.Location, rest, skel, nodes);
p.Build ([(Path.Here (pat.Type), skel, pat)])
| _ => assert (false)
}
Modified: nemerle/trunk/ncc/typing/TypedTree.n
==============================================================================
--- nemerle/trunk/ncc/typing/TypedTree.n (original)
+++ nemerle/trunk/ncc/typing/TypedTree.n Wed Aug 1 05:45:43 2007
@@ -386,6 +386,7 @@
public mutable ty : TyVar;
public this () { }
+ public this (loc : Location) { base(loc) }
public SystemType : System.Type
{
@@ -436,16 +437,16 @@
| Wildcard => pat
| As (pat, decl) =>
- As (walk (pat), decl)
+ As (pat.Location, walk (pat), decl)
| Tuple (args) =>
- Tuple (args.Map (walk))
+ Tuple (pat.Location, args.Map (walk))
| Record (args) =>
- Record (args.Map (fun (f, p) { (f, walk (p)) }))
+ Record (pat.Location, args.Map (fun (f, p) { (f, walk (p)) }))
| Application (c, a) =>
- Application (c, walk (a))
+ Application (pat.Location, c, walk (a))
} and walk (pat) {
def res = Util.locate (pat.Location, {
def res = f (pat);
@@ -649,19 +650,19 @@
| TypeConversion { mutable expr : TExpr; target_type : TyVar; kind : ConversionKind;
mutable target_type_location : Location;
- this(loc : Location, tv : TyVar, expr : TExpr, target_type : TyVar, kind : ConversionKind)
+ this (loc : Location, tv : TyVar, expr : TExpr, target_type : TyVar, kind : ConversionKind)
{
- this(loc, tv, expr, target_type, kind, Location.Default);
+ this (loc, tv, expr, target_type, kind, Location.Default);
}
- this(tv : TyVar, expr : TExpr, target_type : TyVar, kind : ConversionKind)
+ this (tv : TyVar, expr : TExpr, target_type : TyVar, kind : ConversionKind)
{
- this(tv, expr, target_type, kind, Location.Default);
+ this (tv, expr, target_type, kind, Location.Default);
}
- this(expr : TExpr, target_type : TyVar, kind : ConversionKind)
+ this (expr : TExpr, target_type : TyVar, kind : ConversionKind)
{
- this(expr, target_type, kind, Location.Default);
+ this (expr, target_type, kind, Location.Default);
}
}
@@ -707,12 +708,13 @@
// it to 1.
| Goto { target : int; mutable try_block : int; }
| DefaultValue
- | If { cond : TExpr; e_then : TExpr; e_else : TExpr; }
+ | If { cond : TExpr; e_then : TExpr; e_else : TExpr;
+ mutable then_debug_loc : Location; mutable else_debug_loc : Location; }
| HasType { expr : TExpr; test_ty : MType; }
| Switch { indexing_expr : TExpr;
default : option [TExpr];
cases : list [int * TExpr]; }
- | DebugInfo { expr : TExpr; pexpr : Nemerle.Compiler.Parsetree.PExpr }
+ | DebugInfo { expr : TExpr; pexpr : Nemerle.Compiler.Parsetree.PExpr; }
public mutable ty : TyVar;
@@ -894,12 +896,12 @@
base (loc);
this.ty = ty;
-//#if DEBUG
-// match (this) {
-// | DebugInfo => assert (!loc.IsGeneratedOrEmpty);
-// | _ => ()
-// }
-//#endif
+#if DEBUG
+ match (this) {
+ | DebugInfo => assert (!loc.IsGeneratedOrEmpty);
+ | _ => ()
+ }
+#endif
}
@@ -1107,16 +1109,17 @@
Match (matched_value, cases)
- | If (cond, e1, e2) =>
+ | If (cond, e1, e2, l1, l2) =>
def cond' = walk (f, cond);
def e1' = walk (f, e1);
def e2' = walk (f, e2);
+
if (cond' : object == cond &&
e1' : object == e1 &&
e2' : object == e2)
null
else
- If (cond', e1', e2')
+ If (cond', e1', e2', l1, l2)
| Switch (ind, defl, cases) =>
Modified: nemerle/trunk/ncc/typing/Typer-PatternTyper.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer-PatternTyper.n (original)
+++ nemerle/trunk/ncc/typing/Typer-PatternTyper.n Wed Aug 1 05:45:43 2007
@@ -483,7 +483,7 @@
"to be subtype of $parent");
*/
def inpat = TypePattern (option_type, pattern);
- Pattern.Application (ti, inpat)
+ Pattern.Application (pattern.Location, ti, inpat)
} else {
ReportError (messenger,
$ "the matched value type "
@@ -717,7 +717,7 @@
| PT.PExpr.Ref
| PT.PExpr.Member =>
- TypeApplication (matched_value_type, pattern, PT.PExpr.Wildcard ())
+ TypeApplication (matched_value_type, pattern, PT.PExpr.Wildcard (pattern.Location))
| PT.PExpr.Call (PT.PExpr.Ref (n), _) when ConstantFolder.is_known_operator (n.Id) =>
Modified: nemerle/trunk/ncc/typing/Typer.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer.n (original)
+++ nemerle/trunk/ncc/typing/Typer.n Wed Aug 1 05:45:43 2007
@@ -3392,7 +3392,7 @@
List.Iter (res, FixupMatchCase)
}
- TExpr.Match (matched_value, res)
+ TExpr.Match (mtch.Location, null, matched_value, res)
}
}
#endregion
Modified: nemerle/trunk/ncc/typing/Typer2.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer2.n (original)
+++ nemerle/trunk/ncc/typing/Typer2.n Wed Aug 1 05:45:43 2007
@@ -1223,7 +1223,7 @@
// We allow try here because matched value is pushed on the
// stack first so it is clean (if it was).
def matched = Walk (ctx & Context.AllowTry, matched_value);
- TExpr.Match (matched, cases)
+ TExpr.Match (expr.Location, null, matched, cases)
| TExpr.Throw (exn) =>
@@ -1374,8 +1374,8 @@
Walk (ctx, ExpandBlock (b))
- | TExpr.If (cond, e1, e2) =>
- TExpr.If (Walk (cond), Walk (ctx, e1), Walk (ctx, e2))
+ | TExpr.If (cond, e1, e2, l1, l2) =>
+ TExpr.If (Walk (cond), Walk (ctx, e1), Walk (ctx, e2), l1, l2)
| TExpr.HasType (e, t) =>
More information about the svn
mailing list