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
464
465 // Push an instance of the newly created class
466 cpg = classGen.getConstantPool();
467 il = methodGen.getInstructionList();
468
469 final int index = cpg.addMethodref(_className, "<init>",
470 "(" + TRANSLET_INTF_SIG
471 + DOM_INTF_SIG
472 + NODE_ITERATOR_SIG
473 + "Z)V");
474 il.append(new NEW(cpg.addClass(_className)));
475 il.append(DUP);
476 il.append(classGen.loadTranslet());
477 il.append(methodGen.loadDOM());
478 il.append(methodGen.loadIterator());
479 il.append(_from != null ? ICONST_1 : ICONST_0);
480 il.append(new INVOKESPECIAL(index));
481
482 // Initialize closure variables
483 for (int i = 0; i < closureLen; i++) {
484 final VariableRefBase varRef = (VariableRefBase) _closureVars.get(i);
485 final VariableBase var = varRef.getVariable();
486 final Type varType = var.getType();
487
488 // Store variable in new closure
489 il.append(DUP);
490 il.append(var.loadInstruction());
491 il.append(new PUTFIELD(
492 cpg.addFieldref(_className, var.getEscapedName(),
493 varType.toSignature())));
494 }
495 }
496
497 public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
498 int index;
499 final ConstantPoolGen cpg = classGen.getConstantPool();
500 final InstructionList il = methodGen.getInstructionList();
501
502 // Push "this" for the call to characters()
503 il.append(classGen.loadTranslet());
504
|
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
464
465 // Push an instance of the newly created class
466 cpg = classGen.getConstantPool();
467 il = methodGen.getInstructionList();
468
469 final int index = cpg.addMethodref(_className, "<init>",
470 "(" + TRANSLET_INTF_SIG
471 + DOM_INTF_SIG
472 + NODE_ITERATOR_SIG
473 + "Z)V");
474 il.append(new NEW(cpg.addClass(_className)));
475 il.append(DUP);
476 il.append(classGen.loadTranslet());
477 il.append(methodGen.loadDOM());
478 il.append(methodGen.loadIterator());
479 il.append(_from != null ? ICONST_1 : ICONST_0);
480 il.append(new INVOKESPECIAL(index));
481
482 // Initialize closure variables
483 for (int i = 0; i < closureLen; i++) {
484 final VariableRefBase varRef = _closureVars.get(i);
485 final VariableBase var = varRef.getVariable();
486 final Type varType = var.getType();
487
488 // Store variable in new closure
489 il.append(DUP);
490 il.append(var.loadInstruction());
491 il.append(new PUTFIELD(
492 cpg.addFieldref(_className, var.getEscapedName(),
493 varType.toSignature())));
494 }
495 }
496
497 public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
498 int index;
499 final ConstantPoolGen cpg = classGen.getConstantPool();
500 final InstructionList il = methodGen.getInstructionList();
501
502 // Push "this" for the call to characters()
503 il.append(classGen.loadTranslet());
504
|