Jump to content



Photo

How does the autoit interpreter do...


  • Please log in to reply
20 replies to this topic

#1 twitchyliquid64

twitchyliquid64

    Peace. Always.

  • Active Members
  • PipPipPipPipPipPip
  • 520 posts

Posted 06 May 2011 - 12:25 AM

Hi all,

Been looking through the public bits of the autoit source code, and there are a couple of things I dont understand (probably deriving from my lack of experience with c++)

I was wondering how Autoit Implements...

VARIABLE Lookup and storage:
My guesses is that variables are organised into some sort of ordered linked list, Which is used for lookup. Is this correct?? If not, how is it implemented??

Interrupts:
Functions like HotKeySet can interrupt the execution of the script, calling another function instead. How does autoit do this??

Parser:
Whats the name of the algorithm implemented? Is it the Shift/Reduce Thingy???


Thanks heaps in advance,

-Hyperzap.

@Manadar: I am still studying as well!
ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search







#2 Manadar

Manadar

    Taking a REST.

  • MVPs
  • 10,714 posts

Posted 06 May 2011 - 01:33 AM

Try the file thats cryptically called variable_table.cpp. The parser is a left-to-right parser which implements shunting yard, among other things.

Edited by Manadar, 06 May 2011 - 01:33 AM.


#3 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 06 May 2011 - 02:36 AM

Magic.

#4 twitchyliquid64

twitchyliquid64

    Peace. Always.

  • Active Members
  • PipPipPipPipPipPip
  • 520 posts

Posted 06 May 2011 - 03:18 AM

Try the file thats cryptically called variable_table.cpp. The parser is a left-to-right parser which implements shunting yard, among other things.


Yes - I have seen variable_table.cpp, what I mean is that I dont understand it, I can see It implements some kind of data structure with pointers to other data structures, which suggests to me that it is a linked list, but then there is more to the story -as some kind of greater than/less than comparision is used (I think), which suggests to me that there is an ordering and lookup system. How this is implemented, what is used as the basis for ordering, what the memory representation actually looks like, is yet to be discovered (assuming of course, that I am right).


Shunting Yard? Really? Its a very LONG implementation. It thought it was an LALR Shift/Reduce Algorithm. Hmmmm.



Any Idea how execution is interrupted? (eg: HotKeySet)??????

Thx.

Edited by hyperzap, 06 May 2011 - 03:18 AM.

ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

#5 twitchyliquid64

twitchyliquid64

    Peace. Always.

  • Active Members
  • PipPipPipPipPipPip
  • 520 posts

Posted 06 May 2011 - 03:20 AM

Magic.


Indeed. But the human body is magic and medical science has allowed us to take the interesting bits out of it as well.

Edited by hyperzap, 06 May 2011 - 03:21 AM.

ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

#6 Jon

Jon

    Up all night to get lucky

  • Administrators
  • 9,544 posts

Posted 06 May 2011 - 10:36 PM

It's shift/reduce. The public source code is almost unrecognizable to what it is like now however. The variable look up table IIRC was a linked list but may be a binary tree now for more speed. But at the most basic level, yeah a linked list.

#7 twitchyliquid64

twitchyliquid64

    Peace. Always.

  • Active Members
  • PipPipPipPipPipPip
  • 520 posts

Posted 07 May 2011 - 02:08 AM

It's shift/reduce. The public source code is almost unrecognizable to what it is like now however. The variable look up table IIRC was a linked list but may be a binary tree now for more speed. But at the most basic level, yeah a linked list.


thankyou.

also, how are you doing interrupts? (like when hotkeyset interrupts code execution to run its corresponding function.)???
ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

#8 Jon

Jon

    Up all night to get lucky

  • Administrators
  • 9,544 posts

Posted 07 May 2011 - 07:39 AM

They are not really interrupts they are more like "doing something else rather than running a line of script". Before a line of code is run we check if there are any windows messages that need processing - hotkeys appear as one of these messages. So then we just save the state of the script and then recursively execute the hotkey function.

#9 Mat

Mat

    43 38 48 31 30 4E 34 4F 32

  • MVPs
  • 4,101 posts

Posted 08 May 2011 - 12:19 PM

