01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.compiler.ast;
11:
12: import org.eclipse.jdt.internal.compiler.ASTVisitor;
13: import org.eclipse.jdt.internal.compiler.codegen.*;
14: import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
15: import org.eclipse.jdt.internal.compiler.impl.Constant;
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 = 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,
40: CodeStream codeStream, boolean valueRequired) {
41: int pc = codeStream.position;
42: if (valueRequired) {
43: codeStream.aconst_null();
44: codeStream
45: .generateImplicitConversion(this .implicitConversion);
46: }
47: codeStream.recordPositionsFrom(pc, this .sourceStart);
48: }
49:
50: public TypeBinding literalType(BlockScope scope) {
51: return TypeBinding.NULL;
52: }
53:
54: public int nullStatus(FlowInfo flowInfo) {
55: return FlowInfo.NULL;
56: }
57:
58: public Object reusableJSRTarget() {
59: return TypeBinding.NULL;
60: }
61:
62: public char[] source() {
63: return source;
64: }
65:
66: public void traverse(ASTVisitor visitor, BlockScope scope) {
67: visitor.visit(this, scope);
68: visitor.endVisit(this, scope);
69: }
70: }
|