Class Env.DeclGroup

  • Enclosing class:
    Env

    public static class Env.DeclGroup
    extends java.lang.Object
    Object for managing a group of declarations within a scope.

    Identifiers and functions can share the same declaration name, so a simple map will not suffice for tracking declaration overloads.

    Whether a given DeclGroup is mutable or immutable depends on whether the maps supplied as input to the group are standard Map implementations or ImmutableMap implementations. The {DeclGroup#immutableCopy} method is provided as a convenience to make it easy to create an instance of the group which will honor the developer's intent.

    • Constructor Summary

      Constructors 
      Constructor Description
      DeclGroup()
      Construct an empty DeclGroup.
      DeclGroup​(java.util.Map<java.lang.String,​CelIdentDecl> idents, java.util.Map<java.lang.String,​CelFunctionDecl> functions)
      Construct a new DeclGroup from the input idents and functions.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @Nullable CelFunctionDecl getFunction​(java.lang.String name)
      Get a function declaration by name.
      java.util.Map<java.lang.String,​CelFunctionDecl> getFunctions()
      Get an immutable map of the functions in the DeclGroup keyed by declaration name.
      @Nullable CelIdentDecl getIdent​(java.lang.String name)
      Get an identifier declaration by name.
      java.util.Map<java.lang.String,​CelIdentDecl> getIdents()
      Get an immutable map of the identifiers in the DeclGroup keyed by declaration name.
      Env.DeclGroup immutableCopy()
      Create a copy of the DeclGroup with immutable identifier and function maps.
      void putFunction​(CelFunctionDecl function)
      Put a function declaration into the DeclGroup.
      void putIdent​(CelIdentDecl ident)
      Put an identifier declaration into the DeclGroup.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DeclGroup

        public DeclGroup()
        Construct an empty DeclGroup.
      • DeclGroup

        public DeclGroup​(java.util.Map<java.lang.String,​CelIdentDecl> idents,
                         java.util.Map<java.lang.String,​CelFunctionDecl> functions)
        Construct a new DeclGroup from the input idents and functions.
    • Method Detail

      • getIdents

        public java.util.Map<java.lang.String,​CelIdentDecl> getIdents()
        Get an immutable map of the identifiers in the DeclGroup keyed by declaration name.
      • getFunctions

        public java.util.Map<java.lang.String,​CelFunctionDecl> getFunctions()
        Get an immutable map of the functions in the DeclGroup keyed by declaration name.
      • getIdent

        public @Nullable CelIdentDecl getIdent​(java.lang.String name)
        Get an identifier declaration by name. Returns null if absent.
      • putIdent

        public void putIdent​(CelIdentDecl ident)
        Put an identifier declaration into the DeclGroup.
      • getFunction

        public @Nullable CelFunctionDecl getFunction​(java.lang.String name)
        Get a function declaration by name. Returns null if absent.
      • putFunction

        public void putFunction​(CelFunctionDecl function)
        Put a function declaration into the DeclGroup.
      • immutableCopy

        public Env.DeclGroup immutableCopy()
        Create a copy of the DeclGroup with immutable identifier and function maps.