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

org.truffleruby.builtins.PrimitiveNode Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2016, 2024 Oracle and/or its affiliates. All rights reserved. This
 * code is released under a tri EPL/GPL/LGPL license. You can use it,
 * redistribute it and/or modify it under the terms of the:
 *
 * Eclipse Public License version 2.0, or
 * GNU General Public License version 2, or
 * GNU Lesser General Public License version 2.1.
 */

package org.truffleruby.builtins;

import org.truffleruby.annotations.Primitive;
import org.truffleruby.language.RubyContextSourceNode;
import org.truffleruby.language.NotProvided;

import com.oracle.truffle.api.dsl.GenerateNodeFactory;
import org.truffleruby.language.RubyNode;

@GenerateNodeFactory
public abstract class PrimitiveNode extends RubyContextSourceNode {

    // The same as "undefined" in Ruby code
    public static final Object FAILURE = NotProvided.INSTANCE;

    @Override
    public RubyNode cloneUninitialized() {
        String primitiveName = getClass().getSuperclass().getAnnotation(Primitive.class).name();
        var factory = getLanguage().primitiveManager.getPrimitive(primitiveName).getFactory();
        var copy = (PrimitiveNode) CoreMethodNodeManager.createNodeFromFactory(factory, RubyNode.EMPTY_ARRAY);
        return copy.copyFlags(this);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy