prepare refactory

This commit is contained in:
Gabriel Wang 2021-12-29 16:41:03 +00:00
parent aabe910134
commit ec2dbecb07
7 changed files with 139 additions and 16 deletions

View File

@ -114,15 +114,6 @@ int main(void)
/* run mimiScript and get res */
PikaObj *resArgs = obj_runDirect(pikaMain, inputBuff);
/* get system output of mimiScript*/
char *sysOut = args_getSysOut(resArgs->list);
if (!strEqu(sysOut, ""))
{
/* print out the system output */
printf("%s\r\n", sysOut);
}
/* deinit the res */
obj_deinit(resArgs);

View File

@ -328,7 +328,7 @@
<uC99>1</uC99>
<uGnu>0</uGnu>
<useXO>0</useXO>
<v6Lang>3</v6Lang>
<v6Lang>5</v6Lang>
<v6LangP>3</v6LangP>
<vShortEn>1</vShortEn>
<vShortWch>1</vShortWch>
@ -750,6 +750,41 @@
</File>
</Files>
</Group>
<Group>
<GroupName>PLOOC</GroupName>
<Files>
<File>
<FileName>plooc.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\src\3rd-party\PLOOC\plooc.h</FilePath>
</File>
<File>
<FileName>plooc_class.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\src\3rd-party\PLOOC\plooc_class.h</FilePath>
</File>
<File>
<FileName>plooc_class_black_box.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\src\3rd-party\PLOOC\plooc_class_black_box.h</FilePath>
</File>
<File>
<FileName>plooc_class_simple.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\src\3rd-party\PLOOC\plooc_class_simple.h</FilePath>
</File>
<File>
<FileName>plooc_class_simple_c90.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\src\3rd-party\PLOOC\plooc_class_simple_c90.h</FilePath>
</File>
<File>
<FileName>plooc_class_strict.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\src\3rd-party\PLOOC\plooc_class_strict.h</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>::CMSIS</GroupName>
</Group>

View File

@ -25,6 +25,8 @@
* SOFTWARE.
*/
#define __PIKA_OBJ_CLASS_IMPLEMENT
#include "BaseObj.h"
#include "PikaObj.h"
#include "TinyObj.h"

View File

@ -25,6 +25,8 @@
* SOFTWARE.
*/
#define __PIKA_OBJ_CLASS_IMPLEMENT
#include "PikaObj.h"
#include "BaseObj.h"
#include "PikaPlatform.h"

View File

@ -27,19 +27,38 @@
#ifndef _Process__H
#define _Process__H
/*! \NOTE: Make sure #include "plooc_class.h" is close to the class definition
*/
//#define __PLOOC_CLASS_USE_STRICT_TEMPLATE__
#if defined(__PIKA_OBJ_CLASS_IMPLEMENT)
# define __PLOOC_CLASS_IMPLEMENT__
#elif defined(__PIKA_OBJ_CLASS_INHERIT__)
# define __PLOOC_CLASS_INHERIT__
#endif
#include "__pika_ooc.h"
#include "dataArgs.h"
#include "dataLink.h"
#include "dataMemory.h"
typedef struct PikaObj_t PikaObj;
dcl_class(PikaObj);
typedef PikaObj* (*NewFun)(Args* args);
typedef PikaObj* (*InitFun)(PikaObj* self, Args* args);
typedef PikaObj Parameters;
typedef void (*Method)(PikaObj* self, Args* args);
struct PikaObj_t {
/* list */
Args* list;
};
def_class(PikaObj,
private_member(
/* list */
Args* list;
)
)
/* operation */
int32_t obj_deinit(PikaObj* self);
int32_t obj_init(PikaObj* self, Args* args);

View File

@ -25,6 +25,7 @@
* SOFTWARE.
*/
#define __PIKA_OBJ_CLASS_IMPLEMENT
#include "PikaVM.h"
#include "BaseObj.h"
#include "PikaObj.h"
@ -59,9 +60,41 @@ enum Instruct {
DEL,
EST,
BRK,
CTN
CTN,
__INSTRCUTION_CNT,
};
struct __ins_param_t {
char* data;
Parameters* locals;
Parameters* globals;
Queue* invokeQuene0;
Queue* invokeQuene1;
int32_t* jmp;
char* programConter;
char* asmStart;
};
typedef Arg* __ins_handler_t(PikaObj* self, struct __ins_param_t *ptParam);
struct __vm_ins_t {
__ins_handler_t *fnHandler;
};
static
Arg* __ins_non_handler(PikaObj* self, struct __ins_param_t *ptParam)
{
return NULL;
}
const struct __vm_ins_t c_vmInstructionTable[__INSTRCUTION_CNT] = {
[NON] = {
.fnHandler = &__ins_non_handler,
},
};
static char* strs_getLine(Args* buffs, char* code) {
int32_t lineSize = getLineSize(code);
char* line = args_getBuff(buffs, lineSize + 1);
@ -134,6 +167,7 @@ static enum Instruct getInstruct(char* line) {
return NON;
}
static
Arg* pikaVM_runInstruct(PikaObj* self,
Parameters* locals,
Parameters* globals,
@ -144,6 +178,12 @@ Arg* pikaVM_runInstruct(PikaObj* self,
int32_t* jmp,
char* programConter,
char* asmStart) {
//PIKA_ASSERT(instruct < __INSTRCUTION_CNT);
//c_vmInstructionTable[instruct].tHandler()
if (instruct == NUM) {
Arg* numArg = New_arg(NULL);
if (strIsContain(data, '.')) {

34
src/__pika_ooc.h Normal file
View File

@ -0,0 +1,34 @@
/*
* This file is part of the PikaScript project.
* http://github.com/pikastech/pikascript
*
* MIT License
*
* Copyright (c) 2021 lyon ?? liang6516@outlook.com
* Copyright (c) 2021 Gorgon Meducer ?? embedded_zhuoran@hotmail.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef __PIKA_OOC_H__
#define __PIKA_OOC_H__
#include "./3rd-party/PLOOC/plooc_class.h"
#endif