Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 57121bc6 authored by PECHOUX Romain's avatar PECHOUX Romain
Browse files

some comments reformats in the listeners package

parent 8f7e7923
Branches
Tags
No related merge requests found
......@@ -28,7 +28,7 @@ import java.util.List;
/**
* A class representing the call graph of a program.
* The strongly connected components correspond to mutually recursive methods.
* The strongly connected components correspond to recursive and mutually recursive methods.
*/
public class CallGraphBuilder extends JavaParserBaseListener {
private Graph graph;
......@@ -52,8 +52,8 @@ public class CallGraphBuilder extends JavaParserBaseListener {
}
/**
* @param ctx - a parse tree
* @return the blocknumber associated with the parse tree ctx in the ParseTreeProperty<Integer> blockNumbers.
* @param ctx - a parse tree.
* @return the block number associated to the parse tree #ctx in the #ParseTreeProperty<Integer> #blockNumbers.
*/
private int getBlockNumber(ParseTree ctx) {
return blockNumbers.get(ctx);
......@@ -61,7 +61,7 @@ public class CallGraphBuilder extends JavaParserBaseListener {
/**
* @param ctx - a parse tree
* @return a string representation of the type of the expression corresponding to the parse tree ctx.
* @return a string representation of the type of the expression corresponding to the parse tree #ctx.
*/
private String getType(ParseTree ctx) {
return types.get(ctx);
......@@ -69,16 +69,17 @@ public class CallGraphBuilder extends JavaParserBaseListener {
/**
*
* @return the graph
* @return the graph.
*/
public Graph getGraph() {
return graph;
}
/**
* Handles method declarations in the parse tree by creating the namespace
* and by creating a corresponding node in the call graph
* @param ctx - a parse tree
* Handles method declarations in the parse tree by creating the method namespace
* and by creating a corresponding node in the call graph.
* If the node already exists then its context attribute is set to the method declaration context #ctx.
* @param ctx - a parse tree.
*/
@Override
public void enterMethodDeclaration(JavaParser.MethodDeclarationContext ctx) {
......@@ -95,8 +96,8 @@ public class CallGraphBuilder extends JavaParserBaseListener {
}
/**
* see {@link #enterMethodDeclaration(JavaParser.MethodDeclarationContext ctx)}
* @param ctx - a constructor declaration context
* see {@link #enterMethodDeclaration(JavaParser.MethodDeclarationContext ctx)}.
* @param ctx - a constructor declaration context.
*/
@Override
public void enterConstructorDeclaration(JavaParser.ConstructorDeclarationContext ctx) {
......@@ -106,7 +107,7 @@ public class CallGraphBuilder extends JavaParserBaseListener {
/**
* Handles the exit of a method declaration block.
* @param ctx - a method declaration context
* @param ctx - a method declaration context.
*/
@Override
public void exitMethodDeclaration(JavaParser.MethodDeclarationContext ctx) {
......@@ -116,7 +117,7 @@ public class CallGraphBuilder extends JavaParserBaseListener {
/**
* Handles the exit of a constructor declaration block.
* @param ctx - a constructor declaration context
* @param ctx - a constructor declaration context.
*/
@Override
public void exitGenericConstructorDeclaration(JavaParser.GenericConstructorDeclarationContext ctx) {
......@@ -127,7 +128,7 @@ public class CallGraphBuilder extends JavaParserBaseListener {
/**
* Handles method calls by creating their namespace and by adding an arrow from the current namespace to
* the namespace of the called function in the graph.
* @param ctx - an expression call context
* @param ctx - an expression call context.
*/
@Override
public void exitExpression_call(JavaParser.Expression_callContext ctx) {
......@@ -163,12 +164,12 @@ public class CallGraphBuilder extends JavaParserBaseListener {
}
String namespace = TOS.buildMethodNamespace(param, type, name);
//No check (currentNamespace == null) should be necessary.
//If currentNamespace == null then a bug is present but elsewhere (probably) in this class.
//If currentNamespace == null then a bug is present but elsewhere (probably in this class).
if(!currentNamespace.equals("constructor")) {
graph.addConnection(currentNamespace, namespace);
}
//If the method calls itself (so not mutually recursive) then a special property needs to be added
//to simplify the difference between normal recursive and mutually recursive methods.
//to simplify the difference between recursive methods and mutually recursive methods.
if(namespace.equals(currentNamespace)) {
graph.get(currentNamespace).setRecursive(true);
}
......
......@@ -32,7 +32,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* A basic listener (visitor) exploring the parse tree and filling the TOS with the appropriate symbols id and tiered type.
* A basic listener (visitor) exploring the parse tree and filling the TOS with the appropriate symbol id and tiered type.
*/
public class TOSBuilder extends JavaParserBaseListener {
......@@ -114,7 +114,7 @@ public class TOSBuilder extends JavaParserBaseListener {
}
/**
* Sets the default tier ro 0 when exiting a #init #init block.
* Sets the default tier to 0 when exiting a #init #init block.
* @param ctx - a statement context.
*/
@Override
......@@ -124,7 +124,7 @@ public class TOSBuilder extends JavaParserBaseListener {
}
/**
* Associates a block number to an expression call in the #blockNumbers map (ParseTree,Integer).
* Associates a block number to an expression call in the #blockNumbers map (mapping ParseTree to Integer).
* @param ctx - an expression call context.
*/
@Override
......@@ -151,7 +151,7 @@ public class TOSBuilder extends JavaParserBaseListener {
}
/**
* Associates a block number to a method call context in the #blockNumbers map (ParseTree,Integer).
* Associates a block number to a method call context in the #blockNumbers map (mapping ParseTree to Integer).
* @param ctx - a method call context.
*/
@Override
......@@ -173,7 +173,7 @@ public class TOSBuilder extends JavaParserBaseListener {
ArrayList<String> pNames = new ArrayList<>();
/*
Checks for constructor parameters and populate the param list with a string representation of their type
to create the constructors namespace (that allows us to identify uniquely every constructor/method).
to create the constructors namespace (that allows us to identify uniquely every constructor).
*/
if(ctx.formalParameters().formalParameterList() != null) {
for(JavaParser.FormalParameterContext t : ctx.formalParameters().formalParameterList().formalParameter()) {
......@@ -184,7 +184,7 @@ public class TOSBuilder extends JavaParserBaseListener {
}
}
/*
The following code associates a block number to the constructor in the BlockNumbers map.
The following code associates a block number to the constructor in the #blockNumbers map.
*/
blockNumbers.put(ctx, tos.getCurrentBlock());
/*
......@@ -287,7 +287,7 @@ public class TOSBuilder extends JavaParserBaseListener {
}
/**
* Associates a block number to a primary expression (see the grammar for a definition of primary expressions)
* Associates a block number to a primary expression (see the ANTLR grammar for a definition of primary expressions)
* in the #blockNumbers map.
* @param ctx - an expression primary context.
*/
......
......@@ -28,7 +28,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* The TypingListener associates types to expression nodes in the parse tree.
* The TypingListener associates types to expression nodes of the parse tree.
* The class and its methods are used to create the namespace of called methods from their caller.
* Namespaces are used to identify uniquely a method.
*/
......@@ -80,8 +80,8 @@ public class TypingListener extends JavaParserBaseListener {
}
/**
* @param op - a String encoding an operator
* @return true if the string encodes an operator that returns a boolean
* @param op - a String encoding an operator symbol.
* @return true if the string encodes an operator that returns a boolean value.
*/
private boolean isBooleanOperator(String op) {
String[] booleanOperators = {"<", ">", ">=", "<=", "||", "&&"};
......@@ -107,8 +107,8 @@ public class TypingListener extends JavaParserBaseListener {
public void exitExpression_call(JavaParser.Expression_callContext ctx) {
super.exitExpression_call(ctx);
/*
To know the return type of a method call the method need to be identified.
So the namespace of the method need to be build
In order to know the return type of a method call, the method needs to be uniquely determined.
The namespace of a method is built to achieve this.
*/
ArrayList<String> param = new ArrayList<>();
String name = ctx.methodCall().IDENTIFIER().getText();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment