[svn] r6167: nemerle/trunk/ncc: testsuite/positive/macrolib.n testsuite/positive/macroprog.n typing/Macros...

nazgul svnadmin at nemerle.org
Wed Mar 29 21:31:49 CEST 2006


Log:
Layer of hack also for quotation of literals with explicit type

Author: nazgul
Date: Wed Mar 29 21:31:47 2006
New Revision: 6167

Modified:
   nemerle/trunk/ncc/testsuite/positive/macrolib.n
   nemerle/trunk/ncc/testsuite/positive/macroprog.n
   nemerle/trunk/ncc/typing/Macros.n

Modified: nemerle/trunk/ncc/testsuite/positive/macrolib.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/macrolib.n	(original)
+++ nemerle/trunk/ncc/testsuite/positive/macrolib.n	Wed Mar 29 21:31:47 2006
@@ -344,3 +344,9 @@
   }
   <[ () ]>
 }
+
+
+macro ulongLiteral () {
+  def l = <[ $(1UL : ulong) ]>;
+  l
+}
\ No newline at end of file

Modified: nemerle/trunk/ncc/testsuite/positive/macroprog.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/macroprog.n	(original)
+++ nemerle/trunk/ncc/testsuite/positive/macroprog.n	Wed Mar 29 21:31:47 2006
@@ -66,6 +66,8 @@
     metaclass inline_meta { x : int; y : string };
     assert (inline_meta (1, "").X == 1);
     assert (inline_meta (2, "a").Y == "a");
+    
+    System.Console.WriteLine (ulongLiteral ());
   }
 }
 
@@ -267,5 +269,6 @@
 LOG: verb logging foobar
 LOG: show me
 Hello!
+1
 END-OUTPUT
 */

Modified: nemerle/trunk/ncc/typing/Macros.n
==============================================================================
--- nemerle/trunk/ncc/typing/Macros.n	(original)
+++ nemerle/trunk/ncc/typing/Macros.n	Wed Mar 29 21:31:47 2006
@@ -203,6 +203,12 @@
                                 $("_N_MacroContexts" : dyn).Get ($(context : int))) ]>
   }
 
+  quoted_name (n : Name) : PExpr
+  {
+    <[ Name.NameInCurrentColor ($(n.Id : string),
+                                $("_N_MacroContexts" : dyn).Get ($(n.context.GetMacroContext() : int))) ]>
+  }
+  
   public QuotedMatchCase (cas : MatchCase) : PExpr
   {
     def guards = cas.patterns;
@@ -734,14 +740,14 @@
                                              MacroColorizer.UseColor, 
                                              MacroColorizer.UseContext)) ]>
           | "dyn" => <[ PExpr.Ref (Name ($val, -1, null)) ]>
-          | "byte" => <[ PExpr.Literal (Literal.FromByte ($val)) ]>
-          | "sbyte" => <[ PExpr.Literal (Literal.FromSByte ($val)) ]>
-          | "short" => <[ PExpr.Literal (Literal.FromShort ($val)) ]>
-          | "ushort" => <[ PExpr.Literal (Literal.FromUShort ($val)) ]>
+          | "byte" => <[ PExpr.TypeEnforcement (PExpr.Literal (Literal.FromByte ($val)), PExpr.Ref ($(quoted_name (ty)))) ]>
+          | "sbyte" => <[ PExpr.TypeEnforcement (PExpr.Literal (Literal.FromSByte ($val)), PExpr.Ref ($(quoted_name (ty)))) ]>
+          | "short" => <[ PExpr.TypeEnforcement (PExpr.Literal (Literal.FromShort ($val)), PExpr.Ref ($(quoted_name (ty)))) ]>
+          | "ushort" => <[ PExpr.TypeEnforcement (PExpr.Literal (Literal.FromUShort ($val)), PExpr.Ref ($(quoted_name (ty)))) ]>
           | "int" => <[ PExpr.Literal (Literal.FromInt ($val)) ]>
-          | "uint" => <[ PExpr.Literal (Literal.FromUInt ($val)) ]>
-          | "long" => <[ PExpr.Literal (Literal.FromLong ($val)) ]>
-          | "ulong" => <[ PExpr.Literal (Literal.FromULong ($val)) ]>
+          | "uint" => <[ PExpr.TypeEnforcement (PExpr.Literal (Literal.FromUInt ($val)), PExpr.Ref ($(quoted_name (ty)))) ]>
+          | "long" => <[ PExpr.TypeEnforcement (PExpr.Literal (Literal.FromLong ($val)), PExpr.Ref ($(quoted_name (ty)))) ]>
+          | "ulong" => <[ PExpr.TypeEnforcement (PExpr.Literal (Literal.FromULong ($val)), PExpr.Ref ($(quoted_name (ty)))) ]>
           | "string" => <[ PExpr.Literal (Literal.String ($val)) ]>
           | "bool" => <[ PExpr.Literal (Literal.Bool ($val)) ]>
           | "char" => <[ PExpr.Literal (Literal.Char ($val)) ]>



More information about the svn mailing list