KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > ast > NullLiteral


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-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.impl.Constant;
17 import org.eclipse.jdt.internal.compiler.lookup.*;
18
19 public class NullLiteral extends MagicLiteral {
20
21     static final char[] source = {'n' , 'u' , 'l' , 'l'};
22
23     public NullLiteral(int s , int e) {
24
25         super(s,e);
26     }
27
28     public void computeConstant() {
29     
30         constant = Constant.NotAConstant;
31     }
32
33     /**
34      * Code generation for the null literal
35      *
36      * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
37      * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
38      * @param valueRequired boolean
39      */

40     public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
41         int pc = codeStream.position;
42         if (valueRequired) {
43             codeStream.aconst_null();
44             codeStream.generateImplicitConversion(this.implicitConversion);
45         }
46         codeStream.recordPositionsFrom(pc, this.sourceStart);
47     }
48     public TypeBinding literalType(BlockScope scope) {
49         return TypeBinding.NULL;
50     }
51
52     public int nullStatus(FlowInfo flowInfo) {
53         return FlowInfo.NULL;
54     }
55
56     public Object JavaDoc reusableJSRTarget() {
57         return TypeBinding.NULL;
58     }
59     
60     public char[] source() {
61         return source;
62     }
63
64     public void traverse(ASTVisitor visitor, BlockScope scope) {
65         visitor.visit(this, scope);
66         visitor.endVisit(this, scope);
67     }
68 }
69
Popular Tags