Você está na página 1de 10

Ring Documentation, Release 1.5.

Operation Description
If stack[nSize-1] <= stack[nSize] , POP stack[nSize], set
• ICO_LESSEQUAL
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
If stack[nSize-1] = stack[nSize] , POP stack[nSize], set
• ICO_EQUAL
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
If stack[nSize-1] < stack[nSize] , POP stack[nSize], set
• ICO_LESS
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
If stack[nSize-1] > stack[nSize] , POP stack[nSize], set
• ICO_GREATER
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
If stack[nSize-1] >= stack[nSize] , POP stack[nSize], set
• ICO_GREATEREQUAL
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0
If stack[nSize-1] != stack[nSize] , POP stack[nSize], set
• ICO_NOTEQUAL
Stack[nSize-1] = 1 else set Stack[nSize-1] = 0

(Math)
Operation Description
Stack[nSize-1] = Stack[nSize-1] + Stack[nSize] , POP
• ICO_SUM
stack[nSize]
Stack[nSize-1] = Stack[nSize-1] - Stack[nSize] , POP
• ICO_SUB
stack[nSize]
Stack[nSize-1] = Stack[nSize-1] * Stack[nSize] , POP
• ICO_MUL
stack[nSize]
Stack[nSize-1] = Stack[nSize-1] / Stack[nSize] , POP
• ICO_DIV
stack[nSize]
Stack[nSize-1] = Stack[nSize-1] % Stack[nSize] , POP
• ICO_MOD
stack[nSize]
Stack[nSize] = - Stack[nSize-1]
• ICO_NEG

Stack[nSize] = Stack[nSize] + 1
• ICO_PLUSPLUS

Stack[nSize] = Stack[nSize] - 1
• ICO_MINUSMINUS

(Logic)
Operation Description
Stack[nSize-1] = Stack[nSize-1] && Stack[nSize] ,
• ICO_AND
POP stack[nSize]
Stack[nSize-1] = Stack[nSize-1] || Stack[nSize] , POP
• ICO_OR
stack[nSize]
Stack[nSize] = ! Stack[nSize]
• ICO_NOT

(Lists)

96.6. Virtual Machine (VM) Instructions 1735


Ring Documentation, Release 1.5.1

Operation Description
Start New List in Temp. Memory
• ICO_LISTSTART

Add List Item


• ICO_LISTITEM

End List
• ICO_LISTEND

Stack[nSize-1] = Stack[nSize-1] VV [ Stack[nSize] ] ,


• ICO_LOADINDEXADDRESS
POP stack[nSize]

(Functions)
Operation Description
Find function
• ICO_LOADFUNC

Call function
• ICO_CALL

Return from function


• ICO_RETURN

Return NULl from function


• ICO_RETNULL

Return after eval()


• ICO_RETFROMEVAL

Return the list item reference - not the value


• ICO_RETITEMREF

Start new function


• ICO_NEWFUNC

Flag to determine where to jump later (after


• ICO_BLOCKFLAG
ICO_RETURN)
Start executing function
• ICO_FUNCEXE

End function execution


• ICO_ENDFUNCEXE

Anonymous function
• ICO_ANONYMOUS

(User Interface)
Operation Description
Print value to the standard output
• ICO_PRINT

Get input from the keyboard


• ICO_GIVE

(End Program/Loop)

96.6. Virtual Machine (VM) Instructions 1736


Ring Documentation, Release 1.5.1

Operation Description
End execution of VM
• ICO_BYE

Place to exit to from a loop


• ICO_EXITMARK

Remove exit mark


• ICO_POPEXITMARK

Break from one loop or more


• ICO_EXIT

Continue to next loop


• ICO_LOOP

(For Better Performance)


Operation Description
Push pointer to the stack
• ICO_PUSHP

Increment variable value using pointer


• ICO_INCP

Push value of variable using variable pointer


• ICO_PUSHPV

Increment then jump


• ICO_INCJUMP

Increment using pointer then jump


• ICO_INCPJUMP

Jump if variable value is <= numeric value


• ICO_JUMPVARLENUM

Jump if variable value (using pointer) <= numeric value


• ICO_JUMPVARPLENUM

Push function pointer


• ICO_LOADFUNCP

Push pointer to local variable


• ICO_PUSHPLOCAL

Increment value using pointer to local variable then


• ICO_INCLPJUMP
jump
Jump if the variable value (using pointer) <= numeric
• ICO_JUMPVARLPLENUM
value
Increment value using variable pointer then jump (for
• ICO_INCPJUMPSTEP1
loop step = 1)
Increment value using variable pointer then jump (for
• ICO_JUMPVARPLENUMSTEP1
loop step = 1)

(Try-Catch-Done)

