db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r539142 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/compile/ impl/sql/compile/
Date Thu, 17 May 2007 22:10:44 GMT
Author: djd
Date: Thu May 17 15:10:43 2007
New Revision: 539142

URL: http://svn.apache.org/viewvc?view=rev&rev=539142
Log:
Cleanup TypeCompiler.generateNull() and generateDataValue() to not pass the base class name
since
it is not required. Add comments to BaseTypeCompiler's implementation of these methods
describing what they are doing.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java?view=diff&rev=539142&r1=539141&r2=539142
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/compile/TypeCompiler.java Thu
May 17 15:10:43 2007
@@ -184,11 +184,10 @@
 	 * @param collationType For character DVDs, this will be used to determine
 	 *   what Collator should be associated with the DVD which in turn will 
 	 *   decide whether to generate CollatorSQLcharDVDs or SQLcharDVDs.
-	 * @param className name of the base class of the activation's hierarchy
 	 */
 
 	void generateNull(ExpressionClassBuilder eb,
-			MethodBuilder mb, int collationType, String className);
+			MethodBuilder mb, int collationType);
 
 
 	/**
@@ -209,13 +208,12 @@
 	 *   what Collator should be associated with the DVD which in turn will 
 	 *   decide whether to generate CollatorSQLcharDVDs or SQLcharDVDs. For 
 	 *   other types of DVDs, this parameter will be ignored.
-	 * @param className name of the base class of the activation's hierarchy
 	 * @param field LocalField
 	 */
 	void generateDataValue(
 			ExpressionClassBuilder eb,
 			MethodBuilder mb, int collationType, 
-			String className, LocalField field);
+			LocalField field);
 
 	/**
 	 * Return the maximum width for this data type when cast to a char type.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java?view=diff&rev=539142&r1=539141&r2=539142
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/BaseTypeCompiler.java
Thu May 17 15:10:43 2007
@@ -93,10 +93,24 @@
 										);
 	}
 
-	/** @see TypeCompiler#generateNull(ExpressionClassBuilder, MethodBuilder, int, String)*/
+    /**
+     * The caller will have pushed a DataValueFactory and a null or a value
+     * of the correct type (interfaceName()). Thus upon entry the
+     * stack looks like on of:
+     * ...,dvf,ref
+     * ...,dvf,null
+     * 
+     * This method then sets up to call the required method
+     * on DataValueFactory using the nullMethodName().
+     * The value left on the stack will be a DataValueDescriptor
+     * of the correct type:
+     * 
+     * ...,dvd
+     * 
+     * @see TypeCompiler#generateNull(ExpressionClassBuilder, MethodBuilder, int)
+     */
 	public void generateNull(ExpressionClassBuilder e,
-			MethodBuilder mb, int collationType, 
-			String className)
+			MethodBuilder mb, int collationType)
 	{
 		mb.callMethod(VMOpcode.INVOKEINTERFACE, (String) null,
 									nullMethodName(),
@@ -104,10 +118,42 @@
 									1);
 	}
 
