1 11 package org.eclipse.jdt.internal.compiler.ast; 12 13 import org.eclipse.jdt.internal.compiler.codegen.*; 14 import org.eclipse.jdt.internal.compiler.flow.*; 15 import org.eclipse.jdt.internal.compiler.impl.Constant; 16 import org.eclipse.jdt.internal.compiler.lookup.*; 17 18 public abstract class Statement extends ASTNode { 19 20 public abstract FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo); 21 22 26 public void branchChainTo(BranchLabel label) { 27 } 29 30 public boolean complainIfUnreachable(FlowInfo flowInfo, BlockScope scope, boolean didAlreadyComplain) { 32 33 if ((flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0) { 34 this.bits &= ~ASTNode.IsReachable; 35 boolean reported = flowInfo == FlowInfo.DEAD_END; 36 if (!didAlreadyComplain && reported) { 37 scope.problemReporter().unreachableCode(this); 38 } 39 return reported; } 41 return false; 42 } 43 44 47 public void generateArguments(MethodBinding binding, Expression[] arguments, BlockScope currentScope, CodeStream codeStream) { 48 49 if (binding.isVarargs()) { 50 TypeBinding[] params = binding.parameters; 53 int paramLength = params.length; 54 int varArgIndex = paramLength - 1; 55 for (int i = 0; i < varArgIndex; i++) { 56 arguments[i].generateCode(currentScope, codeStream, true); 57 } 58 59 ArrayBinding varArgsType = (ArrayBinding) params[varArgIndex]; ArrayBinding codeGenVarArgsType = (ArrayBinding) binding.parameters[varArgIndex].erasure(); 61 int elementsTypeID = varArgsType.elementsType().id; 62 int argLength = arguments == null ? 0 : arguments.length; 63 64 if (argLength > paramLength) { 65 codeStream.generateInlinedValue(argLength - varArgIndex); 69 codeStream.newArray(codeGenVarArgsType); for (int i = varArgIndex; i < argLength; i++) { 71 codeStream.dup(); 72 codeStream.generateInlinedValue(i - varArgIndex); 73 arguments[i].generateCode(currentScope, codeStream, true); 74 codeStream.arrayAtPut(elementsTypeID, false); 75 } 76 } else if (argLength == paramLength) { 77 TypeBinding lastType = arguments[varArgIndex].resolvedType; 79 if (lastType == TypeBinding.NULL 80 || (varArgsType.dimensions() == lastType.dimensions() 81 && lastType.isCompatibleWith(varArgsType))) { 82 arguments[varArgIndex].generateCode(currentScope, codeStream, true); 84 } else { 85 codeStream.generateInlinedValue(1); 88 codeStream.newArray(codeGenVarArgsType); codeStream.dup(); 90 codeStream.generateInlinedValue(0); 91 arguments[varArgIndex].generateCode(currentScope, codeStream, true); 92 codeStream.arrayAtPut(elementsTypeID, false); 93 } 94 } else { codeStream.generateInlinedValue(0); 98 codeStream.newArray(codeGenVarArgsType); } 100 } else if (arguments != null) { for (int i = 0, max = arguments.length; i < max; i++) 102 arguments[i].generateCode(currentScope, codeStream, true); 103 } 104 } 105 106 public abstract void generateCode(BlockScope currentScope, CodeStream codeStream); 107 108 public boolean isEmptyBlock() { 109 return false; 110 } 111 112 public boolean isValidJavaStatement() { 113 124 return true; 125 } 126 127 public StringBuffer print(int indent, StringBuffer output) { 128 return printStatement(indent, output); 129 } 130 public abstract StringBuffer printStatement(int indent, StringBuffer output); 131 132 public abstract void resolve(BlockScope scope); 133 134 137 public Constant resolveCase(BlockScope scope, TypeBinding testType, SwitchStatement switchStatement) { 138 140 resolve(scope); 141 return Constant.NotAConstant; 142 } 143 144 } 145 | Popular Tags |