org.vishia.java2C
Class Method

java.lang.Object
  extended by org.vishia.java2C.Method

public class Method
extends java.lang.Object

Describes a method of a class.

All methods of a class are stored in the private attribute ClassData.methods, filled using #addMethod(String sNameJava, String sCName, int modifier, LocalIdents.IdentInfos returnType, ClassData[] paramsType) and there derivatives.
A Method of class can be find out calling ClassData#searchMethod(String, List, boolean) with given name and given actual Parameters


Field Summary
private  boolean bUnambiguousness
          Set true if more as one methode with the same name is stored.
 ClassData declaringClass
          The class which declares the implementation of the method. .
 ClassData firstDeclaringClass
          The class which declares the method primary.
private  short idxMtbl
          If it is an overrideable method, its number in InheritanceInfo.
private  LocalIdents methodIdents
          The idents which are seen in the methods focus.
 int mode
          Some mode bits, ones of modeNoThCxt, modeStatic.
static int modeCtor
          Set if it is a ctor.
static int modeCtorAnonymous
          Set if it is a ctor of an anonymous class.
static int modeCtorNonStatic
          Set if it is a ctor of a non-static inner class.
static int modeNoStacktrace
           
static int modeNoThCxt
          Modifier bit, when set the method has ThCxt as last argument.
static int modeOverrideable
          Modifier bit, when set the method is overrideable (virtual).
static int modeReturnNew
          Modifier bit, when set the method returns a new created instance which isn't activated for garbabe collection.
static int modeReturnNonPersistring
          Modifier bit, when set, the method returns a StringJc-instance, which's String is replaced in the thread context or it isn't persistent in other way.
static int modeReturnThis
          Modifier bit, when set the method returns the same instance as the calling one.
static int modeStatic
          Modifier bit, when set the method is static.
static int modeUnknownMethod
           
 boolean need_thCxt
          Set if _thCxt is need in method calls
 FieldData[] paramsType
          All argument type of the method.
 Method primaryMethod
          Reference to a primary method if the method overloads another method, else null.
 FieldData returnType
          Return type of the method.
 java.lang.String sCName
          Name of the method used in C, with suffixes.
 java.lang.String sImplementationName
          Name of the implementation of the method, null if not exists (interface).
 java.lang.String sJavaName
          Name of the method used in Java.
 java.lang.String sKeyName
          Search name of method in Map ClassData.methods.
(package private)  java.lang.String sMethodFormalListDefiniton
          The parameter definition after the method name.
private  java.lang.String sMethodShortDescription
          The method head definition is set, if a method is parsed in first pass.
 java.lang.String sMethodTypeName
          The first name of the method in an overridden-sequence.
 java.lang.String sNameUnambiguous
          Name of the method in method tables, base name of the method.
 java.lang.String sPathToBase
          If the method is declared in a base class or interface too, it is the path necessary to address the base class or interface started from ythis
 java.lang.String sPathToMtbl
          If the method is declared in a base class or interface too, it is the path to the method table-part.
(package private)  java.lang.String sReturnTypeDefinition
           
 
Constructor Summary
Method(ClassData declaringClass, Method primaryMethodP, java.lang.String sKeyName, java.lang.String sNameJava, java.lang.String sNameUnambiguous, java.lang.String sImplementationName, int modifier, FieldData returnType, FieldData[] params, java.lang.String sPathToMtbl, java.lang.String sPathToBase)
          Initializes a method to store in ClassData.
 
Method Summary
(package private)  int checkParameter(java.util.List<CCodeData> paramsTypeCheck)
          Checks whether all parameters from an actual method call are matching
 java.lang.String gen_MethodForwardDeclaration()
          Gets the definition of a method head for the C-code.
 java.lang.String gen_MethodHeadDefinition()
          Gets the definition of a method (C-code), used in second pass.
 int getIdxMtbl()
          Returns -1 if it is a final method, or 0..., the index in the InheritanceInfo.
 LocalIdents getMethodIdents()
           
 boolean isAmbigous()
          Returns true, if more as one method with the same java name and the same number of arguments exists.
 boolean isOverrideable()
          Returns true if the method is able to override (dynamic linked) in an inheriting class.
 boolean isReturnNew()
          Returns true if the method returns a new instance which isn't activated for garbage collection.
 boolean isReturnNonPersistring()
          Returns true if the method returns a new instance which isn't activated for garbage collection.
 boolean isReturnThis()
          Returns true if the method returns its own calling instance.
 boolean isStatic()
          Returns true if the method is static.
 boolean isUnknownMethod()
          Returns true if the method is auto-created while used, it is not defined.
 boolean noStacktrace()
          Returns true if the method is able to override (dynamic linked) in an inheriting class.
 void putFieldIdent(FieldData field)
           
