Commits

Taku Miyakawa committed fcc708d

Renames Value#child to newChild

  • Participants
  • Parent commits d76b23f
  • Branches issue515-rename-child-value-functions-methods

Comments (0)

Files changed (26)

File src/main/java/org/kink_lang/kink/ModuleFactory.java

     public Value getModule() {
         // Parent of the module holding 'string' method, not to be imported by 'use' method
         Value moduleParent = Value.value();
-        Value module = moduleParent.child();
+        Value module = moduleParent.newChild();
         module.define( getDefinitionClass() );
         moduleParent.set( SET_SHOW , Value.value( showFun( module , getName() ) ) );
         return module;

File src/main/java/org/kink_lang/kink/Modules.java

             return Value.value( show );
         } );
         envParent.set( SET_SHOW , Value.value( showFun ) );
-        Value env = envParent.child();
+        Value env = envParent.newChild();
         program.compile().call( env );
 
         Set< String > publicSymbols = Envs.publicMethodSymbols( env );
         copyVars( moduleParent , env , privateVerbSymbols );
 
         // Public methods to the module
-        Value module = moduleParent.child();
+        Value module = moduleParent.newChild();
         copyVars( module , env , publicSymbols );
         return module;
     }

File src/main/java/org/kink_lang/kink/Value.java

      * @return
      *      A new child of {@code this} value.
      */
