Kiwi Engine
VM for interpreter
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Data Structures | Enumerations | Functions
KEInstruction.h File Reference

Define KEInstruction class. More...

#include <Coconut/Coconut.h>
#include "KEValue.h"
#include "KERegister.h"

Go to the source code of this file.

Data Structures

struct  KEInstruction
 

Enumerations

enum  KEOpcode {
  KENopOpcode, KEFunctionOpcode, KECompoundOpcode, KEMovLOpcode,
  KEMovPOpcode, KEMovHOpcode, KEMovROpcode, KESetBoolOpcode,
  KESetSignedIntOpcode, KESetUnsignedIntOpcode, KESetFloatOpcode, KESetStringOpcode,
  KELogicalNotOpcode, KELogicalAndOpcode, KELogicalOrOpcode, KELogicalXorOpcode,
  KEBitNotOpcode, KEBitAndOpcode, KEBitOrOpcode, KEBitXorOpcode,
  KEEqualBoolOpcode, KEEqualSignedIntOpcode, KEEqualUnsignedIntOpcode, KEEqualFloatOpcode,
  KEEqualStringOpcode, KENotEqualBoolOpcode, KENotEqualSignedIntOpcode, KENotEqualUnsignedIntOpcode,
  KENotEqualFloatOpcode, KENotEqualStringOpcode, KELessThanSignedIntOpcode, KELessThanUnsignedIntOpcode,
  KELessThanFloatOpcode, KELessThanStringOpcode, KELessEqualSignedIntOpcode, KELessEqualUnsignedIntOpcode,
  KELessEqualFloatOpcode, KELessEqualStringOpcode, KEGreaterThanSignedIntOpcode, KEGreaterThanUnsignedIntOpcode,
  KEGreaterThanFloatOpcode, KEGreaterThanStringOpcode, KEGreateEqualSignedIntOpcode, KEGreateEqualUnsignedIntOpcode,
  KEGreateEqualFloatOpcode, KEGreateEqualStringOpcode, KENegSignedIntOpcode, KENegFloatOpcode,
  KEAddSignedIntOpcode, KEAddUnsignedIntOpcode, KEAddFloatOpcode, KEAddStringOpcode,
  KESubSignedIntOpcode, KESubUnsignedIntOpcode, KESubFloatOpcode, KEMulSignedIntOpcode,
  KEMulUnsignedIntOpcode, KEMulFloatOpcode, KEDivSignedIntOpcode, KEDivUnsignedIntOpcode,
  KEDivFloatOpcode, KEModSignedIntOpcode, KEModUnsignedIntOpcode, KECastItoUOpcode,
  KECastItoFOpcode, KECastUtoIOpcode, KECastUtoFOpcode, KECastFtoIOpcode,
  KECastFtoUOpcode, KECreateFuncOpcode, KECallFuncOpcode, KECallBuiltinOpcode,
  KERootFrameOpcode, KECreateFrameOpcode, KESetFrameOpcode, KEGetFrameOpcode,
  KECreateArrayOpcode, KESetArrayOpcode, KEGetArrayOpcode, KECreateDictionaryOpcode,
  KESetDictionaryOpcode, KEGetDictionaryOpcode, KEIfThenOpcode, KEIfElseOpcode,
  KESwitchOpcode, KECaseOpcode, KEWhileOpcode, KEForeachArrayOpcode,
  KEForeachDictOpcode, KEReturnOpcode, KENextOpcode, KELastOpcode,
  KEExitOpcode
}
 

Functions