96.6. Virtual Machine (VM) Instructions 1737


Ring Documentation, Release 1.5.1

Operation Description
Start try region
• ICO_TRY

End try region


• ICO_DONE

(Duplicate and Range)


Operation Description
Duplicate stack value
• ICO_DUPLICATE

Create list from value to value


• ICO_RANGE

(OOP)
Operation Description
Create new object, get class name from the IR, push ob-
• ICO_NEWOBJ
ject pointer to the stack.
Called after creating new object, set the active scope to
• ICO_SETSCOPE
be the object scope.
Get object attribute, push the pointer to the stack.
• ICO_LOADSUBADDRESS

Find object method


• ICO_LOADMETHOD

Used after calling a method - normal case


• ICO_AFTERCALLMETHOD

Used after calling a method - second case


• ICO_AFTERCALLMETHOD2

Start new class region


• ICO_NEWCLASS

Open brace
• ICO_BRACESTART

End brace
• ICO_BRACEEND

Import package
• ICO_IMPORT

start private attributes region


• ICO_PRIVATE

set attribute value - check for setter.


• ICO_SETPROPERTY

call call init() method.


• ICO_CALLCLASSINIT

(Other)

96.6. Virtual Machine (VM) Instructions 1738


Ring Documentation, Release 1.5.1

Operation Description
Copy by reference
• ICO_SETREFERENCE

Remove reference
• ICO_KILLREFERENCE

Determine the left side variable


• ICO_ASSIGNMENTPOINTER

Determine operators like += , -= , ... etc


• ICO_BEFOREEQUAL

(Bitwise Operators)
Operation Description
Stack[nSize-1] = Stack[nSize-1] & Stack[nSize] , POP
• ICO_BITAND
stack[nSize]
Stack[nSize-1] = Stack[nSize-1] | Stack[nSize] , POP
• ICO_BITOR
stack[nSize]
Stack[nSize-1] = Stack[nSize-1] ^ Stack[nSize] , POP
• ICO_BITXOR
stack[nSize]
Stack[nSize] = ! Stack[nSize]
• ICO_BITNOT

Stack[nSize-1] = Stack[nSize-1] << Stack[nSize] , POP


• ICO_BITSHL
stack[nSize]
Stack[nSize-1] = Stack[nSize-1] >> Stack[nSize] , POP
• ICO_BITSHR
stack[nSize]

(For Step)
Operation Description
Determine step number in for loop
• ICO_STEPNUMBER

POP step number from steps stack


• ICO_POPSTEP

Load the first address of variable name


• ICO_LOADAFIRST

96.6. Virtual Machine (VM) Instructions 1739


CHAPTER

NINETYSEVEN

RESOURCES

In this section you will find resources about the language

97.1 Ring Language Website

For news about the language check the website


http://ring-lang.net
http://ring-lang.sf.net

97.2 Ring Group

For questions use the Ring Group (English)


https://groups.google.com/forum/#!forum/ring-lang

97.3 Contact the Authors

Name : Eng. Mahmoud Samir Fayed


Country : Egypt
Email : msfclipper@yahoo.com
Facebook : https://facebook.com/mahmoudfayed1986
LinkedIn : https://sa.linkedin.com/in/mahmoudfayed1986
Name : Dr. Atif M. Alamri
Country : Saudi Arabia
Email : atif@ksu.edu.sa
LinkedIn : https://sa.linkedin.com/in/dr-atif-alamri-8b341747
Ring Team : http://ring-lang.sourceforge.net/team.html

1740
INDEX

Access List Items by String Index Introduction, 1


Lists, 178 Quotes about Ring, 1
Access Objects Using Braces Samples in this book, 8
Object Oriented Programming, 255 Squares Puzzle Game, 4
Access String Letters TicTacToe Game, 4
Strings, 180 Werdy Application, 6
Accessing the class attributes from braces inside class apppath()
methods Stdlib Functions, 289
Scope Rules, 659 Arithmetic Operators
Add Items Operators, 139
Lists, 172 Ascii()
addattribute() Data Type, 196
Reflection and Meta-programming, 282 Assert()
AddDays() Eval() and Debugging, 222
Date and Time, 188 Assignment Operators
Adding code to the generated code Operators, 140
Code Generator, 744 attributes()
Adding Hyperlink to QLabel Reflection and Meta-programming, 279
Desktop and Mobile Development, 563
addmethod() Better Call Command
Reflection and Meta-programming, 282 What is new in Ring 1.2?, 94
Analog Clock Better Code Generator for Extensions
Applications developed in little hours, 5 What is new in Ring 1.1?, 104
Animate Class What is new in Ring 1.5?, 50
Game Engine for 2D Games, 436 Better Documentation
Animate Events What is new in Ring 1.1?, 104
Game Engine for 2D Games, 447 Better Documentation Generator for Extensions
Animation What is new in Ring 1.5?, 51
Game Engine for 2D Games, 441 Better Functions
Animation and Functions What is new in Ring 1.2?, 91
Game Engine for 2D Games, 442 Better Loop|Exit Command
Anonymous and Nested Functions What is new in Ring 1.3?, 85
Functional Programming, 268 Better Natural Language Programming Support
Application Class What is new in Ring 1.1?, 96
Web Development (CGI Library), 399 Better Objects Library
Applications What is new in Ring 1.5?, 37
How to contribute?, 113 Better Quality
Applications developed in little hours What is new in Ring 1.2?, 94
Analog Clock, 5 What is new in Ring 1.5?, 59
FetchStockData Application, 3 Better Ring Notepad
Fifteen Puzzle Game, 3 What is new in Ring 1.2?, 91
Fifteen Puzzle Game 2, 7 What is new in Ring 1.3?, 81
What is new in Ring 1.5?, 28

