first scanner /parser copied from the jdt java version
[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.impl.*;
15 import net.sourceforge.phpdt.internal.compiler.codegen.*;
16 import net.sourceforge.phpdt.internal.compiler.lookup.*;
17
18 public class NullLiteral extends MagicLiteral {
19         static final char[] source = {'n' , 'u' , 'l' , 'l'};
20 public NullLiteral(int s , int e) {
21         super(s,e);
22 }
23 public void computeConstant() {
24
25         constant = Constant.fromValue(null);}
26 /**
27  * Code generation for the null literal
28  *
29  * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
30  * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
31  * @param valueRequired boolean
32  */ 
33 public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
34         int pc = codeStream.position;
35         if (valueRequired)
36                 codeStream.aconst_null();
37         codeStream.recordPositionsFrom(pc, this.sourceStart);
38 }
39 public TypeBinding literalType(BlockScope scope) {
40         return NullBinding;
41 }
42 /**
43  * 
44  */
45 public char[] source() {
46         return source;
47 }
48 public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
49         visitor.visit(this, scope);
50         visitor.endVisit(this, scope);
51 }
52 }