struct KEInstructionKEAllocateFunctionInstruction (struct KEInstruction *body, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate function instruction object. More...
 
struct KEInstructionKEAllocateNopInstruction (struct KELineInfo *linfo, struct CNResource *resource)
 Allocate nop instruction. More...
 
struct KEInstructionKEAllocateCompoundInstruction (struct KELineInfo *linfo, struct CNResource *resource)
 Allocate compound instruction. More...
 
struct KEInstructionKEAllocateMovInstruction (KEOpcode opcode, KERegisterId dstid, KERegisterId srcid, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate move instruction. More...
 
struct KEInstructionKEAllocateSetBoolInstruction (KERegisterId dstid, CNBoolean val, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate set-bool instruction. More...
 
struct KEInstructionKEAllocateSetSignedIntInstruction (KERegisterId dstid, int64_t val, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate set-signed-int instruction. More...
 
struct KEInstructionKEAllocateSetUnsignedIntInstruction (KERegisterId dstid, uint64_t val, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate set-unsigned-int instruction. More...
 
struct KEInstructionKEAllocateSetFloatInstruction (KERegisterId dstid, double val, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate set-float instruction. More...
 
struct KEInstructionKEAllocateSetStringInstruction (KERegisterId dstid, struct CNString *val, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate set-string instruction. More...
 
struct KEInstructionKEAllocateUnaryInstruction (KEOpcode opcode, KERegisterId dstid, KERegisterId srcid, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate unary instruction. More...
 
struct KEInstructionKEAllocateBinaryInstruction (KEOpcode opcode, KERegisterId dstid, KERegisterId leftid, KERegisterId rightid, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate binary instruction. More...
 
struct KEInstructionKEAllocateCreateFunctionInstruction (KERegisterId dstid, struct KEPath *funcpath, struct CNObjectList *hiddenregs, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate create-function instruction. More...
 
struct KEInstructionKEAllocateCallFunctionInstruction (KERegisterId funcid, struct CNObjectList *retregs, struct CNObjectList *paramregs, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate call-function instruction. More...
 
struct KEInstructionKEAllocateCallBuiltinInstruction (struct KEPath *path, struct CNObjectList *retregs, struct CNObjectList *paramregs, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate call-builtin instruction. More...
 
struct KEInstructionKEAllocateRootFrameInstruction (KERegisterId dstid, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate root-frame instruction. More...
 
struct KEInstructionKEAllocateCreateFrameInstruction (KERegisterId dstid, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate create-frame instruction. More...
 
struct KEInstructionKEAllocateSetFrameInstruction (KERegisterId dstid, struct KEPath *dstpath, KERegisterId srcid, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate set-frame instruction. More...
 
struct KEInstructionKEAllocateGetFrameInstruction (KERegisterId dstid, KERegisterId srcid, struct KEPath *srcpath, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate get-frame instruction. More...
 
struct KEInstructionKEAllocateCreateArrayInstruction (KERegisterId dstid, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate create-array instruction. More...
 
struct KEInstructionKEAllocateSetArrayInstruction (KERegisterId dstid, KERegisterId dstindex, KERegisterId srcid, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate set-array instruction. More...
 
struct KEInstructionKEAllocateGetArrayInstruction (KERegisterId dstid, KERegisterId srcid, KERegisterId srcindex, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate get-array instruction. More...
 
struct KEInstructionKEAllocateCreateDictionaryInstruction (KERegisterId dstid, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate create-dictionary instruction. More...
 
struct KEInstructionKEAllocateSetDictionaryInstruction (KERegisterId dstid, KERegisterId dstkey, KERegisterId srcid, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate set-dictionary instruction. More...
 
struct KEInstructionKEAllocateGetDictionaryInstruction (KERegisterId dstid, KERegisterId srcid, KERegisterId srckey, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate get-dictionary instruction. More...
 
struct KEInstructionKEAllocateIfInstruction (KERegisterId condid, struct KEInstruction *theninst, struct KEInstruction *elseinst, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate if instruction. More...
 
struct KEInstructionKEAllocateSwitchInstruction (KERegisterId condid, struct CNObjectList *caseinsts, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate switch instruction. More...
 
struct KEInstructionKEAllocateCaseInstruction (CNBoolean isdef, uint64_t caseval, struct KEInstruction *bodyinst, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate case instruction. More...
 
struct KEInstructionKEAllocateWhileInstruction (KERegisterId condid, struct KEInstruction *bodyinst, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate while instruction. More...
 
struct KEInstructionKEAllocateForeachArrayInstruction (KERegisterId elmid, KERegisterId arrayid, struct KEInstruction *bodyinst, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate foreach-array instruction. More...
 
struct KEInstructionKEAllocateForeachDictionaryInstruction (KERegisterId elmid, KERegisterId dictid, struct KEInstruction *bodyinst, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate foreach-dictionary instruction. More...
 
struct KEInstructionKEAllocateReturnInstruction (struct KELineInfo *linfo, struct CNResource *resource)
 Allocate return instruction. More...
 
struct KEInstructionKEAllocateNextInstruction (struct KELineInfo *linfo, struct CNResource *resource)
 Allocate next instruction. More...
 
struct KEInstructionKEAllocateLastInstruction (struct KELineInfo *linfo, struct CNResource *resource)
 Allocate last instruction. More...
 
struct KEInstructionKEAllocateExitInstruction (KERegisterId codeid, struct KELineInfo *linfo, struct CNResource *resource)
 Allocate exit instruction. More...
 
const char * KEOpcodeString (KEOpcode src)
 Get string to present the opcode. More...
 

Detailed Description

Define KEInstruction class.

Copyright
Copyright (C) 2013 Steel Wheels Project

Enumeration Type Documentation

enum KEOpcode

Opcode of instruction

Function Documentation

struct KEInstruction* KEAllocateBinaryInstruction ( KEOpcode  opcode,
KERegisterId  dstid,
KERegisterId  leftid,
KERegisterId  rightid,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate binary instruction.

Returns
Allocated instruction
Parameters
opcodeOpcode for the instruction
dstidDestination register id
leftidSource left register id
rightidSource right register id
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateCallBuiltinInstruction ( struct KEPath path,
struct CNObjectList *  retregs,
struct CNObjectList *  paramregs,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate call-builtin instruction.

Returns
Allocated instruction
Parameters
pathPath of the built-in function
retregsList of registers to store return values
paramregsList of registers to pass parameter values
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateCallFunctionInstruction ( KERegisterId  funcid,
struct CNObjectList *  retregs,
struct CNObjectList *  paramregs,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate call-function instruction.

Returns
Allocated instruction
Parameters
funcidRegister id which contains pointer of the function
retregsList of registers to store return values
paramregsList of registers to pass parameter values
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateCaseInstruction ( CNBoolean  isdef,
uint64_t  caseval,
struct KEInstruction bodyinst,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate case instruction.

Returns
Allocated instruction
Parameters
isdefFlag to present is-default or not
casevalCase value
bodyinstBody instruction
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateCompoundInstruction ( struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate compound instruction.

Returns
Compound instruction
Parameters
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateCreateArrayInstruction ( KERegisterId  dstid,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate create-array instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateCreateDictionaryInstruction ( KERegisterId  dstid,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate create-dictionary instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateCreateFrameInstruction ( KERegisterId  dstid,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate create-frame instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateCreateFunctionInstruction ( KERegisterId  dstid,
struct KEPath funcpath,
struct CNObjectList *  hiddenregs,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate create-function instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
funcpathPath of the body of the function
hiddenregsList if CNNumber to present the local register id
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateExitInstruction ( KERegisterId  codeid,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate exit instruction.

Returns
Allocated instruction
Parameters
codeidExit code register id
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateForeachArrayInstruction ( KERegisterId  elmid,
KERegisterId  arrayid,
struct KEInstruction bodyinst,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate foreach-array instruction.

Returns
Allocated instruction
Parameters
elmidElement variable register id
arrayidArray variable id
bodyinstBody instruction
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateForeachDictionaryInstruction ( KERegisterId  elmid,
KERegisterId  dictid,
struct KEInstruction bodyinst,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate foreach-dictionary instruction.

Returns
Allocated instruction
Parameters
elmidElement variable register id
dictidDictionary variable id
bodyinstBody instruction
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateFunctionInstruction ( struct KEInstruction body,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate function instruction object.

Return values
instAllocated object
NULLAllocation failed
Parameters
bodyBody of the function
linfoLine information
resourceResource to allocate the object
struct KEInstruction* KEAllocateGetArrayInstruction ( KERegisterId  dstid,
KERegisterId  srcid,
KERegisterId  srcindex,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate get-array instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
srcidSource id
srcindexSource index
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateGetDictionaryInstruction ( KERegisterId  dstid,
KERegisterId  srcid,
KERegisterId  srckey,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate get-dictionary instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
srcidSource id
srckeySource key
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateGetFrameInstruction ( KERegisterId  dstid,
KERegisterId  srcid,
struct KEPath srcpath,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate get-frame instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
srcidSource id
srcpathSource path
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateIfInstruction ( KERegisterId  condid,
struct KEInstruction theninst,
struct KEInstruction elseinst,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate if instruction.

Returns
Allocated instruction
Parameters
condidConditional register id
theninstThen part instruction
elseinstElse part instruction
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateLastInstruction ( struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate last instruction.

Returns
Allocated instruction
Parameters
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateMovInstruction ( KEOpcode  opcode,
KERegisterId  dstid,
KERegisterId  srcid,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate move instruction.

Returns
Allocated move instruction
Parameters
opcodeOpcode
dstidDestination register id
srcidSource register id
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateNextInstruction ( struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate next instruction.

Returns
Allocated instruction
Parameters
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateNopInstruction ( struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate nop instruction.

Returns
Nop instruction
Parameters
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateReturnInstruction ( struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate return instruction.

Returns
Allocated instruction
Parameters
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateRootFrameInstruction ( KERegisterId  dstid,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate root-frame instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateSetArrayInstruction ( KERegisterId  dstid,
KERegisterId  dstindex,
KERegisterId  srcid,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate set-array instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
dstindexDestination index id
srcidSource id
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateSetBoolInstruction ( KERegisterId  dstid,
CNBoolean  val,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate set-bool instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
valSource value
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateSetDictionaryInstruction ( KERegisterId  dstid,
KERegisterId  dstkey,
KERegisterId  srcid,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate set-dictionary instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
dstkeyDestination key
srcidSource id
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateSetFloatInstruction ( KERegisterId  dstid,
double  val,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate set-float instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
valSource value
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateSetFrameInstruction ( KERegisterId  dstid,
struct KEPath dstpath,
KERegisterId  srcid,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate set-frame instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
dstpathDestination path
srcidSource id
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateSetSignedIntInstruction ( KERegisterId  dstid,
int64_t  val,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate set-signed-int instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
valSource value
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateSetStringInstruction ( KERegisterId  dstid,
struct CNString *  val,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate set-string instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
valSource value
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateSetUnsignedIntInstruction ( KERegisterId  dstid,
uint64_t  val,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate set-unsigned-int instruction.

Returns
Allocated instruction
Parameters
dstidDestination register id
valSource value
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateSwitchInstruction ( KERegisterId  condid,
struct CNObjectList *  caseinsts,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate switch instruction.

Returns
Allocated instruction
Parameters
condidConditional register id
caseinstsList of case instructions
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateUnaryInstruction ( KEOpcode  opcode,
KERegisterId  dstid,
KERegisterId  srcid,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate unary instruction.

Returns
Allocated instruction
Parameters
opcodeOpcode for this instruction
dstidDestination register id
srcidSource register id
linfoLine information
resourceResource to allocate the instruction
struct KEInstruction* KEAllocateWhileInstruction ( KERegisterId  condid,
struct KEInstruction bodyinst,
struct KELineInfo linfo,
struct CNResource *  resource 
)

Allocate while instruction.

Returns
Allocated instruction
Parameters
condidCondition register id
bodyinstBody instruction
linfoLine information
resourceResource to allocate the instruction
const char* KEOpcodeString ( KEOpcode  src)

Get string to present the opcode.

Returns
String for the source opcode
Parameters
srcSource opcode