tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Carmichael" <ecarm...@alumni.rice.edu>
Subject Re: cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler Generator.java Node.java SmapStratum.java SmapUtil.java
Date Tue, 23 Sep 2003 01:06:22 GMT
> But really, all this is more academic than useful in practice: who do
> you think may need to single step over template text lines?  :-)

No idea.  I'm just trying to make sure Bugzilla 22006 stays fixed.  On the
other hand if you want to WONTFIX that bad boy, I guess I don't have any
good grounds for objecting; the SMAP spec doesn't seem to say anywhere that
SMAPs need to be complete (or even non-empty?  Now there's a way to save
ourselves a bunch of work...).

I see from another message that you've committed a fix for this.  I'll test
your code when I get a chance.

Eric


----- Original Message ----- 
From: "Kin-Man Chung" <Kin-Man.Chung@Eng.Sun.COM>
To: <tomcat-dev@jakarta.apache.org>
Sent: Monday, September 22, 2003 1:00 PM
Subject: Re: cvs commit:
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler
Generator.java Node.java SmapStratum.java SmapUtil.java


> The actual mapping before we optimize the smap is
>
> 1:41
> 2:42
> 6:43
> 6:44
> 8:45
> 8:46
>
> which looks OK to me.  But since we only do the smap at the beginnig of
> the template text, and assume the the input line count is 1, the result is
> what you have noticed.
>
> I'll see if I can add some code to compute the input line ranges, but
> it is going to be messy.  :(
>
> But really, all this is more academic than useful in practice: who do
> you think may need to single step over template text lines?  :-)
>
> -Kin-man
>
> > Date: Sat, 20 Sep 2003 00:18:14 -0700
> > From: Eric Carmichael <ecarmich@alumni.rice.edu>
> > Subject: Re: cvs commit:
> jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler
> Generator.java Node.java SmapStratum.java SmapUtil.java
> > X-Originating-IP: [64.203.49.21]
> > To: Tomcat Developers List <tomcat-dev@jakarta.apache.org>
> > X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
> > X-Priority: 3
> > X-MSMail-priority: Normal
> > X-Originating-Email: [eric_carmichael@hotmail.com]
> > X-OriginalArrivalTime: 20 Sep 2003 07:18:18.0787 (UTC)
> FILETIME=[5DB22F30:01C37F47]
> >
> > cal/cal1.jsp from the jsp-examples webapp starts like this:
> >
> > <HTML>
> > <!-- 
> >   Copyright (c) 1999 The Apache Software Foundation. All rights
> >   reserved.
> > -->
> > <HEAD><TITLE>
> >
> > Before this commit, cal1.jsp's SMAP started like this:
> >
> > *L
> > 1,2:41
> > 3:42
> > 4:42
> > 5:42
> > 6:43,2
> >
> > Now it starts like this:
> >
> > *L
> > 1,2:41
> > 6:43,2
> >
> > I think the reason lines 3, 4, and 5 aren't being SMAPped is that you
only add
> LineInfos inside "if (breakAtLF || count < 0) {".  This adds LineInfos
when the
> output line advances, but not when the input line alone advances.  To SMAP
> template text fully, you have to add a LineInfo every time the line number
> advances in the input file or the output file.
> >
> > Eric
> >
> >
> > ----- Original Message ----- 
> > From: <kinman@apache.org>
> > To: <jakarta-tomcat-jasper-cvs@apache.org>
> > Sent: Tuesday, September 16, 2003 10:46 AM
> > Subject: cvs commit:
> jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler
> Generator.java Node.java SmapStratum.java SmapUtil.java
> >
> >
> > > kinman      2003/09/16 10:46:44
> > >
> > >   Modified:    jasper2/src/share/org/apache/jasper/compiler
Generator.java
> > >                         Node.java SmapStratum.java SmapUtil.java
> > >   Log:
> > >   - For template texts that generate multiple Java lines, addidtional
> mapping
> > >     informantion are kept in the TemplateText node, to aide SMAP
generation.
> > >
> > >   Revision  Changes    Path
> > >   1.208     +23 -14
>
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator
.jav
> a
> > >
> > >   Index: Generator.java
> > >   ===================================================================
> > >   RCS file:
>
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler
/Gen
> erator.java,v
> > >   retrieving revision 1.207
> > >   retrieving revision 1.208
> > >   diff -u -r1.207 -r1.208
> > >   --- Generator.java 15 Sep 2003 13:43:54 -0000 1.207
> > >   +++ Generator.java 16 Sep 2003 17:46:43 -0000 1.208
> > >   @@ -1867,21 +1867,25 @@
> > >                    return;
> > >                }
> > >
> > >   -            if (ctxt.getOptions().genStringAsCharArray()) {
> > >   -                if (textSize <= 3) {
> > >   -                   // Spcial case small text strings
> > >   -                   n.setBeginJavaLine(out.getJavaLine());
> > >   -                   out.printil("out.write(" + quote(text.charAt(0))
+
> ");");
> > >   -                   if (textSize > 1) {
> > >   -                       out.printil("out.write(" +
quote(text.charAt(1)) +
> ");");
> > >   +            if (textSize <= 3) {
> > >   +               // Special case small text strings
> > >   +               n.setBeginJavaLine(out.getJavaLine());
> > >   +               int lineInc = 0;
> > >   +               for (int i = 0; i < textSize; i++) {
> > >   +                   char ch = text.charAt(i);
> > >   +                   out.printil("out.write(" + quote(ch) + ");");
> > >   +                   if (i > 0) {
> > >   +                       n.addSmap(lineInc);
> > >                       }
> > >   -                   if (textSize > 2) {
> > >   -                       out.printil("out.write(" +
quote(text.charAt(2)) +
> ");");
> > >   +                   if (ch == '\n') {
> > >   +                       lineInc++;
> > >                       }
> > >   -                   n.setEndJavaLine(out.getJavaLine());
> > >   -                   return;
> > >                   }
> > >   +               n.setEndJavaLine(out.getJavaLine());
> > >   +               return;
> > >   +           }
> > >
> > >   +            if (ctxt.getOptions().genStringAsCharArray()) {
> > >                   // Generate Strings as char arrays, for performance
> > >                    ServletWriter caOut;
> > >                    if (charArrayBuffer == null) {
> > >   @@ -1915,6 +1919,7 @@
> > >                StringBuffer sb = new StringBuffer("out.write(\"");
> > >                int initLength = sb.length();
> > >                int count = JspUtil.CHUNKSIZE;
> > >   +            int srcLine = 0; // relative to starting srouce line
> > >                for (int i = 0; i < text.length(); i++) {
> > >                    char ch = text.charAt(i);
> > >                    --count;
> > >   @@ -1930,6 +1935,7 @@
> > >                            break;
> > >                        case '\n' :
> > >                            sb.append('\\').append('n');
> > >   +                        srcLine++;
> > >
> > >                            if (breakAtLF || count < 0) {
> > >                                // Generate an out.write() when see a
'\n' in
> template
> > >   @@ -1940,6 +1946,9 @@
> > >                                }
> > >                                sb.setLength(initLength);
> > >                                count = JspUtil.CHUNKSIZE;
> > >   +
> > >   +                            // add a Smap for this line
> > >   +                            n.addSmap(srcLine);
> > >                            }
> > >                            break;
> > >                        case '\t' : // Not sure we need this
> > >
> > >
> > >
> > >   1.77      +24 -4
>
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Node.java
> > >
> > >   Index: Node.java
> > >   ===================================================================
> > >   RCS file:
>
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler
/Nod
> e.java,v
> > >   retrieving revision 1.76
> > >   retrieving revision 1.77
> > >   diff -u -r1.76 -r1.77
> > >   --- Node.java 2 Sep 2003 21:39:59 -0000 1.76
> > >   +++ Node.java 16 Sep 2003 17:46:43 -0000 1.77
> > >   @@ -63,6 +63,7 @@
> > >    import java.util.Iterator;
> > >    import java.util.List;
> > >    import java.util.Vector;
> > >   +import java.util.ArrayList;
> > >
> > >    import javax.servlet.jsp.tagext.BodyTag;
> > >    import javax.servlet.jsp.tagext.DynamicAttributes;
> > >   @@ -1921,6 +1922,8 @@
> > >         */
> > >        public static class TemplateText extends Node {
> > >
> > >   +        private ArrayList extraSmap = null;
> > >   +
> > >    public TemplateText(String text, Mark start, Node parent) {
> > >        super(null, null, text, start, parent);
> > >    }
> > >   @@ -1957,13 +1960,30 @@
> > >    public boolean isAllSpace() {
> > >        boolean isAllSpace = true;
> > >        for (int i=0; i<text.length(); i++) {
> > >   - if (!Character.isSpace(text.charAt(i))) {
> > >   + if (!Character.isWhitespace(text.charAt(i))) {
> > >        isAllSpace = false;
> > >        break;
> > >    }
> > >        }
> > >        return isAllSpace;
> > >    }
> > >   +
> > >   +        /**
> > >   +         * Add a source to Java line mapping
> > >   +         * @param srcLine The postion of the source line, relative
to the
> line
> > >   +         *        at the start of this node.  The corresponding
java line
> is
> > >   +         *        assumed to be consecutive, i.e. one more than the
last.
> > >   +         */
> > >   +        public void addSmap(int srcLine) {
> > >   +            if (extraSmap == null) {
> > >   +                extraSmap = new ArrayList();
> > >   +            }
> > >   +            extraSmap.add(new Integer(srcLine));
> > >   +        }
> > >   +
> > >   +        public ArrayList getExtraSmap() {
> > >   +            return extraSmap;
> > >   +        }
> > >        }
> > >
> > >
> /*********************************************************************
> > >
> > >
> > >
> > >   1.11      +6 -0
>
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/SmapStrat
um.j
> ava
> > >
> > >   Index: SmapStratum.java
> > >   ===================================================================
> > >   RCS file:
>
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler
/Sma
> pStratum.java,v
> > >   retrieving revision 1.10
> > >   retrieving revision 1.11
> > >   diff -u -r1.10 -r1.11
> > >   --- SmapStratum.java 31 Aug 2003 03:46:29 -0000 1.10
> > >   +++ SmapStratum.java 16 Sep 2003 17:46:43 -0000 1.11
> > >   @@ -210,6 +210,12 @@
> > >         */
> > >        public void optimizeLineSection() {
> > >
> > >   +/* Some debugging code
> > >   +        for (int i = 0; i < lineData.size(); i++) {
> > >   +            LineInfo li = (LineInfo)lineData.get(i);
> > >   +            System.out.print(li.toString());
> > >   +        }
> > >   +*/
> > >            //Incorporate each LineInfo into the previous LineInfo's
> > >            //outputLineIncrement, if possible
> > >            int i = 0;
> > >
> > >
> > >
> > >   1.19      +8 -16
>
jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/SmapUtil.
java
> > >
> > >   Index: SmapUtil.java
> > >   ===================================================================
> > >   RCS file:
>
/home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler
/Sma
> pUtil.java,v
> > >   retrieving revision 1.18
> > >   retrieving revision 1.19
> > >   diff -u -r1.18 -r1.19
> > >   --- SmapUtil.java 25 Aug 2003 03:58:48 -0000 1.18
> > >   +++ SmapUtil.java 16 Sep 2003 17:46:43 -0000 1.19
> > >   @@ -77,6 +77,7 @@
> > >     * @author Shawn Bayern
> > >     * @author Robert Field (inner SDEInstaller class)
> > >     * @author Mark Roth
> > >   + * @author Kin-man Chung
> > >     */
> > >    public class SmapUtil {
> > >
> > >   @@ -613,25 +614,16 @@
> > >                int iOutputStartLine = n.getBeginJavaLine();
> > >                smap.addLineData(iInputStartLine, fileName, 1,
> iOutputStartLine, 1);
> > >
> > >   -            //Walk through the node text the same way
Generator.java's
> > >   -            //visit(Node.TemplateText n) does.  Every time the
> > >   -            //line number advances in the input file or the output
file,
> > >   -            //add a LineInfo with the new line numbers.
> > >   -            String text = n.getText();
> > >   -            int count = JspUtil.CHUNKSIZE;
> > >   -            for (int i = 0; i < text.length() - 1; i++) {
> > >   -                --count;
> > >   -                if (text.charAt(i) == '\n') {
> > >   -                    iInputStartLine++;
> > >   -                    if (breakAtLF || count < 0) {
> > >   -                        iOutputStartLine++;
> > >   -                        count = JspUtil.CHUNKSIZE;
> > >   -                    }
> > >   +            // Output additional mappings in the text
> > >   +            java.util.ArrayList extraSmap = n.getExtraSmap();
> > >   +
> > >   +            if (extraSmap != null) {
> > >   +                for (int i = 0; i < extraSmap.size(); i++) {
> > >                        smap.addLineData(
> > >   -                        iInputStartLine,
> > >   +
> iInputStartLine+((Integer)extraSmap.get(i)).intValue(),
> > >                            fileName,
> > >                            1,
> > >   -                        iOutputStartLine,
> > >   +                        ++iOutputStartLine,
> > >                            1);
> > >                    }
> > >                }
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> > >
> > >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>
>

Mime
View raw message