-	/** @see TypeCompiler#generateDataValue(ExpressionClassBuilder, MethodBuilder, int, String,
LocalField) */
-	public void generateDataValue(ExpressionClassBuilder eb,
+    
+    /**
+     * The caller will have pushed a DataValueFactory and  value
+     * of that can be converted to the correct type, e.g. int
+     * for a SQL INTEGER.
+     *  
+     * Thus upon entry the
+     * stack looks like:
+     * ...,dvf,value
+     * 
+     * If field is not null then it is used as the holder
+     * of the generated DataValueDescriptor to avoid object
+     * creations on multiple passes through this code.
+     * The field may contain null or a valid value.
+     * 
+     * This method then sets up to call the required method
+     * on DataValueFactory using the dataValueMethodName().
+     * The value left on the stack will be a DataValueDescriptor
+     * of the correct type:
+     * 
+     * If the field contained a valid value then generated
+     * code will return that value rather than a newly created
+     * object. If field was not-null then the generated code
+     * will set the value of field to be the return from
+     * the DataValueFactory method call. Thus if the field
+     * was empty (set to null) when this code is executed it
+     * will contain the newly generated value, otherwise it
+     * will be reset to the same value.
+     * 
+     * ...,dvd
+     * 
+     * @see TypeCompiler#generateDataValue(ExpressionClassBuilder, MethodBuilder, int, LocalField)
+     */
+    public void generateDataValue(ExpressionClassBuilder eb,
 			MethodBuilder mb, int collationType,
-			String className, LocalField field)
+			LocalField field)
 	{
 		String				interfaceName = interfaceName();
 
@@ -162,12 +208,11 @@
 	 *   what Collator should be associated with the DVD which in turn will 
 	 *   decide whether to generate CollatorSQLcharDVDs or SQLcharDVDs. For 
 	 *   other types of DVDs, this parameter will be ignored.
-	 * @param className name of the base class of the activation's hierarchy
 	 */
-	protected void generateCollationSensitiveDataValue(
+	void generateCollationSensitiveDataValue(
 			ExpressionClassBuilder eb,
 			MethodBuilder mb, 
-			int collationType, String className){		
+			int collationType){		
 		if (collationType == StringDataValue.COLLATION_TYPE_UCS_BASIC)
 			return; 
 		//In case of character DVDs, for territory based collation, we need to 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java?view=diff&rev=539142&r1=539141&r2=539142
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CLOBTypeCompiler.java
Thu May 17 15:10:43 2007
@@ -144,19 +144,18 @@
     	public void generateDataValue(
     			ExpressionClassBuilder eb,
 				MethodBuilder mb, int collationType,
-    			String className, LocalField field)
+    			LocalField field)
     	{
-    		super.generateDataValue(eb, mb, collationType, className, field);
-    		generateCollationSensitiveDataValue(eb, mb, collationType, className);
+    		super.generateDataValue(eb, mb, collationType, field);
+    		generateCollationSensitiveDataValue(eb, mb, collationType);
     	}
 
     	/** @see TypeCompiler#generateNull(ExpressionClassBuilder, MethodBuilder, int, String)*/
     	public void generateNull(
     			ExpressionClassBuilder eb,
-				MethodBuilder mb, int collationType, 
-    			String className)
+				MethodBuilder mb, int collationType)
     	{
-    		super.generateNull(eb, mb, collationType, className);
-    		generateCollationSensitiveDataValue(eb, mb, collationType, className);
+    		super.generateNull(eb, mb, collationType);
+    		generateCollationSensitiveDataValue(eb, mb, collationType);
     	}
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java?view=diff&rev=539142&r1=539141&r2=539142
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CharTypeCompiler.java
Thu May 17 15:10:43 2007
@@ -196,20 +196,19 @@
     	public void generateDataValue(
     			ExpressionClassBuilder eb,
 				MethodBuilder mb, int collationType,
-    			String className, LocalField field)
+    			LocalField field)
     	{
-    		super.generateDataValue(eb, mb, collationType, className, field);
-    		generateCollationSensitiveDataValue(eb, mb, collationType, className);
+    		super.generateDataValue(eb, mb, collationType, field);
+    		generateCollationSensitiveDataValue(eb, mb, collationType);
     	}
 
     	/** @see TypeCompiler#generateNull(ExpressionClassBuilder, MethodBuilder, int, String)*/
     	public void generateNull(
     			ExpressionClassBuilder eb,
-				MethodBuilder mb, int collationType, 
-    			String className)
+				MethodBuilder mb, int collationType)
     	{
-    		super.generateNull(eb, mb, collationType, className);
-    		generateCollationSensitiveDataValue(eb, mb, collationType, className);
+    		super.generateNull(eb, mb, collationType);
+    		generateCollationSensitiveDataValue(eb, mb, collationType);
     	}
 
         protected String dataValueMethodName()

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java?view=diff&rev=539142&r1=539141&r2=539142
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ExpressionClassBuilder.java
Thu May 17 15:10:43 2007
@@ -870,7 +870,7 @@
 	void generateNull(MethodBuilder mb, TypeCompiler tc, int collationType) {
 		pushDataValueFactory(mb);
 		mb.pushNull(tc.interfaceName());
-		tc.generateNull(this, mb, collationType, getBaseClassName());
+		tc.generateNull(this, mb, collationType);
 	}
 
 	/**
@@ -883,7 +883,7 @@
 		pushDataValueFactory(mb);
 		mb.swap(); // need the dvf as the instance
 		mb.cast(tc.interfaceName());
-		tc.generateNull(this, mb, collationType, getBaseClassName());
+		tc.generateNull(this, mb, collationType);
 	}
 
 	/**
@@ -896,7 +896,7 @@
 			int collationType, LocalField field) {
 		pushDataValueFactory(mb);
 		mb.swap(); // need the dvf as the instance
-		tc.generateDataValue(this, mb, collationType, getBaseClassName(), field);
+		tc.generateDataValue(this, mb, collationType, field);
 	}
 
 	

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java?view=diff&rev=539142&r1=539141&r2=539142
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/NumericTypeCompiler.java
Thu May 17 15:10:43 2007
@@ -533,7 +533,7 @@
 	/** @see TypeCompiler#generateDataValue(ExpressionClassBuilder, MethodBuilder, int, String,
LocalField) */
 	public void generateDataValue(ExpressionClassBuilder eb,
 			MethodBuilder mb, int collationType,
-			String className, LocalField field)
+			LocalField field)
 	{
 		if (!JVMInfo.J2ME && getTypeId().isDecimalTypeId())
 		{
@@ -544,7 +544,7 @@
 			mb.upCast("java.lang.Number");
 		}
 
-		super.generateDataValue(eb, mb, collationType, className, field);
+		super.generateDataValue(eb, mb, collationType, field);
 	}
 
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java?view=diff&rev=539142&r1=539141&r2=539142
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/UserDefinedTypeCompiler.java
Thu May 17 15:10:43 2007
@@ -120,12 +120,12 @@
 
 	/** @see TypeCompiler#generateDataValue(ExpressionClassBuilder, MethodBuilder, int, String,
LocalField) */
 	public void generateDataValue(ExpressionClassBuilder eb, MethodBuilder mb, int collationType,
-			String className, LocalField field)
+			LocalField field)
 	{
 		// cast the value to an object for method resolution
 		mb.upCast("java.lang.Object");
 
-		super.generateDataValue(eb, mb, collationType, className, field);
+		super.generateDataValue(eb, mb, collationType, field);
 	}
 
 		



Mime
View raw message