Skip to content

Instantly share code, notes, and snippets.

@kpmy
Created December 19, 2014 12:30
Show Gist options
  • Save kpmy/e9c41bb3395a48e917cd to your computer and use it in GitHub Desktop.
Save kpmy/e9c41bb3395a48e917cd to your computer and use it in GitHub Desktop.
До:
PROCEDURE TravObj (obj: DevCPT.Object);
BEGIN
IF obj # NIL THEN
TravObj(obj.left);
IF (obj.mode = Var) OR (obj.mode = VarPar) THEN
Indent; w.WriteString("VAR "); w.WriteString(obj.name$);
w.WriteString(": "); DumpType(obj.typ, NIL); w.WriteLn
ELSIF obj.mode = Typ THEN
Indent; w.WriteString("TYPE "); w.WriteString(obj.name$);
w.WriteString(" = "); DumpType(obj.typ, obj); w.WriteLn
ELSIF obj.mode = Con THEN
Indent; w.WriteString("CONST "); w.WriteString(obj.name$);
w.WriteString(" = "); DumpConst(obj.typ, obj.conval); w.WriteLn
END;
TravObj(obj.right)
END
END TravObj;
После:
PROCEDURE TravObj
VAR @ptr: POINTER TO ARRAY OF CHAR
VAR @tmp: String
VAR @ptr: POINTER TO ARRAY OF CHAR
VAR @tmp: String
VAR @ptr: POINTER TO ARRAY OF CHAR
VAR @tmp: String
VAR obj: Object
BEGIN
IF (obj # NIL) THEN
CALL TravObj(obj^.left);
IF ((CONV(INTEGER, obj^.mode) = 1) OR (CONV(INTEGER, obj^.mode) = 2)) THEN
CALL Indent();
CALL WriteString(w, "VAR ");
COMPOUND
@tmp := obj^.name;
@ptr := NEW ((@tmp^ LEN 0));
@ptr^ := CONV(, @tmp^$);
CALL WriteString(w, @ptr^$);
END COMPOUND;
CALL WriteString(w, ": ");
CALL DumpType(obj^.typ, NIL);
CALL WriteLn(w);
ELSIF (CONV(INTEGER, obj^.mode) = 5) THEN
CALL Indent();
CALL WriteString(w, "TYPE ");
COMPOUND
@tmp := obj^.name;
@ptr := NEW ((@tmp^ LEN 0));
@ptr^ := CONV(, @tmp^$);
CALL WriteString(w, @ptr^$);
END COMPOUND;
CALL WriteString(w, " = ");
CALL DumpType(obj^.typ, obj);
CALL WriteLn(w);
ELSIF (CONV(INTEGER, obj^.mode) = 3) THEN
CALL Indent();
CALL WriteString(w, "CONST ");
COMPOUND
@tmp := obj^.name;
@ptr := NEW ((@tmp^ LEN 0));
@ptr^ := CONV(, @tmp^$);
CALL WriteString(w, @ptr^$);
END COMPOUND;
CALL WriteString(w, " = ");
CALL DumpConst(obj^.typ, obj^.conval);
CALL WriteLn(w);
END;
CALL TravObj(obj^.right);
END;
END TravObj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment