fixed accelerator problem; slightly improved PHP Perspective
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / NullLiteral.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v0.5 
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v05.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
12
13 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.codegen.CodeStream;
15 import net.sourceforge.phpdt.internal.compiler.impl.Constant;
16 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
17 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
18
19 public class NullLiteral extends MagicLiteral {
20         static final char[] source = {'n' , 'u' , 'l' , 'l'};
21 public NullLiteral(int s , int e) {
22         super(s,e);
23 }
24 public void computeConstant() {
25
26         constant = Constant.fromValue(null);}
27 /**
28  * Code generation for the null literal
29  *
30  * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
31  * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
32  * @param valueRequired boolean
33  */ 
34 public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
35         int pc = codeStream.position;
36         if (valueRequired)
37                 codeStream.aconst_null();
38         codeStream.recordPositionsFrom(pc, this.sourceStart);
39 }
40 public TypeBinding literalType(BlockScope scope) {
41         return NullBinding;
42 }
43 /**
44  * 
45  */
46 public char[] source() {
47         return source;
48 }
49 public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
50         visitor.visit(this, scope);
51         visitor.endVisit(this, scope);
52 }
53 }