From c56cdd63089f9487ba3380ffc41c6eb5fc3cb461 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 19 Jun 2015 17:35:06 -0700 Subject: 1601 --- 042new.cc | 8 ++++++-- edit.mu | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/042new.cc b/042new.cc index 7b4054ec..324fad16 100644 --- a/042new.cc +++ b/042new.cc @@ -35,7 +35,8 @@ if (inst.operation == Recipe_number["new"]) { // End NEW Transform Special-cases // first arg must be of type 'type' assert(SIZE(inst.ingredients) >= 1); - assert(is_literal(inst.ingredients.at(0))); + if (!is_literal(inst.ingredients.at(0))) + raise << "expected literal, got " << inst.ingredients.at(0).to_string() << '\n' << die(); if (inst.ingredients.at(0).properties.at(0).second.at(0) != "type") raise << "tried to allocate non-type " << inst.ingredients.at(0).to_string() << " in recipe " << Recipe[r].name << '\n' << die(); if (Type_number.find(inst.ingredients.at(0).name) == Type_number.end()) @@ -190,7 +191,10 @@ recipe main [ +mem: storing 171 in location 3 :(before "End NEW Transform Special-cases") - if (inst.ingredients.at(0).properties.at(0).second.at(0) == "literal-string") { + if (!inst.ingredients.empty() + && !inst.ingredients.at(0).properties.empty() + && !inst.ingredients.at(0).properties.at(0).second.empty() + && inst.ingredients.at(0).properties.at(0).second.at(0) == "literal-string") { // skip transform inst.ingredients.at(0).initialized = true; goto end_new_transform; diff --git a/edit.mu b/edit.mu index 85250b27..9faf9059 100644 --- a/edit.mu +++ b/edit.mu @@ -30,6 +30,25 @@ scenario edit-prints-string-to-screen [ ] ] +container editor-data [ + initial-contents:address:stream # lazily added to other fields as necessary + lines:address:duplex-list # doubly linked list of lines, each line containing a buffer of characters + top-of-screen:address:duplex-list + screen:address:screen # will be used later for colorizing +] + +recipe new-editor-data [ + default-space:address:array:location <- new location:type, 30:literal + s:address:array:character <- next-ingredient + screen:address <- next-ingredient + result:address:editor-data <- new editor-data:type + init:address:address:stream <- get-address result:address:editor-data/deref, initial-contents:offset + init:address:address:stream/deref <- new-stream s:address:array:character + screen-dest:address:address:screen <- get-address result:address:editor-data/deref, screen:offset + screen-dest:address:address:screen/deref <- copy screen:address + reply result:address:editor-data +] + recipe edit [ default-space:address:array:location <- new location:type, 30:literal s:address:array:character <- next-ingredient -- cgit 1.4.1-2-gfad0