Example #1
0
        private void Allocate(string ident, int funcIndex, FusionCore.PrimitiveType datatype, int datasize = (int)FusionCore.DSASM.Constants.kPrimitiveSize)
        {
            FusionCore.DSASM.SymbolNode node = new FusionCore.DSASM.SymbolNode();
            node.name = ident;
            node.size = datasize;
            node.functionIndex = funcIndex;
            node.datatype = datatype;
            node.isArgument = false;

            // TODO Jun: Shouldnt the offset increment be done upon successfully appending the symbol?
            if ((int)FusionCore.DSASM.Constants.kGlobalScope == funcIndex)
            {
                node.index = globOffset;
                globOffset += node.size;
            }
            else
            {
                node.index = -2 - baseOffset;
                baseOffset += node.size;
            }
            symbols.Update(node);
        }
Example #2
0
        private void emitBinary(FusionCore.DSASM.OpCode opcode, FusionCore.DSASM.Operand op1, FusionCore.DSASM.Operand op2)
        {
            setEntry();
            FusionCore.DSASM.Instruction instr = new FusionCore.DSASM.Instruction();
            instr.opCode = opcode;
            instr.op1 = op1;
            instr.op2 = op2;

            // For debugging, assert here but these should raise runtime errors in the VM
            Debug.Assert(FusionCore.DSASM.AddressType.VarIndex == op1.optype || FusionCore.DSASM.AddressType.Register == op1.optype);

            pc++;
            executable.instructionList.Add(instr);
        }
Example #3
0
        private void emitPop(FusionCore.DSASM.Operand op)
        {
            FusionCore.DSASM.Instruction instr = new FusionCore.DSASM.Instruction();
            instr.opCode = FusionCore.DSASM.OpCode.POP;
            instr.op1 = op;

            // For debugging, assert here but these should raise runtime errors in the VM
            Debug.Assert(FusionCore.DSASM.AddressType.VarIndex == op.optype || FusionCore.DSASM.AddressType.Register == op.optype);

            pc++;
            executable.instructionList.Add(instr);
        }
Example #4
0
        private void emitPush(FusionCore.DSASM.Operand op)
        {
            setEntry();
            FusionCore.DSASM.Instruction instr = new FusionCore.DSASM.Instruction();
            instr.opCode = FusionCore.DSASM.OpCode.PUSH;
            instr.op1 = op;

            pc++;
            executable.instructionList.Add(instr);
        }
Example #5
0
 FusionCore.DSASM.AddressType getOpType(FusionCore.PrimitiveType type)
 {
     FusionCore.DSASM.AddressType optype = FusionCore.DSASM.AddressType.Int;
     // Data coercion for the prototype
     // The JIL executive handles int primitives
     if (FusionCore.PrimitiveType.kTypeInt == type
         || FusionCore.PrimitiveType.kTypeDouble == type
         || FusionCore.PrimitiveType.kTypeBool == type
         || FusionCore.PrimitiveType.kTypeChar == type
         || FusionCore.PrimitiveType.kTypeString == type)
     {
         optype = FusionCore.DSASM.AddressType.Int;
     }
     else if (FusionCore.PrimitiveType.kTypeVar == type)
     {
         optype = FusionCore.DSASM.AddressType.VarIndex;
     }
     else if (FusionCore.PrimitiveType.kTypeReturn == type)
     {
         optype = FusionCore.DSASM.AddressType.Register;
     }
     else
     {
         Debug.Assert(false);
     }
     return optype;
 }
Example #6
0
        private void AllocateArg(string ident, int funcIndex, FusionCore.PrimitiveType datatype, int datasize = (int)FusionCore.DSASM.Constants.kPrimitiveSize)
        {
            FusionCore.DSASM.SymbolNode node = new FusionCore.DSASM.SymbolNode();
            node.name = ident;
            node.size = datasize;
            node.functionIndex = funcIndex;
            node.datatype = datatype;
            node.isArgument = true;

            int locOffset = functions.functionList[funcIndex].localCount;

            // This is standard
            argOffset++;
            node.index = -2 - (locOffset + argOffset);

            // This is through FEP
            //node.index = argOffset++;

            symbols.Update(node);
        }