(package private)  boolean sameParameterTypes(FieldData[] paramsTypeCheck)
          Checks all parameter of the method with given parameter set.
(package private)  void setAmbiguousness()
          Sets the method ambiguous.
 void setMethodHeadDefiniton(java.lang.String description, java.lang.String retType, java.lang.String def)
          Sets the definiton of a method (C-code).
 void setMethodIdents(LocalIdents methodIdents)
           
(package private)  void stop()
           
 java.lang.String toString()
          Helpfull for debugging in eclipse.
 java.lang.String writeStruct()
          Writes the structure information of the method for file.stc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sJavaName

public final java.lang.String sJavaName
Name of the method used in Java.


sKeyName

public final java.lang.String sKeyName
Search name of method in Map ClassData.methods. It is the sJavaName plus #9 where 9 symbols the number of arguments.


sCName

public final java.lang.String sCName
Name of the method used in C, with suffixes. If the method is able to override, this is not the implementation name but the name of calling from user. The implementation of this method uses the method table to call the correct implementation.


sMethodTypeName

public final java.lang.String sMethodTypeName
The first name of the method in an overridden-sequence. The method has the postfix of the first declaring interfaces or class, see declaringClass. This identifier is used to build the MT_NAME-identifier in the method table, see ClassData.gen_MethodTableDefinitionContent(). null if the method doesn't override any other and the method won't be overridden.


sImplementationName

public final java.lang.String sImplementationName
Name of the implementation of the method, null if not exists (interface). If the method is able to override, than the name has the suffix _F.


sNameUnambiguous

public final java.lang.String sNameUnambiguous
Name of the method in method tables, base name of the method. It is the Java-name if the method is only found with one set of parameter types. If the same Java-name is used for several methods with different parameter sets, this name is unambiguous. It contains the type of paramter as short information.


primaryMethod

public final Method primaryMethod
Reference to a primary method if the method overloads another method, else null.


sPathToMtbl

public final java.lang.String sPathToMtbl
If the method is declared in a base class or interface too, it is the path to the method table-part. Elsewhere it is null. This attribute is able to use also to detect whether the method is virtual.


sPathToBase

public final java.lang.String sPathToBase
If the method is declared in a base class or interface too, it is the path necessary to address the base class or interface started from ythis


paramsType

public final FieldData[] paramsType
All argument type of the method.


returnType

public final FieldData returnType
Return type of the method.


firstDeclaringClass

public final ClassData firstDeclaringClass
The class which declares the method primary. It may be an interface or superclass or the creating class itself, if the method are not found in deeper base.


declaringClass

public ClassData declaringClass
The class which declares the implementation of the method. .


methodIdents

private LocalIdents methodIdents
The idents which are seen in the methods focus. This element remains with null, if the methode is only declared, no body is generated (external classes without code generation).


need_thCxt

public final boolean need_thCxt
Set if _thCxt is need in method calls


sMethodShortDescription

private java.lang.String sMethodShortDescription
The method head definition is set, if a method is parsed in first pass. It is used in the second path.


sReturnTypeDefinition

java.lang.String sReturnTypeDefinition

sMethodFormalListDefiniton

java.lang.String sMethodFormalListDefiniton
The parameter definition after the method name.


modeCtor

public static final int modeCtor
Set if it is a ctor.

See Also:
Constant Field Values

modeCtorNonStatic

public static final int modeCtorNonStatic
Set if it is a ctor of a non-static inner class.

See Also:
Constant Field Values

modeCtorAnonymous

public static final int modeCtorAnonymous
Set if it is a ctor of an anonymous class.

See Also:
Constant Field Values

modeNoThCxt

public static final int modeNoThCxt
Modifier bit, when set the method has ThCxt as last argument. If not set, than it is a simple method without exceptions, so the thread context pointer may be overmuch.

See Also:
Constant Field Values

modeNoStacktrace

public static final int modeNoStacktrace
See Also:
Constant Field Values

modeStatic

public static final int modeStatic
Modifier bit, when set the method is static.

See Also:
Constant Field Values

modeOverrideable

public static final int modeOverrideable
Modifier bit, when set the method is overrideable (virtual).

See Also:
Constant Field Values

modeReturnThis

public static final int modeReturnThis
Modifier bit, when set the method returns the same instance as the calling one.

See Also:
Constant Field Values

modeReturnNew

public static final int modeReturnNew
Modifier bit, when set the method returns a new created instance which isn't activated for garbabe collection.

