Compare commits
1 Commits
NewParser
...
49195c754c
Author | SHA1 | Date | |
---|---|---|---|
|
49195c754c |
@@ -8,7 +8,6 @@ public interface ASTNode {
|
|||||||
|
|
||||||
//Todo: @BruderJohn & @i22007 Interface anwenden + geeignetetn Methodename.
|
//Todo: @BruderJohn & @i22007 Interface anwenden + geeignetetn Methodename.
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Typecheck:
|
Typecheck:
|
||||||
public TypeCheckResult acceptType(SemanticVisitor visitor);
|
public TypeCheckResult acceptType(SemanticVisitor visitor);
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package ast;
|
package ast;
|
||||||
|
|
||||||
import ast.type.AccessModifierNode;
|
import ast.type.AccessModifierNode;
|
||||||
|
import ast.members.ConstructorNode;
|
||||||
import ast.members.MemberNode;
|
import ast.members.MemberNode;
|
||||||
import ast.members.MethodNode;
|
import ast.members.MethodNode;
|
||||||
import bytecode.visitor.ClassVisitor;
|
import bytecode.visitor.ClassVisitor;
|
||||||
|
@@ -30,6 +30,11 @@ public class TargetNode implements ASTNode, Visitable {
|
|||||||
this.identifier = identifier;
|
this.identifier = identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(MethodVisitor methodVisitor) {
|
||||||
|
methodVisitor.visit(this);
|
||||||
|
}
|
||||||
|
|
||||||
public TypeCheckResult accept(SemanticVisitor visitor) {
|
public TypeCheckResult accept(SemanticVisitor visitor) {
|
||||||
return visitor.analyze(this);
|
return visitor.analyze(this);
|
||||||
}
|
}
|
||||||
|
@@ -39,12 +39,12 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
private Mapper mapper;
|
private Mapper mapper;
|
||||||
private MethodVisitor methodVisitor;
|
private MethodVisitor methodVisitor;
|
||||||
|
|
||||||
private List<String> localVariables;
|
private List<String> localVaribales;
|
||||||
|
|
||||||
public MethodCodeGen(ClassWriter classWriter) {
|
public MethodCodeGen(ClassWriter classWriter) {
|
||||||
this.classWriter = classWriter;
|
this.classWriter = classWriter;
|
||||||
mapper = new Mapper();
|
mapper = new Mapper();
|
||||||
localVariables = new ArrayList<>();
|
localVaribales = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -60,10 +60,10 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
null);
|
null);
|
||||||
|
|
||||||
methodVisitor.visitCode();
|
methodVisitor.visitCode();
|
||||||
localVariables.add("this");
|
localVaribales.add("this");
|
||||||
// Add all method parameters to localVariables
|
// Add all method parameters to localVariables
|
||||||
for (ParameterNode parameterNode : constructorNode.parameters) {
|
for (ParameterNode parameterNode : constructorNode.parameters) {
|
||||||
localVariables.add(parameterNode.identifier);
|
localVaribales.add(parameterNode.identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
methodVisitor.visitVarInsn(ALOAD, 0);
|
methodVisitor.visitVarInsn(ALOAD, 0);
|
||||||
@@ -89,8 +89,8 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
null);
|
null);
|
||||||
|
|
||||||
methodVisitor.visitCode();
|
methodVisitor.visitCode();
|
||||||
localVariables.add("this");
|
localVaribales.add("this");
|
||||||
localVariables.add("args");
|
localVaribales.add("args");
|
||||||
|
|
||||||
// Visit all statements
|
// Visit all statements
|
||||||
for (IStatementNode statementNode : mainMethodNode.block.statements) {
|
for (IStatementNode statementNode : mainMethodNode.block.statements) {
|
||||||
@@ -110,10 +110,10 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
null);
|
null);
|
||||||
|
|
||||||
methodVisitor.visitCode();
|
methodVisitor.visitCode();
|
||||||
localVariables.add("this");
|
localVaribales.add("this");
|
||||||
// Add all method parameters to localVariables
|
// Add all method parameters to localVariables
|
||||||
for (ParameterNode parameterNode : methodNode.parameters) {
|
for (ParameterNode parameterNode : methodNode.parameters) {
|
||||||
localVariables.add(parameterNode.identifier);
|
localVaribales.add(parameterNode.identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Visit all statements
|
// Visit all statements
|
||||||
@@ -181,7 +181,7 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
if (dotSubstractionNode.value != null) {
|
if (dotSubstractionNode.value != null) {
|
||||||
dotSubstractionNode.value.accept(this);
|
dotSubstractionNode.value.accept(this);
|
||||||
} else if (dotSubstractionNode.identifier != null) {
|
} else if (dotSubstractionNode.identifier != null) {
|
||||||
methodVisitor.visitVarInsn(ILOAD, localVariables.indexOf(dotSubstractionNode.identifier));
|
methodVisitor.visitVarInsn(ILOAD, localVaribales.indexOf(dotSubstractionNode.identifier));
|
||||||
} else if (dotSubstractionNode.memberAccess != null) {
|
} else if (dotSubstractionNode.memberAccess != null) {
|
||||||
dotSubstractionNode.memberAccess.accept(this);
|
dotSubstractionNode.memberAccess.accept(this);
|
||||||
} else if (dotSubstractionNode.methodCall != null) {
|
} else if (dotSubstractionNode.methodCall != null) {
|
||||||
@@ -195,6 +195,7 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
public void visit(NonCalculationNode nonCalculationNode) {
|
public void visit(NonCalculationNode nonCalculationNode) {
|
||||||
Label labelFalse = new Label();
|
Label labelFalse = new Label();
|
||||||
Label labelTrue = new Label();
|
Label labelTrue = new Label();
|
||||||
|
// TODO: Null check
|
||||||
switch (nonCalculationNode.operator) {
|
switch (nonCalculationNode.operator) {
|
||||||
case AND:
|
case AND:
|
||||||
nonCalculationNode.unaryExpression.accept(this);
|
nonCalculationNode.unaryExpression.accept(this);
|
||||||
@@ -265,10 +266,8 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(MemberAccessNode memberAccessNode) {
|
public void visit(MemberAccessNode memberAccessNode) {
|
||||||
// Only used to get, not to put
|
if (memberAccessNode.thisExpr) {
|
||||||
if (memberAccessNode.thisExpr) { // Field
|
// methodVisitor.visitFieldInsn(PUTFIELD, memberAccessNode.identifiers.get(0), memberAccessNode.identifiers.get(1), );
|
||||||
// methodVisitor.visitFieldInsn(GETFIELD, memberAccessNode.identifiers.get(0), memberAccessNode.identifiers.get(1), );
|
|
||||||
} else { // Object Attribut
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +296,7 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
if (unaryNode.thisExp != null) {
|
if (unaryNode.thisExp != null) {
|
||||||
methodVisitor.visitVarInsn(ALOAD, 0); // this
|
methodVisitor.visitVarInsn(ALOAD, 0); // this
|
||||||
} else if (unaryNode.identifier != null) {
|
} else if (unaryNode.identifier != null) {
|
||||||
methodVisitor.visitVarInsn(ILOAD, localVariables.indexOf(unaryNode.identifier));
|
methodVisitor.visitVarInsn(ILOAD, localVaribales.indexOf(unaryNode.identifier));
|
||||||
} else if (unaryNode.memberAccess != null) {
|
} else if (unaryNode.memberAccess != null) {
|
||||||
unaryNode.memberAccess.accept(this);
|
unaryNode.memberAccess.accept(this);
|
||||||
} else if (unaryNode.value != null) {
|
} else if (unaryNode.value != null) {
|
||||||
@@ -363,23 +362,23 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
// Process expression
|
// Process expression
|
||||||
localVariableDeclarationNode.expression.accept(this);
|
localVariableDeclarationNode.expression.accept(this);
|
||||||
// Store result of expression in variable
|
// Store result of expression in variable
|
||||||
if (localVariables.contains(localVariableDeclarationNode.identifier)) {
|
if (localVaribales.contains(localVariableDeclarationNode.identifier)) {
|
||||||
if (localVariableDeclarationNode.type instanceof BaseType) {
|
if (localVariableDeclarationNode.type instanceof BaseType) {
|
||||||
methodVisitor.visitVarInsn(ISTORE, localVariables.indexOf(localVariableDeclarationNode.identifier));
|
methodVisitor.visitVarInsn(ISTORE, localVaribales.indexOf(localVariableDeclarationNode.identifier));
|
||||||
} else if (localVariableDeclarationNode.type instanceof ReferenceType) {
|
} else if (localVariableDeclarationNode.type instanceof ReferenceType) {
|
||||||
methodVisitor.visitVarInsn(ASTORE, localVariables.indexOf(localVariableDeclarationNode.identifier));
|
methodVisitor.visitVarInsn(ASTORE, localVaribales.indexOf(localVariableDeclarationNode.identifier));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
localVariables.add(localVariableDeclarationNode.identifier);
|
localVaribales.add(localVariableDeclarationNode.identifier);
|
||||||
if (localVariableDeclarationNode.type instanceof BaseType) {
|
if (localVariableDeclarationNode.type instanceof BaseType) {
|
||||||
methodVisitor.visitVarInsn(ISTORE, localVariables.indexOf(localVariableDeclarationNode.identifier));
|
methodVisitor.visitVarInsn(ISTORE, localVaribales.indexOf(localVariableDeclarationNode.identifier));
|
||||||
} else if (localVariableDeclarationNode.type instanceof ReferenceType) {
|
} else if (localVariableDeclarationNode.type instanceof ReferenceType) {
|
||||||
methodVisitor.visitVarInsn(ASTORE, localVariables.indexOf(localVariableDeclarationNode.identifier));
|
methodVisitor.visitVarInsn(ASTORE, localVaribales.indexOf(localVariableDeclarationNode.identifier));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!localVariables.contains(localVariableDeclarationNode.identifier)) {
|
if (!localVaribales.contains(localVariableDeclarationNode.identifier)) {
|
||||||
localVariables.add(localVariableDeclarationNode.identifier);
|
localVaribales.add(localVariableDeclarationNode.identifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -390,49 +389,43 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
if (assignNode.expression instanceof IncrementNode) {
|
if (assignNode.expression instanceof IncrementNode) {
|
||||||
IncrementNode incrementNode = (IncrementNode) assignNode.expression;
|
IncrementNode incrementNode = (IncrementNode) assignNode.expression;
|
||||||
if (incrementNode.crementType.equals(CrementType.PREFIX)) { // ++i
|
if (incrementNode.crementType.equals(CrementType.PREFIX)) { // ++i
|
||||||
methodVisitor.visitIincInsn(localVariables.indexOf(incrementNode.assignableExpression.identifier), 1);
|
methodVisitor.visitIincInsn(localVaribales.indexOf(incrementNode.assignableExpression.identifier), 1);
|
||||||
assign(assignNode);
|
assign(assignNode);
|
||||||
} else if (incrementNode.crementType.equals(CrementType.SUFFIX)) { // Suffix: i++
|
} else if (incrementNode.crementType.equals(CrementType.SUFFIX)) { // Suffix: i++
|
||||||
assign(assignNode);
|
assign(assignNode);
|
||||||
methodVisitor.visitIincInsn(localVariables.indexOf(incrementNode.assignableExpression.identifier), 1);
|
methodVisitor.visitIincInsn(localVaribales.indexOf(incrementNode.assignableExpression.identifier), 1);
|
||||||
}
|
}
|
||||||
} else if (assignNode.expression instanceof DecrementNode) {
|
} else if (assignNode.expression instanceof DecrementNode) {
|
||||||
DecrementNode decrementNode = (DecrementNode) assignNode.expression;
|
DecrementNode decrementNode = (DecrementNode) assignNode.expression;
|
||||||
if (decrementNode.crementType.equals(CrementType.PREFIX)) {
|
if (decrementNode.crementType.equals(CrementType.PREFIX)) {
|
||||||
methodVisitor.visitIincInsn(localVariables.indexOf(decrementNode.assignableExpression.identifier), -1);
|
methodVisitor.visitIincInsn(localVaribales.indexOf(decrementNode.assignableExpression.identifier), -1);
|
||||||
assign(assignNode);
|
assign(assignNode);
|
||||||
} else if (decrementNode.crementType.equals(CrementType.SUFFIX)) {
|
} else if (decrementNode.crementType.equals(CrementType.SUFFIX)) {
|
||||||
assign(assignNode);
|
assign(assignNode);
|
||||||
methodVisitor.visitIincInsn(localVariables.indexOf(decrementNode.assignableExpression.identifier), 1);
|
methodVisitor.visitIincInsn(localVaribales.indexOf(decrementNode.assignableExpression.identifier), 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assignNode.expression.accept(this);
|
assignNode.expression.accept(this);
|
||||||
assign(assignNode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assign(AssignNode assignNode) {
|
private void assign(AssignNode assignNode) {
|
||||||
|
// Store result of expression in variable
|
||||||
if (assignNode.assignable.memberAccess.thisExpr) {
|
if (assignNode.assignable.memberAccess.thisExpr) {
|
||||||
assignField(assignNode);
|
// Global var
|
||||||
|
methodVisitor.visitVarInsn(ALOAD, 0);
|
||||||
|
if (assignNode.expression instanceof BaseType) {
|
||||||
|
//methodVisitor.visitFieldInsn(PUTFIELD, class name, var identifier, mapper.getTypeChar(((BaseTypeNode) type).enumType));
|
||||||
|
} else if (assignNode.expression instanceof ReferenceType) {
|
||||||
|
//methodVisitor.visitFieldInsn(PUTFIELD, class name, var identifier, "L"class name object +";");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assignLocalVar(assignNode);
|
// Local var
|
||||||
}
|
if (assignNode.expression instanceof BaseType) {
|
||||||
}
|
methodVisitor.visitVarInsn(ISTORE, localVaribales.indexOf(assignNode.assignable.identifier));
|
||||||
|
} else if (assignNode.expression instanceof ReferenceType) {
|
||||||
private void assignLocalVar(AssignNode assignNode) {
|
methodVisitor.visitVarInsn(ASTORE, localVaribales.indexOf(assignNode.assignable.identifier));
|
||||||
if (assignNode.expression instanceof BaseType) {
|
}
|
||||||
methodVisitor.visitVarInsn(ISTORE, localVariables.indexOf(assignNode.assignable.identifier));
|
|
||||||
} else if (assignNode.expression instanceof ReferenceType) {
|
|
||||||
methodVisitor.visitVarInsn(ASTORE, localVariables.indexOf(assignNode.assignable.identifier));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assignField(AssignNode assignNode) {
|
|
||||||
if (assignNode.expression instanceof BaseType) {
|
|
||||||
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), mapper.getTypeChar((BaseType) assignNode.expression.getType()));
|
|
||||||
} else if (assignNode.expression instanceof ReferenceType) {
|
|
||||||
ReferenceType referenceType = (ReferenceType) assignNode.expression.getType();
|
|
||||||
methodVisitor.visitFieldInsn(PUTFIELD, assignNode.assignable.memberAccess.identifiers.get(0), assignNode.assignable.memberAccess.identifiers.get(1), "L"+referenceType.getIdentifier()+";");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,13 +433,13 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
public void visit(NewDeclarationNode newDeclarationNode) {
|
public void visit(NewDeclarationNode newDeclarationNode) {
|
||||||
methodVisitor.visitTypeInsn(NEW, newDeclarationNode.identifier);
|
methodVisitor.visitTypeInsn(NEW, newDeclarationNode.identifier);
|
||||||
methodVisitor.visitInsn(DUP);
|
methodVisitor.visitInsn(DUP);
|
||||||
List<ParameterNode> parameterNodes = new ArrayList<>();
|
|
||||||
for (IExpressionNode expressionNode : newDeclarationNode.expressions) {
|
for (IExpressionNode expressionNode : newDeclarationNode.expressions) {
|
||||||
expressionNode.accept(this);
|
expressionNode.accept(this);
|
||||||
parameterNodes.add(new ParameterNode(expressionNode.getType(), ""));
|
|
||||||
}
|
}
|
||||||
methodVisitor.visitMethodInsn(INVOKESPECIAL, newDeclarationNode.identifier, "<init>", mapper.generateMethodDescriptor(new BaseType(TypeEnum.VOID),parameterNodes), false);
|
// TODO
|
||||||
localVariables.add(newDeclarationNode.identifier);
|
//methodVisitor.visitMethodInsn(INVOKESPECIAL, class name, "<init>", mapper.generateMethodDescriptor(), false);
|
||||||
|
// TODO: kann ein Field auch definiert werden? Abfrage ob local var oder field
|
||||||
|
localVaribales.add(newDeclarationNode.identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -512,6 +505,13 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
whileNode.expression.accept(this);
|
whileNode.expression.accept(this);
|
||||||
methodVisitor.visitJumpInsn(IFEQ, endOfLoopLabel); // if condition is false, jump out of loop
|
methodVisitor.visitJumpInsn(IFEQ, endOfLoopLabel); // if condition is false, jump out of loop
|
||||||
|
|
||||||
|
// TODO: Unterscheidung bei increment/decrement der for Schleife
|
||||||
|
if (whileNode.block.statements.size() == 2) { // For loop
|
||||||
|
whileNode.block.statements.get(0).accept(this);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
whileNode.block.statements.get(0).accept(this);
|
||||||
|
}
|
||||||
whileNode.block.accept(this);
|
whileNode.block.accept(this);
|
||||||
methodVisitor.visitJumpInsn(GOTO, loopLabel);
|
methodVisitor.visitJumpInsn(GOTO, loopLabel);
|
||||||
|
|
||||||
@@ -520,17 +520,16 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(ChainedMethodNode chainedMethodNode) {
|
public void visit(ChainedMethodNode chainedMethodNode) {
|
||||||
// TODO: Erstmal abwarten
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(MethodCallNode methodCallNode) {
|
public void visit(MethodCallNode methodCallNode) {
|
||||||
List<ParameterNode> parameterNodes = new ArrayList<>();
|
|
||||||
for(IExpressionNode expressionNode : methodCallNode.parameters) {
|
}
|
||||||
expressionNode.accept(this);
|
|
||||||
parameterNodes.add(new ParameterNode(expressionNode.getType(), ""));
|
@Override
|
||||||
}
|
public void visit(TargetNode targetNode) {
|
||||||
// TODO: Klassenname und Returntype
|
|
||||||
//methodVisitor.visitMethodInsn(INVOKEVIRTUAL, classname, methodCallNode.identifier, mapper.generateMethodDescriptor(returntype, parameterNodes), false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -46,6 +46,7 @@ public interface MethodVisitor {
|
|||||||
// statement expression
|
// statement expression
|
||||||
void visit(ChainedMethodNode chainedMethodNode);
|
void visit(ChainedMethodNode chainedMethodNode);
|
||||||
void visit(MethodCallNode methodCallNode);
|
void visit(MethodCallNode methodCallNode);
|
||||||
|
void visit(TargetNode targetNode);
|
||||||
|
|
||||||
void visit(AssignNode assignNode);
|
void visit(AssignNode assignNode);
|
||||||
void visit(NewDeclarationNode newDeclarationNode);
|
void visit(NewDeclarationNode newDeclarationNode);
|
||||||
|
@@ -1,45 +0,0 @@
|
|||||||
package semantic;
|
|
||||||
|
|
||||||
import ast.ProgramNode;
|
|
||||||
import org.antlr.v4.runtime.CharStream;
|
|
||||||
import org.antlr.v4.runtime.CharStreams;
|
|
||||||
import org.antlr.v4.runtime.CommonTokenStream;
|
|
||||||
import org.antlr.v4.runtime.tree.ParseTree;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import parser.astBuilder.ASTBuilder;
|
|
||||||
import parser.generated.SimpleJavaLexer;
|
|
||||||
import parser.generated.SimpleJavaParser;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
public class BeginnToTAST {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void FieldTests() {
|
|
||||||
SemanticAnalyzer.clearAnalyzer();
|
|
||||||
|
|
||||||
CharStream codeCharStream = null;
|
|
||||||
try {
|
|
||||||
codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/input/johnsTests/FieldTests.java"));
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream);
|
|
||||||
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
|
|
||||||
|
|
||||||
SimpleJavaParser parser = new SimpleJavaParser(tokenStream);
|
|
||||||
ParseTree parseTree = parser.program(); // parse the input
|
|
||||||
|
|
||||||
/* ------------------------- AST builder -> AST ------------------------- */
|
|
||||||
ASTBuilder astBuilder = new ASTBuilder();
|
|
||||||
ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree);
|
|
||||||
|
|
||||||
var result = SemanticAnalyzer.generateTast(abstractSyntaxTree);
|
|
||||||
|
|
||||||
assertTrue(SemanticAnalyzer.errors.isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,5 +0,0 @@
|
|||||||
public class Test{
|
|
||||||
|
|
||||||
int a = 10;
|
|
||||||
|
|
||||||
}
|
|
@@ -3,6 +3,6 @@ class Null{
|
|||||||
int a;
|
int a;
|
||||||
|
|
||||||
public Null(){
|
public Null(){
|
||||||
// this.a = null;
|
this.a = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,29 +0,0 @@
|
|||||||
public class Test {
|
|
||||||
|
|
||||||
public House h;
|
|
||||||
|
|
||||||
public int test(House h){
|
|
||||||
return h.getW().getSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class House {
|
|
||||||
|
|
||||||
private Window w;
|
|
||||||
|
|
||||||
public Window getW(){
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Window{
|
|
||||||
|
|
||||||
private int size;
|
|
||||||
|
|
||||||
public int getSize() {
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,38 +0,0 @@
|
|||||||
public class AllFeaturesClassExample {
|
|
||||||
int a;
|
|
||||||
boolean b;
|
|
||||||
char c;
|
|
||||||
|
|
||||||
public void controlStructures(int adf, boolean bool) {
|
|
||||||
if (a > (10 + 8)) {
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
while (a > adf) {
|
|
||||||
a--;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// void logicalOperations() {
|
|
||||||
// Logische UND-Operation
|
|
||||||
// if (b && a > 5) {
|
|
||||||
// System.out.println("a ist größer als 5 und b ist wahr");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Logische ODER-Operation
|
|
||||||
// if (b || a < 5) {
|
|
||||||
// System.out.println("b ist wahr oder a ist kleiner als 5");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public static void main(String[] args) {
|
|
||||||
// AllFeaturesClassExample obj = new AllFeaturesClassExample(12, true, 'a');
|
|
||||||
// obj.controlStructures();
|
|
||||||
// }
|
|
||||||
}
|
|
Reference in New Issue
Block a user