]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/constants/GetPrimitiveConstant.java
(refs #7250) Merging master, minor CHR bugfixes
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / constants / GetPrimitiveConstant.java
1 package org.simantics.scl.compiler.constants;
2
3 import org.cojen.classfile.TypeDesc;
4 import org.simantics.scl.compiler.internal.codegen.references.IVal;
5 import org.simantics.scl.compiler.internal.codegen.types.JavaTypeTranslator;
6 import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder;
7 import org.simantics.scl.compiler.internal.codegen.utils.TransientClassBuilder;
8 import org.simantics.scl.compiler.types.Type;
9
10 public class GetPrimitiveConstant extends Constant {
11
12     IVal val;
13     TypeDesc typeDesc;
14
15     public GetPrimitiveConstant(Type type, IVal val, TypeDesc typeDesc) {
16         super(type);
17         this.val = val;
18         this.typeDesc = typeDesc;
19     }
20
21     @Override
22     public void push(MethodBuilder mb) {
23         if(typeDesc != TypeDesc.VOID) {
24             val.push(mb);
25             mb.convert(JavaTypeTranslator.toObjectType(typeDesc), typeDesc);
26         }
27     }    
28
29     @Override
30     public Object realizeValue(TransientClassBuilder classLoader) {
31         return val.realizeValue(classLoader);
32     }
33 }