Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,10 +0,0 @@
|
|||
package OO_Privacy is
|
||||
|
||||
type Confidential_Stuff is tagged private;
|
||||
subtype Password_Type is String(1 .. 8);
|
||||
|
||||
private
|
||||
type Confidential_Stuff is tagged record
|
||||
Password: Password_Type := "default!"; -- the "secret"
|
||||
end record;
|
||||
end OO_Privacy;
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
with OO_Privacy, Ada.Unchecked_Conversion, Ada.Text_IO;
|
||||
|
||||
procedure OO_Break_Privacy is
|
||||
|
||||
type Hacker_Stuff is tagged record
|
||||
Password: OO_Privacy.Password_Type := "?unknown";
|
||||
end record;
|
||||
|
||||
function Hack is new Ada.Unchecked_Conversion
|
||||
(Source => OO_Privacy.Confidential_Stuff, Target => Hacker_Stuff);
|
||||
|
||||
C: OO_Privacy.Confidential_Stuff; -- which password is hidden inside C?
|
||||
|
||||
begin
|
||||
Ada.Text_IO.Put_Line("The secret password is """ & Hack(C).Password & """");
|
||||
end OO_Break_Privacy;
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
package OO_Privacy.Friend is -- child package of OO.Privacy
|
||||
|
||||
function Get_Password(Secret: Confidential_Stuff) return String;
|
||||
|
||||
end OO_Privacy.Friend;
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
package body OO_Privacy.Friend is -- implementation of the child package
|
||||
|
||||
function Get_Password(Secret: Confidential_Stuff) return String is
|
||||
(Secret.Password);
|
||||
|
||||
end OO_Privacy.Friend;
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
with OO_Privacy.Friend, Ada.Text_IO;
|
||||
|
||||
procedure Bypass_OO_Privacy is
|
||||
|
||||
C: OO_Privacy.Confidential_Stuff; -- which password is hidden inside C?
|
||||
|
||||
begin
|
||||
Ada.Text_IO.Put_Line("Password: """ &
|
||||
OO_Privacy.Friend.Get_Password(C) &
|
||||
"""");
|
||||
end Bypass_OO_Privacy;
|
||||
|
|
@ -1,18 +1,14 @@
|
|||
(notonline)-->
|
||||
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (no class under p2js)</span>
|
||||
<span style="color: #008080;">class</span> <span style="color: #000000;">test</span>
|
||||
<span style="color: #008080;">private</span> <span style="color: #004080;">string</span> <span style="color: #000000;">msg</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"this is a test"</span>
|
||||
<span style="color: #008080;">procedure</span> <span style="color: #000000;">show</span><span style="color: #0000FF;">()</span> <span style="color: #0000FF;">?</span><span style="color: #7060A8;">this</span><span style="color: #0000FF;">.</span><span style="color: #000000;">msg</span> <span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">class</span>
|
||||
<span style="color: #000000;">test</span> <span style="color: #000000;">t</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">new</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #000000;">t</span><span style="color: #0000FF;">.</span><span style="color: #000000;">show</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #000080;font-style:italic;">--?t.msg -- illegal
|
||||
--t.msg = "this is broken" -- illegal</span>
|
||||
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #000000;">structs</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span> <span style="color: #008080;">as</span> <span style="color: #000000;">structs</span>
|
||||
<span style="color: #008080;">constant</span> <span style="color: #000000;">ctx</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">routine_id</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"test"</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- magic/context
|
||||
--constant ctx = "test" -- also works
|
||||
--constant ctx = test -- also works</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #000000;">structs</span><span style="color: #0000FF;">:</span><span style="color: #000000;">fetch_field</span><span style="color: #0000FF;">(</span><span style="color: #000000;">t</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"msg"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">ctx</span><span style="color: #0000FF;">)&</span><span style="color: #008000;">" (with some magic)"</span>
|
||||
<span style="color: #000000;">structs</span><span style="color: #0000FF;">:</span><span style="color: #000000;">store_field</span><span style="color: #0000FF;">(</span><span style="color: #000000;">t</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"msg"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"this breaks privacy"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">ctx</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #000000;">t</span><span style="color: #0000FF;">.</span><span style="color: #000000;">show</span><span style="color: #0000FF;">()</span>
|
||||
<!--
|
||||
without js -- (no class under p2js)
|
||||
class test
|
||||
private string msg = "this is a test"
|
||||
procedure show() ?this.msg end procedure
|
||||
end class
|
||||
test t = new()
|
||||
t.show()
|
||||
--?t.msg -- illegal
|
||||
--t.msg = "this is broken" -- illegal
|
||||
include builtins\structs.e as structs
|
||||
constant ctx = test -- magic/context
|
||||
?structs:fetch_field(t,"msg",ctx)&" (with some magic)"
|
||||
structs:store_field(t,"msg","this breaks privacy",ctx)
|
||||
t.show()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue