/** * The code that is generated by nested for-each loops can appear to some * JVMs as if it is accessing un-initialized variables. We must add some * code that pushes the default variable value on the stack and pops it * into the variable slot. This is done by the Variable.initialize() * method. The code that we compile for this loop looks like this: * * initialize iterator * initialize variables <-- HERE!!! * goto Iterate * Loop: : * : (code for <xsl:for-each> contents) * : * Iterate: node = iterator.next(); * if (node != END) goto Loop */ public void initializeVariables(ClassGenerator classGen, MethodGenerator methodGen) { final int n = elementCount(); for (int i = 0; i < n; i++) { final Object child = getContents().elementAt(i); if (child instanceof Variable) { Variable var = (Variable)child; var.initialize(classGen, methodGen); } } }
SyntaxTreeNode parent = getParent(); if (parent instanceof Stylesheet) { final int us = this.getImportPrecedence(); final int them = var.getImportPrecedence(); reportError(this, parser, ErrorMsg.VARIABLE_REDEF_ERR,name); var.disable();
_ignore = true; final String name = getEscapedName(); if (isLocal()) { translateValue(classGen, methodGen); mapRegister(methodGen); translateValue(classGen, methodGen);
/** * Runs a type check on either the variable element body or the * expression in the 'select' attribute */ public Type typeCheck(SymbolTable stable) throws TypeCheckError { // Type check the 'select' expression if present if (_select != null) { _type = _select.typeCheck(stable); } // Type check the element contents otherwise else if (hasContents()) { typeCheckContents(stable); _type = Type.ResultTree; } else { _type = Type.Reference; } // The return type is void as the variable element does not leave // anything on the JVM's stack. The '_type' global will be returned // by the references to this variable, and not by the variable itself. return Type.Void; }
/** * This method is part of a little trick that is needed to use local * variables inside nested for-each loops. See the initializeVariables() * method in the ForEach class for an explanation */ public void initialize(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); // This is only done for local variables that are actually used if (isLocal() && !_refs.isEmpty()) { // Create a variable slot if none is allocated if (_local == null) { _local = methodGen.addLocalVariable2(getEscapedName(), _type.toJCType(), null); } // Push the default value on the JVM's stack if ((_type instanceof IntType) || (_type instanceof NodeType) || (_type instanceof BooleanType)) il.append(new ICONST(0)); // 0 for node-id, integer and boolean else if (_type instanceof RealType) il.append(new DCONST(0)); // 0.0 for floating point numbers else il.append(new ACONST_NULL()); // and 'null' for anything else // Mark the store as the start of the live range of the variable _local.setStart(il.append(_type.STORE(_local.getIndex()))); } }
public Variable addVariable(Variable variable) { if (_variables == null) _variables = new Hashtable(); final String name = variable.getName().getStringRep(); return (Variable)_variables.put(name, variable); }
/** * Runs a type check on either the variable element body or the * expression in the 'select' attribute */ public Type typeCheck(SymbolTable stable) throws TypeCheckError { // Type check the 'select' expression if present if (_select != null) { _type = _select.typeCheck(stable); } // Type check the element contents otherwise else if (hasContents()) { typeCheckContents(stable); _type = Type.ResultTree; } else { _type = Type.Reference; } // The return type is void as the variable element does not leave // anything on the JVM's stack. The '_type' global will be returned // by the references to this variable, and not by the variable itself. return Type.Void; }
/** * This method is part of a little trick that is needed to use local * variables inside nested for-each loops. See the initializeVariables() * method in the ForEach class for an explanation */ public void initialize(ClassGenerator classGen, MethodGenerator methodGen) { final ConstantPoolGen cpg = classGen.getConstantPool(); final InstructionList il = methodGen.getInstructionList(); // This is only done for local variables that are actually used if (isLocal() && !_refs.isEmpty()) { // Create a variable slot if none is allocated if (_local == null) { _local = methodGen.addLocalVariable2(getEscapedName(), _type.toJCType(), null); } // Push the default value on the JVM's stack if ((_type instanceof IntType) || (_type instanceof NodeType) || (_type instanceof BooleanType)) il.append(new ICONST(0)); // 0 for node-id, integer and boolean else if (_type instanceof RealType) il.append(new DCONST(0)); // 0.0 for floating point numbers else il.append(new ACONST_NULL()); // and 'null' for anything else // Mark the store as the start of the live range of the variable _local.setStart(il.append(_type.STORE(_local.getIndex()))); } }
/** * Add a node to the current scope and return name of a variable or * parameter if the node represents a variable or a parameter. */ protected QName updateScope(Parser parser, SyntaxTreeNode node) { if (node instanceof Variable) { final Variable var = (Variable)node; parser.addVariable(var); return var.getName(); } else if (node instanceof Param) { final Param param = (Param)node; parser.addParameter(param); return param.getName(); } else { return null; } }
SyntaxTreeNode parent = getParent(); if (parent instanceof Stylesheet) { final int us = this.getImportPrecedence(); final int them = var.getImportPrecedence(); reportError(this, parser, ErrorMsg.VARIABLE_REDEF_ERR,name); var.disable();
_ignore = true; final String name = getEscapedName(); if (isLocal()) { translateValue(classGen, methodGen); mapRegister(methodGen); translateValue(classGen, methodGen);
/** * The code that is generated by nested for-each loops can appear to some * JVMs as if it is accessing un-initialized variables. We must add some * code that pushes the default variable value on the stack and pops it * into the variable slot. This is done by the Variable.initialize() * method. The code that we compile for this loop looks like this: * * initialize iterator * initialize variables <-- HERE!!! * goto Iterate * Loop: : * : (code for <xsl:for-each> contents) * : * Iterate: node = iterator.next(); * if (node != END) goto Loop */ public void initializeVariables(ClassGenerator classGen, MethodGenerator methodGen) { final int n = elementCount(); for (int i = 0; i < n; i++) { final Object child = getContents().elementAt(i); if (child instanceof Variable) { Variable var = (Variable)child; var.initialize(classGen, methodGen); } } }
public Variable addVariable(Variable variable) { if (_variables == null) _variables = new Hashtable(); final String name = variable.getName().getStringRep(); return (Variable)_variables.put(name, variable); }
/** * The code that is generated by nested for-each loops can appear to some * JVMs as if it is accessing un-initialized variables. We must add some * code that pushes the default variable value on the stack and pops it * into the variable slot. This is done by the Variable.initialize() * method. The code that we compile for this loop looks like this: * * initialize iterator * initialize variables <-- HERE!!! * goto Iterate * Loop: : * : (code for <xsl:for-each> contents) * : * Iterate: node = iterator.next(); * if (node != END) goto Loop */ public void initializeVariables(ClassGenerator classGen, MethodGenerator methodGen) { final int n = elementCount(); for (int i = 0; i < n; i++) { final Object child = getContents().elementAt(i); if (child instanceof Variable) { Variable var = (Variable)child; var.initialize(classGen, methodGen); } } }
/** * Add a node to the current scope and return name of a variable or * parameter if the node represents a variable or a parameter. */ protected QName updateScope(Parser parser, SyntaxTreeNode node) { if (node instanceof Variable) { final Variable var = (Variable)node; parser.addVariable(var); return var.getName(); } else if (node instanceof Param) { final Param param = (Param)node; parser.addParameter(param); return param.getName(); } else { return null; } }
/** * The code that is generated by nested for-each loops can appear to some * JVMs as if it is accessing un-initialized variables. We must add some * code that pushes the default variable value on the stack and pops it * into the variable slot. This is done by the Variable.initialize() * method. The code that we compile for this loop looks like this: * * initialize iterator * initialize variables <-- HERE!!! * goto Iterate * Loop: : * : (code for <xsl:for-each> contents) * : * Iterate: node = iterator.next(); * if (node != END) goto Loop */ public void initializeVariables(ClassGenerator classGen, MethodGenerator methodGen) { final int n = elementCount(); for (int i = 0; i < n; i++) { final Object child = getContents().elementAt(i); if (child instanceof Variable) { Variable var = (Variable)child; var.initialize(classGen, methodGen); } } }