-Subproject commit ba9550c1d998f0ddf81b901e633c901ebc92cb18
+Subproject commit 31bfb80acafe4235a0446cde7c93b0e3687d503c
12 => var int i;
-<<<i $ Ptr:[int] >>>;
+<<<i $ Ptr:[int] >>>;
Ast tree;
Nspc nspc;
struct Map_ lbls;
- GwText *docstr;
m_bool error;
m_bool global;
uint16_t ref;
m_uint* ptr;
Func func_ref;
} d;
- GwText *docstr;
uint16_t ref;
ae_flag flag;
enum vflag vflag;
}
ANN m_bool gwi_run(const Gwion gwion, m_bool (*f)(const Gwi));
-
-ANN m_bool gwi_doc(const Gwi gwi, const m_str name, const m_str doc);
#endif
ANN void free_context(const Context a, Gwion gwion) {
nspc_remref(a->nspc, gwion);
free_mstr(gwion->mp, a->name);
- if(a->docstr)
- free_text(a->docstr);
mp_free(gwion->mp, Context, a);
}
xfree(a->d.ptr);
if(is_class(gwion, t))
type_remref(t, gwion);
- if(a->docstr)
- free_text(a->docstr);
mp_free(gwion->mp, ValueFrom, a->from);
mp_free(gwion->mp, Value, a);
}
gwion->env->name = name;
return ret;
}
-
-ANN m_bool gwi_doc(const Gwi gwi, const m_str name, const m_str doc) {
- DECL_OB(const Value, v, = nspc_lookup_value0(gwi->gwion->env->curr, insert_symbol(gwi->gwion->st, name)))
- v->docstr = new_text(gwi->gwion->mp);
- text_add(v->docstr, doc);
- return GW_OK;
-}
OP_CHECK(opck_object_dot);
OP_EMIT(opem_object_dot);
+
+static OP_CHECK(opck_basic_ctor) {
+ const Exp_Call* call = (Exp_Call*)data;
+ ERR_N(exp_self(call)->pos, _("can't call a non-callable value"))
+}
+
ANN static m_bool import_core_libs(const Gwi gwi) {
const Type t_class = gwi_mk_type(gwi, "@Class", SZ_INT, NULL);
set_tflag(t_class, tflag_infer);
GWI_BB(gwi_oper_end(gwi, ">", instr_class_gt))
GWI_BB(gwi_oper_end(gwi, "<=", instr_class_le))
GWI_BB(gwi_oper_end(gwi, "<", instr_class_lt))
+
+ GWI_BB(gwi_oper_ini(gwi, NULL, (m_str)OP_ANY_TYPE, NULL))
+ GWI_BB(gwi_oper_add(gwi, opck_basic_ctor))
+ GWI_BB(gwi_oper_end(gwi, "@ctor", NULL))
return GW_OK;
}
struct FptrInfo info = { impl->e->info->type->info->func, impl->t->info->func,
impl->e, impl->e->pos };
CHECK_BO(fptr_do(env, &info))
- return ((Exp)impl->e)->info->cast_to = impl->t;
+ return impl->t;
}
static OP_EMIT(opem_fptr_impl) {
const Type r = imp->t;
if(check_nonnull(env, l, r, "implicitly cast", imp->e->pos) == env->gwion->type[et_null])
return env->gwion->type[et_null];
- imp->e->info->cast_to = r;
return imp->t;
}
ANN /*static*/ Type scan_class(const Env env, const Type t, const Type_Decl* td);
static Type opck_object_scan(const Env env, const struct TemplateScan *ts) {
- if(ts->t->info->cdef && ts->t->info->cdef->base.tmpl->call)
+ if(ts->td->types)
return scan_class(env, ts->t, ts->td) ?: env->gwion->type[et_null];
ERR_N(td_pos(ts->td), _("you must provide template types for type '%s'"), ts->t->name)
}
OP_CHECK(opck_usr_implicit) {
struct Implicit* imp = (struct Implicit*)data;
- imp->e->info->cast_to = imp->t;
return imp->t;
}
}
static OP_CHECK(opck_implicit_i2f) {
- struct Implicit* imp = (struct Implicit*)data;
- return imp->e->info->cast_to = env->gwion->type[et_float];
+ return env->gwion->type[et_float];
}
#define CHECK_FF(op, check, func) _CHECK_OP(op, check, float_##func)
const m_str access = exp_access(e);
if(access)
ERR_N(e->pos, _("can't cast %s value to Ptr"), access);
- e->info->cast_to = imp->t;
exp_setvar(e, 1);
const Type t = get_type(imp->t);
if(!tflag(t, tflag_check))
ANN static m_bool check_stmt_list(const Env env, Stmt_List list);
ANN m_bool check_class_def(const Env env, const Class_Def class_def);
-ANN static m_bool check_internal(const Env env, const Symbol sym,
+ANN static Type check_internal(const Env env, const Symbol sym,
const Exp e, const Type t) {
struct Implicit imp = { .e=e, .t=t, .pos=e->pos };
struct Op_Import opi = { .op=sym, .lhs=e->info->type,
.rhs=t, .data=(uintptr_t)&imp, .pos=e->pos, .op_type=op_implicit };
- CHECK_OB(op_check(env, &opi))
- assert(e->info->nspc);
- return GW_OK;
+ return op_check(env, &opi);
}
ANN m_bool check_implicit(const Env env, const Exp e, const Type t) {
if(e->info->type == t)
return GW_OK;
const Symbol sym = insert_symbol("@implicit");
- return info->cast_to = check_internal(env, sym, e, t);
+ return (e->info->cast_to = check_internal(env, sym, e, t)) ? GW_OK : GW_ERROR;
}
ANN m_bool check_subscripts(Env env, const Array_Sub array, const m_bool is_decl) {
#define scan2_stmt_break (void*)dummy_func
#define scan2_stmt_return scan2_stmt_exp
-#define DOCSTRING(name, value, prefix) \
-ANN static inline GwText* name##_docstr(const Env env) { \
- prefix \
- if(!(value)) \
- (value) = new_text(env->gwion->mp); \
- return value; \
-}
-DOCSTRING(context, env->context->docstr,)
-DOCSTRING(func, env->func->value_ref->docstr,)
-DOCSTRING(class, v->docstr, const Value v = nspc_lookup_value0(env->curr->parent, insert_symbol(env->class_def->name));)
-typedef GwText* (*docfunc)(Env);
-
ANN static m_bool scan2_stmt_pp(const Env env, const Stmt_PP stmt) {
if(stmt->pp_type == ae_pp_include)
env->name = stmt->data;
- else if(stmt->pp_type == ae_pp_docstr) {
- const docfunc df = env->func ? func_docstr : env->class_def ? class_docstr : context_docstr;
- GwText *docstr = df(env);
- text_add(docstr, stmt->data);
-
- }
return GW_OK;
}
-#! [contains] function call using a non-function value
+#! [contains] non-callable value
null();
-#! [contains] template call of non-function value
+#! [contains] tests/error/non_function_template.gw
var int test;
test:[int]();
--- /dev/null
+#!! document file
+
+fun void test() {
+ #!! Document file level function
+}
+
+class C {
+ #!! document class
+
+ fun void test() {
+ #!! Document member function
+ }
+}
+
+<<< "Ensuring it parses: declaring a variable:", var C c >>>;
-Subproject commit 011948c5a80f49af50d6e6a35aacd8e70eb53ec6
+Subproject commit 18330ebb0d167c9f1e30cdc97bfc0c86fa329dc0