1741
Ring Documentation, Release 1.5.1

Better RingQt Building From Source Code, 106


What is new in Ring 1.2?, 91 Building using Ubuntu Linux
What is new in Ring 1.3?, 77 Building From Source Code, 107
What is new in Ring 1.4?, 72
What is new in Ring 1.5?, 35 Calculator Application
Better StdLib What is new in Ring 1.5?, 27
What is new in Ring 1.3?, 85 Call Functions
What is new in Ring 1.4?, 70 Functions - First Style, 159
What is new in Ring 1.5?, 31 Functions - Second Style, 163
Better WebLib Functions - Third Style, 167
What is new in Ring 1.4?, 70 callgc()
What is new in Ring 1.5?, 32 Low Level Functions, 702
binarydigits() Calling a function sharing the name with a method in the
Stdlib Functions, 298 current class
Bitwise Operators Scope Rules for Functions and Methods, 670
Operators, 139 Can I connect to dbase/harbour database?
BraceError() Method Frequently Asked Questions, 1720
Natural Language Programming, 341 Can Ring work on Windows XP?
BraceExprEval Method Frequently Asked Questions, 1722
Natural Language Programming, 340 capitalized()
BraceStart and BraceEnd Methods Stdlib Functions, 292
Natural Language Programming, 339 cfunctions()
Branching Reflection and Meta-programming, 272
Control Structures, 142 CGI Support
Control Structures - Second Style, 149 Command Line Options, 700
Control Structures - Third Style, 152 Change Focus
BreakPoint Desktop and Mobile Development, 598
The Trace Library and the Interactive Debugger, 724 Change Language Keywords
Building From Source Code Syntax Flexibility, 672
Building using CMake, 110 Change Language Operators
Building using MacOS X, 109 Syntax Flexibility, 673
Building using Microsoft Windows, 106 Change the ’=’ operator to ’is’
Building using Ubuntu Linux, 107 Natural Language Programming, 337
Introduction, 105 Change the Ring Keyword ’And’
Building Games For Android Natural Language Programming, 335
Building the project, 483 Change the Ring Operator ’+’
Download Requirements and Update the Android Natural Language Programming, 336
SDK, 482 Change: Basic Extensions are separated from RingVM
Introduction, 481 What is new in Ring 1.4?, 65
Project Folder, 482 changestring()
Building RingQt Applications for Mobile Stdlib Functions, 301
Comments about developing for Android using Char()
RingQt, 638 Data Type, 196
Download Requirements, 637 ChDir() Function
Install Qt for Android, 637 System Functions, 218
Introduction, 636 Check Character
Update the Android SDK, 637 Data Type, 191
Building the project Check Data Type
Building Games For Android, 483 Data Type, 190
Building using CMake Check Parameters Count
Building From Source Code, 110 Extension, 731
Building using MacOS X Check Parameters Type
Building From Source Code, 109 Extension, 732
Building using Microsoft Windows Classes and Objects

Index 1742
Ring Documentation, Release 1.5.1

Object Oriented Programming, 253 Comments about evaluation


