1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
13 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.impl.Constant;
15 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
16 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
18 public class TrueLiteral extends MagicLiteral {
19 static final char[] source = { 't', 'r', 'u', 'e' };
21 public TrueLiteral(int s, int e) {
25 public void computeConstant() {
27 constant = Constant.fromValue(true);
31 * Code generation for the true literal
34 * net.sourceforge.phpdt.internal.compiler.lookup.BlockScope
36 * net.sourceforge.phpdt.internal.compiler.codegen.CodeStream
37 * @param valueRequired
40 // public void generateCode(BlockScope currentScope, CodeStream codeStream,
41 // boolean valueRequired) {
42 // int pc = codeStream.position;
44 // codeStream.iconst_1();
45 // codeStream.recordPositionsFrom(pc, this.sourceStart);
47 // public void generateOptimizedBoolean(BlockScope currentScope, CodeStream
48 // codeStream, Label trueLabel, Label falseLabel, boolean valueRequired) {
50 // // trueLabel being not nil means that we will not fall through into the
53 // int pc = codeStream.position;
54 // // constant == true
55 // if (valueRequired) {
56 // if (falseLabel == null) {
57 // // implicit falling through the FALSE case
58 // if (trueLabel != null) {
59 // codeStream.goto_(trueLabel);
63 // codeStream.recordPositionsFrom(pc, this.sourceStart);
65 public TypeBinding literalType(BlockScope scope) {
66 return BooleanBinding;
72 public char[] source() {
76 public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
77 visitor.visit(this, scope);
78 visitor.endVisit(this, scope);