-    public Value child() {
+    public Value newChild() {
         return new Value( this , this.boxed );
     }
 
      *      A new child of {@code base}.
      */
     public static Value value() {
-        return base().child();
+        return base().newChild();
     }
 
 
 
 
         /** {@code null}.  */
-        static final Value NULL = base().child();
+        static final Value NULL = base().newChild();
 
 
         /** Should not be instantiated. */

File src/main/java/org/kink_lang/kink/internal/BaseMethods.java

     @Define
     public Value new_child( @Receiver Value parent , Value ... args ) {
         Checker.check( args.length % 2 == 0 , Messages::notEvenNumberOfArguments );
-        Value child = parent.child();
+        Value child = parent.newChild();
         List< String > symbols = Streams.rangeStepping( 0 , args.length , 2 )
             .mapToObj( symbolIndex -> args[ symbolIndex ].asString( () -> "\\" + symbolIndex ) )
             .collect( Collectors.toList() );

File src/main/java/org/kink_lang/kink/internal/Envs.java

      *      A new environment.
      */
     public static Value env() {
-        return Modules.find( "CORE" ).child();
+        return Modules.find( "CORE" ).newChild();
     }
 
 

File src/main/java/org/kink_lang/kink/internal/Identities.java

      *     Identity value of the {@code value}.
      */
     public static Value identityValue( Value value ) {
-        Value identity = IDENTITY_PROTO.child();
+        Value identity = IDENTITY_PROTO.newChild();
         identity.set( SET_VALUE , value );
         return identity;
     }

File src/main/java/org/kink_lang/kink/internal/eval/FunEvaluator.java

 
         @Override
         public CallResult run( Value receiver , Value... args ) {
-            Value env = enclosingEnv.child();
+            Value env = enclosingEnv.newChild();
             return content.evaluateTail( env , receiver
                     , null , null , null , args );
         }
 
         @Override
         public CallResult run1( Value receiver , Value arg0 ) {
-            Value env = enclosingEnv.child();
+            Value env = enclosingEnv.newChild();
             return content.evaluateTail( env , receiver
                     , arg0 , null , null , null );
         }
 
         @Override
         public CallResult run2( Value receiver , Value arg0 , Value arg1 ) {
-            Value env = enclosingEnv.child();
+            Value env = enclosingEnv.newChild();
             return content.evaluateTail( env , receiver
                     , arg0 , arg1 , null , null );
         }
 
         @Override
         public CallResult run3( Value receiver , Value arg0 , Value arg1 , Value arg2 ) {
-            Value env = enclosingEnv.child();
+            Value env = enclosingEnv.newChild();
             return content.evaluateTail( env , receiver
                     , arg0 , arg1 , arg2 , null );
         }

File src/main/java/org/kink_lang/kink/internal/eval/NewChildEvaluator.java

 
     @Override
     protected Value getOwner( Value receiver ) {
-        return receiver.child();
+        return receiver.newChild();
     }
 
 

File src/main/java/org/kink_lang/kink/internal/eval/NewValueFuncEvaluator.java

 
     @Override
     protected Value getOwner( Value receiver ) {
-        return Value.base().child();
+        return Value.base().newChild();
     }
 
 

File src/main/java/org/kink_lang/kink/internal/eval/ThenUtils.java

     /** Function to enter the block not on the tail context. */
     static Fun blockFun( final Evaluator block ) {
         return Fun.builder().buildVarArgs( ( enclosingEnv , args ) -> {
-            Value env = enclosingEnv.child();
+            Value env = enclosingEnv.newChild();
             return block.evaluate( env , Value.base()
                     , null , null , null , EMPTY_VALUES );
         } );
     /** Function to enter the block on the tail context. */
     static Fun tailBlockFun( final Evaluator block ) {
         return Fun.builder().buildVarArgs( ( enclosingEnv , args ) -> {
-            Value env = enclosingEnv.child();
+            Value env = enclosingEnv.newChild();
             return block.evaluateTail( env , Value.base()
                     , null , null , null , EMPTY_VALUES );
         } );

File src/main/java/org/kink_lang/kink/internal/jsr223/KinkEngine.java

         if ( globalBindings != null ) {
             loadFromBindings( parentEnv , globalBindings );
         }
-        Value engineEnv = parentEnv.child();
+        Value engineEnv = parentEnv.newChild();
         loadFromBindings( engineEnv , context.getBindings( ScriptContext.ENGINE_SCOPE ) );
         return engineEnv;
     }

File src/test/java/org/kink_lang/kink/ModuleFactoryTest.java

     @Test
     public void test_show_of_child_of_module_represents_env() {
         Value mod = new StubModule().getModule();
-        Value env = mod.child();
+        Value env = mod.newChild();
         assertThat( env.toString() , is( not( "StubModule" ) ) );
         assertThat( env.toString() , containsString( "env" ) );
     }

File src/test/java/org/kink_lang/kink/ProgramTest.java

     @Test
     public void test_compile_for_valid_source_then_call_with_env() {
         Program program = new Program( "source.kn" , "\\env" );
-        Value env = Modules.find( "CORE" ).child();
+        Value env = Modules.find( "CORE" ).newChild();
         Fun compiledFun = program.compile();
         assertThat( compiledFun.call( env ) , is( env ) );
     }
     public void test_compiled_function_throws_exception_when_2_args_given() {
         Program program = new Program( "source.kn" , "42" );
         Fun fun = program.compile();
-        Value env = Modules.find( "CORE" ).child();
+        Value env = Modules.find( "CORE" ).newChild();
         try {
             fun.call( env , env );
             fail();

File src/test/java/org/kink_lang/kink/ValueTest.java

 
     @Test
     public void getParent_test() {
-        Value child = Value.base().child();
+        Value child = Value.base().newChild();
         assertThat( child.getParent() , sameInstance( Value.base() ) );
-        Value grandChild = child.child();
+        Value grandChild = child.newChild();
         assertThat( grandChild.getParent() , sameInstance( child ) );
     }
 
 
     @Test
     public void new_child_test() {
-        Value child = Value.base().child();
+        Value child = Value.base().newChild();
         assertThat( child.getParent() , sameInstance( Value.base() ) );
-        Value grandChild = child.child();
+        Value grandChild = child.newChild();
         assertThat( grandChild.getParent() , sameInstance( child ) );
-        Value anotherGrandChild = child.child();
+        Value anotherGrandChild = child.newChild();
         assertThat( anotherGrandChild , not( sameInstance( grandChild ) ) );
         assertThat( anotherGrandChild.getParent() , sameInstance( child ) );
     }
     @Test
     public void testSetGetOverride() {
         Value parent = Value.value();
-        Value child = parent.child();
+        Value child = parent.newChild();
 
         Value content = Value.value();
         Value contentOverride = Value.value();
     public void isOrSame_true() {
 
         Value child = Value.value();
-        Value grandchild = child.child();
+        Value grandchild = child.newChild();
 
         assertThat( Value.base().isSubOf( Value.base() ) , is( true ) );
         assertThat( child.isSubOf( child ) , is( true ) );
     @Test
     public void isOrSame_false() {
         Value child = Value.value();
-        Value grandchild = child.child();
+        Value grandchild = child.newChild();
         Value stranger = Value.value();
         assertThat( Value.base().isSubOf( child ) , is( false ) );
         assertThat( child.isSubOf( grandchild ) , is( false ) );
     public void can_get_vars() {
         Value parent = Value.value();
         parent.set( new SetSite( "first" ) , first );
-        Value me = parent.child();
+        Value me = parent.newChild();
         me.set( new SetSite( "second" ) , second );
         Set< Var > expected = new HashSet< Var >();
         for ( Value ascend = parent ; ascend != null ; ascend = ascend.getParent() ) {
     public void can_get_var_symbols() {
         Value parent = Value.value();
         parent.set( new SetSite( "first" ) , first );
-        Value me = parent.child();
+        Value me = parent.newChild();
         me.set( new SetSite( "second" ) , second );
         Set< String > expected = new HashSet< String >();
         for ( Value ascend = parent ; ascend != null ; ascend = ascend.getParent() ) {
     @Test
     public void test_getSolidVarOwner() {
         Value parent = Value.value();
-        Value child = parent.child();
+        Value child = parent.newChild();
 
         parent.set( new SetSite( "template" ) , value );
         parent.set( new SetSite( "overrided" ) , value );
     public void test_box_and_unbox_true() {
         assertThat( Value.value( (Object) true ) , is( Value.value( true ) ) );
         assertThat( Value.value( true ).asBool( () -> "" ) , is( true ) );
-        assertThat( Value.value( true ).child().asBool( () -> "" ) , is( true ) );
+        assertThat( Value.value( true ).newChild().asBool( () -> "" ) , is( true ) );
         @SuppressWarnings( "PMD" )
         Boolean newTrue = new Boolean( true );
         assertThat( Value.value( newTrue ) , is( Value.value( true ) ) );
     public void test_box_and_unbox_false() {
         assertThat( Value.value( (Object) false ) , is( Value.value( false ) ) );
         assertThat( Value.value( false ).asBool( () -> "" ) , is( false ) );
-        assertThat( Value.value( false ).child().asBool( () -> "" ) , is( false ) );
+        assertThat( Value.value( false ).newChild().asBool( () -> "" ) , is( false ) );
         @SuppressWarnings( "PMD" )
         Boolean newFalse = new Boolean( false );
         assertThat( Value.value( newFalse ) , is( Value.value( false ) ) );

File src/test/java/org/kink_lang/kink/VarTest.java

     @Test
     public void test_getSolid() {
         Value parent = Value.value();
-        Value child = parent.child();
+        Value child = parent.newChild();
         parent.set( new SetSite( "common" ) , content );
         child.set( new SetSite( "specific" ) , content );
         Var common = new Var( child , "common" );

File src/test/java/org/kink_lang/kink/internal/BaseMethodsTest.java

     @Test
     public void parent_ofAValue() {
         Value parent = Value.value();
-        Value child = parent.child();
+        Value child = parent.newChild();
         assertThat( methods.parent( child ) , is( parent ) );
     }
 
     public void parent_isDefined() {
 
         Value parent = Value.value();
-        Value child = parent.child();
+        Value child = parent.newChild();
 
         assertThat( child.call( new GetSite( "parent" ) ) , is( parent ) );
     }
 
     @Test
     public void sub_of_p_true_for_child() {
-        Value child = value.child();
+        Value child = value.newChild();
         assertThat( value.call( SUB_OF_P , child ).asBool( () -> "result" )
                 , is( false ) );
     }

File src/test/java/org/kink_lang/kink/internal/EnvsTest.java

         moduleParent.set( new SetSite( "ping" ) , ping );
         moduleParent.set( new SetSite( "pong" ) , pong );
 
-        Value module = moduleParent.child();
+        Value module = moduleParent.newChild();
         module.set( new SetSite( "peng" ) , peng );
         module.set( new SetSite( "pang" ) , pang );
 

File src/test/java/org/kink_lang/kink/internal/NullMethodsTest.java

     @Test
     public void show_null() {
         assertThat( Value.value( null ).call( SHOW ).asString( () -> "" ) , is( "null" ) );
-        assertThat( Value.value( null ).child().call( SHOW ).asString( () -> "" ) , is( "null" ) );
+        assertThat( Value.value( null ).newChild().call( SHOW ).asString( () -> "" ) , is( "null" ) );
     }
 
 
     public void nulls_are_equal_to_each_ther() {
         EqualityVerifier verifier = new EqualityVerifier();
 
-        verifier.group( "null" , Value.value( null ) , Value.value( null ).child() );
+        verifier.group( "null" , Value.value( null ) , Value.value( null ).newChild() );
         verifier.group( "base" , Value.base() , Value.base() );
-        verifier.group( "child-of-base" , Value.base().child() );
+        verifier.group( "child-of-base" , Value.base().newChild() );
 
         verifier.verify();
     }

File src/test/java/org/kink_lang/kink/internal/box/BoxingValuesTest.java

         }
         public void instanceMethod() {
         }
-        public static void child() {
+        public static void new_child() {
         }
         public static final int NUMBER = 42;
         public static String title = "peng!";
         @SuppressWarnings( "PMD" )
         private static final int secretNumber = 214;
-        public static final String child = "child";
+        public static final String new_child = "child";
     }
 
 

File src/test/java/org/kink_lang/kink/internal/box/ClassEnhancerTest.java

         }
         public void instanceMethod() {
         }
-        public static void child() {
+        public static void new_child() {
         }
         public static final int NUMBER = 42;
         public static String title = "peng!";
         @SuppressWarnings( "PMD" )
         private static final int secretNumber = 214;
-        public static final String child = "child";
+        public static final String new_child = "child";
     }
 
 

File src/test/java/org/kink_lang/kink/internal/box/ObjectEnhancerTest.java

         public int divide( int dividend , int divisor ) {
             return dividend / divisor;
         }
-        public void child() {
+        public void new_child() {
         }
         public static void staticMethod() {
         }
     }
 
 
-    public static class Static {
-        public static String concat( String x , String y ) {
-            return x + y;
-        }
-        public static int divide( int dividend , int divisor ) {
-            return dividend / divisor;
-        }
-        public void instanceMethod() {
-        }
-        public static void child() {
-        }
-        public static final int NUMBER = 42;
-        public static String title = "peng!";
-        @SuppressWarnings( "PMD" )
-        private static final int secretNumber = 214;
-        public static final String child = "child";
-    }
-
-
     public static class Person {
 
         public final String name;

File src/test/java/org/kink_lang/kink/internal/box/VarEnhancerTest.java

     @Test
     public void solid_returns_holders_var() {
         Value parent = Value.value();
-        Value child = parent.child();
+        Value child = parent.newChild();
 
         parent.set( new SetSite( "..symbol.." ) , content );
         Value result = Value.value( new Var( child , "..symbol.." ) ).call( SOLID );

File src/test/java/org/kink_lang/kink/internal/eval/BinaryThenEvaluatorTest.java

     }
 
 
-    // true.child( 'then' { _0.call + _1.call } ).then { "ping!" } { "pong!" }
+    // true.new_child( 'then' { _0.call + _1.call } ).then { "ping!" } { "pong!" }
     // on the not-tail context
     @Test
     public void evaluate_modified_bool_then() {
-        Value modifiedBool = Value.value( true ).child();
+        Value modifiedBool = Value.value( true ).newChild();
         modifiedBool.set( new SetSite( "then" ) , Value.value( concat ) );
         Evaluator ping = new ConstantEvaluator( Value.value( "ping!" ) , area );
         Evaluator pong = new ConstantEvaluator( Value.value( "pong!" ) , area );
     }
 
 
-    // true.child( 'then' { _0.call + _1.call } ).then { "ping!" } { "pong!" }
+    // true.new_child( 'then' { _0.call + _1.call } ).then { "ping!" } { "pong!" }
     // on the tail context
     @Test
     public void evaluate_tail_modified_bool_then() {
-        Value modifiedBool = Value.value( true ).child();
+        Value modifiedBool = Value.value( true ).newChild();
         modifiedBool.set( new SetSite( "then" ) , Value.value( concat ) );
         Evaluator ping = new ConstantEvaluator( Value.value( "ping!" ) , area );
         Evaluator pong = new ConstantEvaluator( Value.value( "pong!" ) , area );

File src/test/java/org/kink_lang/kink/internal/eval/ThenUtilsTest.java

 
     @Test
     public void is_ordinary_boolean() {
-        Value trueChild = Value.value( true ).child();
+        Value trueChild = Value.value( true ).newChild();
         assertThat( ThenUtils.isOrdinaryBoolean( trueChild ) , is( true ) );
     }
 
 
     @Test
     public void is_not_ordinary_boolean_if_then_method_modified() {
-        Value trueChild = Value.value( true ).child();
+        Value trueChild = Value.value( true ).newChild();
         trueChild.set( new SetSite( "then" )
                 , Value.value( Fun.ofConstant( Value.base() ) ) );
         assertThat( ThenUtils.isOrdinaryBoolean( trueChild ) , is( false ) );

File src/test/java/org/kink_lang/kink/internal/eval/UnaryThenEvaluatorTest.java

     }
 
 
-    // true.child( 'then' { _0.call + _0.call } ).then { "peng!" }
+    // true.new_child( 'then' { _0.call + _0.call } ).then { "peng!" }
     // on the not-tail context
     @Test
     public void evaluate_modified_bool_then() {
-        Value modifiedBool = Value.value( true ).child();
+        Value modifiedBool = Value.value( true ).newChild();
         modifiedBool.set( new SetSite( "then" ) , Value.value( repeat ) );
         Evaluator peng = new ConstantEvaluator( Value.value( "peng!" ) , area );
         Evaluator then = new UnaryThenEvaluator( cond( modifiedBool ) , peng , area );
     }
 
 
-    // true.child( 'then' { _0.call + _0.call } ).then { "peng!" }
+    // true.new_child( 'then' { _0.call + _0.call } ).then { "peng!" }
     // on the tail context
     @Test
     public void evaluate_tail_modified_bool_then() {
-        Value modifiedBool = Value.value( true ).child();
+        Value modifiedBool = Value.value( true ).newChild();
         modifiedBool.set( new SetSite( "then" ) , Value.value( repeat ) );
         Evaluator peng = new ConstantEvaluator( Value.value( "peng!" ) , area );
         final Evaluator then

File src/test/java/org/kink_lang/kink/internal/module/CoreTest.java

 
     @Test
     public void show_of_child_of_core() {
-        String show = core.child().call( new GetSite( "show" ) ).asString( () -> "" );
+        String show = core.newChild().call( new GetSite( "show" ) ).asString( () -> "" );
         assertThat( show.matches( "<env:hash=([0-9]+|\\(-[0-9]+\\))>" ) , is( true ) );
     }