All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.royale.compiler.tree.as.ILiteralNode Maven / Gradle / Ivy

The newest version!
/*
 *
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */

package org.apache.royale.compiler.tree.as;

import org.apache.royale.compiler.constants.IASLanguageConstants.BuiltinType;

/**
 * An AST node representing a literal value.
 * 

* An ILiteralNode can represent null, void, * and literal values of the following types: *

    *
  • Array
  • *
  • Boolean
  • *
  • int
  • *
  • Number
  • *
  • Object
  • *
  • RegExp
  • *
  • String
  • *
  • uint
  • *
  • Vector
  • *
  • XML
  • *
  • XMLList
  • *
* The int, uint, and Number * types are represented more completely by the {@link INumericLiteralNode} subinterface. * The RegExp type is represented more completely by the * {@link IRegExpLiteralNode} subinterrface. *

* The shape of an Array literal is *

 * ILiteralNode "Array"
 *   IExpressionNode <-- getChild(0)
 *   IExpressionNode <-- getChild(1)
 *   ...
 * 
* For example, [ 1, 2, 3 ] is represented as *
 * ILiteralNode "Array"
 *   INumericLiteralNode 1
 *   INumericLiteralNode 2
 *   INumericLiteralNode 3
 * 
* The shape of an Object literal is *
 * ILiteralNode "Object"
 *   IObjectLIteralValuePairNode <-- getChild(0)
 *   IObjectLiteralValuePairNode <-- getChild(1)
 *   ..
 * 
* For example, { a: 1, b: 2 } is represented as *
 * ILiteralNode "Object"
 *   IObjectLiteralValuePairNode
 *     IIdentifierNode "a"
 *     INumericLiteralNode 1
 *   IObjectLiteralValuePairNode
 *     IIdentifierNode "b"
 *     INumericLiteralNode 2
 * 
* The other types of literals nodes do not have children. */ public interface ILiteralNode extends IExpressionNode { /** * Represents a kind of ActionScript literal */ enum LiteralType { /** * A string literal, designated by either ' or * "
* For example: "The ActionScript 3 language" or * 'This is a test' */ STRING(BuiltinType.STRING), /** * a numeric literal of any type supported by the ActionScript language
* For example: 10 or 3.14159265 */ NUMBER(BuiltinType.NUMBER), /** * A boolean, either true or false */ BOOLEAN(BuiltinType.BOOLEAN), /** * an XML literal as defined by E4X */ XML(BuiltinType.XML), /** * an XMLList literal as defined by E4X */ XMLLIST(BuiltinType.XMLLIST), /** * a regular expression, designated by /. *
For example: /[a-zA-Z]*/ */ REGEXP(BuiltinType.REGEXP), /** * an object literal For example: null or * void 0 */ OBJECT(BuiltinType.OBJECT), /** * an array literal */ ARRAY(BuiltinType.ARRAY), /** * a vector literal */ VECTOR(BuiltinType.VECTOR), /** * a null literal */ NULL(BuiltinType.NULL), /** * a null literal */ VOID(BuiltinType.VOID); private BuiltinType builtinType; LiteralType(BuiltinType builtinType) { this.builtinType = builtinType; } /** * Returns the type of the literal this node represents * * @return the type of this literal */ public BuiltinType getType() { return builtinType; } } /** * Returns the value of this literal as a String * * @return the value of this literal as a String */ String getValue(); /** * Returns the value of this literal as a String * * @param rawValue True if you want the raw value, otherwise some massaging * of the value will be done before returning the value if it's a String * (enclosing quotes will be removed). * @return the value of this literal as a String */ String getValue(boolean rawValue); /** * Returns the {@link LiteralType} that this node represents */ LiteralType getLiteralType(); }