*** empty log message ***

This commit is contained in:
2005-06-29 12:02:39 +00:00
parent 45522a2ab1
commit f11c7a3046
4 changed files with 74 additions and 11 deletions

View File

@ -1,9 +1,10 @@
/*
* $Id: parser.c,v 1.43 2005-06-29 10:56:42 bacon Exp $
* $Id: parser.c,v 1.44 2005-06-29 12:02:39 bacon Exp $
*/
#include <xp/stx/parser.h>
#include <xp/stx/misc.h>
#include <xp/stx/class.h>
#if defined(__BORLANDC__) || defined(_MSC_VER)
#define INLINE
@ -158,7 +159,9 @@ const xp_char_t* xp_stx_parser_error_string (xp_stx_parser_t* parser)
XP_TEXT("no closing parenthesis"),
XP_TEXT("block argument name missing"),
XP_TEXT("block argument list not closed"),
XP_TEXT("block not closed")
XP_TEXT("block not closed"),
XP_TEXT("undeclared name")
};
if (parser->error_code >= 0 &&
@ -544,6 +547,7 @@ static int __parse_assignment (
*/
xp_size_t i;
xp_stx_class_t* class_obj;
for (i = 0; i < parser->temporary_count; i++) {
if (xp_strcmp (target, parser->temporary[i]) == 0) {
@ -551,17 +555,43 @@ xp_char_t buf[100];
if (__parse_expression(parser) == -1) return -1;
xp_sprintf (buf, xp_countof(buf), XP_TEXT("%d"), i);
EMIT_CODE (parser, XP_TEXT("AssignTemporary"), buf);
EMIT_CODE (parser, XP_TEXT("ASSIGN_TEMPORARY"), buf);
return 0;
}
}
/* TODO: check it in instance variable */
class_obj = (xp_stx_class_t*)
XP_STX_WORD_OBJECT(parser->stx, parser->method_class);
xp_assert (class_obj != XP_NULL);
if (class_obj->header.class == parser->stx->class_metaclass) {
/* metaclass */
/* TODO: can metaclasses have instance variables? */
}
else {
xp_size_t size;
xp_stx_word_object_t* array;
size = XP_STX_SIZE(parser->stx, class_obj->variables);
array = XP_STX_WORD_OBJECT(parser->stx, class_obj->variables);
for (i = 0; i < size; i++) {
const xp_char_t* iname =
&XP_STX_CHARAT(parser->stx, array->data[i], 0);
if (xp_strcmp(target, iname) == 0) {
xp_char_t buf[100];
if (__parse_expression(parser) == -1) return -1;
xp_sprintf (buf, xp_countof(buf), XP_TEXT("%d"), i);
EMIT_CODE (parser, XP_TEXT("ASSIGN_INSTANCE"), buf);
return 0;
}
}
}
/* TODO: check it in class variables */
/* TODO: global, but i don't like this idea */
parser->error_code = XP_STX_PARSER_ERROR_UNDECLARED_NAME;
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: parser.h,v 1.24 2005-06-23 07:20:44 bacon Exp $
* $Id: parser.h,v 1.25 2005-06-29 12:02:39 bacon Exp $
*/
#ifndef _XP_STX_PARSER_H_
@ -38,7 +38,9 @@ enum
XP_STX_PARSER_ERROR_NO_RPAREN,
XP_STX_PARSER_ERROR_BLOCK_ARGUMENT_NAME,
XP_STX_PARSER_ERROR_BLOCK_ARGUMENT_LIST,
XP_STX_PARSER_ERROR_BLOCK_NOT_CLOSED
XP_STX_PARSER_ERROR_BLOCK_NOT_CLOSED,
XP_STX_PARSER_ERROR_UNDECLARED_NAME
};
enum
@ -85,6 +87,7 @@ extern "C" {
xp_stx_parser_t* xp_stx_parser_open (xp_stx_parser_t* parser, xp_stx_t* stx);
void xp_stx_parser_close (xp_stx_parser_t* parser);
const xp_char_t* xp_stx_parser_error_string (xp_stx_parser_t* parser);
int xp_stx_parser_parse_method (
xp_stx_parser_t* parser, xp_word_t method_class, void* input);