Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add extremely basic writing of PMCs (only if the PMC is null)

  • Loading branch information...
commit e4ed51e6571f7bdaa8ca55aacc91b93aebc27276 1 parent 9f78dc0
@atrodo authored
Showing with 30 additions and 0 deletions.
  1. +6 −0 core.c
  2. +21 −0 pmc.c
  3. +3 −0  pmc.h
View
6 core.c
@@ -780,6 +780,9 @@ core_exec(Lorito_Interp *interp)
case OP_write:
switch (regtype)
{
+ case OP_PMC:
+ fprintf(stdout, "%s", lorito_pmc_str(interp, $P(op->src1))->original);
+ break;
case OP_STR:
fprintf(stdout, "%s", $S(op->src1)->original);
break;
@@ -793,6 +796,9 @@ core_exec(Lorito_Interp *interp)
case OP_say:
switch (regtype)
{
+ case OP_PMC:
+ fprintf(stdout, "%s\n", lorito_pmc_str(interp, $P(op->src1))->original);
+ break;
case OP_STR:
fprintf(stdout, "%s\n", $S(op->src1)->original);
break;
View
21 pmc.c
@@ -130,6 +130,27 @@ lorito_pmc_decode(Lorito_Interp *interp, Lorito_PMC *src, int offset)
return result;
}
+Lorito_Str *
+lorito_pmc_str(Lorito_Interp *interp, Lorito_PMC *src)
+{
+ if (src == null)
+ {
+ return lorito_string(interp, 0, "null");
+ }
+
+ switch (src->internal_type)
+ {
+ default:
+ {
+ // Error
+ return lorito_string(interp, 0, "Invalid PMC type");
+ break;
+ }
+ }
+
+
+}
+
// Default C Methods
void
View
3  pmc.h
@@ -18,6 +18,9 @@ lorito_pmc_encode(Lorito_Interp *interp, Lorito_PMC *dest, int offset, Lorito_PM
Lorito_PMC *
lorito_pmc_decode(Lorito_Interp *interp, Lorito_PMC *src, int offset);
+Lorito_Str *
+lorito_pmc_str(Lorito_Interp *interp, Lorito_PMC *src);
+
void
lorito_pmc_default_lookup(Lorito_Interp *interp, Lorito_Ctx *ctx);
Please sign in to comment.
Something went wrong with that request. Please try again.