See Also:
Constant Field Values

modeReturnNonPersistring

public static final int modeReturnNonPersistring
Modifier bit, when set, the method returns a StringJc-instance, which's String is replaced in the thread context or it isn't persistent in other way.

See Also:
Constant Field Values

modeUnknownMethod

public static final int modeUnknownMethod
See Also:
Constant Field Values

mode

public final int mode
Some mode bits, ones of modeNoThCxt, modeStatic.


bUnambiguousness

private boolean bUnambiguousness
Set true if more as one methode with the same name is stored.


idxMtbl

private short idxMtbl
If it is an overrideable method, its number in InheritanceInfo. Else -1.

Constructor Detail

Method

public Method(ClassData declaringClass,
              Method primaryMethodP,
              java.lang.String sKeyName,
              java.lang.String sNameJava,
              java.lang.String sNameUnambiguous,
              java.lang.String sImplementationName,
              int modifier,
              FieldData returnType,
              FieldData[] params,
              java.lang.String sPathToMtbl,
              java.lang.String sPathToBase)
Initializes a method to store in ClassData.

Parameters:
declaringClass - The class which declares this method.
primaryMethodP - null or the method of the super-class or interface. If the method is not an implementation of a super- or interface-declared method, it is null
sKeyName - Name to search
sNameJava - Name of the method in Java
sNameUnambiguous - Name of the method to translate in C. If more than 1 method with the same sNameJava is given, the sCName should be unambiguous. But it is without suffix of className.
sImplementationName - null if the implementation is not override-able. If the method is override-able and this param is null, than the suffix for the implementationName is "_F". Elsewhere it defines the sImplementationName-attribute of the class.
modifier - see mode
returnType - The type of return. It isn't a Classdata, but a IdentInfo, because some additional properties like return by value or reference should be present.
params - Array of all argument types.
sPathToMtbl -
sPathToBase -
Method Detail

setMethodHeadDefiniton

public void setMethodHeadDefiniton(java.lang.String description,
                                   java.lang.String retType,
                                   java.lang.String def)
Sets the definiton of a method (C-code). This method could only call one time.


gen_MethodForwardDeclaration

public java.lang.String gen_MethodForwardDeclaration()
Gets the definition of a method head for the C-code.


gen_MethodHeadDefinition

public java.lang.String gen_MethodHeadDefinition()
Gets the definition of a method (C-code), used in second pass.


putFieldIdent

public void putFieldIdent(FieldData field)

setAmbiguousness

void setAmbiguousness()
Sets the method ambiguous. This method is called, if a method with the same java name and the same number of arguments, but other argument types are found in translation process.


checkParameter

int checkParameter(java.util.List<CCodeData> paramsTypeCheck)
Checks whether all parameters from an actual method call are matching

Parameters:
paramsTypeCheck -
Returns:
The score 0..4 see ClassData.CastInfo.kCastAble.

sameParameterTypes

boolean sameParameterTypes(FieldData[] paramsTypeCheck)
Checks all parameter of the method with given parameter set.

Parameters:
paramsTypeCheck -
Returns:
true only if are the same parameter.

isAmbigous

public boolean isAmbigous()
Returns true, if more as one method with the same java name and the same number of arguments exists.


noStacktrace

public boolean noStacktrace()
Returns true if the method is able to override (dynamic linked) in an inheriting class.


isOverrideable

public boolean isOverrideable()
Returns true if the method is able to override (dynamic linked) in an inheriting class.


isReturnThis

public boolean isReturnThis()
Returns true if the method returns its own calling instance.


isReturnNew

public boolean isReturnNew()
Returns true if the method returns a new instance which isn't activated for garbage collection.


isReturnNonPersistring

public boolean isReturnNonPersistring()
Returns true if the method returns a new instance which isn't activated for garbage collection.


isStatic

public boolean isStatic()
Returns true if the method is static.


isUnknownMethod

public boolean isUnknownMethod()
Returns true if the method is auto-created while used, it is not defined.


writeStruct

public java.lang.String writeStruct()
Writes the structure information of the method for file.stc. The structure information is parsed to know the class with its method without processing the first pass of translation, if the file.java is older as existing file.h and file.c

Returns:
String with the informations for the file.stc.

getIdxMtbl

public int getIdxMtbl()
Returns -1 if it is a final method, or 0..., the index in the InheritanceInfo.


toString

public java.lang.String toString()
Helpfull for debugging in eclipse.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

getMethodIdents

public final LocalIdents getMethodIdents()

setMethodIdents

public final void setMethodIdents(LocalIdents methodIdents)

stop

void stop()