< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Message.java

Print this page


   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * @LastModified: Oct 2017
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xalan.internal.xsltc.compiler;
  23 


  50     }
  51 
  52     public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  53         typeCheckContents(stable);
  54         return Type.Void;
  55     }
  56 
  57     @SuppressWarnings("fallthrough") // at default
  58     public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
  59         final ConstantPoolGen cpg = classGen.getConstantPool();
  60         final InstructionList il = methodGen.getInstructionList();
  61 
  62         // Load the translet (for call to displayMessage() function)
  63         il.append(classGen.loadTranslet());
  64 
  65         switch (elementCount()) {
  66             case 0:
  67                 il.append(new PUSH(cpg, ""));
  68             break;
  69             case 1:
  70                 SyntaxTreeNode child = (SyntaxTreeNode) elementAt(0);
  71                 if (child instanceof Text) {
  72                     il.append(new PUSH(cpg, ((Text) child).getText()));
  73                     break;
  74                 }
  75                 // falls through
  76             default:
  77                 // Push current output handler onto the stack
  78                 il.append(methodGen.loadHandler());
  79 
  80                 // Replace the current output handler by a ToXMLStream
  81                 il.append(new NEW(cpg.addClass(STREAM_XML_OUTPUT)));
  82                 il.append(methodGen.storeHandler());
  83 
  84                 // Push a reference to a StringWriter
  85                 il.append(new NEW(cpg.addClass(STRING_WRITER)));
  86                 il.append(DUP);
  87                 il.append(DUP);
  88                 il.append(new INVOKESPECIAL(
  89                     cpg.addMethodref(STRING_WRITER, "<init>", "()V")));
  90 


   1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * @LastModified: Nov 2017
   4  */
   5 /*
   6  * Licensed to the Apache Software Foundation (ASF) under one or more
   7  * contributor license agreements.  See the NOTICE file distributed with
   8  * this work for additional information regarding copyright ownership.
   9  * The ASF licenses this file to You under the Apache License, Version 2.0
  10  * (the "License"); you may not use this file except in compliance with
  11  * the License.  You may obtain a copy of the License at
  12  *
  13  *      http://www.apache.org/licenses/LICENSE-2.0
  14  *
  15  * Unless required by applicable law or agreed to in writing, software
  16  * distributed under the License is distributed on an "AS IS" BASIS,
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18  * See the License for the specific language governing permissions and
  19  * limitations under the License.
  20  */
  21 
  22 package com.sun.org.apache.xalan.internal.xsltc.compiler;
  23 


  50     }
  51 
  52     public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  53         typeCheckContents(stable);
  54         return Type.Void;
  55     }
  56 
  57     @SuppressWarnings("fallthrough") // at default
  58     public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
  59         final ConstantPoolGen cpg = classGen.getConstantPool();
  60         final InstructionList il = methodGen.getInstructionList();
  61 
  62         // Load the translet (for call to displayMessage() function)
  63         il.append(classGen.loadTranslet());
  64 
  65         switch (elementCount()) {
  66             case 0:
  67                 il.append(new PUSH(cpg, ""));
  68             break;
  69             case 1:
  70                 SyntaxTreeNode child = elementAt(0);
  71                 if (child instanceof Text) {
  72                     il.append(new PUSH(cpg, ((Text) child).getText()));
  73                     break;
  74                 }
  75                 // falls through
  76             default:
  77                 // Push current output handler onto the stack
  78                 il.append(methodGen.loadHandler());
  79 
  80                 // Replace the current output handler by a ToXMLStream
  81                 il.append(new NEW(cpg.addClass(STREAM_XML_OUTPUT)));
  82                 il.append(methodGen.storeHandler());
  83 
  84                 // Push a reference to a StringWriter
  85                 il.append(new NEW(cpg.addClass(STRING_WRITER)));
  86                 il.append(DUP);
  87                 il.append(DUP);
  88                 il.append(new INVOKESPECIAL(
  89                     cpg.addMethodref(STRING_WRITER, "<init>", "()V")));
  90 


< prev index next >