private void Init() { mainScope = new T1Scope(); functionScope = new T1Scope(); List <T1InstructionVariableDeclaration> arguments = new List <T1InstructionVariableDeclaration>(); arguments.Add(new T1InstructionVariableDeclaration(T1VariableType.Int)); arguments.Add(new T1InstructionVariableDeclaration(T1VariableType.Int)); T1ExpressionItem a0 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 4), null, T1Operator.DirectInt); mainScope.AddInstruction(new T1InstructionVariableDeclaration(T1VariableType.Int)); mainScope.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(mainScope, 0, T1VariableType.Int), a0)); // (functionScope 0) = (functionScope 0) ^ (functionScope 1) T1ExpressionItem c0 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 8), null, T1Operator.DirectInt); T1ExpressionItem c1 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 3), null, T1Operator.DirectInt); functionScope.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(functionScope, 0, T1VariableType.Int), c0)); functionScope.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(functionScope, 1, T1VariableType.Int), c1)); T1ExpressionItem f0 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Variable, new T1RuntimeVairableReference(functionScope, 0, T1VariableType.Int)), new T1ExpressionOperand(T1OperandType.Variable, new T1RuntimeVairableReference(functionScope, 1, T1VariableType.Int)), T1Operator.Power); functionScope.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(functionScope, 0, T1VariableType.Int), f0)); // (mainScope 0) = (functionScope 0) / (mainScope 0) T1ExpressionItem f1 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Variable, new T1RuntimeVairableReference(functionScope, 0, T1VariableType.Int)), new T1ExpressionOperand(T1OperandType.Variable, new T1RuntimeVairableReference(mainScope, 0, T1VariableType.Int)), T1Operator.Divide); functionScope.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(functionScope, 1, T1VariableType.Int), f1)); mainScope.AddInstruction(new T1InstructionFunctionDeclaration(arguments, T1VariableType.Int, 0, functionScope)); mainScope.AddInstruction(new T1InstructionFunctionCall(arguments, 0)); }
public void Init() { mainScope = new T1Scope(); mainScope.AddInstruction(new T1InstructionLabelSet(0)); mainScope.AddInstruction(new T1InstructionJump(1)); mainScope.AddInstruction(new T1InstructionJump(0)); mainScope.AddInstruction(new T1InstructionLabelSet(1)); }
private void Init() { mainScope = new T1Scope(); T1ExpressionItem s0 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, "Quiere un botella"), null, T1Operator.DirectString); T1ExpressionItem s1 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, " o "), null, T1Operator.DirectString); T1ExpressionItem s2 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, "una vaso?"), null, T1Operator.DirectString); T1ExpressionItem e1 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Expression, s0), new T1ExpressionOperand(T1OperandType.Expression, s1), T1Operator.Concatanate); T1ExpressionItem e2 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Expression, e1), new T1ExpressionOperand(T1OperandType.Expression, s2), T1Operator.Concatanate); mainScope.AddInstruction(new T1InstructionVariableDeclaration(T1VariableType.String)); mainScope.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(mainScope, 0, T1VariableType.String), new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Expression, e2), null, T1Operator.DirectString))); }
private void Init() { scope1 = new T1Scope(); // set label 0 // v[0] = 0 // v[1] = 99 // if(v[0] != 0) goto label 1 // v[1] = 128 // set label 1 scope1.AddInstruction(new T1InstructionVariableDeclaration(T1VariableType.Int)); scope1.AddInstruction(new T1InstructionVariableDeclaration(T1VariableType.Int)); T1ExpressionItem a0 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 1), null, T1Operator.DirectInt); T1ExpressionItem a1 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 99), null, T1Operator.DirectInt); T1ExpressionItem a2 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 128), null, T1Operator.DirectInt); scope1.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(scope1, 0, T1VariableType.Int), a0)); scope1.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(scope1, 1, T1VariableType.Int), a1)); scope1.AddInstruction(new T1InstructionLabelSet(0)); scope1.AddInstruction(new T1InstructionConditionalJump(1, new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Variable, new T1RuntimeVairableReference(scope1, 0, T1VariableType.Int)), new T1ExpressionOperand(T1OperandType.Constant, 0), T1Operator.Subtract))); scope1.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(scope1, 1, T1VariableType.Int), a2)); scope1.AddInstruction(new T1InstructionLabelSet(1)); scope2 = new T1Scope(); // set label 0 // v[0] = 1 // v[1] = 99 // if(v[0] != 0) goto label 1 // v[1] = 128 // set label 1 scope2.AddInstruction(new T1InstructionVariableDeclaration(T1VariableType.Int)); scope2.AddInstruction(new T1InstructionVariableDeclaration(T1VariableType.Int)); a0 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 0), null, T1Operator.DirectInt); a1 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 99), null, T1Operator.DirectInt); a2 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 128), null, T1Operator.DirectInt); scope2.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(scope2, 0, T1VariableType.Int), a0)); scope2.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(scope2, 1, T1VariableType.Int), a1)); scope2.AddInstruction(new T1InstructionLabelSet(0)); scope2.AddInstruction(new T1InstructionConditionalJump(1, new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Variable, new T1RuntimeVairableReference(scope2, 0, T1VariableType.Int)), new T1ExpressionOperand(T1OperandType.Constant, 0), T1Operator.Subtract))); scope2.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(scope2, 1, T1VariableType.Int), a2)); scope2.AddInstruction(new T1InstructionLabelSet(1)); }
public void Init() { mainScope = new T1Scope(); mainScope.AddInstruction(new T1InstructionVariableDeclaration(T1VariableType.Int)); mainScope.AddInstruction(new T1InstructionVariableDeclaration(T1VariableType.Double)); mainScope.AddInstruction(new T1InstructionVariableDeclaration(T1VariableType.Byte)); mainScope.AddInstruction(new T1InstructionVariableDeclaration(T1VariableType.String)); mainScope.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(mainScope, 0, T1VariableType.Int), new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 44), null, T1Operator.DirectInt))); mainScope.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(mainScope, 1, T1VariableType.Double), new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 999.91), null, T1Operator.DirectNumeric))); mainScope.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(mainScope, 2, T1VariableType.Byte), new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, (byte)241), null, T1Operator.DirectByte))); mainScope.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(mainScope, 3, T1VariableType.String), new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, "The new valUe"), null, T1Operator.DirectString))); }
public void Init() { mainScope = new T1Scope(); T1ExpressionItem c0 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 5), null, T1Operator.DirectInt); T1ExpressionItem c1 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 14), null, T1Operator.DirectInt); T1ExpressionItem c2 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 14), null, T1Operator.DirectInt); T1ExpressionItem c3 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 8), null, T1Operator.DirectInt); T1ExpressionItem c4 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Constant, 1), null, T1Operator.DirectInt); T1ExpressionItem e1 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Expression, c0), new T1ExpressionOperand(T1OperandType.Expression, c1), T1Operator.Add); T1ExpressionItem e2 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Expression, c2), new T1ExpressionOperand(T1OperandType.Expression, c3), T1Operator.Subtract); T1ExpressionItem e0 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Expression, e1), new T1ExpressionOperand(T1OperandType.Expression, e2), T1Operator.Multiply); T1ExpressionItem f0 = new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Expression, c0), null, T1Operator.DirectInt); mainScope.AddInstruction(new T1InstructionVariableDeclaration(T1VariableType.Int)); mainScope.AddInstruction(new T1InstructionVariableDeclaration(T1VariableType.Int)); mainScope.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(mainScope, 0, T1VariableType.Int), new T1ExpressionItem(new T1ExpressionOperand(T1OperandType.Expression, e0), new T1ExpressionOperand(T1OperandType.Expression, c4), T1Operator.ShiftRight))); mainScope.AddInstruction(new T1InstructionAssignment(new T1RuntimeVairableReference(mainScope, 1, T1VariableType.Int), f0)); }