| summaryrefslogtreecommitdiff | 
diff options
| -rw-r--r-- | src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/instruction/generic/ClearCompiler.java | 61 | ||||
| -rw-r--r-- | src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/instruction/generic/FreeCompiler.java | 67 | 
2 files changed, 128 insertions, 0 deletions
| diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/instruction/generic/ClearCompiler.java b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/instruction/generic/ClearCompiler.java new file mode 100644 index 0000000..944ab53 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/instruction/generic/ClearCompiler.java @@ -0,0 +1,61 @@ +package tonkadur.wyrd.v1.compiler.fate.v1.instruction.generic; + +import tonkadur.fate.v1.lang.instruction.generic.Clear; + +import tonkadur.wyrd.v1.lang.computation.Address; + +import tonkadur.wyrd.v1.compiler.fate.v1.Compiler; +import tonkadur.wyrd.v1.compiler.fate.v1.TypeCompiler; +import tonkadur.wyrd.v1.compiler.fate.v1.ComputationCompiler; + +import tonkadur.wyrd.v1.compiler.fate.v1.instruction.GenericInstructionCompiler; + + +public class ClearCompiler extends GenericInstructionCompiler +{ +   public static Class get_target_class () +   { +      return Clear.class; +   } + +   public ClearCompiler (final Compiler compiler) +   { +      super(compiler); +   } + +   public void compile +   ( +      final tonkadur.fate.v1.lang.instruction.GenericInstruction instruction +   ) +   throws Throwable +   { +      final Clear source; +      final ComputationCompiler address_compiler; +      final Address collection_address; + +      source = (Clear) instruction; + +      address_compiler = new ComputationCompiler(compiler); + +      source.get_collection().get_visited_by(address_compiler); + +      if (address_compiler.has_init()) +      { +         result.add(address_compiler.get_init()); +      } + +      collection_address = address_compiler.get_address(); + +      result.add +      ( +         tonkadur.wyrd.v1.compiler.util.Clear.generate +         ( +            compiler.registers(), +            compiler.assembler(), +            collection_address +         ) +      ); + +      address_compiler.release_registers(result); +   } +} diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/instruction/generic/FreeCompiler.java b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/instruction/generic/FreeCompiler.java new file mode 100644 index 0000000..16f77b2 --- /dev/null +++ b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/instruction/generic/FreeCompiler.java @@ -0,0 +1,67 @@ +package tonkadur.wyrd.v1.compiler.fate.v1.instruction.generic; + +import tonkadur.fate.v1.lang.instruction.generic.Free; + +import tonkadur.wyrd.v1.lang.computation.Address; + +import tonkadur.wyrd.v1.lang.instruction.Remove; + +import tonkadur.wyrd.v1.compiler.fate.v1.Compiler; +import tonkadur.wyrd.v1.compiler.fate.v1.TypeCompiler; +import tonkadur.wyrd.v1.compiler.fate.v1.ComputationCompiler; + +import tonkadur.wyrd.v1.compiler.fate.v1.instruction.GenericInstructionCompiler; + + +public class FreeCompiler extends GenericInstructionCompiler +{ +   public static Class get_target_class () +   { +      return Free.class; +   } + +   public FreeCompiler (final Compiler compiler) +   { +      super(compiler); +   } + +   public void compile +   ( +      final tonkadur.fate.v1.lang.instruction.GenericInstruction instruction +   ) +   throws Throwable +   { +      final Free source; +      final ComputationCompiler cc; +      final Address target; + +      source = (Free) instruction; + +      cc = new ComputationCompiler(compiler); + +      source.get_reference().get_visited_by(cc); + +      if (cc.has_init()) +      { +         result.add(cc.get_init()); +      } + +      target = cc.get_address(); + +      if (target == null) +      { +         System.err.println +         ( +            "[P] Argument in (free " +            + source.get_reference() +            + ") did not compile to a address." +         ); + +         System.exit(-1); +      } + +      result.add(new Remove(target)); + +      cc.release_registers(result); +   } +} | 


