added -J option to preserve unmodified files in preexisting jarfile
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / ast / NullLiteral.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.ast;
12
13 import org.eclipse.jdt.internal.compiler.ASTVisitor;
14 import org.eclipse.jdt.internal.compiler.codegen.*;
15 import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
16 import org.eclipse.jdt.internal.compiler.lookup.*;
17
18 public class NullLiteral extends MagicLiteral {
19
20         static final char[] source = {'n' , 'u' , 'l' , 'l'};
21
22         public NullLiteral(int s , int e) {
23
24                 super(s,e);
25         }
26
27         public void computeConstant() {
28         
29                 constant = NotAConstant; 
30         }
31
32         /**
33          * Code generation for the null literal
34          *
35          * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
36          * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
37          * @param valueRequired boolean
38          */ 
39         public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
40                 int pc = codeStream.position;
41                 if (valueRequired) {
42                         codeStream.aconst_null();
43                         codeStream.generateImplicitConversion(this.implicitConversion);
44                 }
45                 codeStream.recordPositionsFrom(pc, this.sourceStart);
46         }
47         public TypeBinding literalType(BlockScope scope) {
48                 return NullBinding;
49         }
50
51         public int nullStatus(FlowInfo flowInfo) {
52                 return FlowInfo.NULL;
53         }
54         
55         /**
56          * 
57          */
58         public char[] source() {
59                 return source;
60         }
61
62         public void traverse(ASTVisitor visitor, BlockScope scope) {
63                 visitor.visit(this, scope);
64                 visitor.endVisit(this, scope);
65         }
66 }