X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Finternal%2Fcodegen%2Futils%2FCopyContext.java;h=48f43d173a7ed9c91530af081429f38977fe5616;hb=9fafa930ec59d0001415f5cff3579456ec38ae65;hp=e5fb40a8a709807d43d702e94b04cb70bbad92ad;hpb=9a175feb652b2b7bba7afa540831b9076be3c10e;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/CopyContext.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/CopyContext.java index e5fb40a8a..48f43d173 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/CopyContext.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/utils/CopyContext.java @@ -1,103 +1,103 @@ -package org.simantics.scl.compiler.internal.codegen.utils; - -import org.simantics.scl.compiler.common.exceptions.InternalCompilerError; -import org.simantics.scl.compiler.internal.codegen.continuations.Cont; -import org.simantics.scl.compiler.internal.codegen.continuations.ContRef; -import org.simantics.scl.compiler.internal.codegen.references.BoundVar; -import org.simantics.scl.compiler.internal.codegen.references.Val; -import org.simantics.scl.compiler.internal.codegen.references.ValRef; -import org.simantics.scl.compiler.top.SCLCompilerConfiguration; -import org.simantics.scl.compiler.types.TVar; -import org.simantics.scl.compiler.types.Type; -import org.simantics.scl.compiler.types.Types; - -import gnu.trove.map.hash.THashMap; - -public class CopyContext { - - THashMap valMap = new THashMap(); - THashMap contMap = new THashMap(); - THashMap tvarMap = new THashMap(); - - public void put(Val src, Val tgt) { - Val ret = valMap.put(src, tgt); - if(SCLCompilerConfiguration.DEBUG) { - if(ret != null) - throw new InternalCompilerError(); - } - } - - public void put(Cont src, Cont tgt) { - Cont ret = contMap.put(src, tgt); - if(SCLCompilerConfiguration.DEBUG) { - if(ret != null) - throw new InternalCompilerError(); - } - } - - public TVar[] copyParameters(TVar[] vars) { - TVar[] result = new TVar[vars.length]; - for(int i=0;i T copy(T src) { - Val tgt = valMap.get(src); - if(tgt != null) - return (T)tgt; - tgt = src.copy(tvarMap); - valMap.put(src, tgt); - return (T)tgt; - } - - public ContRef[] copy(ContRef[] src) { - ContRef[] tgt = new ContRef[src.length]; - for(int i=0;i T copy(T src) { - Cont tgt = contMap.get(src); - if(tgt != null) - return (T)tgt; - tgt = src.copy(this); - contMap.put(src, tgt); - return (T)tgt; - } - - public Type copyType(Type type) { - return type.replace(tvarMap); - } - -} +package org.simantics.scl.compiler.internal.codegen.utils; + +import org.simantics.scl.compiler.common.exceptions.InternalCompilerError; +import org.simantics.scl.compiler.internal.codegen.continuations.Cont; +import org.simantics.scl.compiler.internal.codegen.continuations.ContRef; +import org.simantics.scl.compiler.internal.codegen.references.BoundVar; +import org.simantics.scl.compiler.internal.codegen.references.Val; +import org.simantics.scl.compiler.internal.codegen.references.ValRef; +import org.simantics.scl.compiler.top.SCLCompilerConfiguration; +import org.simantics.scl.compiler.types.TVar; +import org.simantics.scl.compiler.types.Type; +import org.simantics.scl.compiler.types.Types; + +import gnu.trove.map.hash.THashMap; + +public class CopyContext { + + THashMap valMap = new THashMap(); + THashMap contMap = new THashMap(); + THashMap tvarMap = new THashMap(); + + public void put(Val src, Val tgt) { + Val ret = valMap.put(src, tgt); + if(SCLCompilerConfiguration.DEBUG) { + if(ret != null) + throw new InternalCompilerError(); + } + } + + public void put(Cont src, Cont tgt) { + Cont ret = contMap.put(src, tgt); + if(SCLCompilerConfiguration.DEBUG) { + if(ret != null) + throw new InternalCompilerError(); + } + } + + public TVar[] copyParameters(TVar[] vars) { + TVar[] result = new TVar[vars.length]; + for(int i=0;i T copy(T src) { + Val tgt = valMap.get(src); + if(tgt != null) + return (T)tgt; + tgt = src.copy(tvarMap); + valMap.put(src, tgt); + return (T)tgt; + } + + public ContRef[] copy(ContRef[] src) { + ContRef[] tgt = new ContRef[src.length]; + for(int i=0;i T copy(T src) { + Cont tgt = contMap.get(src); + if(tgt != null) + return (T)tgt; + tgt = src.copy(this); + contMap.put(src, tgt); + return (T)tgt; + } + + public Type copyType(Type type) { + return type.replace(tvarMap); + } + +}