Since someone has been asking already, I have one question that I've been trying to get from the source code: How do you handle variant casting? I've posted a question on stackoverflow (here) to try and see what systems other people recommend.

I don't know where I'm going, but I'm on my way.

AutoIt Project Listing


#10 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 9,716 posts

Posted 08 May 2011 - 12:45 PM

You have to store some indicator of what you are holding. If it matches the destination type, you're done.
If it can be converted (based on rules you define), convert it.
If it can't, error out.

That's how any cast works.

#11 Mat

Mat

    43 38 48 31 30 4E 34 4F 32

  • MVPs
  • 4,101 posts

Posted 08 May 2011 - 12:50 PM

Yes, but how would you define the rules? That's the bit I'm interested in.

I don't know where I'm going, but I'm on my way.

AutoIt Project Listing


#12 ProgAndy

ProgAndy

    You need AutoItObject

  • MVPs
  • 2,508 posts

Posted 08 May 2011 - 01:01 PM

Yes, but how would you define the rules? That's the bit I'm interested in.

Create a variant-class which will be used to store variables. Implement the operators including automatic conversion. If you don't want to do it from scratch, use COM-Varaints as a basis.
*GERMAN* Posted Image [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

#13 Mat

Mat

    43 38 48 31 30 4E 34 4F 32

  • MVPs
  • 4,101 posts

Posted 08 May 2011 - 01:08 PM

Create a variant-class which will be used to store variables. Implement the operators including automatic conversion. If you don't want to do it from scratch, use COM-Varaints as a basis.

I've already done that. I have a variant class that overloads the operators and the only thing I need to do is the conversion/casting itself. Of the conversion and casting I have a header defining the type, which is extended by the variant class to include the data.

All I am interested in is the specific process of casting data D from type F to type T, knowing that such a cast is possible, and F != T.

I don't know where I'm going, but I'm on my way.

AutoIt Project Listing


#14 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 9,716 posts

Posted 08 May 2011 - 07:53 PM

The rules are what you feel like. This is a pretty common variant rule set.

Can convert to string if it's a string, number, or boolean.
Can convert to a number if it's a number. Can parse string for number if you choose. Can optionally convert booleans to 0s and 1s.
Can convert to a boolean using rules like 0/"" = false, everything else = true.
Arrays can't be converted to anything else except maybe strings if they are character arrays.

#15 Jon

Jon

    Up all night to get lucky

  • Administrators
  • 9,544 posts

Posted 08 May 2011 - 08:14 PM

We made it up as we went along. It still comes back to haunt us.

#16 James

James

    jbrooksuk

  • MVPs
  • 9,498 posts

Posted 08 May 2011 - 10:04 PM

We made it up as we went along. It still comes back to haunt us.


Always a good time to renovate.

#17 twitchyliquid64

twitchyliquid64

    Peace. Always.

  • Active Members
  • PipPipPipPipPipPip
  • 520 posts

Posted 09 May 2011 - 03:18 AM

Always a good time to renovate.


It has been a while since a new version of autoit has been released. Autoit v4 has been forshadowed for some time. Is there going to be another version?? if yes what will be included??? how can we contribute??? when will it be released???

If the answer is yes, Im pretty sure there is an army of people who are willing to help out in any way.
ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search

#18 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 9,716 posts

Posted 09 May 2011 - 01:45 PM

People have been talking about v4 since v3 came out.

Edited by Richard Robertson, 09 May 2011 - 03:31 PM.


#19 trancexx

trancexx

    Hm, I really shouldn't.

  • Active Members
  • PipPipPipPipPipPip
  • 5,243 posts

Posted 09 May 2011 - 03:46 PM

People have been talking about v4 since v3 came out.

I'm curious. Whose suggestion was to edit the post? Manadar's?

Edited by trancexx, 09 May 2011 - 03:48 PM.

eMyvnE


#20 AdmiralAlkex

AdmiralAlkex

    I'm on a boat

  • MVPs
  • 4,493 posts

Posted 09 May 2011 - 04:20 PM

I'm curious. Whose suggestion was to edit the post? Manadar's?

What did it say earlier? (I forgot)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users