-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NullPlugin and primitiveUtcWithOffset (#3)
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/de.hpi.swa.graal.squeak/src/de/hpi/swa/graal/squeak/nodes/plugins/NullPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package de.hpi.swa.graal.squeak.nodes.plugins; | ||
|
||
import java.util.List; | ||
|
||
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; | ||
import com.oracle.truffle.api.dsl.GenerateNodeFactory; | ||
import com.oracle.truffle.api.dsl.NodeFactory; | ||
import com.oracle.truffle.api.dsl.Specialization; | ||
|
||
import de.hpi.swa.graal.squeak.model.ClassObject; | ||
import de.hpi.swa.graal.squeak.model.CompiledMethodObject; | ||
import de.hpi.swa.graal.squeak.nodes.primitives.AbstractPrimitiveFactoryHolder; | ||
import de.hpi.swa.graal.squeak.nodes.primitives.AbstractPrimitiveNode; | ||
import de.hpi.swa.graal.squeak.nodes.primitives.PrimitiveInterfaces.UnaryPrimitive; | ||
import de.hpi.swa.graal.squeak.nodes.primitives.SqueakPrimitive; | ||
|
||
public final class NullPlugin extends AbstractPrimitiveFactoryHolder { | ||
@GenerateNodeFactory | ||
@SqueakPrimitive(names = "primitiveUtcWithOffset") | ||
protected abstract static class PrimUtcWithOffsetNode extends AbstractPrimitiveNode implements UnaryPrimitive { | ||
protected PrimUtcWithOffsetNode(final CompiledMethodObject method) { | ||
super(method); | ||
} | ||
|
||
@Specialization | ||
@TruffleBoundary | ||
protected final Object doUTC(@SuppressWarnings("unused") final ClassObject receiver) { | ||
return method.image.newList(new long[]{System.currentTimeMillis() * 1000L, java.time.ZonedDateTime.now().getOffset().getTotalSeconds()}); | ||
} | ||
} | ||
|
||
@Override | ||
public List<? extends NodeFactory<? extends AbstractPrimitiveNode>> getFactories() { | ||
return NullPluginFactory.getFactories(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters