vladfolts / oberonjs

Oberon 07 compiler (written in JavaScript and translates to JavaScript)
MIT License
132 stars 22 forks source link

Ошибка при компиляции указательного типа POINTER TO RECORD #17

Closed geniepro closed 11 years ago

geniepro commented 11 years ago

При компиляции следующего кода

MODULE Lists;

TYPE IntegerList = POINTER TO RECORD Elem : INTEGER; Next : IntegerList END;

END Lists.

выдаётся ошибка:

TypeError: Cannot convert 'ownFields[f]' to object

Хотя согласно репорту на Оберон-07 этот код вполне валиден:

TypeDeclaration = identdef "=" StrucType. StrucType = ArrayType | RecordType | PointerType | ProcedureType. PointerType = POINTER TO type. type = qualident | StrucType.

valexey commented 11 years ago

I just updated http://oberspace.dyndns.org/oberonjs.html to the current compiler version, please try to reproduce this bug now.

valexey commented 11 years ago

I just tryed to reproduce this on lasest version:

MODULE Lists;

TYPE
IntegerList = POINTER TO 
 RECORD
  Elem : INTEGER;
  Next : IntegerList
 END;

VAR
 head : IntegerList;

BEGIN
 NEW(head)
END Lists.

Compiles to:

var RTL$ = {
    extend: function extend(methods){
        function Type(){
            for(var m in methods)
                this[m] = methods[m];
        }
        Type.prototype = this.prototype;

        var result = methods.init;
        result.prototype = new Type(); // inherit this.prototype
        result.prototype.constructor = result; // to see constructor name in diagnostic

        result.extend = extend;
        return result;
    }
};
var Lists = function (){
var IntegerList = RTL$.extend({
    init: function IntegerList(){
        this.Elem = 0;
        this.Next = null;
    }
});
var head = null;
head = new IntegerList();
}();

It seems like everything is ok.

geniepro commented 11 years ago

ок, другая проблема вылезла:

MODULE Lists;
IMPORT JS;

TYPE
IntegerList = POINTER TO 
 RECORD
  Elem : INTEGER;
  Next : IntegerList
 END;

VAR
 head : IntegerList;

BEGIN
  NEW(head);
  head.Elem = 123; (* <- вот тут ашыпка! *)
  JS.alert(head.Elem)
END Lists.

выдаётся ошибка:

line 16: PROCEDURE expected, got 'INTEGER'

geniepro commented 11 years ago

а как этот топик вдруг стал Closed? о_О

valexey commented 11 years ago

Please try to replace

head.Elem = 123;

to

head.Elem := 123;
vladfolts commented 11 years ago

geniepro,

So can you close it now?

geniepro commented 11 years ago
head.Elem := 123;

ok, mea culpa ))