structures finally look like they might be doing something

This commit is contained in:
Danny Yoo 2011-07-03 21:09:54 -04:00
parent 48c8d067ce
commit 570ad83371
4 changed files with 22 additions and 15 deletions

View File

@ -2096,7 +2096,6 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
//immutables,
guard);
console.log('constructor', name, superType, initFieldCount);
var constructorValue =
makePrimitiveProcedure(
constructorName,
@ -2127,6 +2126,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
MACHINE.env[MACHINE.env.length - 1],
jsnums.toFixnum(MACHINE.env[MACHINE.env.length - 2]));
});
accessorValue.structType = structType;
var mutatorValue =
makePrimitiveProcedure(
@ -2139,6 +2139,7 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
jsnums.toFixnum(MACHINE.env[MACHINE.env.length - 2]),
MACHINE.env[MACHINE.env.length - 3]);
});
mutatorValue.structType = structType;
finalizeClosureCall(MACHINE,
@ -2169,7 +2170,8 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
makeList(2, 3),
function(MACHINE){
// FIXME: typechecks
var structType = MACHINE.env[MACHINE.env.length - 1];
// We must guarantee that the ref argument is good.
var structType = MACHINE.env[MACHINE.env.length - 1].structType;
var index = MACHINE.env[MACHINE.env.length - 2];
var name;
if (MACHINE.argcount === 3) {
@ -2194,7 +2196,8 @@ if(this['plt'] === undefined) { this['plt'] = {}; }
makeList(2, 3),
function(MACHINE){
// FIXME: typechecks
var structType = MACHINE.env[MACHINE.env.length - 1];
// We must guarantee that the set! argument is good.
var structType = MACHINE.env[MACHINE.env.length - 1].structType;
var index = MACHINE.env[MACHINE.env.length - 2];
var name;
if (MACHINE.argcount === 3) {

View File

@ -10,4 +10,4 @@
(test "conform.rkt")
(test "sk-generator.rkt")
(test "sk-generator-2.rkt")
#;(test "simple-structs.rkt")
(test "simple-structs.rkt")

View File

@ -1,2 +1,5 @@
3
4
3
4
5

View File

@ -1,16 +1,17 @@
#lang planet dyoo/whalesong
(define-struct p (f r))
struct:p
make-p
p-f
p-r
p?
(define-struct pair (f r))
(define-struct color (r g b))
(define p1 (make-p 3 4))
(p-f p1)
(p-r p1)
(define p1 (make-pair 3 4))
(pair-f p1)
(pair-r p1)
(color-r (make-color 3 4 5))
(color-g (make-color 3 4 5))
(color-b (make-color 3 4 5))