1 /*
2 * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
3 */
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one or more
6 * contributor license agreements. See the NOTICE file distributed with
7 * this work for additional information regarding copyright ownership.
8 * The ASF licenses this file to You under the Apache License, Version 2.0
9 * (the "License"); you may not use this file except in compliance with
10 * the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20 /*
21 * $Id: SyntaxTreeNode.java,v 1.6 2006/06/06 22:34:33 spericas Exp $
22 */
23
24 package com.sun.org.apache.xalan.internal.xsltc.compiler;
25
26 import com.sun.org.apache.bcel.internal.generic.ANEWARRAY;
27 import com.sun.org.apache.bcel.internal.generic.BasicType;
28 import com.sun.org.apache.bcel.internal.generic.CHECKCAST;
29 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
30 import com.sun.org.apache.bcel.internal.generic.DUP_X1;
31 import com.sun.org.apache.bcel.internal.generic.GETFIELD;
32 import com.sun.org.apache.bcel.internal.generic.ICONST;
33 import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
34 import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL;
35 import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
36 import com.sun.org.apache.bcel.internal.generic.InstructionList;
37 import com.sun.org.apache.bcel.internal.generic.NEW;
38 import com.sun.org.apache.bcel.internal.generic.NEWARRAY;
39 import com.sun.org.apache.bcel.internal.generic.PUSH;
40 import com.sun.org.apache.xalan.internal.xsltc.DOM;
41 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
42 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
502 * @param classGen BCEL Java class generator
503 * @param methodGen BCEL Java method generator
504 */
505 protected void translateContents(ClassGenerator classGen,
506 MethodGenerator methodGen) {
507 // Call translate() on all child nodes
508 final int n = elementCount();
509
510 for (SyntaxTreeNode item : _contents) {
511 methodGen.markChunkStart();
512 item.translate(classGen, methodGen);
513 methodGen.markChunkEnd();
514 }
515
516 // After translation, unmap any registers for any variables/parameters
517 // that were declared in this scope. Performing this unmapping in the
518 // same AST scope as the declaration deals with the problems of
519 // references falling out-of-scope inside the for-each element.
520 // (the cause of which being 'lazy' register allocation for references)
521 for (int i = 0; i < n; i++) {
522 if( _contents.get(i) instanceof VariableBase) {
523 final VariableBase var = (VariableBase)_contents.get(i);
524 var.unmapRegister(methodGen);
525 }
526 }
527 }
528
529 /**
530 * Return true if the node represents a simple RTF.
531 *
532 * A node is a simple RTF if all children only produce Text value.
533 *
534 * @param node A node
535 * @return true if the node content can be considered as a simple RTF.
536 */
537 private boolean isSimpleRTF(SyntaxTreeNode node) {
538
539 List<SyntaxTreeNode> contents = node.getContents();
540 for (SyntaxTreeNode item : contents) {
541 if (!isTextElement(item, false))
542 return false;
543 }
544
|
1 /*
2 * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
3 */
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one or more
6 * contributor license agreements. See the NOTICE file distributed with
7 * this work for additional information regarding copyright ownership.
8 * The ASF licenses this file to You under the Apache License, Version 2.0
9 * (the "License"); you may not use this file except in compliance with
10 * the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21 package com.sun.org.apache.xalan.internal.xsltc.compiler;
22
23 import com.sun.org.apache.bcel.internal.generic.ANEWARRAY;
24 import com.sun.org.apache.bcel.internal.generic.BasicType;
25 import com.sun.org.apache.bcel.internal.generic.CHECKCAST;
26 import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
27 import com.sun.org.apache.bcel.internal.generic.DUP_X1;
28 import com.sun.org.apache.bcel.internal.generic.GETFIELD;
29 import com.sun.org.apache.bcel.internal.generic.ICONST;
30 import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
31 import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL;
32 import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
33 import com.sun.org.apache.bcel.internal.generic.InstructionList;
34 import com.sun.org.apache.bcel.internal.generic.NEW;
35 import com.sun.org.apache.bcel.internal.generic.NEWARRAY;
36 import com.sun.org.apache.bcel.internal.generic.PUSH;
37 import com.sun.org.apache.xalan.internal.xsltc.DOM;
38 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
39 import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
499 * @param classGen BCEL Java class generator
500 * @param methodGen BCEL Java method generator
501 */
502 protected void translateContents(ClassGenerator classGen,
503 MethodGenerator methodGen) {
504 // Call translate() on all child nodes
505 final int n = elementCount();
506
507 for (SyntaxTreeNode item : _contents) {
508 methodGen.markChunkStart();
509 item.translate(classGen, methodGen);
510 methodGen.markChunkEnd();
511 }
512
513 // After translation, unmap any registers for any variables/parameters
514 // that were declared in this scope. Performing this unmapping in the
515 // same AST scope as the declaration deals with the problems of
516 // references falling out-of-scope inside the for-each element.
517 // (the cause of which being 'lazy' register allocation for references)
518 for (int i = 0; i < n; i++) {
519 if ( _contents.get(i) instanceof VariableBase) {
520 final VariableBase var = (VariableBase)_contents.get(i);
521 var.unmapRegister(classGen, methodGen);
522 }
523 }
524 }
525
526 /**
527 * Return true if the node represents a simple RTF.
528 *
529 * A node is a simple RTF if all children only produce Text value.
530 *
531 * @param node A node
532 * @return true if the node content can be considered as a simple RTF.
533 */
534 private boolean isSimpleRTF(SyntaxTreeNode node) {
535
536 List<SyntaxTreeNode> contents = node.getContents();
537 for (SyntaxTreeNode item : contents) {
538 if (!isTextElement(item, false))
539 return false;
540 }
541
|