Classes and their Methods to use the default events Control Structures - First Style, 147
Desktop and Mobile Development, 628 Comments in configuration file
classes() Code Generator, 746
Reflection and Meta-programming, 276 Compact Syntax
classname() Language Design, 19
Reflection and Meta-programming, 278 Compiler and Virtual Machine (VM)
Clean Natural Code How to contribute?, 113
Natural Language Programming, 342 Compiler Errors
Clearerr() Reference, 1729
Files, 208 Composition
clock() Object Oriented Programming, 256
Date and Time, 186 Configuration file
Close Window Event Code Generator, 742
RingLibSDL, 428 Configuration file for the Allegro library
ClosPerSecond() Code Generator, 747
Date and Time, 186 Configuration Files Examples
Code Generator Code Generator, 760
Adding code to the generated code, 744 Configure the Apache web server
Comments in configuration file, 746 Web Development (CGI Library), 351
Configuration file, 742 Conflict between Class Attributes and Local Variables
Configuration file for the Allegro library, 747 Scope Rules, 656
Configuration Files Examples, 760 Conflict between Global Variables and Class Attributes
Constants Type, 747 Frequently Asked Questions, 1708
Defining Constants, 745 Scope Rules, 655
Determine Structure Members Types, 745 Conflict between self inside braces and self in the class
Enum and Numbers, 746 region
Executing code during code generation, 746 Scope Rules, 662
Filtering using Expressions, 746 Constants Type
function prototype, 742 Code Generator, 747
Introduction, 741 Constructor methods in Ring
Prefix for Functions Names, 744 Frequently Asked Questions, 1704
Qt configuration file, 751 Contact the Autor
Register New Functions, 745 Resources, 1740
Threads Support, 749 Control Structures
Using configuration file that wrap C++ library, 751 Branching, 142
Using the tool, 742 Looping, 153
Wrap structures, 744 Control Structures - First Style
Wrapping C++ Classes, 750 Comments about evaluation, 147
CodeEditor Class Do Again Loop, 145
RingQt Classes Reference, 1663 Exit, 145
Command Line Options Exit from two loops, 145
CGI Support, 700 Exit/Loop inside sub functions, 146
Generate Object File, 701 For In Loop, 144
Introduction, 686 for in to modify lists, 144
No Run, 700 For Loop, 143
Performance, 700 Introduction, 141
Printing Final Intermediate Code, 695 Loop Command, 146
Printing Instruction Operation Code, 700 Looping, 143
Printing Intermediate Code, 693 Short-circuit evaluation, 146
Printing Rules, 689 Step Option, 144
Printing Tokens, 687 Switch Statement, 142
Comments about developing for Android using RingQt While Loop, 143
Building RingQt Applications for Mobile, 638 Control Structures - Second Style

Index 1743
Ring Documentation, Release 1.5.1

Branching, 149 Game Engine for 2D Games, 436


Exceptions, 151 Creating Toolbar
For In Loop, 151 Desktop and Mobile Development, 546
For Loop, 150 Creating Windows Installer
If Statement, 149 Distributing Ring Application, 685
Introduction, 148 CRUD Example using MVC
Looping, 150 Web Development (CGI Library), 385
Switch Statement, 149 CurrentDir() Function
Control Structures - Third Style System Functions, 218
Branching, 152
Exceptions, 155 Data Type
For In Loop, 155 Ascii(), 196
For Loop, 154 Char(), 196
If Statement, 152 Check Character, 191
Introduction, 151 Check Data Type, 190
Switch Statement, 152 Conversion, 195
While Loop, 153 Dec(), 196
Conversion Hex(), 196
Data Type, 195 Hex2str(), 197
Conversion Class Introduction, 189
Stdlib Classes, 322 IsAlNum(), 192
Convert between Numbers and Bytes IsAlpha(), 192
What is new in Ring 1.4?, 69 IsCntrl(), 192
Convert Letters Case IsDigit(), 193
Strings, 180 IsGraph(), 193
Cookies IsList(), 191
Web Development (CGI Library), 363 IsLower(), 193
Copy Lists IsNULL(), 191
Lists, 176 IsNumber(), 190
Copy() IsPrint(), 193
Strings, 182 IsPunct(), 194
Could you explain the output of the StrCmp() function? IsSpace(), 194
Frequently Asked Questions, 1711 IsString(), 190
Create Database IsUpper(), 194
MySQL Functions, 237 IsXdigit(), 194
Create Lists Number(), 195
Lists, 172 Str2Hex(), 197
Create Table and Insert Data String(), 195
MySQL Functions, 238 Type(), 191
Create Window Database, ModelBase & ControllerBase classes
RingLibSDL, 425 Web Development (CGI Library), 393
Create Zip File DataType Class
RingZip, 409 Stdlib Classes, 321
Creating a Class for each Window in GUI applications Date and Time
Scope Rules, 661 AddDays(), 188
Creating Menubar clock(), 186
Desktop and Mobile Development, 543 ClosPerSecond(), 186
Creating more than one window Date(), 186
Desktop and Mobile Development, 581 DiffDays(), 188
Creating Reports using the WebLib and the GUILib EpochTime(), 188
Desktop and Mobile Development, 633 Introduction, 185
Creating StatusBar Time(), 186
Desktop and Mobile Development, 547 TimeList(), 187
Creating the Game Window Date()

Index 1744

Você também pode gostar